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

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

 



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@xxxxxxxxxx
> https://www.redhat.com/mailman/listinfo/libvir-list

Attachment: pgpBe5UiDY9Dw.pgp
Description: PGP signature

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]