0

I'm attempting to boot a Linux VM with a 9p root file system using libvirt. This works perfectly when QEMU is invoked directly, using the following command:

qemu-system-x86_64 -enable-kvm \
-kernel /vmroot/trusty/boot/vmlinuz-3.13.0-24-generic \
-initrd /vmroot/trusty/boot/initrd.img-3.13.0-24-generic \
-fsdev local,id=root9p,path=/vmroot/trusty,security_model=mapped \
-device virtio-9p-pci,fsdev=root9p,mount_tag=root9p \
-nographic \
-append 'root=root9p rw rootfstype=9p rootflags=trans=virtio console=ttyS0'

Now, I'm trying to get the same effect via libvirt using XML configuration. My XML configuration is as follows:

<?xml version="1.0"?>
<domain type='kvm'>
    <name>trusty</name>
    <uuid>618237b9-2f17-4dfc-ba46-dec508d31e4e</uuid>
    <os>
        <type>hvm</type>
        <kernel>/vmroot/trusty/boot/vmlinuz-3.13.0-45-generic</kernel>
        <initrd>/vmroot/trusty/boot/initrd.img-3.13.0-45-generic</initrd>
        <cmdline>root=root9p rw rootfstype=9p rootflags=trans=virtio console=ttyS0</cmdline>
    </os>
    <vcpu>2</vcpu>
    <memory unit='KiB'>524288</memory>
    <on_poweroff>destroy</on_poweroff>
    <on_reboot>restart</on_reboot>
    <on_crash>destroy</on_crash>
    <features>
        <pae/>
        <acpi/>
        <hap/>
    </features>
    <devices>
        <emulator>/usr/bin/qemu-system-x86_64</emulator>
        <serial type='pty'>
            <target port='0'/>
        </serial>
    </devices>
    <filesystem type='mount' accessmode='mapped'>
        <source dir='/vmroot/trusty'/>
        <target dir='root9p'/>
    </filesystem>
</domain>

Now, the native QEMU command line produced from the XML does not contain the necessary options to enable this. The generated command line is:

qemu-system-x86_64 -name trusty -machine pc,accel=kvm,usb=off -m 512 \
-realtime mlock=off -smp 2,sockets=2,cores=1,threads=1 \
-uuid 618237b9-2f17-4dfc-ba46-dec508d31e4e -nographic -no-user-config \
-nodefaults -chardev socket,id=charmonitor,path=/home/user/.config/libvirt/qemu/lib/trusty.monitor,server,nowait \
-mon chardev=charmonitor,id=monitor,mode=control -rtc base=utc \
-no-shutdown -boot strict=on \
-kernel /vmroot/trusty/boot/vmlinuz-3.13.0-45-generic \
-initrd /vmroot/trusty/boot/initrd.img-3.13.0-45-generic \
-append 'root=root9p rw rootfstype=9p rootflags=trans=virtio console=ttyS0' \
-device piix3-usb-uhci,id=usb,bus=pci.0,addr=0x1.0x2 \
-chardev pty,id=charserial0 \
-device isa-serial,chardev=charserial0,id=serial0 \
-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x2 \
-msg timestamp=on

So, how can I get libvirt to do include the -fsdev and additional -device options?

0

Found the solution. Simple configuration error. The <filesystem> element needs to be inside the <devices> element, thus the XML becomes:

<?xml version="1.0"?>
<domain type='kvm'>
    <name>trusty</name>
    <uuid>618237b9-2f17-4dfc-ba46-dec508d31e4e</uuid>
    <os>
        <type>hvm</type>
        <kernel>/vmroot/trusty/boot/vmlinuz-3.13.0-45-generic</kernel>
        <initrd>/vmroot/trusty/boot/initrd.img-3.13.0-45-generic</initrd>
        <cmdline>root=root9p rw rootfstype=9p rootflags=trans=virtio console=ttyS0</cmdline>
    </os>
    <vcpu>2</vcpu>
    <memory unit='KiB'>524288</memory>
    <on_poweroff>destroy</on_poweroff>
    <on_reboot>restart</on_reboot>
    <on_crash>destroy</on_crash>
    <features>
        <pae/>
        <acpi/>
        <hap/>
    </features>
    <devices>
        <emulator>/usr/bin/qemu-system-x86_64</emulator>
        <serial type='pty'>
            <target port='0'/>
        </serial>
        <filesystem type='mount' accessmode='mapped'>
            <source dir='/vmroot/trusty'/>
            <target dir='root9p'/>
        </filesystem>
    </devices>
</domain>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.