[libvirt] [PATCH] relaxng: allow : in /dev/disk/by-path names

Eric Blake eblake at redhat.com
Thu Mar 26 22:58:46 UTC 2015


On IRC, Hydrar pointed a problem where 'virsh edit' failed on
his domain created through an ISCSI pool managed by virt-manager,
all because the XML included a block device with colons in the
name.

* docs/schemas/basictypes.rng (absFilePath): Add colon as safe.
* tests/qemuxml2argvdata/qemuxml2argv-disk-iscsi.xml: New file.
* tests/qemuxml2argvdata/qemuxml2argv-disk-iscsi.args: Likewise.
* tests/qemuxml2argvtest.c (mymain): Test it.

Signed-off-by: Eric Blake <eblake at redhat.com>
---
 docs/schemas/basictypes.rng                        |  2 +-
 .../qemuxml2argvdata/qemuxml2argv-disk-iscsi.args  |  7 ++++++
 tests/qemuxml2argvdata/qemuxml2argv-disk-iscsi.xml | 28 ++++++++++++++++++++++
 tests/qemuxml2argvtest.c                           |  1 +
 4 files changed, 37 insertions(+), 1 deletion(-)
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-disk-iscsi.args
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-disk-iscsi.xml

diff --git a/docs/schemas/basictypes.rng b/docs/schemas/basictypes.rng
index 0cd1c4e..f086ad2 100644
--- a/docs/schemas/basictypes.rng
+++ b/docs/schemas/basictypes.rng
@@ -242,7 +242,7 @@

   <define name="absFilePath">
     <data type="string">
-      <param name="pattern">/[a-zA-Z0-9_\.\+\-\\&"'<>/%,]+</param>
+      <param name="pattern">/[a-zA-Z0-9_\.\+\-\\&"'<>/%,:]+</param>
     </data>
   </define>

diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-iscsi.args b/tests/qemuxml2argvdata/qemuxml2argv-disk-iscsi.args
new file mode 100644
index 0000000..b987a38
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-iscsi.args
@@ -0,0 +1,7 @@
+LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test QEMU_AUDIO_DRV=none \
+/usr/bin/qemu -S -M \
+pc -m 214 -smp 1 -nographic -monitor unix:/tmp/test-monitor,server,nowait \
+-no-acpi -boot c -usb \
+-hda /dev/disk/by-path/ip-192.168.44.1:3260-iscsi-iqn.2011-02.lan.hdserver\
+:hydrar-desktop.win7vm-lun-0 -net none \
+-serial none -parallel none
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-iscsi.xml b/tests/qemuxml2argvdata/qemuxml2argv-disk-iscsi.xml
new file mode 100644
index 0000000..e4d9c97
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-iscsi.xml
@@ -0,0 +1,28 @@
+<domain type='qemu'>
+  <name>QEMUGuest1</name>
+  <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+  <memory unit='KiB'>219100</memory>
+  <currentMemory unit='KiB'>219100</currentMemory>
+  <vcpu placement='static'>1</vcpu>
+  <os>
+    <type arch='i686' machine='pc'>hvm</type>
+    <boot dev='hd'/>
+  </os>
+  <clock offset='utc'/>
+  <on_poweroff>destroy</on_poweroff>
+  <on_reboot>restart</on_reboot>
+  <on_crash>destroy</on_crash>
+  <devices>
+    <emulator>/usr/bin/qemu</emulator>
+    <disk type='block' device='disk'>
+      <driver name='qemu' type='raw'/>
+      <source dev='/dev/disk/by-path/ip-192.168.44.1:3260-iscsi-iqn.2011-02.lan.hdserver:hydrar-desktop.win7vm-lun-0'/>
+      <target dev='hda' bus='ide'/>
+      <address type='drive' controller='0' bus='0' target='0' unit='0'/>
+    </disk>
+    <controller type='usb' index='0'/>
+    <controller type='ide' index='0'/>
+    <controller type='pci' index='0' model='pci-root'/>
+    <memballoon model='none'/>
+  </devices>
+</domain>
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index 3c2fbf1..57ef053 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -708,6 +708,7 @@ mymain(void)
     DO_TEST("hugepages-pages6", NONE);
     DO_TEST("nosharepages", QEMU_CAPS_MACHINE_OPT, QEMU_CAPS_MEM_MERGE);
     DO_TEST("disk-cdrom", NONE);
+    DO_TEST("disk-iscsi", NONE);
     DO_TEST("disk-cdrom-network-http", QEMU_CAPS_KVM, QEMU_CAPS_DEVICE,
             QEMU_CAPS_DRIVE);
     DO_TEST("disk-cdrom-network-https", QEMU_CAPS_KVM, QEMU_CAPS_DEVICE,
-- 
2.1.0




More information about the libvir-list mailing list