mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 21:55:25 +00:00
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.
This commit is contained in:
parent
098a987b98
commit
055bbf45e4
@ -2415,7 +2415,7 @@ typedef enum {
|
|||||||
} virStorageVolResizeFlags;
|
} virStorageVolResizeFlags;
|
||||||
|
|
||||||
int virStorageVolResize (virStorageVolPtr vol,
|
int virStorageVolResize (virStorageVolPtr vol,
|
||||||
long long capacity,
|
unsigned long long capacity,
|
||||||
unsigned int flags);
|
unsigned int flags);
|
||||||
|
|
||||||
|
|
||||||
|
@ -1277,7 +1277,7 @@ typedef int
|
|||||||
unsigned int flags);
|
unsigned int flags);
|
||||||
typedef int
|
typedef int
|
||||||
(*virDrvStorageVolResize) (virStorageVolPtr vol,
|
(*virDrvStorageVolResize) (virStorageVolPtr vol,
|
||||||
long long capacity,
|
unsigned long long capacity,
|
||||||
unsigned int flags);
|
unsigned int flags);
|
||||||
|
|
||||||
typedef int
|
typedef int
|
||||||
|
@ -13014,16 +13014,20 @@ error:
|
|||||||
* Normally, this operation should only be used to enlarge capacity;
|
* Normally, this operation should only be used to enlarge capacity;
|
||||||
* but if @flags contains VIR_STORAGE_RESIZE_SHRINK, it is possible to
|
* but if @flags contains VIR_STORAGE_RESIZE_SHRINK, it is possible to
|
||||||
* attempt a reduction in capacity even though it might cause data loss.
|
* 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.
|
* Returns 0 on success, or -1 on error.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
virStorageVolResize(virStorageVolPtr vol,
|
virStorageVolResize(virStorageVolPtr vol,
|
||||||
long long capacity,
|
unsigned long long capacity,
|
||||||
unsigned int flags)
|
unsigned int flags)
|
||||||
{
|
{
|
||||||
virConnectPtr conn;
|
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();
|
virResetLastError();
|
||||||
|
|
||||||
@ -13040,12 +13044,9 @@ virStorageVolResize(virStorageVolPtr vol,
|
|||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Negative capacity is valid only with both delta and shrink;
|
/* Zero capacity is only valid with either delta or shrink. */
|
||||||
* zero capacity is valid with either delta or shrink. */
|
if (capacity == 0 && !((flags & VIR_STORAGE_VOL_RESIZE_DELTA) ||
|
||||||
if ((capacity < 0 && !(flags & VIR_STORAGE_VOL_RESIZE_DELTA) &&
|
(flags & VIR_STORAGE_VOL_RESIZE_SHRINK))) {
|
||||||
!(flags & VIR_STORAGE_VOL_RESIZE_SHRINK)) ||
|
|
||||||
(capacity == 0 && !((flags & VIR_STORAGE_VOL_RESIZE_DELTA) ||
|
|
||||||
(flags & VIR_STORAGE_VOL_RESIZE_SHRINK)))) {
|
|
||||||
virLibStorageVolError(VIR_ERR_INVALID_ARG, __FUNCTION__);
|
virLibStorageVolError(VIR_ERR_INVALID_ARG, __FUNCTION__);
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
@ -1709,7 +1709,7 @@ struct remote_storage_vol_get_path_ret {
|
|||||||
|
|
||||||
struct remote_storage_vol_resize_args {
|
struct remote_storage_vol_resize_args {
|
||||||
remote_nonnull_storage_vol vol;
|
remote_nonnull_storage_vol vol;
|
||||||
hyper capacity;
|
unsigned hyper capacity;
|
||||||
unsigned int flags;
|
unsigned int flags;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1282,7 +1282,7 @@ struct remote_storage_vol_get_path_ret {
|
|||||||
};
|
};
|
||||||
struct remote_storage_vol_resize_args {
|
struct remote_storage_vol_resize_args {
|
||||||
remote_nonnull_storage_vol vol;
|
remote_nonnull_storage_vol vol;
|
||||||
int64_t capacity;
|
uint64_t capacity;
|
||||||
u_int flags;
|
u_int flags;
|
||||||
};
|
};
|
||||||
struct remote_node_num_of_devices_args {
|
struct remote_node_num_of_devices_args {
|
||||||
|
Loading…
Reference in New Issue
Block a user