[virt-tools-list] [virtinst v3] Add attribute'model' in VirtualDisk class

Chen Hanxiao chenhanxiao at cn.fujitsu.com
Mon Dec 3 10:24:57 UTC 2012


From: ChenHanxiao <chenhanxiao at cn.fujitsu.com>

Introduce a new attribute 'model' to VirtualDisk for helping
virtual disks set bus model if needed.

Signed-off-by: ChenHanxiao <chenhanxiao at cn.fujitsu.com>
---
 virtinst/VirtualDisk.py |   17 ++++++++++++++---
 1 files changed, 14 insertions(+), 3 deletions(-)

diff --git a/virtinst/VirtualDisk.py b/virtinst/VirtualDisk.py
index 2eeb43d..9e028c3 100644
--- a/virtinst/VirtualDisk.py
+++ b/virtinst/VirtualDisk.py
@@ -553,7 +553,7 @@ class VirtualDisk(VirtualDevice):
                  volInstall=None, volName=None, bus=None, shareable=False,
                  driverCache=None, selinuxLabel=None, format=None,
                  validate=True, parsexml=None, parsexmlnode=None, caps=None,
-                 driverIO=None, sizebytes=None):
+                 driverIO=None, sizebytes=None, model=None):
         """
         @param path: filesystem path to the disk image.
         @type path: C{str}
@@ -615,6 +615,7 @@ class VirtualDisk(VirtualDevice):
         self._pool_object = None
         self._vol_install = None
         self._bus = None
+        self._model = None
         self._shareable = None
         self._driver_cache = None
         self._selinux_label = None
@@ -650,6 +651,7 @@ class VirtualDisk(VirtualDevice):
         self._set_vol_object(volObject, validate=False)
         self._set_vol_install(volInstall, validate=False)
         self._set_bus(bus, validate=False)
+        self._set_model(model, validate=False)
         self._set_shareable(shareable, validate=False)
         self._set_driver_cache(driverCache, validate=False)
         self._set_selinux_label(selinuxLabel, validate=False)
@@ -845,6 +847,15 @@ class VirtualDisk(VirtualDevice):
         self._target = val
     target = _xml_property(_get_target, _set_target,
                            xpath="./target/@dev")
+						   
+    def _get_model(self):
+        return self._model
+    def _set_model(self, val, validate=True):
+        if val is not None:
+            self._check_str(val, "model")
+        self.__validate_wrapper("_model", val, validate, self.model)
+    model = _xml_property(_get_model, _set_model,
+                        xpath="./target/@model")
 
     def _get_shareable(self):
         return self._shareable
@@ -1518,7 +1529,7 @@ class VirtualDisk(VirtualDevice):
         if path is not None:
             ret += "      <source %s='%s'/>\n" % (typeattr, path)
 
-        bus_xml = ""
+        bus_xml = "" 
         if self.bus is not None:
             bus_xml = " bus='%s'" % self.bus
         ret += "      <target dev='%s'%s/>\n" % (disknode, bus_xml)
@@ -1698,7 +1709,7 @@ class VirtualDisk(VirtualDevice):
         # error as appropriate.
         if self.bus == "virtio":
             return ("vd", 1024)
-        elif self.bus in ["sata", "scsi", "usb"]:
+        elif self.bus in ["sata", "scsi", "usb", "virtio-scsi"]:
             return ("sd", 1024)
         elif self.bus == "xen":
             return ("xvd", 1024)
-- 
1.7.1




More information about the virt-tools-list mailing list