mirror of
https://github.com/virt-manager/virt-manager.git
synced 2025-02-25 18:55:27 -06:00
Make sure that persistent VM config is updated after successful hotplug.
This commit is contained in:
parent
f784eacf53
commit
d257ead552
@ -846,6 +846,7 @@ class vmmAddHardware(gobject.GObject):
|
||||
|
||||
logging.debug("Adding device:\n" + xml)
|
||||
|
||||
# Hotplug device
|
||||
attach_err = False
|
||||
try:
|
||||
self.vm.attach_device(xml)
|
||||
@ -862,12 +863,14 @@ class vmmAddHardware(gobject.GObject):
|
||||
"next VM shutdown?")):
|
||||
return
|
||||
|
||||
if self.vm.is_active() and not attach_err:
|
||||
# Attach device should alter xml for us
|
||||
# Alter persistent config
|
||||
try:
|
||||
self.vm.add_device(xml)
|
||||
except Exception, e:
|
||||
self.err.show_err(_("Error adding device: %s" % str(e)),
|
||||
"".join(traceback.format_exc()))
|
||||
return
|
||||
|
||||
self.vm.add_device(xml)
|
||||
|
||||
def do_file_allocate(self, disk, asyncjob):
|
||||
meter = vmmCreateMeter(asyncjob)
|
||||
newconn = None
|
||||
|
@ -1111,16 +1111,7 @@ class vmmDetails(gobject.GObject):
|
||||
return
|
||||
self.config.set_confirm_removedev(not skip_prompt)
|
||||
|
||||
detach_err = False
|
||||
devxml = self.vm.get_device_xml(dev_type, dev_id_info)
|
||||
try:
|
||||
if self.vm.is_active():
|
||||
self.vm.detach_device(devxml)
|
||||
return
|
||||
except Exception, e:
|
||||
logging.debug("Device could not be hotUNplugged: %s" % str(e))
|
||||
detach_err = True
|
||||
|
||||
# Define the change
|
||||
try:
|
||||
self.vm.remove_device(dev_type, dev_id_info)
|
||||
except Exception, e:
|
||||
@ -1128,6 +1119,16 @@ class vmmDetails(gobject.GObject):
|
||||
"".join(traceback.format_exc()))
|
||||
return
|
||||
|
||||
# Try to hot remove
|
||||
detach_err = False
|
||||
devxml = self.vm.get_device_xml(dev_type, dev_id_info)
|
||||
try:
|
||||
if self.vm.is_active():
|
||||
self.vm.detach_device(devxml)
|
||||
except Exception, e:
|
||||
logging.debug("Device could not be hotUNplugged: %s" % str(e))
|
||||
detach_err = True
|
||||
|
||||
if detach_err:
|
||||
self.err.show_info(
|
||||
_("Device could not be removed from the running machine."),
|
||||
|
Loading…
Reference in New Issue
Block a user