]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
xenconfig: produce key=value disk config syntax in xl formatter
authorJim Fehlig <jfehlig@suse.com>
Tue, 9 Feb 2016 23:19:01 +0000 (16:19 -0700)
committerJim Fehlig <jfehlig@suse.com>
Mon, 22 Feb 2016 18:46:50 +0000 (11:46 -0700)
The most formal form of xl disk configuration uses key=value
syntax to define each configuration item, e.g.

format=raw, vdev=xvda, access=rw, backendtype=phy, target=disksrc

Change the xl disk formatter to produce this syntax, which allows
target= to contain meta info needed to setup a network-based
disksrc (e.g. rbd, nbd, iscsi). For details on xl disk config
format, see  $xen-src/docs/misc/xl-disk-configuration.txt

Update the disk config in the tests to use the formal syntax.
But add tests to ensure disks specified with the positional
parameter syntax are correctly converted to <disk> XML.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
14 files changed:
src/xenconfig/xen_xl.c
tests/xlconfigdata/test-disk-positional-parms-full.cfg [new file with mode: 0644]
tests/xlconfigdata/test-disk-positional-parms-full.xml [new file with mode: 0644]
tests/xlconfigdata/test-disk-positional-parms-partial.cfg [new file with mode: 0644]
tests/xlconfigdata/test-disk-positional-parms-partial.xml [new file with mode: 0644]
tests/xlconfigdata/test-fullvirt-direct-kernel-boot.cfg
tests/xlconfigdata/test-fullvirt-multiusb.cfg
tests/xlconfigdata/test-new-disk.cfg
tests/xlconfigdata/test-paravirt-cmdline.cfg
tests/xlconfigdata/test-paravirt-maxvcpus.cfg
tests/xlconfigdata/test-spice-features.cfg
tests/xlconfigdata/test-spice.cfg
tests/xlconfigdata/test-vif-rate.cfg
tests/xlconfigtest.c

index be194e35350c29d387404218f82f2dbcf7c8a072..f3e8b5521721e0f61e8b4da3e7f6d462ae1f3c13 100644 (file)
@@ -587,9 +587,8 @@ xenFormatXLDisk(virConfValuePtr list, virDomainDiskDefPtr disk)
     int format = virDomainDiskGetFormat(disk);
     const char *driver = virDomainDiskGetDriver(disk);
 
-    /* target */
-    virBufferAsprintf(&buf, "%s,", src);
     /* format */
+    virBufferAddLit(&buf, "format=");
     switch (format) {
         case VIR_STORAGE_FILE_RAW:
             virBufferAddLit(&buf, "raw,");
@@ -609,31 +608,37 @@ xenFormatXLDisk(virConfValuePtr list, virDomainDiskDefPtr disk)
     }
 
     /* device */
-    virBufferAdd(&buf, disk->dst, -1);
-
-    virBufferAddLit(&buf, ",");
+    virBufferAsprintf(&buf, "vdev=%s,", disk->dst);
 
+    /* access */
+    virBufferAddLit(&buf, "access=");
     if (disk->src->readonly)
-        virBufferAddLit(&buf, "r,");
+        virBufferAddLit(&buf, "ro,");
     else if (disk->src->shared)
         virBufferAddLit(&buf, "!,");
     else
-        virBufferAddLit(&buf, "w,");
+        virBufferAddLit(&buf, "rw,");
     if (disk->transient) {
         virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
                        _("transient disks not supported yet"));
         goto cleanup;
     }
 
+    /* backendtype */
+    virBufferAddLit(&buf, "backendtype=");
     if (STREQ_NULLABLE(driver, "qemu"))
-        virBufferAddLit(&buf, "backendtype=qdisk");
+        virBufferAddLit(&buf, "qdisk,");
     else if (STREQ_NULLABLE(driver, "tap"))
-        virBufferAddLit(&buf, "backendtype=tap");
+        virBufferAddLit(&buf, "tap,");
     else if (STREQ_NULLABLE(driver, "phy"))
