[libvirt] [PATCH] ZFS: Add vol-resize support
Сергей Мамонов
mrqwer88 at gmail.com
Wed Dec 14 17:29:55 UTC 2016
Hello!
But shrink without additional checks may be very bad idea.
"zfs set volsize=SIZE " not check used size (on zol now) and it can kill
VM filesystem.
2016-12-14 20:15 GMT+03:00 Sergei A Mamonov <mrqwer88 at gmail.com>:
> Add virStorageBackendZFSResizeVol method for storage_backend_zfs.c
>
> ---
> src/storage/storage_backend_zfs.c | 28 ++++++++++++++++++++++++++++
> 1 file changed, 28 insertions(+)
>
> diff --git a/src/storage/storage_backend_zfs.c
> b/src/storage/storage_backend_zfs.c
> index 3a43be4..8e57d72 100644
> --- a/src/storage/storage_backend_zfs.c
> +++ b/src/storage/storage_backend_zfs.c
> @@ -454,6 +454,33 @@ virStorageBackendZFSDeletePool(virConnectPtr conn
> ATTRIBUTE_UNUSED,
> return ret;
> }
>
> +static int
> +virStorageBackendZFSResizeVol(virConnectPtr conn ATTRIBUTE_UNUSED,
> + virStoragePoolObjPtr pool,
> + virStorageVolDefPtr vol,
> + unsigned long long capacity,
> + unsigned int flags)
> +{
> + int ret = -1;
> + virCommandPtr resize_cmd = NULL;
> +
> + virCheckFlags(VIR_STORAGE_VOL_RESIZE_SHRINK, -1);
> +
> + resize_cmd = virCommandNewArgList(ZFS, "set", NULL);
> +
> + virCommandAddArgFormat(resize_cmd, "volsize=%llu", capacity);
> + virCommandAddArgFormat(resize_cmd, "%s/%s",
> + pool->def->source.name, vol->name);
> +
> + if (virCommandRun(resize_cmd, NULL) < 0)
> + goto cleanup;
> +
> + ret = 0;
> + cleanup:
> + virCommandFree(resize_cmd);
> + return ret;
> +}
> +
> virStorageBackend virStorageBackendZFS = {
> .type = VIR_STORAGE_POOL_ZFS,
>
> @@ -465,4 +492,5 @@ virStorageBackend virStorageBackendZFS = {
> .deletePool = virStorageBackendZFSDeletePool,
> .uploadVol = virStorageBackendVolUploadLocal,
> .downloadVol = virStorageBackendVolDownloadLocal,
> + .resizeVol = virStorageBackendZFSResizeVol,
> };
> --
> 1.8.3.1
>
>
--
Best Regards,
Sergey Mamonov
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20161214/07b1558c/attachment-0001.htm>
More information about the libvir-list
mailing list