[virt-tools-list] [virt-manager PATCH 1/2] virtinst: add support for disk type="volume"

Giuseppe Scrivano gscrivan at redhat.com
Fri Sep 26 13:28:46 UTC 2014


Signed-off-by: Giuseppe Scrivano <gscrivan at redhat.com>
---
 tests/xmlparse-xml/change-disk-in.xml  | 6 ++++++
 tests/xmlparse-xml/change-disk-out.xml | 6 ++++++
 tests/xmlparse.py                      | 4 ++++
 virtinst/devicedisk.py                 | 6 +++++-
 4 files changed, 21 insertions(+), 1 deletion(-)

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 870bf36..62aa410 100644
--- a/tests/xmlparse.py
+++ b/tests/xmlparse.py
@@ -331,6 +331,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")
@@ -370,6 +371,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 4088b0a..1d764d9 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
@@ -606,6 +609,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




More information about the virt-tools-list mailing list