On 2013年03月01日 14:52, Gao feng wrote:
qemuGetNumadAdvice will be used by LXC driver,rename it to virGetNumaAdvice and move it to virnuma.c
s/virGetNumaAdvice/virGetNumadAdvice/,
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 | 33 ++------------------------ src/util/virnuma.c | 60 ++++++++++++++++++++++++++++++++++++++++++++++++ src/util/virnuma.h | 28 ++++++++++++++++++++++ 6 files changed, 95 insertions(+), 31 deletions(-) create mode 100644 src/util/virnuma.c create mode 100644 src/util/virnuma.h diff --git a/po/POTFILES.in b/po/POTFILES.in index bd2c02e..ee8ff86 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -164,6 +164,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 a/src/Makefile.am b/src/Makefile.am index c1659a4..21eb84a 100644 --- a/src/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 \
Please use tab to align the "\".
util/virobject.c util/virobject.h \ util/virpci.c util/virpci.h \ util/virpidfile.c util/virpidfile.h \ diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index ed46479..6aee6fa 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -1565,6 +1565,9 @@ nodeSuspendForDuration; virNodeSuspendGetTargetMask; +# util/virnuma.h +virGetNumadAdvice; + # util/virobject.h virClassForObject; virClassForObjectLockable; diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index db95d6e..20d41e3 100644 --- a/src/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 @@ -1981,36 +1982,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 @@ -3721,7 +3692,7 @@ 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 = virGetNumadAdvice(vm->def->vcpus, vm->def->mem.cur_balloon); if (!nodeset) goto cleanup; diff --git a/src/util/virnuma.c b/src/util/virnuma.c new file mode 100644 index 0000000..37931fe --- /dev/null +++ b/src/util/virnuma.c @@ -0,0 +1,60 @@ +/* + * virnuma.c: helper APIS for managing numa
s/APIS/APIs/,
+ * + * 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 *virGetNumadAdvice(unsigned short vcpus, + unsigned long long balloon)
char * virGetNumadAdvice(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 * +virGetNumadAdvice(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 a/src/util/virnuma.h b/src/util/virnuma.h new file mode 100644 index 0000000..b9046c2 --- /dev/null +++ b/src/util/virnuma.h @@ -0,0 +1,28 @@ +/* + * virnuma.h: helper APIS for managing numa
s/APIS/APIs/,
+ * + * 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 *virGetNumadAdvice(unsigned short vcups, + unsigned long long balloon); + +#endif /* __VIR_NUMA_H__ */
ACK with the small nits fixed. It's good to have virnuma.{h,c} for numa stuffs, I guess now we can move many codes into it. Osier -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list