[virt-tools-list] [PATCH] [virt-manager v4]Add virtio-scsi disk bus option
Chen Hanxiao
chenhanxiao at cn.fujitsu.com
Fri Dec 7 10:21:38 UTC 2012
From: ChenHanxiao <chenhanxiao at cn.fujitsu.com>
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 at cn.fujitsu.com>
---
src/virtManager/addhardware.py | 26 ++++++++++++++++++++++++++
1 files changed, 26 insertions(+), 0 deletions(-)
diff --git a/src/virtManager/addhardware.py b/src/virtManager/addhardware.py
index 1fb7e83..1802331 100644
--- a/src/virtManager/addhardware.py
+++ b/src/virtManager/addhardware.py
@@ -34,6 +34,7 @@ import virtManager.uihelpers as uihelpers
from virtManager.asyncjob import vmmAsyncJob
from virtManager.storagebrowse import vmmStorageBrowser
from virtManager.baseclass import vmmGObjectUI
+from virtinst.VirtualController import VirtualControllerSCSI
PAGE_ERROR = 0
PAGE_DISK = 1
@@ -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"
+ + 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
--
1.7.1
More information about the virt-tools-list
mailing list