diff --git a/include/libvirt/libvirt.h.in b/include/libvirt/libvirt.h.in index 0a7b324a8f..d9b9b95f16 100644 --- a/include/libvirt/libvirt.h.in +++ b/include/libvirt/libvirt.h.in @@ -2415,7 +2415,7 @@ typedef enum { } virStorageVolResizeFlags; int virStorageVolResize (virStorageVolPtr vol, - long long capacity, + unsigned long long capacity, unsigned int flags); diff --git a/src/driver.h b/src/driver.h index ba7dbc49b3..2e2042e3b7 100644 --- a/src/driver.h +++ b/src/driver.h @@ -1277,7 +1277,7 @@ typedef int unsigned int flags); typedef int (*virDrvStorageVolResize) (virStorageVolPtr vol, - long long capacity, + unsigned long long capacity, unsigned int flags); typedef int diff --git a/src/libvirt.c b/src/libvirt.c index e702a3421b..c609202e4e 100644 --- a/src/libvirt.c +++ b/src/libvirt.c @@ -13014,16 +13014,20 @@ error: * Normally, this operation should only be used to enlarge capacity; * but if @flags contains VIR_STORAGE_RESIZE_SHRINK, it is possible to * attempt a reduction in capacity even though it might cause data loss. + * If VIR_STORAGE_RESIZE_DELTA is also present, then @capacity is + * subtracted from the current size; without it, @capacity represents + * the absolute new size regardless of whether it is larger or smaller + * than the current size. * * Returns 0 on success, or -1 on error. */ int virStorageVolResize(virStorageVolPtr vol, - long long capacity, + unsigned long long capacity, unsigned int flags) { virConnectPtr conn; - VIR_DEBUG("vol=%p capacity=%lld flags=%x", vol, capacity, flags); + VIR_DEBUG("vol=%p capacity=%llu flags=%x", vol, capacity, flags); virResetLastError(); @@ -13040,12 +13044,9 @@ virStorageVolResize(virStorageVolPtr vol, goto error; } - /* Negative capacity is valid only with both delta and shrink; - * zero capacity is valid with either delta or shrink. */ - if ((capacity < 0 && !(flags & VIR_STORAGE_VOL_RESIZE_DELTA) && - !(flags & VIR_STORAGE_VOL_RESIZE_SHRINK)) || - (capacity == 0 && !((flags & VIR_STORAGE_VOL_RESIZE_DELTA) || - (flags & VIR_STORAGE_VOL_RESIZE_SHRINK)))) { + /* Zero capacity is only valid with either delta or shrink. */ + if (capacity == 0 && !((flags & VIR_STORAGE_VOL_RESIZE_DELTA) || + (flags & VIR_STORAGE_VOL_RESIZE_SHRINK))) { virLibStorageVolError(VIR_ERR_INVALID_ARG, __FUNCTION__); goto error; } diff --git a/src/remote/remote_protocol.x b/src/remote/remote_protocol.x index b58925a235..b2c84261af 100644 --- a/src/remote/remote_protocol.x +++ b/src/remote/remote_protocol.x @@ -1709,7 +1709,7 @@ struct remote_storage_vol_get_path_ret { struct remote_storage_vol_resize_args { remote_nonnull_storage_vol vol; - hyper capacity; + unsigned hyper capacity; unsigned int flags; }; diff --git a/src/remote_protocol-structs b/src/remote_protocol-structs index 5eac9bf9f0..e9137a90b9 100644 --- a/src/remote_protocol-structs +++ b/src/remote_protocol-structs @@ -1282,7 +1282,7 @@ struct remote_storage_vol_get_path_ret { }; struct remote_storage_vol_resize_args { remote_nonnull_storage_vol vol; - int64_t capacity; + uint64_t capacity; u_int flags; }; struct remote_node_num_of_devices_args {