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.
This commit is contained in:
Peter Krempa 2015-01-15 22:40:15 +01:00
parent cd7702d456
commit ea3891a0fc
3 changed files with 32 additions and 7 deletions

View File

@ -400,13 +400,14 @@ virDomainNumatuneFormatNodeset(virDomainNumatunePtr numatune,
cellid));
}
int
virDomainNumatuneMaybeFormatNodeset(virDomainNumatunePtr numatune,
virDomainNumatuneMaybeGetNodeset(virDomainNumatunePtr numatune,
virBitmapPtr auto_nodeset,
char **mask,
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;

View File

@ -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
*/

View File

@ -626,6 +626,7 @@ virDomainNumatuneGetNodeset;
virDomainNumatuneHasPerNodeBinding;
virDomainNumatuneHasPlacementAuto;
virDomainNumatuneMaybeFormatNodeset;
virDomainNumatuneMaybeGetNodeset;
virDomainNumatuneMemModeTypeFromString;
virDomainNumatuneMemModeTypeToString;
virDomainNumatuneNodesetIsAvailable;