[PATCH v3 1/4] rename qemuGetNumadAdvice to virNumaGetAutoPlacementAdvice

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

 



qemuGetNumadAdvice will be used by LXC driver,rename
it to virNumaGetAutoPlacementAdvice and move it to virnuma.c

Signed-off-by: Gao feng <gaofeng@xxxxxxxxxxxxxx>
---
 po/POTFILES.in           |  1 +
 src/Makefile.am          |  1 +
 src/libvirt_private.syms |  3 +++
 src/qemu/qemu_process.c  | 34 +++------------------------
 src/util/virnuma.c       | 61 ++++++++++++++++++++++++++++++++++++++++++++++++
 src/util/virnuma.h       | 28 ++++++++++++++++++++++
 6 files changed, 97 insertions(+), 31 deletions(-)
 create mode 100644 src/util/virnuma.c
 create mode 100644 src/util/virnuma.h

diff --git PATCH v3po/POTFILES.in b/po/POTFILES.in
index 5b5c3c2..771e83f 100644
--- PATCH v3po/POTFILES.in	
+++ b/po/POTFILES.in
@@ -165,6 +165,7 @@ src/util/virnetdevtap.c
 src/util/virnetdevvportprofile.c
 src/util/virnetlink.c
 src/util/virnodesuspend.c
+src/util/virnuma.c
 src/util/virobject.c
 src/util/virpci.c
 src/util/virpidfile.c
diff --git PATCH v3src/Makefile.am b/src/Makefile.am
index 8b591d2..2db03cb 100644
--- PATCH v3src/Makefile.am	
+++ b/src/Makefile.am
@@ -103,6 +103,7 @@ UTIL_SOURCES =							\
 		util/virnetdevvportprofile.h util/virnetdevvportprofile.c \
 		util/virnetlink.c util/virnetlink.h		\
 		util/virnodesuspend.c util/virnodesuspend.h	\
+		util/virnuma.c util/virnuma.h			\
 		util/virobject.c util/virobject.h		\
 		util/virpci.c util/virpci.h			\
 		util/virpidfile.c util/virpidfile.h		\
diff --git PATCH v3src/libvirt_private.syms b/src/libvirt_private.syms
index 5cad990..1374470 100644
--- PATCH v3src/libvirt_private.syms	
+++ b/src/libvirt_private.syms
@@ -1545,6 +1545,9 @@ nodeSuspendForDuration;
 virNodeSuspendGetTargetMask;
 
 
+# util/virnuma.h
+virNumaGetAutoPlacementAdvice;
+
 # util/virobject.h
 virClassForObject;
 virClassForObjectLockable;
diff --git PATCH v3src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index 1941d4e..96ba70a 100644
--- PATCH v3src/qemu/qemu_process.c	
+++ b/src/qemu/qemu_process.c
@@ -70,6 +70,7 @@
 #include "virnetdevtap.h"
 #include "virbitmap.h"
 #include "viratomic.h"
+#include "virnuma.h"
 
 #define VIR_FROM_THIS VIR_FROM_QEMU
 
@@ -1903,36 +1904,6 @@ qemuProcessInitNumaMemoryPolicy(virDomainObjPtr vm,
 }
 #endif
 
-#if HAVE_NUMAD
-static char *
-qemuGetNumadAdvice(virDomainDefPtr def)
-{
-    virCommandPtr cmd = NULL;
-    char *output = NULL;
-
-    cmd = virCommandNewArgList(NUMAD, "-w", NULL);
-    virCommandAddArgFormat(cmd, "%d:%llu", def->vcpus,
-                           VIR_DIV_UP(def->mem.cur_balloon, 1024));
-
-    virCommandSetOutputBuffer(cmd, &output);
-
-    if (virCommandRun(cmd, NULL) < 0)
-        virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
-                       _("Failed to query numad for the "
-                         "advisory nodeset"));
-
-    virCommandFree(cmd);
-    return output;
-}
-#else
-static char *
-qemuGetNumadAdvice(virDomainDefPtr def ATTRIBUTE_UNUSED)
-{
-    virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
-                   _("numad is not available on this host"));
-    return NULL;
-}
-#endif
 
 /* Helper to prepare cpumap for affinity setting, convert
  * NUMA nodeset into cpuset if @nodemask is not NULL, otherwise
@@ -3637,7 +3608,8 @@ int qemuProcessStart(virConnectPtr conn,
          VIR_DOMAIN_CPU_PLACEMENT_MODE_AUTO) ||
         (vm->def->numatune.memory.placement_mode ==
          VIR_DOMAIN_NUMATUNE_MEM_PLACEMENT_MODE_AUTO)) {
-        nodeset = qemuGetNumadAdvice(vm->def);
+        nodeset = virNumaGetAutoPlacementAdvice(vm->def->vcpus,
+                                                vm->def->mem.cur_balloon);
         if (!nodeset)
             goto cleanup;
 
diff --git PATCH v3src/util/virnuma.c b/src/util/virnuma.c
new file mode 100644
index 0000000..f6a6eb2
--- /dev/null
+++ b/src/util/virnuma.c
@@ -0,0 +1,61 @@
+/*
+ * virnuma.c: helper APIs for managing numa
+ *
+ * Copyright (C) 2011-2013 Red Hat, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library.  If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include <config.h>
+
+#include "virnuma.h"
+#include "vircommand.h"
+#include "virerror.h"
+
+#define VIR_FROM_THIS VIR_FROM_NONE
+
+#if HAVE_NUMAD
+char *
+virNumaGetAutoPlacementAdvice(unsigned short vcpus,
+                              unsigned long long balloon)
+{
+    virCommandPtr cmd = NULL;
+    char *output = NULL;
+
+    cmd = virCommandNewArgList(NUMAD, "-w", NULL);
+    virCommandAddArgFormat(cmd, "%d:%llu", vcpus,
+                           VIR_DIV_UP(balloon, 1024));
+
+    virCommandSetOutputBuffer(cmd, &output);
+
+    if (virCommandRun(cmd, NULL) < 0)
+        virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+                       _("Failed to query numad for the "
+                         "advisory nodeset"));
+
+    virCommandFree(cmd);
+    return output;
+}
+#else
+char *
+virNumaGetAutoPlacementAdvice(unsigned short vcpus ATTRIBUTE_UNUSED,
+                              unsigned long long balloon ATTRIBUTE_UNUSED)
+{
+    virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+                   _("numad is not available on this host"));
+    return NULL;
+}
+#endif
diff --git PATCH v3src/util/virnuma.h b/src/util/virnuma.h
new file mode 100644
index 0000000..d3d7d3e
--- /dev/null
+++ b/src/util/virnuma.h
@@ -0,0 +1,28 @@
+/*
+ * virnuma.h: helper APIs for managing numa
+ *
+ * Copyright (C) 2011-2013 Red Hat, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library.  If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifndef __VIR_NUMA_H__
+# define __VIR_NUMA_H__
+
+char *virNumaGetAutoPlacementAdvice(unsigned short vcups,
+                                    unsigned long long balloon);
+
+#endif /* __VIR_NUMA_H__ */
-- 
1.7.11.7

--
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]