From nobody Thu May 15 00:09:07 2025 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 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1517931122295447.7930420527997; Tue, 6 Feb 2018 07:32:02 -0800 (PST) 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 24F933AD98; Tue, 6 Feb 2018 15:32:01 +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 BA16A2D35B; Tue, 6 Feb 2018 15:32: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 4D1BE4A46C; Tue, 6 Feb 2018 15:32:00 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w16FVq1Y022869 for ; Tue, 6 Feb 2018 10:31:52 -0500 Received: by smtp.corp.redhat.com (Postfix) id 5C1AC60C4D; Tue, 6 Feb 2018 15:31:52 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.136]) by smtp.corp.redhat.com (Postfix) with ESMTP id 33ABC51C3F; Tue, 6 Feb 2018 15:31:44 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Tue, 6 Feb 2018 16:30:52 +0100 Message-Id: <681d15f17395fdeaf9be461d2dd94d092d27ed97.1517930985.git.pkrempa@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com Cc: Peter Krempa Subject: [libvirt] [PATCH 1/4] qemu: driver: Extract vcpu halted state directly 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: , MIME-Version: 1.0 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.38]); Tue, 06 Feb 2018 15:32:01 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Don't extract the halted state into a separate array, but rater access the vcpu structures directly. We still need to call the vcpu helper to retrieve the performance statistics though. --- src/qemu/qemu_driver.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index bff49e7be6..172a8a3f73 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -19660,12 +19660,14 @@ qemuDomainGetStatsVcpu(virQEMUDriverPtr driver, int *maxparams, unsigned int privflags) { + virDomainVcpuDefPtr vcpu; + qemuDomainVcpuPrivatePtr vcpupriv; size_t i; int ret =3D -1; char param_name[VIR_TYPED_PARAM_FIELD_LENGTH]; virVcpuInfoPtr cpuinfo =3D NULL; unsigned long long *cpuwait =3D NULL; - bool *cpuhalted =3D NULL; + bool vcpuhalted =3D false; if (virTypedParamsAddUInt(&record->params, &record->nparams, @@ -19691,14 +19693,14 @@ qemuDomainGetStatsVcpu(virQEMUDriverPtr driver, /* it's ok to be silent and go ahead, because halted vcpu info * wasn't here from the beginning */ virResetLastError(); - } else if (VIR_ALLOC_N(cpuhalted, virDomainDefGetVcpus(dom->def)) = < 0) { - goto cleanup; + } else { + vcpuhalted =3D true; } } if (qemuDomainHelperGetVcpus(dom, cpuinfo, cpuwait, virDomainDefGetVcpus(dom->def), - NULL, 0, cpuhalted) < 0) { + NULL, 0, NULL) < 0) { virResetLastError(); ret =3D 0; /* it's ok to be silent and go ahead */ goto cleanup; @@ -19735,14 +19737,20 @@ qemuDomainGetStatsVcpu(virQEMUDriverPtr driver, cpuwait[i]) < 0) goto cleanup; - if (cpuhalted) { + /* state below is extracted from the individual vcpu structs */ + if (!(vcpu =3D virDomainDefGetVcpu(dom->def, cpuinfo[i].number))) + continue; + + vcpupriv =3D QEMU_DOMAIN_VCPU_PRIVATE(vcpu); + + if (vcpuhalted) { snprintf(param_name, VIR_TYPED_PARAM_FIELD_LENGTH, "vcpu.%u.halted", cpuinfo[i].number); if (virTypedParamsAddBoolean(&record->params, &record->nparams, maxparams, param_name, - cpuhalted[i]) < 0) + vcpupriv->halted) < 0) goto cleanup; } } @@ -19752,7 +19760,6 @@ qemuDomainGetStatsVcpu(virQEMUDriverPtr driver, cleanup: VIR_FREE(cpuinfo); VIR_FREE(cpuwait); - VIR_FREE(cpuhalted); return ret; } --=20 2.15.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list