From nobody Thu May 2 13:01:40 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 ARC-Seal: i=1; a=rsa-sha256; t=1603112351; cv=none; d=zohomail.com; s=zohoarc; b=g8VtGqkvqDny34qjJaeastrPIKetd1dgdgdJMSLw3pUF9emxC2PCTmvaxVbnre+HEiyTLwI7fB9zBW3fmvTsuwkl0g0RTGisvSBcizOqjZCHqvtmP3E1I+6KqlJdW8pTFNnampvhJeP8MrPzH++ggMOxeDWKg01Pay+3EaVisUQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1603112351; 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=dvazCTZQjJfBKKbioF4KLbleUVLIG/kAGIEEMcQ0Yso=; b=fXo9qt22gDjhBksnJyZVFJLxdkPRJbTnqKFtfyIOCHR27jT/ZzBdNe6Ppq9fWVnNDibA58IM3sggy6k615yp990BITYvuxhl4E1VWXQsJDQRb7fLhjVFZDZ++clMkokO11WnMerVPhmm9RiNFXyn8YkLcHWh/Rvu9j6NbcZZjXQ= 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 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 1603112351949802.0798742295997; Mon, 19 Oct 2020 05:59:11 -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-293-3xM-DkopMFyqcdD2614ZrA-1; Mon, 19 Oct 2020 08:59:08 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 968151015C93; Mon, 19 Oct 2020 12:59:01 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 73BC15576F; Mon, 19 Oct 2020 12:59:01 +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 3B17A8C7A8; Mon, 19 Oct 2020 12:59:01 +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 09JCwvMj007201 for ; Mon, 19 Oct 2020 08:58:57 -0400 Received: by smtp.corp.redhat.com (Postfix) id 5214D2156A37; Mon, 19 Oct 2020 12:58:57 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast06.extmail.prod.ext.rdu2.redhat.com [10.11.55.22]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 4DE6C2166B44 for ; Mon, 19 Oct 2020 12:58:55 +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 F1085182360F for ; Mon, 19 Oct 2020 12:58:54 +0000 (UTC) Received: from huawei.com (szxga04-in.huawei.com [45.249.212.190]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-3-PKe9wLU6PlK-YDKOxQsgwA-1; Mon, 19 Oct 2020 08:58:49 -0400 Received: from DGGEMS408-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id 455F8DD34ED9DA2FB1A8; Mon, 19 Oct 2020 20:58:44 +0800 (CST) Received: from huawei.com (10.175.104.175) by DGGEMS408-HUB.china.huawei.com (10.3.19.208) with Microsoft SMTP Server id 14.3.487.0; Mon, 19 Oct 2020 20:58:36 +0800 X-MC-Unique: 3xM-DkopMFyqcdD2614ZrA-1 X-MC-Unique: PKe9wLU6PlK-YDKOxQsgwA-1 From: Hao Wang To: Subject: [PATCH v2 1/7] migration/dirtyrate: Introduce virDomainDirtyRateInfo structure Date: Mon, 19 Oct 2020 20:58:26 +0800 Message-ID: <20201019125832.3200876-2-wanghao232@huawei.com> In-Reply-To: <20201019125832.3200876-1-wanghao232@huawei.com> References: <20201019125832.3200876-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 09JCwvMj007201 X-loop: libvir-list@redhat.com Cc: yubihong@huawei.com, alex.chen@huawei.com, zhouyimin@huawei.com, pkrempa@redhat.com, zhang.zhanghailiang@huawei.com, dgilbert@redhat.com, xiexiangyou@huawei.com, david.edmondson@oracle.com, jdenemar@redhat.com, zhengchuan@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.15 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 virDomainDirtyRateInfo structure used for domain's memory dirty r= ate query. Signed-off-by: Hao Wang Reviewed-by: Chuan Zheng --- include/libvirt/libvirt-domain.h | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/include/libvirt/libvirt-domain.h b/include/libvirt/libvirt-dom= ain.h index 77f9116675..c7e22d4af1 100644 --- a/include/libvirt/libvirt-domain.h +++ b/include/libvirt/libvirt-domain.h @@ -5012,4 +5012,28 @@ int virDomainBackupBegin(virDomainPtr domain, char *virDomainBackupGetXMLDesc(virDomainPtr domain, unsigned int flags); =20 +/** + * virDomainDirtyRateInfo: + * + * a virDomainDirtyRateInfo is a structure filled by virDomainGetDirtyRate= () and + * extracting dirty rate infomation for a given active Domain. + */ + +typedef struct _virDomainDirtyRateInfo virDomainDirtyRateInfo; + +struct _virDomainDirtyRateInfo { + int status; /* the status of dirtyrate calculation */ + long long dirtyRate; /* the dirtyrate in MB/s */ + long long startTime; /* the start time of dirtyrate calculation */ + long long calcTime; /* the period of dirtyrate calculation */ +}; + +/** + * virDomainDirtyRateInfoPtr: + * + * a virDomainDirtyRateInfoPtr is a pointer to a virDomainDirtyRateInfo st= ructure. + */ + +typedef virDomainDirtyRateInfo *virDomainDirtyRateInfoPtr; + #endif /* LIBVIRT_DOMAIN_H */ --=20 2.23.0 From nobody Thu May 2 13:01:40 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 ARC-Seal: i=1; a=rsa-sha256; t=1603112409; cv=none; d=zohomail.com; s=zohoarc; b=XlfywcISoTOs3kStFjkTqH2fA1XRDPP7kpxuepbNIDk8gbw2zMAO1BNanqGIRYBHvKzEOC99b62TV250QWBlKEMjDmMua7q7IABRRxRUnItlMkJoiWUbLJoSuvvVkzPS1k5luJyNy2k6EmDXw7x2CYi5XZxDYvHJ7vi9jMuhSR4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1603112409; 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=lt9D+9jvPsAGwOKJlMCTJ/aHice7at513rU89Ha16sk=; b=iHxK3BMFTdXj8GLlOrvZNHFVze/6KhldnpepFqE2q+iMUHrIvctFaZndfs0Zy5aZQ3+KTn3jcmAqiG3lN+m+QOLYQjTO7zuY/C3Zz0IG/sWsmrf20aOngu02XcrRxrGbP3oylcVfkMhnXB7DMoFBsr/qvuZl94TumNHLHSzs1Pg= 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 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 1603112409816805.9708544554082; Mon, 19 Oct 2020 06:00:09 -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-363-DubEx_4WNFe_XxUSfmEgaw-1; Mon, 19 Oct 2020 08:59:03 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id EEEC5835B47; Mon, 19 Oct 2020 12:58:57 +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 9AFAB6198C; Mon, 19 Oct 2020 12:58:57 +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 5CB6544A6B; Mon, 19 Oct 2020 12:58:57 +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 09JCwu4p007190 for ; Mon, 19 Oct 2020 08:58:56 -0400 Received: by smtp.corp.redhat.com (Postfix) id 638A71111C98; Mon, 19 Oct 2020 12:58:56 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast03.extmail.prod.ext.rdu2.redhat.com [10.11.55.19]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 5DFB31111C93 for ; Mon, 19 Oct 2020 12:58:54 +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 18F17811E79 for ; Mon, 19 Oct 2020 12:58:54 +0000 (UTC) Received: from huawei.com (szxga04-in.huawei.com [45.249.212.190]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-224-zm88sdo8NnOra9fay8QN9A-1; Mon, 19 Oct 2020 08:58:48 -0400 Received: from DGGEMS408-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id 3B66C7C1479F908BD8A2; Mon, 19 Oct 2020 20:58:44 +0800 (CST) Received: from huawei.com (10.175.104.175) by DGGEMS408-HUB.china.huawei.com (10.3.19.208) with Microsoft SMTP Server id 14.3.487.0; Mon, 19 Oct 2020 20:58:36 +0800 X-MC-Unique: DubEx_4WNFe_XxUSfmEgaw-1 X-MC-Unique: zm88sdo8NnOra9fay8QN9A-1 From: Hao Wang To: Subject: [PATCH v2 2/7] migration/dirtyrate: Implement qemuMonitorJSONExtractDirtyRateInfo Date: Mon, 19 Oct 2020 20:58:27 +0800 Message-ID: <20201019125832.3200876-3-wanghao232@huawei.com> In-Reply-To: <20201019125832.3200876-1-wanghao232@huawei.com> References: <20201019125832.3200876-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 09JCwu4p007190 X-loop: libvir-list@redhat.com Cc: yubihong@huawei.com, alex.chen@huawei.com, zhouyimin@huawei.com, pkrempa@redhat.com, zhang.zhanghailiang@huawei.com, dgilbert@redhat.com, xiexiangyou@huawei.com, david.edmondson@oracle.com, jdenemar@redhat.com, zhengchuan@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.12 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 qemuMonitorJSONExtractDirtyRateInfo to deal with the return from qmp "query-dirty-rate", and store them in virDomainDirtyRateInfo. Signed-off-by: Hao Wang Reviewed-by: Chuan Zheng --- include/libvirt/libvirt-domain.h | 16 +++++++++++ src/qemu/qemu_monitor_json.c | 48 ++++++++++++++++++++++++++++++++ 2 files changed, 64 insertions(+) diff --git a/include/libvirt/libvirt-domain.h b/include/libvirt/libvirt-dom= ain.h index c7e22d4af1..9bf4f8a8cf 100644 --- a/include/libvirt/libvirt-domain.h +++ b/include/libvirt/libvirt-domain.h @@ -5012,6 +5012,22 @@ int virDomainBackupBegin(virDomainPtr domain, char *virDomainBackupGetXMLDesc(virDomainPtr domain, unsigned int flags); =20 +/** + * virDomainDirtyRateStatus: + * + * Details on the cause of a dirtyrate 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; + /** * virDomainDirtyRateInfo: * diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index e88e6aebaf..37612a9bba 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -9414,3 +9414,51 @@ qemuMonitorJSONGetCPUMigratable(qemuMonitorPtr mon, return virJSONValueGetBoolean(virJSONValueObjectGet(reply, "return"), migratable); } + + +VIR_ENUM_DECL(qemuDomainDirtyRateStatus); +VIR_ENUM_IMPL(qemuDomainDirtyRateStatus, + VIR_DOMAIN_DIRTYRATE_LAST, + "unstarted", + "measuring", + "measured"); + +static int +qemuMonitorJSONExtractDirtyRateInfo(virJSONValuePtr data, + virDomainDirtyRateInfoPtr info) +{ + const char *status; + int statusID; + + if (!(status =3D virJSONValueObjectGetString(data, "status"))) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("query-dirty-rate reply was missing 'status' data= ")); + return -1; + } + + if ((statusID =3D qemuDomainDirtyRateStatusTypeFromString(status)) < 0= ) { + return -1; + } + info->status =3D statusID; + + if ((info->status =3D=3D VIR_DOMAIN_DIRTYRATE_MEASURED) && + (virJSONValueObjectGetNumberLong(data, "dirty-rate", &(info->dirty= Rate)) < 0)) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("query-dirty-rate reply was missing 'dirty-rate' = data")); + return -1; + } + + if (virJSONValueObjectGetNumberLong(data, "start-time", &(info->startT= ime)) < 0) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("query-dirty-rate reply was missing 'start-time' = data")); + return -1; + } + + if (virJSONValueObjectGetNumberLong(data, "calc-time", &(info->calcTim= e)) < 0) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("query-dirty-rate reply was missing 'calc-time' d= ata")); + return -1; + } + + return 0; +} --=20 2.23.0 From nobody Thu May 2 13:01:40 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 ARC-Seal: i=1; a=rsa-sha256; t=1603112357; cv=none; d=zohomail.com; s=zohoarc; b=DffyI6JxSFcb+ztEFYZEGl2c040fHhD41gsoMUNy+GRUkmN6CO6m/XL3JfhnOyXWUCoW8p6L7QUTMP191TlAwIsn8NbpYphXHSA1mHIL0e7d7QeMkKbSbYWxk7FMlxB9j+saWndvj8ktaagDWyGKgBV2y4TREDmw2B7J6wbAuP8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1603112357; 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=Qb+GM4mendlDHfLYLJIaH2Ugu5bklOYY7omRhitvurg=; b=CLNu7DNNvYQXwIh4Pe579GoX/yieef7uCHk9eljPjRf4NoIhxxoISP7naodnHu3Mx2r9lIX12WnGt4kS7kyg9rn2E/+b4Hi6yIwBmL4BffS5LcahNyZerBJZhN1ZHhxqGEXSy4x8HeOq4BJkm3y13Qg49gZVhtQRysELb3MjSkQ= 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 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 1603112357592983.9700053582843; Mon, 19 Oct 2020 05:59:17 -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-417-NL_qOWaOOhGEXLL_gWgT3g-1; Mon, 19 Oct 2020 08:59:14 -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 1D748835BB7; Mon, 19 Oct 2020 12:59:07 +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 E47D05C22B; Mon, 19 Oct 2020 12:59:06 +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 B0BEA8C7AB; Mon, 19 Oct 2020 12:59:06 +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 09JCx0iX007233 for ; Mon, 19 Oct 2020 08:59:00 -0400 Received: by smtp.corp.redhat.com (Postfix) id 2767F200E1E0; Mon, 19 Oct 2020 12:59:00 +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 22E06202348E for ; Mon, 19 Oct 2020 12:58:53 +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 C9F4B805B00 for ; Mon, 19 Oct 2020 12:58:53 +0000 (UTC) Received: from huawei.com (szxga04-in.huawei.com [45.249.212.190]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-457-392Osun-Pv2x-a7bAm7Htw-1; Mon, 19 Oct 2020 08:58:48 -0400 Received: from DGGEMS408-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id 3076C56369C63C855CF4; Mon, 19 Oct 2020 20:58:44 +0800 (CST) Received: from huawei.com (10.175.104.175) by DGGEMS408-HUB.china.huawei.com (10.3.19.208) with Microsoft SMTP Server id 14.3.487.0; Mon, 19 Oct 2020 20:58:37 +0800 X-MC-Unique: NL_qOWaOOhGEXLL_gWgT3g-1 X-MC-Unique: 392Osun-Pv2x-a7bAm7Htw-1 From: Hao Wang To: Subject: [PATCH v2 3/7] migration/dirtyrate: Implement qemuDomainQueryDirtyRate Date: Mon, 19 Oct 2020 20:58:28 +0800 Message-ID: <20201019125832.3200876-4-wanghao232@huawei.com> In-Reply-To: <20201019125832.3200876-1-wanghao232@huawei.com> References: <20201019125832.3200876-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.4 X-MIME-Autoconverted: from quoted-printable to 8bit by lists01.pubmisc.prod.ext.phx2.redhat.com id 09JCx0iX007233 X-loop: libvir-list@redhat.com Cc: yubihong@huawei.com, alex.chen@huawei.com, zhouyimin@huawei.com, pkrempa@redhat.com, zhang.zhanghailiang@huawei.com, dgilbert@redhat.com, xiexiangyou@huawei.com, david.edmondson@oracle.com, jdenemar@redhat.com, zhengchuan@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 qemuDomainQueryDirtyRate which query domain's memory dirty rate using qmp "query-dirty-rate". Signed-off-by: Hao Wang Signed-off-by: Zhou Yimin Reviewed-by: Chuan Zheng --- src/qemu/qemu_migration.c | 31 +++++++++++++++++++++++++++++++ src/qemu/qemu_migration.h | 5 +++++ src/qemu/qemu_monitor.c | 12 ++++++++++++ src/qemu/qemu_monitor.h | 4 ++++ src/qemu/qemu_monitor_json.c | 27 +++++++++++++++++++++++++++ src/qemu/qemu_monitor_json.h | 4 ++++ 6 files changed, 83 insertions(+) diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index 132545c99f..a2f6b319de 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -5826,3 +5826,34 @@ qemuMigrationSrcFetchMirrorStats(virQEMUDriverPtr dr= iver, virHashFree(blockinfo); return 0; } + + +int +qemuDomainQueryDirtyRate(virDomainPtr dom, + virDomainObjPtr vm, + virDomainDirtyRateInfoPtr info) +{ + virQEMUDriverPtr driver =3D dom->conn->privateData; + qemuDomainObjPrivatePtr priv; + int ret =3D -1; + + if (!virDomainObjIsActive(vm)) { + virReportError(VIR_ERR_OPERATION_INVALID, + "%s", _("domain is not running")); + return ret; + } + + priv =3D vm->privateData; + + qemuDomainObjEnterMonitor(driver, vm); + + ret =3D qemuMonitorQueryDirtyRate(priv->mon, info); + if (ret < 0) { + virReportError(VIR_ERR_OPERATION_FAILED, + "%s", _("get vm's dirty rate failed.")); + } + if (qemuDomainObjExitMonitor(driver, vm) < 0) + ret =3D -1; + + return ret; +} diff --git a/src/qemu/qemu_migration.h b/src/qemu/qemu_migration.h index fd9eb7cab0..0cd12adb27 100644 --- a/src/qemu/qemu_migration.h +++ b/src/qemu/qemu_migration.h @@ -258,3 +258,8 @@ qemuMigrationSrcFetchMirrorStats(virQEMUDriverPtr drive= r, virDomainObjPtr vm, qemuDomainAsyncJob asyncJob, qemuDomainJobInfoPtr jobInfo); + +int +qemuDomainQueryDirtyRate(virDomainPtr dom, + virDomainObjPtr vm, + virDomainDirtyRateInfoPtr info); diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c index 834e1c9e8f..009aeb759c 100644 --- a/src/qemu/qemu_monitor.c +++ b/src/qemu/qemu_monitor.c @@ -4656,3 +4656,15 @@ qemuMonitorTransactionBackup(virJSONValuePtr actions, return qemuMonitorJSONTransactionBackup(actions, device, jobname, targ= et, bitmap, syncmode); } + + +int +qemuMonitorQueryDirtyRate(qemuMonitorPtr mon, + virDomainDirtyRateInfoPtr 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 f2c632a7ac..8813c546f0 100644 --- a/src/qemu/qemu_monitor.h +++ b/src/qemu/qemu_monitor.h @@ -1447,3 +1447,7 @@ qemuMonitorTransactionBackup(virJSONValuePtr actions, const char *target, const char *bitmap, qemuMonitorTransactionBackupSyncMode syncmode= ); + +int +qemuMonitorQueryDirtyRate(qemuMonitorPtr mon, + virDomainDirtyRateInfoPtr info); diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index 37612a9bba..23b0796101 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -9462,3 +9462,30 @@ qemuMonitorJSONExtractDirtyRateInfo(virJSONValuePtr = data, =20 return 0; } + + +int +qemuMonitorJSONQueryDirtyRate(qemuMonitorPtr mon, + virDomainDirtyRateInfoPtr 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 e9107eaade..d6dba4731f 100644 --- a/src/qemu/qemu_monitor_json.h +++ b/src/qemu/qemu_monitor_json.h @@ -698,3 +698,7 @@ int qemuMonitorJSONSetDBusVMStateIdList(qemuMonitorPtr = mon, int qemuMonitorJSONGetCPUMigratable(qemuMonitorPtr mon, bool *migratable); + +int +qemuMonitorJSONQueryDirtyRate(qemuMonitorPtr mon, + virDomainDirtyRateInfoPtr info); --=20 2.23.0 From nobody Thu May 2 13:01:40 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 ARC-Seal: i=1; a=rsa-sha256; t=1603112353; cv=none; d=zohomail.com; s=zohoarc; b=SokFr+lzHRhVgOEg2bUt0Owdzk5cbPZlQ6HtfeEE2nL1hr5Iq2gmXUVAKQBZ6o7pRZgzH/VW6Yp3INUrDc88bpepQkPKQBZ4cvr6VlrkXjJ9TGlWoH3lf1yrVZzcpxBO8Gv+1xVlt4VGt9qNhY56DHXg4cSXUXtkyHe5tIwdXvE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1603112353; 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=q48btqPQ4xGUylJxL4bwRA50KA3zkdnuhQh0f2wyh7c=; b=kLKsA2lhXA8n8K9YJPjaLcsSANvHGmKux2Na6u6cNwb4L5x+P+oibO3+Zi5MziFaEKOu+g7dbR48wzKCfLxKuQCv71tRefUYK+EGMZTJkZt8rqDEQ3tmWQYMpvOLiC4p3GRbVSSRNbrvk7JPq5gQDZWlLhPpeCra7VTwjJhXgA8= 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 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 1603112353792426.086766722319; Mon, 19 Oct 2020 05:59:13 -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-38-EjVe9D8tMWuy2GMFAW_vvg-1; Mon, 19 Oct 2020 08:59:10 -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 444A9835B48; Mon, 19 Oct 2020 12:59:04 +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 23B1150B44; Mon, 19 Oct 2020 12:59:04 +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 E388518408AC; Mon, 19 Oct 2020 12:59:03 +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 09JCwvEM007200 for ; Mon, 19 Oct 2020 08:58:57 -0400 Received: by smtp.corp.redhat.com (Postfix) id 3D99E1111C85; Mon, 19 Oct 2020 12:58:57 +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 39BB91111C93 for ; Mon, 19 Oct 2020 12:58:57 +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 13A68803522 for ; Mon, 19 Oct 2020 12:58:57 +0000 (UTC) Received: from huawei.com (szxga04-in.huawei.com [45.249.212.190]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-550-1gO7QX-sNDqJySAzsnGb7g-1; Mon, 19 Oct 2020 08:58:49 -0400 Received: from DGGEMS408-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id 36030F40BA36E1234299; Mon, 19 Oct 2020 20:58:44 +0800 (CST) Received: from huawei.com (10.175.104.175) by DGGEMS408-HUB.china.huawei.com (10.3.19.208) with Microsoft SMTP Server id 14.3.487.0; Mon, 19 Oct 2020 20:58:38 +0800 X-MC-Unique: EjVe9D8tMWuy2GMFAW_vvg-1 X-MC-Unique: 1gO7QX-sNDqJySAzsnGb7g-1 From: Hao Wang To: Subject: [PATCH v2 4/7] migration/dirtyrate: Implement qemuDomainCalculateDirtyRate Date: Mon, 19 Oct 2020 20:58:29 +0800 Message-ID: <20201019125832.3200876-5-wanghao232@huawei.com> In-Reply-To: <20201019125832.3200876-1-wanghao232@huawei.com> References: <20201019125832.3200876-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 09JCwvEM007200 X-loop: libvir-list@redhat.com Cc: yubihong@huawei.com, alex.chen@huawei.com, zhouyimin@huawei.com, pkrempa@redhat.com, zhang.zhanghailiang@huawei.com, dgilbert@redhat.com, xiexiangyou@huawei.com, david.edmondson@oracle.com, jdenemar@redhat.com, zhengchuan@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 qemuDomainCalculateDirtyRate which calculates domain's memory dirty rate using qmp "calc-dirty-rate". Signed-off-by: Hao Wang Signed-off-by: Zhou Yimin Reviewed-by: Chuan Zheng --- src/qemu/qemu_migration.c | 28 ++++++++++++++++++++++++++++ src/qemu/qemu_migration.h | 5 +++++ 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 ++++ 6 files changed, 75 insertions(+) diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index a2f6b319de..8c6dd807f5 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -5857,3 +5857,31 @@ qemuDomainQueryDirtyRate(virDomainPtr dom, =20 return ret; } + + +int +qemuDomainCalculateDirtyRate(virDomainPtr dom, + virDomainObjPtr vm, + long long sec) +{ + virQEMUDriverPtr driver =3D dom->conn->privateData; + qemuDomainObjPrivatePtr priv; + int ret =3D -1; + + if (!virDomainObjIsActive(vm)) { + virReportError(VIR_ERR_OPERATION_INVALID, + "%s", _("domain is not running")); + return ret; + } + + priv =3D vm->privateData; + + VIR_DEBUG("Calculate dirty rate during %lld seconds", sec); + qemuDomainObjEnterMonitor(driver, vm); + + ret =3D qemuMonitorCalculateDirtyRate(priv->mon, sec); + if (qemuDomainObjExitMonitor(driver, vm) < 0) + ret =3D -1; + + return ret; +} diff --git a/src/qemu/qemu_migration.h b/src/qemu/qemu_migration.h index 0cd12adb27..15f707fb57 100644 --- a/src/qemu/qemu_migration.h +++ b/src/qemu/qemu_migration.h @@ -263,3 +263,8 @@ int qemuDomainQueryDirtyRate(virDomainPtr dom, virDomainObjPtr vm, virDomainDirtyRateInfoPtr info); + +int +qemuDomainCalculateDirtyRate(virDomainPtr dom, + virDomainObjPtr vm, + long long sec); diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c index 009aeb759c..4acb5ca5a1 100644 --- a/src/qemu/qemu_monitor.c +++ b/src/qemu/qemu_monitor.c @@ -4668,3 +4668,15 @@ qemuMonitorQueryDirtyRate(qemuMonitorPtr mon, =20 return qemuMonitorJSONQueryDirtyRate(mon, info); } + + +int +qemuMonitorCalculateDirtyRate(qemuMonitorPtr mon, + long long sec) +{ + VIR_DEBUG("seconds=3D%lld", sec); + + QEMU_CHECK_MONITOR(mon); + + return qemuMonitorJSONCalculateDirtyRate(mon, sec); +} diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h index 8813c546f0..936ebf167b 100644 --- a/src/qemu/qemu_monitor.h +++ b/src/qemu/qemu_monitor.h @@ -1451,3 +1451,7 @@ qemuMonitorTransactionBackup(virJSONValuePtr actions, int qemuMonitorQueryDirtyRate(qemuMonitorPtr mon, virDomainDirtyRateInfoPtr info); + +int +qemuMonitorCalculateDirtyRate(qemuMonitorPtr mon, + long long sec); diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index 23b0796101..a8a3432c01 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -9489,3 +9489,25 @@ qemuMonitorJSONQueryDirtyRate(qemuMonitorPtr mon, =20 return qemuMonitorJSONExtractDirtyRateInfo(data, info); } + + +int +qemuMonitorJSONCalculateDirtyRate(qemuMonitorPtr mon, + long long sec) +{ + g_autoptr(virJSONValue) cmd =3D NULL; + g_autoptr(virJSONValue) reply =3D NULL; + + if (!(cmd =3D qemuMonitorJSONMakeCommand("calc-dirty-rate", + "I:calc-time", (long)sec, + 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 d6dba4731f..a18a068f50 100644 --- a/src/qemu/qemu_monitor_json.h +++ b/src/qemu/qemu_monitor_json.h @@ -702,3 +702,7 @@ qemuMonitorJSONGetCPUMigratable(qemuMonitorPtr mon, int qemuMonitorJSONQueryDirtyRate(qemuMonitorPtr mon, virDomainDirtyRateInfoPtr info); + +int +qemuMonitorJSONCalculateDirtyRate(qemuMonitorPtr mon, + long long sec); --=20 2.23.0 From nobody Thu May 2 13:01:40 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 ARC-Seal: i=1; a=rsa-sha256; t=1603112358; cv=none; d=zohomail.com; s=zohoarc; b=AQLYjfvPWT1mQkZJx1q5XuqIgkLvQCqQNu+o4OO7cEFi96FcJjK4yW68arWw+0xnqHcYA0qNM63tfmkSTP1kRFjM0/bPOohqyX3gEoiXumxdmo/SO2ulvVMw4FR5X77Dwj/NO6zDLeiCWUcXsxFaluxOuo+V/wFPLEXkldtikpg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1603112358; 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=8rprjBOdVh+Bn/QrIhpNYlfnuLwSMCKV7PCJxpJg6Xk=; b=MiuPbp/SN35k5o5sn7xQXp/pAsciOEq0szRhnnV+TqoPVYSzlmG1RyQbs2vsko54qeNm/a4Zwq8WM58Ta+xFs7A9EHTsygqXn+zGiIa1nYOcgup3I7pnnH9jK7ODGfm87Q4pLFFi3QcJwq49KNEikcBoiRGwoPb9O0scXS+AOKQ= 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 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 1603112358336472.2770281796878; Mon, 19 Oct 2020 05:59:18 -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-303-OkvarxMyPW60oDnYauvWbQ-1; Mon, 19 Oct 2020 08:59:15 -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 C843E18A0751; Mon, 19 Oct 2020 12:59:06 +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 9D5B41A4D7; Mon, 19 Oct 2020 12:59:06 +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 4D47118408AE; Mon, 19 Oct 2020 12:59:06 +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 09JCx0ew007240 for ; Mon, 19 Oct 2020 08:59:01 -0400 Received: by smtp.corp.redhat.com (Postfix) id C42952024508; Mon, 19 Oct 2020 12:59:00 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast03.extmail.prod.ext.rdu2.redhat.com [10.11.55.19]) by smtp.corp.redhat.com (Postfix) with ESMTPS id BFA9E20244F7 for ; Mon, 19 Oct 2020 12:59:00 +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 ABE82811E95 for ; Mon, 19 Oct 2020 12:59:00 +0000 (UTC) Received: from huawei.com (szxga06-in.huawei.com [45.249.212.32]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-311-u0-PabECM7imeb1rWYU8mQ-1; Mon, 19 Oct 2020 08:58:56 -0400 Received: from DGGEMS408-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id 3ACDC31C2434D8EA91F2; Mon, 19 Oct 2020 20:58:49 +0800 (CST) Received: from huawei.com (10.175.104.175) by DGGEMS408-HUB.china.huawei.com (10.3.19.208) with Microsoft SMTP Server id 14.3.487.0; Mon, 19 Oct 2020 20:58:38 +0800 X-MC-Unique: OkvarxMyPW60oDnYauvWbQ-1 X-MC-Unique: u0-PabECM7imeb1rWYU8mQ-1 From: Hao Wang To: Subject: [PATCH v2 5/7] migration/dirtyrate: Introduce virDomainDirtyRateFlags Date: Mon, 19 Oct 2020 20:58:30 +0800 Message-ID: <20201019125832.3200876-6-wanghao232@huawei.com> In-Reply-To: <20201019125832.3200876-1-wanghao232@huawei.com> References: <20201019125832.3200876-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.4 X-MIME-Autoconverted: from quoted-printable to 8bit by lists01.pubmisc.prod.ext.phx2.redhat.com id 09JCx0ew007240 X-loop: libvir-list@redhat.com Cc: yubihong@huawei.com, alex.chen@huawei.com, zhouyimin@huawei.com, pkrempa@redhat.com, zhang.zhanghailiang@huawei.com, dgilbert@redhat.com, xiexiangyou@huawei.com, david.edmondson@oracle.com, jdenemar@redhat.com, zhengchuan@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 virDomainDirtyRateFlags for DomainGetDirtyRateInfo API. Signed-off-by: Hao Wang Reviewed-by: Chuan Zheng --- include/libvirt/libvirt-domain.h | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/include/libvirt/libvirt-domain.h b/include/libvirt/libvirt-dom= ain.h index 9bf4f8a8cf..ca54ebdb2e 100644 --- a/include/libvirt/libvirt-domain.h +++ b/include/libvirt/libvirt-domain.h @@ -5012,6 +5012,17 @@ int virDomainBackupBegin(virDomainPtr domain, char *virDomainBackupGetXMLDesc(virDomainPtr domain, unsigned int flags); =20 +/** + * virDomainDirtyRateFlags: + * + * Details on the flags used by getdirtyrate api. + */ + +typedef enum { + VIR_DOMAIN_DIRTYRATE_CALC =3D 1 << 0, /* calculate domain's dirtyrate= */ + VIR_DOMAIN_DIRTYRATE_QUERY =3D 1 << 1, /* query domain's dirtyrate */ +} virDomainDirtyRateFlags; + /** * virDomainDirtyRateStatus: * --=20 2.23.0 From nobody Thu May 2 13:01:40 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 ARC-Seal: i=1; a=rsa-sha256; t=1603112362; cv=none; d=zohomail.com; s=zohoarc; b=F86OEl2rHmDMGVc3YnhpR/ZOXus6JERLTz9Gr1ofKnOpisNnNsv3DaY4Sk7/X/8h78ljxb9jLYOiPGMLvfbMUNpFGFkqpfIsPkbSUDrEGow6uo7WqG/8m091HUOjgzLPVWVRY7Y0SFE3aAV//HgQxXr+szuZQFi84+/YT8m3k6Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1603112362; 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=rxVLqbadULEMp2VnnkQ6r8/Zfs3oknrplIFxIeB7jYY=; b=QCQoSAGAyMO8FV7yKM/kpCzhs2Aa8N9Es8pCoON6FNVnpJORBTgMEeUJi8GMObJQpMVtgZj8OSDQ8XuHxCH173MyGbmv2r0+6IDcco7iqmcOG1nJkC/CwEfvYuBQabDrdzVEH7o+6j9CZixzUMSB2RcLSj8UhX9tfN4QiMfWIMo= 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 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 1603112362151684.7538304164497; Mon, 19 Oct 2020 05:59:22 -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-443-kesu3IF7OZWIBsgcRRR3MQ-1; Mon, 19 Oct 2020 08:59:18 -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 658FD107464D; Mon, 19 Oct 2020 12:59:10 +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 3EF855C22B; Mon, 19 Oct 2020 12:59:10 +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 0BBF88C7B0; Mon, 19 Oct 2020 12:59:10 +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 09JCx4Jn007282 for ; Mon, 19 Oct 2020 08:59:04 -0400 Received: by smtp.corp.redhat.com (Postfix) id 4A806200E1E0; Mon, 19 Oct 2020 12:59:04 +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 44D01202450A for ; Mon, 19 Oct 2020 12:59:00 +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 9A2D78727B6 for ; Mon, 19 Oct 2020 12:59:00 +0000 (UTC) Received: from huawei.com (szxga06-in.huawei.com [45.249.212.32]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-147-xACJghnZN8C_ibBXUbLyFQ-1; Mon, 19 Oct 2020 08:58:55 -0400 Received: from DGGEMS408-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id 42EDAD4723587CD3E696; Mon, 19 Oct 2020 20:58:49 +0800 (CST) Received: from huawei.com (10.175.104.175) by DGGEMS408-HUB.china.huawei.com (10.3.19.208) with Microsoft SMTP Server id 14.3.487.0; Mon, 19 Oct 2020 20:58:39 +0800 X-MC-Unique: kesu3IF7OZWIBsgcRRR3MQ-1 X-MC-Unique: xACJghnZN8C_ibBXUbLyFQ-1 From: Hao Wang To: Subject: [PATCH v2 6/7] migration/dirtyrate: Introduce DomainGetDirtyRateInfo API Date: Mon, 19 Oct 2020 20:58:31 +0800 Message-ID: <20201019125832.3200876-7-wanghao232@huawei.com> In-Reply-To: <20201019125832.3200876-1-wanghao232@huawei.com> References: <20201019125832.3200876-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.4 X-MIME-Autoconverted: from quoted-printable to 8bit by lists01.pubmisc.prod.ext.phx2.redhat.com id 09JCx4Jn007282 X-loop: libvir-list@redhat.com Cc: yubihong@huawei.com, alex.chen@huawei.com, zhouyimin@huawei.com, pkrempa@redhat.com, zhang.zhanghailiang@huawei.com, dgilbert@redhat.com, xiexiangyou@huawei.com, david.edmondson@oracle.com, jdenemar@redhat.com, zhengchuan@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" Introduce DomainGetDirtyRateInfo API for domain's memory dirty rate calculation and query. Signed-off-by: Hao Wang Signed-off-by: Zhou Yimin Reviewed-by: Chuan Zheng --- include/libvirt/libvirt-domain.h | 13 ++++++ src/driver-hypervisor.h | 7 ++++ src/libvirt-domain.c | 46 +++++++++++++++++++++ src/libvirt_public.syms | 5 +++ src/qemu/qemu_driver.c | 70 ++++++++++++++++++++++++++++++++ src/remote/remote_driver.c | 1 + src/remote/remote_protocol.x | 21 +++++++++- 7 files changed, 162 insertions(+), 1 deletion(-) diff --git a/include/libvirt/libvirt-domain.h b/include/libvirt/libvirt-dom= ain.h index ca54ebdb2e..f318b0f272 100644 --- a/include/libvirt/libvirt-domain.h +++ b/include/libvirt/libvirt-domain.h @@ -5063,4 +5063,17 @@ struct _virDomainDirtyRateInfo { =20 typedef virDomainDirtyRateInfo *virDomainDirtyRateInfoPtr; =20 +/** + * virDomainDirtyRateInfoPtr: + * + * a virDomainDirtyRateInfoPtr is a pointer to a virDomainDirtyRateInfo st= ructure. + */ + +typedef virDomainDirtyRateInfo *virDomainDirtyRateInfoPtr; + +int virDomainGetDirtyRateInfo(virDomainPtr domain, + virDomainDirtyRateInfoPtr info, + long long sec, + int flags); + #endif /* LIBVIRT_DOMAIN_H */ diff --git a/src/driver-hypervisor.h b/src/driver-hypervisor.h index bce023017d..dc2aefa910 100644 --- a/src/driver-hypervisor.h +++ b/src/driver-hypervisor.h @@ -1387,6 +1387,12 @@ typedef char * (*virDrvDomainBackupGetXMLDesc)(virDomainPtr domain, unsigned int flags); =20 +typedef int +(*virDrvDomainGetDirtyRateInfo)(virDomainPtr domain, + virDomainDirtyRateInfoPtr info, + long long sec, + int flags); + typedef struct _virHypervisorDriver virHypervisorDriver; typedef virHypervisorDriver *virHypervisorDriverPtr; =20 @@ -1650,4 +1656,5 @@ struct _virHypervisorDriver { virDrvDomainAgentSetResponseTimeout domainAgentSetResponseTimeout; virDrvDomainBackupBegin domainBackupBegin; virDrvDomainBackupGetXMLDesc domainBackupGetXMLDesc; + virDrvDomainGetDirtyRateInfo domainGetDirtyRateInfo; }; diff --git a/src/libvirt-domain.c b/src/libvirt-domain.c index 3c5f55176a..8714c1ca93 100644 --- a/src/libvirt-domain.c +++ b/src/libvirt-domain.c @@ -12758,3 +12758,49 @@ virDomainBackupGetXMLDesc(virDomainPtr domain, virDispatchError(conn); return NULL; } + + +/** + * virDomainGetDirtyRateInfo: + * @domain: a domain object. + * @info: return value of current domain's memory dirty rate info. + * @sec: show dirty rate within specified seconds. + * @flags: the flags of getdirtyrate action -- calculate and/or query. + * + * Get the current domain's memory dirty rate (in MB/s). + * + * Returns 0 in case of success, -1 otherwise. + */ +int +virDomainGetDirtyRateInfo(virDomainPtr domain, + virDomainDirtyRateInfoPtr info, + long long sec, + int flags) +{ + virConnectPtr conn; + + VIR_DOMAIN_DEBUG(domain, "info =3D %p, seconds=3D%lld", info, sec); + + virResetLastError(); + + virCheckDomainReturn(domain, -1); + conn =3D domain->conn; + + virCheckNonNullArgGoto(info, error); + virCheckReadOnlyGoto(conn->flags, error); + + if (info) + memset(info, 0, sizeof(*info)); + + if (conn->driver->domainGetDirtyRateInfo) { + if (conn->driver->domainGetDirtyRateInfo(domain, info, sec, flags)= < 0) + goto error; + VIR_DOMAIN_DEBUG(domain, "info =3D %p, seconds=3D%lld", info, sec); + return 0; + } + + virReportUnsupportedError(); + error: + virDispatchError(conn); + return -1; +} diff --git a/src/libvirt_public.syms b/src/libvirt_public.syms index 539d2e3943..11864f48b1 100644 --- a/src/libvirt_public.syms +++ b/src/libvirt_public.syms @@ -873,4 +873,9 @@ LIBVIRT_6.0.0 { virDomainBackupGetXMLDesc; } LIBVIRT_5.10.0; =20 +LIBVIRT_6.9.0 { + global: + virDomainGetDirtyRateInfo; +} LIBVIRT_6.0.0; + # .... define new API here using predicted next version number .... diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 825bdd9119..47292a42be 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -20050,6 +20050,75 @@ qemuDomainAgentSetResponseTimeout(virDomainPtr dom, } =20 =20 +#define MIN_DIRTYRATE_CALCULATION_PERIOD 1 /* 1s */ +#define MAX_DIRTYRATE_CALCULATION_PERIOD 60 /* 60s */ + +static int +qemuDomainGetDirtyRateInfo(virDomainPtr dom, + virDomainDirtyRateInfoPtr info, + long long sec, + int flags) +{ + virDomainObjPtr vm =3D NULL; + virQEMUDriverPtr driver =3D dom->conn->privateData; + int ret =3D -1; + + if (!(vm =3D qemuDomainObjFromDomain(dom))) + return ret; + + if (virDomainGetDirtyRateInfoEnsureACL(dom->conn, vm->def) < 0) + goto cleanup; + + if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_QUERY) < 0) + goto cleanup; + + qemuDomainObjSetAsyncJobMask(vm, (QEMU_JOB_DEFAULT_MASK | + JOB_MASK(QEMU_JOB_SUSPEND))); + + if (!qemuMigrationSrcIsAllowed(driver, vm, false, 0)) + goto endjob; + + if (flags & VIR_DOMAIN_DIRTYRATE_CALC) { + if (sec < MIN_DIRTYRATE_CALCULATION_PERIOD || sec > MAX_DIRTYRATE_= CALCULATION_PERIOD) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + "seconds=3D%lld is invalid, please choose value= within [1, 60].", sec); + goto endjob; + } + + if (qemuDomainCalculateDirtyRate(dom, vm, sec) < 0) { + virReportError(VIR_ERR_OPERATION_FAILED, "%s", + _("can't calculate domain's dirty rate")); + goto endjob; + } + } + + if (flags & VIR_DOMAIN_DIRTYRATE_QUERY) { + if (flags & VIR_DOMAIN_DIRTYRATE_CALC) { + struct timespec ts =3D { .tv_sec =3D sec, .tv_nsec =3D 50 * 10= 00 * 1000ull }; + + virObjectUnlock(vm); + nanosleep(&ts, NULL); + virObjectLock(vm); + } + + if (qemuDomainQueryDirtyRate(dom, vm, info) < 0) { + virReportError(VIR_ERR_OPERATION_FAILED, "%s", + _("can't query domain's dirty rate")); + goto endjob; + } + } + + ret =3D 0; + + endjob: + qemuDomainObjEndJob(driver, vm); + + cleanup: + virDomainObjEndAPI(&vm); + return ret; +} + + static virHypervisorDriver qemuHypervisorDriver =3D { .name =3D QEMU_DRIVER_NAME, .connectURIProbe =3D qemuConnectURIProbe, @@ -20289,6 +20358,7 @@ static virHypervisorDriver qemuHypervisorDriver =3D= { .domainAgentSetResponseTimeout =3D qemuDomainAgentSetResponseTimeout, = /* 5.10.0 */ .domainBackupBegin =3D qemuDomainBackupBegin, /* 6.0.0 */ .domainBackupGetXMLDesc =3D qemuDomainBackupGetXMLDesc, /* 6.0.0 */ + .domainGetDirtyRateInfo =3D qemuDomainGetDirtyRateInfo, /* 6.9.0 */ }; =20 =20 diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c index d318224605..5ea49f1f4e 100644 --- a/src/remote/remote_driver.c +++ b/src/remote/remote_driver.c @@ -8426,6 +8426,7 @@ static virHypervisorDriver hypervisor_driver =3D { .domainAgentSetResponseTimeout =3D remoteDomainAgentSetResponseTimeout= , /* 5.10.0 */ .domainBackupBegin =3D remoteDomainBackupBegin, /* 6.0.0 */ .domainBackupGetXMLDesc =3D remoteDomainBackupGetXMLDesc, /* 6.0.0 */ + .domainGetDirtyRateInfo =3D remoteDomainGetDirtyRateInfo, /* 6.9.0 */ }; =20 static virNetworkDriver network_driver =3D { diff --git a/src/remote/remote_protocol.x b/src/remote/remote_protocol.x index f4d6147676..ce3d0519c9 100644 --- a/src/remote/remote_protocol.x +++ b/src/remote/remote_protocol.x @@ -3771,6 +3771,19 @@ struct remote_domain_backup_get_xml_desc_ret { remote_nonnull_string xml; }; =20 +struct remote_domain_get_dirty_rate_info_args { + remote_nonnull_domain dom; + hyper sec; + int flags; +}; + +struct remote_domain_get_dirty_rate_info_ret { /* insert@1 */ + int status; + hyper dirtyRate; + hyper startTime; + hyper calcTime; +}; + /*----- Protocol. -----*/ =20 /* Define the program number, protocol version and procedure numbers here.= */ @@ -6668,5 +6681,11 @@ enum remote_procedure { * @priority: high * @acl: domain:read */ - REMOTE_PROC_DOMAIN_BACKUP_GET_XML_DESC =3D 422 + REMOTE_PROC_DOMAIN_BACKUP_GET_XML_DESC =3D 422, + + /** + * @generate: both + * @acl: domain:read + */ + REMOTE_PROC_DOMAIN_GET_DIRTY_RATE_INFO =3D 423 }; --=20 2.23.0 From nobody Thu May 2 13:01:40 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 ARC-Seal: i=1; a=rsa-sha256; t=1603112351; cv=none; d=zohomail.com; s=zohoarc; b=ZBZpWx4Ef4lEqv/PXtwNMKQdZK02PdSl7pdYrMWQRdZ3udWIkm9U1avQWMdc+6MYEZBgmmGL8wOSfkI0uhGlP+JH3EffFqms0nMiHTNqF8zLkOBLIuFuqgrzYJhR7pPlapz3mWKNDG+ZMI5fmvuqLPNoTGCaTldulg/PBHVBOmA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1603112351; 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=G1uORkGhlaab+CGzIlGkykyCICv2fDkVYHJFI2jC8/g=; b=Y1M+WjPgxuvkUB6So+06Xr/Hrvcx83EIfKr/RQRXs9Wbf7Wy/uGydmdJY4CbvtLXK2xCu28cyJnXGSI/YiVYgJ/aeCwbmakjEQgRI3lstZFqmHHDZFxY9hqbBDxFt80SkAFGi3DpAbBnRNYseDICg/gLkS1UOUGz1LtSg/B/qY8= 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 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 1603112351487937.9131765273341; Mon, 19 Oct 2020 05:59:11 -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-534-1RKn2NirPLqKM3utfXN3vg-1; Mon, 19 Oct 2020 08:59:07 -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 4DAF864086; Mon, 19 Oct 2020 12:59:02 +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 2962650B44; Mon, 19 Oct 2020 12:59:02 +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 E928F8C7A9; Mon, 19 Oct 2020 12:59:01 +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 09JCwv4T007212 for ; Mon, 19 Oct 2020 08:58:57 -0400 Received: by smtp.corp.redhat.com (Postfix) id B1F7510EE953; Mon, 19 Oct 2020 12:58:57 +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 AE1AA10F1BEB for ; Mon, 19 Oct 2020 12:58:57 +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 92E53102F1E3 for ; Mon, 19 Oct 2020 12:58:57 +0000 (UTC) Received: from huawei.com (szxga06-in.huawei.com [45.249.212.32]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-273-MCg9gKOJN9-fGSyzkyUbog-1; Mon, 19 Oct 2020 08:58:55 -0400 Received: from DGGEMS408-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id 48D65CBF9794DEC65141; Mon, 19 Oct 2020 20:58:49 +0800 (CST) Received: from huawei.com (10.175.104.175) by DGGEMS408-HUB.china.huawei.com (10.3.19.208) with Microsoft SMTP Server id 14.3.487.0; Mon, 19 Oct 2020 20:58:40 +0800 X-MC-Unique: 1RKn2NirPLqKM3utfXN3vg-1 X-MC-Unique: MCg9gKOJN9-fGSyzkyUbog-1 From: Hao Wang To: Subject: [PATCH v2 7/7] migration/dirtyrate: Introduce getdirtyrate virsh api Date: Mon, 19 Oct 2020 20:58:32 +0800 Message-ID: <20201019125832.3200876-8-wanghao232@huawei.com> In-Reply-To: <20201019125832.3200876-1-wanghao232@huawei.com> References: <20201019125832.3200876-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 09JCwv4T007212 X-loop: libvir-list@redhat.com Cc: yubihong@huawei.com, alex.chen@huawei.com, zhouyimin@huawei.com, pkrempa@redhat.com, zhang.zhanghailiang@huawei.com, dgilbert@redhat.com, xiexiangyou@huawei.com, david.edmondson@oracle.com, jdenemar@redhat.com, zhengchuan@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" Signed-off-by: Hao Wang Signed-off-by: Zhou Yimin Reviewed-by: Chuan Zheng --- tools/virsh-domain.c | 112 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 112 insertions(+) diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index 8f11393197..175b2d7cd3 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -14333,6 +14333,112 @@ cmdGuestInfo(vshControl *ctl, const vshCmd *cmd) return ret; } =20 +/* + * "querydirtyrate" command + */ +static const vshCmdInfo info_getdirtyrate[] =3D { + {.name =3D "help", + .data =3D N_("Get a vm's memory dirty rate") + }, + {.name =3D "desc", + .data =3D N_("Get memory dirty rate of a domain in order to decide" + " whether it's proper to be migrated out or not.") + }, + {.name =3D NULL} +}; + +static const vshCmdOptDef opts_getdirtyrate[] =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," + " a valid range of values is [1, 60], and would default to= 1s.") + }, + {.name =3D "calculate", + .type =3D VSH_OT_BOOL, + .help =3D N_("calculate dirty rate only, can be used together with --= query," + " either or both is expected, otherwise would default to b= oth.") + }, + {.name =3D "query", + .type =3D VSH_OT_BOOL, + .help =3D N_("query dirty rate only, can be used together with --calc= ulate," + " either or both is expected, otherwise would default to b= oth.") + }, + {.name =3D NULL} +}; + +static bool +cmdGetDirtyRateInfo(vshControl *ctl, const vshCmd *cmd) +{ + virDomainPtr dom =3D NULL; + virDomainDirtyRateInfo info; + long long sec =3D 0; + const char *status =3D NULL; + unsigned int flags =3D 0; + int rc; + bool ret =3D false; + bool calc =3D vshCommandOptBool(cmd, "calculate"); + bool query =3D vshCommandOptBool(cmd, "query"); + + if (calc) + flags |=3D VIR_DOMAIN_DIRTYRATE_CALC; + if (query) + flags |=3D VIR_DOMAIN_DIRTYRATE_QUERY; + + /* if flag option is missing, default to both --calculate and --query = */ + if (!calc && !query) + flags |=3D VIR_DOMAIN_DIRTYRATE_CALC | VIR_DOMAIN_DIRTYRATE_QUERY; + + if (!(dom =3D virshCommandOptDomain(ctl, cmd, NULL))) + return false; + + rc =3D vshCommandOptLongLong(ctl, cmd, "seconds", &sec); + if (rc < 0) + goto done; + + /* if --seconds option is missing, default to 1s */ + if (!rc) + sec =3D 1; + + if (virDomainGetDirtyRateInfo(dom, &info, sec, flags) < 0) { + vshError(ctl, "%s", _("Get memory dirty-rate failed.")); + goto done; + } + + if (flags & VIR_DOMAIN_DIRTYRATE_QUERY) { + switch (info.status) { + case VIR_DOMAIN_DIRTYRATE_UNSTARTED: + status =3D _("unstarted"); + break; + case VIR_DOMAIN_DIRTYRATE_MEASURING: + status =3D _("measuring"); + break; + case VIR_DOMAIN_DIRTYRATE_MEASURED: + status =3D _("measured"); + break; + default: + status =3D _("unknown"); + } + + vshPrint(ctl, _("status: %s\n"), status); + vshPrint(ctl, _("startTime: %lld\n"), info.startTime); + vshPrint(ctl, _("calcTime: %lld s\n"), info.calcTime); + + if (info.status =3D=3D VIR_DOMAIN_DIRTYRATE_MEASURED) + vshPrint(ctl, _("dirtyRate: %lld MB/s\n"), info.dirtyRate); + else + vshPrint(ctl, _("dirtyRate: the calculation is %s, please = query results later\n"), + status); + } else { + vshPrint(ctl, _("Memory dirty rate is calculating, use --query opt= ion to display results.\n")); + } + + ret =3D true; + done: + virDomainFree(dom); + return ret; +} + const vshCmdDef domManagementCmds[] =3D { {.name =3D "attach-device", .handler =3D cmdAttachDevice, @@ -14960,5 +15066,11 @@ const vshCmdDef domManagementCmds[] =3D { .info =3D info_guestinfo, .flags =3D 0 }, + {.name =3D "getdirtyrate", + .handler =3D cmdGetDirtyRateInfo, + .opts =3D opts_getdirtyrate, + .info =3D info_getdirtyrate, + .flags =3D 0 + }, {.name =3D NULL} }; --=20 2.23.0