2012-02-03 16:47:45 +01:00
|
|
|
Index: virt-manager-0.9.1/src/virtManager/addhardware.py
|
2010-03-21 11:56:54 +01:00
|
|
|
===================================================================
|
2012-02-03 16:47:45 +01:00
|
|
|
--- virt-manager-0.9.1.orig/src/virtManager/addhardware.py
|
|
|
|
+++ virt-manager-0.9.1/src/virtManager/addhardware.py
|
|
|
|
@@ -1140,6 +1140,18 @@ class vmmAddHardware(vmmGObjectUI):
|
2010-03-21 11:56:54 +01:00
|
|
|
self._dev.get_xml_config()
|
|
|
|
logging.debug("Adding device:\n" + self._dev.get_xml_config())
|
|
|
|
|
|
|
|
+ # If vm is active, Try to hotplug the device and modify persistent
|
|
|
|
+ # config in one go
|
|
|
|
+ if self.vm.is_active():
|
|
|
|
+ try:
|
|
|
|
+ self.vm.attach_device_flags(self._dev, 3)
|
|
|
|
+ return (False, None)
|
|
|
|
+ except Exception, e:
|
|
|
|
+ logging.debug("Could not hotplug device and modify persistent "
|
|
|
|
+ "config at the same time: %s" % str(e))
|
|
|
|
+ logging.debug("Trying the operations seperately ...")
|
|
|
|
+
|
|
|
|
+ # Try hotplug then modify persistent config
|
|
|
|
# Hotplug device
|
|
|
|
attach_err = False
|
|
|
|
try:
|
2012-02-03 16:47:45 +01:00
|
|
|
Index: virt-manager-0.9.1/src/virtManager/details.py
|
2010-03-21 11:56:54 +01:00
|
|
|
===================================================================
|
2012-02-03 16:47:45 +01:00
|
|
|
--- virt-manager-0.9.1.orig/src/virtManager/details.py
|
|
|
|
+++ virt-manager-0.9.1/src/virtManager/details.py
|
|
|
|
@@ -2351,6 +2351,17 @@ class vmmDetails(vmmGObjectUI):
|
2011-09-20 17:08:57 +02:00
|
|
|
text1=(_("Are you sure you want to remove this device?"))):
|
|
|
|
return
|
2010-03-21 11:56:54 +01:00
|
|
|
|
|
|
|
+ # If vm is running, try to hot remove the device and modify
|
|
|
|
+ # persistent config in one go
|
|
|
|
+ if self.vm.is_active():
|
|
|
|
+ try:
|
|
|
|
+ self.vm.detach_device_flags(dev_type, dev_id_info, 3)
|
|
|
|
+ return
|
|
|
|
+ except Exception, e:
|
|
|
|
+ logging.debug("Could not hot remove device and modify "
|
|
|
|
+ "persistent config at the same time: %s" % str(e))
|
|
|
|
+ logging.debug("Trying the operations seperately ...")
|
|
|
|
+
|
|
|
|
# Define the change
|
|
|
|
try:
|
2011-03-21 20:38:43 +01:00
|
|
|
self.vm.remove_device(dev_id_info)
|
2012-02-03 16:47:45 +01:00
|
|
|
Index: virt-manager-0.9.1/src/virtManager/domain.py
|
2010-03-21 11:56:54 +01:00
|
|
|
===================================================================
|
2012-02-03 16:47:45 +01:00
|
|
|
--- virt-manager-0.9.1.orig/src/virtManager/domain.py
|
|
|
|
+++ virt-manager-0.9.1/src/virtManager/domain.py
|
|
|
|
@@ -757,6 +757,10 @@ class vmmDomain(vmmLibvirtObject):
|
2011-03-21 20:38:43 +01:00
|
|
|
devxml = devobj.get_xml_config()
|
2010-04-03 00:21:37 +02:00
|
|
|
self._backend.attachDevice(devxml)
|
2010-03-21 11:56:54 +01:00
|
|
|
|
|
|
|
+ def attach_device_flags(self, devobj, flags):
|
|
|
|
+ xml = devobj.get_xml_config()
|
|
|
|
+ self._backend.attachDeviceFlags(xml, flags)
|
|
|
|
+
|
2011-03-21 20:38:43 +01:00
|
|
|
def detach_device(self, devobj):
|
2010-03-21 11:56:54 +01:00
|
|
|
"""
|
|
|
|
Hotunplug device from running guest
|
2012-02-03 16:47:45 +01:00
|
|
|
@@ -775,6 +779,10 @@ class vmmDomain(vmmLibvirtObject):
|
2011-03-21 20:38:43 +01:00
|
|
|
xml = devobj.get_xml_config()
|
|
|
|
self._backend.updateDeviceFlags(xml, flags)
|
2010-03-21 11:56:54 +01:00
|
|
|
|
|
|
|
+ def detach_device_flags(self, devtype, dev_id_info, flags):
|
|
|
|
+ xml = self._get_device_xml(devtype, dev_id_info)
|
|
|
|
+ self._backend.detachDeviceFlags(xml, flags)
|
|
|
|
+
|
|
|
|
def hotplug_vcpus(self, vcpus):
|
|
|
|
vcpus = int(vcpus)
|
|
|
|
if vcpus != self.vcpu_count():
|