#include "nodeinfo.h"
#include "configmake.h"
#include "virstring.h"
+#include "viraccessapicheck.h"
#define VIR_FROM_THIS VIR_FROM_XEN
#define XEN_SAVE_DIR LOCALSTATEDIR "/lib/libvirt/xen/save"
/* We now know the URI is definitely for this driver, so beyond
* here, don't return DECLINED, always use ERROR */
+ if (virConnectOpenEnsureACL(conn) < 0)
+ return VIR_DRV_OPEN_ERROR;
+
/* Allocate per-connection private data. */
if (VIR_ALLOC(priv) < 0) {
virReportOOMError();
static const char *
-xenUnifiedConnectGetType(virConnectPtr conn ATTRIBUTE_UNUSED)
+xenUnifiedConnectGetType(virConnectPtr conn)
{
+ if (virConnectGetTypeEnsureACL(conn) < 0)
+ return NULL;
+
return "Xen";
}
/* Which features are supported by this driver? */
static int
-xenUnifiedConnectSupportsFeature(virConnectPtr conn ATTRIBUTE_UNUSED, int feature)
+xenUnifiedConnectSupportsFeature(virConnectPtr conn, int feature)
{
+ if (virConnectSupportsFeatureEnsureACL(conn) < 0)
+ return -1;
+
switch (feature) {
case VIR_DRV_FEATURE_MIGRATION_V1:
case VIR_DRV_FEATURE_MIGRATION_DIRECT:
static int
xenUnifiedConnectGetVersion(virConnectPtr conn, unsigned long *hvVer)
{
+ if (virConnectGetVersionEnsureACL(conn) < 0)
+ return -1;
+
return xenHypervisorGetVersion(conn, hvVer);
}
-static char *xenUnifiedConnectGetHostname(virConnectPtr conn ATTRIBUTE_UNUSED)
+static char *xenUnifiedConnectGetHostname(virConnectPtr conn)
{
+ if (virConnectGetHostnameEnsureACL(conn) < 0)
+ return NULL;
+
return virGetHostname();
}
virCheckFlags(0, NULL);
+ if (virConnectGetSysinfoEnsureACL(conn) < 0)
+ return NULL;
+
if (!hostsysinfo) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("Host SMBIOS information is not available"));
int
xenUnifiedConnectGetMaxVcpus(virConnectPtr conn, const char *type)
{
+ if (virConnectGetMaxVcpusEnsureACL(conn) < 0)
+ return -1;
+
if (type && STRCASENEQ(type, "Xen")) {
virReportError(VIR_ERR_INVALID_ARG, __FUNCTION__);
return -1;
static int
xenUnifiedNodeGetInfo(virConnectPtr conn, virNodeInfoPtr info)
{
+ if (virNodeGetInfoEnsureACL(conn) < 0)
+ return -1;
+
return xenDaemonNodeGetInfo(conn, info);
}
xenUnifiedPrivatePtr priv = conn->privateData;
char *xml;
+ if (virConnectGetCapabilitiesEnsureACL(conn) < 0)
+ return NULL;
+
if (!(xml = virCapabilitiesFormatXML(priv->caps))) {
virReportOOMError();
return NULL;
static int
xenUnifiedConnectListDomains(virConnectPtr conn, int *ids, int maxids)
{
+ if (virConnectListDomainsEnsureACL(conn) < 0)
+ return -1;
+
return xenStoreListDomains(conn, ids, maxids);
}
static int
xenUnifiedConnectNumOfDomains(virConnectPtr conn)
{
+ if (virConnectNumOfDomainsEnsureACL(conn) < 0)
+ return -1;
+
return xenStoreNumOfDomains(conn);
}
VIR_DOMAIN_XML_INACTIVE)))
goto cleanup;
+ if (virDomainCreateXMLEnsureACL(conn, def) < 0)
+ goto cleanup;
+
if (xenDaemonCreateXML(conn, def) < 0)
goto cleanup;
if (!(def = xenGetDomainDefForID(conn, id)))
goto cleanup;
+ if (virDomainLookupByIDEnsureACL(conn, def) < 0)
+ goto cleanup;
+
if (!(ret = virGetDomain(conn, def->name, def->uuid)))
goto cleanup;
if (!(def = xenGetDomainDefForUUID(conn, uuid)))
goto cleanup;
+ if (virDomainLookupByUUIDEnsureACL(conn, def) < 0)
+ goto cleanup;
+
if (!(ret = virGetDomain(conn, def->name, def->uuid)))
goto cleanup;
if (!(def = xenGetDomainDefForName(conn, name)))
goto cleanup;
+ if (virDomainLookupByNameEnsureACL(conn, def) < 0)
+ goto cleanup;
+
if (!(ret = virGetDomain(conn, def->name, def->uuid)))
goto cleanup;
if (!(def = xenGetDomainDefForDom(dom)))
goto cleanup;
+ if (virDomainSuspendEnsureACL(dom->conn, def) < 0)
+ goto cleanup;
+
ret = xenDaemonDomainSuspend(dom->conn, def);
cleanup:
if (!(def = xenGetDomainDefForDom(dom)))
goto cleanup;
+ if (virDomainResumeEnsureACL(dom->conn, def) < 0)
+ goto cleanup;
+
ret = xenDaemonDomainResume(dom->conn, def);
cleanup:
if (!(def = xenGetDomainDefForDom(dom)))
goto cleanup;
+ if (virDomainShutdownFlagsEnsureACL(dom->conn, def) < 0)
+ goto cleanup;
+
ret = xenDaemonDomainShutdown(dom->conn, def);
cleanup:
if (!(def = xenGetDomainDefForDom(dom)))
goto cleanup;
+ if (virDomainRebootEnsureACL(dom->conn, def) < 0)
+ goto cleanup;
+
ret = xenDaemonDomainReboot(dom->conn, def);
cleanup:
if (!(def = xenGetDomainDefForDom(dom)))
goto cleanup;
+ if (virDomainDestroyFlagsEnsureACL(dom->conn, def) < 0)
+ goto cleanup;
+
ret = xenDaemonDomainDestroy(dom->conn, def);
cleanup:
if (!(def = xenGetDomainDefForDom(dom)))
goto cleanup;
+ if (virDomainGetOSTypeEnsureACL(dom->conn, def) < 0)
+ goto cleanup;
+
if (def->id < 0) {
if (priv->xendConfigVersion < XEND_CONFIG_VERSION_3_0_4) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
if (!(def = xenGetDomainDefForDom(dom)))
goto cleanup;
+ if (virDomainGetMaxMemoryEnsureACL(dom->conn, def) < 0)
+ goto cleanup;
+
if (def->id < 0) {
if (priv->xendConfigVersion < XEND_CONFIG_VERSION_3_0_4)
ret = xenXMDomainGetMaxMemory(dom->conn, def);
if (!(def = xenGetDomainDefForDom(dom)))
goto cleanup;
+ if (virDomainSetMaxMemoryEnsureACL(dom->conn, def) < 0)
+ goto cleanup;
+
if (def->id < 0) {
if (priv->xendConfigVersion < XEND_CONFIG_VERSION_3_0_4)
ret = xenXMDomainSetMaxMemory(dom->conn, def, memory);
if (!(def = xenGetDomainDefForDom(dom)))
goto cleanup;
+ if (virDomainSetMemoryEnsureACL(dom->conn, def) < 0)
+ goto cleanup;
+
if (def->id < 0 && priv->xendConfigVersion < XEND_CONFIG_VERSION_3_0_4)
ret = xenXMDomainSetMemory(dom->conn, def, memory);
else
if (!(def = xenGetDomainDefForDom(dom)))
goto cleanup;
+ if (virDomainGetInfoEnsureACL(dom->conn, def) < 0)
+ goto cleanup;
+
if (def->id < 0) {
if (priv->xendConfigVersion < XEND_CONFIG_VERSION_3_0_4)
ret = xenXMDomainGetInfo(dom->conn, def, info);
if (!(def = xenGetDomainDefForDom(dom)))
goto cleanup;
+ if (virDomainGetStateEnsureACL(dom->conn, def) < 0)
+ goto cleanup;
+
if (def->id < 0) {
if (priv->xendConfigVersion < XEND_CONFIG_VERSION_3_0_4)
ret = xenXMDomainGetState(dom->conn, def, state, reason);
if (!(def = xenGetDomainDefForDom(dom)))
goto cleanup;
+ if (virDomainSaveFlagsEnsureACL(dom->conn, def) < 0)
+ goto cleanup;
+
ret = xenDaemonDomainSave(dom->conn, def, to);
cleanup:
if (!(def = xenGetDomainDefForDom(dom)))
goto cleanup;
+ if (virDomainManagedSaveEnsureACL(dom->conn, def) < 0)
+ goto cleanup;
+
if (!(name = xenUnifiedDomainManagedSavePath(priv, def)))
goto cleanup;
if (!(def = xenGetDomainDefForDom(dom)))
goto cleanup;
+ if (virDomainHasManagedSaveImageEnsureACL(dom->conn, def) < 0)
+ goto cleanup;
+
if (!(name = xenUnifiedDomainManagedSavePath(priv, def)))
goto cleanup;
if (!(def = xenGetDomainDefForDom(dom)))
goto cleanup;
+ if (virDomainManagedSaveRemoveEnsureACL(dom->conn, def) < 0)
+ goto cleanup;
+
if (!(name = xenUnifiedDomainManagedSavePath(priv, def)))
goto cleanup;
if (!(def = xenGetDomainDefForDom(dom)))
goto cleanup;
+ if (virDomainCoreDumpEnsureACL(dom->conn, def) < 0)
+ goto cleanup;
+
ret = xenDaemonDomainCoreDump(dom->conn, def, to, flags);
cleanup:
if (!(def = xenGetDomainDefForDom(dom)))
goto cleanup;
+ if (virDomainSetVcpusFlagsEnsureACL(dom->conn, def, flags) < 0)
+ goto cleanup;
+
/* Try non-hypervisor methods first, then hypervisor direct method
* as a last resort.
*/
if (!(def = xenGetDomainDefForDom(dom)))
goto cleanup;
+ if (virDomainPinVcpuEnsureACL(dom->conn, def) < 0)
+ goto cleanup;
+
if (dom->id < 0) {
if (priv->xendConfigVersion < XEND_CONFIG_VERSION_3_0_4)
ret = xenXMDomainPinVcpu(dom->conn, def, vcpu, cpumap, maplen);
if (!(def = xenGetDomainDefForDom(dom)))
goto cleanup;
+ if (virDomainGetVcpusEnsureACL(dom->conn, def) < 0)
+ goto cleanup;
+
if (dom->id < 0) {
if (priv->xendConfigVersion < XEND_CONFIG_VERSION_3_0_4) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
if (!(def = xenGetDomainDefForDom(dom)))
goto cleanup;
+ if (virDomainGetVcpusFlagsEnsureACL(dom->conn, def) < 0)
+ goto cleanup;
+
if (dom->id < 0) {
if (priv->xendConfigVersion < XEND_CONFIG_VERSION_3_0_4)
ret = xenXMDomainGetVcpusFlags(dom->conn, def, flags);
if (!(minidef = xenGetDomainDefForDom(dom)))
goto cleanup;
+ if (virDomainGetXMLDescEnsureACL(dom->conn, minidef, flags) < 0)
+ goto cleanup;
+
if (dom->id < 0 && priv->xendConfigVersion < XEND_CONFIG_VERSION_3_0_4) {
def = xenXMDomainGetXMLDesc(dom->conn, minidef);
} else {
virCheckFlags(0, NULL);
+ if (virConnectDomainXMLFromNativeEnsureACL(conn) < 0)
+ return NULL;
+
if (STRNEQ(format, XEN_CONFIG_FORMAT_XM) &&
STRNEQ(format, XEN_CONFIG_FORMAT_SEXPR)) {
virReportError(VIR_ERR_INVALID_ARG,
virCheckFlags(0, NULL);
+ if (virConnectDomainXMLToNativeEnsureACL(conn) < 0)
+ return NULL;
+
if (STRNEQ(format, XEN_CONFIG_FORMAT_XM) &&
STRNEQ(format, XEN_CONFIG_FORMAT_SEXPR)) {
virReportError(VIR_ERR_INVALID_ARG,
if (!(def = xenGetDomainDefForDom(dom)))
goto cleanup;
+ if (virDomainMigratePerformEnsureACL(dom->conn, def) < 0)
+ goto cleanup;
+
ret = xenDaemonDomainMigratePerform(dom->conn, def,
cookie, cookielen, uri,
flags, dname, resource);
if (!(minidef = xenGetDomainDefForName(dconn, dname)))
goto cleanup;
+ if (virDomainMigrateFinishEnsureACL(dconn, minidef) < 0)
+ goto cleanup;
+
if (flags & VIR_MIGRATE_PERSIST_DEST) {
if (!(def = xenDaemonDomainGetXMLDesc(dconn, minidef, NULL)))
goto cleanup;
{
xenUnifiedPrivatePtr priv = conn->privateData;
+ if (virConnectListDefinedDomainsEnsureACL(conn) < 0)
+ return -1;
+
if (priv->xendConfigVersion < XEND_CONFIG_VERSION_3_0_4) {
return xenXMListDefinedDomains(conn, names, maxnames);
} else {
{
xenUnifiedPrivatePtr priv = conn->privateData;
+ if (virConnectNumOfDefinedDomainsEnsureACL(conn) < 0)
+ return -1;
+
if (priv->xendConfigVersion < XEND_CONFIG_VERSION_3_0_4) {
return xenXMNumOfDefinedDomains(conn);
} else {
if (!(def = xenGetDomainDefForDom(dom)))
goto cleanup;
+ if (virDomainCreateWithFlagsEnsureACL(dom->conn, def) < 0)
+ goto cleanup;
+
if (!(name = xenUnifiedDomainManagedSavePath(priv, def)))
goto cleanup;
VIR_DOMAIN_XML_INACTIVE)))
goto cleanup;
+ if (virDomainDefineXMLEnsureACL(conn, def) < 0)
+ goto cleanup;
+
if (priv->xendConfigVersion < XEND_CONFIG_VERSION_3_0_4) {
if (xenXMDomainDefineXML(conn, def) < 0)
goto cleanup;
if (!(def = xenGetDomainDefForDom(dom)))
goto cleanup;
+ if (virDomainUndefineFlagsEnsureACL(dom->conn, def) < 0)
+ goto cleanup;
+
if (priv->xendConfigVersion < XEND_CONFIG_VERSION_3_0_4)
ret = xenXMDomainUndefine(dom->conn, def);
else
if (!(def = xenGetDomainDefForDom(dom)))
goto cleanup;
+ if (virDomainAttachDeviceEnsureACL(dom->conn, def) < 0)
+ goto cleanup;
+
if (dom->id < 0 && priv->xendConfigVersion < XEND_CONFIG_VERSION_3_0_4)
ret = xenXMDomainAttachDeviceFlags(dom->conn, def, xml, flags);
else
if (!(def = xenGetDomainDefForDom(dom)))
goto cleanup;
+ if (virDomainAttachDeviceFlagsEnsureACL(dom->conn, def, flags) < 0)
+ goto cleanup;
+
if (dom->id < 0 && priv->xendConfigVersion < XEND_CONFIG_VERSION_3_0_4)
ret = xenXMDomainAttachDeviceFlags(dom->conn, def, xml, flags);
else
if (!(def = xenGetDomainDefForDom(dom)))
goto cleanup;
+ if (virDomainDetachDeviceEnsureACL(dom->conn, def) < 0)
+ goto cleanup;
+
if (dom->id < 0 && priv->xendConfigVersion < XEND_CONFIG_VERSION_3_0_4)
ret = xenXMDomainDetachDeviceFlags(dom->conn, def, xml, flags);
else
if (!(def = xenGetDomainDefForDom(dom)))
goto cleanup;
+ if (virDomainDetachDeviceFlagsEnsureACL(dom->conn, def, flags) < 0)
+ goto cleanup;
+
if (dom->id < 0 && priv->xendConfigVersion < XEND_CONFIG_VERSION_3_0_4)
ret = xenXMDomainDetachDeviceFlags(dom->conn, def, xml, flags);
else
if (!(def = xenGetDomainDefForDom(dom)))
goto cleanup;
+ if (virDomainUpdateDeviceFlagsEnsureACL(dom->conn, def, flags) < 0)
+ goto cleanup;
+
ret = xenDaemonUpdateDeviceFlags(dom->conn, def, xml, flags);
cleanup:
if (!(def = xenGetDomainDefForDom(dom)))
goto cleanup;
+ if (virDomainGetAutostartEnsureACL(dom->conn, def) < 0)
+ goto cleanup;
+
if (priv->xendConfigVersion < XEND_CONFIG_VERSION_3_0_4)
ret = xenXMDomainGetAutostart(def, autostart);
else
if (!(def = xenGetDomainDefForDom(dom)))
goto cleanup;
+ if (virDomainSetAutostartEnsureACL(dom->conn, def) < 0)
+ goto cleanup;
+
if (priv->xendConfigVersion < XEND_CONFIG_VERSION_3_0_4)
ret = xenXMDomainSetAutostart(def, autostart);
else
if (!(def = xenGetDomainDefForDom(dom)))
goto cleanup;
+ if (virDomainGetSchedulerTypeEnsureACL(dom->conn, def) < 0)
+ goto cleanup;
+
if (dom->id < 0) {
if (priv->xendConfigVersion < XEND_CONFIG_VERSION_3_0_4) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
if (!(def = xenGetDomainDefForDom(dom)))
goto cleanup;
+ if (virDomainGetSchedulerParametersFlagsEnsureACL(dom->conn, def) < 0)
+ goto cleanup;
+
if (dom->id < 0) {
if (priv->xendConfigVersion < XEND_CONFIG_VERSION_3_0_4) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
if (!(def = xenGetDomainDefForDom(dom)))
goto cleanup;
+ if (virDomainSetSchedulerParametersFlagsEnsureACL(dom->conn, def, flags) < 0)
+ goto cleanup;
+
if (dom->id < 0) {
if (priv->xendConfigVersion < XEND_CONFIG_VERSION_3_0_4) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
if (!(def = xenGetDomainDefForDom(dom)))
goto cleanup;
+ if (virDomainBlockStatsEnsureACL(dom->conn, def) < 0)
+ goto cleanup;
+
ret = xenHypervisorDomainBlockStats(dom->conn, def, path, stats);
cleanup:
if (!(def = xenGetDomainDefForDom(dom)))
goto cleanup;
+ if (virDomainInterfaceStatsEnsureACL(dom->conn, def) < 0)
+ goto cleanup;
+
ret = xenHypervisorDomainInterfaceStats(def, path, stats);
cleanup:
if (!(def = xenGetDomainDefForDom(dom)))
goto cleanup;
+ if (virDomainBlockPeekEnsureACL(dom->conn, def) < 0)
+ goto cleanup;
+
if (dom->id < 0 && priv->xendConfigVersion < XEND_CONFIG_VERSION_3_0_4)
ret = xenXMDomainBlockPeek(dom->conn, def, path, offset, size, buffer);
else
xenUnifiedNodeGetCellsFreeMemory(virConnectPtr conn, unsigned long long *freeMems,
int startCell, int maxCells)
{
+ if (virNodeGetCellsFreeMemoryEnsureACL(conn) < 0)
+ return 0;
+
return xenHypervisorNodeGetCellsFreeMemory(conn, freeMems,
startCell, maxCells);
}
{
unsigned long long freeMem = 0;
+ if (virNodeGetFreeMemoryEnsureACL(conn) < 0)
+ return 0;
+
if (xenHypervisorNodeGetCellsFreeMemory(conn, &freeMem, -1, 1) < 0)
return 0;
return freeMem;
virFreeCallback freefunc)
{
xenUnifiedPrivatePtr priv = conn->privateData;
-
int ret;
+
+ if (virConnectDomainEventRegisterEnsureACL(conn) < 0)
+ return -1;
+
xenUnifiedLock(priv);
if (priv->xsWatch == -1) {
{
int ret;
xenUnifiedPrivatePtr priv = conn->privateData;
+
+ if (virConnectDomainEventDeregisterEnsureACL(conn) < 0)
+ return -1;
+
xenUnifiedLock(priv);
if (priv->xsWatch == -1) {
virFreeCallback freefunc)
{
xenUnifiedPrivatePtr priv = conn->privateData;
-
int ret;
+
+ if (virConnectDomainEventRegisterAnyEnsureACL(conn) < 0)
+ return -1;
+
xenUnifiedLock(priv);
if (priv->xsWatch == -1) {
{
int ret;
xenUnifiedPrivatePtr priv = conn->privateData;
+
+ if (virConnectDomainEventDeregisterAnyEnsureACL(conn) < 0)
+ return -1;
+
xenUnifiedLock(priv);
if (priv->xsWatch == -1) {
}
static int
-xenUnifiedNodeGetMemoryParameters(virConnectPtr conn ATTRIBUTE_UNUSED,
+xenUnifiedNodeGetMemoryParameters(virConnectPtr conn,
virTypedParameterPtr params,
int *nparams,
unsigned int flags)
{
+ if (virNodeGetMemoryParametersEnsureACL(conn) < 0)
+ return -1;
+
return nodeGetMemoryParameters(params, nparams, flags);
}
static int
-xenUnifiedNodeSetMemoryParameters(virConnectPtr conn ATTRIBUTE_UNUSED,
+xenUnifiedNodeSetMemoryParameters(virConnectPtr conn,
virTypedParameterPtr params,
int nparams,
unsigned int flags)
{
+ if (virNodeSetMemoryParametersEnsureACL(conn) < 0)
+ return -1;
+
return nodeSetMemoryParameters(params, nparams, flags);
}
static int
-xenUnifiedNodeSuspendForDuration(virConnectPtr conn ATTRIBUTE_UNUSED,
+xenUnifiedNodeSuspendForDuration(virConnectPtr conn,
unsigned int target,
unsigned long long duration,
unsigned int flags)
{
+ if (virNodeSuspendForDurationEnsureACL(conn) < 0)
+ return -1;
+
return nodeSuspendForDuration(target, duration, flags);
}