N_("the backing volume if taking a snapshot")},
{"backing-vol-format", VSH_OT_STRING, 0,
N_("format of backing volume if taking a snapshot")},
+ {"prealloc-metadata", VSH_OT_BOOL, 0, N_("preallocate metadata (for qcow2 "
+ "instead of full allocation)")},
{NULL, 0, 0, NULL}
};
const char *snapshotStrVol = NULL, *snapshotStrFormat = NULL;
unsigned long long capacity, allocation = 0;
virBuffer buf = VIR_BUFFER_INITIALIZER;
+ unsigned long flags = 0;
+ if (vshCommandOptBool(cmd, "prealloc-metadata"))
+ flags |= VIR_STORAGE_VOL_CREATE_PREALLOC_METADATA;
if (!(pool = vshCommandOptPoolBy(ctl, cmd, "pool", NULL,
VSH_BYNAME)))
return false;
goto cleanup;
}
xml = virBufferContentAndReset(&buf);
- vol = virStorageVolCreateXML(pool, xml, 0);
+ vol = virStorageVolCreateXML(pool, xml, flags);
VIR_FREE(xml);
virStoragePoolFree(pool);
static const vshCmdOptDef opts_vol_create[] = {
{"pool", VSH_OT_DATA, VSH_OFLAG_REQ, N_("pool name")},
{"file", VSH_OT_DATA, VSH_OFLAG_REQ, N_("file containing an XML vol description")},
+ {"prealloc-metadata", VSH_OT_BOOL, 0, N_("preallocate metadata (for qcow2 "
+ "instead of full allocation)")},
{NULL, 0, 0, NULL}
};
virStorageVolPtr vol;
const char *from = NULL;
bool ret = true;
+ unsigned int flags = 0;
char *buffer;
+ if (vshCommandOptBool(cmd, "prealloc-metadata"))
+ flags |= VIR_STORAGE_VOL_CREATE_PREALLOC_METADATA;
if (!(pool = vshCommandOptPoolBy(ctl, cmd, "pool", NULL,
VSH_BYNAME)))
return false;
return false;
}
- vol = virStorageVolCreateXML(pool, buffer, 0);
+ vol = virStorageVolCreateXML(pool, buffer, flags);
VIR_FREE(buffer);
virStoragePoolFree(pool);
{"file", VSH_OT_DATA, VSH_OFLAG_REQ, N_("file containing an XML vol description")},
{"vol", VSH_OT_DATA, VSH_OFLAG_REQ, N_("input vol name or key")},
{"inputpool", VSH_OT_STRING, 0, N_("pool name or uuid of the input volume's pool")},
+ {"prealloc-metadata", VSH_OT_BOOL, 0, N_("preallocate metadata (for qcow2 "
+ "instead of full allocation)")},
{NULL, 0, 0, NULL}
};
const char *from = NULL;
bool ret = false;
char *buffer = NULL;
+ unsigned int flags = 0;
if (!(pool = vshCommandOptPool(ctl, cmd, "pool", NULL)))
goto cleanup;
+ if (vshCommandOptBool(cmd, "prealloc-metadata"))
+ flags |= VIR_STORAGE_VOL_CREATE_PREALLOC_METADATA;
if (vshCommandOptString(cmd, "file", &from) <= 0) {
goto cleanup;
}
goto cleanup;
}
- newvol = virStorageVolCreateXMLFrom(pool, buffer, inputvol, 0);
+ newvol = virStorageVolCreateXMLFrom(pool, buffer, inputvol, flags);
if (newvol != NULL) {
vshPrint(ctl, _("Vol %s created from input vol %s\n"),
{"vol", VSH_OT_DATA, VSH_OFLAG_REQ, N_("orig vol name or key")},
{"newname", VSH_OT_DATA, VSH_OFLAG_REQ, N_("clone name")},
{"pool", VSH_OT_STRING, 0, N_("pool name or uuid")},
+ {"prealloc-metadata", VSH_OT_BOOL, 0, N_("preallocate metadata (for qcow2 "
+ "instead of full allocation)")},
{NULL, 0, 0, NULL}
};
char *origxml = NULL;
xmlChar *newxml = NULL;
bool ret = false;
+ unsigned int flags = 0;
if (!(origvol = vshCommandOptVol(ctl, cmd, "vol", "pool", NULL)))
goto cleanup;
+ if (vshCommandOptBool(cmd, "prealloc-metadata"))
+ flags |= VIR_STORAGE_VOL_CREATE_PREALLOC_METADATA;
+
origpool = virStoragePoolLookupByVolume(origvol);
if (!origpool) {
vshError(ctl, "%s", _("failed to get parent pool"));
goto cleanup;
}
- newvol = virStorageVolCreateXMLFrom(origpool, (char *) newxml, origvol, 0);
+ newvol = virStorageVolCreateXMLFrom(origpool, (char *) newxml, origvol, flags);
if (newvol != NULL) {
vshPrint(ctl, _("Vol %s cloned from %s\n"),
=over 4
-=item B<vol-create> I<pool-or-uuid> I<FILE>
+=item B<vol-create> I<pool-or-uuid> I<FILE> [I<--prealloc-metadata>]
Create a volume from an XML <file>.
I<pool-or-uuid> is the name or UUID of the storage pool to create the volume in.
I<FILE> is the XML <file> with the volume definition. An easy way to create the
XML <file> is to use the B<vol-dumpxml> command to obtain the definition of a
pre-existing volume.
+[I<--prealloc-metadata>] preallocate metadata (for qcow2 images which don't
+support full allocation). This option creates a sparse image file with metadata,
+resulting in higher performance compared to images with no preallocation and
+only slightly higher initial disk space usage.
B<Example>
virsh vol-create differentstoragepool newvolume.xml
=item B<vol-create-from> I<pool-or-uuid> I<FILE> [I<--inputpool>
-I<pool-or-uuid>] I<vol-name-or-key-or-path>
+I<pool-or-uuid>] I<vol-name-or-key-or-path> [I<--prealloc-metadata>]
Create a volume, using another volume as input.
I<pool-or-uuid> is the name or UUID of the storage pool to create the volume in.
I<--inputpool> I<pool-or-uuid> is the name or uuid of the storage pool the
source volume is in.
I<vol-name-or-key-or-path> is the name or key or path of the source volume.
+[I<--prealloc-metadata>] preallocate metadata (for qcow2 images which don't
+support full allocation). This option creates a sparse image file with metadata,
+resulting in higher performance compared to images with no preallocation and
+only slightly higher initial disk space usage.
=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>]
Create a volume from a set of arguments.
I<pool-or-uuid> is the name or UUID of the storage pool to create the volume
I<--backing-vol-format> I<string> is the format of the snapshot backing volume;
raw, bochs, qcow, qcow2, qed, vmdk, host_device. These are, however, meant for
file based storage pools.
+[I<--prealloc-metadata>] preallocate metadata (for qcow2 images which don't
+support full allocation). This option creates a sparse image file with metadata,
+resulting in higher performance compared to images with no preallocation and
+only slightly higher initial disk space usage.
=item B<vol-clone> [I<--pool> I<pool-or-uuid>] I<vol-name-or-key-or-path>
-I<name>
+I<name> [I<--prealloc-metadata>]
Clone an existing volume. Less powerful, but easier to type, version of
B<vol-create-from>.
the volume in.
I<vol-name-or-key-or-path> is the name or key or path of the source volume.
I<name> is the name of the new volume.
+[I<--prealloc-metadata>] preallocate metadata (for qcow2 images which don't
+support full allocation). This option creates a sparse image file with metadata,
+resulting in higher performance compared to images with no preallocation and
+only slightly higher initial disk space usage.
=item B<vol-delete> [I<--pool> I<pool-or-uuid>] I<vol-name-or-key-or-path>