We always process the full list so there's no value in storing the count
separately.
Signed-off-by: Peter Krempa <pkrempa(a)redhat.com>
---
src/qemu/qemu_command.c | 5 +++--
src/qemu/qemu_domain.c | 18 +++++++++---------
src/qemu/qemu_domain.h | 1 -
3 files changed, 12 insertions(+), 12 deletions(-)
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 4bcb5a3146..ecfed19432 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -10633,10 +10633,11 @@ qemuBuildCommandLine(virQEMUDriver *driver,
if (def->namespaceData) {
qemuDomainXmlNsDef *qemuxmlns;
+ GStrv n;
qemuxmlns = def->namespaceData;
- for (i = 0; i < qemuxmlns->num_args; i++)
- virCommandAddArg(cmd, qemuxmlns->args[i]);
+ for (n = qemuxmlns->args; n && *n; n++)
+ virCommandAddArg(cmd, *n);
for (i = 0; i < qemuxmlns->num_env; i++)
virCommandAddEnvPair(cmd, qemuxmlns->env[i].name,
NULLSTR_EMPTY(qemuxmlns->env[i].value));
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index b2cbd3d6ba..f5d4db33bf 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -3329,7 +3329,7 @@ qemuDomainXmlNsDefFree(qemuDomainXmlNsDef *def)
g_free(def->env[i].value);
}
- virStringListFreeCount(def->args, def->num_args);
+ g_strfreev(def->args);
g_strfreev(def->capsadd);
g_strfreev(def->capsdel);
@@ -3362,10 +3362,10 @@ qemuDomainDefNamespaceParseCommandlineArgs(qemuDomainXmlNsDef
*nsdef,
if (nnodes == 0)
return 0;
- nsdef->args = g_new0(char *, nnodes);
+ nsdef->args = g_new0(char *, nnodes + 1);
for (i = 0; i < nnodes; i++) {
- if (!(nsdef->args[nsdef->num_args++] = virXMLPropString(nodes[i],
"value"))) {
+ if (!(nsdef->args[i] = virXMLPropString(nodes[i], "value"))) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("No qemu command-line argument specified"));
return -1;
@@ -3490,7 +3490,7 @@ qemuDomainDefNamespaceParse(xmlXPathContextPtr ctxt,
nsdata->deprecationBehavior =
virXPathString("string(./qemu:deprecation/@behavior)", ctxt);
- if (nsdata->num_args > 0 || nsdata->num_env > 0 ||
+ if (nsdata->args || nsdata->num_env > 0 ||
nsdata->capsadd || nsdata->capsdel ||
nsdata->deprecationBehavior)
*data = g_steal_pointer(&nsdata);
@@ -3507,17 +3507,17 @@ static void
qemuDomainDefNamespaceFormatXMLCommandline(virBuffer *buf,
qemuDomainXmlNsDef *cmd)
{
+ GStrv n;
size_t i;
- if (!cmd->num_args && !cmd->num_env)
+ if (!cmd->args && !cmd->num_env)
return;
virBufferAddLit(buf, "<qemu:commandline>\n");
virBufferAdjustIndent(buf, 2);
- for (i = 0; i < cmd->num_args; i++)
- virBufferEscapeString(buf, "<qemu:arg value='%s'/>\n",
- cmd->args[i]);
+ for (n = cmd->args; n && *n; n++)
+ virBufferEscapeString(buf, "<qemu:arg value='%s'/>\n",
*n);
for (i = 0; i < cmd->num_env; i++) {
virBufferAsprintf(buf, "<qemu:env name='%s'",
cmd->env[i].name);
virBufferEscapeString(buf, " value='%s'",
cmd->env[i].value);
@@ -6614,7 +6614,7 @@ void qemuDomainObjCheckTaint(virQEMUDriver *driver,
if (obj->def->namespaceData) {
qemuDomainXmlNsDef *qemuxmlns = obj->def->namespaceData;
- if (qemuxmlns->num_args || qemuxmlns->num_env)
+ if (qemuxmlns->args || qemuxmlns->num_env)
qemuDomainObjTaint(driver, obj, VIR_DOMAIN_TAINT_CUSTOM_ARGV, logCtxt);
if (qemuxmlns->capsadd || qemuxmlns->capsdel)
custom_hypervisor_feat = true;
diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h
index aa3ed78094..3cfa6cd44e 100644
--- a/src/qemu/qemu_domain.h
+++ b/src/qemu/qemu_domain.h
@@ -465,7 +465,6 @@ struct _qemuDomainXmlNsEnvTuple {
typedef struct _qemuDomainXmlNsDef qemuDomainXmlNsDef;
struct _qemuDomainXmlNsDef {
- size_t num_args;
char **args;
unsigned int num_env;
--
2.31.1