mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 17:34:18 +03:00
Mon Apr 30 18:00:00 BST 2007 Richard W.M. Jones <rjones@redhat.com>
* src/xen_unified.c: In the non-root case keep track of the Xen underlying drivers which opened correctly and only try methods on those opened drivers.
This commit is contained in:
parent
68c6d74fa1
commit
ebd8071688
@ -1,3 +1,9 @@
|
|||||||
|
Mon Apr 30 18:00:00 BST 2007 Richard W.M. Jones <rjones@redhat.com>
|
||||||
|
|
||||||
|
* src/xen_unified.c: In the non-root case keep track of the
|
||||||
|
Xen underlying drivers which opened correctly and only
|
||||||
|
try methods on those opened drivers.
|
||||||
|
|
||||||
Mon Apr 30 17:58:00 BST 2007 Richard W.M. Jones <rjones@redhat.com>
|
Mon Apr 30 17:58:00 BST 2007 Richard W.M. Jones <rjones@redhat.com>
|
||||||
|
|
||||||
* src/libvirt.c (virConnectNumOfDefinedDomains): Documentation
|
* src/libvirt.c (virConnectNumOfDefinedDomains): Documentation
|
||||||
|
@ -41,14 +41,13 @@
|
|||||||
#include "xm_internal.h"
|
#include "xm_internal.h"
|
||||||
|
|
||||||
/* The five Xen drivers below us. */
|
/* The five Xen drivers below us. */
|
||||||
static virDriverPtr drivers[] = {
|
static virDriverPtr drivers[XEN_UNIFIED_NR_DRIVERS] = {
|
||||||
&xenHypervisorDriver,
|
&xenHypervisorDriver,
|
||||||
&xenProxyDriver,
|
&xenProxyDriver,
|
||||||
&xenDaemonDriver,
|
&xenDaemonDriver,
|
||||||
&xenStoreDriver,
|
&xenStoreDriver,
|
||||||
&xenXMDriver
|
&xenXMDriver
|
||||||
};
|
};
|
||||||
static const int nb_drivers = sizeof drivers / sizeof drivers[0];
|
|
||||||
static const int hypervisor_offset = 0;
|
static const int hypervisor_offset = 0;
|
||||||
static const int proxy_offset = 1;
|
static const int proxy_offset = 1;
|
||||||
|
|
||||||
@ -109,8 +108,8 @@ xenUnifiedOpen (virConnectPtr conn, const char *name, int flags)
|
|||||||
priv->xshandle = NULL;
|
priv->xshandle = NULL;
|
||||||
priv->proxy = -1;
|
priv->proxy = -1;
|
||||||
|
|
||||||
for (i = 0; i < nb_drivers; ++i) {
|
for (i = 0; i < XEN_UNIFIED_NR_DRIVERS; ++i) {
|
||||||
int failed_to_open = 1;
|
priv->opened[i] = 0;
|
||||||
|
|
||||||
/* Ignore proxy for root */
|
/* Ignore proxy for root */
|
||||||
if (i == proxy_offset && getuid() == 0)
|
if (i == proxy_offset && getuid() == 0)
|
||||||
@ -118,13 +117,13 @@ xenUnifiedOpen (virConnectPtr conn, const char *name, int flags)
|
|||||||
|
|
||||||
if (drivers[i]->open &&
|
if (drivers[i]->open &&
|
||||||
drivers[i]->open (conn, name, flags) == VIR_DRV_OPEN_SUCCESS)
|
drivers[i]->open (conn, name, flags) == VIR_DRV_OPEN_SUCCESS)
|
||||||
failed_to_open = 0;
|
priv->opened[i] = 1;
|
||||||
|
|
||||||
/* If as root, then all drivers must succeed.
|
/* If as root, then all drivers must succeed.
|
||||||
If non-root, then only proxy must succeed */
|
If non-root, then only proxy must succeed */
|
||||||
if (failed_to_open && (getuid() == 0 || i == proxy_offset)) {
|
if (!priv->opened[i] && (getuid() == 0 || i == proxy_offset)) {
|
||||||
for (j = 0; j < i; ++j)
|
for (j = 0; j < i; ++j)
|
||||||
drivers[j]->close (conn);
|
if (priv->opened[j]) drivers[j]->close (conn);
|
||||||
return VIR_DRV_OPEN_ERROR;
|
return VIR_DRV_OPEN_ERROR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -132,13 +131,17 @@ xenUnifiedOpen (virConnectPtr conn, const char *name, int flags)
|
|||||||
return VIR_DRV_OPEN_SUCCESS;
|
return VIR_DRV_OPEN_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define GET_PRIVATE(conn) \
|
||||||
|
xenUnifiedPrivatePtr priv = (xenUnifiedPrivatePtr) (conn)->privateData
|
||||||
|
|
||||||
static int
|
static int
|
||||||
xenUnifiedClose (virConnectPtr conn)
|
xenUnifiedClose (virConnectPtr conn)
|
||||||
{
|
{
|
||||||
|
GET_PRIVATE(conn);
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; i < nb_drivers; ++i)
|
for (i = 0; i < XEN_UNIFIED_NR_DRIVERS; ++i)
|
||||||
if (drivers[i]->close)
|
if (priv->opened[i] && drivers[i]->close)
|
||||||
(void) drivers[i]->close (conn);
|
(void) drivers[i]->close (conn);
|
||||||
|
|
||||||
free (conn->privateData);
|
free (conn->privateData);
|
||||||
@ -150,11 +153,12 @@ xenUnifiedClose (virConnectPtr conn)
|
|||||||
static const char *
|
static const char *
|
||||||
xenUnifiedType (virConnectPtr conn)
|
xenUnifiedType (virConnectPtr conn)
|
||||||
{
|
{
|
||||||
|
GET_PRIVATE(conn);
|
||||||
int i;
|
int i;
|
||||||
const char *ret;
|
const char *ret;
|
||||||
|
|
||||||
for (i = 0; i < nb_drivers; ++i)
|
for (i = 0; i < XEN_UNIFIED_NR_DRIVERS; ++i)
|
||||||
if (drivers[i]->type) {
|
if (priv->opened[i] && drivers[i]->type) {
|
||||||
ret = drivers[i]->type (conn);
|
ret = drivers[i]->type (conn);
|
||||||
if (ret) return ret;
|
if (ret) return ret;
|
||||||
}
|
}
|
||||||
@ -165,10 +169,12 @@ xenUnifiedType (virConnectPtr conn)
|
|||||||
static int
|
static int
|
||||||
xenUnifiedVersion (virConnectPtr conn, unsigned long *hvVer)
|
xenUnifiedVersion (virConnectPtr conn, unsigned long *hvVer)
|
||||||
{
|
{
|
||||||
|
GET_PRIVATE(conn);
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; i < nb_drivers; ++i)
|
for (i = 0; i < XEN_UNIFIED_NR_DRIVERS; ++i)
|
||||||
if (drivers[i]->version &&
|
if (priv->opened[i] &&
|
||||||
|
drivers[i]->version &&
|
||||||
drivers[i]->version (conn, hvVer) == 0)
|
drivers[i]->version (conn, hvVer) == 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
@ -178,13 +184,14 @@ xenUnifiedVersion (virConnectPtr conn, unsigned long *hvVer)
|
|||||||
static int
|
static int
|
||||||
xenUnifiedGetMaxVcpus (virConnectPtr conn, const char *type)
|
xenUnifiedGetMaxVcpus (virConnectPtr conn, const char *type)
|
||||||
{
|
{
|
||||||
|
GET_PRIVATE(conn);
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if (!type)
|
if (!type)
|
||||||
type = "Xen";
|
type = "Xen";
|
||||||
|
|
||||||
for (i = 0; i < nb_drivers; ++i)
|
for (i = 0; i < XEN_UNIFIED_NR_DRIVERS; ++i)
|
||||||
if (strcmp (drivers[i]->name, type) == 0)
|
if (priv->opened[i] && strcmp (drivers[i]->name, type) == 0)
|
||||||
return drivers[i]->getMaxVcpus (conn, type);
|
return drivers[i]->getMaxVcpus (conn, type);
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
@ -193,10 +200,12 @@ xenUnifiedGetMaxVcpus (virConnectPtr conn, const char *type)
|
|||||||
static int
|
static int
|
||||||
xenUnifiedNodeGetInfo (virConnectPtr conn, virNodeInfoPtr info)
|
xenUnifiedNodeGetInfo (virConnectPtr conn, virNodeInfoPtr info)
|
||||||
{
|
{
|
||||||
|
GET_PRIVATE(conn);
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; i < nb_drivers; ++i)
|
for (i = 0; i < XEN_UNIFIED_NR_DRIVERS; ++i)
|
||||||
if (drivers[i]->nodeGetInfo &&
|
if (priv->opened[i] &&
|
||||||
|
drivers[i]->nodeGetInfo &&
|
||||||
drivers[i]->nodeGetInfo (conn, info) == 0)
|
drivers[i]->nodeGetInfo (conn, info) == 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
@ -206,11 +215,12 @@ xenUnifiedNodeGetInfo (virConnectPtr conn, virNodeInfoPtr info)
|
|||||||
static char *
|
static char *
|
||||||
xenUnifiedGetCapabilities (virConnectPtr conn)
|
xenUnifiedGetCapabilities (virConnectPtr conn)
|
||||||
{
|
{
|
||||||
|
GET_PRIVATE(conn);
|
||||||
int i;
|
int i;
|
||||||
char *ret;
|
char *ret;
|
||||||
|
|
||||||
for (i = 0; i < nb_drivers; ++i)
|
for (i = 0; i < XEN_UNIFIED_NR_DRIVERS; ++i)
|
||||||
if (drivers[i]->getCapabilities) {
|
if (priv->opened[i] && drivers[i]->getCapabilities) {
|
||||||
ret = drivers[i]->getCapabilities (conn);
|
ret = drivers[i]->getCapabilities (conn);
|
||||||
if (ret) return ret;
|
if (ret) return ret;
|
||||||
}
|
}
|
||||||
@ -221,10 +231,11 @@ xenUnifiedGetCapabilities (virConnectPtr conn)
|
|||||||
static int
|
static int
|
||||||
xenUnifiedListDomains (virConnectPtr conn, int *ids, int maxids)
|
xenUnifiedListDomains (virConnectPtr conn, int *ids, int maxids)
|
||||||
{
|
{
|
||||||
|
GET_PRIVATE(conn);
|
||||||
int i, ret;
|
int i, ret;
|
||||||
|
|
||||||
for (i = 0; i < nb_drivers; ++i)
|
for (i = 0; i < XEN_UNIFIED_NR_DRIVERS; ++i)
|
||||||
if (drivers[i]->listDomains) {
|
if (priv->opened[i] && drivers[i]->listDomains) {
|
||||||
ret = drivers[i]->listDomains (conn, ids, maxids);
|
ret = drivers[i]->listDomains (conn, ids, maxids);
|
||||||
if (ret >= 0) return ret;
|
if (ret >= 0) return ret;
|
||||||
}
|
}
|
||||||
@ -235,10 +246,11 @@ xenUnifiedListDomains (virConnectPtr conn, int *ids, int maxids)
|
|||||||
static int
|
static int
|
||||||
xenUnifiedNumOfDomains (virConnectPtr conn)
|
xenUnifiedNumOfDomains (virConnectPtr conn)
|
||||||
{
|
{
|
||||||
|
GET_PRIVATE(conn);
|
||||||
int i, ret;
|
int i, ret;
|
||||||
|
|
||||||
for (i = 0; i < nb_drivers; ++i)
|
for (i = 0; i < XEN_UNIFIED_NR_DRIVERS; ++i)
|
||||||
if (drivers[i]->numOfDomains) {
|
if (priv->opened[i] && drivers[i]->numOfDomains) {
|
||||||
ret = drivers[i]->numOfDomains (conn);
|
ret = drivers[i]->numOfDomains (conn);
|
||||||
if (ret >= 0) return ret;
|
if (ret >= 0) return ret;
|
||||||
}
|
}
|
||||||
@ -250,11 +262,12 @@ static virDomainPtr
|
|||||||
xenUnifiedDomainCreateLinux (virConnectPtr conn,
|
xenUnifiedDomainCreateLinux (virConnectPtr conn,
|
||||||
const char *xmlDesc, unsigned int flags)
|
const char *xmlDesc, unsigned int flags)
|
||||||
{
|
{
|
||||||
|
GET_PRIVATE(conn);
|
||||||
int i;
|
int i;
|
||||||
virDomainPtr ret;
|
virDomainPtr ret;
|
||||||
|
|
||||||
for (i = 0; i < nb_drivers; ++i)
|
for (i = 0; i < XEN_UNIFIED_NR_DRIVERS; ++i)
|
||||||
if (drivers[i]->domainCreateLinux) {
|
if (priv->opened[i] && drivers[i]->domainCreateLinux) {
|
||||||
ret = drivers[i]->domainCreateLinux (conn, xmlDesc, flags);
|
ret = drivers[i]->domainCreateLinux (conn, xmlDesc, flags);
|
||||||
if (ret) return ret;
|
if (ret) return ret;
|
||||||
}
|
}
|
||||||
@ -265,11 +278,12 @@ xenUnifiedDomainCreateLinux (virConnectPtr conn,
|
|||||||
static virDomainPtr
|
static virDomainPtr
|
||||||
xenUnifiedDomainLookupByID (virConnectPtr conn, int id)
|
xenUnifiedDomainLookupByID (virConnectPtr conn, int id)
|
||||||
{
|
{
|
||||||
|
GET_PRIVATE(conn);
|
||||||
int i;
|
int i;
|
||||||
virDomainPtr ret;
|
virDomainPtr ret;
|
||||||
|
|
||||||
for (i = 0; i < nb_drivers; ++i)
|
for (i = 0; i < XEN_UNIFIED_NR_DRIVERS; ++i)
|
||||||
if (drivers[i]->domainLookupByID) {
|
if (priv->opened[i] && drivers[i]->domainLookupByID) {
|
||||||
ret = drivers[i]->domainLookupByID (conn, id);
|
ret = drivers[i]->domainLookupByID (conn, id);
|
||||||
if (ret) return ret;
|
if (ret) return ret;
|
||||||
}
|
}
|
||||||
@ -281,11 +295,12 @@ static virDomainPtr
|
|||||||
xenUnifiedDomainLookupByUUID (virConnectPtr conn,
|
xenUnifiedDomainLookupByUUID (virConnectPtr conn,
|
||||||
const unsigned char *uuid)
|
const unsigned char *uuid)
|
||||||
{
|
{
|
||||||
|
GET_PRIVATE(conn);
|
||||||
int i;
|
int i;
|
||||||
virDomainPtr ret;
|
virDomainPtr ret;
|
||||||
|
|
||||||
for (i = 0; i < nb_drivers; ++i)
|
for (i = 0; i < XEN_UNIFIED_NR_DRIVERS; ++i)
|
||||||
if (drivers[i]->domainLookupByUUID) {
|
if (priv->opened[i] && drivers[i]->domainLookupByUUID) {
|
||||||
ret = drivers[i]->domainLookupByUUID (conn, uuid);
|
ret = drivers[i]->domainLookupByUUID (conn, uuid);
|
||||||
if (ret) return ret;
|
if (ret) return ret;
|
||||||
}
|
}
|
||||||
@ -297,11 +312,12 @@ static virDomainPtr
|
|||||||
xenUnifiedDomainLookupByName (virConnectPtr conn,
|
xenUnifiedDomainLookupByName (virConnectPtr conn,
|
||||||
const char *name)
|
const char *name)
|
||||||
{
|
{
|
||||||
|
GET_PRIVATE(conn);
|
||||||
int i;
|
int i;
|
||||||
virDomainPtr ret;
|
virDomainPtr ret;
|
||||||
|
|
||||||
for (i = 0; i < nb_drivers; ++i)
|
for (i = 0; i < XEN_UNIFIED_NR_DRIVERS; ++i)
|
||||||
if (drivers[i]->domainLookupByName) {
|
if (priv->opened[i] && drivers[i]->domainLookupByName) {
|
||||||
ret = drivers[i]->domainLookupByName (conn, name);
|
ret = drivers[i]->domainLookupByName (conn, name);
|
||||||
if (ret) return ret;
|
if (ret) return ret;
|
||||||
}
|
}
|
||||||
@ -312,18 +328,21 @@ xenUnifiedDomainLookupByName (virConnectPtr conn,
|
|||||||
static int
|
static int
|
||||||
xenUnifiedDomainSuspend (virDomainPtr dom)
|
xenUnifiedDomainSuspend (virDomainPtr dom)
|
||||||
{
|
{
|
||||||
|
GET_PRIVATE(dom->conn);
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
/* Try non-hypervisor methods first, then hypervisor direct method
|
/* Try non-hypervisor methods first, then hypervisor direct method
|
||||||
* as a last resort.
|
* as a last resort.
|
||||||
*/
|
*/
|
||||||
for (i = 0; i < nb_drivers; ++i)
|
for (i = 0; i < XEN_UNIFIED_NR_DRIVERS; ++i)
|
||||||
if (i != hypervisor_offset &&
|
if (i != hypervisor_offset &&
|
||||||
|
priv->opened[i] &&
|
||||||
drivers[i]->domainSuspend &&
|
drivers[i]->domainSuspend &&
|
||||||
drivers[i]->domainSuspend (dom) == 0)
|
drivers[i]->domainSuspend (dom) == 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (drivers[hypervisor_offset]->domainSuspend &&
|
if (priv->opened[hypervisor_offset] &&
|
||||||
|
drivers[hypervisor_offset]->domainSuspend &&
|
||||||
drivers[hypervisor_offset]->domainSuspend (dom) == 0)
|
drivers[hypervisor_offset]->domainSuspend (dom) == 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
@ -333,18 +352,21 @@ xenUnifiedDomainSuspend (virDomainPtr dom)
|
|||||||
static int
|
static int
|
||||||
xenUnifiedDomainResume (virDomainPtr dom)
|
xenUnifiedDomainResume (virDomainPtr dom)
|
||||||
{
|
{
|
||||||
|
GET_PRIVATE(dom->conn);
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
/* Try non-hypervisor methods first, then hypervisor direct method
|
/* Try non-hypervisor methods first, then hypervisor direct method
|
||||||
* as a last resort.
|
* as a last resort.
|
||||||
*/
|
*/
|
||||||
for (i = 0; i < nb_drivers; ++i)
|
for (i = 0; i < XEN_UNIFIED_NR_DRIVERS; ++i)
|
||||||
if (i != hypervisor_offset &&
|
if (i != hypervisor_offset &&
|
||||||
|
priv->opened[i] &&
|
||||||
drivers[i]->domainResume &&
|
drivers[i]->domainResume &&
|
||||||
drivers[i]->domainResume (dom) == 0)
|
drivers[i]->domainResume (dom) == 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (drivers[hypervisor_offset]->domainResume &&
|
if (priv->opened[hypervisor_offset] &&
|
||||||
|
drivers[hypervisor_offset]->domainResume &&
|
||||||
drivers[hypervisor_offset]->domainResume (dom) == 0)
|
drivers[hypervisor_offset]->domainResume (dom) == 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
@ -354,10 +376,12 @@ xenUnifiedDomainResume (virDomainPtr dom)
|
|||||||
static int
|
static int
|
||||||
xenUnifiedDomainShutdown (virDomainPtr dom)
|
xenUnifiedDomainShutdown (virDomainPtr dom)
|
||||||
{
|
{
|
||||||
|
GET_PRIVATE(dom->conn);
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; i < nb_drivers; ++i)
|
for (i = 0; i < XEN_UNIFIED_NR_DRIVERS; ++i)
|
||||||
if (drivers[i]->domainShutdown &&
|
if (priv->opened[i] &&
|
||||||
|
drivers[i]->domainShutdown &&
|
||||||
drivers[i]->domainShutdown (dom) == 0)
|
drivers[i]->domainShutdown (dom) == 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
@ -367,10 +391,12 @@ xenUnifiedDomainShutdown (virDomainPtr dom)
|
|||||||
static int
|
static int
|
||||||
xenUnifiedDomainReboot (virDomainPtr dom, unsigned int flags)
|
xenUnifiedDomainReboot (virDomainPtr dom, unsigned int flags)
|
||||||
{
|
{
|
||||||
|
GET_PRIVATE(dom->conn);
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; i < nb_drivers; ++i)
|
for (i = 0; i < XEN_UNIFIED_NR_DRIVERS; ++i)
|
||||||
if (drivers[i]->domainReboot &&
|
if (priv->opened[i] &&
|
||||||
|
drivers[i]->domainReboot &&
|
||||||
drivers[i]->domainReboot (dom, flags) == 0)
|
drivers[i]->domainReboot (dom, flags) == 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
@ -380,18 +406,21 @@ xenUnifiedDomainReboot (virDomainPtr dom, unsigned int flags)
|
|||||||
static int
|
static int
|
||||||
xenUnifiedDomainDestroy (virDomainPtr dom)
|
xenUnifiedDomainDestroy (virDomainPtr dom)
|
||||||
{
|
{
|
||||||
|
GET_PRIVATE(dom->conn);
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
/* Try non-hypervisor methods first, then hypervisor direct method
|
/* Try non-hypervisor methods first, then hypervisor direct method
|
||||||
* as a last resort.
|
* as a last resort.
|
||||||
*/
|
*/
|
||||||
for (i = 0; i < nb_drivers; ++i)
|
for (i = 0; i < XEN_UNIFIED_NR_DRIVERS; ++i)
|
||||||
if (i != hypervisor_offset &&
|
if (i != hypervisor_offset &&
|
||||||
|
priv->opened[i] &&
|
||||||
drivers[i]->domainDestroy &&
|
drivers[i]->domainDestroy &&
|
||||||
drivers[i]->domainDestroy (dom) == 0)
|
drivers[i]->domainDestroy (dom) == 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (drivers[hypervisor_offset]->domainDestroy &&
|
if (priv->opened[i] &&
|
||||||
|
drivers[hypervisor_offset]->domainDestroy &&
|
||||||
drivers[hypervisor_offset]->domainDestroy (dom) == 0)
|
drivers[hypervisor_offset]->domainDestroy (dom) == 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
@ -401,11 +430,12 @@ xenUnifiedDomainDestroy (virDomainPtr dom)
|
|||||||
static char *
|
static char *
|
||||||
xenUnifiedDomainGetOSType (virDomainPtr dom)
|
xenUnifiedDomainGetOSType (virDomainPtr dom)
|
||||||
{
|
{
|
||||||
|
GET_PRIVATE(dom->conn);
|
||||||
int i;
|
int i;
|
||||||
char *ret;
|
char *ret;
|
||||||
|
|
||||||
for (i = 0; i < nb_drivers; ++i)
|
for (i = 0; i < XEN_UNIFIED_NR_DRIVERS; ++i)
|
||||||
if (drivers[i]->domainGetOSType) {
|
if (priv->opened[i] && drivers[i]->domainGetOSType) {
|
||||||
ret = drivers[i]->domainGetOSType (dom);
|
ret = drivers[i]->domainGetOSType (dom);
|
||||||
if (ret) return ret;
|
if (ret) return ret;
|
||||||
}
|
}
|
||||||
@ -416,11 +446,12 @@ xenUnifiedDomainGetOSType (virDomainPtr dom)
|
|||||||
static unsigned long
|
static unsigned long
|
||||||
xenUnifiedDomainGetMaxMemory (virDomainPtr dom)
|
xenUnifiedDomainGetMaxMemory (virDomainPtr dom)
|
||||||
{
|
{
|
||||||
|
GET_PRIVATE(dom->conn);
|
||||||
int i;
|
int i;
|
||||||
unsigned long ret;
|
unsigned long ret;
|
||||||
|
|
||||||
for (i = 0; i < nb_drivers; ++i)
|
for (i = 0; i < XEN_UNIFIED_NR_DRIVERS; ++i)
|
||||||
if (drivers[i]->domainGetMaxMemory) {
|
if (priv->opened[i] && drivers[i]->domainGetMaxMemory) {
|
||||||
ret = drivers[i]->domainGetMaxMemory (dom);
|
ret = drivers[i]->domainGetMaxMemory (dom);
|
||||||
if (ret != 0) return ret;
|
if (ret != 0) return ret;
|
||||||
}
|
}
|
||||||
@ -431,10 +462,12 @@ xenUnifiedDomainGetMaxMemory (virDomainPtr dom)
|
|||||||
static int
|
static int
|
||||||
xenUnifiedDomainSetMaxMemory (virDomainPtr dom, unsigned long memory)
|
xenUnifiedDomainSetMaxMemory (virDomainPtr dom, unsigned long memory)
|
||||||
{
|
{
|
||||||
|
GET_PRIVATE(dom->conn);
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; i < nb_drivers; ++i)
|
for (i = 0; i < XEN_UNIFIED_NR_DRIVERS; ++i)
|
||||||
if (drivers[i]->domainSetMaxMemory &&
|
if (priv->opened[i] &&
|
||||||
|
drivers[i]->domainSetMaxMemory &&
|
||||||
drivers[i]->domainSetMaxMemory (dom, memory) == 0)
|
drivers[i]->domainSetMaxMemory (dom, memory) == 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
@ -444,10 +477,12 @@ xenUnifiedDomainSetMaxMemory (virDomainPtr dom, unsigned long memory)
|
|||||||
static int
|
static int
|
||||||
xenUnifiedDomainSetMemory (virDomainPtr dom, unsigned long memory)
|
xenUnifiedDomainSetMemory (virDomainPtr dom, unsigned long memory)
|
||||||
{
|
{
|
||||||
|
GET_PRIVATE(dom->conn);
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; i < nb_drivers; ++i)
|
for (i = 0; i < XEN_UNIFIED_NR_DRIVERS; ++i)
|
||||||
if (drivers[i]->domainSetMemory &&
|
if (priv->opened[i] &&
|
||||||
|
drivers[i]->domainSetMemory &&
|
||||||
drivers[i]->domainSetMemory (dom, memory) == 0)
|
drivers[i]->domainSetMemory (dom, memory) == 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
@ -457,10 +492,12 @@ xenUnifiedDomainSetMemory (virDomainPtr dom, unsigned long memory)
|
|||||||
static int
|
static int
|
||||||
xenUnifiedDomainGetInfo (virDomainPtr dom, virDomainInfoPtr info)
|
xenUnifiedDomainGetInfo (virDomainPtr dom, virDomainInfoPtr info)
|
||||||
{
|
{
|
||||||
|
GET_PRIVATE(dom->conn);
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; i < nb_drivers; ++i)
|
for (i = 0; i < XEN_UNIFIED_NR_DRIVERS; ++i)
|
||||||
if (drivers[i]->domainGetInfo &&
|
if (priv->opened[i] &&
|
||||||
|
drivers[i]->domainGetInfo &&
|
||||||
drivers[i]->domainGetInfo (dom, info) == 0)
|
drivers[i]->domainGetInfo (dom, info) == 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
@ -470,10 +507,12 @@ xenUnifiedDomainGetInfo (virDomainPtr dom, virDomainInfoPtr info)
|
|||||||
static int
|
static int
|
||||||
xenUnifiedDomainSave (virDomainPtr dom, const char *to)
|
xenUnifiedDomainSave (virDomainPtr dom, const char *to)
|
||||||
{
|
{
|
||||||
|
GET_PRIVATE(dom->conn);
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; i < nb_drivers; ++i)
|
for (i = 0; i < XEN_UNIFIED_NR_DRIVERS; ++i)
|
||||||
if (drivers[i]->domainSave &&
|
if (priv->opened[i] &&
|
||||||
|
drivers[i]->domainSave &&
|
||||||
drivers[i]->domainSave (dom, to) == 0)
|
drivers[i]->domainSave (dom, to) == 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
@ -483,10 +522,12 @@ xenUnifiedDomainSave (virDomainPtr dom, const char *to)
|
|||||||
static int
|
static int
|
||||||
xenUnifiedDomainRestore (virConnectPtr conn, const char *from)
|
xenUnifiedDomainRestore (virConnectPtr conn, const char *from)
|
||||||
{
|
{
|
||||||
|
GET_PRIVATE(conn);
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; i < nb_drivers; ++i)
|
for (i = 0; i < XEN_UNIFIED_NR_DRIVERS; ++i)
|
||||||
if (drivers[i]->domainRestore &&
|
if (priv->opened[i] &&
|
||||||
|
drivers[i]->domainRestore &&
|
||||||
drivers[i]->domainRestore (conn, from) == 0)
|
drivers[i]->domainRestore (conn, from) == 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
@ -496,10 +537,12 @@ xenUnifiedDomainRestore (virConnectPtr conn, const char *from)
|
|||||||
static int
|
static int
|
||||||
xenUnifiedDomainCoreDump (virDomainPtr dom, const char *to, int flags)
|
xenUnifiedDomainCoreDump (virDomainPtr dom, const char *to, int flags)
|
||||||
{
|
{
|
||||||
|
GET_PRIVATE(dom->conn);
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; i < nb_drivers; ++i)
|
for (i = 0; i < XEN_UNIFIED_NR_DRIVERS; ++i)
|
||||||
if (drivers[i]->domainCoreDump &&
|
if (priv->opened[i] &&
|
||||||
|
drivers[i]->domainCoreDump &&
|
||||||
drivers[i]->domainCoreDump (dom, to, flags) == 0)
|
drivers[i]->domainCoreDump (dom, to, flags) == 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
@ -509,18 +552,21 @@ xenUnifiedDomainCoreDump (virDomainPtr dom, const char *to, int flags)
|
|||||||
static int
|
static int
|
||||||
xenUnifiedDomainSetVcpus (virDomainPtr dom, unsigned int nvcpus)
|
xenUnifiedDomainSetVcpus (virDomainPtr dom, unsigned int nvcpus)
|
||||||
{
|
{
|
||||||
|
GET_PRIVATE(dom->conn);
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
/* Try non-hypervisor methods first, then hypervisor direct method
|
/* Try non-hypervisor methods first, then hypervisor direct method
|
||||||
* as a last resort.
|
* as a last resort.
|
||||||
*/
|
*/
|
||||||
for (i = 0; i < nb_drivers; ++i)
|
for (i = 0; i < XEN_UNIFIED_NR_DRIVERS; ++i)
|
||||||
if (i != hypervisor_offset &&
|
if (i != hypervisor_offset &&
|
||||||
|
priv->opened[i] &&
|
||||||
drivers[i]->domainSetVcpus &&
|
drivers[i]->domainSetVcpus &&
|
||||||
drivers[i]->domainSetVcpus (dom, nvcpus) == 0)
|
drivers[i]->domainSetVcpus (dom, nvcpus) == 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (drivers[hypervisor_offset]->domainSetVcpus &&
|
if (priv->opened[hypervisor_offset] &&
|
||||||
|
drivers[hypervisor_offset]->domainSetVcpus &&
|
||||||
drivers[hypervisor_offset]->domainSetVcpus (dom, nvcpus) == 0)
|
drivers[hypervisor_offset]->domainSetVcpus (dom, nvcpus) == 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
@ -531,10 +577,12 @@ static int
|
|||||||
xenUnifiedDomainPinVcpu (virDomainPtr dom, unsigned int vcpu,
|
xenUnifiedDomainPinVcpu (virDomainPtr dom, unsigned int vcpu,
|
||||||
unsigned char *cpumap, int maplen)
|
unsigned char *cpumap, int maplen)
|
||||||
{
|
{
|
||||||
|
GET_PRIVATE(dom->conn);
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; i < nb_drivers; ++i)
|
for (i = 0; i < XEN_UNIFIED_NR_DRIVERS; ++i)
|
||||||
if (drivers[i]->domainPinVcpu &&
|
if (priv->opened[i] &&
|
||||||
|
drivers[i]->domainPinVcpu &&
|
||||||
drivers[i]->domainPinVcpu (dom, vcpu, cpumap, maplen) == 0)
|
drivers[i]->domainPinVcpu (dom, vcpu, cpumap, maplen) == 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
@ -546,10 +594,11 @@ xenUnifiedDomainGetVcpus (virDomainPtr dom,
|
|||||||
virVcpuInfoPtr info, int maxinfo,
|
virVcpuInfoPtr info, int maxinfo,
|
||||||
unsigned char *cpumaps, int maplen)
|
unsigned char *cpumaps, int maplen)
|
||||||
{
|
{
|
||||||
|
GET_PRIVATE(dom->conn);
|
||||||
int i, ret;
|
int i, ret;
|
||||||
|
|
||||||
for (i = 0; i < nb_drivers; ++i)
|
for (i = 0; i < XEN_UNIFIED_NR_DRIVERS; ++i)
|
||||||
if (drivers[i]->domainGetVcpus) {
|
if (priv->opened[i] && drivers[i]->domainGetVcpus) {
|
||||||
ret = drivers[i]->domainGetVcpus (dom, info, maxinfo, cpumaps, maplen);
|
ret = drivers[i]->domainGetVcpus (dom, info, maxinfo, cpumaps, maplen);
|
||||||
if (ret > 0)
|
if (ret > 0)
|
||||||
return ret;
|
return ret;
|
||||||
@ -560,10 +609,11 @@ xenUnifiedDomainGetVcpus (virDomainPtr dom,
|
|||||||
static int
|
static int
|
||||||
xenUnifiedDomainGetMaxVcpus (virDomainPtr dom)
|
xenUnifiedDomainGetMaxVcpus (virDomainPtr dom)
|
||||||
{
|
{
|
||||||
|
GET_PRIVATE(dom->conn);
|
||||||
int i, ret;
|
int i, ret;
|
||||||
|
|
||||||
for (i = 0; i < nb_drivers; ++i)
|
for (i = 0; i < XEN_UNIFIED_NR_DRIVERS; ++i)
|
||||||
if (drivers[i]->domainGetMaxVcpus) {
|
if (priv->opened[i] && drivers[i]->domainGetMaxVcpus) {
|
||||||
ret = drivers[i]->domainGetMaxVcpus (dom);
|
ret = drivers[i]->domainGetMaxVcpus (dom);
|
||||||
if (ret != 0) return ret;
|
if (ret != 0) return ret;
|
||||||
}
|
}
|
||||||
@ -574,11 +624,12 @@ xenUnifiedDomainGetMaxVcpus (virDomainPtr dom)
|
|||||||
static char *
|
static char *
|
||||||
xenUnifiedDomainDumpXML (virDomainPtr dom, int flags)
|
xenUnifiedDomainDumpXML (virDomainPtr dom, int flags)
|
||||||
{
|
{
|
||||||
|
GET_PRIVATE(dom->conn);
|
||||||
int i;
|
int i;
|
||||||
char *ret;
|
char *ret;
|
||||||
|
|
||||||
for (i = 0; i < nb_drivers; ++i)
|
for (i = 0; i < XEN_UNIFIED_NR_DRIVERS; ++i)
|
||||||
if (drivers[i]->domainDumpXML) {
|
if (priv->opened[i] && drivers[i]->domainDumpXML) {
|
||||||
ret = drivers[i]->domainDumpXML (dom, flags);
|
ret = drivers[i]->domainDumpXML (dom, flags);
|
||||||
if (ret) return ret;
|
if (ret) return ret;
|
||||||
}
|
}
|
||||||
@ -590,11 +641,12 @@ static int
|
|||||||
xenUnifiedListDefinedDomains (virConnectPtr conn, char **const names,
|
xenUnifiedListDefinedDomains (virConnectPtr conn, char **const names,
|
||||||
int maxnames)
|
int maxnames)
|
||||||
{
|
{
|
||||||
|
GET_PRIVATE(conn);
|
||||||
int i;
|
int i;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
for (i = 0; i < nb_drivers; ++i)
|
for (i = 0; i < XEN_UNIFIED_NR_DRIVERS; ++i)
|
||||||
if (drivers[i]->listDefinedDomains) {
|
if (priv->opened[i] && drivers[i]->listDefinedDomains) {
|
||||||
ret = drivers[i]->listDefinedDomains (conn, names, maxnames);
|
ret = drivers[i]->listDefinedDomains (conn, names, maxnames);
|
||||||
if (ret >= 0) return ret;
|
if (ret >= 0) return ret;
|
||||||
}
|
}
|
||||||
@ -605,11 +657,12 @@ xenUnifiedListDefinedDomains (virConnectPtr conn, char **const names,
|
|||||||
static int
|
static int
|
||||||
xenUnifiedNumOfDefinedDomains (virConnectPtr conn)
|
xenUnifiedNumOfDefinedDomains (virConnectPtr conn)
|
||||||
{
|
{
|
||||||
|
GET_PRIVATE(conn);
|
||||||
int i;
|
int i;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
for (i = 0; i < nb_drivers; ++i)
|
for (i = 0; i < XEN_UNIFIED_NR_DRIVERS; ++i)
|
||||||
if (drivers[i]->numOfDefinedDomains) {
|
if (priv->opened[i] && drivers[i]->numOfDefinedDomains) {
|
||||||
ret = drivers[i]->numOfDefinedDomains (conn);
|
ret = drivers[i]->numOfDefinedDomains (conn);
|
||||||
if (ret >= 0) return ret;
|
if (ret >= 0) return ret;
|
||||||
}
|
}
|
||||||
@ -620,10 +673,11 @@ xenUnifiedNumOfDefinedDomains (virConnectPtr conn)
|
|||||||
static int
|
static int
|
||||||
xenUnifiedDomainCreate (virDomainPtr dom)
|
xenUnifiedDomainCreate (virDomainPtr dom)
|
||||||
{
|
{
|
||||||
|
GET_PRIVATE(dom->conn);
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; i < nb_drivers; ++i)
|
for (i = 0; i < XEN_UNIFIED_NR_DRIVERS; ++i)
|
||||||
if (drivers[i]->domainCreate &&
|
if (priv->opened[i] && drivers[i]->domainCreate &&
|
||||||
drivers[i]->domainCreate (dom) == 0)
|
drivers[i]->domainCreate (dom) == 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
@ -633,11 +687,12 @@ xenUnifiedDomainCreate (virDomainPtr dom)
|
|||||||
static virDomainPtr
|
static virDomainPtr
|
||||||
xenUnifiedDomainDefineXML (virConnectPtr conn, const char *xml)
|
xenUnifiedDomainDefineXML (virConnectPtr conn, const char *xml)
|
||||||
{
|
{
|
||||||
|
GET_PRIVATE(conn);
|
||||||
int i;
|
int i;
|
||||||
virDomainPtr ret;
|
virDomainPtr ret;
|
||||||
|
|
||||||
for (i = 0; i < nb_drivers; ++i)
|
for (i = 0; i < XEN_UNIFIED_NR_DRIVERS; ++i)
|
||||||
if (drivers[i]->domainDefineXML) {
|
if (priv->opened[i] && drivers[i]->domainDefineXML) {
|
||||||
ret = drivers[i]->domainDefineXML (conn, xml);
|
ret = drivers[i]->domainDefineXML (conn, xml);
|
||||||
if (ret) return ret;
|
if (ret) return ret;
|
||||||
}
|
}
|
||||||
@ -648,10 +703,11 @@ xenUnifiedDomainDefineXML (virConnectPtr conn, const char *xml)
|
|||||||
static int
|
static int
|
||||||
xenUnifiedDomainUndefine (virDomainPtr dom)
|
xenUnifiedDomainUndefine (virDomainPtr dom)
|
||||||
{
|
{
|
||||||
|
GET_PRIVATE(dom->conn);
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; i < nb_drivers; ++i)
|
for (i = 0; i < XEN_UNIFIED_NR_DRIVERS; ++i)
|
||||||
if (drivers[i]->domainUndefine &&
|
if (priv->opened[i] && drivers[i]->domainUndefine &&
|
||||||
drivers[i]->domainUndefine (dom) == 0)
|
drivers[i]->domainUndefine (dom) == 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
@ -661,10 +717,11 @@ xenUnifiedDomainUndefine (virDomainPtr dom)
|
|||||||
static int
|
static int
|
||||||
xenUnifiedDomainAttachDevice (virDomainPtr dom, char *xml)
|
xenUnifiedDomainAttachDevice (virDomainPtr dom, char *xml)
|
||||||
{
|
{
|
||||||
|
GET_PRIVATE(dom->conn);
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; i < nb_drivers; ++i)
|
for (i = 0; i < XEN_UNIFIED_NR_DRIVERS; ++i)
|
||||||
if (drivers[i]->domainAttachDevice &&
|
if (priv->opened[i] && drivers[i]->domainAttachDevice &&
|
||||||
drivers[i]->domainAttachDevice (dom, xml) == 0)
|
drivers[i]->domainAttachDevice (dom, xml) == 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
@ -674,10 +731,11 @@ xenUnifiedDomainAttachDevice (virDomainPtr dom, char *xml)
|
|||||||
static int
|
static int
|
||||||
xenUnifiedDomainDetachDevice (virDomainPtr dom, char *xml)
|
xenUnifiedDomainDetachDevice (virDomainPtr dom, char *xml)
|
||||||
{
|
{
|
||||||
|
GET_PRIVATE(dom->conn);
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; i < nb_drivers; ++i)
|
for (i = 0; i < XEN_UNIFIED_NR_DRIVERS; ++i)
|
||||||
if (drivers[i]->domainDetachDevice &&
|
if (priv->opened[i] && drivers[i]->domainDetachDevice &&
|
||||||
drivers[i]->domainDetachDevice (dom, xml) == 0)
|
drivers[i]->domainDetachDevice (dom, xml) == 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
@ -687,10 +745,11 @@ xenUnifiedDomainDetachDevice (virDomainPtr dom, char *xml)
|
|||||||
static int
|
static int
|
||||||
xenUnifiedDomainGetAutostart (virDomainPtr dom, int *autostart)
|
xenUnifiedDomainGetAutostart (virDomainPtr dom, int *autostart)
|
||||||
{
|
{
|
||||||
|
GET_PRIVATE(dom->conn);
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; i < nb_drivers; ++i)
|
for (i = 0; i < XEN_UNIFIED_NR_DRIVERS; ++i)
|
||||||
if (drivers[i]->domainGetAutostart &&
|
if (priv->opened[i] && drivers[i]->domainGetAutostart &&
|
||||||
drivers[i]->domainGetAutostart (dom, autostart) == 0)
|
drivers[i]->domainGetAutostart (dom, autostart) == 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
@ -700,10 +759,11 @@ xenUnifiedDomainGetAutostart (virDomainPtr dom, int *autostart)
|
|||||||
static int
|
static int
|
||||||
xenUnifiedDomainSetAutostart (virDomainPtr dom, int autostart)
|
xenUnifiedDomainSetAutostart (virDomainPtr dom, int autostart)
|
||||||
{
|
{
|
||||||
|
GET_PRIVATE(dom->conn);
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; i < nb_drivers; ++i)
|
for (i = 0; i < XEN_UNIFIED_NR_DRIVERS; ++i)
|
||||||
if (drivers[i]->domainSetAutostart &&
|
if (priv->opened[i] && drivers[i]->domainSetAutostart &&
|
||||||
drivers[i]->domainSetAutostart (dom, autostart) == 0)
|
drivers[i]->domainSetAutostart (dom, autostart) == 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
@ -19,6 +19,8 @@ extern "C" {
|
|||||||
|
|
||||||
extern int xenUnifiedRegister (void);
|
extern int xenUnifiedRegister (void);
|
||||||
|
|
||||||
|
#define XEN_UNIFIED_NR_DRIVERS 5
|
||||||
|
|
||||||
/* xenUnifiedPrivatePtr:
|
/* xenUnifiedPrivatePtr:
|
||||||
*
|
*
|
||||||
* Per-connection private data, stored in conn->privateData. All Xen
|
* Per-connection private data, stored in conn->privateData. All Xen
|
||||||
@ -42,6 +44,12 @@ struct _xenUnifiedPrivate {
|
|||||||
#endif /* WITH_XEN */
|
#endif /* WITH_XEN */
|
||||||
|
|
||||||
int proxy; /* fd of proxy. */
|
int proxy; /* fd of proxy. */
|
||||||
|
|
||||||
|
/* Keep track of the drivers which opened. We keep a yes/no flag
|
||||||
|
* here for each driver, corresponding to the array drivers in
|
||||||
|
* xen_unified.c.
|
||||||
|
*/
|
||||||
|
int opened[XEN_UNIFIED_NR_DRIVERS];
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct _xenUnifiedPrivate *xenUnifiedPrivatePtr;
|
typedef struct _xenUnifiedPrivate *xenUnifiedPrivatePtr;
|
||||||
|
Loading…
Reference in New Issue
Block a user