pub/scm/utils/kernel/virtme/virtme.git  about / heads / tags
An easy way to virtualize the running system
$ git log --pretty=format:'%h %s (%cs)%d'
3dfc002 run.py: Fix deprecated qemu readonly statement (2021-11-18)
	(HEAD -> master)
beb8514 aarch64: Fix aarch64 support (2020-11-12)
1ab5dea Merge branch 'arighi/master' into master (2020-11-11)
8af8c39 virtme-init: Clean up /etc/shadow generation (2020-11-11)
ce55e31 Merge pull request #63 from marcosps/fix_silentconfig (2020-11-11)
0fca4d9 Merge pull request #66 from morbidrsa/smp (2020-11-11)
5b62d47 run.py: introduce '--cpus' argument (2020-11-11)
bd1d869 virtme-init: generate dummy /etc/shadow (2020-11-02)
d8fa047 virtme-configkernel: Fix --allnoconfig option (2020-08-20)
88cd30f Minor sanitize_disk_args() cleanup (2020-07-20)
...

$ git cat-file blob HEAD:README.md
What is virtme?
===============

Virtme is a set of simple tools to run a virtualized Linux kernel that
uses the host Linux distribution or a simple rootfs instead of a whole
disk image.

Virtme is tiny, easy to use, and makes testing kernel changes quite simple.

Some day this might be useful as a sort of sandbox.  Right now it's not
really configurable enough for that.

Virtme is hosted at kernel.org in utils/kernel/virtme/virtme.git ([web][korg-web] | [git][korg-git]).  It's mirrored [on github][github].  Please submit bugs
and PRs via github.  Release tarballs are at [kernel.org in /pub/linux/utils/kernel/virtme][korg-releases].

[korg-web]: https://git.kernel.org/cgit/utils/kernel/virtme/virtme.git "virtme on kernel.org"
[korg-git]: git://git.kernel.org/pub/scm/utils/kernel/virtme/virtme.git "git address"
[korg-releases]: https://mirrors.edge.kernel.org/pub/linux/utils/kernel/virtme/releases/ "virtme releases on kernel.org"
[github]: https://github.com/amluto/virtme

How to use virtme
=================

You'll need a Linux kernel that has these options (built-in or as modules)

    CONFIG_VIRTIO
    CONFIG_VIRTIO_PCI
    CONFIG_NET_9P
    CONFIG_NET_9P_VIRTIO
    CONFIG_9P_FS

For networking support, you also need CONFIG_VIRTIO_NET.

For script support, you need CONFIG_VIRTIO_CONSOLE.

For disk support, you need CONFIG_SCSI_VIRTIO.

That kernel needs to be sane.  Your kernel is probably sane, but allmodconfig and allyesconfig generate insane kernels.  Sanity includes:

    CONFIG_CMDLINE_OVERRIDE=n
    CONFIG_BINFMT_SCRIPT=y
    CONFIG_TMPFS=y

You may also have better luck if you set:

    CONFIG_EMBEDDED=n
    CONFIG_EXPERT=n
    CONFIG_MODULE_SIG_FORCE=n
    CONFIG_DEVTMPFS=y

An easy, somewhat-reliable way to generate a working config is via
the virtme-configkernel. It needs to be run on a kernel source directory,
like:

    virtme-configkernel --arch=ARCH --defconfig

Your host system will need to satisfy some prerequisites:

* You need Python 3.3 or higher.
* QEMU 1.6 or higher is recommended.  QEMU 1.4 and 1.5 are partially supported using a rather ugly kludge.
  * You will have a much better experience if KVM is enabled.  That means that you should be on bare metal with hardware virtualization (VT-x or SVM) enabled or in a VM that supports nested virtualization.  On some Linux distributions, you may need to be a member of the "kvm" group.  Using VirtualBox or most VPS providers will fall back to emulation.
* Depending on the options you use, you may need a statically linked `busybox` binary somewhere in your path.

Once you have such a kernel, run one of:

* virtme-run --kdir PATH_TO_KERNEL_TREE
* virtme-run --installed-kernel
* virtme-run --installed-kernel VERSION
* virtme-run --kimg PATH_TO_KERNEL_IMAGE

With --installed-kernel or --kdir, modules associated with the kernel will be available in the VM.  With --kdir in particular, you will either need to follow the directions that virtme-run prints or specify --mods=auto to make this work.  With --kimg, modules are not supported.

You can then do things like `cd /home/username` and you will have readonly
access to all your files.

