virt-xml: Abide domain name for --build-xml
https://bugzilla.redhat.com/show_bug.cgi?id=1648939
This commit is contained in:
parent
d61f9d9995
commit
524002da02
|
@ -17,7 +17,7 @@ Each B<virt-xml> invocation requires 3 things: name of an existing domain to alt
|
|||
--add-device: Append a new device definition to the XML
|
||||
--remove-device: Remove an existing device definition
|
||||
--edit: Edit an existing XML block
|
||||
--build-xml: Just build the requested XML block and print it (no domain or input XML are required here).
|
||||
--build-xml: Just build the requested XML block and print it. No domain or input are required here, but it's recommended to provide them, so virt-xml can fill in optimal defaults.
|
||||
|
||||
An XML change is one instance of any of the XML options provided by virt-xml, for example --disk or --boot.
|
||||
|
||||
|
@ -118,6 +118,8 @@ This option will error if specified with a non-device XML option (see --edit sec
|
|||
|
||||
Just build the specified XML, and print it to stdout. No input domain or input XML is required. Example: '--build-xml --disk DISK-OPTIONS' will just print the new <disk> device.
|
||||
|
||||
However if the generated XML is targeted for a specific domain, it's recommended to pass it to virt-xml, so the tool can set optimal defaults.
|
||||
|
||||
This option will error if specified with an XML option that does not map cleanly to a specific XML block, like --vcpus or --memory.
|
||||
|
||||
=back
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
<disk type="file" device="disk">
|
||||
<driver name="qemu" type="qcow2"/>
|
||||
<source file="/dev/default-pool/testvol1.img"/>
|
||||
<target dev="vdaf" bus="virtio"/>
|
||||
</disk>
|
|
@ -0,0 +1,5 @@
|
|||
<disk type="file" device="disk">
|
||||
<driver name="qemu" type="qcow2"/>
|
||||
<source file="/dev/default-pool/testvol1.img"/>
|
||||
<target dev="hda" bus="ide"/>
|
||||
</disk>
|
|
@ -1119,6 +1119,8 @@ c.add_compare("--build-xml --cpu pentium3,+x2apic", "build-cpu")
|
|||
c.add_compare("--build-xml --tpm path=/dev/tpm", "build-tpm")
|
||||
c.add_compare("--build-xml --blkiotune weight=100,device0.path=/dev/sdf,device.weight=200", "build-blkiotune")
|
||||
c.add_compare("--build-xml --idmap uid.start=0,uid.target=1000,uid.count=10,gid.start=0,gid.target=1000,gid.count=10", "build-idmap")
|
||||
c.add_compare("--connect %(URI-KVM)s --build-xml --disk %(EXISTIMG1)s", "build-disk-plain")
|
||||
c.add_compare("--connect %(URI-KVM)s test-many-devices --build-xml --disk %(EXISTIMG1)s", "build-disk-domain")
|
||||
c.add_compare("4a64cc71-19c4-2fd0-2323-3050941ea3c3 --edit --boot network,cdrom", "edit-bootorder") # basic bootorder test, also using UUID lookup
|
||||
c.add_compare("--confirm 1 --edit --cpu host-passthrough", "prompt-response", input_text="yes") # prompt response, also using domid lookup
|
||||
c.add_compare("--edit --print-diff --qemu-commandline clearxml=yes", "edit-clearxml-qemu-commandline", input_file=(XMLDIR + "/virtxml-qemu-commandline-clear.xml"))
|
||||
|
|
13
virt-xml
13
virt-xml
|
@ -217,14 +217,13 @@ def action_remove_device(guest, options, parserclass):
|
|||
return devs
|
||||
|
||||
|
||||
def action_build_xml(conn, options, parserclass):
|
||||
def action_build_xml(conn, options, parserclass, guest):
|
||||
if not parserclass.guest_propname:
|
||||
fail(_("--build-xml not supported for --%s") %
|
||||
parserclass.cli_arg_name)
|
||||
if options.os_variant is not None:
|
||||
fail(_("--os-variant is not supported with --build-xml"))
|
||||
|
||||
guest = virtinst.Guest(conn)
|
||||
inst = parserclass.lookup_prop(guest)
|
||||
if parserclass.prop_is_list(guest):
|
||||
inst = inst.new()
|
||||
|
@ -374,7 +373,8 @@ def parse_args():
|
|||
help=_("Add specified device. Example:\n"
|
||||
"--add-device --disk ..."))
|
||||
actg.add_argument("--build-xml", action="store_true",
|
||||
help=_("Just output the built device XML, no domain required."))
|
||||
help=_("Output built device XML. Domain is optional but "
|
||||
"recommended to ensure optimal defaults."))
|
||||
|
||||
outg = parser.add_argument_group(_("Output options"))
|
||||
outg.add_argument("--update", action="store_true",
|
||||
|
@ -467,8 +467,9 @@ def main(conn=None):
|
|||
if options.domain:
|
||||
domain, inactive_xmlobj, active_xmlobj = get_domain_and_guest(
|
||||
conn, options.domain)
|
||||
elif not options.build_xml:
|
||||
inactive_xmlobj = virtinst.Guest(conn, options.stdinxml)
|
||||
else:
|
||||
inactive_xmlobj = virtinst.Guest(conn,
|
||||
parsexml=options.stdinxml)
|
||||
|
||||
check_action_collision(options)
|
||||
parserclass = check_xmlopt_collision(options)
|
||||
|
@ -478,7 +479,7 @@ def main(conn=None):
|
|||
(parserclass.cli_arg_name))
|
||||
|
||||
if options.build_xml:
|
||||
devs = action_build_xml(conn, options, parserclass)
|
||||
devs = action_build_xml(conn, options, parserclass, inactive_xmlobj)
|
||||
for dev in devs:
|
||||
# pylint: disable=no-member
|
||||
print_stdout(dev.get_xml())
|
||||
|
|
Loading…
Reference in New Issue