summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChenHanxiao <chenhanxiao@cn.fujitsu.com>2012-12-07 18:21:38 +0800
committerCole Robinson <crobinso@redhat.com>2012-12-09 14:28:42 -0500
commitad1b24e885670d36b4ffd3a96434fd19dbe2ce98 (patch)
treeefde58c99ca2eb247954ee31ea7f6a5be00d91d2
parentb2a7c396de511f47bedfdff172a2835b32b63a0e (diff)
downloadvirt-manager-ad1b24e885670d36b4ffd3a96434fd19dbe2ce98.tar.gz
Add virtio-scsi disk bus option
This patch will add virtio-scsi bus option on "Add New Virtual Hardware" GUI page. It will support users to add a virtual disk using SCSI bus with a controller model virtio-scsi. If there is no SCSI controller existed, a new SCSI controller by model 'virtio-scsi' will be added automatically. Signed-off-by: ChenHanxiao <chenhanxiao@cn.fujitsu.com> (crobinso: add Chen to AUTHORS, some cosmetic tweaks)
-rw-r--r--AUTHORS1
-rw-r--r--src/virtManager/addhardware.py26
2 files changed, 27 insertions, 0 deletions
diff --git a/AUTHORS b/AUTHORS
index c575da26..80138678 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -85,6 +85,7 @@ Further patches have been submitted by:
Marcus Karlsson <mk-at-acc.umu.se>
Michal Privoznik <mprivozn-at-redhat-dot-com>
Martin Kletzander <mkletzan-at-redhat-dot-com>
+ ChenHanxiao <chenhanxiao-at-cn-dot-fujitsu-dot-com>
<...send a patch & get your name here...>
diff --git a/src/virtManager/addhardware.py b/src/virtManager/addhardware.py
index 1fb7e83e..25a3068b 100644
--- a/src/virtManager/addhardware.py
+++ b/src/virtManager/addhardware.py
@@ -28,6 +28,7 @@ from virtinst import (VirtualCharDevice, VirtualDevice,
VirtualVideoDevice, VirtualWatchdog,
VirtualFilesystem, VirtualSmartCardDevice,
VirtualRedirDevice)
+from virtinst.VirtualController import VirtualControllerSCSI
import virtManager.util as util
import virtManager.uihelpers as uihelpers
@@ -543,6 +544,8 @@ class vmmAddHardware(vmmGObjectUI):
_("SATA disk"))
add_dev("virtio", virtinst.VirtualDisk.DEVICE_DISK,
_("Virtio disk"))
+ add_dev("virtio-scsi", virtinst.VirtualDisk.DEVICE_DISK,
+ _("Virtio SCSI disk"))
if self.conn.is_xen() or self.conn.is_test_conn():
add_dev("xen", virtinst.VirtualDisk.DEVICE_DISK,
_("Xen virtual disk"))
@@ -1154,9 +1157,15 @@ class vmmAddHardware(vmmGObjectUI):
self._dev.get_xml_config()
logging.debug("Adding device:\n" + self._dev.get_xml_config())
+ controller = getattr(self._dev, "vmm_controller", None)
+ if controller is not None:
+ logging.debug("Adding controller:\n%s",
+ self._dev.vmm_controller.get_xml_config())
# Hotplug device
attach_err = False
try:
+ if controller is not None:
+ self.vm.attach_device(self._dev.vmm_controller)
self.vm.attach_device(self._dev)
except Exception, e:
logging.debug("Device could not be hotplugged: %s", str(e))
@@ -1179,6 +1188,8 @@ class vmmAddHardware(vmmGObjectUI):
# Alter persistent config
try:
+ if controller is not None:
+ self.vm.add_device(self._dev.vmm_controller)
self.vm.add_device(self._dev)
except Exception, e:
self.err.show_err(_("Error adding device: %s" % str(e)))
@@ -1224,6 +1235,10 @@ class vmmAddHardware(vmmGObjectUI):
bus, device = self.get_config_disk_target()
cache = self.get_config_disk_cache()
fmt = self.get_config_disk_format()
+ controller_model = None
+ if bus == "virtio-scsi":
+ bus = "scsi"
+ controller_model = "virtio-scsi"
# Make sure default pool is running
if self.is_default_storage():
@@ -1318,6 +1333,17 @@ class vmmAddHardware(vmmGObjectUI):
uihelpers.check_path_search_for_qemu(self.topwin,
self.conn, disk.path)
+ # Add a SCSI controller with model virtio-scsi if needed
+ disk.vmm_controller = None
+ if (controller_model == "virtio-scsi") and (bus == "scsi"):
+ controllers = self.vm.get_controller_devices()
+ controller = VirtualControllerSCSI(conn = self.conn.vmm)
+ controller.set_model(controller_model)
+ disk.vmm_controller = controller
+ for d in controllers:
+ if controller_model == d.model:
+ disk.vmm_controller = None
+
self._dev = disk
return True