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 323cd59..7f322ea 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 7ca7f97..28c4ce2 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 bd7870f..24fd4da 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -626,6 +626,7 @@ virDomainNumatuneGetNodeset; virDomainNumatuneHasPerNodeBinding; virDomainNumatuneHasPlacementAuto; virDomainNumatuneMaybeFormatNodeset; +virDomainNumatuneMaybeGetNodeset; virDomainNumatuneMemModeTypeFromString; virDomainNumatuneMemModeTypeToString; virDomainNumatuneNodesetIsAvailable; -- 2.2.2 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list