-        virBufferAddLit(&buf, "backendtype=phy");
+        virBufferAddLit(&buf, "phy,");
 
+    /* devtype */
     if (disk->device == VIR_DOMAIN_DISK_DEVICE_CDROM)
-        virBufferAddLit(&buf, ",devtype=cdrom");
+        virBufferAddLit(&buf, "devtype=cdrom,");
+
+    /* target */
+    virBufferAsprintf(&buf, "target=%s", src);
 
     if (virBufferCheckError(&buf) < 0)
         goto cleanup;
diff --git a/tests/xlconfigdata/test-disk-positional-parms-full.cfg b/tests/xlconfigdata/test-disk-positional-parms-full.cfg
new file mode 100644 (file)
index 0000000..026e451
--- /dev/null
@@ -0,0 +1,26 @@
+name = "XenGuest2"
+uuid = "c7a5fdb2-cdaf-9455-926a-d65c16db1809"
+maxmem = 579
+memory = 394
+vcpus = 1
+pae = 1
+acpi = 1
+apic = 1
+hap = 0
+viridian = 0
+rtc_timeoffset = 0
+localtime = 0
+on_poweroff = "destroy"
+on_reboot = "restart"
+on_crash = "restart"
+device_model = "/usr/lib/xen/bin/qemu-dm"
+sdl = 0
+vnc = 1
+vncunused = 1
+vnclisten = "127.0.0.1"
+vif = [ "mac=00:16:3e:66:92:9c,bridge=xenbr1,script=vif-bridge,model=e1000" ]
+parallel = "none"
+serial = "none"
+builder = "hvm"
+boot = "d"
+disk = [ "/dev/HostVG/XenGuest2,raw,hda,rw,backendtype=phy", "/var/lib/libvirt/images/XenGuest2-home,qcow2,hdb,rw", "/root/boot.iso,raw,hdc,ro,devtype=cdrom" ]
diff --git a/tests/xlconfigdata/test-disk-positional-parms-full.xml b/tests/xlconfigdata/test-disk-positional-parms-full.xml
new file mode 100644 (file)
index 0000000..7fd1899
--- /dev/null
@@ -0,0 +1,55 @@
+<domain type='xen'>
+  <name>XenGuest2</name>
+  <uuid>c7a5fdb2-cdaf-9455-926a-d65c16db1809</uuid>
+  <memory unit='KiB'>592896</memory>
+  <currentMemory unit='KiB'>403456</currentMemory>
+  <vcpu placement='static'>1</vcpu>
+  <os>
+    <type arch='x86_64' machine='xenfv'>hvm</type>
+    <loader type='rom'>/usr/lib/xen/boot/hvmloader</loader>
+    <boot dev='cdrom'/>
+  </os>
+  <features>
+    <acpi/>
+    <apic/>
+    <pae/>
+  </features>
+  <clock offset='variable' adjustment='0' basis='utc'/>
+  <on_poweroff>destroy</on_poweroff>
+  <on_reboot>restart</on_reboot>
+  <on_crash>restart</on_crash>
+  <devices>
+    <emulator>/usr/lib/xen/bin/qemu-dm</emulator>
+    <disk type='block' device='disk'>
+      <driver name='phy' type='raw'/>
+      <source dev='/dev/HostVG/XenGuest2'/>
+      <target dev='hda' bus='ide'/>
+      <address type='drive' controller='0' bus='0' target='0' unit='0'/>
+    </disk>
+    <disk type='file' device='disk'>
+      <driver name='qemu' type='qcow2'/>
+      <source file='/var/lib/libvirt/images/XenGuest2-home'/>
+      <target dev='hdb' bus='ide'/>
+      <address type='drive' controller='0' bus='0' target='0' unit='1'/>
+    </disk>
+    <disk type='file' device='cdrom'>
+      <driver name='qemu' type='raw'/>
+      <source file='/root/boot.iso'/>
+      <target dev='hdc' bus='ide'/>
+      <readonly/>
+      <address type='drive' controller='0' bus='1' target='0' unit='0'/>
+    </disk>
+    <controller type='ide' index='0'/>
+    <interface type='bridge'>
+      <mac address='00:16:3e:66:92:9c'/>
+      <source bridge='xenbr1'/>
+      <script path='vif-bridge'/>
+      <model type='e1000'/>
+    </interface>
+    <input type='mouse' bus='ps2'/>
+    <input type='keyboard' bus='ps2'/>
+    <graphics type='vnc' port='-1' autoport='yes' listen='127.0.0.1'>
+      <listen type='address' address='127.0.0.1'/>
+    </graphics>
+  </devices>
+</domain>
diff --git a/tests/xlconfigdata/test-disk-positional-parms-partial.cfg b/tests/xlconfigdata/test-disk-positional-parms-partial.cfg
new file mode 100644 (file)
index 0000000..0591037
--- /dev/null
@@ -0,0 +1,26 @@
+name = "XenGuest2"
+uuid = "c7a5fdb2-cdaf-9455-926a-d65c16db1809"
+maxmem = 579
+memory = 394
+vcpus = 1
+pae = 1
+acpi = 1
+apic = 1
+hap = 0
+viridian = 0
+rtc_timeoffset = 0
+localtime = 0
+on_poweroff = "destroy"
+on_reboot = "restart"
+on_crash = "restart"
+device_model = "/usr/lib/xen/bin/qemu-dm"
+sdl = 0
+vnc = 1
+vncunused = 1
+vnclisten = "127.0.0.1"
+vif = [ "mac=00:16:3e:66:92:9c,bridge=xenbr1,script=vif-bridge,model=e1000" ]
+parallel = "none"
+serial = "none"
+builder = "hvm"
+boot = "d"
+disk = [ "/dev/HostVG/XenGuest2,,hda,,backendtype=phy", "/var/lib/libvirt/images/XenGuest2-home,,hdb,,", "/root/boot.iso,,hdc,,devtype=cdrom" ]
diff --git a/tests/xlconfigdata/test-disk-positional-parms-partial.xml b/tests/xlconfigdata/test-disk-positional-parms-partial.xml
new file mode 100644 (file)
index 0000000..7c42736
--- /dev/null
@@ -0,0 +1,55 @@
+<domain type='xen'>
+  <name>XenGuest2</name>
+  <uuid>c7a5fdb2-cdaf-9455-926a-d65c16db1809</uuid>
+  <memory unit='KiB'>592896</memory>
+  <currentMemory unit='KiB'>403456</currentMemory>
+  <vcpu placement='static'>1</vcpu>
+  <os>
+    <type arch='x86_64' machine='xenfv'>hvm</type>
+    <loader type='rom'>/usr/lib/xen/boot/hvmloader</loader>
+    <boot dev='cdrom'/>
+  </os>
+  <features>
+    <acpi/>
+    <apic/>
+    <pae/>
+  </features>
+  <clock offset='variable' adjustment='0' basis='utc'/>
+  <on_poweroff>destroy</on_poweroff>
+  <on_reboot>restart</on_reboot>
+  <on_crash>restart</on_crash>
+  <devices>
+    <emulator>/usr/lib/xen/bin/qemu-dm</emulator>
+    <disk type='block' device='disk'>
+      <driver name='phy' type='raw'/>
+      <source dev='/dev/HostVG/XenGuest2'/>
+      <target dev='hda' bus='ide'/>
+      <address type='drive' controller='0' bus='0' target='0' unit='0'/>
+    </disk>
+    <disk type='file' device='disk'>
+      <driver name='qemu' type='raw'/>
+      <source file='/var/lib/libvirt/images/XenGuest2-home'/>
+      <target dev='hdb' bus='ide'/>
+      <address type='drive' controller='0' bus='0' target='0' unit='1'/>
+    </disk>
+    <disk type='file' device='cdrom'>
+      <driver name='qemu' type='raw'/>
+      <source file='/root/boot.iso'/>
+      <target dev='hdc' bus='ide'/>
+      <readonly/>
+      <address type='drive' controller='0' bus='1' target='0' unit='0'/>
+    </disk>
+    <controller type='ide' index='0'/>
+    <interface type='bridge'>
+      <mac address='00:16:3e:66:92:9c'/>
+      <source bridge='xenbr1'/>
+      <script path='vif-bridge'/>
+      <model type='e1000'/>
+    </interface>
+    <input type='mouse' bus='ps2'/>
+    <input type='keyboard' bus='ps2'/>
+    <graphics type='vnc' port='-1' autoport='yes' listen='127.0.0.1'>
+      <listen type='address' address='127.0.0.1'/>
+    </graphics>
+  </devices>
+</domain>
index 32b08e1a877095741e456ce189510b317b999805..9ebbc89fe0d4ce4e2be3ac8734fd82fc2340cc4c 100644 (file)
@@ -27,4 +27,4 @@ kernel = "/tmp/vmlinuz"
 ramdisk = "/tmp/initrd"
 cmdline = "ignore_loglvl"
 boot = "d"
