Xen: xen_driver: remove use of XEND_CONFIG_VERSION

Remove use of XEND_CONFIG_VERSION_* in the Xen unified driver.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
This commit is contained in:
Jim Fehlig 2015-12-04 14:06:10 -07:00
parent 5ff2e370af
commit 64d14daa4b
1 changed files with 65 additions and 229 deletions

View File

@ -109,16 +109,10 @@ static virDomainDefPtr xenGetDomainDefForID(virConnectPtr conn, int id)
static virDomainDefPtr xenGetDomainDefForName(virConnectPtr conn, const char *name) static virDomainDefPtr xenGetDomainDefForName(virConnectPtr conn, const char *name)
{ {
xenUnifiedPrivatePtr priv = conn->privateData;
virDomainDefPtr ret; virDomainDefPtr ret;
ret = xenDaemonLookupByName(conn, name); ret = xenDaemonLookupByName(conn, name);
/* Try XM for inactive domains. */
if (!ret &&
priv->xendConfigVersion <= XEND_CONFIG_VERSION_3_0_3)
ret = xenXMDomainLookupByName(conn, name);
if (!ret && virGetLastError() == NULL) if (!ret && virGetLastError() == NULL)
virReportError(VIR_ERR_NO_DOMAIN, __FUNCTION__); virReportError(VIR_ERR_NO_DOMAIN, __FUNCTION__);
@ -128,18 +122,13 @@ static virDomainDefPtr xenGetDomainDefForName(virConnectPtr conn, const char *na
static virDomainDefPtr xenGetDomainDefForUUID(virConnectPtr conn, const unsigned char *uuid) static virDomainDefPtr xenGetDomainDefForUUID(virConnectPtr conn, const unsigned char *uuid)
{ {
xenUnifiedPrivatePtr priv = conn->privateData;
virDomainDefPtr ret; virDomainDefPtr ret;
ret = xenHypervisorLookupDomainByUUID(conn, uuid); ret = xenHypervisorLookupDomainByUUID(conn, uuid);
/* Try XM for inactive domains. */ /* Try xend for inactive domains. */
if (!ret) { if (!ret)
if (priv->xendConfigVersion <= XEND_CONFIG_VERSION_3_0_3) ret = xenDaemonLookupByUUID(conn, uuid);
ret = xenXMDomainLookupByUUID(conn, uuid);
else
ret = xenDaemonLookupByUUID(conn, uuid);
}
if (!ret && virGetLastError() == NULL) if (!ret && virGetLastError() == NULL)
virReportError(VIR_ERR_NO_DOMAIN, __FUNCTION__); virReportError(VIR_ERR_NO_DOMAIN, __FUNCTION__);
@ -516,15 +505,6 @@ xenUnifiedConnectOpen(virConnectPtr conn, virConnectAuthPtr auth, unsigned int f
VIR_DEBUG("Activated XenD sub-driver"); VIR_DEBUG("Activated XenD sub-driver");
priv->opened[XEN_UNIFIED_XEND_OFFSET] = 1; priv->opened[XEN_UNIFIED_XEND_OFFSET] = 1;
/* For old XenD, the XM driver is required to succeed */
if (priv->xendConfigVersion <= XEND_CONFIG_VERSION_3_0_3) {
VIR_DEBUG("Trying XM sub-driver");
if (xenXMOpen(conn, auth, flags) < 0)
goto error;
VIR_DEBUG("Activated XM sub-driver");
priv->opened[XEN_UNIFIED_XM_OFFSET] = 1;
}
VIR_DEBUG("Trying XS sub-driver"); VIR_DEBUG("Trying XS sub-driver");
if (xenStoreOpen(conn, auth, flags) < 0) if (xenStoreOpen(conn, auth, flags) < 0)
goto error; goto error;
@ -1055,7 +1035,6 @@ xenUnifiedDomainDestroy(virDomainPtr dom)
static char * static char *
xenUnifiedDomainGetOSType(virDomainPtr dom) xenUnifiedDomainGetOSType(virDomainPtr dom)
{ {
xenUnifiedPrivatePtr priv = dom->conn->privateData;
char *ret = NULL; char *ret = NULL;
virDomainDefPtr def; virDomainDefPtr def;
@ -1065,17 +1044,10 @@ xenUnifiedDomainGetOSType(virDomainPtr dom)
if (virDomainGetOSTypeEnsureACL(dom->conn, def) < 0) if (virDomainGetOSTypeEnsureACL(dom->conn, def) < 0)
goto cleanup; goto cleanup;
if (def->id < 0) { if (def->id < 0)
if (priv->xendConfigVersion < XEND_CONFIG_VERSION_3_0_4) { ret = xenDaemonDomainGetOSType(dom->conn, def);
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", else
_("Unable to query OS type for inactive domain"));
return NULL;
} else {
ret = xenDaemonDomainGetOSType(dom->conn, def);
}
} else {
ret = xenHypervisorDomainGetOSType(dom->conn, def); ret = xenHypervisorDomainGetOSType(dom->conn, def);
}
cleanup: cleanup:
virDomainDefFree(def); virDomainDefFree(def);
@ -1086,7 +1058,6 @@ xenUnifiedDomainGetOSType(virDomainPtr dom)
static unsigned long long static unsigned long long
xenUnifiedDomainGetMaxMemory(virDomainPtr dom) xenUnifiedDomainGetMaxMemory(virDomainPtr dom)
{ {
xenUnifiedPrivatePtr priv = dom->conn->privateData;
unsigned long long ret = 0; unsigned long long ret = 0;
virDomainDefPtr def; virDomainDefPtr def;
@ -1096,14 +1067,10 @@ xenUnifiedDomainGetMaxMemory(virDomainPtr dom)
if (virDomainGetMaxMemoryEnsureACL(dom->conn, def) < 0) if (virDomainGetMaxMemoryEnsureACL(dom->conn, def) < 0)
goto cleanup; goto cleanup;
if (def->id < 0) { if (def->id < 0)
if (priv->xendConfigVersion < XEND_CONFIG_VERSION_3_0_4) ret = xenDaemonDomainGetMaxMemory(dom->conn, def);
ret = xenXMDomainGetMaxMemory(dom->conn, def); else
else
ret = xenDaemonDomainGetMaxMemory(dom->conn, def);
} else {
ret = xenHypervisorGetMaxMemory(dom->conn, def); ret = xenHypervisorGetMaxMemory(dom->conn, def);
}
cleanup: cleanup:
virDomainDefFree(def); virDomainDefFree(def);
@ -1113,7 +1080,6 @@ xenUnifiedDomainGetMaxMemory(virDomainPtr dom)
static int static int
xenUnifiedDomainSetMaxMemory(virDomainPtr dom, unsigned long memory) xenUnifiedDomainSetMaxMemory(virDomainPtr dom, unsigned long memory)
{ {
xenUnifiedPrivatePtr priv = dom->conn->privateData;
int ret = -1; int ret = -1;
virDomainDefPtr def; virDomainDefPtr def;
@ -1123,14 +1089,10 @@ xenUnifiedDomainSetMaxMemory(virDomainPtr dom, unsigned long memory)
if (virDomainSetMaxMemoryEnsureACL(dom->conn, def) < 0) if (virDomainSetMaxMemoryEnsureACL(dom->conn, def) < 0)
goto cleanup; goto cleanup;
if (def->id < 0) { if (def->id < 0)
if (priv->xendConfigVersion < XEND_CONFIG_VERSION_3_0_4) ret = xenDaemonDomainSetMaxMemory(dom->conn, def, memory);
ret = xenXMDomainSetMaxMemory(dom->conn, def, memory); else
else
ret = xenDaemonDomainSetMaxMemory(dom->conn, def, memory);
} else {
ret = xenHypervisorSetMaxMemory(dom->conn, def, memory); ret = xenHypervisorSetMaxMemory(dom->conn, def, memory);
}
cleanup: cleanup:
virDomainDefFree(def); virDomainDefFree(def);
@ -1140,7 +1102,6 @@ xenUnifiedDomainSetMaxMemory(virDomainPtr dom, unsigned long memory)
static int static int
xenUnifiedDomainSetMemory(virDomainPtr dom, unsigned long memory) xenUnifiedDomainSetMemory(virDomainPtr dom, unsigned long memory)
{ {
xenUnifiedPrivatePtr priv = dom->conn->privateData;
int ret = -1; int ret = -1;
virDomainDefPtr def; virDomainDefPtr def;
@ -1150,10 +1111,7 @@ xenUnifiedDomainSetMemory(virDomainPtr dom, unsigned long memory)
if (virDomainSetMemoryEnsureACL(dom->conn, def) < 0) if (virDomainSetMemoryEnsureACL(dom->conn, def) < 0)
goto cleanup; goto cleanup;
if (def->id < 0 && priv->xendConfigVersion < XEND_CONFIG_VERSION_3_0_4) ret = xenDaemonDomainSetMemory(dom->conn, def, memory);
ret = xenXMDomainSetMemory(dom->conn, def, memory);
else
ret = xenDaemonDomainSetMemory(dom->conn, def, memory);
cleanup: cleanup:
virDomainDefFree(def); virDomainDefFree(def);
@ -1163,7 +1121,6 @@ xenUnifiedDomainSetMemory(virDomainPtr dom, unsigned long memory)
static int static int
xenUnifiedDomainGetInfo(virDomainPtr dom, virDomainInfoPtr info) xenUnifiedDomainGetInfo(virDomainPtr dom, virDomainInfoPtr info)
{ {
xenUnifiedPrivatePtr priv = dom->conn->privateData;
int ret = -1; int ret = -1;
virDomainDefPtr def; virDomainDefPtr def;
@ -1173,14 +1130,10 @@ xenUnifiedDomainGetInfo(virDomainPtr dom, virDomainInfoPtr info)
if (virDomainGetInfoEnsureACL(dom->conn, def) < 0) if (virDomainGetInfoEnsureACL(dom->conn, def) < 0)
goto cleanup; goto cleanup;
if (def->id < 0) { if (def->id < 0)
if (priv->xendConfigVersion < XEND_CONFIG_VERSION_3_0_4) ret = xenDaemonDomainGetInfo(dom->conn, def, info);
ret = xenXMDomainGetInfo(dom->conn, def, info); else
else
ret = xenDaemonDomainGetInfo(dom->conn, def, info);
} else {
ret = xenHypervisorGetDomainInfo(dom->conn, def, info); ret = xenHypervisorGetDomainInfo(dom->conn, def, info);
}
cleanup: cleanup:
virDomainDefFree(def); virDomainDefFree(def);
@ -1193,7 +1146,7 @@ xenUnifiedDomainGetState(virDomainPtr dom,
int *reason, int *reason,
unsigned int flags) unsigned int flags)
{ {
xenUnifiedPrivatePtr priv = dom->conn->privateData;
int ret = -1; int ret = -1;
virDomainDefPtr def; virDomainDefPtr def;
@ -1205,14 +1158,10 @@ xenUnifiedDomainGetState(virDomainPtr dom,
if (virDomainGetStateEnsureACL(dom->conn, def) < 0) if (virDomainGetStateEnsureACL(dom->conn, def) < 0)
goto cleanup; goto cleanup;
if (def->id < 0) { if (def->id < 0)
if (priv->xendConfigVersion < XEND_CONFIG_VERSION_3_0_4) ret = xenDaemonDomainGetState(dom->conn, def, state, reason);
ret = xenXMDomainGetState(dom->conn, def, state, reason); else
else
ret = xenDaemonDomainGetState(dom->conn, def, state, reason);
} else {
ret = xenHypervisorGetDomainState(dom->conn, def, state, reason); ret = xenHypervisorGetDomainState(dom->conn, def, state, reason);
}
cleanup: cleanup:
virDomainDefFree(def); virDomainDefFree(def);
@ -1391,7 +1340,6 @@ static int
xenUnifiedDomainSetVcpusFlags(virDomainPtr dom, unsigned int nvcpus, xenUnifiedDomainSetVcpusFlags(virDomainPtr dom, unsigned int nvcpus,
unsigned int flags) unsigned int flags)
{ {
xenUnifiedPrivatePtr priv = dom->conn->privateData;
virDomainDefPtr def = NULL; virDomainDefPtr def = NULL;
int ret = -1; int ret = -1;
@ -1420,13 +1368,7 @@ xenUnifiedDomainSetVcpusFlags(virDomainPtr dom, unsigned int nvcpus,
if (virDomainSetVcpusFlagsEnsureACL(dom->conn, def, flags) < 0) if (virDomainSetVcpusFlagsEnsureACL(dom->conn, def, flags) < 0)
goto cleanup; goto cleanup;
/* Try non-hypervisor methods first, then hypervisor direct method ret = xenDaemonDomainSetVcpusFlags(dom->conn, def, nvcpus, flags);
* as a last resort.
*/
if (dom->id < 0 && priv->xendConfigVersion < XEND_CONFIG_VERSION_3_0_4)
ret = xenXMDomainSetVcpusFlags(dom->conn, def, nvcpus, flags);
else
ret = xenDaemonDomainSetVcpusFlags(dom->conn, def, nvcpus, flags);
cleanup: cleanup:
virDomainDefFree(def); virDomainDefFree(def);
@ -1436,14 +1378,12 @@ xenUnifiedDomainSetVcpusFlags(virDomainPtr dom, unsigned int nvcpus,
static int static int
xenUnifiedDomainSetVcpus(virDomainPtr dom, unsigned int nvcpus) xenUnifiedDomainSetVcpus(virDomainPtr dom, unsigned int nvcpus)
{ {
xenUnifiedPrivatePtr priv = dom->conn->privateData; unsigned int flags;
unsigned int flags = VIR_DOMAIN_VCPU_LIVE;
/* Per the documented API, it is hypervisor-dependent whether this /* Per the documented API, it is hypervisor-dependent whether this
* affects just _LIVE or _LIVE|_CONFIG; in xen's case, that * affects just _LIVE or _LIVE|_CONFIG; in xen's case, both are
* depends on xendConfigVersion. */ * affected. */
if (priv->xendConfigVersion >= XEND_CONFIG_VERSION_3_0_4) flags = VIR_DOMAIN_VCPU_LIVE | VIR_DOMAIN_VCPU_CONFIG;
flags |= VIR_DOMAIN_VCPU_CONFIG;
return xenUnifiedDomainSetVcpusFlags(dom, nvcpus, flags); return xenUnifiedDomainSetVcpusFlags(dom, nvcpus, flags);
} }
@ -1452,7 +1392,6 @@ static int
xenUnifiedDomainPinVcpu(virDomainPtr dom, unsigned int vcpu, xenUnifiedDomainPinVcpu(virDomainPtr dom, unsigned int vcpu,
unsigned char *cpumap, int maplen) unsigned char *cpumap, int maplen)
{ {
xenUnifiedPrivatePtr priv = dom->conn->privateData;
virDomainDefPtr def = NULL; virDomainDefPtr def = NULL;
int ret = -1; int ret = -1;
@ -1462,14 +1401,10 @@ xenUnifiedDomainPinVcpu(virDomainPtr dom, unsigned int vcpu,
if (virDomainPinVcpuEnsureACL(dom->conn, def) < 0) if (virDomainPinVcpuEnsureACL(dom->conn, def) < 0)
goto cleanup; goto cleanup;
if (dom->id < 0) { if (dom->id < 0)
if (priv->xendConfigVersion < XEND_CONFIG_VERSION_3_0_4) ret = xenDaemonDomainPinVcpu(dom->conn, def, vcpu, cpumap, maplen);
ret = xenXMDomainPinVcpu(dom->conn, def, vcpu, cpumap, maplen); else
else
ret = xenDaemonDomainPinVcpu(dom->conn, def, vcpu, cpumap, maplen);
} else {
ret = xenHypervisorPinVcpu(dom->conn, def, vcpu, cpumap, maplen); ret = xenHypervisorPinVcpu(dom->conn, def, vcpu, cpumap, maplen);
}
cleanup: cleanup:
virDomainDefFree(def); virDomainDefFree(def);
@ -1484,17 +1419,11 @@ xenUnifiedDomainGetVcpusInternal(virDomainPtr dom,
unsigned char *cpumaps, unsigned char *cpumaps,
int maplen) int maplen)
{ {
xenUnifiedPrivatePtr priv = dom->conn->privateData;
int ret = -1; int ret = -1;
if (dom->id < 0) { if (dom->id < 0) {
if (priv->xendConfigVersion < XEND_CONFIG_VERSION_3_0_4) { ret = xenDaemonDomainGetVcpus(dom->conn, def, info, maxinfo,
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", cpumaps, maplen);
_("Cannot get VCPUs of inactive domain"));
} else {
ret = xenDaemonDomainGetVcpus(dom->conn, def, info, maxinfo,
cpumaps, maplen);
}
} else { } else {
ret = xenHypervisorGetVcpus(dom->conn, def, info, maxinfo, cpumaps, ret = xenHypervisorGetVcpus(dom->conn, def, info, maxinfo, cpumaps,
maplen); maplen);
@ -1530,14 +1459,10 @@ xenUnifiedDomainGetVcpusFlagsInternal(virDomainPtr dom,
virDomainDefPtr def, virDomainDefPtr def,
unsigned int flags) unsigned int flags)
{ {
xenUnifiedPrivatePtr priv = dom->conn->privateData;
int ret = -1; int ret = -1;
if (dom->id < 0) { if (dom->id < 0) {
if (priv->xendConfigVersion < XEND_CONFIG_VERSION_3_0_4) ret = xenDaemonDomainGetVcpusFlags(dom->conn, def, flags);
ret = xenXMDomainGetVcpusFlags(dom->conn, def, flags);
else
ret = xenDaemonDomainGetVcpusFlags(dom->conn, def, flags);
} else { } else {
if (flags == (VIR_DOMAIN_VCPU_CONFIG | VIR_DOMAIN_VCPU_MAXIMUM)) if (flags == (VIR_DOMAIN_VCPU_CONFIG | VIR_DOMAIN_VCPU_MAXIMUM))
ret = xenHypervisorGetVcpuMax(dom->conn, def); ret = xenHypervisorGetVcpuMax(dom->conn, def);
@ -1585,6 +1510,7 @@ xenUnifiedDomainGetXMLDesc(virDomainPtr dom, unsigned int flags)
virDomainDefPtr minidef = NULL; virDomainDefPtr minidef = NULL;
virDomainDefPtr def = NULL; virDomainDefPtr def = NULL;
char *ret = NULL; char *ret = NULL;
char *cpus = NULL;
if (!(minidef = xenGetDomainDefForDom(dom))) if (!(minidef = xenGetDomainDefForDom(dom)))
goto cleanup; goto cleanup;
@ -1592,22 +1518,17 @@ xenUnifiedDomainGetXMLDesc(virDomainPtr dom, unsigned int flags)
if (virDomainGetXMLDescEnsureACL(dom->conn, minidef, flags) < 0) if (virDomainGetXMLDescEnsureACL(dom->conn, minidef, flags) < 0)
goto cleanup; goto cleanup;
if (dom->id < 0 && priv->xendConfigVersion < XEND_CONFIG_VERSION_3_0_4) { xenUnifiedLock(priv);
def = xenXMDomainGetXMLDesc(dom->conn, minidef); cpus = xenDomainUsedCpus(dom, minidef);
} else { xenUnifiedUnlock(priv);
char *cpus; def = xenDaemonDomainGetXMLDesc(dom->conn, minidef, cpus);
xenUnifiedLock(priv);
cpus = xenDomainUsedCpus(dom, minidef);
xenUnifiedUnlock(priv);
def = xenDaemonDomainGetXMLDesc(dom->conn, minidef, cpus);
VIR_FREE(cpus);
}
if (def) if (def)
ret = virDomainDefFormat(def, ret = virDomainDefFormat(def,
virDomainDefFormatConvertXMLFlags(flags)); virDomainDefFormatConvertXMLFlags(flags));
cleanup: cleanup:
VIR_FREE(cpus);
virDomainDefFree(def); virDomainDefFree(def);
virDomainDefFree(minidef); virDomainDefFree(minidef);
return ret; return ret;
@ -1776,7 +1697,6 @@ xenUnifiedDomainMigrateFinish(virConnectPtr dconn,
const char *uri ATTRIBUTE_UNUSED, const char *uri ATTRIBUTE_UNUSED,
unsigned long flags) unsigned long flags)
{ {
xenUnifiedPrivatePtr priv = dconn->privateData;
virDomainPtr ret = NULL; virDomainPtr ret = NULL;
virDomainDefPtr minidef = NULL; virDomainDefPtr minidef = NULL;
virDomainDefPtr def = NULL; virDomainDefPtr def = NULL;
@ -1793,13 +1713,8 @@ xenUnifiedDomainMigrateFinish(virConnectPtr dconn,
if (!(def = xenDaemonDomainGetXMLDesc(dconn, minidef, NULL))) if (!(def = xenDaemonDomainGetXMLDesc(dconn, minidef, NULL)))
goto cleanup; goto cleanup;
if (priv->xendConfigVersion < XEND_CONFIG_VERSION_3_0_4) { if (xenDaemonDomainDefineXML(dconn, def) < 0)
if (xenXMDomainDefineXML(dconn, def) < 0) goto cleanup;
goto cleanup;
} else {
if (xenDaemonDomainDefineXML(dconn, def) < 0)
goto cleanup;
}
} }
ret = virGetDomain(dconn, minidef->name, minidef->uuid); ret = virGetDomain(dconn, minidef->name, minidef->uuid);
@ -1816,31 +1731,19 @@ static int
xenUnifiedConnectListDefinedDomains(virConnectPtr conn, char **const names, xenUnifiedConnectListDefinedDomains(virConnectPtr conn, char **const names,
int maxnames) int maxnames)
{ {
xenUnifiedPrivatePtr priv = conn->privateData;
if (virConnectListDefinedDomainsEnsureACL(conn) < 0) if (virConnectListDefinedDomainsEnsureACL(conn) < 0)
return -1; return -1;
if (priv->xendConfigVersion < XEND_CONFIG_VERSION_3_0_4) { return xenDaemonListDefinedDomains(conn, names, maxnames);
return xenXMListDefinedDomains(conn, names, maxnames);
} else {
return xenDaemonListDefinedDomains(conn, names, maxnames);
}
} }
static int static int
xenUnifiedConnectNumOfDefinedDomains(virConnectPtr conn) xenUnifiedConnectNumOfDefinedDomains(virConnectPtr conn)
{ {
xenUnifiedPrivatePtr priv = conn->privateData;
if (virConnectNumOfDefinedDomainsEnsureACL(conn) < 0) if (virConnectNumOfDefinedDomainsEnsureACL(conn) < 0)
return -1; return -1;
if (priv->xendConfigVersion < XEND_CONFIG_VERSION_3_0_4) { return xenDaemonNumOfDefinedDomains(conn);
return xenXMNumOfDefinedDomains(conn);
} else {
return xenDaemonNumOfDefinedDomains(conn);
}
} }
static int static int
@ -1869,10 +1772,7 @@ xenUnifiedDomainCreateWithFlags(virDomainPtr dom, unsigned int flags)
goto cleanup; goto cleanup;
} }
if (priv->xendConfigVersion < XEND_CONFIG_VERSION_3_0_4) ret = xenDaemonDomainCreate(dom->conn, def);
ret = xenXMDomainCreate(dom->conn, def);
else
ret = xenDaemonDomainCreate(dom->conn, def);
if (ret >= 0) if (ret >= 0)
dom->id = def->id; dom->id = def->id;
@ -1909,16 +1809,9 @@ xenUnifiedDomainDefineXMLFlags(virConnectPtr conn, const char *xml, unsigned int
if (virDomainDefineXMLFlagsEnsureACL(conn, def) < 0) if (virDomainDefineXMLFlagsEnsureACL(conn, def) < 0)
goto cleanup; goto cleanup;
if (priv->xendConfigVersion < XEND_CONFIG_VERSION_3_0_4) { if (xenDaemonDomainDefineXML(conn, def) < 0)
if (xenXMDomainDefineXML(conn, def) < 0) goto cleanup;
goto cleanup; ret = virGetDomain(conn, def->name, def->uuid);
ret = virGetDomain(conn, def->name, def->uuid);
def = NULL; /* XM driver owns it now */
} else {
if (xenDaemonDomainDefineXML(conn, def) < 0)
goto cleanup;
ret = virGetDomain(conn, def->name, def->uuid);
}
if (ret) if (ret)
ret->id = -1; ret->id = -1;
@ -1937,7 +1830,6 @@ xenUnifiedDomainDefineXML(virConnectPtr conn, const char *xml)
static int static int
xenUnifiedDomainUndefineFlags(virDomainPtr dom, unsigned int flags) xenUnifiedDomainUndefineFlags(virDomainPtr dom, unsigned int flags)
{ {
xenUnifiedPrivatePtr priv = dom->conn->privateData;
virDomainDefPtr def = NULL; virDomainDefPtr def = NULL;
int ret = -1; int ret = -1;
@ -1949,10 +1841,7 @@ xenUnifiedDomainUndefineFlags(virDomainPtr dom, unsigned int flags)
if (virDomainUndefineFlagsEnsureACL(dom->conn, def) < 0) if (virDomainUndefineFlagsEnsureACL(dom->conn, def) < 0)
goto cleanup; goto cleanup;
if (priv->xendConfigVersion < XEND_CONFIG_VERSION_3_0_4) ret = xenDaemonDomainUndefine(dom->conn, def);
ret = xenXMDomainUndefine(dom->conn, def);
else
ret = xenDaemonDomainUndefine(dom->conn, def);
cleanup: cleanup:
virDomainDefFree(def); virDomainDefFree(def);
@ -1968,18 +1857,15 @@ xenUnifiedDomainUndefine(virDomainPtr dom)
static int static int
xenUnifiedDomainAttachDevice(virDomainPtr dom, const char *xml) xenUnifiedDomainAttachDevice(virDomainPtr dom, const char *xml)
{ {
xenUnifiedPrivatePtr priv = dom->conn->privateData;
unsigned int flags = VIR_DOMAIN_DEVICE_MODIFY_LIVE; unsigned int flags = VIR_DOMAIN_DEVICE_MODIFY_LIVE;
virDomainDefPtr def = NULL; virDomainDefPtr def = NULL;
int ret = -1; int ret = -1;
/* /*
* HACK: xend with xendConfigVersion >= 3 does not support changing live * HACK: xend does not support changing live config without also touching
* config without touching persistent config, we add the extra flag here * persistent config. We add the extra flag here to make this API work
* to make this API work
*/ */
if (priv->xendConfigVersion >= XEND_CONFIG_VERSION_3_0_4) flags |= VIR_DOMAIN_DEVICE_MODIFY_CONFIG;
flags |= VIR_DOMAIN_DEVICE_MODIFY_CONFIG;
if (!(def = xenGetDomainDefForDom(dom))) if (!(def = xenGetDomainDefForDom(dom)))
goto cleanup; goto cleanup;
@ -1987,10 +1873,7 @@ xenUnifiedDomainAttachDevice(virDomainPtr dom, const char *xml)
if (virDomainAttachDeviceEnsureACL(dom->conn, def) < 0) if (virDomainAttachDeviceEnsureACL(dom->conn, def) < 0)
goto cleanup; goto cleanup;
if (dom->id < 0 && priv->xendConfigVersion < XEND_CONFIG_VERSION_3_0_4) ret = xenDaemonAttachDeviceFlags(dom->conn, def, xml, flags);
ret = xenXMDomainAttachDeviceFlags(dom->conn, def, xml, flags);
else
ret = xenDaemonAttachDeviceFlags(dom->conn, def, xml, flags);
cleanup: cleanup:
virDomainDefFree(def); virDomainDefFree(def);
@ -2001,7 +1884,6 @@ static int
xenUnifiedDomainAttachDeviceFlags(virDomainPtr dom, const char *xml, xenUnifiedDomainAttachDeviceFlags(virDomainPtr dom, const char *xml,
unsigned int flags) unsigned int flags)
{ {
xenUnifiedPrivatePtr priv = dom->conn->privateData;
virDomainDefPtr def = NULL; virDomainDefPtr def = NULL;
int ret = -1; int ret = -1;
@ -2011,10 +1893,7 @@ xenUnifiedDomainAttachDeviceFlags(virDomainPtr dom, const char *xml,
if (virDomainAttachDeviceFlagsEnsureACL(dom->conn, def, flags) < 0) if (virDomainAttachDeviceFlagsEnsureACL(dom->conn, def, flags) < 0)
goto cleanup; goto cleanup;
if (dom->id < 0 && priv->xendConfigVersion < XEND_CONFIG_VERSION_3_0_4) ret = xenDaemonAttachDeviceFlags(dom->conn, def, xml, flags);
ret = xenXMDomainAttachDeviceFlags(dom->conn, def, xml, flags);
else
ret = xenDaemonAttachDeviceFlags(dom->conn, def, xml, flags);
cleanup: cleanup:
virDomainDefFree(def); virDomainDefFree(def);
@ -2024,18 +1903,15 @@ xenUnifiedDomainAttachDeviceFlags(virDomainPtr dom, const char *xml,
static int static int
xenUnifiedDomainDetachDevice(virDomainPtr dom, const char *xml) xenUnifiedDomainDetachDevice(virDomainPtr dom, const char *xml)
{ {
xenUnifiedPrivatePtr priv = dom->conn->privateData;
unsigned int flags = VIR_DOMAIN_DEVICE_MODIFY_LIVE; unsigned int flags = VIR_DOMAIN_DEVICE_MODIFY_LIVE;
virDomainDefPtr def = NULL; virDomainDefPtr def = NULL;
int ret = -1; int ret = -1;
/* /*
* HACK: xend with xendConfigVersion >= 3 does not support changing live * HACK: xend does not support changing live config without also touching
* config without touching persistent config, we add the extra flag here * persistent config. We add the extra flag here to make this API work
* to make this API work
*/ */
if (priv->xendConfigVersion >= XEND_CONFIG_VERSION_3_0_4) flags |= VIR_DOMAIN_DEVICE_MODIFY_CONFIG;
flags |= VIR_DOMAIN_DEVICE_MODIFY_CONFIG;
if (!(def = xenGetDomainDefForDom(dom))) if (!(def = xenGetDomainDefForDom(dom)))
goto cleanup; goto cleanup;
@ -2043,10 +1919,7 @@ xenUnifiedDomainDetachDevice(virDomainPtr dom, const char *xml)
if (virDomainDetachDeviceEnsureACL(dom->conn, def) < 0) if (virDomainDetachDeviceEnsureACL(dom->conn, def) < 0)
goto cleanup; goto cleanup;
if (dom->id < 0 && priv->xendConfigVersion < XEND_CONFIG_VERSION_3_0_4) ret = xenDaemonDetachDeviceFlags(dom->conn, def, xml, flags);
ret = xenXMDomainDetachDeviceFlags(dom->conn, def, xml, flags);
else
ret = xenDaemonDetachDeviceFlags(dom->conn, def, xml, flags);
cleanup: cleanup:
virDomainDefFree(def); virDomainDefFree(def);
@ -2057,7 +1930,6 @@ static int
xenUnifiedDomainDetachDeviceFlags(virDomainPtr dom, const char *xml, xenUnifiedDomainDetachDeviceFlags(virDomainPtr dom, const char *xml,
unsigned int flags) unsigned int flags)
{ {
xenUnifiedPrivatePtr priv = dom->conn->privateData;
virDomainDefPtr def = NULL; virDomainDefPtr def = NULL;
int ret = -1; int ret = -1;
@ -2067,10 +1939,7 @@ xenUnifiedDomainDetachDeviceFlags(virDomainPtr dom, const char *xml,
if (virDomainDetachDeviceFlagsEnsureACL(dom->conn, def, flags) < 0) if (virDomainDetachDeviceFlagsEnsureACL(dom->conn, def, flags) < 0)
goto cleanup; goto cleanup;
if (dom->id < 0 && priv->xendConfigVersion < XEND_CONFIG_VERSION_3_0_4) ret = xenDaemonDetachDeviceFlags(dom->conn, def, xml, flags);
ret = xenXMDomainDetachDeviceFlags(dom->conn, def, xml, flags);
else
ret = xenDaemonDetachDeviceFlags(dom->conn, def, xml, flags);
cleanup: cleanup:
virDomainDefFree(def); virDomainDefFree(def);
@ -2100,7 +1969,6 @@ xenUnifiedDomainUpdateDeviceFlags(virDomainPtr dom, const char *xml,
static int static int
xenUnifiedDomainGetAutostart(virDomainPtr dom, int *autostart) xenUnifiedDomainGetAutostart(virDomainPtr dom, int *autostart)
{ {
xenUnifiedPrivatePtr priv = dom->conn->privateData;
virDomainDefPtr def = NULL; virDomainDefPtr def = NULL;
int ret = -1; int ret = -1;
@ -2110,10 +1978,7 @@ xenUnifiedDomainGetAutostart(virDomainPtr dom, int *autostart)
if (virDomainGetAutostartEnsureACL(dom->conn, def) < 0) if (virDomainGetAutostartEnsureACL(dom->conn, def) < 0)
goto cleanup; goto cleanup;
if (priv->xendConfigVersion < XEND_CONFIG_VERSION_3_0_4) ret = xenDaemonDomainGetAutostart(dom->conn, def, autostart);
ret = xenXMDomainGetAutostart(def, autostart);
else
ret = xenDaemonDomainGetAutostart(dom->conn, def, autostart);
cleanup: cleanup:
virDomainDefFree(def); virDomainDefFree(def);
@ -2123,7 +1988,6 @@ xenUnifiedDomainGetAutostart(virDomainPtr dom, int *autostart)
static int static int
xenUnifiedDomainSetAutostart(virDomainPtr dom, int autostart) xenUnifiedDomainSetAutostart(virDomainPtr dom, int autostart)
{ {
xenUnifiedPrivatePtr priv = dom->conn->privateData;
virDomainDefPtr def = NULL; virDomainDefPtr def = NULL;
int ret = -1; int ret = -1;
@ -2133,10 +1997,7 @@ xenUnifiedDomainSetAutostart(virDomainPtr dom, int autostart)
if (virDomainSetAutostartEnsureACL(dom->conn, def) < 0) if (virDomainSetAutostartEnsureACL(dom->conn, def) < 0)
goto cleanup; goto cleanup;
if (priv->xendConfigVersion < XEND_CONFIG_VERSION_3_0_4) ret = xenDaemonDomainSetAutostart(dom->conn, def, autostart);
ret = xenXMDomainSetAutostart(def, autostart);
else
ret = xenDaemonDomainSetAutostart(dom->conn, def, autostart);
cleanup: cleanup:
virDomainDefFree(def); virDomainDefFree(def);
@ -2146,7 +2007,6 @@ xenUnifiedDomainSetAutostart(virDomainPtr dom, int autostart)
static char * static char *
xenUnifiedDomainGetSchedulerType(virDomainPtr dom, int *nparams) xenUnifiedDomainGetSchedulerType(virDomainPtr dom, int *nparams)
{ {
xenUnifiedPrivatePtr priv = dom->conn->privateData;
virDomainDefPtr def = NULL; virDomainDefPtr def = NULL;
char *ret = NULL; char *ret = NULL;
@ -2156,16 +2016,10 @@ xenUnifiedDomainGetSchedulerType(virDomainPtr dom, int *nparams)
if (virDomainGetSchedulerTypeEnsureACL(dom->conn, def) < 0) if (virDomainGetSchedulerTypeEnsureACL(dom->conn, def) < 0)
goto cleanup; goto cleanup;
if (dom->id < 0) { if (dom->id < 0)
if (priv->xendConfigVersion < XEND_CONFIG_VERSION_3_0_4) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Cannot change scheduler parameters"));
goto cleanup;
}
ret = xenDaemonGetSchedulerType(dom->conn, nparams); ret = xenDaemonGetSchedulerType(dom->conn, nparams);
} else { else
ret = xenHypervisorGetSchedulerType(dom->conn, nparams); ret = xenHypervisorGetSchedulerType(dom->conn, nparams);
}
cleanup: cleanup:
virDomainDefFree(def); virDomainDefFree(def);
@ -2178,7 +2032,6 @@ xenUnifiedDomainGetSchedulerParametersFlags(virDomainPtr dom,
int *nparams, int *nparams,
unsigned int flags) unsigned int flags)
{ {
xenUnifiedPrivatePtr priv = dom->conn->privateData;
virDomainDefPtr def = NULL; virDomainDefPtr def = NULL;
int ret = -1; int ret = -1;
@ -2190,16 +2043,10 @@ xenUnifiedDomainGetSchedulerParametersFlags(virDomainPtr dom,
if (virDomainGetSchedulerParametersFlagsEnsureACL(dom->conn, def) < 0) if (virDomainGetSchedulerParametersFlagsEnsureACL(dom->conn, def) < 0)
goto cleanup; goto cleanup;
if (dom->id < 0) { if (dom->id < 0)
if (priv->xendConfigVersion < XEND_CONFIG_VERSION_3_0_4) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Cannot change scheduler parameters"));
goto cleanup;
}
ret = xenDaemonGetSchedulerParameters(dom->conn, def, params, nparams); ret = xenDaemonGetSchedulerParameters(dom->conn, def, params, nparams);
} else { else
ret = xenHypervisorGetSchedulerParameters(dom->conn, def, params, nparams); ret = xenHypervisorGetSchedulerParameters(dom->conn, def, params, nparams);
}
cleanup: cleanup:
virDomainDefFree(def); virDomainDefFree(def);
@ -2221,7 +2068,6 @@ xenUnifiedDomainSetSchedulerParametersFlags(virDomainPtr dom,
int nparams, int nparams,
unsigned int flags) unsigned int flags)
{ {
xenUnifiedPrivatePtr priv = dom->conn->privateData;
virDomainDefPtr def = NULL; virDomainDefPtr def = NULL;
int ret = -1; int ret = -1;
@ -2233,16 +2079,10 @@ xenUnifiedDomainSetSchedulerParametersFlags(virDomainPtr dom,
if (virDomainSetSchedulerParametersFlagsEnsureACL(dom->conn, def, flags) < 0) if (virDomainSetSchedulerParametersFlagsEnsureACL(dom->conn, def, flags) < 0)
goto cleanup; goto cleanup;
if (dom->id < 0) { if (dom->id < 0)
if (priv->xendConfigVersion < XEND_CONFIG_VERSION_3_0_4) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Cannot change scheduler parameters"));
goto cleanup;
}
ret = xenDaemonSetSchedulerParameters(dom->conn, def, params, nparams); ret = xenDaemonSetSchedulerParameters(dom->conn, def, params, nparams);
} else { else
ret = xenHypervisorSetSchedulerParameters(dom->conn, def, params, nparams); ret = xenHypervisorSetSchedulerParameters(dom->conn, def, params, nparams);
}
cleanup: cleanup:
virDomainDefFree(def); virDomainDefFree(def);
@ -2303,7 +2143,6 @@ xenUnifiedDomainBlockPeek(virDomainPtr dom, const char *path,
unsigned long long offset, size_t size, unsigned long long offset, size_t size,
void *buffer, unsigned int flags) void *buffer, unsigned int flags)
{ {
xenUnifiedPrivatePtr priv = dom->conn->privateData;
virDomainDefPtr def = NULL; virDomainDefPtr def = NULL;
int ret = -1; int ret = -1;
@ -2315,10 +2154,7 @@ xenUnifiedDomainBlockPeek(virDomainPtr dom, const char *path,
if (virDomainBlockPeekEnsureACL(dom->conn, def) < 0) if (virDomainBlockPeekEnsureACL(dom->conn, def) < 0)
goto cleanup; goto cleanup;
if (dom->id < 0 && priv->xendConfigVersion < XEND_CONFIG_VERSION_3_0_4) ret = xenDaemonDomainBlockPeek(dom->conn, def, path, offset, size, buffer);
ret = xenXMDomainBlockPeek(dom->conn, def, path, offset, size, buffer);
else
ret = xenDaemonDomainBlockPeek(dom->conn, def, path, offset, size, buffer);
cleanup: cleanup:
virDomainDefFree(def); virDomainDefFree(def);