qemuBuildMemoryCellBackendStr: Return JSON props instead of a buffer

Rename the function to 'qemuBuildMemoryCellBackendProps' and return the
properties before conversion to commandline arguments. This requires
changes in the caller.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
Peter Krempa 2021-09-24 15:37:17 +02:00
parent acf4159556
commit d8f3fb187d

View File

@ -3188,15 +3188,13 @@ qemuBuildMemoryBackendProps(virJSONValue **backendProps,
static int static int
qemuBuildMemoryCellBackendStr(virDomainDef *def, qemuBuildMemoryCellBackendProps(virDomainDef *def,
virQEMUDriverConfig *cfg, virQEMUDriverConfig *cfg,
size_t cell, size_t cell,
qemuDomainObjPrivate *priv, qemuDomainObjPrivate *priv,
virBuffer *buf) virJSONValue **props)
{ {
g_autoptr(virJSONValue) props = NULL;
g_autofree char *alias = NULL; g_autofree char *alias = NULL;
int rc;
virDomainMemoryDef mem = { 0 }; virDomainMemoryDef mem = { 0 };
unsigned long long memsize = virDomainNumaGetNodeMemorySize(def->numa, unsigned long long memsize = virDomainNumaGetNodeMemorySize(def->numa,
cell); cell);
@ -3207,14 +3205,7 @@ qemuBuildMemoryCellBackendStr(virDomainDef *def,
mem.targetNode = cell; mem.targetNode = cell;
mem.info.alias = alias; mem.info.alias = alias;
if ((rc = qemuBuildMemoryBackendProps(&props, alias, cfg, return qemuBuildMemoryBackendProps(props, alias, cfg, priv, def, &mem, false, false);
priv, def, &mem, false, false)) < 0)
return -1;
if (qemuBuildObjectCommandlineFromJSON(buf, props, priv->qemuCaps) < 0)
return -1;
return rc;
} }
@ -7407,7 +7398,7 @@ qemuBuildNumaCommandLine(virQEMUDriverConfig *cfg,
size_t i, j; size_t i, j;
virQEMUCaps *qemuCaps = priv->qemuCaps; virQEMUCaps *qemuCaps = priv->qemuCaps;
g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER; g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
virBuffer *nodeBackends = NULL; virJSONValue **nodeBackends = NULL;
bool needBackend = false; bool needBackend = false;
bool hmat = false; bool hmat = false;
int ret = -1; int ret = -1;
@ -7427,7 +7418,7 @@ qemuBuildNumaCommandLine(virQEMUDriverConfig *cfg,
hmat = true; hmat = true;
} }
nodeBackends = g_new0(virBuffer, ncells); nodeBackends = g_new0(virJSONValue *, ncells);
/* using of -numa memdev= cannot be combined with -numa mem=, thus we /* using of -numa memdev= cannot be combined with -numa mem=, thus we
* need to check which approach to use */ * need to check which approach to use */
@ -7437,7 +7428,7 @@ qemuBuildNumaCommandLine(virQEMUDriverConfig *cfg,
int rc; int rc;
for (i = 0; i < ncells; i++) { for (i = 0; i < ncells; i++) {
if ((rc = qemuBuildMemoryCellBackendStr(def, cfg, i, priv, if ((rc = qemuBuildMemoryCellBackendProps(def, cfg, i, priv,
&nodeBackends[i])) < 0) &nodeBackends[i])) < 0)
goto cleanup; goto cleanup;
@ -7467,8 +7458,14 @@ qemuBuildNumaCommandLine(virQEMUDriverConfig *cfg,
ssize_t initiator = virDomainNumaGetNodeInitiator(def->numa, i); ssize_t initiator = virDomainNumaGetNodeInitiator(def->numa, i);
if (needBackend) { if (needBackend) {
g_auto(virBuffer) objbuf = VIR_BUFFER_INITIALIZER;
if (qemuBuildObjectCommandlineFromJSON(&objbuf, nodeBackends[i],
priv->qemuCaps) < 0)
goto cleanup;
virCommandAddArg(cmd, "-object"); virCommandAddArg(cmd, "-object");
virCommandAddArgBuffer(cmd, &nodeBackends[i]); virCommandAddArgBuffer(cmd, &objbuf);
} }
virCommandAddArg(cmd, "-numa"); virCommandAddArg(cmd, "-numa");
@ -7526,7 +7523,7 @@ qemuBuildNumaCommandLine(virQEMUDriverConfig *cfg,
cleanup: cleanup:
if (nodeBackends) { if (nodeBackends) {
for (i = 0; i < ncells; i++) for (i = 0; i < ncells; i++)
virBufferFreeAndReset(&nodeBackends[i]); virJSONValueFree(nodeBackends[i]);
VIR_FREE(nodeBackends); VIR_FREE(nodeBackends);
} }