-disk = [ "/dev/HostVG/XenGuest2,raw,hda,w,backendtype=phy", "/root/boot.iso,raw,hdc,r,backendtype=qdisk,devtype=cdrom" ]
+disk = [ "format=raw,vdev=hda,access=rw,backendtype=phy,target=/dev/HostVG/XenGuest2", "format=raw,vdev=hdc,access=ro,backendtype=qdisk,devtype=cdrom,target=/root/boot.iso" ]
index d0482a83ec19d595ad526bab61276e4dcd1cd4ed..097de88b8fcdcc21df2fdeebc9922c7ae2fa3631 100755 (executable)
@@ -24,6 +24,6 @@ parallel = "none"
 serial = "none"
 builder = "hvm"
 boot = "d"
-disk = [ "/dev/HostVG/XenGuest2,raw,hda,w,backendtype=phy", "/root/boot.iso,raw,hdc,r,backendtype=qdisk,devtype=cdrom" ]
+disk = [ "format=raw,vdev=hda,access=rw,backendtype=phy,target=/dev/HostVG/XenGuest2", "format=raw,vdev=hdc,access=ro,backendtype=qdisk,devtype=cdrom,target=/root/boot.iso" ]
 usb = 1
 usbdevice = [ "mouse", "tablet" ]
index 9b9fb366b6d0e2559c3f3b9aa3a18b8016be77df..4a5b66e285423af574431621e17df96f85d46a7e 100644 (file)
@@ -23,4 +23,4 @@ parallel = "none"
 serial = "none"
 builder = "hvm"
 boot = "d"
