[PATCH v3 2/2] schema: add support for Windows file paths and device names

Matt Coleman mcoleman at datto.com
Mon Nov 23 17:39:53 UTC 2020


Signed-off-by: Matt Coleman <matt at datto.com>
---
 docs/schemas/basictypes.rng                   |  2 +-
 docs/schemas/domaincommon.rng                 |  5 +++-
 .../disk-hyperv-physical.xml                  | 17 ++++++++++++++
 .../disk-hyperv-virtual.xml                   | 17 ++++++++++++++
 .../disk-hyperv-physical.xml                  | 23 +++++++++++++++++++
 .../disk-hyperv-virtual.xml                   | 23 +++++++++++++++++++
 tests/genericxml2xmltest.c                    |  2 ++
 7 files changed, 87 insertions(+), 2 deletions(-)
 create mode 100644 tests/genericxml2xmlindata/disk-hyperv-physical.xml
 create mode 100644 tests/genericxml2xmlindata/disk-hyperv-virtual.xml
 create mode 100644 tests/genericxml2xmloutdata/disk-hyperv-physical.xml
 create mode 100644 tests/genericxml2xmloutdata/disk-hyperv-virtual.xml

diff --git a/docs/schemas/basictypes.rng b/docs/schemas/basictypes.rng
index ea18b2d2fb..fc52799466 100644
--- a/docs/schemas/basictypes.rng
+++ b/docs/schemas/basictypes.rng
@@ -299,7 +299,7 @@
 
   <define name="absFilePath">
     <data type="string">
-      <param name="pattern">/.+</param>
+      <param name="pattern">(/|[a-zA-Z]:\\).+</param>
     </data>
   </define>
 
diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
index f86a854863..da9d1da187 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -1691,7 +1691,10 @@
         <interleave>
           <optional>
             <attribute name="dev">
-              <ref name="absFilePath"/>
+              <choice>
+                <ref name="absFilePath"/>
+                <ref name="deviceName"/>
+              </choice>
             </attribute>
           </optional>
           <ref name="diskSourceCommon"/>
diff --git a/tests/genericxml2xmlindata/disk-hyperv-physical.xml b/tests/genericxml2xmlindata/disk-hyperv-physical.xml
new file mode 100644
index 0000000000..a7f34c18f4
--- /dev/null
+++ b/tests/genericxml2xmlindata/disk-hyperv-physical.xml
@@ -0,0 +1,17 @@
+<domain type='hyperv'>
+  <name>test_disk-hyperv</name>
+  <uuid>deadbeef-dead-beef-dead-beefdeadbeef</uuid>
+  <memory unit='KiB'>1048576</memory>
+  <vcpu placement='static'>3</vcpu>
+  <os>
+    <type>hvm</type>
+  </os>
+  <devices>
+    <disk type='block' device='disk'>
+      <source dev='2'/>
+      <target dev='sdb' bus='scsi'/>
+      <address type='drive' controller='0' bus='0' target='0' unit='0'/>
+    </disk>
+    <controller type='scsi' index='0'/>
+  </devices>
+</domain>
diff --git a/tests/genericxml2xmlindata/disk-hyperv-virtual.xml b/tests/genericxml2xmlindata/disk-hyperv-virtual.xml
new file mode 100644
index 0000000000..bbc56c9f89
--- /dev/null
+++ b/tests/genericxml2xmlindata/disk-hyperv-virtual.xml
@@ -0,0 +1,17 @@
+<domain type='hyperv'>
+  <name>test_disk-hyperv</name>
+  <uuid>deadbeef-dead-beef-dead-beefdeadbeef</uuid>
+  <memory unit='KiB'>1048576</memory>
+  <vcpu placement='static'>3</vcpu>
+  <os>
+    <type>hvm</type>
+  </os>
+  <devices>
+    <disk type='file' device='disk'>
+      <source file='X:\test_disk-hyperv.vhdx'/>
+      <target dev='sda' bus='scsi'/>
+      <address type='drive' controller='0' bus='0' target='0' unit='0'/>
+    </disk>
+    <controller type='scsi' index='0'/>
+  </devices>
+</domain>
diff --git a/tests/genericxml2xmloutdata/disk-hyperv-physical.xml b/tests/genericxml2xmloutdata/disk-hyperv-physical.xml
new file mode 100644
index 0000000000..112a5081cd
--- /dev/null
+++ b/tests/genericxml2xmloutdata/disk-hyperv-physical.xml
@@ -0,0 +1,23 @@
+<domain type='hyperv'>
+  <name>test_disk-hyperv</name>
+  <uuid>deadbeef-dead-beef-dead-beefdeadbeef</uuid>
+  <memory unit='KiB'>1048576</memory>
+  <currentMemory unit='KiB'>1048576</currentMemory>
+  <vcpu placement='static'>3</vcpu>
+  <os>
+    <type arch='x86_64'>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>
+    <disk type='block' device='disk'>
+      <source dev='2'/>
+      <target dev='sdb' bus='scsi'/>
+      <address type='drive' controller='0' bus='0' target='0' unit='0'/>
+    </disk>
+    <controller type='scsi' index='0'/>
+  </devices>
+</domain>
diff --git a/tests/genericxml2xmloutdata/disk-hyperv-virtual.xml b/tests/genericxml2xmloutdata/disk-hyperv-virtual.xml
new file mode 100644
index 0000000000..dadd3318ab
--- /dev/null
+++ b/tests/genericxml2xmloutdata/disk-hyperv-virtual.xml
@@ -0,0 +1,23 @@
+<domain type='hyperv'>
+  <name>test_disk-hyperv</name>
+  <uuid>deadbeef-dead-beef-dead-beefdeadbeef</uuid>
+  <memory unit='KiB'>1048576</memory>
+  <currentMemory unit='KiB'>1048576</currentMemory>
+  <vcpu placement='static'>3</vcpu>
+  <os>
+    <type arch='x86_64'>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>
+    <disk type='file' device='disk'>
+      <source file='X:\test_disk-hyperv.vhdx'/>
+      <target dev='sda' bus='scsi'/>
+      <address type='drive' controller='0' bus='0' target='0' unit='0'/>
+    </disk>
+    <controller type='scsi' index='0'/>
+  </devices>
+</domain>
diff --git a/tests/genericxml2xmltest.c b/tests/genericxml2xmltest.c
index 5110bfba86..5e8f58b4a2 100644
--- a/tests/genericxml2xmltest.c
+++ b/tests/genericxml2xmltest.c
@@ -154,6 +154,8 @@ mymain(void)
     DO_TEST_FULL(name, 1, false, TEST_COMPARE_DOM_XML2XML_RESULT_SUCCESS)
 
     DO_TEST_DIFFERENT("disk-virtio");
+    DO_TEST_DIFFERENT("disk-hyperv-physical");
+    DO_TEST_DIFFERENT("disk-hyperv-virtual");
 
     DO_TEST_DIFFERENT("graphics-vnc-minimal");
     DO_TEST_DIFFERENT("graphics-vnc-manual-port");
-- 
2.27.0





More information about the libvir-list mailing list