From nobody Thu Jul 3 20:35:01 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 1529050786912207.6722999075879; Fri, 15 Jun 2018 01:19:46 -0700 (PDT) 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 mx1.redhat.com (Postfix) with ESMTPS id B3583C04BD5D; Fri, 15 Jun 2018 08:19: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 80609B543C; Fri, 15 Jun 2018 08:19: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 31E5A4CA81; Fri, 15 Jun 2018 08:19:45 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w5F8IpWg028796 for ; Fri, 15 Jun 2018 04:18:52 -0400 Received: by smtp.corp.redhat.com (Postfix) id D3837210C6D1; Fri, 15 Jun 2018 08:18:51 +0000 (UTC) Received: from moe.brq.redhat.com (unknown [10.43.2.192]) by smtp.corp.redhat.com (Postfix) with ESMTP id 778FA2017D10 for ; Fri, 15 Jun 2018 08:18:51 +0000 (UTC) From: Michal Privoznik To: libvir-list@redhat.com Date: Fri, 15 Jun 2018 10:18:33 +0200 Message-Id: In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v2 4/5] Introduce VIR_CONNECT_GET_ALL_DOMAINS_STATS_NOWAIT 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.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Fri, 15 Jun 2018 08:19:46 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" https://bugzilla.redhat.com/show_bug.cgi?id=3D1552092 If there's a long running job it might cause us to wait 30 seconds before we give up acquiring the job. This is problematic to interactive applications that fetch stats repeatedly every few seconds. The solution is to introduce VIR_CONNECT_GET_ALL_DOMAINS_STATS_NOWAIT flag which tries to acquire job but does not wait if acquiring failed. Signed-off-by: Michal Privoznik Reviewed-by: John Ferlan --- include/libvirt/libvirt-domain.h | 2 ++ src/libvirt-domain.c | 12 ++++++++++++ src/qemu/qemu_driver.c | 15 ++++++++++++--- 3 files changed, 26 insertions(+), 3 deletions(-) diff --git a/include/libvirt/libvirt-domain.h b/include/libvirt/libvirt-dom= ain.h index 3ef7c24528..796f2e1408 100644 --- a/include/libvirt/libvirt-domain.h +++ b/include/libvirt/libvirt-domain.h @@ -2055,6 +2055,8 @@ typedef enum { VIR_CONNECT_GET_ALL_DOMAINS_STATS_SHUTOFF =3D VIR_CONNECT_LIST_DOMAINS= _SHUTOFF, VIR_CONNECT_GET_ALL_DOMAINS_STATS_OTHER =3D VIR_CONNECT_LIST_DOMAINS_O= THER, =20 + VIR_CONNECT_GET_ALL_DOMAINS_STATS_NOWAIT =3D 1 << 29, /* report statis= tics that can be obtained + immediately wit= hout any blocking */ VIR_CONNECT_GET_ALL_DOMAINS_STATS_BACKING =3D 1 << 30, /* include back= ing chain for block stats */ VIR_CONNECT_GET_ALL_DOMAINS_STATS_ENFORCE_STATS =3D 1U << 31, /* enfor= ce requested stats */ } virConnectGetAllDomainStatsFlags; diff --git a/src/libvirt-domain.c b/src/libvirt-domain.c index 4a899f31c8..c71f2e6877 100644 --- a/src/libvirt-domain.c +++ b/src/libvirt-domain.c @@ -11502,6 +11502,12 @@ virConnectGetDomainCapabilities(virConnectPtr conn, * fields for offline domains if the statistics are meaningful only for a * running domain. * + * Passing VIR_CONNECT_GET_ALL_DOMAINS_STATS_NOWAIT in + * @flags means when libvirt is unable to fetch stats for any of + * the domains (for whatever reason) only a subset of statistics + * is returned for the domain. That subset being statistics that + * don't involve querying the underlying hypervisor. + * * Similarly to virConnectListAllDomains, @flags can contain various flags= to * filter the list of domains to provide stats for. * @@ -11586,6 +11592,12 @@ virConnectGetAllDomainStats(virConnectPtr conn, * fields for offline domains if the statistics are meaningful only for a * running domain. * + * Passing VIR_CONNECT_GET_ALL_DOMAINS_STATS_NOWAIT in + * @flags means when libvirt is unable to fetch stats for any of + * the domains (for whatever reason) only a subset of statistics + * is returned for the domain. That subset being statistics that + * don't involve querying the underlying hypervisor. + * * Note that any of the domain list filtering flags in @flags may be rejec= ted * by this function. * diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 42069ee617..35038889a3 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -20428,6 +20428,7 @@ qemuConnectGetAllDomainStats(virConnectPtr conn, virCheckFlags(VIR_CONNECT_LIST_DOMAINS_FILTERS_ACTIVE | VIR_CONNECT_LIST_DOMAINS_FILTERS_PERSISTENT | VIR_CONNECT_LIST_DOMAINS_FILTERS_STATE | + VIR_CONNECT_GET_ALL_DOMAINS_STATS_NOWAIT | VIR_CONNECT_GET_ALL_DOMAINS_STATS_BACKING | VIR_CONNECT_GET_ALL_DOMAINS_STATS_ENFORCE_STATS, -1); =20 @@ -20462,9 +20463,17 @@ qemuConnectGetAllDomainStats(virConnectPtr conn, =20 virObjectLock(vm); =20 - if (HAVE_JOB(privflags) && - qemuDomainObjBeginJob(driver, vm, QEMU_JOB_QUERY) =3D=3D 0) - domflags |=3D QEMU_DOMAIN_STATS_HAVE_JOB; + if (HAVE_JOB(privflags)) { + int rv; + + if (flags & VIR_CONNECT_GET_ALL_DOMAINS_STATS_NOWAIT) + rv =3D qemuDomainObjBeginJobNowait(driver, vm, QEMU_JOB_QU= ERY); + else + rv =3D qemuDomainObjBeginJob(driver, vm, QEMU_JOB_QUERY); + + if (rv =3D=3D 0) + domflags |=3D QEMU_DOMAIN_STATS_HAVE_JOB; + } /* else: without a job it's still possible to gather some data */ =20 if (flags & VIR_CONNECT_GET_ALL_DOMAINS_STATS_BACKING) --=20 2.16.4 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list