[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [virt-tools-list] [virtinst][Patch v2] Add attribute'model' in VirtualDisk class



Ping...

> -----Original Message-----
> From: Chen Hanxiao [mailto:chenhanxiao cn fujitsu com]
> Sent: Friday, November 16, 2012 5:36 PM
> To: virt-tools-list redhat com
> Cc: chenhanxiao cn fujitsu com
> Subject: [virt-tools-list][virtinst][Patch v2] Add attribute'model' in
VirtualDisk
> class
> 
> From: ChenHanxiao <chenhanxiao cn fujitsu com>
> 
> Introduce a new attribute 'model' to VirtualDisk for helping virtual disks
to set
> bus model if needed.
> It can support virtio-scsi disk with SCSI controller by model
'virtio-scsi'.
> 
> Signed-off-by: ChenHanxiao <chenhanxiao 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)
> --
> 1.7.1




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]