mirror of
https://github.com/virt-manager/virt-manager.git
synced 2025-02-25 18:55:27 -06:00
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)
This commit is contained in:
parent
b2a7c396de
commit
ad1b24e885
1
AUTHORS
1
AUTHORS
@ -85,6 +85,7 @@ Further patches have been submitted by:
|
|||||||
Marcus Karlsson <mk-at-acc.umu.se>
|
Marcus Karlsson <mk-at-acc.umu.se>
|
||||||
Michal Privoznik <mprivozn-at-redhat-dot-com>
|
Michal Privoznik <mprivozn-at-redhat-dot-com>
|
||||||
Martin Kletzander <mkletzan-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...>
|
<...send a patch & get your name here...>
|
||||||
|
|
||||||
|
@ -28,6 +28,7 @@ from virtinst import (VirtualCharDevice, VirtualDevice,
|
|||||||
VirtualVideoDevice, VirtualWatchdog,
|
VirtualVideoDevice, VirtualWatchdog,
|
||||||
VirtualFilesystem, VirtualSmartCardDevice,
|
VirtualFilesystem, VirtualSmartCardDevice,
|
||||||
VirtualRedirDevice)
|
VirtualRedirDevice)
|
||||||
|
from virtinst.VirtualController import VirtualControllerSCSI
|
||||||
|
|
||||||
import virtManager.util as util
|
import virtManager.util as util
|
||||||
import virtManager.uihelpers as uihelpers
|
import virtManager.uihelpers as uihelpers
|
||||||
@ -543,6 +544,8 @@ class vmmAddHardware(vmmGObjectUI):
|
|||||||
_("SATA disk"))
|
_("SATA disk"))
|
||||||
add_dev("virtio", virtinst.VirtualDisk.DEVICE_DISK,
|
add_dev("virtio", virtinst.VirtualDisk.DEVICE_DISK,
|
||||||
_("Virtio 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():
|
if self.conn.is_xen() or self.conn.is_test_conn():
|
||||||
add_dev("xen", virtinst.VirtualDisk.DEVICE_DISK,
|
add_dev("xen", virtinst.VirtualDisk.DEVICE_DISK,
|
||||||
_("Xen virtual disk"))
|
_("Xen virtual disk"))
|
||||||
@ -1154,9 +1157,15 @@ class vmmAddHardware(vmmGObjectUI):
|
|||||||
self._dev.get_xml_config()
|
self._dev.get_xml_config()
|
||||||
logging.debug("Adding device:\n" + 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
|
# Hotplug device
|
||||||
attach_err = False
|
attach_err = False
|
||||||
try:
|
try:
|
||||||
|
if controller is not None:
|
||||||
|
self.vm.attach_device(self._dev.vmm_controller)
|
||||||
self.vm.attach_device(self._dev)
|
self.vm.attach_device(self._dev)
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
logging.debug("Device could not be hotplugged: %s", str(e))
|
logging.debug("Device could not be hotplugged: %s", str(e))
|
||||||
@ -1179,6 +1188,8 @@ class vmmAddHardware(vmmGObjectUI):
|
|||||||
|
|
||||||
# Alter persistent config
|
# Alter persistent config
|
||||||
try:
|
try:
|
||||||
|
if controller is not None:
|
||||||
|
self.vm.add_device(self._dev.vmm_controller)
|
||||||
self.vm.add_device(self._dev)
|
self.vm.add_device(self._dev)
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
self.err.show_err(_("Error adding device: %s" % str(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()
|
bus, device = self.get_config_disk_target()
|
||||||
cache = self.get_config_disk_cache()
|
cache = self.get_config_disk_cache()
|
||||||
fmt = self.get_config_disk_format()
|
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
|
# Make sure default pool is running
|
||||||
if self.is_default_storage():
|
if self.is_default_storage():
|
||||||
@ -1318,6 +1333,17 @@ class vmmAddHardware(vmmGObjectUI):
|
|||||||
uihelpers.check_path_search_for_qemu(self.topwin,
|
uihelpers.check_path_search_for_qemu(self.topwin,
|
||||||
self.conn, disk.path)
|
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
|
self._dev = disk
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user