From nobody Sun May 5 07:48:57 2024 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=1628177686; cv=none; d=zohomail.com; s=zohoarc; b=HfJTqJlb27xIyv4N1boiIF5aAtM0hfmfXU0DkG/Stz8ygh2eV43Q6VoWyV73Q1dWwESezrX9CwGzGOAK8iB0YnfESKgK1nV9jQYJlyBNWjiFDpHB02AL0T2DfANuhqpVrBMx5GV6f6QVb3YQ2rKvjScZcqFrghmMa0spZZk8W7Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1628177686; 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=ArUCoCm0aJTcAqds/XlFliw7I1hHM4//5sV4EycVjWI=; b=MRrGnY5Jp5q1Vr5lRwe1DzQPHR7LtbjjDtBwACNHHZP+gDCszB19HIljg15spXttxQ2srM4EyXJFwqUpa/gYOqW1NxoCDWEqK2URbFDIzYvBHWVaX+bSRRX2ElPBhUijG06wE5ujWY8yo0HfHsDXkEoDPHOo9SmH0T45XYKpLM4= 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 1628177686916310.6742445614219; Thu, 5 Aug 2021 08:34:46 -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-421-PtG8DPXFP4eVOZNk17PRWw-1; Thu, 05 Aug 2021 11:34:44 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 7675E871827; Thu, 5 Aug 2021 15:34:38 +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 55D8760CC9; Thu, 5 Aug 2021 15:34:38 +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 1DC33181A2A5; Thu, 5 Aug 2021 15:34:38 +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 175FYZ1s027603 for ; Thu, 5 Aug 2021 11:34:35 -0400 Received: by smtp.corp.redhat.com (Postfix) id B1BFD18401; Thu, 5 Aug 2021 15:34:35 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.33]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1C7735D6B1 for ; Thu, 5 Aug 2021 15:34:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1628177685; 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=ArUCoCm0aJTcAqds/XlFliw7I1hHM4//5sV4EycVjWI=; b=Fwqehl5sfLBf9ULiqtWHx/1H8YuIBGFn6lmLckXZzarNRW4yUlQzqjakZqGAKAiFiYE/3T FDvrDdpbefM0hnjLv/OCn6kHdF8+1/hTzZVSlqnEEBqQ2U44InWllaj7PT52mvEf8G8ufv dH8hWQNcZsry+PZKDTLOEaaTFyzrzNQ= X-MC-Unique: PtG8DPXFP4eVOZNk17PRWw-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 01/13] testQemuAgentSSHKeys: Refactor cleanup Date: Thu, 5 Aug 2021 17:34:17 +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.12 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: 1628177688251100001 Content-Type: text/plain; charset="utf-8" Use automatic memory freeing for the 'qemuMonitorTest' object and the list of keys so that the cleanup section can be removed. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- tests/qemuagenttest.c | 54 ++++++++++++++++++------------------------- 1 file changed, 23 insertions(+), 31 deletions(-) diff --git a/tests/qemuagenttest.c b/tests/qemuagenttest.c index e0d2575c45..a447c93494 100644 --- a/tests/qemuagenttest.c +++ b/tests/qemuagenttest.c @@ -39,16 +39,15 @@ static int testQemuAgentSSHKeys(const void *data) { virDomainXMLOption *xmlopt =3D (virDomainXMLOption *)data; - qemuMonitorTest *test =3D qemuMonitorTestNewAgent(xmlopt); - char **keys =3D NULL; + g_autoptr(qemuMonitorTest) test =3D qemuMonitorTestNewAgent(xmlopt); + g_auto(GStrv) keys =3D NULL; int nkeys =3D 0; - int ret =3D -1; if (!test) return -1; if (qemuMonitorTestAddAgentSyncResponse(test) < 0) - goto cleanup; + return -1; if (qemuMonitorTestAddItem(test, "guest-ssh-get-authorized-keys", "{\"return\": {" @@ -57,59 +56,52 @@ testQemuAgentSSHKeys(const void *data) " \"algo2 key2 comments2\"" " ]" "}}") < 0) - goto cleanup; + return -1; if (qemuMonitorTestAddAgentSyncResponse(test) < 0) - goto cleanup; + return -1; if (qemuMonitorTestAddItem(test, "guest-ssh-add-authorized-keys", "{ \"return\" : {} }") < 0) - goto cleanup; + return -1; if (qemuMonitorTestAddAgentSyncResponse(test) < 0) - goto cleanup; + return -1; if (qemuMonitorTestAddItem(test, "guest-ssh-remove-authorized-keys", "{ \"return\" : {} }") < 0) - goto cleanup; + return -1; if ((nkeys =3D qemuAgentSSHGetAuthorizedKeys(qemuMonitorTestGetAgent(t= est), "user", &keys)) < 0) - goto cleanup; + return -1; if (nkeys !=3D 2) { virReportError(VIR_ERR_INTERNAL_ERROR, "expected 2 keys, got %d", nkeys); - ret =3D -1; - goto cleanup; + return -1; } if (STRNEQ(keys[1], "algo2 key2 comments2")) { virReportError(VIR_ERR_INTERNAL_ERROR, "Unexpected key returned: %= s", keys[1]); - ret =3D -1; - goto cleanup; + return -1; } - if ((ret =3D qemuAgentSSHAddAuthorizedKeys(qemuMonitorTestGetAgent(tes= t), - "user", - (const char **) keys, - nkeys, - true)) < 0) - goto cleanup; - - if ((ret =3D qemuAgentSSHRemoveAuthorizedKeys(qemuMonitorTestGetAgent(= test), - "user", - (const char **) keys, - nkeys)) < 0) - goto cleanup; + if (qemuAgentSSHAddAuthorizedKeys(qemuMonitorTestGetAgent(test), + "user", + (const char **) keys, + nkeys, + true) < 0) + return -1; - ret =3D 0; + if (qemuAgentSSHRemoveAuthorizedKeys(qemuMonitorTestGetAgent(test), + "user", + (const char **) keys, + nkeys) < 0) + return -1; - cleanup: - virStringListFreeCount(keys, nkeys); - qemuMonitorTestFree(test); - return ret; + return 0; } --=20 2.31.1 From nobody Sun May 5 07:48:57 2024 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=XEVJJN2N4ROickgGvInTBo7RZFU8AsPjZ/DHi8q7mGp9Xpeg3N+NEB8lqk75wfLeGM824ImlgO7MHx9P3Ndg9ZkUhLo5+mGdQAGU7SA84sekTWX0QLZIaRsPSoWF/jJ+I1qmNU8gRV8JyTH+JV6n5idp9+KDFQ6VlWTz27WR5Tc= 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=GQFvJx9NRGiWQAyMxIJhxH5GGiBgeSjMKmum7fSMgxo=; b=BtLo4pALTvfvKnumNzrSPg7w91Fq6hw0OZh/UOziB4Fbn97mWKdTWcQ6hgf6XCKORug3dFoUSlPFftxIKY9kGHiXhBxrsVblMpy+VRJDIaTPUodfwVEdPTZxIhyg9eoGUckck+uM1FIMZXH8feBBz7AB02CnyLgPqSIvQLRlhkI= 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 1628177693581608.0512220038669; 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-351-3IIZ-UpSO3OT4RS0mTGDQA-1; Thu, 05 Aug 2021 11:34:51 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 63CC7100CA8B; Thu, 5 Aug 2021 15:34:42 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 25DCD6A056; Thu, 5 Aug 2021 15:34:42 +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 E47674BB7C; Thu, 5 Aug 2021 15:34:41 +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 175FYdKd027621 for ; Thu, 5 Aug 2021 11:34:39 -0400 Received: by smtp.corp.redhat.com (Postfix) id 427BD18401; Thu, 5 Aug 2021 15:34:39 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.33]) by smtp.corp.redhat.com (Postfix) with ESMTP id 988E25D6B1 for ; Thu, 5 Aug 2021 15:34:35 +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=GQFvJx9NRGiWQAyMxIJhxH5GGiBgeSjMKmum7fSMgxo=; b=ePkhmkPzbiFwJGsFR/7ZO6CANkzx4T/SkYPrlzHcRxKjvyaLDqY4fEJYtkZz58tnrkZ9Es 4jdWRF7dGbAFUdvzwdEP9ftG81lUeWGABehIUTZpBNL2zsyfcVRi3KoyWwMWNh11hjp8Ok 4ok57PEQ99BLTNjeCsNsQixmXBj9rQM= X-MC-Unique: 3IIZ-UpSO3OT4RS0mTGDQA-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 02/13] remote: dispatch: Don't use virStringListFreeCount for NULL terminated lists Date: Thu, 5 Aug 2021 17:34:18 +0200 Message-Id: <9160053a9572f2b2c2514261a38b1f484a402571.1628176883.git.pkrempa@redhat.com> 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.13 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: 1628177694763100002 Content-Type: text/plain; charset="utf-8" Both virDomainAuthorizedSSHKeysGet and virDomainGetMessages return a NULL-terminated string-list, so we can use g_auto(GStrv) to clear the used memory on failures. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/remote/remote_daemon_dispatch.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/remote/remote_daemon_dispatch.c b/src/remote/remote_daemon= _dispatch.c index 99ae25c5f7..d43306d4c9 100644 --- a/src/remote/remote_daemon_dispatch.c +++ b/src/remote/remote_daemon_dispatch.c @@ -7253,7 +7253,7 @@ remoteDispatchDomainAuthorizedSshKeysGet(virNetServer= *server G_GNUC_UNUSED, int rv =3D -1; virConnectPtr conn =3D remoteGetHypervisorConn(client); int nkeys =3D 0; - char **keys =3D NULL; + g_auto(GStrv) keys =3D NULL; virDomainPtr dom =3D NULL; if (!conn) @@ -7281,8 +7281,6 @@ remoteDispatchDomainAuthorizedSshKeysGet(virNetServer= *server G_GNUC_UNUSED, cleanup: if (rv < 0) virNetMessageSaveError(rerr); - if (nkeys > 0) - virStringListFreeCount(keys, nkeys); virObjectUnref(dom); return rv; @@ -7335,7 +7333,7 @@ remoteDispatchDomainGetMessages(virNetServer *server = G_GNUC_UNUSED, int rv =3D -1; virConnectPtr conn =3D remoteGetHypervisorConn(client); int nmsgs =3D 0; - char **msgs =3D NULL; + g_auto(GStrv) msgs =3D NULL; virDomainPtr dom =3D NULL; if (!conn) @@ -7362,8 +7360,6 @@ remoteDispatchDomainGetMessages(virNetServer *server = G_GNUC_UNUSED, cleanup: if (rv < 0) virNetMessageSaveError(rerr); - if (nmsgs > 0) - virStringListFreeCount(msgs, nmsgs); virObjectUnref(dom); return rv; --=20 2.31.1 From nobody Sun May 5 07:48:57 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.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 170.10.133.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=1628177689; cv=none; d=zohomail.com; s=zohoarc; b=lxBAMPO1GPU1fSAFevQ9HGt5ZJPH6v0rogkYCA1FT8/qgHiZGbPrmgN2zcSGq6/nQmrDcOL0FksnSeLDG/yLE4k7fB9G0Tds/s6CIBF0DXTmiz5gL2Jwmi2Md60m3YOUAydbpogI48E6Y6VzQIEsyM2nguWtfxRvDBhdI65JVIo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1628177689; 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=c86KER+L4NWUorZ8AYp5oyz/nduHiuUTHyFIN0xaC6U=; b=eIMoA5QNi3qOQ4nEoMOKRDey+x99I3f/DgolW1hSwzDRvC4gufEeaTj/47g5QPKLbK6j/l2pS5Hgmih9db8CWjc07HR/CG9KWpW8TsWga+/IhiNklIUo7wB4dK7bjhfizYkQcdTchvZFUAvIbbEDvO5ScmVd6gPxmIFSPRPJ6lU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.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 [170.10.133.124]) by mx.zohomail.com with SMTPS id 162817768967399.9878577992489; Thu, 5 Aug 2021 08:34:49 -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-352-rkknW-SWO-6M9oI77WRsbQ-1; Thu, 05 Aug 2021 11:34:47 -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 B53EB802928; Thu, 5 Aug 2021 15:34:41 +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 9112C5D9DE; Thu, 5 Aug 2021 15:34:41 +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 59C2B181A2AA; Thu, 5 Aug 2021 15:34:41 +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 175FYetm027627 for ; Thu, 5 Aug 2021 11:34:40 -0400 Received: by smtp.corp.redhat.com (Postfix) id 552725D6B1; Thu, 5 Aug 2021 15:34:40 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.33]) by smtp.corp.redhat.com (Postfix) with ESMTP id B030F5D6A1 for ; Thu, 5 Aug 2021 15:34:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1628177688; 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=c86KER+L4NWUorZ8AYp5oyz/nduHiuUTHyFIN0xaC6U=; b=Qa9SEMUXker/BVhMa4GLoB1aMTLLvQEA0iJTHERlcbSKcPaVtCC5Drb3qChsxn8WjP2ls+ BA9pSEsykJeH8ceLKowFuYCAopraVaHGnwApssLQgX68C/f0EToyX6NvOel/thRwje8wqj VelYjkUw/kCsrzHvKSqH5xhdQlcgXWM= X-MC-Unique: rkknW-SWO-6M9oI77WRsbQ-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 03/13] qemu: firmware: Store machine types as a NULL-terminated string list Date: Thu, 5 Aug 2021 17:34:19 +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: 1628177690466100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_firmware.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/qemu/qemu_firmware.c b/src/qemu/qemu_firmware.c index 17380b7573..529ab8d68e 100644 --- a/src/qemu/qemu_firmware.c +++ b/src/qemu/qemu_firmware.c @@ -239,7 +239,7 @@ qemuFirmwareTargetFree(qemuFirmwareTarget *target) if (!target) return; - virStringListFreeCount(target->machines, target->nmachines); + g_strfreev(target->machines); g_free(target); } @@ -534,7 +534,7 @@ qemuFirmwareTargetParse(const char *path, nmachines =3D virJSONValueArraySize(machines); - t->machines =3D g_new0(char *, nmachines); + t->machines =3D g_new0(char *, nmachines + 1); for (j =3D 0; j < nmachines; j++) { virJSONValue *machine =3D virJSONValueArrayGet(machines, j); --=20 2.31.1 From nobody Sun May 5 07:48:57 2024 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=1628177698; cv=none; d=zohomail.com; s=zohoarc; b=CXXVp606ZLGw5VBcMlcydvmzS6qSGifvlohAK3Uyk830bODBJPhtYBoG/Nq8ZAiXjNOQQawsOLzdVg4rff5JDsCW6z4pTL8SOLITWbpPAFJdbrh1rsbVOHh9Mi4Ynk+LF8ejMSbDo8pvV5ROL9eoE/OSRUcOmYDcdiWdwwPw7Y0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1628177698; 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=AHnYuzwV3VZF/XmUpOpIGo8LAcODqCP/EUqhLf3e1Uc=; b=GKG0fKCcYjNjsbnnoiOHRIqQJq0Nc3SdBzRisbYkXEv6Gf8B1AOHBvs4ybaVuj/XJ3gITlpd3GTvyb3ysqNKsavPZB9Ea6frknV5xAM0IRWd3X0Qm+AlJx/HUhl4LiI7PM//Szwe3GHjezXF/F0VWOrQ3MDSHRdSySFgc/aUjmE= 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 1628177698935446.7440417694571; Thu, 5 Aug 2021 08:34:58 -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-329-Rc5Wx77SMFGQgh83xCEWzg-1; Thu, 05 Aug 2021 11:34:56 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 376C71018F75; Thu, 5 Aug 2021 15:34:45 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 193292C175; 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 657654A7C9; Thu, 5 Aug 2021 15:34:44 +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 175FYfeM027637 for ; Thu, 5 Aug 2021 11:34:41 -0400 Received: by smtp.corp.redhat.com (Postfix) id 6A2335D6B1; Thu, 5 Aug 2021 15:34:41 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.33]) by smtp.corp.redhat.com (Postfix) with ESMTP id BF44A5D6A1 for ; Thu, 5 Aug 2021 15:34:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1628177698; 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=AHnYuzwV3VZF/XmUpOpIGo8LAcODqCP/EUqhLf3e1Uc=; b=cxDGUxhc4ezoTaMBiZvyST4r8UUaOwcN1clUL8LpVr59ddD1QCMXqsi0fMnxXDZZ4cEKr9 X1mXI+xaCvAJqXSbaNUnQTV5jGXI1IeWRN+/uKr90iWJnWQybRA8zJDqDvMAgFCu+Jv7M2 xtYyL7EukM7cXYf8QeIkOs/E8RXu2sM= X-MC-Unique: Rc5Wx77SMFGQgh83xCEWzg-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 04/13] qemu: domain: Store passthrough environment variables in a struct Date: Thu, 5 Aug 2021 17:34:20 +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.11 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: 1628177701399100001 Content-Type: text/plain; charset="utf-8" Previously they were stored in two separate arrays. This way it's obvious when referencing the same one. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_command.c | 4 ++-- src/qemu/qemu_domain.c | 45 +++++++++++++++++++++++------------------ src/qemu/qemu_domain.h | 9 +++++++-- 3 files changed, 34 insertions(+), 24 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 4381ea7d8b..4bcb5a3146 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -10638,8 +10638,8 @@ qemuBuildCommandLine(virQEMUDriver *driver, for (i =3D 0; i < qemuxmlns->num_args; i++) virCommandAddArg(cmd, qemuxmlns->args[i]); for (i =3D 0; i < qemuxmlns->num_env; i++) - virCommandAddEnvPair(cmd, qemuxmlns->env_name[i], - NULLSTR_EMPTY(qemuxmlns->env_value[i])); + virCommandAddEnvPair(cmd, qemuxmlns->env[i].name, + NULLSTR_EMPTY(qemuxmlns->env[i].value)); } if (qemuBuildSeccompSandboxCommandLine(cmd, cfg, qemuCaps) < 0) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 6f8c93ea0c..21668cae4c 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -3319,12 +3319,17 @@ virDomainXMLPrivateDataCallbacks virQEMUDriverPriva= teDataCallbacks =3D { static void qemuDomainXmlNsDefFree(qemuDomainXmlNsDef *def) { + size_t i; + if (!def) return; + for (i =3D 0; i < def->num_env; i++) { + g_free(def->env[i].name); + g_free(def->env[i].value); + } + virStringListFreeCount(def->args, def->num_args); - virStringListFreeCount(def->env_name, def->num_env); - virStringListFreeCount(def->env_value, def->num_env); virStringListFreeCount(def->capsadd, def->ncapsadd); virStringListFreeCount(def->capsdel, def->ncapsdel); @@ -3372,15 +3377,21 @@ qemuDomainDefNamespaceParseCommandlineArgs(qemuDoma= inXmlNsDef *nsdef, static int -qemuDomainDefNamespaceParseCommandlineEnvNameValidate(const char *envname) +qemuDomainDefNamespaceParseCommandlineEnvValidate(qemuDomainXmlNsEnvTuple = *env) { - if (!g_ascii_isalpha(envname[0]) && envname[0] !=3D '_') { + if (!env->name) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("No qemu environment name specified")); + return -1; + } + + if (!g_ascii_isalpha(env->name[0]) && env->name[0] !=3D '_') { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid environment name, it must begin with a l= etter or underscore")); return -1; } - if (strspn(envname, "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvw= xyz0123456789_") !=3D strlen(envname)) { + if (strspn(env->name, "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstu= vwxyz0123456789_") !=3D strlen(env->name)) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid environment name, it must contain only a= lphanumerics and underscore")); return -1; @@ -3404,22 +3415,17 @@ qemuDomainDefNamespaceParseCommandlineEnv(qemuDomai= nXmlNsDef *nsdef, if (nnodes =3D=3D 0) return 0; - nsdef->env_name =3D g_new0(char *, nnodes); - nsdef->env_value =3D g_new0(char *, nnodes); + nsdef->env =3D g_new0(qemuDomainXmlNsEnvTuple, nnodes); for (i =3D 0; i < nnodes; i++) { - if (!(nsdef->env_name[nsdef->num_env] =3D virXMLPropString(nodes[i= ], "name"))) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("No qemu environment name specified")); - return -1; - } + qemuDomainXmlNsEnvTuple *env =3D nsdef->env + i; - if (qemuDomainDefNamespaceParseCommandlineEnvNameValidate(nsdef->e= nv_name[nsdef->num_env]) < 0) - return -1; - - nsdef->env_value[nsdef->num_env] =3D virXMLPropString(nodes[i], "v= alue"); - /* a NULL value for command is allowed, since it might be empty */ + env->name =3D virXMLPropString(nodes[i], "name"); + env->value =3D virXMLPropString(nodes[i], "value"); nsdef->num_env++; + + if (qemuDomainDefNamespaceParseCommandlineEnvValidate(env) < 0) + return -1; } return 0; @@ -3513,9 +3519,8 @@ qemuDomainDefNamespaceFormatXMLCommandline(virBuffer = *buf, virBufferEscapeString(buf, "\n", cmd->args[i]); for (i =3D 0; i < cmd->num_env; i++) { - virBufferAsprintf(buf, "env_name[i]); - if (cmd->env_value[i]) - virBufferEscapeString(buf, " value=3D'%s'", cmd->env_value[i]); + virBufferAsprintf(buf, "env[i].name); + virBufferEscapeString(buf, " value=3D'%s'", cmd->env[i].value); virBufferAddLit(buf, "/>\n"); } diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h index acf6ca5ab6..5f2814271d 100644 --- a/src/qemu/qemu_domain.h +++ b/src/qemu/qemu_domain.h @@ -457,14 +457,19 @@ struct _qemuDomainSaveCookie { G_DEFINE_AUTOPTR_CLEANUP_FUNC(qemuDomainSaveCookie, virObjectUnref); +typedef struct _qemuDomainXmlNsEnvTuple qemuDomainXmlNsEnvTuple; +struct _qemuDomainXmlNsEnvTuple { + char *name; + char *value; +}; + typedef struct _qemuDomainXmlNsDef qemuDomainXmlNsDef; struct _qemuDomainXmlNsDef { size_t num_args; char **args; unsigned int num_env; - char **env_name; - char **env_value; + qemuDomainXmlNsEnvTuple *env; size_t ncapsadd; char **capsadd; --=20 2.31.1 From nobody Sun May 5 07:48:57 2024 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=1628177699; cv=none; d=zohomail.com; s=zohoarc; b=dnIUuUjB3dTFZo/kp5CFNGikvEy1V3FvjXQKjQdlhWDZU+1SUmA9xZJ8rj02AdJ8CwupNwcPXFZlFAZ4NJi6k6T6+c8pTq0bJXcbC3cQS025WBkwnTvdBP+lHwdHSS1U9f6Uq8PqJOV9dQ/622GhiQI+A3RwQzGFuT27fUR5bjE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1628177699; 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=FdVBc3ngoys9IN5DWHX1FZnVE5LuzGrOxm5B+KwC3Yk=; b=heJtD0qrqcO+eFK14ic2qoJk2ZkuGl5+ponmOu1K88kUJkZE3yrIqIj98e2MCX0uJz2RQ7C40QdJEvtwUWS8QZyyzFaVNf5AaOT+fN0YaLFNFjoU2kXnw6ofxkm1vmjTJsCvZD8ysDAYYRxaTdEPgisQ9jikntd2jY7ZBqILB+Y= 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 1628177699126543.3956259550426; Thu, 5 Aug 2021 08:34:59 -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-539-hPY144g-Ocyb9RtsbfBXMQ-1; Thu, 05 Aug 2021 11:34:56 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 0D1C51B18BD5; Thu, 5 Aug 2021 15:34:51 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id BBC641346F; Thu, 5 Aug 2021 15:34:47 +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 8377E4A7CD; Thu, 5 Aug 2021 15:34:47 +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 175FYg51027647 for ; Thu, 5 Aug 2021 11:34:42 -0400 Received: by smtp.corp.redhat.com (Postfix) id 781D818401; Thu, 5 Aug 2021 15:34:42 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.33]) by smtp.corp.redhat.com (Postfix) with ESMTP id D828E5D6A1 for ; Thu, 5 Aug 2021 15:34:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1628177698; 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=FdVBc3ngoys9IN5DWHX1FZnVE5LuzGrOxm5B+KwC3Yk=; b=RMb9qo4LujEm42VUWVgFbt5HgGeHTSCFXYis0V7jERJjrhF462LeNpbh/eB4Juu2IeZ89/ jbahlMKaIhELB1M+mklDhs0J1PKK/tnpEgcE4GNqIw1pv0wXyYie6SJFretIPbFaImGD9h KgUvdoC2QbnBwpLTpqtBxzvsFQJ0qMw= X-MC-Unique: hPY144g-Ocyb9RtsbfBXMQ-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 05/13] qemu: domain: Store capability overrides in NULL-terminated string list Date: Thu, 5 Aug 2021 17:34:21 +0200 Message-Id: <5e43bcd1c0ec8930644176afdeb2fbec8ce9e1a7.1628176883.git.pkrempa@redhat.com> 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.11 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: 1628177701451100002 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 Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_domain.c | 28 ++++++++++++++-------------- src/qemu/qemu_domain.h | 2 -- src/qemu/qemu_process.c | 13 ++++++------- 3 files changed, 20 insertions(+), 23 deletions(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 21668cae4c..b2cbd3d6ba 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -3330,8 +3330,8 @@ qemuDomainXmlNsDefFree(qemuDomainXmlNsDef *def) } virStringListFreeCount(def->args, def->num_args); - virStringListFreeCount(def->capsadd, def->ncapsadd); - virStringListFreeCount(def->capsdel, def->ncapsdel); + g_strfreev(def->capsadd); + g_strfreev(def->capsdel); g_free(def->deprecationBehavior); @@ -3447,10 +3447,10 @@ qemuDomainDefNamespaceParseCaps(qemuDomainXmlNsDef = *nsdef, return -1; if (nnodesadd > 0) { - nsdef->capsadd =3D g_new0(char *, nnodesadd); + nsdef->capsadd =3D g_new0(char *, nnodesadd + 1); for (i =3D 0; i < nnodesadd; i++) { - if (!(nsdef->capsadd[nsdef->ncapsadd++] =3D virXMLPropString(n= odesadd[i], "capability"))) { + if (!(nsdef->capsadd[i] =3D virXMLPropString(nodesadd[i], "cap= ability"))) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("missing capability name")); return -1; @@ -3459,10 +3459,10 @@ qemuDomainDefNamespaceParseCaps(qemuDomainXmlNsDef = *nsdef, } if (nnodesdel > 0) { - nsdef->capsdel =3D g_new0(char *, nnodesdel); + nsdef->capsdel =3D g_new0(char *, nnodesdel + 1); for (i =3D 0; i < nnodesdel; i++) { - if (!(nsdef->capsdel[nsdef->ncapsdel++] =3D virXMLPropString(n= odesdel[i], "capability"))) { + if (!(nsdef->capsdel[i] =3D virXMLPropString(nodesdel[i], "cap= ability"))) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("missing capability name")); return -1; @@ -3491,7 +3491,7 @@ qemuDomainDefNamespaceParse(xmlXPathContextPtr ctxt, nsdata->deprecationBehavior =3D virXPathString("string(./qemu:deprecat= ion/@behavior)", ctxt); if (nsdata->num_args > 0 || nsdata->num_env > 0 || - nsdata->ncapsadd > 0 || nsdata->ncapsdel > 0 || + nsdata->capsadd || nsdata->capsdel || nsdata->deprecationBehavior) *data =3D g_steal_pointer(&nsdata); @@ -3533,19 +3533,19 @@ static void qemuDomainDefNamespaceFormatXMLCaps(virBuffer *buf, qemuDomainXmlNsDef *xmlns) { - size_t i; + GStrv n; - if (!xmlns->ncapsadd && !xmlns->ncapsdel) + if (!xmlns->capsadd && !xmlns->capsdel) return; virBufferAddLit(buf, "\n"); virBufferAdjustIndent(buf, 2); - for (i =3D 0; i < xmlns->ncapsadd; i++) - virBufferEscapeString(buf, "\n", xmln= s->capsadd[i]); + for (n =3D xmlns->capsadd; n && *n; n++) + virBufferEscapeString(buf, "\n", *n); - for (i =3D 0; i < xmlns->ncapsdel; i++) - virBufferEscapeString(buf, "\n", xmln= s->capsdel[i]); + for (n =3D xmlns->capsdel; n && *n; n++) + virBufferEscapeString(buf, "\n", *n); virBufferAdjustIndent(buf, -2); virBufferAddLit(buf, "\n"); @@ -6616,7 +6616,7 @@ void qemuDomainObjCheckTaint(virQEMUDriver *driver, qemuDomainXmlNsDef *qemuxmlns =3D obj->def->namespaceData; if (qemuxmlns->num_args || qemuxmlns->num_env) qemuDomainObjTaint(driver, obj, VIR_DOMAIN_TAINT_CUSTOM_ARGV, = logCtxt); - if (qemuxmlns->ncapsadd > 0 || qemuxmlns->ncapsdel > 0) + 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 5f2814271d..aa3ed78094 100644 --- a/src/qemu/qemu_domain.h +++ b/src/qemu/qemu_domain.h @@ -471,10 +471,8 @@ struct _qemuDomainXmlNsDef { unsigned int num_env; qemuDomainXmlNsEnvTuple *env; - size_t ncapsadd; char **capsadd; - size_t ncapsdel; char **capsdel; /* We deliberately keep this as a string so that it's parsed only when diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 81af4f1a44..4264191a9a 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -5484,7 +5484,6 @@ qemuProcessStartUpdateCustomCaps(virDomainObj *vm) qemuDomainXmlNsDef *nsdef =3D vm->def->namespaceData; char **next; int tmp; - size_t i; if (cfg->capabilityfilters) { for (next =3D cfg->capabilityfilters; *next; next++) { @@ -5500,22 +5499,22 @@ qemuProcessStartUpdateCustomCaps(virDomainObj *vm) } if (nsdef) { - for (i =3D 0; i < nsdef->ncapsadd; i++) { - if ((tmp =3D virQEMUCapsTypeFromString(nsdef->capsadd[i])) < 0= ) { + for (next =3D nsdef->capsadd; next && *next; next++) { + if ((tmp =3D virQEMUCapsTypeFromString(*next)) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, _("invalid qemu namespace capability '%s'"), - nsdef->capsadd[i]); + *next); return -1; } virQEMUCapsSet(priv->qemuCaps, tmp); } - for (i =3D 0; i < nsdef->ncapsdel; i++) { - if ((tmp =3D virQEMUCapsTypeFromString(nsdef->capsdel[i])) < 0= ) { + for (next =3D nsdef->capsdel; next && *next; next++) { + if ((tmp =3D virQEMUCapsTypeFromString(*next)) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, _("invalid qemu namespace capability '%s'"), - nsdef->capsdel[i]); + *next); return -1; } --=20 2.31.1 From nobody Sun May 5 07:48:57 2024 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 Reviewed-by: J=C3=A1n Tomko --- 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 From nobody Sun May 5 07:48:57 2024 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=1628177700; cv=none; d=zohomail.com; s=zohoarc; b=nwF1Ci8VY0H8QqBZ29uSzGWTlEX4i5LTGRTArDfG+lgc/Edjuhhw0Mt9eTcXLVa3gTW3Q+u43hiM3vBxCoqi4JkvYBj8V+3ByW0jw2kAExS70lu3E90zidCdS1SQyVwwG/Swv1iZMPZaLDHf2+eurC2f/+dHA+R0DbgvJPJ1U24= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1628177700; 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=kCnUV1YgrOWgkjlPCn8BjHscd9geC0tS1idUACtUBpE=; b=Z0XdIUDwlPWbbEorQYpwbEcXwiEb5rV9fD0/NhVsvvxrKXx/LhSYf4YCA9fPB1hMuiPJDJJdI8OjQuPI8p/rxI3GWzIiS9g9A3g6UusuPneORG84+tV/kGO4bIYuyE8zuxsCScY8K6/5pIp3FIxEdgT2winIThy2o9ddHD2gmzU= 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 1628177700987925.7920033773846; Thu, 5 Aug 2021 08:35:00 -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-311-5Ym75CP8NOC5CLP5K4kYyA-1; Thu, 05 Aug 2021 11:34:58 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A674C107ACF5; Thu, 5 Aug 2021 15:34:52 +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 767E9104327A; Thu, 5 Aug 2021 15:34:52 +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 3B6F0181A3F1; Thu, 5 Aug 2021 15:34:52 +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 175FYpdd027689 for ; Thu, 5 Aug 2021 11:34:51 -0400 Received: by smtp.corp.redhat.com (Postfix) id 17FD61ACBB; Thu, 5 Aug 2021 15:34:51 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.33]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8053518401 for ; Thu, 5 Aug 2021 15:34:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1628177700; 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=kCnUV1YgrOWgkjlPCn8BjHscd9geC0tS1idUACtUBpE=; b=cfhcw9OpwrXHDhw3OM6GChUG8SEtMD1azb/42uHsjLuBMpRPjo8biLsApmnG4FCCl1F4R5 1VM2zMOAs01OB60+aw9TwdqrZVTEPuNihfIW6LY/ocSMC4w7nPpZa9O6Af+c/6CM1yrlQP z+T8O+ekb/bOcYq6qD/bUJwQqSys/I4= X-MC-Unique: 5Ym75CP8NOC5CLP5K4kYyA-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 07/13] network: bridge: Store dnsmasq passthrough options in NULL-terminated string list Date: Thu, 5 Aug 2021 17:34:23 +0200 Message-Id: <6b39b9d0a9e2bd642e4001f9166efb736adb0dee.1628176883.git.pkrempa@redhat.com> 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.84 on 10.5.11.22 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: 1628177701674100005 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 Reviewed-by: J=C3=A1n Tomko --- src/network/bridge_driver.c | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c index 2555119892..acbc6be965 100644 --- a/src/network/bridge_driver.c +++ b/src/network/bridge_driver.c @@ -145,7 +145,6 @@ extern virXMLNamespace networkDnsmasqXMLNamespace; typedef struct _networkDnsmasqXmlNsDef networkDnsmasqXmlNsDef; struct _networkDnsmasqXmlNsDef { - size_t noptions; char **options; }; @@ -157,7 +156,7 @@ networkDnsmasqDefNamespaceFree(void *nsdata) if (!def) return; - virStringListFreeCount(def->options, def->noptions); + g_strfreev(def->options); g_free(def); } @@ -179,10 +178,10 @@ networkDnsmasqDefNamespaceParseOptions(networkDnsmasq= XmlNsDef *nsdef, if (nnodes =3D=3D 0) return 0; - nsdef->options =3D g_new0(char *, nnodes); + nsdef->options =3D g_new0(char *, nnodes + 1); for (i =3D 0; i < nnodes; i++) { - if (!(nsdef->options[nsdef->noptions++] =3D virXMLPropString(nodes= [i], "value"))) { + if (!(nsdef->options[i] =3D virXMLPropString(nodes[i], "value"))) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("No dnsmasq options value specified")); return -1; @@ -202,7 +201,7 @@ networkDnsmasqDefNamespaceParse(xmlXPathContextPtr ctxt, if (networkDnsmasqDefNamespaceParseOptions(nsdata, ctxt)) return -1; - if (nsdata->noptions > 0) + if (nsdata->options) *data =3D g_steal_pointer(&nsdata); return 0; @@ -214,17 +213,16 @@ networkDnsmasqDefNamespaceFormatXML(virBuffer *buf, void *nsdata) { networkDnsmasqXmlNsDef *def =3D nsdata; - size_t i; + GStrv n; - if (!def->noptions) + if (!def->options) return 0; virBufferAddLit(buf, "\n"); virBufferAdjustIndent(buf, 2); - for (i =3D 0; i < def->noptions; i++) { - virBufferEscapeString(buf, "\n", - def->options[i]); + for (n =3D def->options; *n; n++) { + virBufferEscapeString(buf, "\n", *n); } virBufferAdjustIndent(buf, -2); @@ -1554,8 +1552,9 @@ networkDnsmasqConfContents(virNetworkObj *obj, if (def->namespaceData) { networkDnsmasqXmlNsDef *dnsmasqxmlns =3D def->namespaceData; - for (i =3D 0; i < dnsmasqxmlns->noptions; i++) - virBufferAsprintf(&configbuf, "%s\n", dnsmasqxmlns->options[i]= ); + GStrv n; + for (n =3D dnsmasqxmlns->options; n && *n; n++) + virBufferAsprintf(&configbuf, "%s\n", *n); } if (!(*configstr =3D virBufferContentAndReset(&configbuf))) --=20 2.31.1 From nobody Sun May 5 07:48:57 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.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 170.10.133.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=1628177708; cv=none; d=zohomail.com; s=zohoarc; b=LGi9ekmXO1QVf80GYnYaYNiNa4NS3CUVqS5lB21EiciejeLjwHXuRAhcOnwvU7TtUA+Nr4g6UGVbQU/oHB+wcE4P3wETsG7DtTaCq39kvrMT2IiGQzcM3ct+DqHVNQCI2VA7GS0fEE3byy3LuPQo5if05yrz+PvweRhA1GZXFNg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1628177708; 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=UsKWnRjcLpMQjSyB61vQuIS1xiSS+ifjebEQICVCGgM=; b=nH66WSfPGWtxIB7l/KbbNOVtmg62RDtQVOqseXAaLFt6qWJAMeSqMtlqWM/97X7LIbX7f4ntOKoK2aobDEgljn1TADHQ4gaFu7qvPfJCNvLZDLc3jy2kBQZm3EzOR6AMXLCUbOHLhFg7MsHeZCgXIKmYfOcDwm2b1Lp9HUg37ks= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.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 [170.10.133.124]) by mx.zohomail.com with SMTPS id 1628177708051317.44155085331784; Thu, 5 Aug 2021 08:35:08 -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-118-cUIIM-yJM9yzy__cem-rtA-1; Thu, 05 Aug 2021 11:35:04 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id DCBBE1018F72; Thu, 5 Aug 2021 15:34:57 +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 B6A9B60CA1; Thu, 5 Aug 2021 15:34:57 +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 81D9B181A3F4; Thu, 5 Aug 2021 15:34:57 +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 175FYuO4027733 for ; Thu, 5 Aug 2021 11:34:56 -0400 Received: by smtp.corp.redhat.com (Postfix) id 12A6D18401; Thu, 5 Aug 2021 15:34:56 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.33]) by smtp.corp.redhat.com (Postfix) with ESMTP id 714245D6B1 for ; Thu, 5 Aug 2021 15:34:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1628177707; 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=UsKWnRjcLpMQjSyB61vQuIS1xiSS+ifjebEQICVCGgM=; b=Yhpl1X++WZzsGmAr9AkIfwHxVfmr2P5ejmkwObf2xtwHU/vd2JX2KZ5FfxYAAkT3aG9M+O tnKkJrqbSitSgrvm3lmDP7xGv/Zn6JwDclCV33ddD6acQrZveeslSO63/EKFe2J9T1j19p L+uafT5+zVsOuVJP3wDoM+olZHYrwY0= X-MC-Unique: cUIIM-yJM9yzy__cem-rtA-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 08/13] qemuNamespacePrepareOneItem: Restructure code to avoid temporary variables Date: Thu, 5 Aug 2021 17:34:24 +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.12 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: 1628177708496100001 Content-Type: text/plain; charset="utf-8" The value of 'next' is copied into 'item.file' so we can move the update to the 'next' pointer earlier and move the VIR_APPEND_ELEMENT call to where we figure out that we need to append the value. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_namespace.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/src/qemu/qemu_namespace.c b/src/qemu/qemu_namespace.c index ca59b5d95b..01a5edc585 100644 --- a/src/qemu/qemu_namespace.c +++ b/src/qemu/qemu_namespace.c @@ -1197,7 +1197,6 @@ qemuNamespacePrepareOneItem(qemuNamespaceMknodData *d= ata, while (1) { g_auto(qemuNamespaceMknodItem) item =3D { 0 }; bool isLink; - bool addToData =3D false; int rc; rc =3D qemuNamespaceMknodItemInit(&item, cfg, vm, next); @@ -1210,25 +1209,21 @@ qemuNamespacePrepareOneItem(qemuNamespaceMknodData = *data, } isLink =3D S_ISLNK(item.sb.st_mode); + g_free(next); + next =3D g_strdup(item.target); - if (STRPREFIX(next, QEMU_DEVPREFIX)) { + if (STRPREFIX(item.file, QEMU_DEVPREFIX)) { for (i =3D 0; i < ndevMountsPath; i++) { if (STREQ(devMountsPath[i], "/dev")) continue; - if (STRPREFIX(next, devMountsPath[i])) + if (STRPREFIX(item.file, devMountsPath[i])) break; } if (i =3D=3D ndevMountsPath) - addToData =3D true; + VIR_APPEND_ELEMENT(data->items, data->nitems, item); } - g_free(next); - next =3D g_strdup(item.target); - - if (addToData) - VIR_APPEND_ELEMENT(data->items, data->nitems, item); - if (!isLink) break; --=20 2.31.1 From nobody Sun May 5 07:48:57 2024 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=1628177709; cv=none; d=zohomail.com; s=zohoarc; b=LXtcSKLCkKlqpw1m5fJH/q/OX+A0kxnfTwuEpBv7w/SG12I50aMLJBDBdST5eVzmSAQ4VyC/RKWDhwDTVocnuNgnmCxSYBIj3lLFc4Vrgg4qTkjNNyP7ERqZXgMhKytAD//U8IEKDc3s02Q2EdWCNgsJwaIvovW2pM09FezSY24= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1628177709; 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=feboxxXiohDXp3mb1enxJRW2wWNCsNAzNRspSUv2ctQ=; b=jWtQMqxqxbK+jkdmou+6SW939Jl5TF7WAPAcZPifsuOyukEDspcW06sSNSUeIgwCD8L7mqOOnSOSO0hmTlX26qXS4RM+YT+oBIo8DMLaBYFBKhCwmBY8rUWUtzkrUSwHZO10Xc9IiffLzS28FQb2UNCecHqC0aycsWpbgcdnHo0= 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 1628177709822284.46611920294686; Thu, 5 Aug 2021 08:35:09 -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-109-913ZiM0qP3as1doM-mK4qw-1; Thu, 05 Aug 2021 11:35:07 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id F25D31018F7B; Thu, 5 Aug 2021 15:35:00 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D4C2919C87; Thu, 5 Aug 2021 15:35:00 +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 9A2854A707; Thu, 5 Aug 2021 15:35:00 +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 175FYvFP027766 for ; Thu, 5 Aug 2021 11:34:57 -0400 Received: by smtp.corp.redhat.com (Postfix) id 232CF18401; Thu, 5 Aug 2021 15:34:57 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.33]) by smtp.corp.redhat.com (Postfix) with ESMTP id 791175D6B1 for ; Thu, 5 Aug 2021 15:34:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1628177708; 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=feboxxXiohDXp3mb1enxJRW2wWNCsNAzNRspSUv2ctQ=; b=IGlrv4O5xxuu0YjJxWZ7MFB6HKkC1DqwT2OmJzxANBEQG++pAVc7wivN0HtIa2UhNODBv6 +bXZGesPQlzZEsBZqK3SkvhkVKgW8JsM62hXi46FBR19fOVRfNgM9po/0lMCXNdey1vlsu fSaqMZWIejMGNE28RiI9fGNonqDZcMw= X-MC-Unique: 913ZiM0qP3as1doM-mK4qw-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 09/13] qemuNamespacePrepareOneItem: Don't pass count of elements Date: Thu, 5 Aug 2021 17:34:25 +0200 Message-Id: <3f12f0b114831a6f86f4e9e35e2196625e6b3830.1628176883.git.pkrempa@redhat.com> 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.11 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: 1628177710887100001 Content-Type: text/plain; charset="utf-8" The only caller is passing a NULL terminated string list as 'devMountsPath' thus we don't need to get the count of elements. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_namespace.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/qemu/qemu_namespace.c b/src/qemu/qemu_namespace.c index 01a5edc585..06169922b9 100644 --- a/src/qemu/qemu_namespace.c +++ b/src/qemu/qemu_namespace.c @@ -1187,12 +1187,10 @@ qemuNamespacePrepareOneItem(qemuNamespaceMknodData = *data, virQEMUDriverConfig *cfg, virDomainObj *vm, const char *file, - char * const *devMountsPath, - size_t ndevMountsPath) + GStrv devMountsPath) { long ttl =3D sysconf(_SC_SYMLOOP_MAX); g_autofree char *next =3D g_strdup(file); - size_t i; while (1) { g_auto(qemuNamespaceMknodItem) item =3D { 0 }; @@ -1213,14 +1211,19 @@ qemuNamespacePrepareOneItem(qemuNamespaceMknodData = *data, next =3D g_strdup(item.target); if (STRPREFIX(item.file, QEMU_DEVPREFIX)) { - for (i =3D 0; i < ndevMountsPath; i++) { - if (STREQ(devMountsPath[i], "/dev")) + GStrv n; + bool found =3D false; + + for (n =3D devMountsPath; n && *n; n++) { + if (STREQ(*n, "/dev")) continue; - if (STRPREFIX(item.file, devMountsPath[i])) + if (STRPREFIX(item.file, *n)) { + found =3D true; break; + } } - if (i =3D=3D ndevMountsPath) + if (!found) VIR_APPEND_ELEMENT(data->items, data->nitems, item); } @@ -1269,8 +1272,7 @@ qemuNamespaceMknodPaths(virDomainObj *vm, for (next =3D paths; next; next =3D next->next) { const char *path =3D next->data; - if (qemuNamespacePrepareOneItem(&data, cfg, vm, path, - devMountsPath, ndevMountsPath) < 0) + if (qemuNamespacePrepareOneItem(&data, cfg, vm, path, devMountsPat= h) < 0) goto cleanup; } --=20 2.31.1 From nobody Sun May 5 07:48:57 2024 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=1628177712; cv=none; d=zohomail.com; s=zohoarc; b=jy3J/XF4N6E5xLrPA/dWaYFymeJK8y+HwvX1/lT1yHL89yXbnf7VDo4ixFBG023H8EVOpPWlzr9vYFIPCyimGLXfPTz5pqb9ursYDbNV28oAT2/OM780zHdSfse+tRi15MLN8pYpX98Ifhk98X0Pue/myUmqH6KaeLDSLnmxYqE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1628177712; 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=qTJ7jqxjnC9VcfeOUYCAV1InxpNM7kDvYwAyqWksfFo=; b=YkXrIzD9P3oWtB9N+qIMt4eMFdoFse7coumL7n8t6LIsTWGNVGrL6FD/naauv2lHg95IKMJrP9qubPTN1l0+T10LYV9uUhRjs9SxPYNO0Rjb1R/7zPUjazS73LlmX9D/JyGvfQD5UZEbLHg0btwtdVzLYhSIY6hEGSNWTg3K5K4= 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 1628177712117591.7309262682655; Thu, 5 Aug 2021 08:35:12 -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-559-n7KYduGaMZa1x07XleeLtg-1; Thu, 05 Aug 2021 11:35:09 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 34E10801A92; Thu, 5 Aug 2021 15:35:04 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 11A8D5F724; Thu, 5 Aug 2021 15:35:04 +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 CD34B4A70C; Thu, 5 Aug 2021 15:35:03 +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 175FYwIB027783 for ; Thu, 5 Aug 2021 11:34:58 -0400 Received: by smtp.corp.redhat.com (Postfix) id 3BF2F18401; Thu, 5 Aug 2021 15:34:58 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.33]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8FC855D6B1 for ; Thu, 5 Aug 2021 15:34:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1628177711; 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=qTJ7jqxjnC9VcfeOUYCAV1InxpNM7kDvYwAyqWksfFo=; b=Z2Yi3BFgP3h6aE1vehIKsj9uh4iBU1B9CDRQWAeItjQjd2VopdkUALE2qnJB6frfc5/aGc PPPNgVQ723oJxCPzV4e6lPTOuJ83n//0rNGJS47a4ljUp/G/BnZXc+Vr6X1poE1AFRwIbi 94j6W99c2JCO5lx1unXLzvvs9tVIOQg= X-MC-Unique: n7KYduGaMZa1x07XleeLtg-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 10/13] qemuNamespaceMknodPaths: Remove 'ndevMountsPath' Date: Thu, 5 Aug 2021 17:34:26 +0200 Message-Id: <5edb2754e2123b069ce22d5196947d6956219d9e.1628176883.git.pkrempa@redhat.com> 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.16 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: 1628177713287100005 Content-Type: text/plain; charset="utf-8" 'devMountsPath' can be converted to an auto-cleared stringlist and thus asking for the number of entries is not necessary. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_namespace.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/qemu/qemu_namespace.c b/src/qemu/qemu_namespace.c index 06169922b9..b2e6ecb71a 100644 --- a/src/qemu/qemu_namespace.c +++ b/src/qemu/qemu_namespace.c @@ -1250,8 +1250,7 @@ qemuNamespaceMknodPaths(virDomainObj *vm, qemuDomainObjPrivate *priv =3D vm->privateData; virQEMUDriver *driver =3D priv->driver; g_autoptr(virQEMUDriverConfig) cfg =3D NULL; - char **devMountsPath =3D NULL; - size_t ndevMountsPath =3D 0; + g_auto(GStrv) devMountsPath =3D NULL; qemuNamespaceMknodData data =3D { 0 }; size_t i; int ret =3D -1; @@ -1261,9 +1260,7 @@ qemuNamespaceMknodPaths(virDomainObj *vm, return 0; cfg =3D virQEMUDriverGetConfig(driver); - if (qemuDomainGetPreservedMounts(cfg, vm, - &devMountsPath, NULL, - &ndevMountsPath) < 0) + if (qemuDomainGetPreservedMounts(cfg, vm, &devMountsPath, NULL, NULL) = < 0) return -1; data.driver =3D driver; @@ -1304,7 +1301,6 @@ qemuNamespaceMknodPaths(virDomainObj *vm, } } qemuNamespaceMknodDataClear(&data); - virStringListFreeCount(devMountsPath, ndevMountsPath); return ret; } --=20 2.31.1 From nobody Sun May 5 07:48:57 2024 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=1628177710; cv=none; d=zohomail.com; s=zohoarc; b=RfIoAWtSlc3HgqXDw/lAVGDbQdwGdXexBOyF3MZg9ZnPe+JpjSI+NEZcsEZPJHPFnhaXeYfrw1dPJXe+NsjgulLNyAxcrvw8s+aa7Ri/tJJUT5w1wLqQsX9KnTOnsArgW5qVfguQWYI9+vOUfvvJOqbYfXOzF1s3Xc0IQu/pQQc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1628177710; 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=c0aWFFldMeXHQOi6VQndP/P9kR0PBc3b2aBd+VQNfj4=; b=H+6QFP+QkVzDg73OmvUnMOsay3DHfL0gCFy1sm1Rr0ZVGf67sb3khpZ6ZkMEkxk4PG3A71MfxM+Ol8Is/JLgd9rx8umPs9OdFbs6yp6HX7i5HEmEVj9/MU7pGOM5nRdQsI+/2aEueCz5/SzfruhVvDoSD42vAy/w/M6bG4Az1C8= 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 1628177710873421.66935983910287; Thu, 5 Aug 2021 08:35:10 -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-363-qDE_F_DKN4eMdaYLnktPOA-1; Thu, 05 Aug 2021 11:35:08 -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 A415893925; Thu, 5 Aug 2021 15:35:02 +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 7CBB14EF72; Thu, 5 Aug 2021 15:35:02 +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 4762B181A601; Thu, 5 Aug 2021 15:35:02 +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 175FYx4E027800 for ; Thu, 5 Aug 2021 11:34:59 -0400 Received: by smtp.corp.redhat.com (Postfix) id 4ACD518401; Thu, 5 Aug 2021 15:34:59 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.33]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9F7255D6B1 for ; Thu, 5 Aug 2021 15:34:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1628177709; 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=c0aWFFldMeXHQOi6VQndP/P9kR0PBc3b2aBd+VQNfj4=; b=LraA4f3yAIP+pBI41Y1ATGnyX34QT2ZGpyxKtJ/M4miIMpqHTm3XTsd/vBiwU3f3mjJ7IK UW3nnQ6TDtrANXHfUfI34s+L7DUK5Hn7hS+1CIY9HlxW9KuxfRg/FAcQ8rqbYzFW22pEx9 VxKUEP/74tiCCc2eIW5SvA+LFL5fl7k= X-MC-Unique: qDE_F_DKN4eMdaYLnktPOA-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 11/13] qemuDomainUnshareNamespace: Use automatic memory clearing for string lists Date: Thu, 5 Aug 2021 17:34:27 +0200 Message-Id: <3eb61f59615ec546d793493738d1ff00dc70ca6a.1628176883.git.pkrempa@redhat.com> 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: 1628177713025100003 Content-Type: text/plain; charset="utf-8" 'devMountsPath' and 'devMountsSavePath' are NULL terminated. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_namespace.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/qemu/qemu_namespace.c b/src/qemu/qemu_namespace.c index b2e6ecb71a..728d77fc61 100644 --- a/src/qemu/qemu_namespace.c +++ b/src/qemu/qemu_namespace.c @@ -682,7 +682,8 @@ qemuDomainUnshareNamespace(virQEMUDriverConfig *cfg, virDomainObj *vm) { const char *devPath =3D NULL; - char **devMountsPath =3D NULL, **devMountsSavePath =3D NULL; + g_auto(GStrv) devMountsPath =3D NULL; + g_auto(GStrv) devMountsSavePath =3D NULL; size_t ndevMountsPath =3D 0, i; int ret =3D -1; @@ -791,8 +792,6 @@ qemuDomainUnshareNamespace(virQEMUDriverConfig *cfg, else unlink(devMountsSavePath[i]); } - virStringListFreeCount(devMountsPath, ndevMountsPath); - virStringListFreeCount(devMountsSavePath, ndevMountsPath); return ret; } --=20 2.31.1 From nobody Sun May 5 07:48:57 2024 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=1628177766; cv=none; d=zohomail.com; s=zohoarc; b=lWSmToXrT52qIQosxC5rDT1cTu0W8NsdWNGbB8AQGHj+uH8Fm1W6TPcCf7p2kRxq2jVL/N4k6dvxrgJaeTIMMQsGYQ2pOorn1m4j2YHvzbKCgIOAMuIIFKw1wLqL8hQCx6+WYDhVDDKUMM0k7zdX/CqkavpL/JzULuDKR0mz+4Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1628177766; 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=F6JyD785JWbHwacNRNK7ALH7k4m38W3t3uWwPbnkDNM=; b=hdDlgELgeIKkP0tnnGqE0IYZ6fz4BqiWGaXfwd9Z19pM509WgGpHuJzcfaiEjlXmTdjkkxUmngAWz+g8y4LAzS8L9QHUUKu3xduidJTNK+UVugAODoA8Jw8JvgEplxx2+3PpM7HXNYUJZj71UMI8mHZGyf1U0FaDG1ikkdgufy0= 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 1628177766729113.31973139740705; Thu, 5 Aug 2021 08:36:06 -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-304-vaD65XmYNeGD8sQECrlHug-1; Thu, 05 Aug 2021 11:35:12 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 7F377100CA8D; Thu, 5 Aug 2021 15:35:07 +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 534DC27CAA; Thu, 5 Aug 2021 15:35:07 +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 16833181A6E6; Thu, 5 Aug 2021 15:35:07 +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 175FZ0T3027835 for ; Thu, 5 Aug 2021 11:35:00 -0400 Received: by smtp.corp.redhat.com (Postfix) id 5CBEC669F3; Thu, 5 Aug 2021 15:35:00 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.33]) by smtp.corp.redhat.com (Postfix) with ESMTP id BA2D15D6B1 for ; Thu, 5 Aug 2021 15:34:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1628177765; 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=F6JyD785JWbHwacNRNK7ALH7k4m38W3t3uWwPbnkDNM=; b=X1uXdIZhaqOu/MA54reCWISGkH85jPYG+UCJMFBPOb0Ai00fY3GpyHyXXvNEQrMOaXiFG6 rTKM9eMyejDUDYznk/+Bdffe+Gmkdb4v5Mn4mazTc/6EjMkXRlyuJDw04hlUyluMkVntVT GtgzF1SX7hZ8zAWPonOp9Knc8GujFJU= X-MC-Unique: vaD65XmYNeGD8sQECrlHug-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 12/13] lxcContainerSetReadOnly: Refactor cleanup handling Date: Thu, 5 Aug 2021 17:34:28 +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.84 on 10.5.11.23 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: 1628177768724100001 Content-Type: text/plain; charset="utf-8" Turn 'mounts' into a proper GStrv after sorting so that automatic cleanup can be used and shuffle around the cleanup steps so that jumps can be avoided in favor of direct return of error code. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/lxc/lxc_container.c | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/src/lxc/lxc_container.c b/src/lxc/lxc_container.c index 1cadfe70e0..d788e77196 100644 --- a/src/lxc/lxc_container.c +++ b/src/lxc/lxc_container.c @@ -773,8 +773,7 @@ static int lxcContainerSetReadOnly(void) FILE *procmnt; struct mntent mntent; char mntbuf[1024]; - int ret =3D -1; - char **mounts =3D NULL; + g_auto(GStrv) mounts =3D NULL; size_t nmounts =3D 0; size_t i; @@ -797,13 +796,16 @@ static int lxcContainerSetReadOnly(void) VIR_APPEND_ELEMENT(mounts, nmounts, tmp); } - if (!mounts) { - ret =3D 0; - goto cleanup; - } + endmntent(procmnt); + + if (!mounts) + return 0; + + qsort(mounts, nmounts, sizeof(mounts[0]), virStringSortRevCompare); - qsort(mounts, nmounts, sizeof(mounts[0]), - virStringSortRevCompare); + /* turn 'mounts' into a proper GStrv */ + VIR_EXPAND_N(mounts, nmounts, 1); + nmounts--; for (i =3D 0; i < nmounts; i++) { VIR_DEBUG("Bind readonly %s", mounts[i]); @@ -811,16 +813,11 @@ static int lxcContainerSetReadOnly(void) virReportSystemError(errno, _("Failed to make mount %s readonly"), mounts[i]); - goto cleanup; + return -1; } } - ret =3D 0; - cleanup: - virStringListFreeCount(mounts, nmounts); - endmntent(procmnt); - return ret; - + return 0; } --=20 2.31.1 From nobody Sun May 5 07:48:57 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.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 170.10.133.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=1628177714; cv=none; d=zohomail.com; s=zohoarc; b=iNUQ47EfCvUjLBzrfH8OdDQeb+VdPYyX8ypNbIwFupm+9k19hpjhSoSoMvADNO3SsJgyClOF+GBLcghfV9PBzaMBMB4U7RxyabDwmeLuJZT0Tbfi3H/kmjB+Sy4uXjeqvF62KcP2KW7glNLPtz18YeaVUHM/By8+aB8i03ypjTo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1628177714; 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=hSqTkGlh5e9u2yJ+ACD7Bu1pBfefkGOUPwenJN3cVJo=; b=CznIIm/jXK9yO5MGBX2SdoW4nOnxZnEnhHffncLMAA2dJstY+YIB7i9MVS+c34T5xsn2f+n1pfhYejuBxnkWVEgcyetHu3Js4YjR57vwiHH2DtA2LHTAVERYguVR1MEPI+W9krUCkQnzMZj57EiUIXZszX63YH6FQieqLgQtaVg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.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 [170.10.133.124]) by mx.zohomail.com with SMTPS id 1628177714766611.3331695079194; Thu, 5 Aug 2021 08:35:14 -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-144-b8W0D30nNh2VZP-nqlSNeQ-1; Thu, 05 Aug 2021 11:35:12 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 5B66E801AC0; Thu, 5 Aug 2021 15:35:06 +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 343A760E1C; Thu, 5 Aug 2021 15:35:06 +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 EBF33181A6E4; Thu, 5 Aug 2021 15:35:05 +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 175FZ1nU027841 for ; Thu, 5 Aug 2021 11:35:01 -0400 Received: by smtp.corp.redhat.com (Postfix) id 6921E1ACBB; Thu, 5 Aug 2021 15:35:01 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.33]) by smtp.corp.redhat.com (Postfix) with ESMTP id BFBC05D6B1 for ; Thu, 5 Aug 2021 15:35:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1628177713; 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=hSqTkGlh5e9u2yJ+ACD7Bu1pBfefkGOUPwenJN3cVJo=; b=gLw9B6X7j86YYIxR+IG5tXTcSlPKQh5tcE0HwZ811NSd9TFKo3eEu3/NEZvxDs5UfcPDJ5 Cfn3fECM/gJBCVojBqnUKGwrjW38En/77BK9eJmudP5+iPGXmEBwKgF0kGsgZeFQ6y4KNT w9Yq2luKSYkiJfn7BIsg8CSx3hi/hWU= X-MC-Unique: b8W0D30nNh2VZP-nqlSNeQ-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 13/13] util: virstring: Remove unused virStringListFreeCount Date: Thu, 5 Aug 2021 17:34:29 +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.12 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: 1628177715698100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/libvirt_private.syms | 1 - src/util/virstring.c | 23 ----------------------- src/util/virstring.h | 3 --- 3 files changed, 27 deletions(-) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index fd02b27c51..e177591fa8 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -3288,7 +3288,6 @@ virStringHasControlChars; virStringHasSuffix; virStringIsEmpty; virStringIsPrintable; -virStringListFreeCount; virStringListMerge; virStringMatch; virStringMatchesNameSuffix; diff --git a/src/util/virstring.c b/src/util/virstring.c index a2c07e5c17..f416fed3c5 100644 --- a/src/util/virstring.c +++ b/src/util/virstring.c @@ -70,29 +70,6 @@ virStringListMerge(char ***dst, } -/** - * virStringListFreeCount: - * @strings: array of strings to free - * @count: number of elements in the array - * - * Frees a string array of @count length. - */ -void -virStringListFreeCount(char **strings, - size_t count) -{ - size_t i; - - if (!strings) - return; - - for (i =3D 0; i < count; i++) - g_free(strings[i]); - - g_free(strings); -} - - /* Like strtol, but produce an "int" result, and check more carefully. Return 0 upon success; return -1 to indicate failure. When END_PTR is NULL, the byte after the final valid digit must be NUL. diff --git a/src/util/virstring.h b/src/util/virstring.h index 7cc1d8c55f..ca81889c9b 100644 --- a/src/util/virstring.h +++ b/src/util/virstring.h @@ -25,9 +25,6 @@ int virStringListMerge(char ***dst, char ***src); -void virStringListFreeCount(char **strings, - size_t count); - int virStrToLong_i(char const *s, char **end_ptr, int base, --=20 2.31.1