From 53f075ab76e1c372474ae0d88f202e487d9f213f Mon Sep 17 00:00:00 2001 From: Cole Robinson Date: Sun, 16 Jun 2019 17:01:32 -0400 Subject: virt-xml: Warn if libvirt discards our defined changes This can happen if we try to remove a default device, like a ps2 mouse on x86, but it can happen for many other reasons as well https://bugzilla.redhat.com/show_bug.cgi?id=1405263 --- virt-xml | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'virt-xml') diff --git a/virt-xml b/virt-xml index 5ed470f4..1fbf2bbb 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 -- cgit v1.2.1