mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-20 11:48:28 -06:00
virsh: Add --print-xml flag for attach-disk command
The flag causes the XML of the disk that would be attached to be printed instead.
This commit is contained in:
parent
702911496f
commit
f8d5119e4f
@ -317,6 +317,12 @@ static const vshCmdOptDef opts_attach_disk[] = {
|
||||
.flags = 0,
|
||||
.help = N_("use multifunction pci under specified address")
|
||||
},
|
||||
{.name = "print-xml",
|
||||
.type = VSH_OT_BOOL,
|
||||
.flags = 0,
|
||||
.help = N_("print XML document rather than attach the disk")
|
||||
},
|
||||
|
||||
{.name = NULL}
|
||||
};
|
||||
|
||||
@ -480,11 +486,11 @@ cmdAttachDisk(vshControl *ctl, const vshCmd *cmd)
|
||||
unsigned int flags;
|
||||
const char *stype = NULL;
|
||||
virBuffer buf = VIR_BUFFER_INITIALIZER;
|
||||
char *xml;
|
||||
char *xml = NULL;
|
||||
struct stat st;
|
||||
|
||||
if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
|
||||
goto cleanup;
|
||||
return false;
|
||||
|
||||
if (vshCommandOptString(cmd, "source", &source) <= 0)
|
||||
goto cleanup;
|
||||
@ -620,6 +626,12 @@ cmdAttachDisk(vshControl *ctl, const vshCmd *cmd)
|
||||
|
||||
xml = virBufferContentAndReset(&buf);
|
||||
|
||||
if (vshCommandOptBool(cmd, "print-xml")) {
|
||||
vshPrint(ctl, "%s", xml);
|
||||
functionReturn = true;
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
if (vshCommandOptBool(cmd, "config")) {
|
||||
flags = VIR_DOMAIN_AFFECT_CONFIG;
|
||||
if (virDomainIsActive(dom) == 1)
|
||||
@ -629,8 +641,6 @@ cmdAttachDisk(vshControl *ctl, const vshCmd *cmd)
|
||||
ret = virDomainAttachDevice(dom, xml);
|
||||
}
|
||||
|
||||
VIR_FREE(xml);
|
||||
|
||||
if (ret != 0) {
|
||||
vshError(ctl, "%s", _("Failed to attach disk"));
|
||||
} else {
|
||||
@ -639,8 +649,8 @@ cmdAttachDisk(vshControl *ctl, const vshCmd *cmd)
|
||||
}
|
||||
|
||||
cleanup:
|
||||
if (dom)
|
||||
virDomainFree(dom);
|
||||
VIR_FREE(xml);
|
||||
virDomainFree(dom);
|
||||
virBufferFreeAndReset(&buf);
|
||||
return functionReturn;
|
||||
}
|
||||
|
@ -1787,7 +1787,7 @@ needed if the device does not use managed mode.
|
||||
[I<--driver driver>] [I<--subdriver subdriver>] [I<--cache cache>]
|
||||
[I<--type type>] [I<--mode mode>] [I<--config>] [I<--sourcetype soucetype>]
|
||||
[I<--serial serial>] [I<--shareable>] [I<--rawio>] [I<--address address>]
|
||||
[I<--multifunction>]
|
||||
[I<--multifunction>] [I<--print-xml>]
|
||||
|
||||
Attach a new disk device to the domain.
|
||||
I<source> is path for the files and devices. I<target> controls the bus or
|
||||
@ -1817,6 +1817,9 @@ scsi:controller.bus.unit or ide:controller.bus.unit.
|
||||
I<multifunction> indicates specified pci address is a multifunction pci device
|
||||
address.
|
||||
|
||||
If I<--print-xml> is specified, then the XML of the disk that would be attached
|
||||
is printed instead.
|
||||
|
||||
=item B<attach-interface> I<domain> I<type> I<source>
|
||||
[I<--target target>] [I<--mac mac>] [I<--script script>] [I<--model model>]
|
||||
[I<--config>] [I<--inbound average,peak,burst>] [I<--outbound average,peak,burst>]
|
||||
|
Loading…
Reference in New Issue
Block a user