virt-xml: If no XML diff is generated, explicitly warn

This commit is contained in:
Cole Robinson 2019-06-16 15:13:54 -04:00
parent 9ed926a898
commit 0221471e4f
2 changed files with 5 additions and 1 deletions

View File

@ -1088,7 +1088,7 @@ c.add_valid("--sound=? --tpm=?") # basic introspection test
c.add_valid("test-state-shutoff --edit --update --boot menu=on") # --update with inactive VM, should work but warn
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") # 'no diff' code path
c.add_valid("test-for-virtxml --edit --metadata name=test-for-virtxml", grep="requested changes will have no effect")
c.add_invalid("test --edit 2 --events on_poweroff=destroy", grep="'--edit 2' doesn't make sense with --events")
c.add_invalid("test --os-variant fedora26 --edit --cpu host-passthrough", grep="--os-variant is not supported")
c.add_invalid("test-for-virtxml --os-variant fedora26 --remove-device --disk 1", grep="--os-variant is not supported")

View File

@ -333,6 +333,10 @@ def prepare_changes(xmlobj, options, parserclass):
newxml = xmlobj.get_xml()
diff = get_diff(origxml, newxml)
if not diff:
logging.warning(_("No XML diff was generated. The requested "
"changes will have no effect."))
if options.print_diff:
if diff:
print_stdout(diff)