This allows us to resize storage pool volumes.
Signed-off-by: Wido den Hollander <wido(a)widodh.nl>
---
src/main/java/org/libvirt/StorageVol.java | 36 ++++++++++++++++++++++++++++
src/main/java/org/libvirt/jna/Libvirt.java | 1 +
2 files changed, 37 insertions(+)
diff --git a/src/main/java/org/libvirt/StorageVol.java
b/src/main/java/org/libvirt/StorageVol.java
index 4b9db80..bc0c01f 100644
--- a/src/main/java/org/libvirt/StorageVol.java
+++ b/src/main/java/org/libvirt/StorageVol.java
@@ -22,6 +22,23 @@ public class StorageVol {
static final int VIR_STORAGE_POOL_DELETE_ZEROED = 1;
}
+ static final class ResizeFlags {
+ /**
+ * force allocation of new size
+ */
+ static final int ALLOCATE = 1;
+
+ /**
+ * size is relative to current
+ */
+ static final int DELTA = 2;
+
+ /**
+ * allow decrease in capacity
+ */
+ static final int SHRINK = 4;
+ }
+
public static enum Type {
/**
* Regular file based volumes
@@ -33,6 +50,8 @@ public class StorageVol {
VIR_STORAGE_VOL_BLOCK
}
+
+
/**
* the native virStorageVolPtr.
*/
@@ -203,4 +222,21 @@ public class StorageVol {
processError();
return returnValue;
}
+
+ /**
+ * Resize a volume
+ *
+ * @see <a
href="http://www.libvirt.org/html/libvirt-libvirt.html#virStorageVol...
Documentation</a>
+ * @param capacity
+ * new capacity for volume
+ * @param flags
+ * flags for resizing, see libvirt API for exact flags
+ * @return 0 on success, or -1 on error
+ * @throws LibvirtException
+ */
+ public int resize(long capacity, int flags) throws LibvirtException {
+ int returnValue = libvirt.virStorageVolResize(VSVP, capacity, flags);
+ processError();
+ return returnValue;
+ }
}
diff --git a/src/main/java/org/libvirt/jna/Libvirt.java
b/src/main/java/org/libvirt/jna/Libvirt.java
index e64cb9d..8262cb9 100644
--- a/src/main/java/org/libvirt/jna/Libvirt.java
+++ b/src/main/java/org/libvirt/jna/Libvirt.java
@@ -325,6 +325,7 @@ public interface Libvirt extends Library {
StorageVolPointer virStorageVolLookupByName(StoragePoolPointer storagePoolPtr, String
name);
StorageVolPointer virStorageVolLookupByPath(ConnectionPointer virConnectPtr, String
path);
int virStorageVolWipe(StorageVolPointer storageVolPtr, int flags);
+ int virStorageVolResize(StorageVolPointer storageVolPtr, long capacity, int flags);
// Interface Methods
int virInterfaceCreate(InterfacePointer virDevicePointer);
--
1.7.9.5