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 --- src/driver.h | 7 ++++++ src/esx/esx_driver.c | 1 + src/libvirt.c | 48 +++++++++++++++++++++++++++++++++++++++++++ src/libvirt_public.syms | 5 ++++ src/lxc/lxc_driver.c | 1 + src/opennebula/one_driver.c | 1 + src/openvz/openvz_driver.c | 1 + src/phyp/phyp_driver.c | 1 + src/test/test_driver.c | 1 + src/uml/uml_driver.c | 1 + src/vbox/vbox_tmpl.c | 1 + src/xen/xen_driver.c | 1 + src/xenapi/xenapi_driver.c | 1 + 13 files changed, 70 insertions(+), 0 deletions(-) diff --git a/src/driver.h b/src/driver.h index f8db9c1..0975b59 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 c0c3195..8e55fc6 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 ff36681..7760f10 100644 --- a/src/libvirt.c +++ b/src/libvirt.c @@ -4625,6 +4625,54 @@ error: } +/** + * virDomainGetBlockInfo: + * @domain: a domain object + * @path: path to the block device or file + * @info: pointer to a virDomainBlockInfo structure allocated by the user + * + * 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", domain, info); + + 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 b4db904..81465d3 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 2851a2a..409b1cf 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 cdd61eb..acd52c2 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 47004d6..00b8a14 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 f4d817e..467ea19 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/test/test_driver.c b/src/test/test_driver.c index 4ea0279..6706cba 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 a251e89..644ac8b 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 f564213..6a9a2bf 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 b6dcf8d..91f0acd 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 75796d6..7ef03cb 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 */ -- 1.6.6.1 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list