From: Eric Blake Date: Mon, 30 Jan 2012 19:04:20 +0000 (-0700) Subject: resize: slightly alter signature X-Git-Tag: v0.9.10-rc1~65 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=055bbf4;p=thirdparty%2Flibvirt.git resize: slightly alter signature Our existing virDomainBlockResize takes an unsigned long long argument; if that command is later taught a DELTA and SHRINK flag, we cannot change its type without breaking API (but at least such a change would be ABI compatible). Meanwhile, the only time a negative size makes sense is if both DELTA and SHRINK are used together, but if we keep the argument unsigned, applications can pass the positive delta amount by which they would like to shrink the system, and have the flags imply the negative value. So, since this API has not yet been released, and in the interest of consistency with existing API, we swap virStorageVolResize to always pass an unsigned value. * include/libvirt/libvirt.h.in (virStorageVolResize): Use unsigned argument. * src/libvirt.c (virStorageVolResize): Likewise. * src/driver.h (virDrvStorageVolUpload): Adjust clients. * src/remote/remote_protocol.x (remote_storage_vol_resize_args): Likewise. * src/remote_protocol-structs: Regenerate. Suggested by Daniel P. Berrange. --- 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 {