virt-manager/76bad650-fix-virt-xml-define-and-update.patch
Charles Arnold dd8a28d4b2 - bsc#937336 - ImportError using virt-install
virt-manager.spec
- Upstream bug fixes
  76bad650-fix-virt-xml-define-and-update.patch
  fc93e154-fix-udp-tcp-host-vs-mode-UI.patch
  34db1af7-fix-adding-iscsi-pools.patch
  77423e7a-connection-catch-more-errors-in-filter_nodedevs.patch
- fate#318394: Update to version 1.2.1

OBS-URL: https://build.opensuse.org/package/show/Virtualization/virt-manager?expand=0&rev=241
2015-07-10 14:37:12 +00:00

115 lines
3.7 KiB
Diff

Subject: virt-xml: refactor the handling of --define and --update options
From: Pavel Hrdina phrdina@redhat.com Thu Jul 2 14:09:46 2015 +0200
Date: Tue Jul 7 10:42:32 2015 -0400:
Git: 76bad650dea9f83305f4a77bf83dee34d79e5308
The code was wrong in many ways. The main issue was, that for live
updates we were using config XML instead of live XML.
This patch fixes the --update and --define options to work properly as
described in man page.
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1192875
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
diff --git a/virt-xml b/virt-xml
index 744af3d..5dbe2e1 100755
--- a/virt-xml
+++ b/virt-xml
@@ -295,6 +295,33 @@ def update_changes(domain, devs, action, confirm):
print_stdout("")
+def prepare_changes(xmlobj, options, parsermap, parserobj):
+ origxml = xmlobj.get_xml_config()
+
+ if options.edit != -1:
+ devs = action_edit(xmlobj, options, parsermap, parserobj)
+ action = "update"
+
+ elif options.add_device:
+ devs = action_add_device(xmlobj, options, parsermap, parserobj)
+ action = "hotplug"
+
+ elif options.remove_device:
+ devs = action_remove_device(xmlobj, options, parsermap, parserobj)
+ action = "hotunplug"
+
+ newxml = xmlobj.get_xml_config()
+ diff = get_diff(origxml, newxml)
+
+ if options.print_diff:
+ if diff:
+ print_stdout(diff)
+ elif options.print_xml:
+ print_stdout(newxml)
+
+ return devs, action
+
+
#######################
# CLI option handling #
#######################
@@ -410,10 +437,6 @@ def main(conn=None):
elif not options.build_xml:
inactive_xmlobj = _make_guest(conn, options.stdinxml)
- origxml = None
- if inactive_xmlobj:
- origxml = inactive_xmlobj.get_xml_config()
-
check_action_collision(options)
parserobj = check_xmlopt_collision(options, parsermap)
@@ -421,42 +444,25 @@ def main(conn=None):
fail(_("Don't know how to --update for --%s") %
(parserobj.cli_arg_name))
- if options.edit != -1:
- devs = action_edit(inactive_xmlobj, options, parsermap, parserobj)
- action = "update"
-
- elif options.add_device:
- devs = action_add_device(inactive_xmlobj, options,
- parsermap, parserobj)
- action = "hotplug"
-
- elif options.remove_device:
- devs = action_remove_device(inactive_xmlobj, options,
- parsermap, parserobj)
- action = "hotunplug"
-
- elif options.build_xml:
+ if options.build_xml:
devs = action_build_xml(conn, options, parsermap, parserobj)
for dev in util.listify(devs):
print_stdout(dev.get_xml_config())
return 0
- newxml = inactive_xmlobj.get_xml_config()
- diff = get_diff(origxml, newxml)
-
- if options.print_diff:
- if diff:
- print_stdout(diff)
- elif options.print_xml:
- print_stdout(newxml)
-
if options.update and active_xmlobj:
+ devs, action = prepare_changes(active_xmlobj, options,
+ parsermap, parserobj)
update_changes(domain, devs, action, options.confirm)
if options.define:
+ devs, action = prepare_changes(inactive_xmlobj, options,
+ parsermap, parserobj)
define_changes(conn, inactive_xmlobj, devs, action, options.confirm)
if not options.update and active_xmlobj:
print_stdout(
_("Changes will take effect after the next domain shutdown."))
+ if not options.update and not options.define:
+ prepare_changes(inactive_xmlobj, options, parsermap, parserobj)
return 0