From nobody Mon Feb 9 03:14:01 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1628177693; cv=none; d=zohomail.com; s=zohoarc; b=TM7c5VFLA5NLgxEH1NYFHwDJgR7EWnKVI/vNUqr18mGkrmZLzQ0RvB+5ha/Gjeo7dVEsyYwcI915rS0KlZ3g2qxnR6BlHIbUS2cD/clTql8pdLCNmywdZ4UfxdgSr8DHc59Su+3fpOV1q/5j+mh5FyWWGa3xUnFx5ItxuSmnv+I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1628177693; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=LpddGthPvT0S3tQedzNceyv+wJKoM3tp65SHJuIv6r8=; b=SblBmj+jJJD6N/vIVRFD/620L/fR1ix22JfuqTror+NeHABrJgxphA/0BLwvsgM/Bav6tCA86Z4Qynv/T/6pmp9e+YjdIBPqBsydVoGuBS8TKngPeyh7q9WWOSwvLReWAAl96ksP5Fuc8YUch2nSYTlvdZwHeCVX1MRg3ZW+XqE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1628177693854541.6254011509667; Thu, 5 Aug 2021 08:34:53 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-493-qqZVAuWAMzeBHrdQtiaNVw-1; Thu, 05 Aug 2021 11:34:51 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A23441B18BC6; Thu, 5 Aug 2021 15:34:45 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8020F29671; Thu, 5 Aug 2021 15:34:45 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 458F9181A2E4; Thu, 5 Aug 2021 15:34:45 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 175FYhYv027657 for ; Thu, 5 Aug 2021 11:34:43 -0400 Received: by smtp.corp.redhat.com (Postfix) id 88A735D6B1; Thu, 5 Aug 2021 15:34:43 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.33]) by smtp.corp.redhat.com (Postfix) with ESMTP id DA8D75D6A1 for ; Thu, 5 Aug 2021 15:34:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1628177692; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=LpddGthPvT0S3tQedzNceyv+wJKoM3tp65SHJuIv6r8=; b=bK75Oamyf9CbzY0Gf5axfPei5WdGPHaCclLh/xrwjKjGwBROGfzXT9pgBa91s28GU22jZf k7lcxPlh+BfA4parBHA2XHwX6L+43hfci2Y3ENYTzFDYgKygMfsMuhB+zz/5tHdXV6aHCn 4YzCmrUMdo5WAEJF9WcewKjKGRXyoZE= X-MC-Unique: qqZVAuWAMzeBHrdQtiaNVw-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 06/13] qemu: domain: Store passthrough arguments in NULL-terminated string list Date: Thu, 5 Aug 2021 17:34:22 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1628177694733100001 Content-Type: text/plain; charset="utf-8" We always process the full list so there's no value in storing the count separately. Signed-off-by: Peter Krempa --- 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 =3D def->namespaceData; - for (i =3D 0; i < qemuxmlns->num_args; i++) - virCommandAddArg(cmd, qemuxmlns->args[i]); + for (n =3D qemuxmlns->args; n && *n; n++) + virCommandAddArg(cmd, *n); for (i =3D 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(qemuDoma= inXmlNsDef *nsdef, if (nnodes =3D=3D 0) return 0; - nsdef->args =3D g_new0(char *, nnodes); + nsdef->args =3D g_new0(char *, nnodes + 1); for (i =3D 0; i < nnodes; i++) { - if (!(nsdef->args[nsdef->num_args++] =3D virXMLPropString(nodes[i]= , "value"))) { + if (!(nsdef->args[i] =3D 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 =3D virXPathString("string(./qemu:deprecat= ion/@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 =3D 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, "\n"); virBufferAdjustIndent(buf, 2); - for (i =3D 0; i < cmd->num_args; i++) - virBufferEscapeString(buf, "\n", - cmd->args[i]); + for (n =3D cmd->args; n && *n; n++) + virBufferEscapeString(buf, "\n", *n); for (i =3D 0; i < cmd->num_env; i++) { virBufferAsprintf(buf, "env[i].name); virBufferEscapeString(buf, " value=3D'%s'", cmd->env[i].value); @@ -6614,7 +6614,7 @@ void qemuDomainObjCheckTaint(virQEMUDriver *driver, if (obj->def->namespaceData) { qemuDomainXmlNsDef *qemuxmlns =3D 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 =3D 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; --=20 2.31.1