-disk = [ "/dev/HostVG/XenGuest2,raw,hda,w,backendtype=phy", "/var/lib/libvirt/images/XenGuest2-home,qcow2,hdb,w,backendtype=qdisk", "/root/boot.iso,raw,hdc,r,backendtype=qdisk,devtype=cdrom" ]
+disk = [ "format=raw,vdev=hda,access=rw,backendtype=phy,target=/dev/HostVG/XenGuest2", "format=qcow2,vdev=hdb,access=rw,backendtype=qdisk,target=/var/lib/libvirt/images/XenGuest2-home", "format=raw,vdev=hdc,access=ro,backendtype=qdisk,devtype=cdrom,target=/root/boot.iso" ]
index c512a055e3ee937aff67387135d2dbc622694242..e82d900f4fee1c75545395686a76706aec2becb9 100644 (file)
@@ -11,4 +11,4 @@ vif = [ "mac=00:16:3e:66:92:9c,bridge=xenbr1,script=vif-bridge" ]
 kernel = "/tmp/vmlinuz"
 ramdisk = "/tmp/initrd"
 cmdline = "root=/dev/xvda1 console=hvc0"
-disk = [ "/dev/HostVG/XenGuest2,raw,xvda,w,backendtype=qdisk" ]
+disk = [ "format=raw,vdev=xvda,access=rw,backendtype=qdisk,target=/dev/HostVG/XenGuest2" ]
index d506b7549af47c0bc131f6c0271e23274a1b2cc1..8316774bb0790c0ee357fc29cad3ac5afff42587 100644 (file)
@@ -10,4 +10,4 @@ on_reboot = "restart"
 on_crash = "preserve"
 vif = [ "mac=5a:36:0e:be:00:09" ]
 bootloader = "/usr/bin/pygrub"
