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

Cole Robinson crobinso at redhat.com
Tue Nov 27 15:58:13 UTC 2012


On 11/12/2012 03:13 AM, Chen Hanxiao wrote:
> From: ChenHanxiao <chenhanxiao at cn.fujitsu.com>
> 
> Introduce a new attribute 'model' to support virtio-scsi disk with SCSI
> controller type 'virtio-scsi'
> 

Does libvirt <disk> even have a model attribute? I don't see one in libvirt.git

- Cole

> Signed-off-by: ChenHanxiao <chenhanxiao at cn.fujitsu.com>
> ---
>  virtinst/VirtualDisk.py |   23 +++++++++++++++++++----
>  1 files changed, 19 insertions(+), 4 deletions(-)
> 
> diff --git a/virtinst/VirtualDisk.py b/virtinst/VirtualDisk.py
> index 2eeb43d..d340313 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,9 +1529,13 @@ 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
> +            print "bus is %s" %self.bus
> +            if self.model is not None:
> +                bus_xml = " bus='%s' model='%s'" % (self.bus, self.model)
> +            else:
> +                bus_xml = " bus='%s'" % self.bus
>          ret += "      <target dev='%s'%s/>\n" % (disknode, bus_xml)
>  
>          ro = self.read_only
> @@ -1698,7 +1713,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)
> 




More information about the virt-tools-list mailing list