[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [libvirt] [PATCH libvirt 2/2] storage: learn to create qcow2 with preallocation



On Sat, May 05, 2012 at 02:46:32AM +0200, Marc-André Lureau wrote:
>  
> +    if (vol->target.format != VIR_STORAGE_FILE_QCOW2 && with_preallocation) {
> +        virStorageReportError(VIR_ERR_INTERNAL_ERROR,
> +                              _("Preallocation is only available with qcow2"));
> +        return -1;
> +    }

/volume/allocation says in its documentation "If set to a value smaller
than the capacity, the pool has the option of deciding to sparsely allocate
a volume. It does not have to honour requests for sparse allocation
though.", ie when trying to use "allocation" to get a sparsely allocated
volume, failures to do the sparse allocation are not fatal (if the
documentation is to be trusted). I think it would be nicer to be consistent
with that for preallocation and not return an error either in this case.

Christophe

> +
>      if (vol->backingStore.path) {
>          int accessRetCode = -1;
>          char *absolutePath = NULL;
> @@ -781,16 +820,20 @@ virStorageBackendCreateQemuImg(virConnectPtr conn,
>      if (imgformat < 0)
>          goto cleanup;
>  
> +    if (imgformat != QEMU_IMG_BACKING_FORMAT_OPTIONS && with_preallocation)
> +        VIR_INFO("Preallocation not supported with this version of qemu-img");
> +
>      cmd = virCommandNew(create_tool);
>  
>      if (inputvol) {
>          virCommandAddArgList(cmd, "convert", "-f", inputType, "-O", type,
>                               inputPath, vol->target.path, NULL);
>  
> -        if (do_encryption) {
> -            if (imgformat == QEMU_IMG_BACKING_FORMAT_OPTIONS) {
> -                virCommandAddArgList(cmd, "-o", "encryption=on", NULL);
> -            } else {
> +        if (imgformat == QEMU_IMG_BACKING_FORMAT_OPTIONS) {
> +            virCommandAddArg(cmd, "-o");
> +            virCommandAddArg(cmd, virStorageQemuImgOptionsStr(vol));
> +        } else {
> +            if (do_encryption) {
>                  virCommandAddArg(cmd, "-e");
>              }
>          }
> @@ -811,8 +854,7 @@ virStorageBackendCreateQemuImg(virConnectPtr conn,
>  
>          case QEMU_IMG_BACKING_FORMAT_OPTIONS:
>              virCommandAddArg(cmd, "-o");
> -            virCommandAddArgFormat(cmd, "backing_fmt=%s%s", backingType,
> -                                   do_encryption ? ",encryption=on" : "");
> +            virCommandAddArg(cmd, virStorageQemuImgOptionsStr(vol));
>              virCommandAddArg(cmd, vol->target.path);
>              virCommandAddArgFormat(cmd, "%lluK", size_arg);
>              break;
> @@ -831,10 +873,11 @@ virStorageBackendCreateQemuImg(virConnectPtr conn,
>                               vol->target.path, NULL);
>          virCommandAddArgFormat(cmd, "%lluK", size_arg);
>  
> -        if (do_encryption) {
> -            if (imgformat == QEMU_IMG_BACKING_FORMAT_OPTIONS) {
> -                virCommandAddArgList(cmd, "-o", "encryption=on", NULL);
> -            } else {
> +        if (imgformat == QEMU_IMG_BACKING_FORMAT_OPTIONS) {
> +            virCommandAddArg(cmd, "-o");
> +            virCommandAddArg(cmd, virStorageQemuImgOptionsStr(vol));
> +        } else {
> +            if (do_encryption) {
>                  virCommandAddArg(cmd, "-e");
>              }
>          }
> -- 
> 1.7.10
> 
> --
> libvir-list mailing list
> libvir-list redhat com
> https://www.redhat.com/mailman/listinfo/libvir-list

Attachment: pgpgIC4JYHcyj.pgp
Description: PGP signature


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]