summaryrefslogtreecommitdiff
path: root/virt-xml
diff options
context:
space:
mode:
authorCole Robinson <crobinso@redhat.com>2018-03-20 17:23:34 -0400
committerCole Robinson <crobinso@redhat.com>2018-03-21 11:17:36 -0400
commit7b61c45d3b5b6c6cf1207fca79a1b07566d1b06d (patch)
treea1a0baff6535c135265a4242fd45dc84b82fe6c1 /virt-xml
parentfe9ed2340cd5b62c2c212bbe269064e91b345643 (diff)
downloadvirt-manager-7b61c45d3b5b6c6cf1207fca79a1b07566d1b06d.tar.gz
guest: Move all_devices to guest.devices.X
The way we enumerate devices doesn't conform with the way all other XMLBuilder instances expose child objects. Move more towards that direction. This requires some virt-xml and cli.py hacks but we will remove those in future patches
Diffstat (limited to 'virt-xml')
-rwxr-xr-xvirt-xml19
1 files changed, 14 insertions, 5 deletions
diff --git a/virt-xml b/virt-xml
index a4a044c1..dc39b265 100755
--- a/virt-xml
+++ b/virt-xml
@@ -92,7 +92,10 @@ def get_domain_and_guest(conn, domstr):
################
def _find_objects_to_edit(guest, action_name, editval, parserclass):
- objlist = guest.list_children_for_class(parserclass.objclass)
+ if issubclass(parserclass.objclass, virtinst.Device):
+ objlist = guest.devices.list_children_for_class(parserclass.objclass)
+ else:
+ objlist = guest.list_children_for_class(parserclass.objclass)
idx = None
if editval is None:
@@ -179,16 +182,22 @@ def action_edit(guest, options, parserclass):
return cli.parse_option_strings(options, guest, inst, update=True)
+def _is_singleton(guest, objclass):
+ if not objclass:
+ return True
+ if issubclass(objclass, virtinst.devices.Device):
+ return False
+ return guest.child_class_is_singleton(objclass)
+
+
def action_add_device(guest, options, parserclass):
- if (not parserclass.objclass or
- guest.child_class_is_singleton(parserclass.objclass)):
+ if _is_singleton(guest, parserclass.objclass):
fail(_("Cannot use --add-device with --%s") % parserclass.cli_arg_name)
return cli.parse_option_strings(options, guest, None)
def action_remove_device(guest, options, parserclass):
- if (not parserclass.objclass or
- guest.child_class_is_singleton(parserclass.objclass)):
+ if _is_singleton(guest, parserclass.objclass):
fail(_("Cannot use --remove-device with --%s") %
parserclass.cli_arg_name)