[PATCH V2 08/13] libxl: move libxlDomainSetVcpuAffinities to libxl_domain

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Move libxlDomainSetVcpuAffinities from libxl_driver to libxl_domain
for use by other libxl modules.

Signed-off-by: Jim Fehlig <jfehlig@xxxxxxxx>
---
 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 dceba9f..afe891f 100644
--- a/src/libxl/libxl_domain.c
+++ b/src/libxl/libxl_domain.c
@@ -799,3 +799,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 36e3e25..80b9e93 100644
--- a/src/libxl/libxl_driver.c
+++ b/src/libxl/libxl_driver.c
@@ -308,60 +308,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

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]