Tuesday, November 13, 2012

qemu init scirpt for gentoo

It's over a year ago since i've posted a gentoo init script for qemu guests. Privately i've updated and added features regularly. Now i've uploaded an updated version which has lots of changes and an easier configuration file.

The most notable changes/features are:
  • per default i'm using now the qxl video card for guests
  • for many options there are default's which the init-script would use if there are no settings
  • guests don't have to run as root, you can specify an different user
  • spice support (you can choose between vnc and spice)
  • qemu guest agent support (qga has to be installed in the guest)
  • snapshot mode, guests can run in an snapshot-mode where changes won't be saved.

init script start and stop
The script needs following packages to work:
  • app-emulation/qemu
  • sys-apps/coreutils
  • sys-apps/net-tools
  • sys-apps/grep
  • sys-apps/iproute2
  • sys-process/procps
  • net-misc/bridge-utils
  • net-analyzer/netcat6
Download the script: Link

Basically most of these packages should be already installed on any system. However, you must configure an bridge first otherwise networking wouldn't work. To install the script there are just a few steps to do. First, extract the file:
 tar xzf qemu-init-script.tar.gz -C /etc/init.d/  

Move the default.config to /etc/conf.d/:
 mv /etc/init.d/kvm.config /etc/conf.d/  

For every guest you have to create an symlink to the init script (example for a guest called windows7):
 cd /etc/init.d/  
 ln -s kvm.init kvm.windows7  

You also have to create an new config file for this windows7 guest:
 cd /etc/conf.d/  
 cp kvm.default kvm.windows7  

Afterwards you have to edit the config to your needs. Basically you must change at least VM_IMAGE and BRDEV. BRDEV is the name of your bridge and VM_IMAGE is the path to the image file or lvm2 partition.
For an new guest you also have to change the boot settings. VM_BOOT_DEV sets how to boot (network/disk/cdrom/floppy), while VM_CDROM should point to an iso file or a cd.
The rest of the config should be quite self explaining. Anyway, i've tried to explain all variables as good as possible.

3 comments:

  1. How about adding support for nen x86_64 guests like qemu-system-arm? And suport for non smp guests?

    ReplyDelete
    Replies
    1. Support for non x86_64 guests is something i clearly want to add. It's my next goal and i hope it won't be to difficult. About non smp guests: What exactly do you mean here? I actually couldn't find a way to "disable" smp in qemu?

      Delete
    2. I forked you on github https://github.com/jlec/qemu-init.
      See the devel branch for my first try on supporting other arches. This is untested and needs probably more work.

      Regarding the smp support, most arm models do not support -smp, so we can't use it by default in the init script.

      Delete