Move libxlDomainSetVcpuAffinities from libxl_driver to libxl_domain
for use by other libxl modules.
Signed-off-by: Jim Fehlig <jfehlig(a)suse.com>
---
src/libxl/libxl_domain.c | 54 ++++++++++++++++++++++++++++++++++++++++++++++++
src/libxl/libxl_domain.h | 4 ++++
src/libxl/libxl_driver.c | 54 ------------------------------------------------
3 files changed, 58 insertions(+), 54 deletions(-)
diff --git a/src/libxl/libxl_domain.c b/src/libxl/libxl_domain.c
index 6816a96..ef85790 100644
--- a/src/libxl/libxl_domain.c
+++ b/src/libxl/libxl_domain.c
@@ -786,3 +786,57 @@ cleanup:
return ret;
}
+
+int
+libxlDomainSetVcpuAffinities(libxlDriverPrivatePtr driver, virDomainObjPtr vm)
+{
+ libxlDomainObjPrivatePtr priv = vm->privateData;
+ virDomainDefPtr def = vm->def;
+ libxl_bitmap map;
+ virBitmapPtr cpumask = NULL;
+ uint8_t *cpumap = NULL;
+ virNodeInfo nodeinfo;
+ size_t cpumaplen;
+ int vcpu;
+ size_t i;
+ int ret = -1;
+
+ if (libxlDriverNodeGetInfo(driver, &nodeinfo) < 0)
+ goto cleanup;
+
+ cpumaplen = VIR_CPU_MAPLEN(VIR_NODEINFO_MAXCPUS(nodeinfo));
+
+ for (vcpu = 0; vcpu < def->cputune.nvcpupin; ++vcpu) {
+ if (vcpu != def->cputune.vcpupin[vcpu]->vcpuid)
+ continue;
+
+ if (VIR_ALLOC_N(cpumap, cpumaplen) < 0)
+ goto cleanup;
+
+ cpumask = def->cputune.vcpupin[vcpu]->cpumask;
+
+ for (i = 0; i < virBitmapSize(cpumask); ++i) {
+ bool bit;
+ ignore_value(virBitmapGetBit(cpumask, i, &bit));
+ if (bit)
+ VIR_USE_CPU(cpumap, i);
+ }
+
+ map.size = cpumaplen;
+ map.map = cpumap;
+
+ if (libxl_set_vcpuaffinity(priv->ctx, def->id, vcpu, &map) != 0) {
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Failed to pin vcpu '%d' with
libxenlight"), vcpu);
+ goto cleanup;
+ }
+
+ VIR_FREE(cpumap);
+ }
+
+ ret = 0;
+
+cleanup:
+ VIR_FREE(cpumap);
+ return ret;
+}
diff --git a/src/libxl/libxl_domain.h b/src/libxl/libxl_domain.h
index a50efd3..775a91c 100644
--- a/src/libxl/libxl_domain.h
+++ b/src/libxl/libxl_domain.h
@@ -123,4 +123,8 @@ int
libxlDomainAutoCoreDump(libxlDriverPrivatePtr driver,
virDomainObjPtr vm);
+int
+libxlDomainSetVcpuAffinities(libxlDriverPrivatePtr driver,
+ virDomainObjPtr vm);
+
#endif /* LIBXL_DOMAIN_H */
diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c
index 665c740..b511383 100644
--- a/src/libxl/libxl_driver.c
+++ b/src/libxl/libxl_driver.c
@@ -305,60 +305,6 @@ const struct libxl_event_hooks ev_hooks = {
};
static int
-libxlDomainSetVcpuAffinities(libxlDriverPrivatePtr driver, virDomainObjPtr vm)
-{
- libxlDomainObjPrivatePtr priv = vm->privateData;
- virDomainDefPtr def = vm->def;
- libxl_bitmap map;
- virBitmapPtr cpumask = NULL;
- uint8_t *cpumap = NULL;
- virNodeInfo nodeinfo;
- size_t cpumaplen;
- int vcpu;
- size_t i;
- int ret = -1;
-
- if (libxlDriverNodeGetInfo(driver, &nodeinfo) < 0)
- goto cleanup;
-
- cpumaplen = VIR_CPU_MAPLEN(VIR_NODEINFO_MAXCPUS(nodeinfo));
-
- for (vcpu = 0; vcpu < def->cputune.nvcpupin; ++vcpu) {
- if (vcpu != def->cputune.vcpupin[vcpu]->vcpuid)
- continue;
-
- if (VIR_ALLOC_N(cpumap, cpumaplen) < 0)
- goto cleanup;
-
- cpumask = def->cputune.vcpupin[vcpu]->cpumask;
-
- for (i = 0; i < virBitmapSize(cpumask); ++i) {
- bool bit;
- ignore_value(virBitmapGetBit(cpumask, i, &bit));
- if (bit)
- VIR_USE_CPU(cpumap, i);
- }
-
- map.size = cpumaplen;
- map.map = cpumap;
-
- if (libxl_set_vcpuaffinity(priv->ctx, def->id, vcpu, &map) != 0) {
- virReportError(VIR_ERR_INTERNAL_ERROR,
- _("Failed to pin vcpu '%d' with
libxenlight"), vcpu);
- goto cleanup;
- }
-
- VIR_FREE(cpumap);
- }
-
- ret = 0;
-
-cleanup:
- VIR_FREE(cpumap);
- return ret;
-}
-
-static int
libxlFreeMem(libxlDomainObjPrivatePtr priv, libxl_domain_config *d_config)
{
uint32_t needed_mem;
--
1.8.1.4