help-guix
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

"guix system vm" to libvirt XML domain


From: Giovanni Biscuolo
Subject: "guix system vm" to libvirt XML domain
Date: Thu, 24 Jan 2019 19:18:52 +0100

Hi!

I'm using guix on a foreign distro (Debian 9) and I'm already using
libvirtd to manage some KVM guests; I'd like to also manage "guix
system vm" generated ones using libvirt

it would be great to be able to automatically manage the (re)definition
of VMs (and containers?) on - possibly remote - libvirtd servers using a
distributedVM.scm config :-): WDYT?

anyway... as for now it must be "manually" managed and this is
what I'm doing: it fails at the end, what am I doing wrong?

is there a better way to do it?

1. I save the "command line" from the script generated by "guix system
vm" (except the last "@") calling this "container.minimal.args.orig

--8<---------------cut here---------------start------------->8---
/gnu/store/4pnx934k40wni57r5swj2kr29l1j549f-qemu-3.1.0/bin/qemu-system-x86_64 
-kernel /gnu/store/y5aiijqiqna1y8ypn6c0jp367813xxnc-linux-libre-4.20.3/bzImage 
-initrd /gnu/store/9xgqs9zf51i9binqjl5hgl8gl7ql40hc-system/initrd -append 
"--root=/dev/vda1 --system=/gnu/store/9xgqs9zf51i9binqjl5hgl8gl7ql40hc-system 
--load=/gnu/store/9xgqs9zf51i9binqjl5hgl8gl7ql40hc-system/boot" -enable-kvm 
-no-reboot -net nic,model=virtio -object 
rng-random,filename=/dev/urandom,id=guixsd-vm-rng -device 
virtio-rng-pci,rng=guixsd-vm-rng -virtfs 
local,path="/gnu/store",security_model=none,mount_tag="TAGjoptajej2oynju6yvboauz7pl6uj"
 -vga std -drive 
file=/gnu/store/4mz1qqv7h5g5885q1aq0izlmy01knf1g-qemu-image,if=virtio,cache=writeback,werror=report,readonly
 -m  256
--8<---------------cut here---------------end--------------->8---

2. try to convert it to libvirt XML domain definition

--8<---------------cut here---------------start------------->8---
$ virsh --connect qemu:///system domxml-from-native qemu-argv 
container-minimal.args.orig 
error: internal error: malformed keyword arguments in 
'file=/gnu/store/4mz1qqv7h5g5885q1aq0izlmy01knf1g-qemu-image,if=virtio,cache=writeback,werror=report,readonly'
--8<---------------cut here---------------end--------------->8---

3. remove the "readonly" keyword from the last "-drive" arg, calling this
"container.minimal.args" (that *must* be then manually added to the XML
definition)

--8<---------------cut here---------------start------------->8---
/gnu/store/4pnx934k40wni57r5swj2kr29l1j549f-qemu-3.1.0/bin/qemu-system-x86_64 
-kernel /gnu/store/y5aiijqiqna1y8ypn6c0jp367813xxnc-linux-libre-4.20.3/bzImage 
-initrd /gnu/store/9xgqs9zf51i9binqjl5hgl8gl7ql40hc-system/initrd -append 
"--root=/dev/vda1 --system=/gnu/store/9xgqs9zf51i9binqjl5hgl8gl7ql40hc-system 
--load=/gnu/store/9xgqs9zf51i9binqjl5hgl8gl7ql40hc-system/boot" -enable-kvm 
-no-reboot -net nic,model=virtio -object 
rng-random,filename=/dev/urandom,id=guixsd-vm-rng -device 
virtio-rng-pci,rng=guixsd-vm-rng -virtfs 
local,path="/gnu/store",security_model=none,mount_tag="TAGjoptajej2oynju6yvboauz7pl6uj"
 -vga std -drive 
file=/gnu/store/4mz1qqv7h5g5885q1aq0izlmy01knf1g-qemu-image,if=virtio,cache=writeback,werror=report
 -m  256
--8<---------------cut here---------------end--------------->8---

4. converting the file above

