diff --git a/tests/clitest.py b/tests/clitest.py index 611f9d7cb..c9b1f6ec1 100644 --- a/tests/clitest.py +++ b/tests/clitest.py @@ -1086,6 +1086,7 @@ c = vixml.add_category("misc", "") c.add_valid("--help") # basic --help test c.add_valid("--sound=? --tpm=?") # basic introspection test c.add_valid("test-state-shutoff --edit --update --boot menu=on", grep="The VM is not running") # --update with inactive VM, should work but warn +c.add_valid("test-state-shutoff --edit --boot menu=on", grep="XML did not change after domain define") # menu=on is discarded because is specified c.add_valid("test-for-virtxml --edit --graphics password=foo --update --confirm", input_text="no\nno\n") # prompt exiting c.add_valid("test-for-virtxml --edit --cpu host-passthrough --no-define --start --confirm", input_text="no") # transient prompt exiting c.add_valid("test-for-virtxml --edit --metadata name=test-for-virtxml", grep="requested changes will have no effect") diff --git a/virt-xml b/virt-xml index 5ed470f45..1fbf2bbbe 100755 --- a/virt-xml +++ b/virt-xml @@ -103,6 +103,12 @@ def get_domain_and_guest(conn, domstr): return (domain, inactive_xmlobj, active_xmlobj) +def defined_xml_is_unchanged(conn, domain, original_xml): + rawxml = get_xmldesc(domain, inactive=True) + new_xml = virtinst.Guest(conn, parsexml=rawxml) + return new_xml != original_xml + + ################ # Change logic # ################ @@ -522,6 +528,7 @@ def main(conn=None): # It's hard to hit this case with the test suite return 0 # pragma: no cover + original_xml = inactive_xmlobj.get_xml() devs, action = prepare_changes(inactive_xmlobj, options, parserclass) if not options.define: if options.start: @@ -547,6 +554,9 @@ def main(conn=None): elif vm_is_running and not performed_update: print_stdout( _("Changes will take effect after the domain is fully powered off.")) + elif defined_xml_is_unchanged(conn, domain, original_xml): + logging.warning(_("XML did not change after domain define. You may " + "have changed a value that libvirt is setting by default.")) return 0