]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
Add virDomainGetBlockInfo API to query disk sizing
authorDaniel P. Berrange <berrange@redhat.com>
Tue, 27 Apr 2010 19:24:30 +0000 (20:24 +0100)
committerDaniel P. Berrange <berrange@redhat.com>
Thu, 29 Apr 2010 16:20:24 +0000 (17:20 +0100)
Some applications need to be able to query a guest's disk info,
even for paths not managed by the storage pool APIs. This adds
a very simple API to get this information, modelled on the
virStorageVolGetInfo API, but with an extra field 'physical'.
Normally 'physical' and 'allocation' will be identical, but
in the case of a qcow2-like file stored inside a block device
'physical' will give the block device size, while 'allocation'
will give the qcow2 image size

* include/libvirt/libvirt.h.in: Define virDomainGetBlockInfo

include/libvirt/libvirt.h.in

index 4addc62b6f2b8053c68e6e26ff2be522a40ac6b8..4237b7b2ce6e392a74e0fd12d5e99e2361a79dd7 100644 (file)
@@ -733,6 +733,42 @@ int                     virDomainBlockPeek (virDomainPtr dom,
                                             void *buffer,
                                             unsigned int flags);
 
+
+/** virDomainBlockInfo:
+ *
+ * This struct provides information about the size of a block device backing store
+ *
+ * Examples:
+ *
+ *  - Fully allocated raw file in filesystem:
+ *       * capacity, allocation, physical: All the same
+ *
+ *  - Sparse raw file in filesystem:
+ *       * capacity: logical size of the file
+ *       * allocation, physical: number of blocks allocated to file
+ *
+ *  - qcow2 file in filesystem
+ *       * capacity: logical size from qcow2 header
+ *       * allocation, physical: logical size of the file / highest qcow extent (identical)
+ *
+ *  - qcow2 file in a block device
+ *       * capacity: logical size from qcow2 header
+ *       * allocation: highest qcow extent written
+ *       * physical: size of the block device container
+ */
+typedef struct _virDomainBlockInfo virDomainBlockInfo;
+typedef virDomainBlockInfo *virDomainBlockInfoPtr;
+struct _virDomainBlockInfo {
+    unsigned long long capacity;   /* logical size in bytes of the block device backing image */
+    unsigned long long allocation; /* highest allocated extent in bytes of the block device backing image */
+    unsigned long long physical;   /* physical size in bytes of the container of the backing image */
+};
+
+int                     virDomainGetBlockInfo(virDomainPtr dom,
+                                              const char *path,
+                                              virDomainBlockInfoPtr info,
+                                              unsigned int flags);
+
 /* Memory peeking flags. */
 typedef enum {
   VIR_MEMORY_VIRTUAL              = 1, /* addresses are virtual addresses */