[PATCH 3/5] conf: Support NUMA tuning XML

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

 



E.g.

<numatune>
  <membind nodeset='+0-4,8-12'/>
</numatune>
---
 src/conf/domain_conf.c |   42 +++++++++++++++++++++++++++++++++++++++++-
 src/conf/domain_conf.h |   11 +++++++++++
 2 files changed, 52 insertions(+), 1 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 2a681d9..fbf5f81 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -48,6 +48,11 @@
 #include "files.h"
 #include "bitmap.h"
 
+#if HAVE_NUMACTL
+# include <numa.h>
+#endif
+
+
 #define VIR_FROM_THIS VIR_FROM_DOMAIN
 
 VIR_ENUM_IMPL(virDomainVirt, VIR_DOMAIN_VIRT_LAST,
@@ -5530,6 +5535,29 @@ static virDomainDefPtr virDomainDefParseXML(virCapsPtr caps,
     }
     VIR_FREE(nodes);
 
+    /* Extract numatune if exists. */
+    if ((n = virXPathNodeSet("./numatune", ctxt, NULL)) < 0) {
+        virDomainReportError(VIR_ERR_INTERNAL_ERROR,
+                             "%s", _("cannot extract numatune nodes"));
+        goto error;
+    }
+
+    if (n) {
+#ifdef HAVE_NUMACTL
+        if (numa_available() < 0) {
+            virDomainReportError(VIR_ERR_INTERNAL_ERROR,
+                                 "%s", _("Host kernel is not aware of NUMA."));
+            goto error;
+        }
+
+        def->numatune.membind.nodeset = virXPathString("string(./numatune/membind/@nodeset)", ctxt);
+#else
+        virDomainReportError(VIR_ERR_INTERNAL_ERROR,
+                             "%s", _("libvirt is compiled without NUMA tuning support"));
+        goto error;
+#endif
+    }
+
     n = virXPathNodeSet("./features/*", ctxt, &nodes);
     if (n < 0)
         goto error;
@@ -6020,7 +6048,6 @@ static virDomainDefPtr virDomainDefParseXML(virCapsPtr caps,
         def->ninputs++;
     }
 
-
     /* analysis of the sound devices */
     if ((n = virXPathNodeSet("./devices/sound", ctxt, &nodes)) < 0) {
         virDomainReportError(VIR_ERR_INTERNAL_ERROR,
@@ -8175,6 +8202,19 @@ char *virDomainDefFormat(virDomainDefPtr def,
     if (def->cputune.shares || def->cputune.vcpupin)
         virBufferAddLit(&buf, "  </cputune>\n");
 
+#ifdef HAVE_NUMACTL
+    if (def->numatune.membind.nodeset) {
+        virBufferAddLit(&buf, "  <numatune>\n");
+    }
+
+    if (def->numatune.membind.nodeset)
+            virBufferVSprintf(&buf, "    <membind nodeset='%s'/>\n",
+                              def->numatune.membind.nodeset);
+
+    if (def->numatune.membind.nodeset)
+        virBufferAddLit(&buf, "  </numatune>\n");
+#endif
+
     if (def->sysinfo)
         virDomainSysinfoDefFormat(&buf, def->sysinfo);
 
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 1dadf98..61c7d65 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -1085,6 +1085,15 @@ int virDomainVcpupinIsDuplicate(virDomainVcpupinDefPtr *def,
 virDomainVcpupinDefPtr virDomainVcpupinFindByVcpu(virDomainVcpupinDefPtr *def,
                                                   int nvcpupin,
                                                   int vcpu);
+typedef struct _virDomainNumatuneDef virDomainNumatuneDef;
+typedef virDomainNumatuneDef *virDomainNumatuneDefPtr;
+struct _virDomainNumatuneDef {
+    struct {
+        char *nodeset;
+    } membind;
+
+    /* Future NUMA tuning related stuff should go here. */
+};
 
 /* Guest VM main configuration */
 typedef struct _virDomainDef virDomainDef;
@@ -1120,6 +1129,8 @@ struct _virDomainDef {
         virDomainVcpupinDefPtr *vcpupin;
     } cputune;
 
+    virDomainNumatuneDef numatune;
+
     /* These 3 are based on virDomainLifeCycleAction enum flags */
     int onReboot;
     int onPoweroff;
-- 
1.7.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]