Virtme gives you console input and output by default.  Type ctrl-a x to exit.
Type ctrl-a c to access the QEMU monitor.

For now, the virtme console is a serial console -- virtconsole seems to be unusably buggy.  I don't know of any way to keep the tty state in sync between the host and guest, so resizing the host window after starting the guest may confuse guest libraries like readline.

Graphics
========

If you want graphical output instead of console output, pass --graphics.  Note that this is the opposite of QEMU's default behavior.

Architecture support
====================

By default, virtme will use whatever architecture would be shown by `uname -m`.  You can override this with `--arch`.  Note that you may need to do some poorly documented fiddling for now to get non-native architectures working, and you will almost certainly need to set `--root` to a root that matches the architecture.

In general, the easiest way to configure a working kernel is to run:

    virtme-configkernel --arch=ARCH --defconfig

x86
---

x86 (both x86_64 and i386) is fully supported, although some odd KVM configurations may cause problems.

ARM
---

ARM is supported using qemu's `vexpress-a15` machine.  There is no built-in KVM support for ARM right now, although it might work by accident -- I don't own a real KVM-capable ARM machine to test it on.

If you use any mode other than --kdir, you'll need to manually set QEMU's -dtb option.  I'm not sure why -- I assumed that QEMU would provide its own device tree, but this doesn't seem to be the case.

Aarch64
-------

Aarch64 works out of the box if you have a new enough version of QEMU.

PPC64
-----

PPC64 appears to be reasonably functional.

RISC-V
------

riscv64 works out of the box, but you'll neet at least QEMU-4.1.0 to be
able to run `vmlinux`-style kernels.  riscv32 is not supported because
there are no existing userspace images for it.  Support is provided via
QEMU's `virt` machine with OpenSBI for firmware.

Others
------

Other architectures may or may not work.  Adding support is trivial, so ping me if you need another architecture.  Unrecognized architectures use a set of maybe-acceptable defaults.

Upcoming features
=================

In the near term, the high-priority features are:

* Support for modular virtfs and 9p for non-installed kernels.

Contributing
============

Please see DCO.txt

# heads (aka `branches'):
$ git for-each-ref --sort=-creatordate refs/heads \
	--format='%(HEAD) %(refname:short) %(subject) (%(creatordate:short))'
* master       run.py: Fix deprecated qemu readonly statement (2021-11-18)
  crash-virtconsole virtme-run: Add --console (2014-03-31)

# tags:
$ git for-each-ref --sort=-creatordate refs/tags \
	--format='%(refname:short) %(subject) (%(creatordate:short))'
v0.1.1       Version 0.1.1 (2019-10-10) tar.gz
v0.1         Version 0.1 (2019-10-10) tar.gz
v0.0.1       Virtme 0.0.1 (2014-09-09) tar.gz