-disk = [ "/var/lib/xen/images/debian/disk.qcow2,qcow2,xvda,w,backendtype=qdisk" ]
+disk = [ "format=qcow2,vdev=xvda,access=rw,backendtype=qdisk,target=/var/lib/xen/images/debian/disk.qcow2" ]
index 152cb27ee3ebdb5144562b8bd21afc6b224f9c1a..8c1ca189cd6925dfe2a031260bb30c5dfb529e7d 100644 (file)
@@ -19,7 +19,7 @@ parallel = "none"
 serial = "none"
 builder = "hvm"
 boot = "d"
-disk = [ "/dev/HostVG/XenGuest2,raw,hda,w,backendtype=phy", "/root/boot.iso,raw,hdc,r,backendtype=qdisk,devtype=cdrom" ]
+disk = [ "format=raw,vdev=hda,access=rw,backendtype=phy,target=/dev/HostVG/XenGuest2", "format=raw,vdev=hdc,access=ro,backendtype=qdisk,devtype=cdrom,target=/root/boot.iso" ]
 sdl = 0
 vnc = 0
 spice = 1
index 1a96114a817f2e93c948017668e586cf5d85e071..84b3ae659879ce2b2bd25f60b4a5a52a96399087 100644 (file)
@@ -19,7 +19,7 @@ parallel = "none"
 serial = "none"
 builder = "hvm"
 boot = "d"
-disk = [ "/dev/HostVG/XenGuest2,raw,hda,w,backendtype=phy", "/root/boot.iso,raw,hdc,r,backendtype=qdisk,devtype=cdrom" ]
+disk = [ "format=raw,vdev=hda,access=rw,backendtype=phy,target=/dev/HostVG/XenGuest2", "format=raw,vdev=hdc,access=ro,backendtype=qdisk,devtype=cdrom,target=/root/boot.iso" ]
 sdl = 0
 vnc = 0
 spice = 1
index c5484dc50f961910ea888947ad127800a022868f..44bfa3c95724686f0d087973ff15e64317256f72 100644 (file)
@@ -23,4 +23,4 @@ parallel = "none"
 serial = "none"
 builder = "hvm"
 boot = "d"
-disk = [ "/dev/HostVG/XenGuest2,raw,hda,w,backendtype=phy", "/var/lib/libvirt/images/XenGuest2-home,qcow2,hdb,w,backendtype=qdisk", "/root/boot.iso,raw,hdc,r,backendtype=qdisk,devtype=cdrom" ]
+disk = [ "format=raw,vdev=hda,access=rw,backendtype=phy,target=/dev/HostVG/XenGuest2", "format=qcow2,vdev=hdb,access=rw,backendtype=qdisk,target=/var/lib/libvirt/images/XenGuest2-home", "format=raw,vdev=hdc,access=ro,backendtype=qdisk,devtype=cdrom,target=/root/boot.iso" ]
index aa53ed8f70931fb1a3d4874df3e1c3c2eb2c1192..13b99f2d92695f9cc70b0185519fa5dcd098374e 100644 (file)
@@ -208,6 +208,8 @@ mymain(void)
 
     DO_TEST("paravirt-maxvcpus");
     DO_TEST("new-disk");
+    DO_TEST_FORMAT("disk-positional-parms-full");
+    DO_TEST_FORMAT("disk-positional-parms-partial");
     DO_TEST("spice");
     DO_TEST("spice-features");
     DO_TEST("vif-rate");