From nobody Thu May 9 05:03:55 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 ARC-Seal: i=1; a=rsa-sha256; t=1615898016; cv=none; d=zohomail.com; s=zohoarc; b=P7GhOw2bJ3zM5baSpD3P+cwArwiCXNP099WhF5rSUhDsNRI9EmX9vial4QnCX6LwxnzRXrdEBO8G0fTdTU7+TcIrQojfhEkii2cd6IymbD7lCc24w5n0PI5DyGulx5MW9R2/RK2lclAvTMmpFkPK/7rxndobt8U4/kpeljDoFpA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1615898016; 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=fyoEWbgnAzWGjaHzM7FVJirLBoCtsgmK+Clb+zrPplk=; b=ROJPARI54VELsx+13j4MnllP24baPqE7MxU5iedtOWD/8/aCpJXJVB1Jym0uXBy9nqiMou4W0fH+HTooEF/Cx1fJemZU5oiAM5QsTpOrjl2PyXu7JBV2VDtuAZp37fG5oMhxcQ0mDvFPdOLwW70SmyFxz1ntcZ3CDtvGN5hMbPU= ARC-Authentication-Results: i=1; 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 header.from= (p=none dis=none) header.from= 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 1615898016533628.1237736801041; Tue, 16 Mar 2021 05:33:36 -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-56-dkUWIFYDNB6s-oyL5_qT8w-1; Tue, 16 Mar 2021 08:33:33 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id C25E7192D787; Tue, 16 Mar 2021 12:33:27 +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 EF9BB6C43A; Tue, 16 Mar 2021 12:33:26 +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 AE46557DC1; Tue, 16 Mar 2021 12:33:26 +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 12GCXFR8030732 for ; Tue, 16 Mar 2021 08:33:16 -0400 Received: by smtp.corp.redhat.com (Postfix) id C56992166BB3; Tue, 16 Mar 2021 12:33:15 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast05.extmail.prod.ext.rdu2.redhat.com [10.11.55.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id BFB092166BA9 for ; Tue, 16 Mar 2021 12:33:13 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-1.mimecast.com [207.211.31.81]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 018A880B921 for ; Tue, 16 Mar 2021 12:33:13 +0000 (UTC) Received: from szxga07-in.huawei.com (szxga07-in.huawei.com [45.249.212.35]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-577-or7sRRqiNf-PS4eykhCv9g-1; Tue, 16 Mar 2021 08:33:07 -0400 Received: from DGGEMS404-HUB.china.huawei.com (unknown [172.30.72.59]) by szxga07-in.huawei.com (SkyGuard) with ESMTP id 4F0CM21tm4z9060; Tue, 16 Mar 2021 20:31:10 +0800 (CST) Received: from huawei.com (10.175.104.175) by DGGEMS404-HUB.china.huawei.com (10.3.19.204) with Microsoft SMTP Server id 14.3.498.0; Tue, 16 Mar 2021 20:32:52 +0800 X-MC-Unique: dkUWIFYDNB6s-oyL5_qT8w-1 X-MC-Unique: or7sRRqiNf-PS4eykhCv9g-1 From: Hao Wang To: Subject: [PATCH v7 1/7] migration/dirtyrate: Introduce virDomainStartDirtyRateCalc API Date: Tue, 16 Mar 2021 20:32:45 +0800 Message-ID: <20210316123251.511485-2-wanghao232@huawei.com> In-Reply-To: <20210316123251.511485-1-wanghao232@huawei.com> References: <20210316123251.511485-1-wanghao232@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.104.175] 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 12GCXFR8030732 X-loop: libvir-list@redhat.com Cc: yubihong@huawei.com, zhengchuan@huawei.com, pkrempa@redhat.com, zhang.zhanghailiang@huawei.com, mprivozn@redhat.com, danielhb413@gmail.com, xiexiangyou@huawei.com, alex.chen@huawei.com, wanghao232@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.11 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 Content-Type: text/plain; charset="utf-8" Introduce virDomainStartDirtyRateCalc API for start calculation of a domain's memory dirty rate with a specified time. Signed-off-by: Hao Wang Reviewed-by: Michal Privoznik --- include/libvirt/libvirt-domain.h | 4 +++ src/driver-hypervisor.h | 6 +++++ src/libvirt-domain.c | 44 ++++++++++++++++++++++++++++++++ src/libvirt_public.syms | 5 ++++ src/remote/remote_driver.c | 1 + src/remote/remote_protocol.x | 14 +++++++++- src/remote_protocol-structs | 6 +++++ 7 files changed, 79 insertions(+), 1 deletion(-) diff --git a/include/libvirt/libvirt-domain.h b/include/libvirt/libvirt-dom= ain.h index 8011cf9fe1..7aa5ef4543 100644 --- a/include/libvirt/libvirt-domain.h +++ b/include/libvirt/libvirt-domain.h @@ -5128,4 +5128,8 @@ int virDomainGetMessages(virDomainPtr domain, char ***msgs, unsigned int flags); =20 +int virDomainStartDirtyRateCalc(virDomainPtr domain, + int seconds, + unsigned int flags); + #endif /* LIBVIRT_DOMAIN_H */ diff --git a/src/driver-hypervisor.h b/src/driver-hypervisor.h index 05d7dfb5c7..2ec7b8b24a 100644 --- a/src/driver-hypervisor.h +++ b/src/driver-hypervisor.h @@ -1405,6 +1405,11 @@ typedef int char ***msgs, unsigned int flags); =20 +typedef int +(*virDrvDomainStartDirtyRateCalc)(virDomainPtr domain, + int seconds, + unsigned int flags); + typedef struct _virHypervisorDriver virHypervisorDriver; typedef virHypervisorDriver *virHypervisorDriverPtr; =20 @@ -1671,4 +1676,5 @@ struct _virHypervisorDriver { virDrvDomainAuthorizedSSHKeysGet domainAuthorizedSSHKeysGet; virDrvDomainAuthorizedSSHKeysSet domainAuthorizedSSHKeysSet; virDrvDomainGetMessages domainGetMessages; + virDrvDomainStartDirtyRateCalc domainStartDirtyRateCalc; }; diff --git a/src/libvirt-domain.c b/src/libvirt-domain.c index e54d11e513..91001fc4ed 100644 --- a/src/libvirt-domain.c +++ b/src/libvirt-domain.c @@ -13158,3 +13158,47 @@ virDomainGetMessages(virDomainPtr domain, virDispatchError(conn); return -1; } + + +/** + * virDomainStartDirtyRateCalc: + * @domain: a domain object + * @seconds: specified calculating time in seconds + * @flags: extra flags; not used yet, so callers should always pass 0 + * + * Calculate the current domain's memory dirty rate in next @seconds. + * The calculated dirty rate information is available by calling + * virConnectGetAllDomainStats. + * + * Returns 0 in case of success, -1 otherwise. + */ +int +virDomainStartDirtyRateCalc(virDomainPtr domain, + int seconds, + unsigned int flags) +{ + virConnectPtr conn; + + VIR_DOMAIN_DEBUG(domain, "seconds=3D%d, flags=3D0x%x", seconds, flags); + + virResetLastError(); + + virCheckDomainReturn(domain, -1); + conn =3D domain->conn; + + virCheckReadOnlyGoto(conn->flags, error); + + if (conn->driver->domainStartDirtyRateCalc) { + int ret; + ret =3D conn->driver->domainStartDirtyRateCalc(domain, seconds, fl= ags); + if (ret < 0) + goto error; + return ret; + } + + virReportUnsupportedError(); + + error: + virDispatchError(conn); + return -1; +} diff --git a/src/libvirt_public.syms b/src/libvirt_public.syms index d851333eb0..51a3d7265a 100644 --- a/src/libvirt_public.syms +++ b/src/libvirt_public.syms @@ -884,4 +884,9 @@ LIBVIRT_7.1.0 { virDomainGetMessages; } LIBVIRT_6.10.0; =20 +LIBVIRT_7.2.0 { + global: + virDomainStartDirtyRateCalc; +} LIBVIRT_7.1.0; + # .... define new API here using predicted next version number .... diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c index 31868269b1..494f4b6dc5 100644 --- a/src/remote/remote_driver.c +++ b/src/remote/remote_driver.c @@ -8571,6 +8571,7 @@ static virHypervisorDriver hypervisor_driver =3D { .domainAuthorizedSSHKeysGet =3D remoteDomainAuthorizedSSHKeysGet, /* 6= .10.0 */ .domainAuthorizedSSHKeysSet =3D remoteDomainAuthorizedSSHKeysSet, /* 6= .10.0 */ .domainGetMessages =3D remoteDomainGetMessages, /* 7.1.0 */ + .domainStartDirtyRateCalc =3D remoteDomainStartDirtyRateCalc, /* 7.2.0= */ }; =20 static virNetworkDriver network_driver =3D { diff --git a/src/remote/remote_protocol.x b/src/remote/remote_protocol.x index d3724bc305..7fdc65f029 100644 --- a/src/remote/remote_protocol.x +++ b/src/remote/remote_protocol.x @@ -3811,6 +3811,12 @@ struct remote_domain_get_messages_ret { remote_nonnull_string msgs; }; =20 +struct remote_domain_start_dirty_rate_calc_args { + remote_nonnull_domain dom; + int seconds; + unsigned int flags; +}; + =20 /*----- Protocol. -----*/ =20 @@ -6733,5 +6739,11 @@ enum remote_procedure { * @generate: none * @acl: domain:read */ - REMOTE_PROC_DOMAIN_GET_MESSAGES =3D 426 + REMOTE_PROC_DOMAIN_GET_MESSAGES =3D 426, + + /** + * @generate: both + * @acl: domain:read + */ + REMOTE_PROC_DOMAIN_START_DIRTY_RATE_CALC =3D 427 }; diff --git a/src/remote_protocol-structs b/src/remote_protocol-structs index c0c034ac6a..d13dc81a82 100644 --- a/src/remote_protocol-structs +++ b/src/remote_protocol-structs @@ -3172,6 +3172,11 @@ struct remote_domain_get_messages_ret { remote_nonnull_string * msgs_val; } msgs; }; +struct remote_domain_start_dirty_rate_calc_args { + remote_nonnull_domain dom; + int seconds; + u_int flags; +}; enum remote_procedure { REMOTE_PROC_CONNECT_OPEN =3D 1, REMOTE_PROC_CONNECT_CLOSE =3D 2, @@ -3599,4 +3604,5 @@ enum remote_procedure { REMOTE_PROC_DOMAIN_AUTHORIZED_SSH_KEYS_GET =3D 424, REMOTE_PROC_DOMAIN_AUTHORIZED_SSH_KEYS_SET =3D 425, REMOTE_PROC_DOMAIN_GET_MESSAGES =3D 426, + REMOTE_PROC_DOMAIN_START_DIRTY_RATE_CALC =3D 427, }; --=20 2.23.0 From nobody Thu May 9 05:03:55 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.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 63.128.21.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=huawei.com ARC-Seal: i=1; a=rsa-sha256; t=1615898025; cv=none; d=zohomail.com; s=zohoarc; b=PJi1gnGUZgGr9XCmgK/SLCmlza8xm3397KQl2pDiSmigHigkumGjXtls0bdOdEv/1NxOrSlhdbc75w0Ii1H1fqgTGOSbHTde07AGWoUisudGTn7CeOTeqSbvjgSyHWGFpB/IWQZmhKVtxqqLYgTB3slWTrt2UxjpZE6Dn8lcNIw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1615898025; 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=BBii5EmJoc/KQEKdsWF2IK1R7F7XT3NboL3NfkicPrg=; b=GdRXXtF7iVqz0wMJEmjQUrsRuQrwoVQUEbiBlebZVzt67q4iShpFUz0d0bTAV4PejPD9TYUcWK5ylUdRKeew6XMFirRbMUEaFLDDPYZMp4xLXVE//EZJZkP3iOH36syeIQpDXOuuw+a7F5rLg3iazAab7sQ0W9bCzZyXEiGK1F8= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by mx.zohomail.com with SMTPS id 161589802574031.32228194636309; Tue, 16 Mar 2021 05:33:45 -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-448-SPkkEkHdO2yUKPF_AbWGjw-1; Tue, 16 Mar 2021 08:33:42 -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 DAA44192D78F; Tue, 16 Mar 2021 12:33:36 +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 AB8F067CC4; Tue, 16 Mar 2021 12:33:36 +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 50DE71800B8B; Tue, 16 Mar 2021 12:33:36 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 12GCXYRd030825 for ; Tue, 16 Mar 2021 08:33:34 -0400 Received: by smtp.corp.redhat.com (Postfix) id 42C036E1BC; Tue, 16 Mar 2021 12:33:34 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast02.extmail.prod.ext.rdu2.redhat.com [10.11.55.18]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 3D58B6E1BF for ; Tue, 16 Mar 2021 12:33:31 +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-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 4B4768001A6 for ; Tue, 16 Mar 2021 12:33:31 +0000 (UTC) Received: from szxga07-in.huawei.com (szxga07-in.huawei.com [45.249.212.35]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-579-tKzso_m1PJ6HeBxaQGT6vA-1; Tue, 16 Mar 2021 08:33:14 -0400 Received: from DGGEMS404-HUB.china.huawei.com (unknown [172.30.72.59]) by szxga07-in.huawei.com (SkyGuard) with ESMTP id 4F0CM2115nz905k; Tue, 16 Mar 2021 20:31:10 +0800 (CST) Received: from huawei.com (10.175.104.175) by DGGEMS404-HUB.china.huawei.com (10.3.19.204) with Microsoft SMTP Server id 14.3.498.0; Tue, 16 Mar 2021 20:32:53 +0800 X-MC-Unique: SPkkEkHdO2yUKPF_AbWGjw-1 X-MC-Unique: tKzso_m1PJ6HeBxaQGT6vA-1 From: Hao Wang To: Subject: [PATCH v7 2/7] migration/dirtyrate: Implement qemuDomainStartDirtyRateCalc Date: Tue, 16 Mar 2021 20:32:46 +0800 Message-ID: <20210316123251.511485-3-wanghao232@huawei.com> In-Reply-To: <20210316123251.511485-1-wanghao232@huawei.com> References: <20210316123251.511485-1-wanghao232@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.104.175] 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.79 on 10.11.54.5 X-MIME-Autoconverted: from quoted-printable to 8bit by lists01.pubmisc.prod.ext.phx2.redhat.com id 12GCXYRd030825 X-loop: libvir-list@redhat.com Cc: yubihong@huawei.com, zhengchuan@huawei.com, pkrempa@redhat.com, zhang.zhanghailiang@huawei.com, mprivozn@redhat.com, danielhb413@gmail.com, xiexiangyou@huawei.com, alex.chen@huawei.com, wanghao232@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 Content-Type: text/plain; charset="utf-8" Implement qemuDomainStartDirtyRateCalc which calculates domain's memory dirty rate calling qmp "calc-dirty-rate". Signed-off-by: Hao Wang Reviewed-by: Michal Privoznik --- src/qemu/qemu_driver.c | 59 ++++++++++++++++++++++++++++++++++++ src/qemu/qemu_monitor.c | 12 ++++++++ src/qemu/qemu_monitor.h | 4 +++ src/qemu/qemu_monitor_json.c | 22 ++++++++++++++ src/qemu/qemu_monitor_json.h | 4 +++ 5 files changed, 101 insertions(+) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 16c5ccae45..8836d9fd16 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -20342,6 +20342,64 @@ qemuDomainGetMessages(virDomainPtr dom, } =20 =20 +#define MIN_DIRTYRATE_CALC_PERIOD 1 /* supported min dirtyrate calculatin= g time: 1s */ +#define MAX_DIRTYRATE_CALC_PERIOD 60 /* supported max dirtyrate calculatin= g time: 60s */ + +static int +qemuDomainStartDirtyRateCalc(virDomainPtr dom, + int seconds, + unsigned int flags) +{ + virQEMUDriverPtr driver =3D dom->conn->privateData; + virDomainObjPtr vm; + qemuDomainObjPrivatePtr priv; + int ret =3D -1; + + virCheckFlags(0, -1); + + if (seconds < MIN_DIRTYRATE_CALC_PERIOD || + seconds > MAX_DIRTYRATE_CALC_PERIOD) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("seconds=3D%d is invalid, please choose value wit= hin [%d, %d]."), + seconds, + MIN_DIRTYRATE_CALC_PERIOD, + MAX_DIRTYRATE_CALC_PERIOD); + return -1; + } + + if (!(vm =3D qemuDomainObjFromDomain(dom))) + return -1; + + if (virDomainStartDirtyRateCalcEnsureACL(dom->conn, vm->def) < 0) + goto cleanup; + + if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_QUERY) < 0) + goto cleanup; + + if (!virDomainObjIsActive(vm)) { + virReportError(VIR_ERR_OPERATION_INVALID, + "%s", _("domain is not running")); + goto endjob; + } + + VIR_DEBUG("Calculate dirty rate in next %d seconds", seconds); + + priv =3D vm->privateData; + qemuDomainObjEnterMonitor(driver, vm); + ret =3D qemuMonitorStartDirtyRateCalc(priv->mon, seconds); + + if (qemuDomainObjExitMonitor(driver, vm) < 0) + ret =3D -1; + + endjob: + qemuDomainObjEndJob(driver, vm); + + cleanup: + virDomainObjEndAPI(&vm); + return ret; +} + + static virHypervisorDriver qemuHypervisorDriver =3D { .name =3D QEMU_DRIVER_NAME, .connectURIProbe =3D qemuConnectURIProbe, @@ -20584,6 +20642,7 @@ static virHypervisorDriver qemuHypervisorDriver =3D= { .domainAuthorizedSSHKeysGet =3D qemuDomainAuthorizedSSHKeysGet, /* 6.1= 0.0 */ .domainAuthorizedSSHKeysSet =3D qemuDomainAuthorizedSSHKeysSet, /* 6.1= 0.0 */ .domainGetMessages =3D qemuDomainGetMessages, /* 7.1.0 */ + .domainStartDirtyRateCalc =3D qemuDomainStartDirtyRateCalc, /* 7.2.0 */ }; =20 =20 diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c index b4f2641504..ce927687e3 100644 --- a/src/qemu/qemu_monitor.c +++ b/src/qemu/qemu_monitor.c @@ -4742,3 +4742,15 @@ qemuMonitorTransactionBackup(virJSONValuePtr actions, return qemuMonitorJSONTransactionBackup(actions, device, jobname, targ= et, bitmap, syncmode); } + + +int +qemuMonitorStartDirtyRateCalc(qemuMonitorPtr mon, + int seconds) +{ + VIR_DEBUG("seconds=3D%d", seconds); + + QEMU_CHECK_MONITOR(mon); + + return qemuMonitorJSONStartDirtyRateCalc(mon, seconds); +} diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h index d25c26343a..94813906b4 100644 --- a/src/qemu/qemu_monitor.h +++ b/src/qemu/qemu_monitor.h @@ -1526,3 +1526,7 @@ qemuMonitorTransactionBackup(virJSONValuePtr actions, const char *target, const char *bitmap, qemuMonitorTransactionBackupSyncMode syncmode= ); + +int +qemuMonitorStartDirtyRateCalc(qemuMonitorPtr mon, + int seconds); diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index ad62e24cfc..588fcd3a1c 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -9480,3 +9480,25 @@ qemuMonitorJSONGetCPUMigratable(qemuMonitorPtr mon, return virJSONValueGetBoolean(virJSONValueObjectGet(reply, "return"), migratable); } + + +int +qemuMonitorJSONStartDirtyRateCalc(qemuMonitorPtr mon, + int seconds) +{ + g_autoptr(virJSONValue) cmd =3D NULL; + g_autoptr(virJSONValue) reply =3D NULL; + + if (!(cmd =3D qemuMonitorJSONMakeCommand("calc-dirty-rate", + "i:calc-time", seconds, + NULL))) + return -1; + + if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0) + return -1; + + if (qemuMonitorJSONCheckError(cmd, reply) < 0) + return -1; + + return 0; +} diff --git a/src/qemu/qemu_monitor_json.h b/src/qemu/qemu_monitor_json.h index 3dd1eb24c7..32782cf681 100644 --- a/src/qemu/qemu_monitor_json.h +++ b/src/qemu/qemu_monitor_json.h @@ -711,3 +711,7 @@ int qemuMonitorJSONSetDBusVMStateIdList(qemuMonitorPtr = mon, int qemuMonitorJSONGetCPUMigratable(qemuMonitorPtr mon, bool *migratable); + +int +qemuMonitorJSONStartDirtyRateCalc(qemuMonitorPtr mon, + int seconds); --=20 2.23.0 From nobody Thu May 9 05:03:55 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.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 63.128.21.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=huawei.com ARC-Seal: i=1; a=rsa-sha256; t=1615898023; cv=none; d=zohomail.com; s=zohoarc; b=BJuJBHUJGH3bK0BKPpCoQunJnjjAU83xXZr14baPuEWdJc9dVrTGkXx5P1m5qlnGeyiic2Lx0ifbDL306MZFtixNITQOpRZfG02mIz+ffIJikcD/pClXPLhkaai7rU+1xM/h7KrAqVm+v9uZpxPcWEke/k3z8caFP6pTD4pdQ5w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1615898023; 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=ef5gkXaVqhBQCGcJ3kNqr/5iPS6ayuxaXe4Z0l9xJrc=; b=DL8m0slR3Y+zehWMapafTpDno70OpfPUd4tCwa4shSnK6HRA+Y7jAO/TSpfjgS7yz3ssPvbZVhQEZ/XU2M/stTZM5xek/tFlZXnbM+Xiru4QwgqkCb5PC5vdtKjDx9kS1LImb5aRry09Us7ibBWSiv+WW3pPltGG+TKzlvsEZSo= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by mx.zohomail.com with SMTPS id 1615898023421906.9021153963332; Tue, 16 Mar 2021 05:33:43 -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-294-cPlW2ySnM9Kl0XerZM0WUw-1; Tue, 16 Mar 2021 08:33:40 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 70BDC881D6C; Tue, 16 Mar 2021 12:33:34 +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 44FCE76C1D; Tue, 16 Mar 2021 12:33:34 +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 DF0E957DC4; Tue, 16 Mar 2021 12:33:33 +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 12GCXJEG030776 for ; Tue, 16 Mar 2021 08:33:20 -0400 Received: by smtp.corp.redhat.com (Postfix) id DE8892166B44; Tue, 16 Mar 2021 12:33:19 +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 D972D2166BA2 for ; Tue, 16 Mar 2021 12:33:19 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id C13D6100DE77 for ; Tue, 16 Mar 2021 12:33:19 +0000 (UTC) Received: from szxga07-in.huawei.com (szxga07-in.huawei.com [45.249.212.35]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-219-QD_NS56ENG6LB3SbDTJrBg-1; Tue, 16 Mar 2021 08:33:17 -0400 Received: from DGGEMS404-HUB.china.huawei.com (unknown [172.30.72.59]) by szxga07-in.huawei.com (SkyGuard) with ESMTP id 4F0CM21RXrz905v; Tue, 16 Mar 2021 20:31:10 +0800 (CST) Received: from huawei.com (10.175.104.175) by DGGEMS404-HUB.china.huawei.com (10.3.19.204) with Microsoft SMTP Server id 14.3.498.0; Tue, 16 Mar 2021 20:32:53 +0800 X-MC-Unique: cPlW2ySnM9Kl0XerZM0WUw-1 X-MC-Unique: QD_NS56ENG6LB3SbDTJrBg-1 From: Hao Wang To: Subject: [PATCH v7 3/7] migration/dirtyrate: Introduce domdirtyrate-calc virsh api Date: Tue, 16 Mar 2021 20:32:47 +0800 Message-ID: <20210316123251.511485-4-wanghao232@huawei.com> In-Reply-To: <20210316123251.511485-1-wanghao232@huawei.com> References: <20210316123251.511485-1-wanghao232@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.104.175] 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 12GCXJEG030776 X-loop: libvir-list@redhat.com Cc: yubihong@huawei.com, zhengchuan@huawei.com, pkrempa@redhat.com, zhang.zhanghailiang@huawei.com, mprivozn@redhat.com, danielhb413@gmail.com, xiexiangyou@huawei.com, alex.chen@huawei.com, wanghao232@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.11 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 Content-Type: text/plain; charset="utf-8" Introduce domdirtyrate-calc virsh api to start calculating domain's memory dirty rate: # virsh domdirtyrate-calc [--seconds ] Signed-off-by: Hao Wang Reviewed-by: Michal Privoznik --- docs/manpages/virsh.rst | 17 ++++++++++++ tools/virsh-domain.c | 58 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 75 insertions(+) diff --git a/docs/manpages/virsh.rst b/docs/manpages/virsh.rst index 9ff31a0160..367b4bddeb 100644 --- a/docs/manpages/virsh.rst +++ b/docs/manpages/virsh.rst @@ -1704,6 +1704,23 @@ states other than "ok" or "error" the command also p= rints number of seconds elapsed since the control interface entered its current state. =20 =20 +domdirtyrate-calc +----------------- + +**Syntax:** + +:: + + domdirtyrate-calc [--seconds ] + +Calculate an active domain's memory dirty rate which may be expected by +user in order to decide whether it's proper to be migrated out or not. +The ``seconds`` parameter can be used to calculate dirty rate in a +specific time which allows 60s at most now and would be default to 1s +if missing. The calculated dirty rate information is available by calling +'domstats --dirtyrate'. + + domdisplay ---------- =20 diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index f8f36ce361..7db88f700a 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -14402,6 +14402,58 @@ cmdSetUserSSHKeys(vshControl *ctl, const vshCmd *c= md) } =20 =20 +/* + * "domdirtyrate" command + */ +static const vshCmdInfo info_domdirtyrate_calc[] =3D { + {.name =3D "help", + .data =3D N_("Calculate a vm's memory dirty rate") + }, + {.name =3D "desc", + .data =3D N_("Calculate memory dirty rate of a domain in order to " + "decide whether it's proper to be migrated out or not.\n" + "The calculated dirty rate information is available by " + "calling 'domstats --dirtyrate'.") + }, + {.name =3D NULL} +}; + +static const vshCmdOptDef opts_domdirtyrate_calc[] =3D { + VIRSH_COMMON_OPT_DOMAIN_FULL(0), + {.name =3D "seconds", + .type =3D VSH_OT_INT, + .help =3D N_("calculate memory dirty rate within specified seconds, " + "the supported value range from 1 to 60, default to 1.") + }, + {.name =3D NULL} +}; + +static bool +cmdDomDirtyRateCalc(vshControl *ctl, const vshCmd *cmd) +{ + virDomainPtr dom =3D NULL; + int seconds =3D 1; /* the default value is 1 */ + bool ret =3D false; + + if (!(dom =3D virshCommandOptDomain(ctl, cmd, NULL))) + return false; + + if (vshCommandOptInt(ctl, cmd, "seconds", &seconds) < 0) + goto cleanup; + + if (virDomainStartDirtyRateCalc(dom, seconds, 0) < 0) + goto cleanup; + + vshPrintExtra(ctl, _("Start to calculate domain's memory " + "dirty rate successfully.\n")); + ret =3D true; + + cleanup: + virshDomainFree(dom); + return ret; +} + + const vshCmdDef domManagementCmds[] =3D { {.name =3D "attach-device", .handler =3D cmdAttachDevice, @@ -15041,5 +15093,11 @@ const vshCmdDef domManagementCmds[] =3D { .info =3D info_guestinfo, .flags =3D 0 }, + {.name =3D "domdirtyrate-calc", + .handler =3D cmdDomDirtyRateCalc, + .opts =3D opts_domdirtyrate_calc, + .info =3D info_domdirtyrate_calc, + .flags =3D 0 + }, {.name =3D NULL} }; --=20 2.23.0 From nobody Thu May 9 05:03:55 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 ARC-Seal: i=1; a=rsa-sha256; t=1615898028; cv=none; d=zohomail.com; s=zohoarc; b=lsRL5Y7O0MZb9lUGR8Y0HzvpQM319NsIyU46GcCshdw18xtZYg919gePMVG/S7vcVu+I7nvDGEi9a1LyFMy8kITvdL1JmU2fXAJiVIIjM1+v8POhPY+XgFZyhP57OeHkw3kzoIHiLQMUyfUcvUZVac/1CLhnhaancAFPa9IySrA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1615898028; 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=xf8SxD4PvsVOyv+3p2i4amERt3yS8IUWcqTlKm82mbE=; b=XaqQvv0HTV2+QSXWkhQmYXwJ5DoHtUqK65k7f9V5wo4/VAJ/iRfBWVfihZrhj4Asqs5iDCSO27k+s14wtUTL/FgxmReNU8Zu/9wLfRZ4wpcmFVGtzqbq0eZ1oqSWe5xIr0LzUVrq7Uma00GIAViQsYRMDYIZ92vYV+gcYvDmEkM= ARC-Authentication-Results: i=1; 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 header.from= (p=none dis=none) header.from= 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 1615898028992373.66578440513376; Tue, 16 Mar 2021 05:33:48 -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-173-ObpqxuMAOdKtHhnnLtev6Q-1; Tue, 16 Mar 2021 08:33:45 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id C7D73192D787; Tue, 16 Mar 2021 12:33:38 +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 93A482B3C2; Tue, 16 Mar 2021 12:33:38 +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 4475D1800BAE; Tue, 16 Mar 2021 12:33:38 +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 12GCXNlD030797 for ; Tue, 16 Mar 2021 08:33:23 -0400 Received: by smtp.corp.redhat.com (Postfix) id 39AF310031EC; Tue, 16 Mar 2021 12:33:23 +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 35AD81003209 for ; Tue, 16 Mar 2021 12:33:23 +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-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 22D9485A5BA for ; Tue, 16 Mar 2021 12:33:23 +0000 (UTC) Received: from szxga07-in.huawei.com (szxga07-in.huawei.com [45.249.212.35]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-409-3N76BPOaNrqoYdNthNB4qg-1; Tue, 16 Mar 2021 08:33:20 -0400 Received: from DGGEMS404-HUB.china.huawei.com (unknown [172.30.72.59]) by szxga07-in.huawei.com (SkyGuard) with ESMTP id 4F0CM21DG8z905t; Tue, 16 Mar 2021 20:31:10 +0800 (CST) Received: from huawei.com (10.175.104.175) by DGGEMS404-HUB.china.huawei.com (10.3.19.204) with Microsoft SMTP Server id 14.3.498.0; Tue, 16 Mar 2021 20:32:54 +0800 X-MC-Unique: ObpqxuMAOdKtHhnnLtev6Q-1 X-MC-Unique: 3N76BPOaNrqoYdNthNB4qg-1 From: Hao Wang To: Subject: [PATCH v7 4/7] migration/dirtyrate: Introduce virDomainDirtyRateStatus enum Date: Tue, 16 Mar 2021 20:32:48 +0800 Message-ID: <20210316123251.511485-5-wanghao232@huawei.com> In-Reply-To: <20210316123251.511485-1-wanghao232@huawei.com> References: <20210316123251.511485-1-wanghao232@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.104.175] 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 12GCXNlD030797 X-loop: libvir-list@redhat.com Cc: yubihong@huawei.com, zhengchuan@huawei.com, pkrempa@redhat.com, zhang.zhanghailiang@huawei.com, mprivozn@redhat.com, danielhb413@gmail.com, xiexiangyou@huawei.com, alex.chen@huawei.com, wanghao232@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.23 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 Content-Type: text/plain; charset="utf-8" Introduce virDomainDirtyRateStatus enum. Signed-off-by: Hao Wang Reviewed-by: Michal Privoznik --- include/libvirt/libvirt-domain.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/include/libvirt/libvirt-domain.h b/include/libvirt/libvirt-dom= ain.h index 7aa5ef4543..b05bb94131 100644 --- a/include/libvirt/libvirt-domain.h +++ b/include/libvirt/libvirt-domain.h @@ -5128,6 +5128,24 @@ int virDomainGetMessages(virDomainPtr domain, char ***msgs, unsigned int flags); =20 +/** + * virDomainDirtyRateStatus: + * + * Details on the cause of a dirty rate calculation status. + */ +typedef enum { + VIR_DOMAIN_DIRTYRATE_UNSTARTED =3D 0, /* the dirtyrate calculation has + not been started */ + VIR_DOMAIN_DIRTYRATE_MEASURING =3D 1, /* the dirtyrate calculation is + measuring */ + VIR_DOMAIN_DIRTYRATE_MEASURED =3D 2, /* the dirtyrate calculation is + completed */ + +# ifdef VIR_ENUM_SENTINELS + VIR_DOMAIN_DIRTYRATE_LAST +# endif +} virDomainDirtyRateStatus; + int virDomainStartDirtyRateCalc(virDomainPtr domain, int seconds, unsigned int flags); --=20 2.23.0 From nobody Thu May 9 05:03:55 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 ARC-Seal: i=1; a=rsa-sha256; t=1615898016; cv=none; d=zohomail.com; s=zohoarc; b=dLVLmzeFkcQrNHrrP0FUjNuib8RI6G1nVjTk8ql6pn9wEUCpA5Nb6wMLv+62y5xOk29Cx8JN18A9eRs3Qu6noNSmVxbUNcJFdBrPO+bTjfaLQLUGOAvbQxFRmiCBjXaNPNgB3PLBuGtWI9XD7whNJc3M4MEXv+r90nXjjPGZYn4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1615898016; 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=8EgnOU86QejyeLwpiO9hF83bf0Dbl37LY6nJ8WpgALk=; b=Tzc9szP3ahTEBVK8zohjZZPQiAztlYrEhQY0w89VJInpJ2gOs8Bd5/rhk4OB2fXuJCu2VdPHEjVarxG/6DEq7ZpY4VThc5MsgoAeLjTS0o4ND8AwRuLzrArMtwMKF1TCGvOiq/1ZDU8n1uJithd2dp9t79NeWQPt9B0vyE3Fvz8= ARC-Authentication-Results: i=1; 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 header.from= (p=none dis=none) header.from= 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 1615898016797969.3137206756977; Tue, 16 Mar 2021 05:33:36 -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-597-TU-v3lYYM9KDdemsHThWrA-1; Tue, 16 Mar 2021 08:33:33 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 200D3760C0; Tue, 16 Mar 2021 12:33:27 +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 E86C96C355; Tue, 16 Mar 2021 12:33:26 +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 AE53E1800B9A; Tue, 16 Mar 2021 12:33:26 +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 12GCXFDv030729 for ; Tue, 16 Mar 2021 08:33:16 -0400 Received: by smtp.corp.redhat.com (Postfix) id 8CF7D2166B44; Tue, 16 Mar 2021 12:33:15 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast05.extmail.prod.ext.rdu2.redhat.com [10.11.55.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 86DEE2166BA3 for ; Tue, 16 Mar 2021 12:33:12 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-1.mimecast.com [205.139.110.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 8A216800140 for ; Tue, 16 Mar 2021 12:33:12 +0000 (UTC) Received: from szxga07-in.huawei.com (szxga07-in.huawei.com [45.249.212.35]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-502-XJCyV0N2PQiN0eAoX2MGMw-1; Tue, 16 Mar 2021 08:33:07 -0400 Received: from DGGEMS404-HUB.china.huawei.com (unknown [172.30.72.59]) by szxga07-in.huawei.com (SkyGuard) with ESMTP id 4F0CM20nVFz905V; Tue, 16 Mar 2021 20:31:10 +0800 (CST) Received: from huawei.com (10.175.104.175) by DGGEMS404-HUB.china.huawei.com (10.3.19.204) with Microsoft SMTP Server id 14.3.498.0; Tue, 16 Mar 2021 20:32:55 +0800 X-MC-Unique: TU-v3lYYM9KDdemsHThWrA-1 X-MC-Unique: XJCyV0N2PQiN0eAoX2MGMw-1 From: Hao Wang To: Subject: [PATCH v7 5/7] migration/dirtyrate: Implement qemuMonitorQueryDirtyRate Date: Tue, 16 Mar 2021 20:32:49 +0800 Message-ID: <20210316123251.511485-6-wanghao232@huawei.com> In-Reply-To: <20210316123251.511485-1-wanghao232@huawei.com> References: <20210316123251.511485-1-wanghao232@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.104.175] 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 12GCXFDv030729 X-loop: libvir-list@redhat.com Cc: yubihong@huawei.com, zhengchuan@huawei.com, pkrempa@redhat.com, zhang.zhanghailiang@huawei.com, mprivozn@redhat.com, danielhb413@gmail.com, xiexiangyou@huawei.com, alex.chen@huawei.com, wanghao232@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.11 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 Content-Type: text/plain; charset="utf-8" Implement qemuMonitorQueryDirtyRate which query domain's memory dirty rate calling qmp "query-dirty-rate". Signed-off-by: Hao Wang Reviewed-by: Michal Privoznik --- src/qemu/qemu_monitor.c | 12 ++++++ src/qemu/qemu_monitor.h | 15 +++++++ src/qemu/qemu_monitor_json.c | 79 ++++++++++++++++++++++++++++++++++++ src/qemu/qemu_monitor_json.h | 4 ++ 4 files changed, 110 insertions(+) diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c index ce927687e3..9f1f645b0b 100644 --- a/src/qemu/qemu_monitor.c +++ b/src/qemu/qemu_monitor.c @@ -4754,3 +4754,15 @@ qemuMonitorStartDirtyRateCalc(qemuMonitorPtr mon, =20 return qemuMonitorJSONStartDirtyRateCalc(mon, seconds); } + + +int +qemuMonitorQueryDirtyRate(qemuMonitorPtr mon, + qemuMonitorDirtyRateInfoPtr info) +{ + VIR_DEBUG("info=3D%p", info); + + QEMU_CHECK_MONITOR(mon); + + return qemuMonitorJSONQueryDirtyRate(mon, info); +} diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h index 94813906b4..c812aa9cc3 100644 --- a/src/qemu/qemu_monitor.h +++ b/src/qemu/qemu_monitor.h @@ -1530,3 +1530,18 @@ qemuMonitorTransactionBackup(virJSONValuePtr actions, int qemuMonitorStartDirtyRateCalc(qemuMonitorPtr mon, int seconds); + +typedef struct _qemuMonitorDirtyRateInfo qemuMonitorDirtyRateInfo; +typedef qemuMonitorDirtyRateInfo *qemuMonitorDirtyRateInfoPtr; + +struct _qemuMonitorDirtyRateInfo { + int status; /* the status of last dirtyrate calculation, + one of virDomainDirtyRateStatus */ + int calcTime; /* the period of dirtyrate calculation */ + long long startTime; /* the start time of dirtyrate calculation */ + long long dirtyRate; /* the dirtyrate in MiB/s */ +}; + +int +qemuMonitorQueryDirtyRate(qemuMonitorPtr mon, + qemuMonitorDirtyRateInfoPtr info); diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index 588fcd3a1c..b669630bc8 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -9502,3 +9502,82 @@ qemuMonitorJSONStartDirtyRateCalc(qemuMonitorPtr mon, =20 return 0; } + +VIR_ENUM_DECL(qemuMonitorDirtyRateStatus); +VIR_ENUM_IMPL(qemuMonitorDirtyRateStatus, + VIR_DOMAIN_DIRTYRATE_LAST, + "unstarted", + "measuring", + "measured"); + +static int +qemuMonitorJSONExtractDirtyRateInfo(virJSONValuePtr data, + qemuMonitorDirtyRateInfoPtr info) +{ + const char *statusstr; + int status; + + if (!(statusstr =3D virJSONValueObjectGetString(data, "status"))) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("query-dirty-rate reply was missing 'status' data= ")); + return -1; + } + + if ((status =3D qemuMonitorDirtyRateStatusTypeFromString(statusstr)) <= 0) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Unknown dirty rate status: %s"), statusstr); + return -1; + } + info->status =3D status; + + /* `query-dirty-rate` replies `dirty-rate` data only if the status of = the latest + * calculation is `measured`. + */ + if ((info->status =3D=3D VIR_DOMAIN_DIRTYRATE_MEASURED) && + (virJSONValueObjectGetNumberLong(data, "dirty-rate", &info->dirtyR= ate) < 0)) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("query-dirty-rate reply was missing 'dirty-rate' = data")); + return -1; + } + + if (virJSONValueObjectGetNumberLong(data, "start-time", &info->startTi= me) < 0) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("query-dirty-rate reply was missing 'start-time' = data")); + return -1; + } + + if (virJSONValueObjectGetNumberInt(data, "calc-time", &info->calcTime)= < 0) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("query-dirty-rate reply was missing 'calc-time' d= ata")); + return -1; + } + + return 0; +} + + +int +qemuMonitorJSONQueryDirtyRate(qemuMonitorPtr mon, + qemuMonitorDirtyRateInfoPtr info) +{ + g_autoptr(virJSONValue) cmd =3D NULL; + g_autoptr(virJSONValue) reply =3D NULL; + virJSONValuePtr data =3D NULL; + + if (!(cmd =3D qemuMonitorJSONMakeCommand("query-dirty-rate", NULL))) + return -1; + + if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0) + return -1; + + if (qemuMonitorJSONCheckError(cmd, reply) < 0) + return -1; + + if (!(data =3D virJSONValueObjectGetObject(reply, "return"))) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("query-dirty-rate reply was missing 'return' data= ")); + return -1; + } + + return qemuMonitorJSONExtractDirtyRateInfo(data, info); +} diff --git a/src/qemu/qemu_monitor_json.h b/src/qemu/qemu_monitor_json.h index 32782cf681..8d4232f67b 100644 --- a/src/qemu/qemu_monitor_json.h +++ b/src/qemu/qemu_monitor_json.h @@ -715,3 +715,7 @@ qemuMonitorJSONGetCPUMigratable(qemuMonitorPtr mon, int qemuMonitorJSONStartDirtyRateCalc(qemuMonitorPtr mon, int seconds); + +int +qemuMonitorJSONQueryDirtyRate(qemuMonitorPtr mon, + qemuMonitorDirtyRateInfoPtr info); --=20 2.23.0 From nobody Thu May 9 05:03:55 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 ARC-Seal: i=1; a=rsa-sha256; t=1615898009; cv=none; d=zohomail.com; s=zohoarc; b=hoYo2LHB4ETWBbTBGP/zmIwMky36JPi/i7RJq0WP/u4wjzgZBbuE/7BiwcNiZVW/s8WRQE2qMfaTUQ4r3u6DWDT3i0+OsDOv/pWpbb2WuWTquT84qe7cmckHtEGDV9crr/1cJsHpVNSQMZJalDb7WIrWRIi3XuIPfNFEZfjtjQw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1615898009; 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=HINq43psZpSe5in/DIT6q4pw7EbnZFlx8Ra9FUfi9MI=; b=lUy45J0jRjd9/9NaNcILjk5eLUkhPphaVQh7/GhgT2lxRBOqc8dm3ED4MgyfdoSXXImo4BBZF5TGpj3OS1hx1pP9KV3WChxEdU0GfcNkB0K+vn4JVAksZA8fYraOURFOUepUO0vu55LIUndGblvRJp5m/Z+O10hEAyINtfsVEQs= ARC-Authentication-Results: i=1; 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 header.from= (p=none dis=none) header.from= 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 1615898009312585.5470461486783; Tue, 16 Mar 2021 05:33:29 -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-493-n2h1JqGQM3Gea1Ua61Tbxw-1; Tue, 16 Mar 2021 08:33:25 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id ED30083DD20; Tue, 16 Mar 2021 12:33:18 +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 B6DA75D9DC; Tue, 16 Mar 2021 12:33:18 +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 8E2B61800847; Tue, 16 Mar 2021 12:33:17 +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 12GCXFjL030728 for ; Tue, 16 Mar 2021 08:33:16 -0400 Received: by smtp.corp.redhat.com (Postfix) id 89D7F2166BA4; Tue, 16 Mar 2021 12:33:15 +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 820432166BA2 for ; Tue, 16 Mar 2021 12:33:12 +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-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id CC37E85A5BA for ; Tue, 16 Mar 2021 12:33:12 +0000 (UTC) Received: from szxga07-in.huawei.com (szxga07-in.huawei.com [45.249.212.35]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-152-gJuteAZOMT2RBbtrUh-fqg-1; Tue, 16 Mar 2021 08:33:08 -0400 Received: from DGGEMS404-HUB.china.huawei.com (unknown [172.30.72.59]) by szxga07-in.huawei.com (SkyGuard) with ESMTP id 4F0CM226kWz9062; Tue, 16 Mar 2021 20:31:10 +0800 (CST) Received: from huawei.com (10.175.104.175) by DGGEMS404-HUB.china.huawei.com (10.3.19.204) with Microsoft SMTP Server id 14.3.498.0; Tue, 16 Mar 2021 20:32:55 +0800 X-MC-Unique: n2h1JqGQM3Gea1Ua61Tbxw-1 X-MC-Unique: gJuteAZOMT2RBbtrUh-fqg-1 From: Hao Wang To: Subject: [PATCH v7 6/7] migration/dirtyrate: Extend dirtyrate statistics for domGetStats Date: Tue, 16 Mar 2021 20:32:50 +0800 Message-ID: <20210316123251.511485-7-wanghao232@huawei.com> In-Reply-To: <20210316123251.511485-1-wanghao232@huawei.com> References: <20210316123251.511485-1-wanghao232@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.104.175] 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 12GCXFjL030728 X-loop: libvir-list@redhat.com Cc: yubihong@huawei.com, zhengchuan@huawei.com, pkrempa@redhat.com, zhang.zhanghailiang@huawei.com, mprivozn@redhat.com, danielhb413@gmail.com, xiexiangyou@huawei.com, alex.chen@huawei.com, wanghao232@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.14 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 Content-Type: text/plain; charset="utf-8" Extend dirtyrate statistics for domGetStats to display the information of a domain's memory dirty rate produced by domainStartDirtyRateCalc. Signed-off-by: Hao Wang Reviewed-by: Michal Privoznik --- include/libvirt/libvirt-domain.h | 1 + src/libvirt-domain.c | 15 ++++++++++ src/qemu/qemu_driver.c | 51 ++++++++++++++++++++++++++++++++ 3 files changed, 67 insertions(+) diff --git a/include/libvirt/libvirt-domain.h b/include/libvirt/libvirt-dom= ain.h index b05bb94131..03c119fe26 100644 --- a/include/libvirt/libvirt-domain.h +++ b/include/libvirt/libvirt-domain.h @@ -2185,6 +2185,7 @@ typedef enum { VIR_DOMAIN_STATS_PERF =3D (1 << 6), /* return domain perf event info */ VIR_DOMAIN_STATS_IOTHREAD =3D (1 << 7), /* return iothread poll info */ VIR_DOMAIN_STATS_MEMORY =3D (1 << 8), /* return domain memory info */ + VIR_DOMAIN_STATS_DIRTYRATE =3D (1 << 9), /* return domain dirty rate i= nfo */ } virDomainStatsTypes; =20 typedef enum { diff --git a/src/libvirt-domain.c b/src/libvirt-domain.c index 91001fc4ed..83ff7df9fe 100644 --- a/src/libvirt-domain.c +++ b/src/libvirt-domain.c @@ -11887,6 +11887,21 @@ virConnectGetDomainCapabilities(virConnectPtr conn, * bytes consumed by @vcpus that passing through all * memory controllers, either local or remote contro= ller. * + * VIR_DOMAIN_STATS_DIRTYRATE: + * Return memory dirty rate information. The typed parameter keys are = in + * this format: + * + * "dirtyrate.calc_status" - the status of last memory dirty rate calc= ulation, + * returned as int from virDomainDirtyRateSt= atus + * enum. + * "dirtyrate.calc_start_time" - the start time of last memory dirty r= ate + * calculation as long long. + * "dirtyrate.calc_period" - the period of last memory dirty rate calc= ulation + * as int. + * "dirtyrate.megabytes_per_second" - the calculated memory dirty rate= in + * MiB/s as long long. It is produc= ed + * only if the calc_status is measu= red. + * * Note that entire stats groups or individual stat fields may be missing = from * the output in case they are not supported by the given hypervisor, are = not * applicable for the current state of the guest domain, or their retrieval diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 8836d9fd16..f3f8caab44 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -18577,6 +18577,56 @@ qemuDomainGetStatsPerf(virQEMUDriverPtr driver G_G= NUC_UNUSED, return 0; } =20 +static int +qemuDomainGetStatsDirtyRateMon(virQEMUDriverPtr driver, + virDomainObjPtr vm, + qemuMonitorDirtyRateInfoPtr info) +{ + qemuDomainObjPrivatePtr priv =3D vm->privateData; + int ret; + + qemuDomainObjEnterMonitor(driver, vm); + ret =3D qemuMonitorQueryDirtyRate(priv->mon, info); + if (qemuDomainObjExitMonitor(driver, vm) < 0) + ret =3D -1; + + return ret; +} + +static int +qemuDomainGetStatsDirtyRate(virQEMUDriverPtr driver, + virDomainObjPtr dom, + virTypedParamListPtr params, + unsigned int privflags) +{ + qemuMonitorDirtyRateInfo info; + + if (!HAVE_JOB(privflags) || !virDomainObjIsActive(dom)) + return 0; + + if (qemuDomainGetStatsDirtyRateMon(driver, dom, &info) < 0) + return -1; + + if (virTypedParamListAddInt(params, info.status, + "dirtyrate.calc_status") < 0) + return -1; + + if (virTypedParamListAddLLong(params, info.startTime, + "dirtyrate.calc_start_time") < 0) + return -1; + + if (virTypedParamListAddInt(params, info.calcTime, + "dirtyrate.calc_period") < 0) + return -1; + + if ((info.status =3D=3D VIR_DOMAIN_DIRTYRATE_MEASURED) && + virTypedParamListAddLLong(params, info.dirtyRate, + "dirtyrate.megabytes_per_second") < 0) + return -1; + + return 0; +} + typedef int (*qemuDomainGetStatsFunc)(virQEMUDriverPtr driver, virDomainObjPtr dom, @@ -18599,6 +18649,7 @@ static struct qemuDomainGetStatsWorker qemuDomainGe= tStatsWorkers[] =3D { { qemuDomainGetStatsPerf, VIR_DOMAIN_STATS_PERF, false }, { qemuDomainGetStatsIOThread, VIR_DOMAIN_STATS_IOTHREAD, true }, { qemuDomainGetStatsMemory, VIR_DOMAIN_STATS_MEMORY, false }, + { qemuDomainGetStatsDirtyRate, VIR_DOMAIN_STATS_DIRTYRATE, true }, { NULL, 0, false } }; =20 --=20 2.23.0 From nobody Thu May 9 05:03:55 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 ARC-Seal: i=1; a=rsa-sha256; t=1615898009; cv=none; d=zohomail.com; s=zohoarc; b=kNQLqLJeEA3iTTI8psLdvMAGtFj4bmwJ/JxTwv5SWcMtNig3R691bnV43VLufehTCKtj42AiorafpebPHwCnyAsR7TBYYZrSUOuFh7Rt/wUgC+BjBh6tOfknMuqJrwNCezC0SRFW8TNazP+N3Eik6ZzyurSaWwFVu7/8tZByGwI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1615898009; 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=/OL/i6NKmLV+3c5jphJiRPV2EhYZcCboL2y1LvIET54=; b=IS3hCwRkXybL0UTXg9vCnaHOJbe4CFhrCrv/5MjTHw6k6t2Rx2P6FW9sVxGIR/UTqIF/roavSSpPhGPpeS38BMMKnHde9+vsLjb7OMrOM3mwAxvD311aWsdnrQC9ubbLF2cVN6tm7HfsTY2GGOt796Ch152CTBSr7yzEi6KL6FY= ARC-Authentication-Results: i=1; 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 header.from= (p=none dis=none) header.from= 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 1615898009404783.1817526420646; Tue, 16 Mar 2021 05:33:29 -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-188-6deFXwOVOk-NjOJ5fIbzkw-1; Tue, 16 Mar 2021 08:33:24 -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 EB57A101F001; Tue, 16 Mar 2021 12:33:18 +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 BEBE81037E83; Tue, 16 Mar 2021 12:33:18 +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 88AC618006D9; Tue, 16 Mar 2021 12:33:17 +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 12GCXFDr030730 for ; Tue, 16 Mar 2021 08:33:16 -0400 Received: by smtp.corp.redhat.com (Postfix) id BCF751003209; Tue, 16 Mar 2021 12:33:15 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast05.extmail.prod.ext.rdu2.redhat.com [10.11.55.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B8ADD10031EC for ; Tue, 16 Mar 2021 12:33:12 +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-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id AE7E580A1D2 for ; Tue, 16 Mar 2021 12:33:12 +0000 (UTC) Received: from szxga07-in.huawei.com (szxga07-in.huawei.com [45.249.212.35]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-458-3UTjQQqnNcWr84iKsMnbiQ-1; Tue, 16 Mar 2021 08:33:07 -0400 Received: from DGGEMS404-HUB.china.huawei.com (unknown [172.30.72.59]) by szxga07-in.huawei.com (SkyGuard) with ESMTP id 4F0CM20KvLz901m; Tue, 16 Mar 2021 20:31:10 +0800 (CST) Received: from huawei.com (10.175.104.175) by DGGEMS404-HUB.china.huawei.com (10.3.19.204) with Microsoft SMTP Server id 14.3.498.0; Tue, 16 Mar 2021 20:32:56 +0800 X-MC-Unique: 6deFXwOVOk-NjOJ5fIbzkw-1 X-MC-Unique: 3UTjQQqnNcWr84iKsMnbiQ-1 From: Hao Wang To: Subject: [PATCH v7 7/7] migration/dirtyrate: Introduce command 'virsh domstats --dirtyrate' Date: Tue, 16 Mar 2021 20:32:51 +0800 Message-ID: <20210316123251.511485-8-wanghao232@huawei.com> In-Reply-To: <20210316123251.511485-1-wanghao232@huawei.com> References: <20210316123251.511485-1-wanghao232@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.104.175] 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 12GCXFDr030730 X-loop: libvir-list@redhat.com Cc: yubihong@huawei.com, zhengchuan@huawei.com, pkrempa@redhat.com, zhang.zhanghailiang@huawei.com, mprivozn@redhat.com, danielhb413@gmail.com, xiexiangyou@huawei.com, alex.chen@huawei.com, wanghao232@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 Content-Type: text/plain; charset="utf-8" Introduce command 'virsh domstats --dirtyrate' for reporting memory dirty rate information. The info is listed as: Domain: 'vm0' dirtyrate.calc_status=3D2 dirtyrate.calc_start_time=3D1534523 dirtyrate.calc_period=3D1 dirtyrate.megabytes_per_second=3D5 Signed-off-by: Hao Wang Reviewed-by: Michal Privoznik --- docs/manpages/virsh.rst | 16 ++++++++++++++-- tools/virsh-domain-monitor.c | 7 +++++++ 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/docs/manpages/virsh.rst b/docs/manpages/virsh.rst index 367b4bddeb..813fb0bd60 100644 --- a/docs/manpages/virsh.rst +++ b/docs/manpages/virsh.rst @@ -2219,7 +2219,7 @@ domstats =20 domstats [--raw] [--enforce] [--backing] [--nowait] [--state] [--cpu-total] [--balloon] [--vcpu] [--interface] - [--block] [--perf] [--iothread] [--memory] + [--block] [--perf] [--iothread] [--memory] [--dirtyrate] [[--list-active] [--list-inactive] [--list-persistent] [--list-transient] [--list-running]y [--list-paused] [--list-shutoff] [--list-other]] | [domain ...] @@ -2238,7 +2238,8 @@ behavior use the *--raw* flag. The individual statistics groups are selectable via specific flags. By default all supported statistics groups are returned. Supported statistics groups flags are: *--state*, *--cpu-total*, *--balloon*, -*--vcpu*, *--interface*, *--block*, *--perf*, *--iothread*, *--memory*. +*--vcpu*, *--interface*, *--block*, *--perf*, *--iothread*, *--memory*, +*--dirtyrate*. =20 Note that - depending on the hypervisor type and version or the domain sta= te - not all of the following statistics may be returned. @@ -2435,6 +2436,17 @@ not available for statistical purposes. bytes consumed by @vcpus that passing through all memory controllers, ei= ther local or remote controller. =20 +*--dirtyrate* returns: + +* ``dirtyrate.calc_status`` - the status of last memory dirty rate + calculation, returned as number from virDomainDirtyRateStatus enum. +* ``dirtyrate.calc_start_time`` - the start time of last memory dirty + rate calculation. +* ``dirtyrate.calc_period`` - the period of last memory dirty rate + calculation. +* ``dirtyrate.megabytes_per_second`` - the calculated memory dirty + rate in MiB/s. + =20 Selecting a specific statistics groups doesn't guarantee that the daemon supports the selected group of stats. Flag *--enforce* diff --git a/tools/virsh-domain-monitor.c b/tools/virsh-domain-monitor.c index 897339b6f9..c4d7464695 100644 --- a/tools/virsh-domain-monitor.c +++ b/tools/virsh-domain-monitor.c @@ -2148,6 +2148,10 @@ static const vshCmdOptDef opts_domstats[] =3D { .type =3D VSH_OT_BOOL, .help =3D N_("report domain memory usage"), }, + {.name =3D "dirtyrate", + .type =3D VSH_OT_BOOL, + .help =3D N_("report domain dirty rate information"), + }, {.name =3D "list-active", .type =3D VSH_OT_BOOL, .help =3D N_("list only active domains"), @@ -2267,6 +2271,9 @@ cmdDomstats(vshControl *ctl, const vshCmd *cmd) if (vshCommandOptBool(cmd, "memory")) stats |=3D VIR_DOMAIN_STATS_MEMORY; =20 + if (vshCommandOptBool(cmd, "dirtyrate")) + stats |=3D VIR_DOMAIN_STATS_DIRTYRATE; + if (vshCommandOptBool(cmd, "list-active")) flags |=3D VIR_CONNECT_GET_ALL_DOMAINS_STATS_ACTIVE; =20 --=20 2.23.0