From nobody Sat May 4 16:20:48 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=huawei.com Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1626941130263384.21875055746204; Thu, 22 Jul 2021 01:05:30 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-255-_30aUznkM8SjzX2F16ijig-1; Thu, 22 Jul 2021 04:05:27 -0400 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id DB057802C89; Thu, 22 Jul 2021 08:05:21 +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 A038F60C9B; Thu, 22 Jul 2021 08:05:21 +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 5C9554BB7C; Thu, 22 Jul 2021 08:05:21 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 16M85Js6012352 for ; Thu, 22 Jul 2021 04:05:19 -0400 Received: by smtp.corp.redhat.com (Postfix) id 832AC202865A; Thu, 22 Jul 2021 08:05:19 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast01.extmail.prod.ext.rdu2.redhat.com [10.11.55.17]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 7C70D2028668 for ; Thu, 22 Jul 2021 08:05:18 +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 DF30185828D for ; Thu, 22 Jul 2021 08:05:17 +0000 (UTC) Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-242-bzub2RgqPMSf8Cri9rTaZQ-1; Thu, 22 Jul 2021 04:05:13 -0400 Received: from dggemv711-chm.china.huawei.com (unknown [172.30.72.53]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4GVlJn1g7yz7x80; Thu, 22 Jul 2021 16:01:29 +0800 (CST) Received: from dggpeml500009.china.huawei.com (7.185.36.209) by dggemv711-chm.china.huawei.com (10.1.198.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Thu, 22 Jul 2021 16:05:09 +0800 Received: from 90078.china.huawei.com (10.174.187.199) by dggpeml500009.china.huawei.com (7.185.36.209) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Thu, 22 Jul 2021 16:05:08 +0800 X-MC-Unique: _30aUznkM8SjzX2F16ijig-1 X-MC-Unique: bzub2RgqPMSf8Cri9rTaZQ-1 From: Yang Fei To: Subject: [PATCH v4 1/3] util: Add virFileReadValueUllongQuiet Date: Thu, 22 Jul 2021 16:05:00 +0800 Message-ID: <20210722080502.20364-2-yangfei85@huawei.com> In-Reply-To: <20210722080502.20364-1-yangfei85@huawei.com> References: <20210722080502.20364-1-yangfei85@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.174.187.199] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To dggpeml500009.china.huawei.com (7.185.36.209) X-CFilter-Loop: Reflected 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.6 X-MIME-Autoconverted: from quoted-printable to 8bit by lists01.pubmisc.prod.ext.phx2.redhat.com id 16M85Js6012352 X-loop: libvir-list@redhat.com Cc: yubihong@huawei.com, pkrempa@redhat.com, mprivozn@redhat.com, yangfei85@huawei.com, xiexiangyou@huawei.com, liangpeng10@huawei.com 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: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZM-MESSAGEID: 1626941131783100001 Content-Type: text/plain; charset="utf-8" Use function virFileReadValueUllongQuiet to read unsigned long long value without error report. Signed-off-by: Yang Fei Reviewed-by: Michal Privoznik --- src/libvirt_private.syms | 1 + src/util/virfile.c | 24 ++++++++++++++++++++++++ src/util/virfile.h | 2 ++ 3 files changed, 27 insertions(+) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 4bc2974e7f..5429a82a7c 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -2242,6 +2242,7 @@ virFileReadValueScaledInt; virFileReadValueString; virFileReadValueUint; virFileReadValueUllong; +virFileReadValueUllongQuiet; virFileRelLinkPointsTo; virFileRemove; virFileRemoveLastComponent; diff --git a/src/util/virfile.c b/src/util/virfile.c index 723e1ca6e5..70737f4751 100644 --- a/src/util/virfile.c +++ b/src/util/virfile.c @@ -4065,6 +4065,30 @@ virFileReadValueUllong(unsigned long long *value, co= nst char *format, ...) return 0; } =20 +int +virFileReadValueUllongQuiet(unsigned long long *value, const char *format,= ...) +{ + g_autofree char *str =3D NULL; + g_autofree char *path =3D NULL; + va_list ap; + + va_start(ap, format); + path =3D g_strdup_vprintf(format, ap); + va_end(ap); + + if (!virFileExists(path)) + return -2; + + if (virFileReadAllQuiet(path, VIR_INT64_STR_BUFLEN, &str) < 0) + return -1; + + virStringTrimOptionalNewline(str); + + if (virStrToLong_ullp(str, NULL, 10, value) < 0) + return -1; + + return 0; +} =20 /** * virFileReadValueScaledInt: diff --git a/src/util/virfile.h b/src/util/virfile.h index 72368495bf..967c9a9b4f 100644 --- a/src/util/virfile.h +++ b/src/util/virfile.h @@ -339,6 +339,8 @@ int virFileReadValueUint(unsigned int *value, const cha= r *format, ...) G_GNUC_PRINTF(2, 3); int virFileReadValueUllong(unsigned long long *value, const char *format, = ...) G_GNUC_PRINTF(2, 3); +int virFileReadValueUllongQuiet(unsigned long long *value, const char *for= mat, ...) + G_GNUC_PRINTF(2, 3); int virFileReadValueBitmap(virBitmap **value, const char *format, ...) G_GNUC_PRINTF(2, 3); int virFileReadValueScaledInt(unsigned long long *value, const char *forma= t, ...) --=20 2.23.0 From nobody Sat May 4 16:20:48 2024 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; 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=huawei.com 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 1626941140690349.66535604824; Thu, 22 Jul 2021 01:05:40 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-518-xmikhmpnP-qCIUmITEa-aQ-1; Thu, 22 Jul 2021 04:05:38 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id EB778802CB4; Thu, 22 Jul 2021 08:05:31 +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 C5A3D10074E1; Thu, 22 Jul 2021 08:05:31 +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 95CA65003D; Thu, 22 Jul 2021 08:05:31 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 16M85Nao012382 for ; Thu, 22 Jul 2021 04:05:23 -0400 Received: by smtp.corp.redhat.com (Postfix) id 2FF6A103F263; Thu, 22 Jul 2021 08:05:23 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast04.extmail.prod.ext.rdu2.redhat.com [10.11.55.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 2B3B51041AFC for ; Thu, 22 Jul 2021 08:05:19 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-2.mimecast.com [207.211.31.81]) (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 A940B1064C8F for ; Thu, 22 Jul 2021 08:05:19 +0000 (UTC) Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-579-ZWZMeIboOT65LLE_JdO2kg-1; Thu, 22 Jul 2021 04:05:14 -0400 Received: from dggemv704-chm.china.huawei.com (unknown [172.30.72.55]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4GVlK74MC6zchCs; Thu, 22 Jul 2021 16:01:47 +0800 (CST) Received: from dggpeml500009.china.huawei.com (7.185.36.209) by dggemv704-chm.china.huawei.com (10.3.19.47) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Thu, 22 Jul 2021 16:05:11 +0800 Received: from 90078.china.huawei.com (10.174.187.199) by dggpeml500009.china.huawei.com (7.185.36.209) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Thu, 22 Jul 2021 16:05:10 +0800 X-MC-Unique: xmikhmpnP-qCIUmITEa-aQ-1 X-MC-Unique: ZWZMeIboOT65LLE_JdO2kg-1 From: Yang Fei To: Subject: [PATCH v4 2/3] util: Add virHostCPUGetHaltPollTime Date: Thu, 22 Jul 2021 16:05:01 +0800 Message-ID: <20210722080502.20364-3-yangfei85@huawei.com> In-Reply-To: <20210722080502.20364-1-yangfei85@huawei.com> References: <20210722080502.20364-1-yangfei85@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.174.187.199] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To dggpeml500009.china.huawei.com (7.185.36.209) X-CFilter-Loop: Reflected 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.3 X-MIME-Autoconverted: from quoted-printable to 8bit by lists01.pubmisc.prod.ext.phx2.redhat.com id 16M85Nao012382 X-loop: libvir-list@redhat.com Cc: yubihong@huawei.com, pkrempa@redhat.com, mprivozn@redhat.com, yangfei85@huawei.com, xiexiangyou@huawei.com, liangpeng10@huawei.com 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: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZM-MESSAGEID: 1626941141104100001 Content-Type: text/plain; charset="utf-8" Add helper function virHostCPUGetHaltPollTime to obtain halt polling time. If the kernel support halt polling time statistic, and mount debugfs. This function will take effect on KVM VMs. Signed-off-by: Yang Fei Reviewed-by: Michal Privoznik --- src/libvirt_private.syms | 1 + src/util/virhostcpu.c | 39 +++++++++++++++++++++++++++++++++++++++ src/util/virhostcpu.h | 4 ++++ 3 files changed, 44 insertions(+) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 5429a82a7c..531ba03cf7 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -2374,6 +2374,7 @@ virHookPresent; # util/virhostcpu.h virHostCPUGetAvailableCPUsBitmap; virHostCPUGetCount; +virHostCPUGetHaltPollTime; virHostCPUGetInfo; virHostCPUGetKVMMaxVCPUs; virHostCPUGetMap; diff --git a/src/util/virhostcpu.c b/src/util/virhostcpu.c index bf7fda23af..7f577c3e3e 100644 --- a/src/util/virhostcpu.c +++ b/src/util/virhostcpu.c @@ -1535,3 +1535,42 @@ virHostCPUGetSignature(char **signature) } =20 #endif /* __linux__ */ + +int +virHostCPUGetHaltPollTime(pid_t pid, + unsigned long long *haltPollSuccess, + unsigned long long *haltPollFail) +{ + g_autofree char *pidToStr =3D NULL; + g_autofree char *debugFsPath =3D NULL; + g_autofree char *kvmPath =3D NULL; + struct dirent *ent =3D NULL; + g_autoptr(DIR) dir =3D NULL; + bool found =3D false; + + if (!(debugFsPath =3D virFileFindMountPoint("debugfs"))) + return -1; + + kvmPath =3D g_strdup_printf("%s/%s", debugFsPath, "kvm"); + if (virDirOpenQuiet(&dir, kvmPath) !=3D 1) + return -1; + + pidToStr =3D g_strdup_printf("%lld%c", (long long)pid, '-'); + while (virDirRead(dir, &ent, NULL) > 0) { + if (STRPREFIX(ent->d_name, pidToStr)) { + found =3D true; + break; + } + } + + if (!found) + return -1; + + if (virFileReadValueUllongQuiet(haltPollSuccess, "%s/%s/%s", kvmPath, + ent->d_name, "halt_poll_success_ns") <= 0 || + virFileReadValueUllongQuiet(haltPollFail, "%s/%s/%s", kvmPath, + ent->d_name, "halt_poll_fail_ns") < 0) + return -1; + + return 0; +} diff --git a/src/util/virhostcpu.h b/src/util/virhostcpu.h index fc717250d9..d98385d53f 100644 --- a/src/util/virhostcpu.h +++ b/src/util/virhostcpu.h @@ -83,3 +83,7 @@ int virHostCPUGetMSR(unsigned long index, virHostCPUTscInfo *virHostCPUGetTscInfo(void); =20 int virHostCPUGetSignature(char **signature); + +int virHostCPUGetHaltPollTime(pid_t pid, + unsigned long long *haltPollSuccess, + unsigned long long *haltPollFail); --=20 2.23.0 From nobody Sat May 4 16:20:48 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=huawei.com Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 16269411324833.459558368889361; Thu, 22 Jul 2021 01:05:32 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-415-zSLAPia2ODST96ey923qNA-1; Thu, 22 Jul 2021 04:05:30 -0400 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id B837F1005D57; Thu, 22 Jul 2021 08:05:24 +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 6AC475C1BB; Thu, 22 Jul 2021 08:05:24 +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 2FE131818481; Thu, 22 Jul 2021 08:05:24 +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 16M85MO5012371 for ; Thu, 22 Jul 2021 04:05:22 -0400 Received: by smtp.corp.redhat.com (Postfix) id 70D2E208DD9A; Thu, 22 Jul 2021 08:05:22 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast04.extmail.prod.ext.rdu2.redhat.com [10.11.55.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 6C482208DD99 for ; Thu, 22 Jul 2021 08:05:19 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-2.mimecast.com [205.139.110.61]) (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 2F597101A529 for ; Thu, 22 Jul 2021 08:05:19 +0000 (UTC) Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-584-VuW739JkPxa2xOYhJLkVnw-1; Thu, 22 Jul 2021 04:05:16 -0400 Received: from dggemv703-chm.china.huawei.com (unknown [172.30.72.53]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4GVlGN33FGzYctT; Thu, 22 Jul 2021 15:59:24 +0800 (CST) Received: from dggpeml500009.china.huawei.com (7.185.36.209) by dggemv703-chm.china.huawei.com (10.3.19.46) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Thu, 22 Jul 2021 16:05:12 +0800 Received: from 90078.china.huawei.com (10.174.187.199) by dggpeml500009.china.huawei.com (7.185.36.209) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Thu, 22 Jul 2021 16:05:12 +0800 X-MC-Unique: zSLAPia2ODST96ey923qNA-1 X-MC-Unique: VuW739JkPxa2xOYhJLkVnw-1 From: Yang Fei To: Subject: [PATCH v4 3/3] qemu: Introduce qemuDomainGetStatsCpuHaltPollTime Date: Thu, 22 Jul 2021 16:05:02 +0800 Message-ID: <20210722080502.20364-4-yangfei85@huawei.com> In-Reply-To: <20210722080502.20364-1-yangfei85@huawei.com> References: <20210722080502.20364-1-yangfei85@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.174.187.199] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To dggpeml500009.china.huawei.com (7.185.36.209) X-CFilter-Loop: Reflected 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-MIME-Autoconverted: from quoted-printable to 8bit by lists01.pubmisc.prod.ext.phx2.redhat.com id 16M85MO5012371 X-loop: libvir-list@redhat.com Cc: yubihong@huawei.com, pkrempa@redhat.com, mprivozn@redhat.com, yangfei85@huawei.com, xiexiangyou@huawei.com, liangpeng10@huawei.com 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: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZM-MESSAGEID: 1626941134126100001 Content-Type: text/plain; charset="utf-8" This function add halt polling time interface in domstats. So that we can use command 'virsh domstats VM' to get the data if system support. Signed-off-by: Yang Fei Reviewed-by: Michal Privoznik --- docs/manpages/virsh.rst | 4 ++++ src/libvirt-domain.c | 7 +++++++ src/qemu/qemu_driver.c | 20 ++++++++++++++++++++ 3 files changed, 31 insertions(+) diff --git a/docs/manpages/virsh.rst b/docs/manpages/virsh.rst index 87668f2b9a..20936994ce 100644 --- a/docs/manpages/virsh.rst +++ b/docs/manpages/virsh.rst @@ -2260,6 +2260,10 @@ When selecting the *--state* group the following fie= lds are returned: * ``cpu.time`` - total cpu time spent for this domain in nanoseconds * ``cpu.user`` - user cpu time spent in nanoseconds * ``cpu.system`` - system cpu time spent in nanoseconds +* ``cpu.haltpoll.success.time`` - cpu halt polling success time spent in + nanoseconds +* ``cpu.haltpoll.fail.time`` - cpu halt polling fail time spent in + nanoseconds * ``cpu.cache.monitor.count`` - the number of cache monitors for this domain * ``cpu.cache.monitor..name`` - the name of cache monitor diff --git a/src/libvirt-domain.c b/src/libvirt-domain.c index 35c0df0ebc..4eb14d4176 100644 --- a/src/libvirt-domain.c +++ b/src/libvirt-domain.c @@ -11625,6 +11625,13 @@ virConnectGetDomainCapabilities(virConnectPtr conn, * "cpu.user" - user cpu time spent in nanoseconds as unsigned long lo= ng. * "cpu.system" - system cpu time spent in nanoseconds as unsigned long * long. + * "cpu.haltpoll.success.time" - halt-polling cpu usage about the VCPU= polled + * until a virtual interrupt was deliver= ed in + * nanoseconds as unsigned long long. + * "cpu.haltpoll.fail.time" - halt-polling cpu usage about the VCPU ha= d to schedule + * out (either because the maximum poll tim= e was reached + * or it needed to yield the CPU) in nanose= conds as + * unsigned long long. * "cpu.cache.monitor.count" - the number of cache monitors for this d= omain * "cpu.cache.monitor..name" - the name of cache monitor * "cpu.cache.monitor..vcpus" - vcpu list of cache monitor diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 521063d438..79308b7157 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -17857,6 +17857,23 @@ qemuDomainGetStatsCpuCgroup(virDomainObj *dom, return 0; } =20 +static int +qemuDomainGetStatsCpuHaltPollTime(virDomainObj *dom, + virTypedParamList *params) +{ + unsigned long long haltPollSuccess =3D 0; + unsigned long long haltPollFail =3D 0; + pid_t pid =3D dom->pid; + + if (virHostCPUGetHaltPollTime(pid, &haltPollSuccess, &haltPollFail) < = 0) + return 0; + + if (virTypedParamListAddULLong(params, haltPollSuccess, "cpu.haltpoll.= success.time") < 0 || + virTypedParamListAddULLong(params, haltPollFail, "cpu.haltpoll.fai= l.time") < 0) + return -1; + + return 0; +} =20 static int qemuDomainGetStatsCpu(virQEMUDriver *driver, @@ -17870,6 +17887,9 @@ qemuDomainGetStatsCpu(virQEMUDriver *driver, if (qemuDomainGetStatsCpuCache(driver, dom, params) < 0) return -1; =20 + if (qemuDomainGetStatsCpuHaltPollTime(dom, params) < 0) + return -1; + return 0; } =20 --=20 2.23.0