virt-xml: Disable clearxml= for devices

It doesn't work in the general case, and users can just --remove and
--add devices as needed for the same effect
This commit is contained in:
Cole Robinson 2014-12-04 15:17:34 -05:00
parent 8d6ffafa1b
commit e992cc15b2
4 changed files with 4 additions and 26 deletions

View File

@ -62,7 +62,7 @@ Edit the specified XML block. EDIT-OPTIONS tell B<virt-xml> which block to edit.
Certain XML options only ever map to a single XML block, like --cpu, --security, --boot, --clock, and a few others. In those cases, B<virt-xml> will not complain if a corresponding XML block does not already exist, it will create it for you.
Every XML option has a special value 'clearxml=yes'. When combined with --edit, it will completely blank out the XML block being edited before applying the requested changes. This allows completely rebuilding an XML block. See EXAMPLES for some usage.
Some XML option support a special value 'clearxml=yes'. When combined with --edit, it will completely blank out the XML block being edited before applying the requested changes. This allows completely rebuilding an XML block. See EXAMPLES for some usage.
EDIT-OPTIONS examples:
@ -230,8 +230,6 @@ Generally these options map pretty straightforwardly to the libvirt XML, documen
Option strings are in the format of: --option opt=val,opt2=val2,... example: --disk path=/tmp/foo,shareable=on. Properties can be used with '--option opt=,', so to clear a disks cache setting you could use '--disk cache=,'
Every XML option has a special value 'clearxml=yes'. When combined with --edit, it will completely blank out the XML block being edited before applying the requested changes. This allows completely rebuilding an XML block. See EXAMPLES for some usage.
For any option, use --option=? to see a list of all available sub options, example: --disk=? or --boot=?
--help output also lists a few general examples. See the EXAMPLES section below for some common examples.

View File

@ -1,16 +0,0 @@
</pm>
<devices>
<emulator>/usr/lib/xen/bin/qemu-dm</emulator>
- <disk type="block" device="floppy">
- <source dev="/dev/null"/>
+ <disk device="floppy">
<target dev="fda" bus="fdc"/>
- <boot order="5"/>
- <address type="drive" controller="0" bus="0" target="0" unit="0"/>
+ <source file="/foo/bar"/>
</disk>
<disk type="dir" device="floppy">
<source dir="/tmp"/>
Domain 'test-many-devices' defined successfully.
Changes will take effect after the next domain shutdown.

View File

@ -844,9 +844,9 @@ c.add_compare("--edit mac=00:11:7f:33:44:55 --network target=nic55", "edit-selec
c = vixml.add_category("edit clear", "test-many-devices --print-diff --define", compare_check=support.SUPPORT_CONN_INPUT_KEYBOARD)
c.add_invalid("--edit --memory 200,clearxml=yes") # clear isn't wired up for memory
c.add_invalid("--edit --disk /foo/bar,target=fda,bus=fdc,device=floppy,clearxml=yes") # clearxml isn't supported for devices
c.add_compare("--edit --cpu host-passthrough,clearxml=yes", "edit-clear-cpu")
c.add_compare("--edit --clock offset=utc,clearxml=yes", "edit-clear-clock")
c.add_compare("--edit --disk /foo/bar,target=fda,bus=fdc,device=floppy,clearxml=yes", "edit-clear-disk")
c = vixml.add_category("add/rm devices", "test-many-devices --print-diff --define", compare_check=support.SUPPORT_CONN_INPUT_KEYBOARD)
c.add_invalid("--add-device --security foo") # --add-device without a device

View File

@ -948,16 +948,12 @@ class VirtCLIParser(object):
def __init_global_params(self):
def set_clearxml_cb(opts, inst, cliname, val):
ignore = opts = cliname
if not self.clear_attr and not self.devclass:
if not self.clear_attr:
raise RuntimeError("Don't know how to clearxml --%s" %
self.cli_arg_name)
clearobj = inst
if self.clear_attr:
clearobj = getattr(inst, self.clear_attr)
if val is not True:
return
clearobj.clear()
getattr(inst, self.clear_attr).clear()
self.set_param(None, "clearxml",
setter_cb=set_clearxml_cb, is_onoff=True)