# associated public inboxes:
# (number on the left is used for dev purposes)
          5 lkml
          4 linux-riscv
          4 bpf
          4 qemu-devel
          4 netdev
          4 linux-kselftest
          4 git
          3 linux-nfs
          3 netfilter-devel
          3 linux-cifs
          3 xen-devel
          3 linux-gpio
          3 linux-rdma
          3 dpdk-dev
          3 linuxppc-dev
          3 util-linux
          3 u-boot
          3 buildroot
          3 yocto
          3 poky
          3 qemu-riscv
          3 grub-devel
          2 linux-samsung-soc
          2 linux-wireless
          2 linux-mtd
          2 linux-nvme
          2 linux-xfs
          2 linux-mediatek
          2 linux-crypto
          2 linux-acpi
          2 linux-fsdevel
          2 linux-devicetree
          2 linux-amlogic
          2 linux-erofs
          2 linux-mm
          2 linux-iommu
          2 linux-media
          2 stable
          2 linux-mips
          2 fstests
          2 linux-pm
          2 linux-rtc
          2 linux-input
          2 alsa-devel
          2 linux-scsi
          2 linux-btrfs
          2 linux-arm-kernel
          2 kvmarm
          2 driverdev-devel
          2 linux-usb
          2 selinux
          2 linux-clk
          2 linux-iio
          2 linux-ext4
          2 linux-security-module
          2 linux-pci
          2 linux-f2fs-devel
          2 kvm
          2 linux-modules
          2 linux-rt-users
          2 linux-bluetooth
          2 linux-ide
          2 linux-serial
          2 linux-watchdog
          2 linux-trace-devel
          2 backports
          2 linux-doc
          2 linux-man
          2 linux-mmc
          2 amd-gfx
          2 dri-devel
          2 intel-gfx
          2 linux-api
          2 linux-omap
          2 linux-spi
          2 linux-i2c
          2 linux-sparse
          2 linux-tegra
          2 lttng-dev
          2 virtualization
          2 linux-kbuild
          2 linux-arch
          2 linux-can
          2 containers
          2 linux-rockchip
          2 linux-raid
          2 openbmc
          2 dm-devel
          2 linux-fbdev
          2 linux-cxl
          2 linux-perf-users
          2 linux-sh
          2 nouveau
          2 linux-s390
          2 linux-coco
          2 fio
          2 iwd
          2 ltp
          2 yocto-meta-freescale
          2 openembedded-core
          2 yocto-toaster
          2 yocto-meta-arm
          2 openembedded-devel
          2 bitbake-devel
          2 yocto-meta-virtualization
          2 yocto-meta-ti
          2 yocto-meta-arago
          2 outreachy
          2 openrisc
          2 intel-wired-lan
          2 kexec
          2 batman
          2 intel-xe
          2 linux-um
          2 virtio-comment
          2 cluster-devel
          2 kvm-ppc
          2 linux-hexagon
          2 reiserfs-devel
          2 lvm-devel
          2 virtio-fs
          2 ../../../../../../fuego
          2 ../../../../../../igt-dev
          1 linux-fscrypt
          1 cocci
          1 linux-block
          1 live-patching
          1 linux-efi
          1 linux-integrity
          1 linux-edac
          1 linux-arm-msm
          1 linux-nvdimm
          1 linux-snps-arc
          1 linux-hwmon
          1 linux-renesas-soc
          1 kernel-hardening
          1 dmaengine
          1 linux-next
          1 linux-parisc
          1 linux-leds
          1 kernelnewbies
          1 linux-sgx
          1 linux-hyperv
          1 workflows
          1 rcu
          1 selinux-refpolicy
          1 linux-m68k
          1 linux-i3c
          1 linux-spdx
          1 linux-wpan
          1 ksummit-discuss
          1 wireguard
          1 io-uring
          1 linux-kernel-mentees
          1 linux-csky
          1 tpmdd-devel
          1 linux-unionfs
          1 linux-firmware
          1 cip-dev
          1 linux-audit
          1 linux-remoteproc
          1 linux-dash
          1 linux-bcache
          1 mm-commits
          1 linux-pwm
          1 linux-fpga
          1 ceph-devel
          1 xdp-newbies
          1 platform-driver-x86
          1 phone-devel
          1 linux-hardening
          1 dash
          1 keyrings
          1 linux-sctp
          1 target-devel
          1 lustre-devel
          1 soc
          1 ocfs2-devel
          1 rust-for-linux
          1 ath10k
          1 ath11k
          1 linux-phy
          1 kernel-janitors
          1 sparclinux
          1 linux-staging
          1 linux-sunxi
          1 mptcp
          1 regressions
          1 ksummit
          1 b43-dev
          1 nvdimm
          1 linux-nfc
          1 linux-bcachefs
          1 ath9k-devel
          1 ntfs3
          1 llvm
          1 ell
          1 ofono
          1 yocto-docs
          1 linux-patches
          1 chrome-platform
          1 ntb
          1 xenomai
          1 damon
          1 asahi
          1 loongarch
          1 imx
          1 ath12k
          1 b4-sent
          1 linux-trace-kernel
          1 oe-linux-nfc
          1 oe-kbuild-all
          1 oe-chipsec
          1 virtio-dev
          1 v9fs
          1 ecryptfs
          1 linux-ia64
          1 kbd
          1 autofs
          1 cpufreq
          1 dccp
          1 cgroups
          1 devicetree-spec
          1 devicetree-compiler
          1 initramfs
          1 hail-devel
          1 kvm-ia64
          1 linux-8086
          1 kernel-testers
          1 linux-alpha
          1 linux-btrace
          1 linux-embedded
          1 linux-hams
          1 linux-hotplug
          1 linux-laptop
          1 linux-sound
          1 trinity
          1 linux-metag
          1 linux-x25
          1 linux-nilfs
          1 lvs-devel
          1 netfilter
          1 linux-oxnas
          1 u-boot-amlogic
          1 lm-sensors
          1 acpica-devel
          1 perfbook
          1 smatch
          1 ../../../../../../wireless-regdb
          1 ../../../../../../powertop

git clone https://yhbt.net/lore/pub/scm/utils/kernel/virtme/virtme.git