]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
resize: slightly alter signature
authorEric Blake <eblake@redhat.com>
Mon, 30 Jan 2012 19:04:20 +0000 (12:04 -0700)
committerLaine Stump <laine@laine.org>
Tue, 31 Jan 2012 16:58:06 +0000 (11:58 -0500)
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.

include/libvirt/libvirt.h.in
src/driver.h
src/libvirt.c
src/remote/remote_protocol.x
src/remote_protocol-structs

index 0a7b324a8fc64d03677b0060280af3bdc235715e..d9b9b95f161f4c193f939c4c6daece11f01fb41e 100644 (file)
@@ -2415,7 +2415,7 @@ typedef enum {
 } virStorageVolResizeFlags;
 
 int                     virStorageVolResize             (virStorageVolPtr vol,
-                                                         long long capacity,
+                                                         unsigned long long capacity,
                                                          unsigned int flags);
 
 
index ba7dbc49b3cc61ec9d9c58217d3967565a376431..2e2042e3b7218f3509eebeeb14fa1571c11f1ea1 100644 (file)
@@ -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
index e702a3421b25418d1a61c53905e6db159384a413..c609202e4efa3377ab2bde9bc888903c2d458ce4 100644 (file)
@@ -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;
     }
index b58925a235ada7969713c78c96674f8866c39587..b2c84261af4c699a00efb61ea99275128eeb9fd7 100644 (file)
@@ -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;
 };
 
index 5eac9bf9f0e950cd62bae9185d6fdeabf4889e0b..e9137a90b9a0ec6592a30e81b7304c5d9dabd824 100644 (file)
@@ -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 {