From nobody Sat Feb 7 06:55:17 2026 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; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1660409017; cv=none; d=zohomail.com; s=zohoarc; b=CYIZ1YXiK/hUmdJlqwAs+z/ZiwoxLLXa20q+suFR3G3LKhhSzJmKkOYsSp8z1LUlUiN8uP1Dd0uoJ8xAYPTUqsbdJP+9LBTduzwA+TXaA3uT8VcU/oviCqFDyq7ckSl0gNBypfVtolGMsux0lL2CrNTsf1fDUKMCgv75oDXubno= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1660409017; 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=lSc5Am5vIhtdEv2dLS8q2OXdFsXGBhe4BGHeJ8cDAbs=; b=EwBBpeEV94crnDKIuphR/PdlK/ZTSydyrWoXVL7DZFpLxnPW2TiICQ6xdYXm5+zcmPZUc1s9joXO666uXzzHl3X9ZUblKG15U1AyOCGGy8DDbhxiAQooq4epsJHjCoYv5Y8Bp+5ye+ER46cQrLBUEWdvQPhYlCe4vHzkQIZX7JI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.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 [170.10.133.124]) by mx.zohomail.com with SMTPS id 1660409017772754.6118674995031; Sat, 13 Aug 2022 09:43:37 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-34-Mgs2QelPPCC2Q65QCmDa8Q-1; Sat, 13 Aug 2022 12:43:31 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id CDF791035347; Sat, 13 Aug 2022 16:43:27 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id BB03294624; Sat, 13 Aug 2022 16:43:27 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 4A5A61947047; Sat, 13 Aug 2022 16:43:25 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id A44971946A4B for ; Sat, 13 Aug 2022 16:43:22 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 96AF0141512E; Sat, 13 Aug 2022 16:43:22 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast09.extmail.prod.ext.rdu2.redhat.com [10.11.55.25]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 933FE140EBE3 for ; Sat, 13 Aug 2022 16:43:22 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-2.mimecast.com [207.211.31.81]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 7A5CD29AA3B5 for ; Sat, 13 Aug 2022 16:43:22 +0000 (UTC) Received: from chinatelecom.cn (prt-mail.chinatelecom.cn [42.123.76.226]) by relay.mimecast.com with ESMTP id us-mta-573-iRTIDyRsPJ-Meyzh9iup8w-1; Sat, 13 Aug 2022 12:43:19 -0400 Received: from clientip-118.116.19.21 (unknown [172.18.0.218]) by chinatelecom.cn (HERMES) with SMTP id C02A52800B7; Sun, 14 Aug 2022 00:31:51 +0800 (CST) Received: from ([172.18.0.218]) by app0025 with ESMTP id d033c0882b844404b6e81db09215ff91 for libvir-list@redhat.com; Sun, 14 Aug 2022 00:31:52 CST DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1660409016; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:in-reply-to:references:references:references: list-id:list-help:list-unsubscribe:list-subscribe:list-post; bh=lSc5Am5vIhtdEv2dLS8q2OXdFsXGBhe4BGHeJ8cDAbs=; b=YD9EKme4JrEH4qkEbaRTkXAUHA2QQRCRA9/waGtFP5gDJEXyhnFCw0bxYxwIojJRTw7KCE HWa236c8hAdduop5lB6JtR4UZn9uKEtVrFD6lp4MUN1HIbLkZHgWPoCsDahl+ya2tdbWUZ SINn0+9FyHthOOAVEw+0dO9NSCWpFqI= X-MC-Unique: Mgs2QelPPCC2Q65QCmDa8Q-1 X-Original-To: libvir-list@listman.corp.redhat.com X-MC-Unique: iRTIDyRsPJ-Meyzh9iup8w-1 HMM_SOURCE_IP: 172.18.0.218:42044.1596025118 HMM_ATTACHE_NUM: 0000 HMM_SOURCE_TYPE: SMTP X-189-SAVE-TO-SEND: +huangy81@chinatelecom.cn X-Transaction-ID: d033c0882b844404b6e81db09215ff91 X-Real-From: huangy81@chinatelecom.cn X-Receive-IP: 172.18.0.218 X-MEDUSA-Status: 0 From: huangy81@chinatelecom.cn To: Subject: [PATCH 09/11] qemu_driver: Implement qemuDomainCancelVcpuDirtyLimit Date: Sun, 14 Aug 2022 00:31:21 +0800 Message-Id: <832e203a152f6a45bce225f5e1e9c8cef353b71b.1660406068.git.huangy81@chinatelecom.cn> In-Reply-To: References: In-Reply-To: References: MIME-Version: 1.0 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-Mimecast-Spam-Signature: yes X-Scanned-By: MIMEDefang 2.85 on 10.11.54.7 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Hyman=20Huang=28=E9=BB=84=E5=8B=87=29?= Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1660409019936100003 Content-Type: text/plain; charset="utf-8" From: Hyman Huang(=E9=BB=84=E5=8B=87) Implement qemuDomainCancelVcpuDirtyLimit to cancel vcpu dirty page rate limit. Signed-off-by: Hyman Huang(=E9=BB=84=E5=8B=87) --- src/qemu/qemu_driver.c | 47 ++++++++++++++++++++++++++++++++++++++++= ++++ src/qemu/qemu_monitor.c | 11 +++++++++++ src/qemu/qemu_monitor.h | 4 ++++ src/qemu/qemu_monitor_json.c | 35 +++++++++++++++++++++++++++++++++ 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 fbd6a32..06ad9a9 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -20800,6 +20800,52 @@ qemuDomainSetVcpuDirtyLimit(virDomainPtr domain, return ret; } =20 +static int +qemuDomainCancelVcpuDirtyLimit(virDomainPtr domain, + int vcpu, + unsigned int flags) +{ + virDomainObj *vm =3D NULL; + qemuDomainObjPrivate *priv; + int ret =3D -1; + + if (!(vm =3D qemuDomainObjFromDomain(domain))) + return -1; + + priv =3D vm->privateData; + if (!virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_VCPU_DIRTY_LIMIT)) { + virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s", + _("QEMU does not support setting vcpu dirty page ra= te limit")); + goto cleanup; + } + + if (qemuDomainObjBeginJob(vm, VIR_JOB_MODIFY) < 0) + goto cleanup; + + if (virDomainCancelVcpuDirtyLimitEnsureACL(domain->conn, vm->def) < 0) + goto endjob; + + if (virDomainObjCheckActive(vm) < 0) + goto endjob; + + qemuDomainObjEnterMonitor(vm); + if (flags & VIR_DOMAIN_DIRTYLIMIT_VCPU) { + VIR_DEBUG("Cancel vcpu[%d] dirty page rate limit", vcpu); + ret =3D qemuMonitorCancelVcpuDirtyLimit(priv->mon, vcpu); + } else { + VIR_DEBUG("Cancel all vcpus dirty page rate limit of vm"); + ret =3D qemuMonitorCancelVcpuDirtyLimit(priv->mon, -1); + } + qemuDomainObjExitMonitor(vm); + + endjob: + qemuDomainObjEndJob(vm); + + cleanup: + virDomainObjEndAPI(&vm); + return ret; +} + static virHypervisorDriver qemuHypervisorDriver =3D { .name =3D QEMU_DRIVER_NAME, .connectURIProbe =3D qemuConnectURIProbe, @@ -21049,6 +21095,7 @@ static virHypervisorDriver qemuHypervisorDriver =3D= { .domainStartDirtyRateCalc =3D qemuDomainStartDirtyRateCalc, /* 7.2.0 */ .domainSetLaunchSecurityState =3D qemuDomainSetLaunchSecurityState, /*= 8.0.0 */ .domainSetVcpuDirtyLimit =3D qemuDomainSetVcpuDirtyLimit, /* 8.7.0 */ + .domainCancelVcpuDirtyLimit =3D qemuDomainCancelVcpuDirtyLimit, /* 8.7= .0 */ }; =20 =20 diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c index 7480856..67d0171 100644 --- a/src/qemu/qemu_monitor.c +++ b/src/qemu/qemu_monitor.c @@ -4321,3 +4321,14 @@ qemuMonitorQueryVcpuDirtyLimit(qemuMonitor *mon, =20 return qemuMonitorJSONQueryVcpuDirtyLimit(mon, info); } + +int +qemuMonitorCancelVcpuDirtyLimit(qemuMonitor *mon, + int vcpu) +{ + VIR_DEBUG("cancel vcpu %d dirty page rate limit", vcpu); + + QEMU_CHECK_MONITOR(mon); + + return qemuMonitorJSONCancelVcpuDirtyLimit(mon, vcpu); +} diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h index cf76f43..bad55fc 100644 --- a/src/qemu/qemu_monitor.h +++ b/src/qemu/qemu_monitor.h @@ -1503,3 +1503,7 @@ struct _qemuMonitorVcpuDirtyLimitInfo { int qemuMonitorQueryVcpuDirtyLimit(qemuMonitor *mon, qemuMonitorVcpuDirtyLimitInfo *info); + +int +qemuMonitorCancelVcpuDirtyLimit(qemuMonitor *mon, + int vcpu); diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index 4642a2d..ef86384 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -8676,3 +8676,38 @@ qemuMonitorJSONQueryVcpuDirtyLimit(qemuMonitor *mon, =20 return qemuMonitorJSONExtractVcpuDirtyLimitInfo(data, info); } + +int +qemuMonitorJSONCancelVcpuDirtyLimit(qemuMonitor *mon, + int vcpu) +{ + g_autoptr(virJSONValue) cmd =3D NULL; + g_autoptr(virJSONValue) reply =3D NULL; + + if (vcpu >=3D 0) { + /* cancel vcpu dirty page rate limit */ + if (!(cmd =3D qemuMonitorJSONMakeCommand("cancel-vcpu-dirty-limit", + "i:cpu-index", vcpu, + NULL))) { + return -1; + } + } else if (vcpu =3D=3D -1) { + /* cancel vm dirty page rate limit */ + if (!(cmd =3D qemuMonitorJSONMakeCommand("cancel-vcpu-dirty-limit= ", + NULL))) { + return -1; + } + } else { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("unexpected vcpu index %d"), vcpu); + 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 2852061..12f330e 100644 --- a/src/qemu/qemu_monitor_json.h +++ b/src/qemu/qemu_monitor_json.h @@ -821,3 +821,7 @@ qemuMonitorJSONSetVcpuDirtyLimit(qemuMonitor *mon, int qemuMonitorJSONQueryVcpuDirtyLimit(qemuMonitor *mon, qemuMonitorVcpuDirtyLimitInfo *info); + +int +qemuMonitorJSONCancelVcpuDirtyLimit(qemuMonitor *mon, + int vcpu); --=20 1.8.3.1