mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-03-07 17:28:15 +00:00
conf: numa: Always allocate the NUMA config
Since our formatter now handles well if the config is allocated and not filled we can safely always-allocate the NUMA config and remove the ad-hoc allocation code. This will help in later patches as the parser will be refactored to just fill the data.
This commit is contained in:
parent
c03411199e
commit
21008c013c
@ -2319,9 +2319,17 @@ virDomainDefNew(void)
|
||||
{
|
||||
virDomainDefPtr ret;
|
||||
|
||||
ignore_value(VIR_ALLOC(ret));
|
||||
if (VIR_ALLOC(ret) < 0)
|
||||
return NULL;
|
||||
|
||||
if (!(ret->numa = virDomainNumaNew()))
|
||||
goto error;
|
||||
|
||||
return ret;
|
||||
|
||||
error:
|
||||
virDomainDefFree(ret);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
|
@ -117,11 +117,6 @@ virDomainNumatuneNodeParseXML(virDomainNumaPtr *numatunePtr,
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
if (!numatune && VIR_ALLOC(numatune) < 0)
|
||||
goto cleanup;
|
||||
|
||||
*numatunePtr = numatune;
|
||||
|
||||
VIR_FREE(numatune->mem_nodes);
|
||||
if (VIR_ALLOC_N(numatune->mem_nodes, ncells) < 0)
|
||||
goto cleanup;
|
||||
@ -224,11 +219,6 @@ virDomainNumatuneParseXML(virDomainNumaPtr *numatunePtr,
|
||||
|
||||
node = virXPathNode("./numatune/memory[1]", ctxt);
|
||||
|
||||
if (*numatunePtr) {
|
||||
virDomainNumaFree(*numatunePtr);
|
||||
*numatunePtr = NULL;
|
||||
}
|
||||
|
||||
if (!placement_static && !node)
|
||||
placement = VIR_DOMAIN_NUMATUNE_PLACEMENT_AUTO;
|
||||
|
||||
@ -454,27 +444,20 @@ virDomainNumatuneSet(virDomainNumaPtr *numatunePtr,
|
||||
int mode,
|
||||
virBitmapPtr nodeset)
|
||||
{
|
||||
bool created = false;
|
||||
int ret = -1;
|
||||
virDomainNumaPtr numatune;
|
||||
virDomainNumaPtr numatune = *numatunePtr;
|
||||
|
||||
/* No need to do anything in this case */
|
||||
if (mode == -1 && placement == -1 && !nodeset)
|
||||
return 0;
|
||||
|
||||
if (!(*numatunePtr)) {
|
||||
if (VIR_ALLOC(*numatunePtr) < 0)
|
||||
goto cleanup;
|
||||
|
||||
created = true;
|
||||
if (!numatune->memory.specified) {
|
||||
if (mode == -1)
|
||||
mode = VIR_DOMAIN_NUMATUNE_MEM_STRICT;
|
||||
if (placement == -1)
|
||||
placement = VIR_DOMAIN_NUMATUNE_PLACEMENT_DEFAULT;
|
||||
}
|
||||
|
||||
numatune = *numatunePtr;
|
||||
|
||||
/* Range checks */
|
||||
if (mode != -1 &&
|
||||
(mode < 0 || mode >= VIR_DOMAIN_NUMATUNE_MEM_LAST)) {
|
||||
@ -534,11 +517,6 @@ virDomainNumatuneSet(virDomainNumaPtr *numatunePtr,
|
||||
ret = 0;
|
||||
|
||||
cleanup:
|
||||
if (ret < 0 && created) {
|
||||
virDomainNumaFree(*numatunePtr);
|
||||
*numatunePtr = NULL;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -827,3 +805,14 @@ virDomainNumaGetCPUCountTotal(virCPUDefPtr numa)
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
virDomainNumaPtr
|
||||
virDomainNumaNew(void)
|
||||
{
|
||||
virDomainNumaPtr ret = NULL;
|
||||
|
||||
ignore_value(VIR_ALLOC(ret));
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
@ -56,6 +56,7 @@ typedef enum {
|
||||
|
||||
VIR_ENUM_DECL(virNumaMemAccess)
|
||||
|
||||
virDomainNumaPtr virDomainNumaNew(void);
|
||||
void virDomainNumaFree(virDomainNumaPtr numa);
|
||||
|
||||
/*
|
||||
|
@ -629,6 +629,7 @@ virNodeDeviceObjUnlock;
|
||||
# conf/numa_conf.h
|
||||
virDomainNumaEquals;
|
||||
virDomainNumaFree;
|
||||
virDomainNumaNew;
|
||||
virDomainNumatuneFormatNodeset;
|
||||
virDomainNumatuneFormatXML;
|
||||
virDomainNumatuneGetMode;
|
||||
|
Loading…
x
Reference in New Issue
Block a user