From nobody Tue Feb 10 10:18:37 2026 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=fail(p=none dis=none) header.from=weirdnatto.in ARC-Seal: i=1; a=rsa-sha256; t=1662546898; cv=none; d=zohomail.com; s=zohoarc; b=hLNCyFwyg1Pp1Q9TzhJM6GO13w9pHplKqis/lh0B0pSBBbr3q5ihAXeXWCTLgkXlgqATboUIvT1VI6S15V4ixF50QkSxe1lyBhsQnZiMDX8uO7CjMBBb+QqlzuThuvGVjjY82euBEjE4/3HzFncjEgeReJHjV7dCzeUkC5VfFUM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1662546898; 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; bh=/GcNF7WJk65F00Su59AIX8E0bPPEd8FwljuVzFCFfZw=; b=jOV5FWfZgDsWjLA2iDOqp1brQYdFgnhyUxfpybRnAhzVctXx02kFywU/TDzL4vJ7GJYCr0nLrJZ9kTaSz/DXkDswjaUpgBMjI/t4OhEnWjntuYJGY9FxYWTdb5bDm5489n6b7Tfdyln7OwwmYZ4l0Z5yKrXXaUcr7I4Gp25OwiM= 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=fail 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 1662546898905109.20946305737357; Wed, 7 Sep 2022 03:34:58 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-468-cTk9w8yqP0-x12imJligKA-1; Wed, 07 Sep 2022 06:34:55 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id BB8571C06ED1; Wed, 7 Sep 2022 10:34:53 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id A7E48C15BB3; Wed, 7 Sep 2022 10:34:53 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 9CA4E1946A49; Wed, 7 Sep 2022 10:34:53 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 0588B1946A40 for ; Wed, 7 Sep 2022 10:34:53 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id DC5442026D64; Wed, 7 Sep 2022 10:34:52 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast07.extmail.prod.ext.rdu2.redhat.com [10.11.55.23]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D83082026D4C for ; Wed, 7 Sep 2022 10:34:52 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id BB73A3C0D1B1 for ; Wed, 7 Sep 2022 10:34:52 +0000 (UTC) Received: from mail.weirdnatto.in (140.238.225.67 [140.238.225.67]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-606-vvClTFZSNCeF8if10knfBw-1; Wed, 07 Sep 2022 06:34:49 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1662546898; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc: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=/GcNF7WJk65F00Su59AIX8E0bPPEd8FwljuVzFCFfZw=; b=ScI20njZwyElAN6YFzBOaYlbvwjQ20DSCftswcFsTPYDHuHgcjtIEpQOPi4Lep80qPx8uj ohQESsiwR5Z76Icu3Mf9qNrVt69gRR9ralYas7e81HO2pN/CtuMHLJg+1tmE4X3DuWTQ40 kB+G78lbD7J+m0+UnRWtFP1RQmXPStw= X-MC-Unique: cTk9w8yqP0-x12imJligKA-1 X-Original-To: libvir-list@listman.corp.redhat.com X-MC-Unique: vvClTFZSNCeF8if10knfBw-1 From: Amneesh Singh To: libvir-list@redhat.com Subject: [RFC PATCH 4/6] qemu_monitor: add qemuMonitorGetStatsByQOMPath Date: Wed, 7 Sep 2022 16:04:21 +0530 Message-Id: <20220907103423.662344-5-natto@weirdnatto.in> In-Reply-To: <20220907103423.662344-1-natto@weirdnatto.in> References: <20220907103423.662344-1-natto@weirdnatto.in> MIME-Version: 1.0 X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mkletzan@redhat.com, pbonzini@redhat.com, Amneesh Singh Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.85 on 10.11.54.8 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: 1662546900683100003 Content-Type: text/plain; charset="utf-8"; x-default="true" This function returns the virJSONValue object which has the same qom_path as specified. Signed-off-by: Amneesh Singh --- src/qemu/qemu_monitor.c | 38 ++++++++++++++++++++++++++++++++++++++ src/qemu/qemu_monitor.h | 4 ++++ 2 files changed, 42 insertions(+) diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c index 9581e90796..3d4302a6ed 100644 --- a/src/qemu/qemu_monitor.c +++ b/src/qemu/qemu_monitor.c @@ -1537,6 +1537,7 @@ qemuMonitorGetCPUInfoLegacy(struct qemuMonitorQueryCp= usEntry *cpuentries, vcpus[i].tid =3D cpuentries[i].tid; vcpus[i].halted =3D cpuentries[i].halted; vcpus[i].qemu_id =3D cpuentries[i].qemu_id; + vcpus[i].qom_path =3D g_strdup(cpuentries[i].qom_path); } =20 /* for legacy hotplug to work we need to fake the vcpu count added= by @@ -4446,3 +4447,40 @@ qemuMonitorExtractQueryStats(virJSONValue *info) =20 return g_steal_pointer(&hash_table); } + + +/** + * qemuMonitorStatsSchemaByQOMPath: + * @arr: Array of objects returned by qemuMonitorQueryStats + * + * Returns the object which matches the QOM path of the vCPU + * + * Returns NULL on failure. + */ +virJSONValue * +qemuMonitorGetStatsByQOMPath(virJSONValue *arr, + char *qom_path) +{ + size_t i; + + if (!virJSONValueIsArray(arr) || !qom_path) + return NULL; + + for (i =3D 0; i < virJSONValueArraySize(arr); i++) { + virJSONValue *obj =3D virJSONValueArrayGet(arr, i); + const char *test_qom_path =3D NULL; + + if (!obj) + return NULL; + + test_qom_path =3D virJSONValueObjectGetString(obj, "qom-path"); + + if (!test_qom_path) + return NULL; + + if (STRCASEEQ(qom_path, test_qom_path)) + return obj; + } + + return NULL; +} diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h index 4c817dea20..6b0440fdf0 100644 --- a/src/qemu/qemu_monitor.h +++ b/src/qemu/qemu_monitor.h @@ -1564,3 +1564,7 @@ qemuMonitorQueryStats(qemuMonitor *mon, =20 GHashTable * qemuMonitorExtractQueryStats(virJSONValue *info); + +virJSONValue * +qemuMonitorGetStatsByQOMPath(virJSONValue *arr, + char *qom_path); --=20 2.37.1