From ea3891a0fc14ce15cd5b113af2795bcb426582f3 Mon Sep 17 00:00:00 2001 From: Peter Krempa Date: Thu, 15 Jan 2015 22:40:15 +0100 Subject: [PATCH] conf: numatune: Extract code for requesting memory nodeset from formatting Extract the logic to determine which nodeset has to be used for a domain from the formatting step so that it can be reused separately when the nodeset is used in a different way. --- src/conf/numatune_conf.c | 33 ++++++++++++++++++++++++++------- src/conf/numatune_conf.h | 5 +++++ src/libvirt_private.syms | 1 + 3 files changed, 32 insertions(+), 7 deletions(-) diff --git a/src/conf/numatune_conf.c b/src/conf/numatune_conf.c index 323cd59d19..7f322ea7e2 100644 --- a/src/conf/numatune_conf.c +++ b/src/conf/numatune_conf.c @@ -400,13 +400,14 @@ virDomainNumatuneFormatNodeset(virDomainNumatunePtr numatune, cellid)); } + int -virDomainNumatuneMaybeFormatNodeset(virDomainNumatunePtr numatune, - virBitmapPtr auto_nodeset, - char **mask, - int cellid) +virDomainNumatuneMaybeGetNodeset(virDomainNumatunePtr numatune, + virBitmapPtr auto_nodeset, + virBitmapPtr *retNodeset, + int cellid) { - *mask = NULL; + *retNodeset = NULL; if (!numatune) return 0; @@ -424,8 +425,26 @@ virDomainNumatuneMaybeFormatNodeset(virDomainNumatunePtr numatune, return -1; } - *mask = virDomainNumatuneFormatNodeset(numatune, auto_nodeset, cellid); - if (!*mask) + *retNodeset = virDomainNumatuneGetNodeset(numatune, auto_nodeset, cellid); + + return 0; +} + + +int +virDomainNumatuneMaybeFormatNodeset(virDomainNumatunePtr numatune, + virBitmapPtr auto_nodeset, + char **mask, + int cellid) +{ + virBitmapPtr nodeset; + + if (virDomainNumatuneMaybeGetNodeset(numatune, auto_nodeset, &nodeset, + cellid) < 0) + return -1; + + if (nodeset && + !(*mask = virBitmapFormat(nodeset))) return -1; return 0; diff --git a/src/conf/numatune_conf.h b/src/conf/numatune_conf.h index 7ca7f976f2..28c4ce255c 100644 --- a/src/conf/numatune_conf.h +++ b/src/conf/numatune_conf.h @@ -70,6 +70,11 @@ virBitmapPtr virDomainNumatuneGetNodeset(virDomainNumatunePtr numatune, virBitmapPtr auto_nodeset, int cellid); +int virDomainNumatuneMaybeGetNodeset(virDomainNumatunePtr numatune, + virBitmapPtr auto_nodeset, + virBitmapPtr *retNodeset, + int cellid); + /* * Formatters */ diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index db60813566..d8f15e9568 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -626,6 +626,7 @@ virDomainNumatuneGetNodeset; virDomainNumatuneHasPerNodeBinding; virDomainNumatuneHasPlacementAuto; virDomainNumatuneMaybeFormatNodeset; +virDomainNumatuneMaybeGetNodeset; virDomainNumatuneMemModeTypeFromString; virDomainNumatuneMemModeTypeToString; virDomainNumatuneNodesetIsAvailable;