On Wed, May 16, 2012 at 12:55:13AM +0200, Marc-André Lureau wrote: > Use preallocation mode specified in volume XML format when running > qemu-img. > --- > src/storage/storage_backend.c | 70 +++++++++++++++++++++++++++++++++++------ > 1 file changed, 60 insertions(+), 10 deletions(-) > > diff --git a/src/storage/storage_backend.c b/src/storage/storage_backend.c > index caac2f8..8b31823 100644 > --- a/src/storage/storage_backend.c > +++ b/src/storage/storage_backend.c > @@ -645,6 +645,38 @@ cleanup: > return ret; > } > > +static char * > +virStorageQemuImgOptionsStr(virStorageVolDefPtr vol) > +{ > + virBuffer buf = VIR_BUFFER_INITIALIZER; > + bool do_encryption = (vol->target.encryption != NULL); > + const char *backingType = vol->backingStore.path ? > + virStorageFileFormatTypeToString(vol->backingStore.format) : NULL; > + bool comma = false; > + const char *preallocation = vol->preallocation != VIR_STORAGE_PREALLOCATION_NONE ? > + virStoragePreallocationModeTypeToString(vol->preallocation) : NULL; > + > + if (backingType) { > + virBufferAddLit(&buf, "backing_fmt="); > + virBufferAdd(&buf, backingType, -1); > + comma = true; > + } > + > + if (do_encryption) { > + virBufferAdd(&buf, comma ? "," : "", -1); > + virBufferAddLit(&buf, "encryption=on"); > + comma = true; > + } > + > + if (preallocation) { > + virBufferAdd(&buf, comma ? "," : "", -1); > + virBufferAddLit(&buf, "preallocation="); > + virBufferAdd(&buf, preallocation, -1); > + comma = true; > + } > + > + return virBufferContentAndReset(&buf); > +} > > static int > virStorageBackendCreateQemuImg(virConnectPtr conn, > @@ -658,7 +690,9 @@ virStorageBackendCreateQemuImg(virConnectPtr conn, > int imgformat = -1; > virCommandPtr cmd = NULL; > bool do_encryption = (vol->target.encryption != NULL); > + bool with_preallocation = (vol->preallocation != VIR_STORAGE_PREALLOCATION_NONE); > unsigned long long int size_arg; > + char *options; > > virCheckFlags(0, -1); > > @@ -689,6 +723,12 @@ virStorageBackendCreateQemuImg(virConnectPtr conn, > return -1; > } > > + if (vol->target.format != VIR_STORAGE_FILE_QCOW2 && with_preallocation) { > + virStorageReportError(VIR_ERR_INTERNAL_ERROR, > + _("Preallocation is only available with qcow2")); This is not an internal error since it's caused by user xml input. The rest of the code seems to be using VIR_ERR_CONFIG_UNSUPPORTED in similar cases. ACK with that fixed. Christophe
Attachment:
pgpBPt6OMmDxP.pgp
Description: PGP signature
-- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list