From nobody Sun May 5 09:29:12 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 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=1565092078; cv=none; d=zoho.com; s=zohoarc; b=O2T8iUsPkNvoOXqIuUxRQt/kJzGcCWnLd/lf2l6LddoMEl7HKUpFQiu0g8rGKy0v8k6O3qLXMsyJaoFqSaeoWJMwE/b422EDJC/Mn6jlC9/waMs6xDALpzwCnLsyWBUIpDSonv8w4WXUCReVNWjoRZKce5hPg5qx7Wi1OL3R4ns= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1565092078; h=Content-Type:Content-Transfer-Encoding:Cc: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:ARC-Authentication-Results; bh=Y7Qdq8V5KVJK5JdmVFTx4q51pBbePZu6w/rqi8qsT4M=; b=TN1IkdhvSbr8Zkx/u7jEBLSN5D1v/XUNMZ1rUUTOzUo14npBKjh3ODsf5u8EMdyrXyCpnH46BFEgH1y2ivAX8aWce/3SBhMZjBRNq0z1rYUJwPZslg4DvyvjHZ+mpn1kO4PGGJPiFMwAH5y9Zq4BVVIRti35o1ZtOz+lmPacack= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1565092078761882.3913366408351; Tue, 6 Aug 2019 04:47:58 -0700 (PDT) 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 mx1.redhat.com (Postfix) with ESMTPS id 6544B87633; Tue, 6 Aug 2019 11:47:57 +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 32988608A7; Tue, 6 Aug 2019 11:47: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 F02233CBA; Tue, 6 Aug 2019 11:47:56 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x76BlpCP022368 for ; Tue, 6 Aug 2019 07:47:51 -0400 Received: by smtp.corp.redhat.com (Postfix) id DCFFC5DA21; Tue, 6 Aug 2019 11:47:51 +0000 (UTC) Received: from moe.brq.redhat.com (unknown [10.43.2.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1CE035DA8C; Tue, 6 Aug 2019 11:47:50 +0000 (UTC) From: Michal Privoznik To: libvir-list@redhat.com Date: Tue, 6 Aug 2019 13:47:44 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Cc: huaqiang.wang@intel.com Subject: [libvirt] [PATCH 1/3] qemuDomainGetResctrlMonData: Don't leak @caps 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: , Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Tue, 06 Aug 2019 11:47:57 +0000 (UTC) Content-Type: text/plain; charset="utf-8" The capabilities object must be unrefed when no longer needed. use VIR_AUTOUNREF() for that. Signed-off-by: Michal Privoznik Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_driver.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 3c5ec848ba..d5a8beb134 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -20737,7 +20737,7 @@ qemuDomainGetResctrlMonData(virQEMUDriverPtr driver, virDomainResctrlDefPtr resctrl =3D NULL; virQEMUResctrlMonDataPtr res =3D NULL; char **features =3D NULL; - virCapsPtr caps =3D NULL; + VIR_AUTOUNREF(virCapsPtr) caps =3D NULL; size_t i =3D 0; size_t j =3D 0; =20 --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun May 5 09:29:12 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 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=1565092075; cv=none; d=zoho.com; s=zohoarc; b=d4MMgyoywTXsfCigY8chWeTi9WBGIh87pJwRqQE8YxiQmATXfvaQP/zTe2DllbHnv2narQf6esROgxFGSgXc2feljr+3poTf+0yOq/NynMh5305COraa4E3oIzJD2Dz1U5rrzZ4GP0mSa38D7qMTJa6o6aWuDDbs92wX6x1SO7U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1565092075; h=Content-Type:Content-Transfer-Encoding:Cc: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:ARC-Authentication-Results; bh=DorKzWNz1ICCb/TZA2jaXQ8uMTuxdjpeZdzutjAGitU=; b=fQwz+tCAm1TdwTb22hkRnysAZgNeKiVulj/izQOps598EgU5glMtdtnvRzZ2WhpyAPL8QIr+PqtgX+teAqWWCnjyjJHdofe9T3zhvr2Clt1B1i1znd0V2TWXoCaStjff6ldkAxcA4AKZs8o6w4spV1IVxHF6vtMOvu709+hiNaE= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1565092075714474.15908564064136; Tue, 6 Aug 2019 04:47:55 -0700 (PDT) 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 mx1.redhat.com (Postfix) with ESMTPS id 7E2BF30BCB80; Tue, 6 Aug 2019 11:47:54 +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 54F6919C78; Tue, 6 Aug 2019 11:47:54 +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 1E46E180B536; Tue, 6 Aug 2019 11:47:54 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x76BlrR3022378 for ; Tue, 6 Aug 2019 07:47:53 -0400 Received: by smtp.corp.redhat.com (Postfix) id 03E255DA8C; Tue, 6 Aug 2019 11:47:53 +0000 (UTC) Received: from moe.brq.redhat.com (unknown [10.43.2.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id 379345DA21; Tue, 6 Aug 2019 11:47:52 +0000 (UTC) From: Michal Privoznik To: libvir-list@redhat.com Date: Tue, 6 Aug 2019 13:47:45 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Cc: huaqiang.wang@intel.com Subject: [libvirt] [PATCH 2/3] qemuDomainGetResctrlMonData: Dereference resctrl monitor iff not NULL 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: , Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.49]); Tue, 06 Aug 2019 11:47:54 +0000 (UTC) Content-Type: text/plain; charset="utf-8" If the host doesn't have resctrl then the monitor is going to be NULL and we must avoid dereferencing it. Signed-off-by: Michal Privoznik Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_driver.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index d5a8beb134..25b6653e38 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -20744,7 +20744,8 @@ qemuDomainGetResctrlMonData(virQEMUDriverPtr driver, caps =3D virQEMUDriverGetCapabilities(driver, false); =20 if (tag =3D=3D VIR_RESCTRL_MONITOR_TYPE_CACHE) { - features =3D caps->host.cache.monitor->features; + if (caps->host.cache.monitor) + features =3D caps->host.cache.monitor->features; } else { virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s", _("Unsupported resctrl monitor type")); --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun May 5 09:29:12 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 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=1565092079; cv=none; d=zoho.com; s=zohoarc; b=IbeyYwKT0tMsCD6+vWBsHfLDStr+tYTRITON12ZwxyNNkFjqFtqP89RNAQRlOCY527bsS5hg1ztR4JGUXKTHkNH+cDxGsYEiuIPusC5M5s16q2T4l+idd7vb7O+TYMytxKStvuXiMsgDxW2LUOaHZb64i49F5anOXmG+ZJ+SmaI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1565092079; h=Content-Type:Content-Transfer-Encoding:Cc: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:ARC-Authentication-Results; bh=zhnlmcxYrOOkD5NhGSq6YFlj57zcX4sTgZ1I29KL/9k=; b=a3zyjEV5znrLnp5Qn0ynst8VC8z9V9oswvpP9kgFmpJdGas/UzXjh5rWXcovAd7PKRX0Wc0tmfw+0ClCAjUf4y9dNGGxowEL0yrYpFShX9W3iGvvTkcZn6/EFBPfvbN3UBZrRSms23gL246x2FQ+1A/DSf0F2XMtra5owhfRb+g= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1565092079436189.82508456748985; Tue, 6 Aug 2019 04:47:59 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id CF1D599D2E; Tue, 6 Aug 2019 11:47: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 AD3C05D71C; Tue, 6 Aug 2019 11:47: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 717FC180BA99; Tue, 6 Aug 2019 11:47:57 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x76Bls8N022388 for ; Tue, 6 Aug 2019 07:47:54 -0400 Received: by smtp.corp.redhat.com (Postfix) id 1B4B45DA8C; Tue, 6 Aug 2019 11:47:54 +0000 (UTC) Received: from moe.brq.redhat.com (unknown [10.43.2.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4E7585DA21; Tue, 6 Aug 2019 11:47:53 +0000 (UTC) From: Michal Privoznik To: libvir-list@redhat.com Date: Tue, 6 Aug 2019 13:47:46 +0200 Message-Id: <0f8e54c4f2c50d3aedd3c689b503a4aae6464e6b.1565092024.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Cc: huaqiang.wang@intel.com Subject: [libvirt] [PATCH 3/3] qemuDomainGetResctrlMonData: Switch to switch() 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: , Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Tue, 06 Aug 2019 11:47:58 +0000 (UTC) Content-Type: text/plain; charset="utf-8" This way it is obvious when adding a new resource control type that stats helper func needs to be updated too. Signed-off-by: Michal Privoznik Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_driver.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 25b6653e38..5606639482 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -20743,10 +20743,14 @@ qemuDomainGetResctrlMonData(virQEMUDriverPtr driv= er, =20 caps =3D virQEMUDriverGetCapabilities(driver, false); =20 - if (tag =3D=3D VIR_RESCTRL_MONITOR_TYPE_CACHE) { + switch (tag) { + case VIR_RESCTRL_MONITOR_TYPE_CACHE: if (caps->host.cache.monitor) features =3D caps->host.cache.monitor->features; - } else { + break; + case VIR_RESCTRL_MONITOR_TYPE_MEMBW: + case VIR_RESCTRL_MONITOR_TYPE_UNSUPPORT: + case VIR_RESCTRL_MONITOR_TYPE_LAST: virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s", _("Unsupported resctrl monitor type")); return -1; --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list