Blob Blame History Raw
From 206c7f1028c20e4a4859c60b3ea308a34e02f5a6 Mon Sep 17 00:00:00 2001
From: Giuseppe Scrivano <gscrivan@redhat.com>
Date: Fri, 26 Sep 2014 15:24:34 +0200
Subject: [PATCH 1/2] virtinst: add support for disk type="volume"

Closes: https://bugzilla.redhat.com/show_bug.cgi?id=1146869

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
(cherry picked from commit cce582719528a9f664e2064fe662ba7fa34dbb24)
---
 tests/cli-test-xml/compare/virt-xml-edit-clear-clock.xml      | 2 +-
 tests/cli-test-xml/compare/virt-xml-edit-clear-cpu.xml        | 2 +-
 tests/cli-test-xml/compare/virt-xml-edit-select-disk-path.xml | 4 ++--
 tests/cli-test-xml/compare/virt-xml-edit-simple-metadata.xml  | 2 +-
 tests/testdriver.xml                                          | 6 ++++++
 tests/xmlparse-xml/change-disk-in.xml                         | 6 ++++++
 tests/xmlparse-xml/change-disk-out.xml                        | 6 ++++++
 tests/xmlparse.py                                             | 4 ++++
 virtinst/devicedisk.py                                        | 6 +++++-
 9 files changed, 32 insertions(+), 6 deletions(-)

diff --git a/tests/cli-test-xml/compare/virt-xml-edit-clear-clock.xml b/tests/cli-test-xml/compare/virt-xml-edit-clear-clock.xml
index 70ee019..99f0865 100644
--- a/tests/cli-test-xml/compare/virt-xml-edit-clear-clock.xml
+++ b/tests/cli-test-xml/compare/virt-xml-edit-clear-clock.xml
@@ -9,7 +9,7 @@
    <on_poweroff>destroy</on_poweroff>
    <on_reboot>restart</on_reboot>
    <on_crash>restart</on_crash>
-@@ -333,4 +328,5 @@
+@@ -339,4 +334,5 @@
        <address type="isa" iobase="0x505"/>
      </panic>
    </devices>
diff --git a/tests/cli-test-xml/compare/virt-xml-edit-clear-cpu.xml b/tests/cli-test-xml/compare/virt-xml-edit-clear-cpu.xml
index 8db2c2e..d966148 100644
--- a/tests/cli-test-xml/compare/virt-xml-edit-clear-cpu.xml
+++ b/tests/cli-test-xml/compare/virt-xml-edit-clear-cpu.xml
@@ -21,7 +21,7 @@
    <clock offset="utc">
      <timer name="rtc" tickpolicy="catchup"/>
      <timer name="pit" tickpolicy="delay"/>
-@@ -333,4 +316,5 @@
+@@ -339,4 +322,5 @@
        <address type="isa" iobase="0x505"/>
      </panic>
    </devices>
diff --git a/tests/cli-test-xml/compare/virt-xml-edit-select-disk-path.xml b/tests/cli-test-xml/compare/virt-xml-edit-select-disk-path.xml
index a045687..3fbcc73 100644
--- a/tests/cli-test-xml/compare/virt-xml-edit-select-disk-path.xml
+++ b/tests/cli-test-xml/compare/virt-xml-edit-select-disk-path.xml
@@ -5,8 +5,8 @@
        <boot order="1"/>
 +      <readonly/>
      </disk>
-     <disk type="block" device="disk">
-       <source dev="/dev/default-pool/overlay.img"/>
+     <disk type="volume" device="disk">
+       <driver name="qemu"/>
 
 Domain 'test-many-devices' defined successfully.
 Changes will take effect after the next domain shutdown.
\ No newline at end of file
diff --git a/tests/cli-test-xml/compare/virt-xml-edit-simple-metadata.xml b/tests/cli-test-xml/compare/virt-xml-edit-simple-metadata.xml
index ad2fbcc..15b464f 100644
--- a/tests/cli-test-xml/compare/virt-xml-edit-simple-metadata.xml
+++ b/tests/cli-test-xml/compare/virt-xml-edit-simple-metadata.xml
@@ -12,7 +12,7 @@
    <memory unit="KiB">409600</memory>
    <currentMemory unit="KiB">204800</currentMemory>
    <blkiotune>
-@@ -333,4 +333,5 @@
+@@ -339,4 +339,5 @@
        <address type="isa" iobase="0x505"/>
      </panic>
    </devices>
