From 4a044d0256da97462852bb8018b4db1ec697cb19 Mon Sep 17 00:00:00 2001 From: "Daniel P. Berrange" Date: Mon, 29 Apr 2013 10:16:56 +0100 Subject: [PATCH] Separate internal node suspend APIs from public API The individual hypervisor drivers were directly referencing APIs in virnodesuspend.c in their virDriverPtr struct. Separate these methods, so there is always a wrapper in the hypervisor driver. This allows the unused virConnectPtr args to be removed from the virnodesuspend.c file. Again this will ensure that ACL checks will only be performed on invocations that are directly associated with public API usage. Signed-off-by: Daniel P. Berrange --- src/lxc/lxc_driver.c | 13 ++++++++++++- src/qemu/qemu_driver.c | 13 ++++++++++++- src/uml/uml_driver.c | 12 +++++++++++- src/util/virnodesuspend.c | 3 +-- src/util/virnodesuspend.h | 3 +-- src/xen/xen_driver.c | 13 ++++++++++++- 6 files changed, 49 insertions(+), 8 deletions(-) diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c index 56f89340f5..38ea58d752 100644 --- a/src/lxc/lxc_driver.c +++ b/src/lxc/lxc_driver.c @@ -4478,6 +4478,17 @@ lxcNodeGetCPUMap(virConnectPtr conn ATTRIBUTE_UNUSED, return nodeGetCPUMap(cpumap, online, flags); } + +static int +lxcNodeSuspendForDuration(virConnectPtr conn ATTRIBUTE_UNUSED, + unsigned int target, + unsigned long long duration, + unsigned int flags) +{ + return nodeSuspendForDuration(target, duration, flags); +} + + /* Function Tables */ static virDriver lxcDriver = { .no = VIR_DRV_LXC, @@ -4549,7 +4560,7 @@ static virDriver lxcDriver = { .connectDomainEventDeregisterAny = lxcConnectDomainEventDeregisterAny, /* 0.8.0 */ .domainOpenConsole = lxcDomainOpenConsole, /* 0.8.6 */ .connectIsAlive = lxcConnectIsAlive, /* 0.9.8 */ - .nodeSuspendForDuration = nodeSuspendForDuration, /* 0.9.8 */ + .nodeSuspendForDuration = lxcNodeSuspendForDuration, /* 0.9.8 */ .nodeGetMemoryParameters = lxcNodeGetMemoryParameters, /* 0.10.2 */ .nodeSetMemoryParameters = lxcNodeSetMemoryParameters, /* 0.10.2 */ .domainSendProcessSignal = lxcDomainSendProcessSignal, /* 1.0.1 */ diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index c44ffbcb06..e593516c41 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -14779,6 +14779,17 @@ qemuNodeGetCPUMap(virConnectPtr conn ATTRIBUTE_UNUSED, return nodeGetCPUMap(cpumap, online, flags); } + +static int +qemuNodeSuspendForDuration(virConnectPtr conn ATTRIBUTE_UNUSED, + unsigned int target, + unsigned long long duration, + unsigned int flags) +{ + return nodeSuspendForDuration(target, duration, flags); +} + + static virDriver qemuDriver = { .no = VIR_DRV_QEMU, .name = QEMU_DRIVER_NAME, @@ -14940,7 +14951,7 @@ static virDriver qemuDriver = { .domainBlockRebase = qemuDomainBlockRebase, /* 0.9.10 */ .domainBlockCommit = qemuDomainBlockCommit, /* 1.0.0 */ .connectIsAlive = qemuConnectIsAlive, /* 0.9.8 */ - .nodeSuspendForDuration = nodeSuspendForDuration, /* 0.9.8 */ + .nodeSuspendForDuration = qemuNodeSuspendForDuration, /* 0.9.8 */ .domainSetBlockIoTune = qemuDomainSetBlockIoTune, /* 0.9.8 */ .domainGetBlockIoTune = qemuDomainGetBlockIoTune, /* 0.9.8 */ .domainSetNumaParameters = qemuDomainSetNumaParameters, /* 0.9.9 */ diff --git a/src/uml/uml_driver.c b/src/uml/uml_driver.c index 6ae0def798..ded079827d 100644 --- a/src/uml/uml_driver.c +++ b/src/uml/uml_driver.c @@ -2673,6 +2673,16 @@ umlNodeGetCPUMap(virConnectPtr conn ATTRIBUTE_UNUSED, } +static int +umlNodeSuspendForDuration(virConnectPtr conn ATTRIBUTE_UNUSED, + unsigned int target, + unsigned long long duration, + unsigned int flags) +{ + return nodeSuspendForDuration(target, duration, flags); +} + + static virDriver umlDriver = { .no = VIR_DRV_UML, .name = "UML", @@ -2731,7 +2741,7 @@ static virDriver umlDriver = { .connectDomainEventDeregisterAny = umlConnectDomainEventDeregisterAny, /* 0.9.4 */ .domainOpenConsole = umlDomainOpenConsole, /* 0.8.6 */ .connectIsAlive = umlConnectIsAlive, /* 0.9.8 */ - .nodeSuspendForDuration = nodeSuspendForDuration, /* 0.9.8 */ + .nodeSuspendForDuration = umlNodeSuspendForDuration, /* 0.9.8 */ .nodeGetMemoryParameters = umlNodeGetMemoryParameters, /* 0.10.2 */ .nodeSetMemoryParameters = umlNodeSetMemoryParameters, /* 0.10.2 */ }; diff --git a/src/util/virnodesuspend.c b/src/util/virnodesuspend.c index df40ccd4d4..72a17cd353 100644 --- a/src/util/virnodesuspend.c +++ b/src/util/virnodesuspend.c @@ -165,8 +165,7 @@ static void virNodeSuspend(void *cmdString) * -1 if suspending the node is not supported, or if a previous suspend * operation is still in progress. */ -int nodeSuspendForDuration(virConnectPtr conn ATTRIBUTE_UNUSED, - unsigned int target, +int nodeSuspendForDuration(unsigned int target, unsigned long long duration, unsigned int flags) { diff --git a/src/util/virnodesuspend.h b/src/util/virnodesuspend.h index ac54015dfe..b5f67dde0c 100644 --- a/src/util/virnodesuspend.h +++ b/src/util/virnodesuspend.h @@ -25,8 +25,7 @@ # include "internal.h" -int nodeSuspendForDuration(virConnectPtr conn, - unsigned int target, +int nodeSuspendForDuration(unsigned int target, unsigned long long duration, unsigned int flags); diff --git a/src/xen/xen_driver.c b/src/xen/xen_driver.c index 758cf15e4d..8285912846 100644 --- a/src/xen/xen_driver.c +++ b/src/xen/xen_driver.c @@ -2369,6 +2369,17 @@ xenUnifiedNodeSetMemoryParameters(virConnectPtr conn ATTRIBUTE_UNUSED, return nodeSetMemoryParameters(params, nparams, flags); } + +static int +xenUnifiedNodeSuspendForDuration(virConnectPtr conn ATTRIBUTE_UNUSED, + unsigned int target, + unsigned long long duration, + unsigned int flags) +{ + return nodeSuspendForDuration(target, duration, flags); +} + + /*----- Register with libvirt.c, and initialize Xen drivers. -----*/ /* The interface which we export upwards to libvirt.c. */ @@ -2462,7 +2473,7 @@ static virDriver xenUnifiedDriver = { .connectDomainEventDeregisterAny = xenUnifiedConnectDomainEventDeregisterAny, /* 0.8.0 */ .domainOpenConsole = xenUnifiedDomainOpenConsole, /* 0.8.6 */ .connectIsAlive = xenUnifiedConnectIsAlive, /* 0.9.8 */ - .nodeSuspendForDuration = nodeSuspendForDuration, /* 0.9.8 */ + .nodeSuspendForDuration = xenUnifiedNodeSuspendForDuration, /* 0.9.8 */ .nodeGetMemoryParameters = xenUnifiedNodeGetMemoryParameters, /* 0.10.2 */ .nodeSetMemoryParameters = xenUnifiedNodeSetMemoryParameters, /* 0.10.2 */ };