From nobody Thu May 15 13:20:24 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 1517931175018843.7732544035042; Tue, 6 Feb 2018 07:32:55 -0800 (PST) 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 mx1.redhat.com (Postfix) with ESMTPS id CE1925415E; Tue, 6 Feb 2018 15:32:53 +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 9E95F51DD7; Tue, 6 Feb 2018 15:32: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 CD1F54A477; Tue, 6 Feb 2018 15:32:49 +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 w16FWms0023320 for ; Tue, 6 Feb 2018 10:32:48 -0500 Received: by smtp.corp.redhat.com (Postfix) id CBDD951C5C; Tue, 6 Feb 2018 15:32:48 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.136]) by smtp.corp.redhat.com (Postfix) with ESMTP id 40F1F609C0; Tue, 6 Feb 2018 15:32:00 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Tue, 6 Feb 2018 16:30:54 +0100 Message-Id: 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 3/4] qemu: domain: Store vcpu halted state as a tristate 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.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Tue, 06 Feb 2018 15:32:54 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Since it may be possible that the state is unknown in some cases we should store it as a tristate so that other code using it can determine whether the state was updated. --- src/qemu/qemu_domain.c | 3 ++- src/qemu/qemu_domain.h | 2 +- src/qemu/qemu_driver.c | 13 ++++--------- 3 files changed, 7 insertions(+), 11 deletions(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 429660689b..5395cd093c 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -8737,7 +8737,8 @@ qemuDomainRefreshVcpuHalted(virQEMUDriverPtr driver, for (i =3D 0; i < maxvcpus; i++) { vcpu =3D virDomainDefGetVcpu(vm->def, i); vcpupriv =3D QEMU_DOMAIN_VCPU_PRIVATE(vcpu); - vcpupriv->halted =3D virBitmapIsBitSet(haltedmap, vcpupriv->qemu_i= d); + vcpupriv->halted =3D virTristateBoolFromBool(virBitmapIsBitSet(hal= tedmap, + vcpup= riv->qemu_id)); } ret =3D 0; diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h index 25328cd110..f3ec5d8042 100644 --- a/src/qemu/qemu_domain.h +++ b/src/qemu/qemu_domain.h @@ -399,7 +399,7 @@ struct _qemuDomainVcpuPrivate { int enable_id; /* order in which the vcpus were enabled in qemu */ int qemu_id; /* ID reported by qemu as 'CPU' in query-cpus */ char *alias; - bool halted; + virTristateBool halted; /* information for hotpluggable cpus */ char *type; diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index eaa6049fee..8d77d8913a 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -19659,7 +19659,6 @@ qemuDomainGetStatsVcpu(virQEMUDriverPtr driver, char param_name[VIR_TYPED_PARAM_FIELD_LENGTH]; virVcpuInfoPtr cpuinfo =3D NULL; unsigned long long *cpuwait =3D NULL; - bool vcpuhalted =3D false; if (virTypedParamsAddUInt(&record->params, &record->nparams, @@ -19679,15 +19678,11 @@ qemuDomainGetStatsVcpu(virQEMUDriverPtr driver, VIR_ALLOC_N(cpuwait, virDomainDefGetVcpus(dom->def)) < 0) goto cleanup; - if (HAVE_JOB(privflags) && virDomainObjIsActive(dom)) { - if (qemuDomainRefreshVcpuHalted(driver, dom, - QEMU_ASYNC_JOB_NONE) < 0) { + if (HAVE_JOB(privflags) && virDomainObjIsActive(dom) && + qemuDomainRefreshVcpuHalted(driver, dom, QEMU_ASYNC_JOB_NONE) < 0)= { /* it's ok to be silent and go ahead, because halted vcpu info * wasn't here from the beginning */ virResetLastError(); - } else { - vcpuhalted =3D true; - } } if (qemuDomainHelperGetVcpus(dom, cpuinfo, cpuwait, @@ -19735,14 +19730,14 @@ qemuDomainGetStatsVcpu(virQEMUDriverPtr driver, vcpupriv =3D QEMU_DOMAIN_VCPU_PRIVATE(vcpu); - if (vcpuhalted) { + if (vcpupriv->halted !=3D VIR_TRISTATE_BOOL_ABSENT) { snprintf(param_name, VIR_TYPED_PARAM_FIELD_LENGTH, "vcpu.%u.halted", cpuinfo[i].number); if (virTypedParamsAddBoolean(&record->params, &record->nparams, maxparams, param_name, - vcpupriv->halted) < 0) + vcpupriv->halted =3D=3D VIR_TRIST= ATE_BOOL_YES) < 0) goto cleanup; } } --=20 2.15.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list