mirror of
https://github.com/virt-manager/virt-manager.git
synced 2025-01-08 21:18:04 +03:00
virtinst: unify detection of duplicate console when removing device
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
This commit is contained in:
parent
29145b9e93
commit
ef64949e84
@ -622,21 +622,11 @@ class vmmDomain(vmmLibvirtObject):
|
||||
"""
|
||||
Remove passed device from the inactive guest XML
|
||||
"""
|
||||
# If serial and duplicate console are both present, they both need
|
||||
# to be removed at the same time
|
||||
con = None
|
||||
if self.serial_is_console_dup(devobj):
|
||||
con = self.xmlobj.devices.console[0]
|
||||
|
||||
xmlobj = self._make_xmlobj_to_define()
|
||||
editdev = self._lookup_device_to_define(xmlobj, devobj, False)
|
||||
if not editdev:
|
||||
return # pragma: no cover
|
||||
|
||||
if con:
|
||||
rmcon = xmlobj.find_device(con)
|
||||
if rmcon:
|
||||
xmlobj.remove_device(rmcon)
|
||||
xmlobj.remove_device(editdev)
|
||||
|
||||
self._redefine_xmlobj(xmlobj)
|
||||
|
@ -501,8 +501,11 @@ class Guest(XMLBuilder):
|
||||
|
||||
def add_device(self, dev):
|
||||
self.devices.add_child(dev)
|
||||
|
||||
def remove_device(self, dev):
|
||||
self.devices.remove_child(dev)
|
||||
self._remove_duplicate_console(dev)
|
||||
|
||||
devices = XMLChildProperty(_DomainDevices, is_single=True)
|
||||
|
||||
def find_device(self, origdev):
|
||||
@ -1212,3 +1215,9 @@ class Guest(XMLBuilder):
|
||||
self._add_spice_channels()
|
||||
self._add_spice_sound()
|
||||
self._add_spice_usbredir()
|
||||
|
||||
def _remove_duplicate_console(self, dev):
|
||||
condup = DeviceConsole.get_console_duplicate(self, dev)
|
||||
if condup:
|
||||
log.debug("Found duplicate console device:\n%s", condup.get_xml())
|
||||
self.devices.remove_child(condup)
|
||||
|
@ -10,7 +10,6 @@ import libvirt
|
||||
|
||||
from . import cli
|
||||
from .cli import fail, fail_conflicting, print_stdout, print_stderr
|
||||
from .devices import DeviceConsole
|
||||
from .guest import Guest
|
||||
from .logger import log
|
||||
from . import xmlutil
|
||||
@ -189,13 +188,6 @@ def action_remove_device(guest, options, parserclass):
|
||||
getattr(options, parserclass.cli_arg_name)[-1], parserclass)
|
||||
devs = xmlutil.listify(devs)
|
||||
|
||||
# Check for console duplicate devices
|
||||
for dev in devs[:]:
|
||||
condup = DeviceConsole.get_console_duplicate(guest, dev)
|
||||
if condup:
|
||||
log.debug("Found duplicate console device:\n%s", condup.get_xml())
|
||||
devs.append(condup)
|
||||
|
||||
for dev in devs:
|
||||
guest.remove_device(dev)
|
||||
return devs
|
||||
|
Loading…
Reference in New Issue
Block a user