aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel P. Berrange <berrange@redhat.com>2010-04-27 20:27:34 +0100
committerDaniel P. Berrange <berrange@redhat.com>2010-04-29 17:20:24 +0100
commit46bad5121f1a5adf5f30f835d150b3710f964319 (patch)
treec44c9c5e827298a1ee492f9d3dd7104407eb7e0e
parentAdd virDomainGetBlockInfo API to query disk sizing (diff)
downloadlibvirt-46bad5121f1a5adf5f30f835d150b3710f964319.tar.gz
libvirt-46bad5121f1a5adf5f30f835d150b3710f964319.tar.bz2
libvirt-46bad5121f1a5adf5f30f835d150b3710f964319.zip
Internal driver API infrastructure for virDomainGetBlockInfo
This defines the internal driver API and stubs out each driver * src/driver.h: Define virDrvDomainGetBlockInfo signature * src/libvirt.c, src/libvirt_public.syms: Glue public API to drivers * src/esx/esx_driver.c, src/lxc/lxc_driver.c, src/opennebula/one_driver.c, src/openvz/openvz_driver.c, src/phyp/phyp_driver.c, src/test/test_driver.c, src/uml/uml_driver.c, src/vbox/vbox_tmpl.c, src/xen/xen_driver.c, src/xenapi/xenapi_driver.c: Stub out driver
-rw-r--r--src/driver.h7
-rw-r--r--src/esx/esx_driver.c1
-rw-r--r--src/libvirt.c49
-rw-r--r--src/libvirt_public.syms5
-rw-r--r--src/lxc/lxc_driver.c1
-rw-r--r--src/opennebula/one_driver.c1
-rw-r--r--src/openvz/openvz_driver.c1
-rw-r--r--src/phyp/phyp_driver.c1
-rw-r--r--src/qemu/qemu_driver.c1
-rw-r--r--src/remote/remote_driver.c1
-rw-r--r--src/test/test_driver.c1
-rw-r--r--src/uml/uml_driver.c1
-rw-r--r--src/vbox/vbox_tmpl.c1
-rw-r--r--src/xen/xen_driver.c1
-rw-r--r--src/xenapi/xenapi_driver.c1
15 files changed, 73 insertions, 0 deletions
diff --git a/src/driver.h b/src/driver.h
index f8db9c1d3..0975b590d 100644
--- a/src/driver.h
+++ b/src/driver.h
@@ -261,6 +261,12 @@ typedef int
unsigned long long start, size_t size,
void *buffer,
unsigned int flags);
+typedef int
+ (*virDrvDomainGetBlockInfo)
+ (virDomainPtr domain,
+ const char *path,
+ virDomainBlockInfoPtr info,
+ unsigned int flags);
typedef int
(*virDrvDomainMigratePrepare)
@@ -525,6 +531,7 @@ struct _virDriver {
virDrvDomainMemoryStats domainMemoryStats;
virDrvDomainBlockPeek domainBlockPeek;
virDrvDomainMemoryPeek domainMemoryPeek;
+ virDrvDomainGetBlockInfo domainGetBlockInfo;
virDrvNodeGetCellsFreeMemory nodeGetCellsFreeMemory;
virDrvNodeGetFreeMemory getFreeMemory;
virDrvDomainEventRegister domainEventRegister;
diff --git a/src/esx/esx_driver.c b/src/esx/esx_driver.c
index c0c31955a..8e55fc689 100644
--- a/src/esx/esx_driver.c
+++ b/src/esx/esx_driver.c
@@ -3776,6 +3776,7 @@ static virDriver esxDriver = {
NULL, /* domainMemoryStats */
NULL, /* domainBlockPeek */
NULL, /* domainMemoryPeek */
+ NULL, /* domainGetBlockInfo */
NULL, /* nodeGetCellsFreeMemory */
esxNodeGetFreeMemory, /* nodeGetFreeMemory */
NULL, /* domainEventRegister */
diff --git a/src/libvirt.c b/src/libvirt.c
index ff3668132..028115c45 100644
--- a/src/libvirt.c
+++ b/src/libvirt.c
@@ -4625,6 +4625,55 @@ error:
}
+/**
+ * virDomainGetBlockInfo:
+ * @domain: a domain object
+ * @path: path to the block device or file
+ * @info: pointer to a virDomainBlockInfo structure allocated by the user
+ * @flags: currently unused, pass zero
+ *
+ * Extract information about a domain's block device.
+ *
+ * Returns 0 in case of success and -1 in case of failure.
+ */
+int
+virDomainGetBlockInfo(virDomainPtr domain, const char *path, virDomainBlockInfoPtr info, unsigned int flags)
+{
+ virConnectPtr conn;
+ DEBUG("domain=%p, info=%p flags=%u", domain, info, flags);
+
+ virResetLastError();
+
+ if (!VIR_IS_CONNECTED_DOMAIN(domain)) {
+ virLibDomainError(NULL, VIR_ERR_INVALID_DOMAIN, __FUNCTION__);
+ virDispatchError(NULL);
+ return (-1);
+ }
+ if (info == NULL) {
+ virLibDomainError(domain, VIR_ERR_INVALID_ARG, __FUNCTION__);
+ goto error;
+ }
+
+ memset(info, 0, sizeof(virDomainBlockInfo));
+
+ conn = domain->conn;
+
+ if (conn->driver->domainGetBlockInfo) {
+ int ret;
+ ret = conn->driver->domainGetBlockInfo (domain, path, info, flags);
+ if (ret < 0)
+ goto error;
+ return ret;
+ }
+
+ virLibConnError (conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
+
+error:
+ virDispatchError(domain->conn);
+ return -1;
+}
+
+
/************************************************************************
* *
* Handling of defined but not running domains *
diff --git a/src/libvirt_public.syms b/src/libvirt_public.syms
index b4db90464..81465d3e1 100644
--- a/src/libvirt_public.syms
+++ b/src/libvirt_public.syms
@@ -394,4 +394,9 @@ LIBVIRT_0.8.0 {
} LIBVIRT_0.7.7;
+LIBVIRT_0.8.1 {
+ global:
+ virDomainGetBlockInfo;
+} LIBVIRT_0.8.0;
+
# .... define new API here using predicted next version number ....
diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c
index 2851a2a8e..409b1cff4 100644
--- a/src/lxc/lxc_driver.c
+++ b/src/lxc/lxc_driver.c
@@ -2517,6 +2517,7 @@ static virDriver lxcDriver = {
NULL, /* domainMemoryStats */
NULL, /* domainBlockPeek */
NULL, /* domainMemoryPeek */
+ NULL, /* domainGetBlockInfo */
nodeGetCellsFreeMemory, /* nodeGetCellsFreeMemory */
nodeGetFreeMemory, /* getFreeMemory */
lxcDomainEventRegister, /* domainEventRegister */
diff --git a/src/opennebula/one_driver.c b/src/opennebula/one_driver.c
index cdd61eb5a..acd52c2c9 100644
--- a/src/opennebula/one_driver.c
+++ b/src/opennebula/one_driver.c
@@ -771,6 +771,7 @@ static virDriver oneDriver = {
NULL, /* domainMemoryStats */
NULL, /* domainBlockPeek */
NULL, /* domainMemoryPeek */
+ NULL, /* domainGetBlockInfo */
NULL, /* nodeGetCellsFreeMemory */
NULL, /* getFreeMemory */
NULL, /* domainEventRegister */
diff --git a/src/openvz/openvz_driver.c b/src/openvz/openvz_driver.c
index 47004d656..00b8a14bb 100644
--- a/src/openvz/openvz_driver.c
+++ b/src/openvz/openvz_driver.c
@@ -1525,6 +1525,7 @@ static virDriver openvzDriver = {
NULL, /* domainMemoryStats */
NULL, /* domainBlockPeek */
NULL, /* domainMemoryPeek */
+ NULL, /* domainGetBlockInfo */
NULL, /* nodeGetCellsFreeMemory */
NULL, /* getFreeMemory */
NULL, /* domainEventRegister */
diff --git a/src/phyp/phyp_driver.c b/src/phyp/phyp_driver.c
index f4d817e35..467ea1941 100644
--- a/src/phyp/phyp_driver.c
+++ b/src/phyp/phyp_driver.c
@@ -1630,6 +1630,7 @@ virDriver phypDriver = {
NULL, /* domainMemoryStats */
NULL, /* domainBlockPeek */
NULL, /* domainMemoryPeek */
+ NULL, /* domainGetBlockInfo */
NULL, /* nodeGetCellsFreeMemory */
NULL, /* getFreeMemory */
NULL, /* domainEventRegister */
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 6ee5cc26a..0cac1300e 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -11467,6 +11467,7 @@ static virDriver qemuDriver = {
qemudDomainMemoryStats, /* domainMemoryStats */
qemudDomainBlockPeek, /* domainBlockPeek */
qemudDomainMemoryPeek, /* domainMemoryPeek */
+ NULL, /* domainBlockInfo */
nodeGetCellsFreeMemory, /* nodeGetCellsFreeMemory */
nodeGetFreeMemory, /* getFreeMemory */
qemuDomainEventRegister, /* domainEventRegister */
diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c
index 1917f267f..0494d8260 100644
--- a/src/remote/remote_driver.c
+++ b/src/remote/remote_driver.c
@@ -10144,6 +10144,7 @@ static virDriver remote_driver = {
remoteDomainMemoryStats, /* domainMemoryStats */
remoteDomainBlockPeek, /* domainBlockPeek */
remoteDomainMemoryPeek, /* domainMemoryPeek */
+ NULL, /* domainBlockInfo */
remoteNodeGetCellsFreeMemory, /* nodeGetCellsFreeMemory */
remoteNodeGetFreeMemory, /* getFreeMemory */
remoteDomainEventRegister, /* domainEventRegister */
diff --git a/src/test/test_driver.c b/src/test/test_driver.c
index 4ea027919..6706cba31 100644
--- a/src/test/test_driver.c
+++ b/src/test/test_driver.c
@@ -5280,6 +5280,7 @@ static virDriver testDriver = {
NULL, /* domainMemoryStats */
NULL, /* domainBlockPeek */
NULL, /* domainMemoryPeek */
+ NULL, /* domainGetBlockInfo */
testNodeGetCellsFreeMemory, /* nodeGetCellsFreeMemory */
NULL, /* getFreeMemory */
testDomainEventRegister, /* domainEventRegister */
diff --git a/src/uml/uml_driver.c b/src/uml/uml_driver.c
index a251e894b..644ac8b35 100644
--- a/src/uml/uml_driver.c
+++ b/src/uml/uml_driver.c
@@ -1911,6 +1911,7 @@ static virDriver umlDriver = {
NULL, /* domainMemoryStats */
umlDomainBlockPeek, /* domainBlockPeek */
NULL, /* domainMemoryPeek */
+ NULL, /* domainGetBlockInfo */
nodeGetCellsFreeMemory, /* nodeGetCellsFreeMemory */
nodeGetFreeMemory, /* getFreeMemory */
NULL, /* domainEventRegister */
diff --git a/src/vbox/vbox_tmpl.c b/src/vbox/vbox_tmpl.c
index f564213dc..6a9a2bf7f 100644
--- a/src/vbox/vbox_tmpl.c
+++ b/src/vbox/vbox_tmpl.c
@@ -8164,6 +8164,7 @@ virDriver NAME(Driver) = {
NULL, /* domainMemoryStats */
NULL, /* domainBlockPeek */
NULL, /* domainMemoryPeek */
+ NULL, /* domainGetBlockInfo */
nodeGetCellsFreeMemory, /* nodeGetCellsFreeMemory */
nodeGetFreeMemory, /* getFreeMemory */
#if VBOX_API_VERSION == 2002
diff --git a/src/xen/xen_driver.c b/src/xen/xen_driver.c
index b6dcf8d08..91f0acd2c 100644
--- a/src/xen/xen_driver.c
+++ b/src/xen/xen_driver.c
@@ -1961,6 +1961,7 @@ static virDriver xenUnifiedDriver = {
NULL, /* domainMemoryStats */
xenUnifiedDomainBlockPeek, /* domainBlockPeek */
NULL, /* domainMemoryPeek */
+ NULL, /* domainGetBlockInfo */
xenUnifiedNodeGetCellsFreeMemory, /* nodeGetCellsFreeMemory */
xenUnifiedNodeGetFreeMemory, /* getFreeMemory */
xenUnifiedDomainEventRegister, /* domainEventRegister */
diff --git a/src/xenapi/xenapi_driver.c b/src/xenapi/xenapi_driver.c
index 75796d617..7ef03cb2f 100644
--- a/src/xenapi/xenapi_driver.c
+++ b/src/xenapi/xenapi_driver.c
@@ -1762,6 +1762,7 @@ static virDriver xenapiDriver = {
NULL, /* domainMemoryStats */
NULL, /* domainBlockPeek */
NULL, /* domainMemoryPeek */
+ NULL, /* domainGetBlockInfo */
xenapiNodeGetCellsFreeMemory, /* nodeGetCellsFreeMemory */
xenapiNodeGetFreeMemory, /* getFreeMemory */
NULL, /* domainEventRegister */