--8<---------------cut here---------------start------------->8---
$ virsh --connect qemu:///system domxml-from-native qemu-argv 
container-minimal.args
<domain type='kvm' xmlns:qemu='http://libvirt.org/schemas/domain/qemu/1.0'>
  <name>unnamed</name>
  <uuid>894f668e-32a5-4331-9d30-8604b89ae359</uuid>
  <memory unit='KiB'>262144</memory>
  <currentMemory unit='KiB'>262144</currentMemory>
  <vcpu placement='static'>1</vcpu>
  <os>
    <type arch='x86_64' machine='pc-i440fx-2.8'>hvm</type>
    
<kernel>/gnu/store/y5aiijqiqna1y8ypn6c0jp367813xxnc-linux-libre-4.20.3/bzImage</kernel>
    <initrd>/gnu/store/9xgqs9zf51i9binqjl5hgl8gl7ql40hc-system/initrd</initrd>
    <cmdline>--root=/dev/vda1 
--system=/gnu/store/9xgqs9zf51i9binqjl5hgl8gl7ql40hc-system 
--load=/gnu/store/9xgqs9zf51i9binqjl5hgl8gl7ql40hc-system/boot</cmdline>
  </os>
  <features>
    <acpi/>
  </features>
  <clock offset='utc'/>
  <on_poweroff>destroy</on_poweroff>
  <on_reboot>destroy</on_reboot>
  <on_crash>destroy</on_crash>
  <devices>
    
<emulator>/gnu/store/4pnx934k40wni57r5swj2kr29l1j549f-qemu-3.1.0/bin/qemu-system-x86_64</emulator>
    <disk type='file' device='disk'>
      <driver name='qemu' type='raw' cache='writeback' error_policy='report'/>
      <source file='/gnu/store/4mz1qqv7h5g5885q1aq0izlmy01knf1g-qemu-image'/>
      <target dev='vda' bus='virtio'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x03' 
function='0x0'/>
    </disk>
    <controller type='usb' index='0' model='piix3-uhci'>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' 
function='0x2'/>
    </controller>
    <controller type='pci' index='0' model='pci-root'/>
    <input type='mouse' bus='ps2'/>
    <input type='keyboard' bus='ps2'/>
    <graphics type='sdl'/>
    <video>
      <model type='vga' vram='16384' heads='1' primary='yes'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x02' 
function='0x0'/>
    </video>
    <memballoon model='none'/>
  </devices>
  <qemu:commandline>
    <qemu:arg value='-object'/>
    <qemu:arg value='rng-random,filename=/dev/urandom,id=guixsd-vm-rng'/>
    <qemu:arg value='-device'/>
    <qemu:arg value='virtio-rng-pci,rng=guixsd-vm-rng'/>
    <qemu:arg value='-virtfs'/>
    <qemu:arg 
value='local,path=&quot;/gnu/store&quot;,security_model=none,mount_tag=&quot;TAGjoptajej2oynju6yvboauz7pl6uj&quot;'/>
  </qemu:commandline>
</domain>
--8<---------------cut here---------------end--------------->8---

5. unfortunately some command line args are not automatically converted,
so I have to "manually" convert it [1]... also adapting some parametrs
to my needs (e.g. name, memory, network, graphics); saving as
container-minimal-fixed.xml

Attachment: signature.asc
Description: PGP signature

Attachment: container-minimal-fixed.xml
Description: application/xml

6. register the domain definition in libvirtd

--8<---------------cut here---------------start------------->8---
$ virsh --connect qemu:///system define container-minimal-fixed.xml
Domain container-minimal defined from container-minimal-fixed.xml
--8<---------------cut here---------------end--------------->8---

7. start the VM, connect via SPICE and see the VM does not boot due to
an error in procedure mount, falling back to the guile REPL; the backtrace
is:

--8<---------------cut here---------------start------------->8---
In gnu/build/linux-boot.scm:
   516:13  2 (_)
    367:8  1 (mount-root-file-system "/dev/vda1" "ext4" # _)
In unknown file:
           0 (mount "/dev/vda1" "/real-root" "ext4" 1 #<undefined>)
--8<---------------cut here---------------end--------------->8---

any hint please?

Thanks!
Giovanni

[1] using this docs as ref:
https://wiki.qemu.org/Documentation/9psetup#Starting_the_Guest_using_libvirt
https://libvirt.org/formatdomain.html#elementsRng

-- 
Giovanni Biscuolo

Xelera IT Infrastructures

reply via email to

[Prev in Thread] Current Thread [Next in Thread]