pub/scm/linux/kernel/git/maz/vminstall.git  about / heads / tags
Random VM creation scripts
$ git log --pretty=format:'%h %s (%cs)%d'
a4d193b Use readonly=on for EFI flash device (2021-10-02)
	(HEAD -> master)
a94d7fa Add license blurb (2021-06-24)
bdaf7ad Fix 32bit documentation (2021-06-24)
8f3ad9e build-cd-image: Add PRESEED_PATH option for alternative pressed file (2021-02-06)
850ce99 runinstallvm: Add TEMPLATE option for self-contained install (2021-02-06)
02791c4 Don't ask about restarting daemons (2021-01-26)
7a4e8db runefivm: Allow multiple tap interfaces (2020-06-08)
58de049 runinstallvm: Fix image path (2020-05-24)
355a85e runefivm: Use gic-version instead of gic_version (2020-05-24)
175a463 runefivm: Use AIO and don't cache disk accesses (2020-05-24)
...

$ git cat-file blob HEAD:README
TiNLV: This is Not LibVirt

<boring>
Everything here is licensed under the GPLv2. Please see the LICENSE
file at the root of the directory.
</boring>

This repository contains a bag of scripts I cobbled together to easily
install and run KVM/arm64 UEFI based VMs, acting as a middle ground
between the full complexity of the QEMU command line and the awkward
abstraction provided by LibVirt. The VMs can either be ephemeral (they
are destroyed on exit) or made persistent (though no effort is made to
keep them running).

There are essentially three major scripts here:

- runefivm.sh runs a guest, taking a bunch of parameters such as the
  disk image, the EFI binary, the number of CPUs...

- runinstallvm.sh is a very simple wrapper for runefivm.sh, creating
  the storage for the VM, and either destroying it once it ends, or
  moving it into a safe location for later reuse.

- build-cd-image is only slightly related to the above. It takes a
  Debian or Ubuntu CD/DVD image, and messes with it enough that it
  becomes an unattended installer. Now also deals with Fedora DVD
  images.

All the scripts are expected to be run from the vminstall
directory. Yes, this is a braindead expectation, and maybe I'll fix it
at some point. Maybe.

* runefivm.sh [QEMU args]

  runefivm.sh is entirely driven by environment variables, and
  provides more or less sensible defaults when the variable is not
  defined:

  - EFI: The EFI (AAVMF) binary. Defaults to
    /usr/share/AAVMF/AAVMF_CODE.fd

  - EFIVAR: The per-VM EFI variable container. Defauts to no variables.

  - DISK: The raw file containing the VM mass storage. Defaults to
    none.

  - BUS: The bus on which the virtio devices are created. Can be
    "device" or "pci", defaults to "pci".

  - NETIF: The host network interface for this VM. Can be a tap or
    macvtap interface (which enables vhost), or "none" (which
    indicates that no networking is to be provided). When absent,
    userspace networking is provided to the guest. Multiple taps
    can be passed as a colon separated list, each of them resulting
    in a guest network interface.

  - GIC: The GIC version. Use "2" to force GICv2, "3" for GICv3+ITS,
    "3,noits" for GICv3 without an ITS. Defaults to "host", which is
    whichever is physically present.

  - BIT: 32 or 64, defaults to 64. If using 32, you will have to
    provide the path to the EFI path using the EFI variable.

  - CPUS: Number of CPUs, defaults to 4.

  - RAM: Memory size, defaults to 1G.

  - CDROM: A cdrom image provided to the guest, defaults to no cdrom
    at all.

  - QEMU: The QEMU binary, defaults to /usr/bin/qemu-system-aarch64.

  Any additional parameter is directly passed to QEMU.

* runinstallvm.sh [QEMU args]

  All the environment variables used by runefivm.sh are equaly valid
  for runinstallvm.sh, with the exception of DISK and EFIVAR (which it
  overrides). In addition, it provides the following:

  - SIZE: Size of the virtio disk storage. Defaults to 16GB.

  - KEEPME: When provided, create a directory with that name, and
    store the VM disk and EFI variables in that directory. Also
    generate a "runvm.sh" script in the same directory, which calls
    runefivm.sh with the right environment variables.

  - TEMPLATE: A disk image that is used to pre-populates the virtio
    disk (useful for things like mini.iso that will pull everything
    from the network).

* build-cd-image source.iso target.iso

  - Debian/Ubuntu: Takes source.iso, adds preseed.cfg to it, add a new
    grub entry for unattended installation, repack the whole thing as
    target.iso. The only VM user is root, password is root. Don't try
    this on a publicly visible box... Depends on the xorriso package
    being installed. If the PRESEED_PATH environment variable is
    defined, feed this to the installer as part of the kernel command
    line. This is useful to point the installer to a remote preseed
    file (PRESEED_PATH="url=http://my.remote.box/preseed.cfg").

Example:

  $ ./build-cd-image ../debian-9.0.0-arm64-netinst.iso ../debian-9.0.0-arm64-netinst-preseed.iso
  $ CDROM=../debian-9.0.0-arm64-netinst-preseed.iso RAM=2G KEEPME=stretch ./runinstallvm.sh
  [halt the VM]
  $ ./stretch/runvm.sh

  - Fedora: Take source.iso, adds a kickstart file and a new grub
    entry, and do the same magic to generate an unattended
    installer. Note that this will only work with a full DVD image,
    and it will probably stop working if packages are missing from the
    image. Same user/passwd as above. Only tested with Fedora 26
    Server DVD image.

# heads (aka `branches'):
$ git for-each-ref --sort=-creatordate refs/heads \
	--format='%(HEAD) %(refname:short) %(subject) (%(creatordate:short))'
* master       Use readonly=on for EFI flash device (2021-10-02)

# tags:
$ git for-each-ref --sort=-creatordate refs/tags \
	--format='%(refname:short) %(subject) (%(creatordate:short))'
# no tags, yet...

# associated public inboxes:
# (number on the left is used for dev purposes)
          2 lkml
          1 linux-xfs
          1 qemu-devel
          1 linux-devicetree
          1 linux-erofs
          1 netdev
          1 xen-devel
          1 linux-arm-kernel
          1 linux-gpio
          1 linux-trace-devel
          1 backports
          1 lttng-dev

git clone https://80x24.org/lore/pub/scm/linux/kernel/git/maz/vminstall.git