Next: , Previous: , Up: System Configuration   [Contents][Index]


6.2.14 Running GuixSD in a Virtual Machine

To run GuixSD in a virtual machine (VM), one can either use the pre-built GuixSD VM image distributed at ‘ftp://alpha.gnu.org/guix/guixsd-vm-image-0.13.0.314-a8d0c.system.tar.xz’ , or build their own virtual machine image using guix system vm-image (see Invoking guix system). The returned image is in qcow2 format, which the QEMU emulator can efficiently use.

If you built your own image, you must copy it out of the store (see The Store) and give yourself permission to write to the copy before you can use it. When invoking QEMU, you must choose a system emulator that is suitable for your hardware platform. Here is a minimal QEMU invocation that will boot the result of guix system vm-image on x86_64 hardware:

$ qemu-system-x86_64 \
   -net user -net nic,model=virtio \
   -enable-kvm -m 256 /tmp/qemu-image

Here is what each of these options means:

qemu-system-x86_64

This specifies the hardware platform to emulate. This should match the host.

-net user

Enable the unprivileged user-mode network stack. The guest OS can access the host but not vice versa. This is the simplest way to get the guest OS online.

-net nic,model=virtio

You must create a network interface of a given model. If you do not create a NIC, the boot will fail. Assuming your hardware platform is x86_64, you can get a list of available NIC models by running qemu-system-x86_64 -net nic,model=help.

-enable-kvm

If your system has hardware virtualization extensions, enabling the virtual machine support (KVM) of the Linux kernel will make things run faster.

-m 256

RAM available to the guest OS, in mebibytes. Defaults to 128 MiB, which may be insufficient for some operations.

/tmp/qemu-image

The file name of the qcow2 image.

The default run-vm.sh script that is returned by an invocation of guix system vm does not add a -net user flag by default. To get network access from within the vm add the (dhcp-client-service) to your system definition and start the VM using `guix system vm config.scm` -net user. An important caveat of using -net user for networking is that ping will not work, because it uses the ICMP protocol. You’ll have to use a different command to check for network connectivity, for example guix download.

6.2.14.1 Connecting Through SSH

To enable SSH inside a VM you need to add a SSH server like (dropbear-service) or (lsh-service) to your VM. The (lsh-service) doesn’t currently boot unsupervised. It requires you to type some characters to initialize the randomness generator. In addition you need to forward the SSH port, 22 by default, to the host. You can do this with

`guix system vm config.scm` -net user,hostfwd=tcp::10022-:22

To connect to the VM you can run

ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -p 10022

The -p tells ssh the port you want to connect to. -o UserKnownHostsFile=/dev/null prevents ssh from complaining every time you modify your config.scm file and the -o StrictHostKeyChecking=no prevents you from having to allow a connection to an unknown host every time you connect.

6.2.14.2 Using virt-viewer with Spice

As an alternative to the default qemu graphical client you can use the remote-viewer from the virt-viewer package. To connect pass the -spice port=5930,disable-ticketing flag to qemu. See previous section for further information on how to do this.

Spice also allows you to do some nice stuff like share your clipboard with your VM. To enable that you’ll also have to pass the following flags to qemu:

-device virtio-serial-pci,id=virtio-serial0,max_ports=16,bus=pci.0,addr=0x5
-chardev spicevmc,name=vdagent,id=vdagent
-device virtserialport,nr=1,bus=virtio-serial0.0,chardev=vdagent,
name=com.redhat.spice.0

You’ll also need to add the see Spice service.


Next: , Previous: , Up: System Configuration   [Contents][Index]