2677655bda
001-adf30349-cli-refactor-get_prop.patch 002-60c7e778-xmlapi-add-set_prop.patch 003-5bad22e8-tests-Use-get-set_prop.patch 004-ee5f3eab-support-Add-SUPPORT_CONN_DEVICE_BOOT_ORDER.patch 005-7768eb17-cli-Add-check-if-device-boot-order-is-supported.patch 006-ecc0861c-tests-xmlparse-refactor-method-for-generating-out-file-path.patch 007-c9d070da-guest-Add-reorder_boot_order-method.patch 008-1b535940-tests-Add-test-case-for-reorder_boot_order-method.patch 009-b83a0a61-cli-Use-reorder_boot_order-for-setting-the-boot-order.patch 010-c896d19d-tests-cli-Add-boot.order-tests.patch 011-29f9f2ac-virt-xml-Add-no-define-argument.patch 012-c2bff509-tests-cli-Add-test-case-for-no-define-argument.patch 013-90b1a3ab-virt-xml-Add-support-for-starting-the-domain.patch 014-908b8e8d-tests-virt-xml-Add-test-cases-for-start-option.patch OBS-URL: https://build.opensuse.org/package/show/Virtualization/virt-manager?expand=0&rev=468
104 lines
4.1 KiB
Diff
104 lines
4.1 KiB
Diff
References: jsc#SLE-6262, fate#327048: KVM: Boot Configuration Override (virt-manager)
|
|
|
|
Subject: virt-xml: Add support for starting the domain
|
|
From: Marc Hartmayer mhartmay@linux.ibm.com Tue Feb 26 10:56:43 2019 +0100
|
|
Date: Wed Mar 6 13:15:38 2019 -0500:
|
|
Git: 90b1a3ab7d9cb9c84e7dda7093ae2c97217fa591
|
|
|
|
Add support for starting the domain. By default, first the domain is
|
|
defined and then started. If the `--start` is used in combination with
|
|
`--no-define` a transient domain is created without persisting the
|
|
changes in the persistent domain definition.
|
|
|
|
Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com>
|
|
Reviewed-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
|
|
|
|
Index: virt-manager-2.1.0/virt-xml
|
|
===================================================================
|
|
--- virt-manager-2.1.0.orig/virt-xml
|
|
+++ virt-manager-2.1.0/virt-xml
|
|
@@ -257,9 +257,28 @@ def define_changes(conn, inactive_xmlobj
|
|
for dev in devs:
|
|
setup_device(dev)
|
|
|
|
- conn.defineXML(inactive_xmlobj.get_xml())
|
|
+ dom = conn.defineXML(inactive_xmlobj.get_xml())
|
|
print_stdout(_("Domain '%s' defined successfully.") % inactive_xmlobj.name)
|
|
- return True
|
|
+ return dom
|
|
+
|
|
+
|
|
+def start_domain_transient(conn, xmlobj, devs, action, confirm):
|
|
+ if confirm:
|
|
+ if not prompt_yes_or_no(
|
|
+ _("Start '%s' with the changed XML?") % xmlobj.name):
|
|
+ return False
|
|
+
|
|
+ if action == "hotplug":
|
|
+ for dev in devs:
|
|
+ setup_device(dev)
|
|
+
|
|
+ try:
|
|
+ dom = conn.createXML(xmlobj.get_xml())
|
|
+ except libvirt.libvirtError as e:
|
|
+ fail(_("Failed starting domain '%s': %s") % (xmlobj.name, e))
|
|
+ else:
|
|
+ print_stdout(_("Domain '%s' started successfully.") % xmlobj.name)
|
|
+ return dom
|
|
|
|
|
|
def update_changes(domain, devs, action, confirm):
|
|
@@ -370,6 +389,8 @@ def parse_args():
|
|
define_g.add_argument("--no-define", dest='define', action="store_false",
|
|
help=_("Force not defining the domain."))
|
|
define_g.set_defaults(define=None)
|
|
+ outg.add_argument("--start", action="store_true",
|
|
+ help=_("Start the domain."))
|
|
outg.add_argument("--print-diff", action="store_true",
|
|
help=_("Only print the requested change, in diff format"))
|
|
outg.add_argument("--print-xml", action="store_true",
|
|
@@ -411,6 +432,9 @@ def main(conn=None):
|
|
options.quiet = False
|
|
cli.setupLogging("virt-xml", options.debug, options.quiet)
|
|
|
|
+ if options.update and options.start:
|
|
+ fail(_("Either update or start a domain"))
|
|
+
|
|
if cli.check_option_introspection(options):
|
|
return 0
|
|
|
|
@@ -468,14 +492,27 @@ def main(conn=None):
|
|
else:
|
|
logging.warning(
|
|
_("The VM is not running, --update is inapplicable."))
|
|
- if options.define:
|
|
+
|
|
+ if options.define or options.start:
|
|
devs, action = prepare_changes(inactive_xmlobj, options, parserclass)
|
|
- applied = define_changes(conn, inactive_xmlobj,
|
|
+ if options.define:
|
|
+ dom = define_changes(conn, inactive_xmlobj,
|
|
devs, action, options.confirm)
|
|
- if not options.update and active_xmlobj and applied:
|
|
- print_stdout(
|
|
- _("Changes will take effect after the domain is fully powered off."))
|
|
- if not options.update and not options.define:
|
|
+ if dom and options.start:
|
|
+ try:
|
|
+ dom.create()
|
|
+ except libvirt.libvirtError as e:
|
|
+ fail(_("Failed starting domain '%s': %s") % (inactive_xmlobj.name, e))
|
|
+ print_stdout(_("Domain '%s' started successfully.") %
|
|
+ inactive_xmlobj.name)
|
|
+ elif not options.update and active_xmlobj and dom:
|
|
+ print_stdout(
|
|
+ _("Changes will take effect after the domain is fully powered off."))
|
|
+ else:
|
|
+ dom = start_domain_transient(conn, inactive_xmlobj, devs,
|
|
+ action, options.confirm)
|
|
+
|
|
+ if not options.update and not options.define and not options.start:
|
|
prepare_changes(inactive_xmlobj, options, parserclass)
|
|
|
|
return 0
|