diff --git a/tests/testdriver.xml b/tests/testdriver.xml
index 6a2a92b..baf8922 100644
--- a/tests/testdriver.xml
+++ b/tests/testdriver.xml
@@ -173,6 +173,12 @@
       <source startupPolicy='requisite'/>
       <target dev='hdb' bus='ide'/>
     </disk>
+    <disk type="volume" device="disk">
+      <driver name="qemu"/>
+      <source pool="pool" volume="foobarvolume"/>
+      <target dev="hdc" bus="virtio"/>
+      <readonly/>
+    </disk>
 
 
     <!-- interfaces -->
diff --git a/tests/xmlparse-xml/change-disk-in.xml b/tests/xmlparse-xml/change-disk-in.xml
index 12f58cd..9725e9b 100644
--- a/tests/xmlparse-xml/change-disk-in.xml
+++ b/tests/xmlparse-xml/change-disk-in.xml
@@ -62,6 +62,12 @@
       <source dev="/dev/null"/>
       <target dev="vda" bus="virtio"/>
     </disk>
+    <disk type='volume' device='disk'>
+      <driver name='qemu'/>
+      <source pool='defaultPool' volume='foobar'/>
+      <target dev='vda' bus='virtio'/>
+      <readonly/>
+    </disk>
     <input type="mouse" bus="ps2"/>
     <graphics type="vnc" display=":3.4" xauth="/tmp/.Xauthority"/>
     <console type="pty"/>
diff --git a/tests/xmlparse-xml/change-disk-out.xml b/tests/xmlparse-xml/change-disk-out.xml
index 4bca70e..d9af1e3 100644
--- a/tests/xmlparse-xml/change-disk-out.xml
+++ b/tests/xmlparse-xml/change-disk-out.xml
@@ -64,6 +64,12 @@
       <source dev="/dev/null"/>
       <target dev="vda" bus="virtio"/>
     </disk>
+    <disk type="volume" device="disk">
+      <driver name="qemu"/>
+      <source pool="anotherPool" volume="foobar"/>
+      <target dev="vda" bus="virtio"/>
+      <readonly/>
+    </disk>
     <input type="mouse" bus="ps2"/>
     <graphics type="vnc" display=":3.4" xauth="/tmp/.Xauthority"/>
     <console type="pty"/>
diff --git a/tests/xmlparse.py b/tests/xmlparse.py
index d257f38..9a2f59d 100644
--- a/tests/xmlparse.py
+++ b/tests/xmlparse.py
@@ -313,6 +313,7 @@ class XMLParseTest(unittest.TestCase):
         disk3.size = 1
         disk6 = disks[5]
         disk6.size = 1
+        disk9 = disks[8]
 
         check = self._make_checker(disk1)
         check("path", "/tmp/test.img", "/dev/null")
@@ -352,6 +353,9 @@ class XMLParseTest(unittest.TestCase):
         check = self._make_checker(disk6.boot)
         check("order", None, 7, None)
 
+        check = self._make_checker(disk9)
+        check("sourcePool", "defaultPool", "anotherPool")
+
         self._alter_compare(guest.get_xml_config(), outfile)
 
     def testSingleDisk(self):
diff --git a/virtinst/devicedisk.py b/virtinst/devicedisk.py
index 9f39949..f4675ec 100644
--- a/virtinst/devicedisk.py
+++ b/virtinst/devicedisk.py
@@ -182,7 +182,8 @@ class VirtualDisk(VirtualDevice):
     TYPE_FILE = "file"
     TYPE_BLOCK = "block"
     TYPE_DIR = "dir"
-    types = [TYPE_FILE, TYPE_BLOCK, TYPE_DIR]
+    TYPE_VOLUME = "volume"
+    types = [TYPE_FILE, TYPE_BLOCK, TYPE_DIR, TYPE_VOLUME]
 
     IO_MODE_NATIVE = "native"
     IO_MODE_THREADS = "threads"
@@ -214,6 +215,8 @@ class VirtualDisk(VirtualDevice):
             return "dev"
         elif disk_type == VirtualDisk.TYPE_DIR:
             return "dir"
+        elif disk_type == VirtualDisk.TYPE_VOLUME:
+            return "volume"
         return "file"
 
     @staticmethod
@@ -594,6 +597,7 @@ class VirtualDisk(VirtualDevice):
                            clear_first=["./source/@" + target for target in
                                         _TARGET_PROPS])
 
+    sourcePool = XMLProperty("./source/@pool")
     sourceStartupPolicy = XMLProperty("./source/@startupPolicy")
     device = XMLProperty("./@device",
                          default_cb=lambda s: s.DEVICE_DISK)
-- 
1.9.3