.type = VSH_OT_BOOL,
.help = N_("preallocate metadata (for qcow2 instead of full allocation)")
},
+ {.name = "print-xml",
+ .type = VSH_OT_BOOL,
+ .help = N_("print XML document, but don't define/create")
+ },
{.name = NULL}
};
virStoragePoolPtr pool;
virStorageVolPtr vol = NULL;
char *xml = NULL;
+ bool printXML = vshCommandOptBool(cmd, "print-xml");
const char *name, *capacityStr = NULL, *allocationStr = NULL, *format = NULL;
const char *snapshotStrVol = NULL, *snapshotStrFormat = NULL;
unsigned long long capacity, allocation = 0;
}
xml = virBufferContentAndReset(&buf);
- if (!(vol = virStorageVolCreateXML(pool, xml, flags))) {
- vshError(ctl, _("Failed to create vol %s"), name);
- goto cleanup;
+ if (printXML) {
+ vshPrint(ctl, "%s", xml);
+ } else {
+ if (!(vol = virStorageVolCreateXML(pool, xml, flags))) {
+ vshError(ctl, _("Failed to create vol %s"), name);
+ goto cleanup;
+ }
+ vshPrint(ctl, _("Vol %s created\n"), name);
}
- vshPrint(ctl, _("Vol %s created\n"), name);
ret = true;
cleanup:
=item B<vol-create-as> I<pool-or-uuid> I<name> I<capacity>
[I<--allocation> I<size>] [I<--format> I<string>] [I<--backing-vol>
I<vol-name-or-key-or-path>] [I<--backing-vol-format> I<string>]
-[I<--prealloc-metadata>]
+[I<--prealloc-metadata>] [I<--print-xml>]
-Create a volume from a set of arguments.
+Create a volume from a set of arguments unless I<--print-xml> is specified, in
+which case just the XML of the volume object is printed out without any actual
+object creation.
I<pool-or-uuid> is the name or UUID of the storage pool to create the volume
in.
I<name> is the name of the new volume. For a disk pool, this must match the