diff --git a/src/xen/xen_driver.c b/src/xen/xen_driver.c index ee387676b59d53ddb519569c447666f814a9ba61..64b7c26b9eaa44937869533a017bf3c0a7fb7477 100644 --- a/src/xen/xen_driver.c +++ b/src/xen/xen_driver.c @@ -84,7 +84,6 @@ xenUnifiedDomainGetVcpus(virDomainPtr dom, static struct xenUnifiedDriver const * const drivers[XEN_UNIFIED_NR_DRIVERS] = { [XEN_UNIFIED_HYPERVISOR_OFFSET] = &xenHypervisorDriver, [XEN_UNIFIED_XEND_OFFSET] = &xenDaemonDriver, - [XEN_UNIFIED_XS_OFFSET] = &xenStoreDriver, [XEN_UNIFIED_XM_OFFSET] = &xenXMDriver, }; @@ -853,15 +852,15 @@ static int xenUnifiedDomainGetInfo(virDomainPtr dom, virDomainInfoPtr info) { xenUnifiedPrivatePtr priv = dom->conn->privateData; - int i; - - for (i = 0; i < XEN_UNIFIED_NR_DRIVERS; ++i) - if (priv->opened[i] && - drivers[i]->xenDomainGetInfo && - drivers[i]->xenDomainGetInfo(dom, info) == 0) - return 0; - return -1; + if (dom->id < 0) { + if (priv->xendConfigVersion < XEND_CONFIG_VERSION_3_0_4) + return xenXMDomainGetInfo(dom, info); + else + return xenDaemonDomainGetInfo(dom, info); + } else { + return xenHypervisorGetDomainInfo(dom, info); + } } static int @@ -871,38 +870,17 @@ xenUnifiedDomainGetState(virDomainPtr dom, unsigned int flags) { xenUnifiedPrivatePtr priv = dom->conn->privateData; - int ret; virCheckFlags(0, -1); - /* trying drivers in the same order as GetInfo for consistent results: - * hypervisor, xend, xs, and xm */ - - if (priv->opened[XEN_UNIFIED_HYPERVISOR_OFFSET]) { - ret = xenHypervisorGetDomainState(dom, state, reason, flags); - if (ret >= 0) - return ret; - } - - if (priv->opened[XEN_UNIFIED_XEND_OFFSET]) { - ret = xenDaemonDomainGetState(dom, state, reason, flags); - if (ret >= 0) - return ret; - } - - if (priv->opened[XEN_UNIFIED_XS_OFFSET]) { - ret = xenStoreDomainGetState(dom, state, reason, flags); - if (ret >= 0) - return ret; - } - - if (priv->opened[XEN_UNIFIED_XM_OFFSET]) { - ret = xenXMDomainGetState(dom, state, reason, flags); - if (ret >= 0) - return ret; + if (dom->id < 0) { + if (priv->xendConfigVersion < XEND_CONFIG_VERSION_3_0_4) + return xenXMDomainGetState(dom, state, reason); + else + return xenDaemonDomainGetState(dom, state, reason); + } else { + return xenHypervisorGetDomainState(dom, state, reason); } - - return -1; } static int diff --git a/src/xen/xen_driver.h b/src/xen/xen_driver.h index 4509161da5a6e43a8211bb32ae015b7d40bb91c1..953da6467742666e7d0f0b06fb7cbde5c9867b4c 100644 --- a/src/xen/xen_driver.h +++ b/src/xen/xen_driver.h @@ -93,7 +93,6 @@ extern int xenRegister (void); * structure with direct calls in xen_unified.c. */ struct xenUnifiedDriver { - virDrvDomainGetInfo xenDomainGetInfo; virDrvDomainPinVcpu xenDomainPinVcpu; virDrvDomainGetVcpus xenDomainGetVcpus; virDrvConnectListDefinedDomains xenListDefinedDomains; diff --git a/src/xen/xen_hypervisor.c b/src/xen/xen_hypervisor.c index 38f0e55b53d10497065ff283c6542fe1b61f5184..3703945cadfb3f5c5546d8d042c7a58fc03d5d4a 100644 --- a/src/xen/xen_hypervisor.c +++ b/src/xen/xen_hypervisor.c @@ -871,7 +871,6 @@ typedef struct xen_op_v2_dom xen_op_v2_dom; #endif struct xenUnifiedDriver xenHypervisorDriver = { - .xenDomainGetInfo = xenHypervisorGetDomainInfo, .xenDomainPinVcpu = xenHypervisorPinVcpu, .xenDomainGetVcpus = xenHypervisorGetVcpus, .xenDomainGetSchedulerType = xenHypervisorGetSchedulerType, @@ -2880,11 +2879,7 @@ xenHypervisorGetDomInfo(virConnectPtr conn, int id, virDomainInfoPtr info) int xenHypervisorGetDomainInfo(virDomainPtr domain, virDomainInfoPtr info) { - if (domain->id < 0) - return -1; - return xenHypervisorGetDomInfo(domain->conn, domain->id, info); - } /** @@ -2892,7 +2887,6 @@ xenHypervisorGetDomainInfo(virDomainPtr domain, virDomainInfoPtr info) * @domain: pointer to the domain block * @state: returned state of the domain * @reason: returned reason for the state - * @flags: additional flags, 0 for now * * Do a hypervisor call to get the related set of domain information. * @@ -2901,16 +2895,10 @@ xenHypervisorGetDomainInfo(virDomainPtr domain, virDomainInfoPtr info) int xenHypervisorGetDomainState(virDomainPtr domain, int *state, - int *reason, - unsigned int flags) + int *reason) { virDomainInfo info; - virCheckFlags(0, -1); - - if (domain->id < 0) - return -1; - if (xenHypervisorGetDomInfo(domain->conn, domain->id, &info) < 0) return -1; diff --git a/src/xen/xen_hypervisor.h b/src/xen/xen_hypervisor.h index 9748cf8b280b2032545b620564d80ef5576fa173..b36fcca92a996b2c05d3f4458743279250d2235c 100644 --- a/src/xen/xen_hypervisor.h +++ b/src/xen/xen_hypervisor.h @@ -76,8 +76,7 @@ int xenHypervisorGetDomainInfo (virDomainPtr domain, ATTRIBUTE_NONNULL (1); int xenHypervisorGetDomainState (virDomainPtr domain, int *state, - int *reason, - unsigned int flags) + int *reason) ATTRIBUTE_NONNULL (1); int xenHypervisorGetDomInfo (virConnectPtr conn, int id, diff --git a/src/xen/xend_internal.c b/src/xen/xend_internal.c index b4f4a926959e7f2fc19c8b6c9f9ccee992953ca0..d7dc8f18c12ea8ba7e09107e81fa3e79bd9aa48d 100644 --- a/src/xen/xend_internal.c +++ b/src/xen/xend_internal.c @@ -1648,10 +1648,6 @@ xenDaemonDomainGetInfo(virDomainPtr domain, virDomainInfoPtr info) { struct sexpr *root; int ret; - xenUnifiedPrivatePtr priv = domain->conn->privateData; - - if (domain->id < 0 && priv->xendConfigVersion < XEND_CONFIG_VERSION_3_0_4) - return -1; root = sexpr_get(domain->conn, "/xend/domain/%s?detail=1", domain->name); if (root == NULL) @@ -1668,7 +1664,6 @@ xenDaemonDomainGetInfo(virDomainPtr domain, virDomainInfoPtr info) * @domain: a domain object * @state: returned domain's state * @reason: returned reason for the state - * @flags: additional flags, 0 for now * * This method looks up domain state and reason. * @@ -1677,17 +1672,10 @@ xenDaemonDomainGetInfo(virDomainPtr domain, virDomainInfoPtr info) int xenDaemonDomainGetState(virDomainPtr domain, int *state, - int *reason, - unsigned int flags) + int *reason) { - xenUnifiedPrivatePtr priv = domain->conn->privateData; struct sexpr *root; - virCheckFlags(0, -1); - - if (domain->id < 0 && priv->xendConfigVersion < XEND_CONFIG_VERSION_3_0_4) - return -1; - root = sexpr_get(domain->conn, "/xend/domain/%s?detail=1", domain->name); if (!root) return -1; @@ -3425,7 +3413,6 @@ xenDaemonDomainBlockPeek(virDomainPtr domain, } struct xenUnifiedDriver xenDaemonDriver = { - .xenDomainGetInfo = xenDaemonDomainGetInfo, .xenDomainPinVcpu = xenDaemonDomainPinVcpu, .xenDomainGetVcpus = xenDaemonDomainGetVcpus, .xenListDefinedDomains = xenDaemonListDefinedDomains, diff --git a/src/xen/xend_internal.h b/src/xen/xend_internal.h index 9681068203b989417605f998db54c51ac6dde0f9..fd661c9cdd60616e3797466c12b4f19ac844a095 100644 --- a/src/xen/xend_internal.h +++ b/src/xen/xend_internal.h @@ -101,8 +101,7 @@ int xenDaemonDomainSetMaxMemory(virDomainPtr domain, unsigned long memory); int xenDaemonDomainGetInfo(virDomainPtr domain, virDomainInfoPtr info); int xenDaemonDomainGetState(virDomainPtr domain, int *state, - int *reason, - unsigned int flags); + int *reason); char *xenDaemonDomainGetXMLDesc(virDomainPtr domain, unsigned int flags, const char *cpus); unsigned long long xenDaemonDomainGetMaxMemory(virDomainPtr domain); diff --git a/src/xen/xm_internal.c b/src/xen/xm_internal.c index f37b0e60dad25c0c82e67e8d43ca5ad8f90217bb..f2349b21015dd81227ba54743c2dcd7d7f775cc8 100644 --- a/src/xen/xm_internal.c +++ b/src/xen/xm_internal.c @@ -81,7 +81,6 @@ static int xenXMDomainDetachDeviceFlags(virDomainPtr domain, const char *xml, #define XM_XML_ERROR "Invalid xml" struct xenUnifiedDriver xenXMDriver = { - .xenDomainGetInfo = xenXMDomainGetInfo, .xenDomainPinVcpu = xenXMDomainPinVcpu, .xenListDefinedDomains = xenXMListDefinedDomains, .xenNumOfDefinedDomains = xenXMNumOfDefinedDomains, @@ -462,15 +461,10 @@ xenXMClose(virConnectPtr conn) * Since these are all offline domains, the state is always SHUTOFF. */ int -xenXMDomainGetState(virDomainPtr domain, - int *state, int *reason, - unsigned int flags) +xenXMDomainGetState(virDomainPtr domain ATTRIBUTE_UNUSED, + int *state, + int *reason) { - virCheckFlags(0, -1); - - if (domain->id != -1) - return -1; - *state = VIR_DOMAIN_SHUTOFF; if (reason) *reason = 0; @@ -490,9 +484,6 @@ xenXMDomainGetInfo(virDomainPtr domain, virDomainInfoPtr info) const char *filename; xenXMConfCachePtr entry; - if (domain->id != -1) - return -1; - xenUnifiedLock(priv); if (!(filename = virHashLookup(priv->nameConfigMap, domain->name))) diff --git a/src/xen/xm_internal.h b/src/xen/xm_internal.h index 3f3bd5172a8c0d0e4ebbf55679bce0b78fc9abcb..2a5d8684e081430a518eaaee56e7c65876ae97f8 100644 --- a/src/xen/xm_internal.h +++ b/src/xen/xm_internal.h @@ -42,8 +42,7 @@ const char *xenXMGetType(virConnectPtr conn); int xenXMDomainGetInfo(virDomainPtr domain, virDomainInfoPtr info); int xenXMDomainGetState(virDomainPtr domain, int *state, - int *reason, - unsigned int flags); + int *reason); char *xenXMDomainGetXMLDesc(virDomainPtr domain, unsigned int flags); int xenXMDomainSetMemory(virDomainPtr domain, unsigned long memory); int xenXMDomainSetMaxMemory(virDomainPtr domain, unsigned long memory); diff --git a/src/xen/xs_internal.c b/src/xen/xs_internal.c index dd1f2a065be9d18cd152aace24eb1df9e0deb1a2..496c30bd745fc7bf3c28f8279f2616b527141544 100644 --- a/src/xen/xs_internal.c +++ b/src/xen/xs_internal.c @@ -56,32 +56,11 @@ static void xenStoreWatchEvent(int watch, int fd, int events, void *data); static void xenStoreWatchListFree(xenStoreWatchListPtr list); -struct xenUnifiedDriver xenStoreDriver = { - .xenDomainGetInfo = xenStoreGetDomainInfo, -}; - /************************************************************************ * * * Helper internal APIs * * * ************************************************************************/ -/** - * virConnectDoStoreList: - * @conn: pointer to the hypervisor connection - * @path: the absolute path of the directory in the store to list - * @nb: OUT pointer to the number of items found - * - * Internal API querying the Xenstore for a list - * - * Returns a string which must be freed by the caller or NULL in case of error - */ -static char ** -virConnectDoStoreList(virConnectPtr conn, const char *path, unsigned int *nb) -{ - xenUnifiedPrivatePtr priv = conn->privateData; - - return xs_directory(priv->xshandle, 0, path, nb); -} /** * virDomainDoStoreQuery: @@ -234,100 +213,6 @@ xenStoreClose(virConnectPtr conn) return 0; } -/** - * xenStoreGetDomainInfo: - * @domain: pointer to the domain block - * @info: the place where information should be stored - * - * Do a hypervisor call to get the related set of domain information. - * - * Returns 0 in case of success, -1 in case of error. - */ -int -xenStoreGetDomainInfo(virDomainPtr domain, virDomainInfoPtr info) -{ - char *tmp, **tmp2; - unsigned int nb_vcpus; - char request[200]; - xenUnifiedPrivatePtr priv = domain->conn->privateData; - - if (priv->xshandle == NULL || domain->id == -1) - return -1; - - tmp = virDomainDoStoreQuery(domain->conn, domain->id, "running"); - if (tmp != NULL) { - if (tmp[0] == '1') - info->state = VIR_DOMAIN_RUNNING; - VIR_FREE(tmp); - } else { - info->state = VIR_DOMAIN_NOSTATE; - } - tmp = virDomainDoStoreQuery(domain->conn, domain->id, "memory/target"); - if (tmp != NULL) { - info->memory = atol(tmp); - info->maxMem = atol(tmp); - VIR_FREE(tmp); - } else { - info->memory = 0; - info->maxMem = 0; - } -#if 0 - /* doesn't seems to work */ - tmp = virDomainDoStoreQuery(domain->conn, domain->id, "cpu_time"); - if (tmp != NULL) { - info->cpuTime = atol(tmp); - VIR_FREE(tmp); - } else { - info->cpuTime = 0; - } -#endif - snprintf(request, 199, "/local/domain/%d/cpu", domain->id); - request[199] = 0; - tmp2 = virConnectDoStoreList(domain->conn, request, &nb_vcpus); - if (tmp2 != NULL) { - info->nrVirtCpu = nb_vcpus; - VIR_FREE(tmp2); - } - return 0; -} - -/** - * xenStoreDomainGetState: - * @domain: pointer to the domain block - * @state: returned domain's state - * @reason: returned state reason - * @flags: additional flags, 0 for now - * - * Returns 0 in case of success, -1 in case of error. - */ -int -xenStoreDomainGetState(virDomainPtr domain, - int *state, - int *reason, - unsigned int flags) -{ - char *running; - - virCheckFlags(0, -1); - - if (domain->id == -1) - return -1; - - running = virDomainDoStoreQuery(domain->conn, domain->id, "running"); - - if (running && *running == '1') - *state = VIR_DOMAIN_RUNNING; - else - *state = VIR_DOMAIN_NOSTATE; - if (reason) - *reason = 0; - - VIR_FREE(running); - - return 0; -} - - /** * xenStoreNumOfDomains: * @conn: pointer to the hypervisor connection diff --git a/src/xen/xs_internal.h b/src/xen/xs_internal.h index 439073339355575119fce5d852fb7600365c8d69..bc5bd8c6b73c8a40bc187e769798632b14dea383 100644 --- a/src/xen/xs_internal.h +++ b/src/xen/xs_internal.h @@ -26,19 +26,10 @@ # include "internal.h" # include "driver.h" -extern struct xenUnifiedDriver xenStoreDriver; -int xenStoreInit (void); - int xenStoreOpen (virConnectPtr conn, virConnectAuthPtr auth, unsigned int flags); int xenStoreClose (virConnectPtr conn); -int xenStoreGetDomainInfo (virDomainPtr domain, - virDomainInfoPtr info); -int xenStoreDomainGetState (virDomainPtr domain, - int *state, - int *reason, - unsigned int flags); int xenStoreNumOfDomains (virConnectPtr conn); int xenStoreListDomains (virConnectPtr conn, int *ids,