[virt-tools-list] [virt-manager PATCH v2 2/2] add support for modifying scsi controller model
Chen Hanxiao
chenhanxiao at cn.fujitsu.com
Mon Jan 20 12:15:11 UTC 2014
From: Chen Hanxiao <chenhanxiao at cn.fujitsu.com>
We could modify scsi controller model
between 'default' and 'virtio-scsi'.
Signed-off-by: Chen Hanxiao <chenhanxiao at cn.fujitsu.com>
---
v2: fix an issue if no scsi controller existed
virtManager/domain.py | 39 +++++++++++++++++++++++++++++++++------
1 file changed, 33 insertions(+), 6 deletions(-)
diff --git a/virtManager/domain.py b/virtManager/domain.py
index ada404b..f590c5e 100644
--- a/virtManager/domain.py
+++ b/virtManager/domain.py
@@ -822,27 +822,54 @@ class vmmDomain(vmmLibvirtObject):
# Controller define methods
def define_controller_model(self, devobj, newmodel):
+ #model list from libvirt
+ usb_controller_model = ["default", "piix3-uhci", "piix4-uhci",
+ "ehci", "ich9-ehci1", "ich9-uhci1", "ich9-uhci2",
+ "ich9-uhci3", "vt82c686b-uhci", "pci-ohci", "nec-xhci"]
+ scsi_controller_model = ["default_virtio_scsi", "auto", "buslogic",
+ "lsilogic", "lsisas1068", "vmpvscsi", "ibmvscsi", "virtio-scsi",
+ "lsisas1078"]
+
def change(editdev):
ignore = editdev
guest = self._get_xmlobj_to_define()
ctrls = guest.get_devices("controller")
- ctrls = [x for x in ctrls if (x.type ==
- VirtualController.TYPE_USB)]
- for dev in ctrls:
- guest.remove_device(dev)
-
+ ctrls_usb = [x for x in ctrls if
+ (x.type == VirtualController.TYPE_USB)]
+ ctrls_scsi = [x for x in ctrls if
+ (x.type == VirtualController.TYPE_SCSI)]
+
+ for dev in ctrls_usb:
+ if newmodel in usb_controller_model:
+ guest.remove_device(dev)
if newmodel == "ich9-ehci1":
for dev in VirtualController.get_usb2_controllers(
guest.conn):
guest.add_device(dev)
- else:
+ elif newmodel in usb_controller_model:
dev = VirtualController(guest.conn)
dev.type = "usb"
if newmodel != "default":
dev.model = newmodel
guest.add_device(dev)
+ if len(ctrls_scsi) > 0:
+ index_new = max([x.index for x in ctrls_scsi]) + 1
+
+ for dev in ctrls_scsi:
+ if newmodel in scsi_controller_model:
+ guest.remove_device(dev)
+ for dev in ctrls_scsi:
+ if newmodel == "virtio-scsi":
+ dev = VirtualController(guest.conn)
+ dev.type = "scsi"
+ dev.index = index_new
+ if newmodel != "default":
+ dev.model = newmodel
+ guest.add_device(dev)
+ break
+
return self._redefine_device(change, devobj)
--
1.8.2.1
More information about the virt-tools-list
mailing list