From nobody Sun May 19 19:10:11 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; 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; dmarc=fail(p=none dis=none) header.from=git.sr.ht ARC-Seal: i=1; a=rsa-sha256; t=1691423782; cv=none; d=zohomail.com; s=zohoarc; b=P6tOUKrGxpAt4bIfDDMvZkUPmKAQQ5ZUW3bCVOWf3nkZAjTMHcyP94MvU43DdJWVl6Z7CfDUvI95vrkE1HoG9Nw5GADzc7/3dZiqmLFy+/N8O4JTSt8t2Yz2KA3njouWXs958/6ZgmUSf79j+nhnpeP4Gva0M/nCSEmxrnOfDkY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1691423782; 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:Reply-To:Sender:Subject:To; bh=VpcpIZ4DxsxkUrU/5Cs5VTkjROtq+x2FuQox/Z3IMoE=; b=lhffB1m9Z1cKRUW8b3ipF5+5d0MQFHSUgRas5Qoyx5Zgt2gmDycVr5WX+cC1tgXYraGMc2rMl76anFbC/Cj4JC0uk9rigA/3FgauaovDYuqswX5BCB9ZDq76TLDrk8c1pMLQkshj0/O30daQssLUUgJ44QSl9nHEvVM8v8i2Gi0= 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; dmarc=fail header.from= (p=none dis=none) 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 1691423782942391.14645066285107; Mon, 7 Aug 2023 08:56:22 -0700 (PDT) Received: from mimecast-mx02.redhat.com (66.187.233.73 [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-416-uBey2ODmM8aBaowmyfjgbw-1; Mon, 07 Aug 2023 11:56:17 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 44C13280BC43; Mon, 7 Aug 2023 15:56:15 +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 324F240D2839; Mon, 7 Aug 2023 15:56:15 +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 6C8AC19465BD; Mon, 7 Aug 2023 15:56:11 +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 DF86A1946588 for ; Mon, 7 Aug 2023 15:56:09 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 98AFF140E963; Mon, 7 Aug 2023 15:56:09 +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 908D4140E962 for ; Mon, 7 Aug 2023 15:56:09 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 71B67101A528 for ; Mon, 7 Aug 2023 15:56:09 +0000 (UTC) Received: from mail-b.sr.ht (mail-b.sr.ht [173.195.146.151]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-664-AeBQncx9Oi2a8Vwh6TobPA-1; Mon, 07 Aug 2023 11:56:07 -0400 Received: from git.sr.ht (unknown [173.195.146.142]) by mail-b.sr.ht (Postfix) with ESMTPSA id 40DE811EE9A; Mon, 7 Aug 2023 15:56:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1691423782; h=from:from:sender:sender:reply-to: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:list-id:list-help:list-unsubscribe: list-subscribe:list-post; bh=VpcpIZ4DxsxkUrU/5Cs5VTkjROtq+x2FuQox/Z3IMoE=; b=APcZDkvdYuS2iC7yFm1xjJPFUqoetrnfQ/XXzwN/2Ho2ok9e2dTmVilsY78pKU/SEuEHWs ejJmVn/hYzdDZ0eJGZ88QDPQS13wtmfKNYWkUB8JE/8tq/oQ8v2pfe8r3hCxHlGFILSMD8 mRxsUq+p/kPk1nsQoRVNLaJH9kgs0sQ= X-MC-Unique: uBey2ODmM8aBaowmyfjgbw-1 X-Original-To: libvir-list@listman.corp.redhat.com X-MC-Unique: AeBQncx9Oi2a8Vwh6TobPA-1 From: ~hyman Date: Tue, 02 Aug 2022 22:49:24 +0800 Subject: [PATCH Libvirt v2 01/10] qemu_capabilities: Introduce QEMU_CAPS_VCPU_DIRTY_LIMIT capability MIME-Version: 1.0 Message-ID: <169142376567.1452.17600824269401067909-1@git.sr.ht> In-Reply-To: <169142376567.1452.17600824269401067909-0@git.sr.ht> To: libvir-list@redhat.com 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 3.1 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: , Reply-To: ~hyman Cc: Peter Krempa , yong.huang@smartx.com Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: git.sr.ht Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1691423784459100003 From: Hyman Huang(=E9=BB=84=E5=8B=87) set-vcpu-dirty-limit/cancel-vcpu-dirty-limit/query-vcpu-dirty-limit were introduced since qemu >=3D7.1.0. Introduce corresponding capability. Signed-off-by: Hyman Huang(=E9=BB=84=E5=8B=87) --- src/qemu/qemu_capabilities.c | 2 ++ src/qemu/qemu_capabilities.h | 1 + tests/qemucapabilitiesdata/caps_7.1.0_ppc64.xml | 1 + tests/qemucapabilitiesdata/caps_7.1.0_x86_64.xml | 1 + tests/qemucapabilitiesdata/caps_7.2.0_ppc.xml | 1 + tests/qemucapabilitiesdata/caps_7.2.0_x86_64+hvf.xml | 1 + tests/qemucapabilitiesdata/caps_7.2.0_x86_64.xml | 1 + tests/qemucapabilitiesdata/caps_8.0.0_riscv64.xml | 1 + tests/qemucapabilitiesdata/caps_8.0.0_x86_64.xml | 1 + tests/qemucapabilitiesdata/caps_8.1.0_s390x.xml | 1 + tests/qemucapabilitiesdata/caps_8.1.0_x86_64.xml | 1 + 11 files changed, 12 insertions(+) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index f80bdb579d..6e0c095b55 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -697,6 +697,7 @@ VIR_ENUM_IMPL(virQEMUCaps, =20 /* 450 */ "run-with.async-teardown", /* QEMU_CAPS_RUN_WITH_ASYNC_TEARD= OWN */ + "set-vcpu-dirty-limit", /* QEMU_CAPS_VCPU_DIRTY_LIMIT */ ); =20 =20 @@ -1221,6 +1222,7 @@ struct virQEMUCapsStringFlags virQEMUCapsCommands[] = =3D { { "calc-dirty-rate", QEMU_CAPS_CALC_DIRTY_RATE }, { "query-stats", QEMU_CAPS_QUERY_STATS }, { "query-stats-schemas", QEMU_CAPS_QUERY_STATS_SCHEMAS }, + { "set-vcpu-dirty-limit", QEMU_CAPS_VCPU_DIRTY_LIMIT }, }; =20 struct virQEMUCapsStringFlags virQEMUCapsMigration[] =3D { diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h index c72f73a161..9e96f548af 100644 --- a/src/qemu/qemu_capabilities.h +++ b/src/qemu/qemu_capabilities.h @@ -676,6 +676,7 @@ typedef enum { /* virQEMUCapsFlags grouping marker for = syntax-check */ =20 /* 450 */ QEMU_CAPS_RUN_WITH_ASYNC_TEARDOWN, /* asynchronous teardown -run-with = async-teardown=3Don|off */ + QEMU_CAPS_VCPU_DIRTY_LIMIT, /* 'set-vcpu-dirty-limit' QMP command pres= ent */ =20 QEMU_CAPS_LAST /* this must always be the last item */ } virQEMUCapsFlags; diff --git a/tests/qemucapabilitiesdata/caps_7.1.0_ppc64.xml b/tests/qemuca= pabilitiesdata/caps_7.1.0_ppc64.xml index 3ff7a88cd2..f333df6599 100644 --- a/tests/qemucapabilitiesdata/caps_7.1.0_ppc64.xml +++ b/tests/qemucapabilitiesdata/caps_7.1.0_ppc64.xml @@ -158,6 +158,7 @@ + 7001000 42900244 v7.1.0 diff --git a/tests/qemucapabilitiesdata/caps_7.1.0_x86_64.xml b/tests/qemuc= apabilitiesdata/caps_7.1.0_x86_64.xml index 4e2addd76b..20e10b3090 100644 --- a/tests/qemucapabilitiesdata/caps_7.1.0_x86_64.xml +++ b/tests/qemucapabilitiesdata/caps_7.1.0_x86_64.xml @@ -195,6 +195,7 @@ + 7001000 43100244 v7.1.0 diff --git a/tests/qemucapabilitiesdata/caps_7.2.0_ppc.xml b/tests/qemucapa= bilitiesdata/caps_7.2.0_ppc.xml index 06f8c5801f..50e1d6c359 100644 --- a/tests/qemucapabilitiesdata/caps_7.2.0_ppc.xml +++ b/tests/qemucapabilitiesdata/caps_7.2.0_ppc.xml @@ -153,6 +153,7 @@ + 7002000 0 qemu-7.2.0-6.fc37 diff --git a/tests/qemucapabilitiesdata/caps_7.2.0_x86_64+hvf.xml b/tests/q= emucapabilitiesdata/caps_7.2.0_x86_64+hvf.xml index 0007a33dca..d804bb51e1 100644 --- a/tests/qemucapabilitiesdata/caps_7.2.0_x86_64+hvf.xml +++ b/tests/qemucapabilitiesdata/caps_7.2.0_x86_64+hvf.xml @@ -199,6 +199,7 @@ + 7002000 43100245 v7.2.0 diff --git a/tests/qemucapabilitiesdata/caps_7.2.0_x86_64.xml b/tests/qemuc= apabilitiesdata/caps_7.2.0_x86_64.xml index e298cbd9b1..618e2e7778 100644 --- a/tests/qemucapabilitiesdata/caps_7.2.0_x86_64.xml +++ b/tests/qemucapabilitiesdata/caps_7.2.0_x86_64.xml @@ -199,6 +199,7 @@ + 7002000 43100245 v7.2.0 diff --git a/tests/qemucapabilitiesdata/caps_8.0.0_riscv64.xml b/tests/qemu= capabilitiesdata/caps_8.0.0_riscv64.xml index 987962ca41..0643fd8054 100644 --- a/tests/qemucapabilitiesdata/caps_8.0.0_riscv64.xml +++ b/tests/qemucapabilitiesdata/caps_8.0.0_riscv64.xml @@ -140,6 +140,7 @@ + 7002050 0 v7.2.0-333-g222059a0fc diff --git a/tests/qemucapabilitiesdata/caps_8.0.0_x86_64.xml b/tests/qemuc= apabilitiesdata/caps_8.0.0_x86_64.xml index c43c209328..1e0bc96f88 100644 --- a/tests/qemucapabilitiesdata/caps_8.0.0_x86_64.xml +++ b/tests/qemucapabilitiesdata/caps_8.0.0_x86_64.xml @@ -203,6 +203,7 @@ + 8000000 43100244 v8.0.0 diff --git a/tests/qemucapabilitiesdata/caps_8.1.0_s390x.xml b/tests/qemuca= pabilitiesdata/caps_8.1.0_s390x.xml index 35751ed441..6d5e6ee76f 100644 --- a/tests/qemucapabilitiesdata/caps_8.1.0_s390x.xml +++ b/tests/qemucapabilitiesdata/caps_8.1.0_s390x.xml @@ -114,6 +114,7 @@ + 8000050 39100245 v8.0.0-1270-g1c12355b diff --git a/tests/qemucapabilitiesdata/caps_8.1.0_x86_64.xml b/tests/qemuc= apabilitiesdata/caps_8.1.0_x86_64.xml index e656a2024a..ca8b5d056c 100644 --- a/tests/qemucapabilitiesdata/caps_8.1.0_x86_64.xml +++ b/tests/qemucapabilitiesdata/caps_8.1.0_x86_64.xml @@ -204,6 +204,7 @@ + 8000050 43100245 v8.0.0-2835-g361d539735 --=20 2.38.5 From nobody Sun May 19 19:10:11 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.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.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=git.sr.ht ARC-Seal: i=1; a=rsa-sha256; t=1691423786; cv=none; d=zohomail.com; s=zohoarc; b=njkhwNM2mMviv5oVJ5E8q8LeuhGsMBkEimhh865wrNvH7oVpmU9JlEfH10r2XNSnQ5iNt1oOnEnsO/1EsI1uULqNMfzkAKnudv5hxAc+Z+cLa0XuiINdQsXF7xz8LXMIynq1DbhcpECbjnmP8rTtHJzHdkPtIgk68OhQyagGxdQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1691423786; 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:Reply-To:Sender:Subject:To; bh=tiTWb7Ek9/aTA7BqYuumeGmtLFfqblq/MqEbI0BC1bE=; b=e3t74H2qnbxcc1bsPNrEcLQx7drz7yA+9MIPMbRKf3faM1Z+Q5K2cqtIJOLrzRPLJw6Z7c2KMLktZPNi9DVa8lxPvsOk4p5rxket9cbXNDVEtPY0F64Jo3YrvpKsoSVbniKvrh9pB0k77DtzDTGUTJET4PCISV/iHlIgvDdwm0g= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1691423786581521.5815159448123; Mon, 7 Aug 2023 08:56:26 -0700 (PDT) Received: from mimecast-mx02.redhat.com (66.187.233.73 [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-199-FohSkqhHNjSlBmhEQ0nVpA-1; Mon, 07 Aug 2023 11:56:22 -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 D1EA23C108CD; Mon, 7 Aug 2023 15:56:18 +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 923E3440C7; Mon, 7 Aug 2023 15:56:18 +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 A9F9E1946A48; Mon, 7 Aug 2023 15:56:11 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id F24831946589 for ; Mon, 7 Aug 2023 15:56:09 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id D32E2C15BAE; Mon, 7 Aug 2023 15:56:09 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast08.extmail.prod.ext.rdu2.redhat.com [10.11.55.24]) by smtp.corp.redhat.com (Postfix) with ESMTPS id CBFC3C15BAD for ; Mon, 7 Aug 2023 15:56:09 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id A4D18381C16A for ; Mon, 7 Aug 2023 15:56:09 +0000 (UTC) Received: from mail-b.sr.ht (mail-b.sr.ht [173.195.146.151]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-240-nH0QXuo8M42HGcauu4z6Tw-1; Mon, 07 Aug 2023 11:56:07 -0400 Received: from git.sr.ht (unknown [173.195.146.142]) by mail-b.sr.ht (Postfix) with ESMTPSA id 775E711EEAC; Mon, 7 Aug 2023 15:56:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1691423785; h=from:from:sender:sender:reply-to: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:list-id:list-help:list-unsubscribe: list-subscribe:list-post; bh=tiTWb7Ek9/aTA7BqYuumeGmtLFfqblq/MqEbI0BC1bE=; b=eBOSJ/GYMYzFHmjRZGK5eOyPkV71OBfyyy4XDIrjIclTBhjZIamdiZygtH5FN2BC3oGRor FMJts2ZACPYeWXdduJuidVNHfuMxNJsqTEKjcsg7zltcXWUVeV5PFcUlyYlsddJffHlVMq fW0p5DMQzW16IC99UCqehtzp+URsm44= X-MC-Unique: FohSkqhHNjSlBmhEQ0nVpA-1 X-Original-To: libvir-list@listman.corp.redhat.com X-MC-Unique: nH0QXuo8M42HGcauu4z6Tw-1 From: ~hyman Date: Tue, 01 Aug 2023 17:31:12 +0800 Subject: [PATCH Libvirt v2 02/10] conf: Introduce XML for dirty limit configuration MIME-Version: 1.0 Message-ID: <169142376567.1452.17600824269401067909-2@git.sr.ht> In-Reply-To: <169142376567.1452.17600824269401067909-0@git.sr.ht> To: libvir-list@redhat.com 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 3.1 on 10.11.54.8 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: , Reply-To: ~hyman Cc: Peter Krempa , yong.huang@smartx.com Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: git.sr.ht Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1691423786968100007 From: Hyman Huang(=E9=BB=84=E5=8B=87) The upper limit (MB/s) of the dirty page rate configured by the user can be tracked by the XML. To allow this, add the following XML: ... 3 ... The "dirty_limit" attribute in "vcpu" sub-element within "vcpus" element allows to set an upper limit for the individual vCPU. The value can be set dynamically by limit-dirty-page-rate API. Note that the dirty limit feature is based on the dirty-ring feature, so it requires dirty-ring size configuration in XML. Signed-off-by: Hyman Huang(=E9=BB=84=E5=8B=87) --- docs/formatdomain.rst | 7 ++++++- src/conf/domain_conf.c | 26 ++++++++++++++++++++++++ src/conf/domain_conf.h | 8 ++++++++ src/conf/domain_validate.c | 33 +++++++++++++++++++++++++++++++ src/conf/schemas/domaincommon.rng | 5 +++++ 5 files changed, 78 insertions(+), 1 deletion(-) diff --git a/docs/formatdomain.rst b/docs/formatdomain.rst index cd9cb02bf8..7305ba38ea 100644 --- a/docs/formatdomain.rst +++ b/docs/formatdomain.rst @@ -649,7 +649,7 @@ CPU Allocation ... 2 - + ... @@ -715,6 +715,11 @@ CPU Allocation be enabled and non-hotpluggable. On PPC64 along with it vCPUs that are = in the same core need to be enabled as well. All non-hotpluggable CPUs present= at boot need to be grouped after vCPU 0. :since:`Since 2.2.0 (QEMU only)` + ``dirty_limit`` :since:`Since 9.6.0 (QEMU and KVM only)` + The optional attribute ``dirty_limit`` allows to set an upper limit (MB= /s) + of the dirty page rate for the vCPU. User can change the upper limit va= lue + dynamically by using ``limit-dirty-page-rate`` API. Require ``dirty-rin= g`` + size configured. =20 =20 IOThreads Allocation diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 47693a49bf..0af6ddd358 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -17061,6 +17061,7 @@ virDomainVcpuParse(virDomainDef *def, virDomainXMLOption *xmlopt) { int n; + int rv; xmlNodePtr vcpuNode; size_t i; unsigned int maxvcpus; @@ -17148,6 +17149,13 @@ virDomainVcpuParse(virDomainDef *def, if (virXMLPropUInt(nodes[i], "order", 10, VIR_XML_PROP_NONE, &vcpu->order) < 0) return -1; + + if ((rv =3D virXMLPropULongLong(nodes[i], "dirty_limit", 10, V= IR_XML_PROP_NONNEGATIVE, + &vcpu->dirty_limit)) < 0) { + return -1; + } else if (rv > 0) { + vcpu->dirtyLimitSet =3D true; + } } } else { if (virDomainDefSetVcpus(def, vcpus) < 0) @@ -21147,6 +21155,20 @@ virDomainDefVcpuCheckAbiStability(virDomainDef *sr= c, i); return false; } + + if (svcpu->dirtyLimitSet !=3D dvcpu->dirtyLimitSet) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("Dirty limit state of vCPU '%1$zu' differs be= tween source and destination definitions"), + i); + return false; + } + + if (svcpu->dirty_limit !=3D dvcpu->dirty_limit) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("Dirty limit of vCPU '%1$zu' differs between = source and destination definitions"), + i); + return false; + } } =20 return true; @@ -26712,6 +26734,10 @@ virDomainCpuDefFormat(virBuffer *buf, if (vcpu->order !=3D 0) virBufferAsprintf(buf, " order=3D'%d'", vcpu->order); =20 + if (vcpu->dirtyLimitSet) { + virBufferAsprintf(buf, " dirty_limit=3D'%llu'", vcpu->dirt= y_limit); + } + virBufferAddLit(buf, "/>\n"); } virBufferAdjustIndent(buf, -2); diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index c857ba556f..7e8bfcb884 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -2785,6 +2785,14 @@ struct _virDomainVcpuDef { virDomainThreadSchedParam sched; =20 virObject *privateData; + + /* set to true if the dirty page rate upper limit for + * the virtual CPU is configured + * */ + bool dirtyLimitSet; + + /* dirty page rate upper limit */ + unsigned long long dirty_limit; }; =20 struct _virDomainBlkiotune { diff --git a/src/conf/domain_validate.c b/src/conf/domain_validate.c index ad383b604e..db3b7e1d9d 100644 --- a/src/conf/domain_validate.c +++ b/src/conf/domain_validate.c @@ -1798,6 +1798,36 @@ virDomainDefValidateIOThreads(const virDomainDef *de= f) return 0; } =20 +static int +virDomainDefHasDirtyLimitStartupVcpus(const virDomainDef *def) +{ + size_t maxvcpus =3D virDomainDefGetVcpusMax(def); + virDomainVcpuDef *vcpu; + size_t i; + + for (i =3D 0; i < maxvcpus; i++) { + vcpu =3D def->vcpus[i]; + + if (vcpu->dirtyLimitSet && (vcpu->dirty_limit !=3D 0)) + return true; + } + + return false; +} + +static int +virDomainDefDirtyLimitValidate(const virDomainDef *def) +{ + if (virDomainDefHasDirtyLimitStartupVcpus(def)) { + if (def->kvm_features->dirty_ring_size =3D=3D 0) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("Dirty limit requires dirty-ring size configu= ration")); + return -1; + } + } + + return 0; +} =20 static int virDomainDefValidateInternal(const virDomainDef *def, @@ -1854,6 +1884,9 @@ virDomainDefValidateInternal(const virDomainDef *def, if (virDomainDefValidateIOThreads(def) < 0) return -1; =20 + if (virDomainDefDirtyLimitValidate(def) < 0) + return -1; + return 0; } =20 diff --git a/src/conf/schemas/domaincommon.rng b/src/conf/schemas/domaincom= mon.rng index c2f56b0490..da0986b7c3 100644 --- a/src/conf/schemas/domaincommon.rng +++ b/src/conf/schemas/domaincommon.rng @@ -859,6 +859,11 @@ + + + + + --=20 2.38.5 From nobody Sun May 19 19:10:11 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.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.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=git.sr.ht ARC-Seal: i=1; a=rsa-sha256; t=1691423783; cv=none; d=zohomail.com; s=zohoarc; b=EsXnezmLj5AZKkRKG7VAci6gA9KNpuZwFsnB/4Csz5vp3I3GXAI5/VilTdbmDXvV/I1SQBhFfyif9PYe2Bzgs+a66X1yc3gULHy0/zApTfv3Y3br7bs12PPglFyGnUhflv/zb0fNFQkAc5XBZ2J8r4P8hqctFquWuwoQC6Hhi1U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1691423783; 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:Reply-To:Sender:Subject:To; bh=FIwebUZ+VRdObEsUPax4AgauoAZSSdpQJbB7HMoJCPE=; b=Wxas0EsVU26jLGinRCbI77vYXWzifSM+2hEi5zhhN5Oa7M1Xezelu1bxHoiXAE5th2OOhPebs1dz2+gwZksQo9CLgNSWvy4n5Nlta/ZL6p/RNd+AnhejKXuzrFDPJtkUIEOhDgnulGRozgbc81KOVoO9FVrswimpRc+0CTYxX5A= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1691423783509202.15451183145922; Mon, 7 Aug 2023 08:56:23 -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-371-8_JP-XHzPiOcW7jojmPFyw-1; Mon, 07 Aug 2023 11:56:16 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id B9B20185A78F; Mon, 7 Aug 2023 15:56:13 +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 DF5E340C2077; Mon, 7 Aug 2023 15:56:10 +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 69C9A1946587; Mon, 7 Aug 2023 15:56:10 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id DF3891946586 for ; Mon, 7 Aug 2023 15:56:09 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id B05BF1121318; Mon, 7 Aug 2023 15:56:09 +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 A7FE51121314 for ; Mon, 7 Aug 2023 15:56:09 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-inbound-delivery-1.mimecast.com [205.139.110.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 8577D101AA48 for ; Mon, 7 Aug 2023 15:56:09 +0000 (UTC) Received: from mail-b.sr.ht (mail-b.sr.ht [173.195.146.151]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-114-wto4xEfPOSCE8Fr1Sp_JFw-1; Mon, 07 Aug 2023 11:56:07 -0400 Received: from git.sr.ht (unknown [173.195.146.142]) by mail-b.sr.ht (Postfix) with ESMTPSA id BF29911EEC6; Mon, 7 Aug 2023 15:56:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1691423782; h=from:from:sender:sender:reply-to: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:list-id:list-help:list-unsubscribe: list-subscribe:list-post; bh=FIwebUZ+VRdObEsUPax4AgauoAZSSdpQJbB7HMoJCPE=; b=U1n+lsZocu6Y/4q2D4MzFDjlQlBR+iq7rfFLwfgztNXwROuemSchsesbsuXzJc/0/lgxYh taPgtKpKwS7TRJ3s38cCNVuCP3V+BOhAjLL+SkgmOjzA/GZIVRBMvNQ1OiT8/ltT0DjL9G aVLzt/wG9oQydMNARKMp9rzRIgrw75E= X-MC-Unique: 8_JP-XHzPiOcW7jojmPFyw-1 X-Original-To: libvir-list@listman.corp.redhat.com X-MC-Unique: wto4xEfPOSCE8Fr1Sp_JFw-1 From: ~hyman Date: Tue, 02 Aug 2022 22:13:40 +0800 Subject: [PATCH Libvirt v2 03/10] libvirt: Add virDomainSetVcpuDirtyLimit API MIME-Version: 1.0 Message-ID: <169142376567.1452.17600824269401067909-3@git.sr.ht> In-Reply-To: <169142376567.1452.17600824269401067909-0@git.sr.ht> To: libvir-list@redhat.com 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 3.1 on 10.11.54.3 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: , Reply-To: ~hyman Cc: Peter Krempa , yong.huang@smartx.com Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: git.sr.ht Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1691423784965100005 From: Hyman Huang(=E9=BB=84=E5=8B=87) Introduce virDomainSetVcpuDirtyLimit API to set or cancel the dirty page rate upper limit. The API will throttle the virtual CPU as needed to keep their dirty page rate within the limit set by @rate. Since it just throttles the virtual CPU, which dirties memory, read processes in the guest OS aren't penalized. This could, in some scenes, be used to provide quality-of-service in the aspect of the memory workload for virtual CPUs. Signed-off-by: Hyman Huang(=E9=BB=84=E5=8B=87) --- include/libvirt/libvirt-domain.h | 4 +++ src/driver-hypervisor.h | 7 ++++ src/libvirt-domain.c | 59 ++++++++++++++++++++++++++++++++ src/libvirt_public.syms | 5 +++ src/remote/remote_driver.c | 1 + src/remote/remote_protocol.x | 17 ++++++++- src/remote_protocol-structs | 7 ++++ 7 files changed, 99 insertions(+), 1 deletion(-) diff --git a/include/libvirt/libvirt-domain.h b/include/libvirt/libvirt-dom= ain.h index a1902546bb..3d3c7cdcba 100644 --- a/include/libvirt/libvirt-domain.h +++ b/include/libvirt/libvirt-domain.h @@ -6506,4 +6506,8 @@ int virDomainFDAssociate(virDomainPtr domain, int *fds, unsigned int flags); =20 +int virDomainSetVcpuDirtyLimit(virDomainPtr domain, + int vcpu, + unsigned long long rate, + unsigned int flags); #endif /* LIBVIRT_DOMAIN_H */ diff --git a/src/driver-hypervisor.h b/src/driver-hypervisor.h index 5219344b72..e61b9efca5 100644 --- a/src/driver-hypervisor.h +++ b/src/driver-hypervisor.h @@ -1448,6 +1448,12 @@ typedef int int *fds, unsigned int flags); =20 +typedef int +(*virDrvDomainSetVcpuDirtyLimit)(virDomainPtr domain, + int vcpu, + unsigned long long rate, + unsigned int flags); + typedef struct _virHypervisorDriver virHypervisorDriver; =20 /** @@ -1720,4 +1726,5 @@ struct _virHypervisorDriver { virDrvDomainGetMessages domainGetMessages; virDrvDomainStartDirtyRateCalc domainStartDirtyRateCalc; virDrvDomainFDAssociate domainFDAssociate; + virDrvDomainSetVcpuDirtyLimit domainSetVcpuDirtyLimit; }; diff --git a/src/libvirt-domain.c b/src/libvirt-domain.c index ec42bb9a53..9a60ac7f67 100644 --- a/src/libvirt-domain.c +++ b/src/libvirt-domain.c @@ -14059,3 +14059,62 @@ virDomainFDAssociate(virDomainPtr domain, virDispatchError(conn); return -1; } + +/** + * virDomainSetVcpuDirtyLimit: + * @domain: pointer to domain object + * @vcpu: index of the limited virtual CPU + * @rate: upper limit of dirty page rate (mebibyte/s) for virtual CPUs + * @flags: bitwise-OR of virDomainModificationImpact + * + * Dynamically set the dirty page rate upper limit for the virtual CPUs. + * + * @vcpu may be a positive value, zero, or equal to -1. If -1 is set, + * the change affects all virtual CPUs of VM; it affects the specified + * virtual CPU otherwise. + * @rate may be 0 to cancel the limit or a positive value to enable. The + * hypervisors are free to round it down to the nearest mebibyte/s. + * + * The API will throttle the virtual CPU as needed to keep their dirty + * page rate within the limit set by @rate. Since it just throttles the + * virtual CPU, which dirties memory, read processes in the guest OS + * aren't penalized. This could, in some scenes, be used to provide + * quality-of-service in the aspect of the memory workload for virtual + * CPUs. + * + * Returns 0 in case of success, -1 in case of failure. + * + * Since: 9.6.0 + */ +int +virDomainSetVcpuDirtyLimit(virDomainPtr domain, + int vcpu, + unsigned long long rate, + unsigned int flags) +{ + virConnectPtr conn; + + VIR_DOMAIN_DEBUG(domain, "vcpu=3D%d, rate=3D%llu, flags=3D0x%x", + vcpu, rate, flags); + + virResetLastError(); + + virCheckDomainReturn(domain, -1); + conn =3D domain->conn; + + virCheckReadOnlyGoto(conn->flags, error); + + if (conn->driver->domainSetVcpuDirtyLimit) { + int ret; + ret =3D conn->driver->domainSetVcpuDirtyLimit(domain, vcpu, rate, = flags); + if (ret < 0) + goto error; + return ret; + } + + virReportUnsupportedError(); + + error: + virDispatchError(domain->conn); + return -1; +} diff --git a/src/libvirt_public.syms b/src/libvirt_public.syms index 80742f268e..6fc01b518f 100644 --- a/src/libvirt_public.syms +++ b/src/libvirt_public.syms @@ -932,4 +932,9 @@ LIBVIRT_9.0.0 { virDomainFDAssociate; } LIBVIRT_8.5.0; =20 +LIBVIRT_9.6.0 { + global: + virDomainSetVcpuDirtyLimit; +} LIBVIRT_9.0.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 faad7292ed..9d7522d3bf 100644 --- a/src/remote/remote_driver.c +++ b/src/remote/remote_driver.c @@ -8119,6 +8119,7 @@ static virHypervisorDriver hypervisor_driver =3D { .domainStartDirtyRateCalc =3D remoteDomainStartDirtyRateCalc, /* 7.2.0= */ .domainSetLaunchSecurityState =3D remoteDomainSetLaunchSecurityState, = /* 8.0.0 */ .domainFDAssociate =3D remoteDomainFDAssociate, /* 9.0.0 */ + .domainSetVcpuDirtyLimit =3D remoteDomainSetVcpuDirtyLimit, /* 9.6.0 */ }; =20 static virNetworkDriver network_driver =3D { diff --git a/src/remote/remote_protocol.x b/src/remote/remote_protocol.x index 5d86a51116..33bdad7865 100644 --- a/src/remote/remote_protocol.x +++ b/src/remote/remote_protocol.x @@ -3935,6 +3935,14 @@ struct remote_domain_fd_associate_args { remote_nonnull_string name; unsigned int flags; }; + +struct remote_domain_set_vcpu_dirty_limit_args { + remote_nonnull_domain dom; + int vcpu; + unsigned hyper rate; + unsigned int flags; +}; + /*----- Protocol. -----*/ =20 /* Define the program number, protocol version and procedure numbers here.= */ @@ -6974,5 +6982,12 @@ enum remote_procedure { * @generate: none * @acl: domain:write */ - REMOTE_PROC_DOMAIN_FD_ASSOCIATE =3D 443 + REMOTE_PROC_DOMAIN_FD_ASSOCIATE =3D 443, + /** + * @generate: both + * @acl: domain:write + * @acl: domain:save:!VIR_DOMAIN_AFFECT_CONFIG|VIR_DOMAIN_AFFECT_LIVE + * @acl: domain:save:VIR_DOMAIN_AFFECT_CONFIG + */ + REMOTE_PROC_DOMAIN_SET_VCPU_DIRTY_LIMIT =3D 444 }; diff --git a/src/remote_protocol-structs b/src/remote_protocol-structs index 3c6c230a16..f7543ec667 100644 --- a/src/remote_protocol-structs +++ b/src/remote_protocol-structs @@ -3273,6 +3273,12 @@ struct remote_domain_fd_associate_args { remote_nonnull_string name; u_int flags; }; +struct remote_domain_set_vcpu_dirty_limit_args { + remote_nonnull_domain dom; + int vcpu; + uint64_t rate; + u_int flags; +}; enum remote_procedure { REMOTE_PROC_CONNECT_OPEN =3D 1, REMOTE_PROC_CONNECT_CLOSE =3D 2, @@ -3717,4 +3723,5 @@ enum remote_procedure { REMOTE_PROC_DOMAIN_RESTORE_PARAMS =3D 441, REMOTE_PROC_DOMAIN_ABORT_JOB_FLAGS =3D 442, REMOTE_PROC_DOMAIN_FD_ASSOCIATE =3D 443, + REMOTE_PROC_DOMAIN_SET_VCPU_DIRTY_LIMIT =3D 444, }; --=20 2.38.5 From nobody Sun May 19 19:10:11 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.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.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=git.sr.ht ARC-Seal: i=1; a=rsa-sha256; t=1691423800; cv=none; d=zohomail.com; s=zohoarc; b=JnWaKjDvreb0dLTB4J9W5sKOfOw1FkhOgXgtTRAn0tmeVvuyisFBMTOCzod/52o0jEW95TxlOpZ1mEcSvw7UwbHl7J9bTIEEKc3AcycrXrC/NKi/gnX7wnEC3qMjsEhnkSeQUGopirmO4wIIhX+qBxU/I7fZrLtFqJYrnVmelbk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1691423800; 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:Reply-To:Sender:Subject:To; bh=Gxd1QUTdQbQuaDPGHZOM4V4WoQ0HVnp8ynJKSIS+apI=; b=lRSHaaOnRjUPtKAYMLPHzMZ+WL7qfSecBCXHwPrIDhIp4coXfPrhbIgmprjpXzWNkibKYdYW2rM7J/W5c8HbQWolK9vhESRFfgvRThrpc2eYXGMbEQouojZ7fBBGwRecCGdXGuBUu2n2TCxVM0tYoxOEg6hGroT9ieBbUeYFFeU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1691423800608581.8134012515646; Mon, 7 Aug 2023 08:56:40 -0700 (PDT) Received: from mimecast-mx02.redhat.com (66.187.233.73 [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-657-GIFdaHY9Nh6_uAgunaQ6Qw-1; Mon, 07 Aug 2023 11:56:33 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 033E23C108CE; Mon, 7 Aug 2023 15:56:31 +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 E244B40D2839; Mon, 7 Aug 2023 15:56:30 +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 879311946A77; Mon, 7 Aug 2023 15:56:17 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 64FA319465A4 for ; Mon, 7 Aug 2023 15:56:12 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 56941415F27; Mon, 7 Aug 2023 15:56:12 +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 4E63B403174 for ; Mon, 7 Aug 2023 15:56:12 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-inbound-delivery-1.mimecast.com [205.139.110.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 33A08280BC47 for ; Mon, 7 Aug 2023 15:56:12 +0000 (UTC) Received: from mail-b.sr.ht (mail-b.sr.ht [173.195.146.151]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-288-t2ZUqdHWP_e0F4ArL4zv_Q-1; Mon, 07 Aug 2023 11:56:07 -0400 Received: from git.sr.ht (unknown [173.195.146.142]) by mail-b.sr.ht (Postfix) with ESMTPSA id E64B011EF1B; Mon, 7 Aug 2023 15:56:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1691423799; h=from:from:sender:sender:reply-to: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:list-id:list-help:list-unsubscribe: list-subscribe:list-post; bh=Gxd1QUTdQbQuaDPGHZOM4V4WoQ0HVnp8ynJKSIS+apI=; b=ZTZkI6T4VTMhqmqldT3RTnXh+1IMdTSks/4mm1EiPM9xhCnPWtyRB1oHtstYEs6BtFFAgb drB0mO/JNHe4X5+S+KdKSBUTPWSHon4bdQjrJb6KzoqVJq8J+xWFyzTS3EGdR7i+f2vn8T NVz2TKs6ZUUb3qyn+zelN1TpgguLses= X-MC-Unique: GIFdaHY9Nh6_uAgunaQ6Qw-1 X-Original-To: libvir-list@listman.corp.redhat.com X-MC-Unique: t2ZUqdHWP_e0F4ArL4zv_Q-1 From: ~hyman Date: Wed, 03 Aug 2022 00:27:47 +0800 Subject: [PATCH Libvirt v2 04/10] qemu_driver: Implement qemuDomainSetVcpuDirtyLimit MIME-Version: 1.0 Message-ID: <169142376567.1452.17600824269401067909-4@git.sr.ht> In-Reply-To: <169142376567.1452.17600824269401067909-0@git.sr.ht> To: libvir-list@redhat.com 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 3.1 on 10.11.54.10 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: , Reply-To: ~hyman Cc: Peter Krempa , yong.huang@smartx.com Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: git.sr.ht Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1691423801252100003 From: Hyman Huang(=E9=BB=84=E5=8B=87) Implement qemuDomainSetVcpuDirtyLimit, which can be used to set or cancel the upper limit of the dirty page rate for virtual CPUs. Signed-off-by: Hyman Huang(=E9=BB=84=E5=8B=87) --- src/qemu/qemu_driver.c | 131 +++++++++++++++++++++++++++++++++++ src/qemu/qemu_monitor.c | 13 ++++ src/qemu/qemu_monitor.h | 5 ++ src/qemu/qemu_monitor_json.c | 43 ++++++++++++ src/qemu/qemu_monitor_json.h | 5 ++ 5 files changed, 197 insertions(+) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index f8039160f4..9779cd0579 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -19906,6 +19906,136 @@ qemuDomainFDAssociate(virDomainPtr domain, return ret; } =20 +static void +qemuDomainSetDirtyLimit(virDomainVcpuDef *vcpu, + unsigned long long rate) +{ + if (rate > 0) { + vcpu->dirtyLimitSet =3D true; + vcpu->dirty_limit =3D rate; + } else { + vcpu->dirtyLimitSet =3D false; + vcpu->dirty_limit =3D 0; + } +} + +static void +qemuDomainSetVcpuDirtyLimitConfig(virDomainDef *def, + int vcpu, + unsigned long long rate) +{ + def->individualvcpus =3D true; + + if (vcpu =3D=3D -1) { + size_t maxvcpus =3D virDomainDefGetVcpusMax(def); + size_t i; + for (i =3D 0; i < maxvcpus; i++) { + qemuDomainSetDirtyLimit(virDomainDefGetVcpu(def, i), rate); + } + } else { + qemuDomainSetDirtyLimit(virDomainDefGetVcpu(def, vcpu), rate); + } +} + +static int +qemuDomainSetVcpuDirtyLimitInternal(virQEMUDriver *driver, + virDomainObj *vm, + virDomainDef *def, + virDomainDef *persistentDef, + int vcpu, + unsigned long long rate) +{ + g_autoptr(virQEMUDriverConfig) cfg =3D virQEMUDriverGetConfig(driver); + qemuDomainObjPrivate *priv =3D vm->privateData; + + VIR_DEBUG("vcpu %d, rate %llu", vcpu, rate); + if (def) { + qemuDomainObjEnterMonitor(vm); + if (qemuMonitorSetVcpuDirtyLimit(priv->mon, vcpu, rate) < 0) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Failed to set dirty page rate limit")); + qemuDomainObjExitMonitor(vm); + return -1; + } + qemuDomainObjExitMonitor(vm); + qemuDomainSetVcpuDirtyLimitConfig(def, vcpu, rate); + } + + if (persistentDef) { + qemuDomainSetVcpuDirtyLimitConfig(persistentDef, vcpu, rate); + if (virDomainDefSave(persistentDef, driver->xmlopt, cfg->configDir= ) < 0) + return -1; + } + + return 0; +} + +static int +qemuDomainSetVcpuDirtyLimit(virDomainPtr domain, + int vcpu, + unsigned long long rate, + unsigned int flags) +{ + virQEMUDriver *driver =3D domain->conn->privateData; + virDomainObj *vm =3D NULL; + qemuDomainObjPrivate *priv; + virDomainDef *def =3D NULL; + virDomainDef *persistentDef =3D NULL; + int ret =3D -1; + + virCheckFlags(VIR_DOMAIN_AFFECT_LIVE | + VIR_DOMAIN_AFFECT_CONFIG, -1); + + if (!(vm =3D qemuDomainObjFromDomain(domain))) + return -1; + + if (virDomainSetVcpuDirtyLimitEnsureACL(domain->conn, vm->def, flags) = < 0) + goto cleanup; + + if (virDomainObjBeginJob(vm, VIR_JOB_MODIFY) < 0) + goto cleanup; + + if (virDomainObjGetDefs(vm, flags, &def, &persistentDef) < 0) + goto endjob; + + if (persistentDef) { + if (vcpu >=3D 0 && vcpu >=3D (int)virDomainDefGetVcpusMax(persiste= ntDef)) { + virReportError(VIR_ERR_INVALID_ARG, + _("vcpu %1$d is not present in persistent confi= g"), + vcpu); + goto endjob; + } + } + + if (def) { + if (virDomainObjCheckActive(vm) < 0) + goto endjob; + + priv =3D vm->privateData; + if (!virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_VCPU_DIRTY_LIMIT)) { + virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s", + _("QEMU does not support setting dirty page rat= e limit")); + goto endjob; + } + + if (vcpu >=3D 0 && vcpu >=3D (int)virDomainDefGetVcpusMax(def)) { + virReportError(VIR_ERR_INVALID_ARG, + _("vcpu %1$d is not present in live config"), + vcpu); + goto endjob; + } + } + + ret =3D qemuDomainSetVcpuDirtyLimitInternal(driver, vm, def, persisten= tDef, + vcpu, rate); + + endjob: + virDomainObjEndJob(vm); + + cleanup: + virDomainObjEndAPI(&vm); + return ret; +} =20 static virHypervisorDriver qemuHypervisorDriver =3D { .name =3D QEMU_DRIVER_NAME, @@ -20156,6 +20286,7 @@ static virHypervisorDriver qemuHypervisorDriver =3D= { .domainStartDirtyRateCalc =3D qemuDomainStartDirtyRateCalc, /* 7.2.0 */ .domainSetLaunchSecurityState =3D qemuDomainSetLaunchSecurityState, /*= 8.0.0 */ .domainFDAssociate =3D qemuDomainFDAssociate, /* 9.0.0 */ + .domainSetVcpuDirtyLimit =3D qemuDomainSetVcpuDirtyLimit, /* 9.6.0 */ }; =20 =20 diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c index 02da1d6dfc..5756b4ff50 100644 --- a/src/qemu/qemu_monitor.c +++ b/src/qemu/qemu_monitor.c @@ -4501,3 +4501,16 @@ qemuMonitorGetStatsByQOMPath(virJSONValue *arr, =20 return NULL; } + + +int +qemuMonitorSetVcpuDirtyLimit(qemuMonitor *mon, + int vcpu, + unsigned long long rate) +{ + VIR_DEBUG("set vcpu %d dirty page rate limit %llu", vcpu, rate); + + QEMU_CHECK_MONITOR(mon); + + return qemuMonitorJSONSetVcpuDirtyLimit(mon, vcpu, rate); +} diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h index 6c590933aa..07a05365cf 100644 --- a/src/qemu/qemu_monitor.h +++ b/src/qemu/qemu_monitor.h @@ -1579,3 +1579,8 @@ qemuMonitorExtractQueryStats(virJSONValue *info); virJSONValue * qemuMonitorGetStatsByQOMPath(virJSONValue *arr, char *qom_path); + +int +qemuMonitorSetVcpuDirtyLimit(qemuMonitor *mon, + int vcpu, + unsigned long long rate); diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index 34c4b543e8..6200cf097d 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -8886,3 +8886,46 @@ qemuMonitorJSONQueryStats(qemuMonitor *mon, =20 return virJSONValueObjectStealArray(reply, "return"); } + +/** + * qemuMonitorJSONSetVcpuDirtyLimit: + * @mon: monitor object + * @vcpu: virtual cpu index to be set, -1 affects all virtual CPUs + * @rate: dirty page rate upper limit to be set, use 0 to disable + * and a positive value to enable + * + * Returns -1 on failure. + */ +int +qemuMonitorJSONSetVcpuDirtyLimit(qemuMonitor *mon, + int vcpu, + unsigned long long rate) +{ + g_autoptr(virJSONValue) cmd =3D NULL; + g_autoptr(virJSONValue) reply =3D NULL; + + if (rate !=3D 0) { + /* set the vcpu dirty page rate limit */ + if (!(cmd =3D qemuMonitorJSONMakeCommand("set-vcpu-dirty-limit", + "k:cpu-index", vcpu, + "U:dirty-rate", rate, + NULL))) { + return -1; + } + } else { + /* cancel the vcpu dirty page rate limit */ + if (!(cmd =3D qemuMonitorJSONMakeCommand("cancel-vcpu-dirty-limit", + "k:cpu-index", vcpu, + 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 06023b98ea..89f61b3052 100644 --- a/src/qemu/qemu_monitor_json.h +++ b/src/qemu/qemu_monitor_json.h @@ -825,3 +825,8 @@ qemuMonitorJSONQueryStats(qemuMonitor *mon, qemuMonitorQueryStatsTargetType target, char **vcpus, GPtrArray *providers); + +int +qemuMonitorJSONSetVcpuDirtyLimit(qemuMonitor *mon, + int vcpu, + unsigned long long rate); --=20 2.38.5 From nobody Sun May 19 19:10:11 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; 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; dmarc=fail(p=none dis=none) header.from=git.sr.ht ARC-Seal: i=1; a=rsa-sha256; t=1691423792; cv=none; d=zohomail.com; s=zohoarc; b=ngRdIYXpHGM/ycfDnS90F5WWacKhXFZP2+q4AKir41AxkIyGo7D5U4x4uzExlH6R0V5utR9F6/AG5pjWc4HdJIgPPrPC6Q4EPO19t3z69VC8btPAuuYu2I5XZvXhn7k9STo+QGxhydXgFj5SJ//9FXFN48gnJyCzwu9jdilLzk4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1691423792; 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:Reply-To:Sender:Subject:To; bh=JVEDV/9pOHZmugXQbVP0GfxebbeOFlmJAZJ0VLzmdmA=; b=WNf+l1EPooYeruIWSsph6/TFz/lz6c248EQ32y6DIfdUFqxXsahUAWSbM9IDfWtFfjdRFnFcsnwNpsZq2rLSgjv3qZ2m6hlotqTwpDucyCrVeOxQx18gPwN/X9kjUZX3Ep6qpxUZaRnuUpW38RjBm2k2rwNtabpEJho6XyieoM8= 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; dmarc=fail header.from= (p=none dis=none) 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 1691423792915957.6618513296011; Mon, 7 Aug 2023 08:56:32 -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-636-GhlUnTKYPjGWG4njBltr6g-1; Mon, 07 Aug 2023 11:56:28 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 38DF6857A84; Mon, 7 Aug 2023 15:56:25 +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 23E17C15BB8; Mon, 7 Aug 2023 15:56:25 +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 4AB9D1946A69; Mon, 7 Aug 2023 15:56:17 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id CFECE1946A51 for ; Mon, 7 Aug 2023 15:56:11 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id A9D7C2026D2A; Mon, 7 Aug 2023 15:56:11 +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 A221F2026D68 for ; Mon, 7 Aug 2023 15:56:11 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-2.mimecast.com [205.139.110.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 2E9BC802A6E for ; Mon, 7 Aug 2023 15:56:11 +0000 (UTC) Received: from mail-b.sr.ht (mail-b.sr.ht [173.195.146.151]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-426-jdYHvckaMCu9_66hnKNvfQ-1; Mon, 07 Aug 2023 11:56:09 -0400 Received: from git.sr.ht (unknown [173.195.146.142]) by mail-b.sr.ht (Postfix) with ESMTPSA id 1A37511EF84; Mon, 7 Aug 2023 15:56:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1691423791; h=from:from:sender:sender:reply-to: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:list-id:list-help:list-unsubscribe: list-subscribe:list-post; bh=JVEDV/9pOHZmugXQbVP0GfxebbeOFlmJAZJ0VLzmdmA=; b=bbcquTdEObhaajMbJ5gpntqYtOfYu2PD5+z5EzsuBjWk3q7F6OGyXsYFfmMg2lrt7Ef3cv fHnO2Y9vLRFUwEa7uTowdwRtRTyli2J+LXXtNxJ6rUXrASprTwD4MeHnvkSYVR24b5Umg1 Ne+dGYX3oJRTQRCeapGnMGpDLPB81OU= X-MC-Unique: GhlUnTKYPjGWG4njBltr6g-1 X-Original-To: libvir-list@listman.corp.redhat.com X-MC-Unique: jdYHvckaMCu9_66hnKNvfQ-1 From: ~hyman Date: Fri, 04 Aug 2023 10:03:06 +0800 Subject: [PATCH Libvirt v2 05/10] domain_validate: Export virDomainDefHasDirtyLimitStartupVcpus symbol MIME-Version: 1.0 Message-ID: <169142376567.1452.17600824269401067909-5@git.sr.ht> In-Reply-To: <169142376567.1452.17600824269401067909-0@git.sr.ht> To: libvir-list@redhat.com 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 3.1 on 10.11.54.4 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: , Reply-To: ~hyman Cc: Peter Krempa , yong.huang@smartx.com Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: git.sr.ht Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1691423794019100001 From: Hyman Huang(=E9=BB=84=E5=8B=87) Export virDomainDefHasDirtyLimitStartupVcpus as a util function, which could be used in qemu_process.c file for the next commit. Signed-off-by: Hyman Huang(=E9=BB=84=E5=8B=87) --- src/conf/domain_validate.c | 2 +- src/conf/domain_validate.h | 2 ++ src/libvirt_private.syms | 1 + 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/conf/domain_validate.c b/src/conf/domain_validate.c index db3b7e1d9d..7036fcae1d 100644 --- a/src/conf/domain_validate.c +++ b/src/conf/domain_validate.c @@ -1798,7 +1798,7 @@ virDomainDefValidateIOThreads(const virDomainDef *def) return 0; } =20 -static int +int virDomainDefHasDirtyLimitStartupVcpus(const virDomainDef *def) { size_t maxvcpus =3D virDomainDefGetVcpusMax(def); diff --git a/src/conf/domain_validate.h b/src/conf/domain_validate.h index fc441cef5b..ccec3663cc 100644 --- a/src/conf/domain_validate.h +++ b/src/conf/domain_validate.h @@ -47,3 +47,5 @@ int virDomainDiskDefSourceLUNValidate(const virStorageSou= rce *src); =20 int virDomainDefOSValidate(const virDomainDef *def, virDomainXMLOption *xmlopt); + +int virDomainDefHasDirtyLimitStartupVcpus(const virDomainDef *def); diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index da60c965dd..984e9d6b3a 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -793,6 +793,7 @@ virDomainDefPostParse; =20 # conf/domain_validate.h virDomainActualNetDefValidate; +virDomainDefHasDirtyLimitStartupVcpus; virDomainDefOSValidate; virDomainDefValidate; virDomainDeviceValidateAliasForHotplug; --=20 2.38.5 From nobody Sun May 19 19:10:11 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; 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; dmarc=fail(p=none dis=none) header.from=git.sr.ht ARC-Seal: i=1; a=rsa-sha256; t=1691423806; cv=none; d=zohomail.com; s=zohoarc; b=RBmgPkw4fi33+ZHkfC2e2Ff1njNOdeLFBSTSpj2F/OnRruWdZvcQyfetCldwoRa3sB+wMbZLBnJuFC4vTFEexZ+1YiRhxZ7GmJTTxbCZYncM9pfU77kwe9cY0aAQrBLwwTpr8YUsbRi2xZkhPkNdthTDbbfAuWvBPoXgxLibOsk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1691423806; 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:Reply-To:Sender:Subject:To; bh=wMhdATVX7kyQpflqds6G6PS6S9Q5zZHqGS0Ekxp+U6Y=; b=nHI+sgg2otbM0ru6L0int11CkcewU3rdP/RF/Lco+M+ZaK7l/AUtBWS9gV29j8faJg7wi0Uz0kwkYERVjbqRS0o6flQMCgkrL64rp677UGAqEcTBjrwlhJy0Q1gxXPdnaZgNEZq6JMxmIVHE4UMoKGWsnnIfYJZ4gvbuQDHHA84= 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; dmarc=fail header.from= (p=none dis=none) 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 1691423806909280.3914268860716; Mon, 7 Aug 2023 08:56:46 -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-484-FRKejqnfOEmCDcyrtaPz5g-1; Mon, 07 Aug 2023 11:56:43 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 05B108019CC; Mon, 7 Aug 2023 15:56:41 +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 DE06B140E962; Mon, 7 Aug 2023 15:56:40 +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 589961946A41; Mon, 7 Aug 2023 15:56:25 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 58A551946A6D for ; Mon, 7 Aug 2023 15:56:17 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 38BCA40C2078; Mon, 7 Aug 2023 15:56:12 +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 3206240C2076 for ; Mon, 7 Aug 2023 15:56:12 +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-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 177AA805AF6 for ; Mon, 7 Aug 2023 15:56:12 +0000 (UTC) Received: from mail-b.sr.ht (mail-b.sr.ht [173.195.146.151]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-187-lahIoXGhM0KcoxBJ6QUpSA-1; Mon, 07 Aug 2023 11:56:09 -0400 Received: from git.sr.ht (unknown [173.195.146.142]) by mail-b.sr.ht (Postfix) with ESMTPSA id 4BD4A11EFD1; Mon, 7 Aug 2023 15:56:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1691423806; h=from:from:sender:sender:reply-to: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:list-id:list-help:list-unsubscribe: list-subscribe:list-post; bh=wMhdATVX7kyQpflqds6G6PS6S9Q5zZHqGS0Ekxp+U6Y=; b=XE5HAsJazMBqzxHjtUHQtrjHI7xh3BxWmmY9p0/G7NTCJKCVVjw1cbsa54xGshGrp0zaWH T4xq+zaNyT+XBn6/v3jHT/JenxdWL+/ZMo6Niye/C4P8SEu6DB+rat7Se9PTxo1pF20JJv xcgyDokpoNro6EkUjH+0eZq80PTpWGE= X-MC-Unique: FRKejqnfOEmCDcyrtaPz5g-1 X-Original-To: libvir-list@listman.corp.redhat.com X-MC-Unique: lahIoXGhM0KcoxBJ6QUpSA-1 From: ~hyman Date: Tue, 01 Aug 2023 18:38:15 +0800 Subject: [PATCH Libvirt v2 06/10] qemu_process: Setup dirty limit after launching VM MIME-Version: 1.0 Message-ID: <169142376567.1452.17600824269401067909-6@git.sr.ht> In-Reply-To: <169142376567.1452.17600824269401067909-0@git.sr.ht> To: libvir-list@redhat.com 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 3.1 on 10.11.54.1 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: , Reply-To: ~hyman Cc: Peter Krempa , yong.huang@smartx.com Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: git.sr.ht Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1691423808759100001 From: Hyman Huang(=E9=BB=84=E5=8B=87) The dirty_limit attribute in XML requires setting up the upper limit of dirty page rate once after launching the VM, so add the implementation. Signed-off-by: Hyman Huang(=E9=BB=84=E5=8B=87) --- src/qemu/qemu_process.c | 44 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 0644f80161..47763bbefc 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -6161,6 +6161,46 @@ qemuDomainHasHotpluggableStartupVcpus(virDomainDef *= def) } =20 =20 +static int +qemuProcessSetupDirtyLimit(virDomainObj *vm, + virDomainAsyncJob asyncJob) +{ + qemuDomainObjPrivate *priv =3D vm->privateData; + virDomainDef *def =3D vm->def; + int ret =3D -1; + + /* Dirty limit capability is not present, skip the setup */ + if (!virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_VCPU_DIRTY_LIMIT)) + return 0; + + if (virDomainDefHasDirtyLimitStartupVcpus(def)) { + size_t maxvcpus =3D virDomainDefGetVcpusMax(def); + virDomainVcpuDef *vcpu; + size_t i; + + if (qemuDomainObjEnterMonitorAsync(vm, asyncJob) < 0) + return -1; + + for (i =3D 0; i < maxvcpus; i++) { + vcpu =3D virDomainDefGetVcpu(def, i); + + if (vcpu->dirtyLimitSet && (vcpu->dirty_limit !=3D 0)) { + if ((ret =3D qemuMonitorSetVcpuDirtyLimit(priv->mon, i, vc= pu->dirty_limit)) < 0) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Failed to set dirty page rate limit = of vcpu[%1$zu]"), i); + qemuDomainObjExitMonitor(vm); + return ret; + } + VIR_DEBUG("Set vcpu[%zu] dirty page rate limit %lld", i, v= cpu->dirty_limit); + } + } + qemuDomainObjExitMonitor(vm); + } + + return 0; +} + + static int qemuProcessVcpusSortOrder(const void *a, const void *b) @@ -7839,6 +7879,10 @@ qemuProcessLaunch(virConnectPtr conn, if (qemuProcessUpdateAndVerifyCPU(vm, asyncJob) < 0) goto cleanup; =20 + VIR_DEBUG("Setting Dirty Limit for virtual CPUs"); + if (qemuProcessSetupDirtyLimit(vm, asyncJob) < 0) + goto cleanup; + VIR_DEBUG("Detecting IOThread PIDs"); if (qemuProcessDetectIOThreadPIDs(vm, asyncJob) < 0) goto cleanup; --=20 2.38.5 From nobody Sun May 19 19:10:11 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.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.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=git.sr.ht ARC-Seal: i=1; a=rsa-sha256; t=1691423786; cv=none; d=zohomail.com; s=zohoarc; b=eLxP9H2OjLotwK1P/dKqi4mdFs4n83/nMA7VqCKmVoke/IUzMYZcOIsuXWkB8KvfCMCiOlDPK676/eSBY5kn11pv81LbAvI5GxN5rwFCL+x8vH0E4Y3phPVJXVCOn6hYVbjqKw5o9PZO9SloGyq2+L/0eF7w4IypxQt5s2MSN+U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1691423786; 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:Reply-To:Sender:Subject:To; bh=2AzbjkVhf1utLmIep6aqbIMLeQhr7/n4u4KYVrZZQKc=; b=I5wTn7htDIPUcp9WAvfwf1ck+bFEc6wlMLD6nPPnXG+1EW/IyJ4XpqCcdLTuL/nqoZQkwHQPfuFuRq5SCVzbyqOY9jnMyxLRec5Lku3d2n4WAfvQGID1idToHYqt75IOekuuJXQFAYP8OMAgqtscVqLn1gfl01qkEsndiR3lDBc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1691423786671391.23530249601606; Mon, 7 Aug 2023 08:56:26 -0700 (PDT) Received: from mimecast-mx02.redhat.com (66.187.233.73 [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-651-opoFj5eDNCWaenFkvIev0Q-1; Mon, 07 Aug 2023 11:56:22 -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 7B7533C108E3; Mon, 7 Aug 2023 15:56:19 +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 2D10744104; Mon, 7 Aug 2023 15:56:19 +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 018E3194658D; Mon, 7 Aug 2023 15:56:17 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 67BE41946586 for ; Mon, 7 Aug 2023 15:56:11 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 4C919403174; Mon, 7 Aug 2023 15:56:11 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast10.extmail.prod.ext.rdu2.redhat.com [10.11.55.26]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 44CD840F16E for ; Mon, 7 Aug 2023 15:56:11 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-inbound-delivery-1.mimecast.com [205.139.110.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 288221C05145 for ; Mon, 7 Aug 2023 15:56:11 +0000 (UTC) Received: from mail-b.sr.ht (mail-b.sr.ht [173.195.146.151]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-192-UU5dvS7WP9i9h_WSwOXfGw-1; Mon, 07 Aug 2023 11:56:09 -0400 Received: from git.sr.ht (unknown [173.195.146.142]) by mail-b.sr.ht (Postfix) with ESMTPSA id 8841611F00B; Mon, 7 Aug 2023 15:56:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1691423785; h=from:from:sender:sender:reply-to: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:list-id:list-help:list-unsubscribe: list-subscribe:list-post; bh=2AzbjkVhf1utLmIep6aqbIMLeQhr7/n4u4KYVrZZQKc=; b=Bwwf/iUiiLEoLKxMNR1iLPJ/+lUF0Xw6bsw2kI1WZVQIv4wfZ+Y578W33Hsd1qW2zQlWDr p9v/uDm94OWiSMUIU4Z+hjiiXw+G5KQMMaQNKRPklekIAhzM/0xb5qtScDip+4sDbJNrJn 14VWOO5YoIXMjQ+AvCsuJqYyNwrCAdU= X-MC-Unique: opoFj5eDNCWaenFkvIev0Q-1 X-Original-To: libvir-list@listman.corp.redhat.com X-MC-Unique: UU5dvS7WP9i9h_WSwOXfGw-1 From: ~hyman Date: Mon, 08 Aug 2022 23:41:27 +0800 Subject: [PATCH Libvirt v2 07/10] virsh: Introduce limit-dirty-page-rate api MIME-Version: 1.0 Message-ID: <169142376567.1452.17600824269401067909-7@git.sr.ht> In-Reply-To: <169142376567.1452.17600824269401067909-0@git.sr.ht> To: libvir-list@redhat.com 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 3.1 on 10.11.54.10 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: , Reply-To: ~hyman Cc: Peter Krempa , yong.huang@smartx.com Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: git.sr.ht Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1691423812802100003 From: Hyman Huang(=E9=BB=84=E5=8B=87) Introduce limit-dirty-page-rate virsh api to set or cancel dirty page rate upper limit for virtual CPUs. Usage is below: $ virsh limit-dirty-page-rate --rate \ [--vcpu ] Set the dirty page rate upper limit for the given vcpu specified by the "vcpu"; set for all virtual CPUs if vcpu option is not passed in. Cancel the dirty page rate upper limit if the "rate" option is set to zero. Note that the API requires dirty-ring size configured. Signed-off-by: Hyman Huang(=E9=BB=84=E5=8B=87) --- docs/manpages/virsh.rst | 21 ++++++++ tools/virsh-domain.c | 109 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 130 insertions(+) diff --git a/docs/manpages/virsh.rst b/docs/manpages/virsh.rst index f4e5a0bd62..59eecbcef0 100644 --- a/docs/manpages/virsh.rst +++ b/docs/manpages/virsh.rst @@ -5273,6 +5273,27 @@ use to avoid keeping them open unnecessarily. Best-e= ffort security label restore may be requested by using the *--seclabel-restore* flag. =20 =20 +limit-dirty-page-rate +----------------- + +**Syntax:** + +:: + + limit-dirty-page-rate --rate [--vcpu ] + +Set or cancel a domain's dirty page rate upper limit for the given vcpu sp= ecified +by the ``vcpu``; set for all virtual CPUs if ``vcpu`` if not specified and= cancel +the domain's dirty page rate upper limit if ``rate`` is set to zero. +Set or cancel a domain's dirty page rate upper limit for the given virtual= CPU +specified by ``vcpu``; set for all virtual CPUs if ``vcpu`` is not specifi= ed; +and cancel the domain's dirty page rate upper limit if ``rate`` is set to = zero. + +CPU will be throttled as needed to keep their dirty page rate within the l= imit +if the feature enabled. This could, in some scenes, be used to provide +quality-of-service in the aspect of the memory workload for virtual CPUs. + + NODEDEV COMMANDS =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =20 diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index f8758f18a3..c0b0ef7472 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -13812,6 +13812,109 @@ cmdDomDirtyRateCalc(vshControl *ctl, const vshCmd= *cmd) return true; } =20 +/* + * "limit-dirty-page-rate" command + */ +static const vshCmdInfo info_limit_dirty_page_rate[] =3D { + {.name =3D "help", + .data =3D N_("Set or cancel dirty page rate upper limit") + }, + {.name =3D "desc", + .data =3D N_("Set or cancel dirty page rate upper limit, " + "require dirty-ring size configured") + }, + {.name =3D NULL} +}; + +static const vshCmdOptDef opts_limit_dirty_page_rate[] =3D { + VIRSH_COMMON_OPT_DOMAIN_FULL(0), + {.name =3D "rate", + .type =3D VSH_OT_INT, + .flags =3D VSH_OFLAG_REQ, + .help =3D N_("Upper limit of dirty page rate (MB/s) for " + "virtual CPUs, use 0 to cancel") + }, + {.name =3D "vcpu", + .type =3D VSH_OT_INT, + .help =3D N_("Index of a virtual CPU") + }, + VIRSH_COMMON_OPT_DOMAIN_PERSISTENT, + VIRSH_COMMON_OPT_DOMAIN_CONFIG, + VIRSH_COMMON_OPT_DOMAIN_LIVE, + VIRSH_COMMON_OPT_DOMAIN_CURRENT, + {.name =3D NULL} +}; + +static bool +cmdLimitDirtyPageRate(vshControl *ctl, const vshCmd *cmd) +{ + g_autoptr(virshDomain) dom =3D NULL; + int vcpu_idx =3D -1; + unsigned long long rate =3D 0; + unsigned int flags =3D VIR_DOMAIN_AFFECT_CURRENT; + bool vcpu =3D vshCommandOptBool(cmd, "vcpu"); + bool current =3D vshCommandOptBool(cmd, "current"); + bool config =3D vshCommandOptBool(cmd, "config"); + bool live =3D vshCommandOptBool(cmd, "live"); + + VSH_EXCLUSIVE_OPTIONS_VAR(current, live); + VSH_EXCLUSIVE_OPTIONS_VAR(current, config); + + if (config) + flags |=3D VIR_DOMAIN_AFFECT_CONFIG; + if (live) + flags |=3D VIR_DOMAIN_AFFECT_LIVE; + + if (!(dom =3D virshCommandOptDomain(ctl, cmd, NULL))) + return false; + + if (vshCommandOptULongLong(ctl, cmd, "rate", &rate) < 0) + return false; + + if (vcpu) { + if (vshCommandOptInt(ctl, cmd, "vcpu", &vcpu_idx) < 0) + return false; + + if (vcpu_idx < 0) { + vshError(ctl, "%s", _("Invalid vcpu index, using --vcpu " + "to specify cpu index")); + return false; + } + } + + if (vcpu) { + /* Set the dirty page rate upper limit for the specified + * virtual CPU in the given VM; cancel it if rate is set + * to zero. + */ + if (virDomainSetVcpuDirtyLimit(dom, vcpu_idx, + rate, flags) < 0) + return false; + if (rate =3D=3D 0) + vshPrintExtra(ctl, _("Cancel vcpu[%1$d] dirty page rate upper " + "limit successfully\n"), + vcpu_idx); + else + vshPrintExtra(ctl, _("Set vcpu[%1$d] dirty page rate upper " + "limit %2$lld(MB/s) successfully\n"), + vcpu_idx, rate); + } else { + /* Set all dirty page rate upper limits for virtual CPUs in + * the given VM; cancel it if the rate is set to zero. + */ + if (virDomainSetVcpuDirtyLimit(dom, -1, rate, flags) < 0) + return false; + if (rate =3D=3D 0) + vshPrintExtra(ctl, "%s", _("Cancel dirty page rate limit for " + "all virtual CPUs successfully\n")); + else + vshPrintExtra(ctl, _("Set dirty page rate limit %1$lld(MB/s) " + "for all virtual CPUs successfully\n"), + rate); + } + + return true; +} =20 const vshCmdDef domManagementCmds[] =3D { {.name =3D "attach-device", @@ -14476,5 +14579,11 @@ const vshCmdDef domManagementCmds[] =3D { .info =3D info_dom_fd_associate, .flags =3D 0 }, + {.name =3D "limit-dirty-page-rate", + .handler =3D cmdLimitDirtyPageRate, + .opts =3D opts_limit_dirty_page_rate, + .info =3D info_limit_dirty_page_rate, + .flags =3D 0 + }, {.name =3D NULL} }; --=20 2.38.5 From nobody Sun May 19 19:10:11 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; 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; dmarc=fail(p=none dis=none) header.from=git.sr.ht ARC-Seal: i=1; a=rsa-sha256; t=1691423803; cv=none; d=zohomail.com; s=zohoarc; b=e1SQwCnA3usXu3oyY3gWqktlpgpHuYYXFA7rEA3jFOQV6ode23C/bJBwfLZwCA12zlweWPxOajX920dsJB4VUAimWUYe37FbvOysHg2VXcq9zriuFNqN6Ovy9amSVeEXOSguwND2P4lyUEb+syqOrKx++L7AmVsGOgitYASYUFU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1691423803; 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:Reply-To:Sender:Subject:To; bh=DoMpByojfCx39zHWGO3hjS78PcCSoT+uqht4Q6fNjxw=; b=AidtYXp7mZaZSkzXbhnks3h5UqbM5AKEf5y4cOKpgHqsd2qxrYf+U53upbMA5IVuW0mvxVEs2aqyPRQIW9d2cFlbmDa+87pG+dt/XaBY+BeIOVpqG/8XfTnqQ2rx78mnuukACsiBRnHj/vcl8LDRVFYk+MjsPpcn7met1nU5dgE= 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; dmarc=fail header.from= (p=none dis=none) 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 1691423803480402.67752801009533; Mon, 7 Aug 2023 08:56:43 -0700 (PDT) Received: from mimecast-mx02.redhat.com (66.187.233.73 [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-440-iuzJowauPbGsteuijFG6sg-1; Mon, 07 Aug 2023 11:56:40 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 1A6373C108C7; Mon, 7 Aug 2023 15:56:38 +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 06C4440C2076; Mon, 7 Aug 2023 15:56:38 +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 1827619465A4; Mon, 7 Aug 2023 15:56:25 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 4DF5B1946A51 for ; Mon, 7 Aug 2023 15:56:12 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 3CA44492C14; Mon, 7 Aug 2023 15:56:12 +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 34381492C13 for ; Mon, 7 Aug 2023 15:56:11 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-inbound-delivery-1.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 C2D0C185A78B for ; Mon, 7 Aug 2023 15:56:11 +0000 (UTC) Received: from mail-b.sr.ht (mail-b.sr.ht [173.195.146.151]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-295-jFexH0GkPMOFwSsYfM_rYA-1; Mon, 07 Aug 2023 11:56:09 -0400 Received: from git.sr.ht (unknown [173.195.146.142]) by mail-b.sr.ht (Postfix) with ESMTPSA id C4BDE11F00C; Mon, 7 Aug 2023 15:56:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1691423802; h=from:from:sender:sender:reply-to: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:list-id:list-help:list-unsubscribe: list-subscribe:list-post; bh=DoMpByojfCx39zHWGO3hjS78PcCSoT+uqht4Q6fNjxw=; b=LiHixjQX0DQK3dfzGJCj6iQqp2pjevneue+DO9Gd1Mamtt3WoFJbh2bxXI1/Fw0MxDUabx OnXw5wH0K+5TEqoQC+eHMRAV/w/p57E+H25BPc+u21RN1rPIAcXiahqrTL9yOb3SpFGi1l X54S4mfd4XCTwTR0C1NomWXKonXFGds= X-MC-Unique: iuzJowauPbGsteuijFG6sg-1 X-Original-To: libvir-list@listman.corp.redhat.com X-MC-Unique: jFexH0GkPMOFwSsYfM_rYA-1 From: ~hyman Date: Fri, 12 Aug 2022 23:50:36 +0800 Subject: [PATCH Libvirt v2 08/10] qemu_monitor: Implement qemuMonitorQueryVcpuDirtyLimit MIME-Version: 1.0 Message-ID: <169142376567.1452.17600824269401067909-8@git.sr.ht> In-Reply-To: <169142376567.1452.17600824269401067909-0@git.sr.ht> To: libvir-list@redhat.com 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 3.1 on 10.11.54.9 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: , Reply-To: ~hyman Cc: Peter Krempa , yong.huang@smartx.com Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: git.sr.ht Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1691423805066100001 From: Hyman Huang(=E9=BB=84=E5=8B=87) Implement qemuMonitorQueryVcpuDirtyLimit which query vcpu dirty limit info by calling qmp 'query-vcpu-dirty-limit'. Signed-off-by: Hyman Huang(=E9=BB=84=E5=8B=87) --- src/qemu/qemu_monitor.c | 12 +++++++ src/qemu/qemu_monitor.h | 17 ++++++++++ src/qemu/qemu_monitor_json.c | 64 ++++++++++++++++++++++++++++++++++++ src/qemu/qemu_monitor_json.h | 4 +++ 4 files changed, 97 insertions(+) diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c index 5756b4ff50..14a70404ec 100644 --- a/src/qemu/qemu_monitor.c +++ b/src/qemu/qemu_monitor.c @@ -4514,3 +4514,15 @@ qemuMonitorSetVcpuDirtyLimit(qemuMonitor *mon, =20 return qemuMonitorJSONSetVcpuDirtyLimit(mon, vcpu, rate); } + + +int +qemuMonitorQueryVcpuDirtyLimit(qemuMonitor *mon, + qemuMonitorVcpuDirtyLimitInfo *info) +{ + VIR_DEBUG("info=3D%p", info); + + QEMU_CHECK_MONITOR(mon); + + return qemuMonitorJSONQueryVcpuDirtyLimit(mon, info); +} diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h index 07a05365cf..1828bb202a 100644 --- a/src/qemu/qemu_monitor.h +++ b/src/qemu/qemu_monitor.h @@ -1584,3 +1584,20 @@ int qemuMonitorSetVcpuDirtyLimit(qemuMonitor *mon, int vcpu, unsigned long long rate); + +typedef struct _qemuMonitorVcpuDirtyLimit qemuMonitorVcpuDirtyLimit; +struct _qemuMonitorVcpuDirtyLimit { + int idx; /* virtual cpu index */ + unsigned long long limit; /* virtual cpu dirty page rate limit i= n MB/s */ + unsigned long long current; /* virtual cpu dirty page rate in MB/s= */ +}; + +typedef struct _qemuMonitorVcpuDirtyLimitInfo qemuMonitorVcpuDirtyLimitInf= o; +struct _qemuMonitorVcpuDirtyLimitInfo { + size_t nvcpus; /* number of virtual cpu */ + qemuMonitorVcpuDirtyLimit *limits; /* array of dirty page rate limit= */ +}; + +int +qemuMonitorQueryVcpuDirtyLimit(qemuMonitor *mon, + qemuMonitorVcpuDirtyLimitInfo *info); diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index 6200cf097d..2eff813de1 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -8929,3 +8929,67 @@ qemuMonitorJSONSetVcpuDirtyLimit(qemuMonitor *mon, =20 return 0; } + +static int +qemuMonitorJSONExtractVcpuDirtyLimitInfo(virJSONValue *data, + qemuMonitorVcpuDirtyLimitInfo *in= fo) +{ + size_t nvcpus; + size_t i; + + nvcpus =3D virJSONValueArraySize(data); + info->nvcpus =3D nvcpus; + info->limits =3D g_new0(qemuMonitorVcpuDirtyLimit, nvcpus); + + for (i =3D 0; i < nvcpus; i++) { + virJSONValue *entry =3D virJSONValueArrayGet(data, i); + if (virJSONValueObjectGetNumberInt(entry, "cpu-index", + &info->limits[i].idx) < 0) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("query-vcpu-dirty-limit reply was missing 'cp= u-index' data")); + return -1; + } + + if (virJSONValueObjectGetNumberUlong(entry, "limit-rate", + &info->limits[i].limit) < 0) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("query-vcpu-dirty-limit reply was missing 'li= mit-rate' data")); + return -1; + } + + if (virJSONValueObjectGetNumberUlong(entry, "current-rate", + &info->limits[i].current) < 0)= { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("query-vcpu-dirty-limit reply was missing 'cu= rrent-rate' data")); + return -1; + } + } + + return 0; +} + +int +qemuMonitorJSONQueryVcpuDirtyLimit(qemuMonitor *mon, + qemuMonitorVcpuDirtyLimitInfo *info) +{ + g_autoptr(virJSONValue) cmd =3D NULL; + g_autoptr(virJSONValue) reply =3D NULL; + virJSONValue *data =3D NULL; + + if (!(cmd =3D qemuMonitorJSONMakeCommand("query-vcpu-dirty-limit", NUL= L))) + return -1; + + if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0) + return -1; + + if (qemuMonitorJSONCheckError(cmd, reply) < 0) + return -1; + + if (!(data =3D virJSONValueObjectGetArray(reply, "return"))) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("query-vcpu-dirty-limit reply was missing 'return= ' data")); + return -1; + } + + return qemuMonitorJSONExtractVcpuDirtyLimitInfo(data, info); +} diff --git a/src/qemu/qemu_monitor_json.h b/src/qemu/qemu_monitor_json.h index 89f61b3052..bd8131508b 100644 --- a/src/qemu/qemu_monitor_json.h +++ b/src/qemu/qemu_monitor_json.h @@ -830,3 +830,7 @@ int qemuMonitorJSONSetVcpuDirtyLimit(qemuMonitor *mon, int vcpu, unsigned long long rate); + +int +qemuMonitorJSONQueryVcpuDirtyLimit(qemuMonitor *mon, + qemuMonitorVcpuDirtyLimitInfo *info); --=20 2.38.5 From nobody Sun May 19 19:10:11 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; 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; dmarc=fail(p=none dis=none) header.from=git.sr.ht ARC-Seal: i=1; a=rsa-sha256; t=1691423810; cv=none; d=zohomail.com; s=zohoarc; b=A6IhXIYEOU0nf2FA152uhHyuJa/xuxsRMOXam+csSbngYrAxZNbJRQhuJL6Fs+6elJUXUx7nDsBfYo/XH3askM2aBdBMPpg9Iic7A9BR7A06loM1GudCcBIpfaOfR7ct6xOW3rtn4TJxyFH3jRBD6Kqpd3yIMl5nDJFDmC/0rpc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1691423810; 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:Reply-To:Sender:Subject:To; bh=JnGG/Z4ipKhCPDKVbSqBJ9poiDLqa5mm3XRoTCYXYFM=; b=ShuUtJxYWjUS6YlK1F33T/vsFjsYWadEe87U7jGJ6hsh4T+eGho3maQvj8bcnSREtQtO4Dm8M8vY0u0EzZpkcc6aDnEMC2Kotmpm/gDmxiiI745ysrfBAt+DgHqdnyHFOxZqTrlOn6BSsoxCOriGuHBwLcjl9VkYNdXosJ+2oHY= 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; dmarc=fail header.from= (p=none dis=none) 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 1691423810774480.93123072846277; Mon, 7 Aug 2023 08:56:50 -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-300-XZxNiBRpODCKLP0w71wE3Q-1; Mon, 07 Aug 2023 11:56:45 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 89CB6185A7AE; Mon, 7 Aug 2023 15:56:42 +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 7127C1121315; Mon, 7 Aug 2023 15:56:42 +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 97F601946A63; Mon, 7 Aug 2023 15:56:25 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id C62FC1947203 for ; Mon, 7 Aug 2023 15:56:17 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id A636C1121315; Mon, 7 Aug 2023 15:56:12 +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 9E6AF1121314 for ; Mon, 7 Aug 2023 15:56:12 +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-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 83984101A528 for ; Mon, 7 Aug 2023 15:56:12 +0000 (UTC) Received: from mail-b.sr.ht (mail-b.sr.ht [173.195.146.151]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-403-auYa0qLOO_uMAUdrpfE_WQ-1; Mon, 07 Aug 2023 11:56:09 -0400 Received: from git.sr.ht (unknown [173.195.146.142]) by mail-b.sr.ht (Postfix) with ESMTPSA id 1583B11F00E; Mon, 7 Aug 2023 15:56:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1691423809; h=from:from:sender:sender:reply-to: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:list-id:list-help:list-unsubscribe: list-subscribe:list-post; bh=JnGG/Z4ipKhCPDKVbSqBJ9poiDLqa5mm3XRoTCYXYFM=; b=T1d2ABVKCjEbPwXHqoBHY4s+tlQQjdvwj7bZbV3fw8sEiNPs7JqtvTx2WiHNo59gRd0z2e erwkqFAyHoy1qKHKfOBhTURNlAk3ni1sGVn3PQ1H0B33NE8QQ+5iT6GIfsXw3Y7XVQdN/K Z7YRQuu3eIqe2sAV5JWA2du1PCBD6D4= X-MC-Unique: XZxNiBRpODCKLP0w71wE3Q-1 X-Original-To: libvir-list@listman.corp.redhat.com X-MC-Unique: auYa0qLOO_uMAUdrpfE_WQ-1 From: ~hyman Date: Sun, 06 Aug 2023 16:02:49 +0800 Subject: [PATCH Libvirt v2 09/10] qemu_driver: Extend dirtlimit statistics for domGetStats MIME-Version: 1.0 Message-ID: <169142376567.1452.17600824269401067909-9@git.sr.ht> In-Reply-To: <169142376567.1452.17600824269401067909-0@git.sr.ht> To: libvir-list@redhat.com 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 3.1 on 10.11.54.3 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: , Reply-To: ~hyman Cc: Peter Krempa , yong.huang@smartx.com Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.3 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: git.sr.ht Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1691423811464100001 From: Hyman Huang(=E9=BB=84=E5=8B=87) Extend dirtylimit statistics for domGetStats to display the information of the upper limit of dirty page rate for virtual CPUs. Signed-off-by: Hyman Huang(=E9=BB=84=E5=8B=87) --- include/libvirt/libvirt-domain.h | 1 + src/libvirt-domain.c | 9 ++++++ src/qemu/qemu_driver.c | 50 ++++++++++++++++++++++++++++++++ 3 files changed, 60 insertions(+) diff --git a/include/libvirt/libvirt-domain.h b/include/libvirt/libvirt-dom= ain.h index 3d3c7cdcba..14fc5ff82e 100644 --- a/include/libvirt/libvirt-domain.h +++ b/include/libvirt/libvirt-domain.h @@ -2739,6 +2739,7 @@ typedef enum { VIR_DOMAIN_STATS_MEMORY =3D (1 << 8), /* return domain memory info (Si= nce: 6.0.0) */ VIR_DOMAIN_STATS_DIRTYRATE =3D (1 << 9), /* return domain dirty rate i= nfo (Since: 7.2.0) */ VIR_DOMAIN_STATS_VM =3D (1 << 10), /* return vm info (Since: 8.9.0) */ + VIR_DOMAIN_STATS_DIRTYLIMIT =3D (1 << 11), /* return domain dirty limi= t info (Since: 9.6.0) */ } virDomainStatsTypes; =20 /** diff --git a/src/libvirt-domain.c b/src/libvirt-domain.c index 9a60ac7f67..9117881703 100644 --- a/src/libvirt-domain.c +++ b/src/libvirt-domain.c @@ -12531,6 +12531,15 @@ virConnectGetDomainCapabilities(virConnectPtr conn, * naming or meaning will stay consistent. Changes to existing fields, * however, are expected to be rare. * + * VIR_DOMAIN_STATS_DIRTYLIMIT: + * Return virtual CPU dirty limit information. The typed parameter key= s are in + * this format: + * + * "dirtylimit.vcpu..limit" - The dirty page rate upper limit for= the + * virtual CPU, in MB/s. + * "dirtylimit.vcpu..current" - The dirty page rate for the virtu= al CPU + * currently, in MB/s. + * * 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 9779cd0579..cbeab252a4 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -17679,6 +17679,50 @@ qemuDomainGetStatsVm(virQEMUDriver *driver G_GNUC_= UNUSED, return 0; } =20 + +static int +qemuDomainGetStatsDirtyLimitMon(virDomainObj *vm, + qemuMonitorVcpuDirtyLimitInfo *info) +{ + qemuDomainObjPrivate *priv =3D vm->privateData; + int ret; + + qemuDomainObjEnterMonitor(vm); + ret =3D qemuMonitorQueryVcpuDirtyLimit(priv->mon, info); + qemuDomainObjExitMonitor(vm); + + return ret; +} + + +static int +qemuDomainGetStatsDirtyLimit(virQEMUDriver *driver G_GNUC_UNUSED, + virDomainObj *dom, + virTypedParamList *params, + unsigned int privflags) +{ + qemuMonitorVcpuDirtyLimitInfo info; + size_t i; + + if (!HAVE_JOB(privflags) || !virDomainObjIsActive(dom)) + return 0; + + if (qemuDomainGetStatsDirtyLimitMon(dom, &info) < 0) + return -1; + + for (i =3D 0; i < info.nvcpus; i++) { + virTypedParamListAddULLong(params, info.limits[i].limit, + "dirtylimit.vcpu.%d.limit", + info.limits[i].idx); + virTypedParamListAddULLong(params, info.limits[i].current, + "dirtylimit.vcpu.%d.current", + info.limits[i].idx); + } + + return 0; +} + + typedef int (*qemuDomainGetStatsFunc)(virQEMUDriver *driver, virDomainObj *dom, @@ -17703,6 +17747,11 @@ static virQEMUCapsFlags queryVmRequired[] =3D { QEMU_CAPS_LAST }; =20 +static virQEMUCapsFlags queryDirtyLimitRequired[] =3D { + QEMU_CAPS_VCPU_DIRTY_LIMIT, + QEMU_CAPS_LAST +}; + static struct qemuDomainGetStatsWorker qemuDomainGetStatsWorkers[] =3D { { qemuDomainGetStatsState, VIR_DOMAIN_STATS_STATE, false, NULL }, { qemuDomainGetStatsCpu, VIR_DOMAIN_STATS_CPU_TOTAL, true, NULL }, @@ -17715,6 +17764,7 @@ static struct qemuDomainGetStatsWorker qemuDomainGe= tStatsWorkers[] =3D { { qemuDomainGetStatsMemory, VIR_DOMAIN_STATS_MEMORY, false, NULL }, { qemuDomainGetStatsDirtyRate, VIR_DOMAIN_STATS_DIRTYRATE, true, query= DirtyRateRequired }, { qemuDomainGetStatsVm, VIR_DOMAIN_STATS_VM, true, queryVmRequired }, + { qemuDomainGetStatsDirtyLimit, VIR_DOMAIN_STATS_DIRTYLIMIT, true, que= ryDirtyLimitRequired }, { NULL, 0, false, NULL } }; =20 --=20 2.38.5 From nobody Sun May 19 19:10:11 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.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.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=git.sr.ht ARC-Seal: i=1; a=rsa-sha256; t=1691423798; cv=none; d=zohomail.com; s=zohoarc; b=OnGsiWj5aP/Igd6VaAAMge7TyWnGZaAhWv8z8LrypCU/tMAs1EujXIBoGNlzvQOe7BngzmXMcTl6L4Giwe7JPECzDgSk/MGyy5IVSmYVDLeBRZNCdFJJ9NZQlvrcv1bFhAa+E8DYI+2DB2aY23ggC40DF4Hmxi4a2fKYf68qumE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1691423798; 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:Reply-To:Sender:Subject:To; bh=FpSj/8g0rkLfnJN933uGbDAMz1d7xFMxSM0PAhzcORM=; b=i07udN69Gh08Vl1Xdzx0VPo44kC1DaMRBcsZSfXSOHapwXFbBQS202bV4OnON+dDo0UgNyuU08TXfU19MnQHTupMEzwxSfS71WLK1WUBRDEWF/kRqBiVe5NTkCeYUV+qnf+8om78fKLT2BCDCuomyd6IPJX9okgWeKBCNwekt6w= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1691423798898738.4472835835323; Mon, 7 Aug 2023 08:56:38 -0700 (PDT) Received: from mimecast-mx02.redhat.com (66.187.233.73 [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-665-Hf6eJS-FPLOT--iGcf4yxg-1; Mon, 07 Aug 2023 11:56:34 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 239B31C05145; Mon, 7 Aug 2023 15:56:32 +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 0BF492026D68; Mon, 7 Aug 2023 15:56:32 +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 DB6FA1947208; Mon, 7 Aug 2023 15:56:17 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 9AF3A1946587 for ; Mon, 7 Aug 2023 15:56:14 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 8AA9D40C2077; Mon, 7 Aug 2023 15:56:14 +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 83F4F40C2076 for ; Mon, 7 Aug 2023 15:56:14 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 6ABFC185A7A3 for ; Mon, 7 Aug 2023 15:56:14 +0000 (UTC) Received: from mail-b.sr.ht (mail-b.sr.ht [173.195.146.151]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-358-zyzbZuxLMvCqDcT7zNxbLQ-1; Mon, 07 Aug 2023 11:56:11 -0400 Received: from git.sr.ht (unknown [173.195.146.142]) by mail-b.sr.ht (Postfix) with ESMTPSA id 40F4411F00F; Mon, 7 Aug 2023 15:56:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1691423797; h=from:from:sender:sender:reply-to: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:list-id:list-help:list-unsubscribe: list-subscribe:list-post; bh=FpSj/8g0rkLfnJN933uGbDAMz1d7xFMxSM0PAhzcORM=; b=UPj1n7BOZuD+dJMCJR8A/hCVJQcEFiYOtM0okPL0bs9BYNuMFwOiWM1Gg4KV95Zce+n78N uejQo9I4ROOUlRkZlnCLqtmWEaCcLKoia3Xo2ZMGMO+qeRoXSnaflPduc1uEPD7/lh37i7 OcDf/16V+69Kn9Y/tEV7WUy8TtMgkbg= X-MC-Unique: Hf6eJS-FPLOT--iGcf4yxg-1 X-Original-To: libvir-list@listman.corp.redhat.com X-MC-Unique: zyzbZuxLMvCqDcT7zNxbLQ-1 From: ~hyman Date: Sun, 06 Aug 2023 16:17:14 +0800 Subject: [PATCH Libvirt v2 10/10] virsh: Introduce command 'virsh domstats --dirtylimit' MIME-Version: 1.0 Message-ID: <169142376567.1452.17600824269401067909-10@git.sr.ht> In-Reply-To: <169142376567.1452.17600824269401067909-0@git.sr.ht> To: libvir-list@redhat.com 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 3.1 on 10.11.54.1 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: , Reply-To: ~hyman Cc: Peter Krempa , yong.huang@smartx.com Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: git.sr.ht Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1691423800720100001 From: Hyman Huang(=E9=BB=84=E5=8B=87) Introduce command 'virsh domstats --dirtylimit' for reporting dirty page rate upper limit infomation. The info is listed as follows: Domain: 'vm' dirtylimit.vcpu.0.limit=3D10 dirtylimit.vcpu.0.current=3D16 dirtylimit.vcpu.1.limit=3D10 dirtylimit.vcpu.1.current=3D0 ... Signed-off-by: Hyman Huang(=E9=BB=84=E5=8B=87) --- docs/manpages/virsh.rst | 12 ++++++++++-- tools/virsh-domain-monitor.c | 7 +++++++ 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/docs/manpages/virsh.rst b/docs/manpages/virsh.rst index 59eecbcef0..ac619b7697 100644 --- a/docs/manpages/virsh.rst +++ b/docs/manpages/virsh.rst @@ -2317,7 +2317,7 @@ domstats domstats [--raw] [--enforce] [--backing] [--nowait] [--state] [--cpu-total] [--balloon] [--vcpu] [--interface] [--block] [--perf] [--iothread] [--memory] [--dirtyrate] [--vm] - [[--list-active] [--list-inactive] + [--dirtylimit] [[--list-active] [--list-inactive] [--list-persistent] [--list-transient] [--list-running]y [--list-paused] [--list-shutoff] [--list-other]] | [domain ...] =20 @@ -2336,7 +2336,7 @@ The individual statistics groups are selectable via s= pecific flags. By default all supported statistics groups are returned. Supported statistics groups flags are: *--state*, *--cpu-total*, *--balloon*, *--vcpu*, *--interface*, *--block*, *--perf*, *--iothread*, *--memory*, -*--dirtyrate*, *--vm*. +*--dirtyrate*, *--vm*, *--dirtylimit*. =20 Note that - depending on the hypervisor type and version or the domain sta= te - not all of the following statistics may be returned. @@ -2579,6 +2579,14 @@ not available for statistical purposes. The *--vm* option enables reporting of hypervisor-specific statistics. Nam= ing and meaning of the fields is entirely hypervisor dependent. =20 + +*--dirtylimit* returns: + +* ``dirtylimit.vcpu..limit`` - the upper limit of dirty page rate for= a + virtual CPU in MiB/s +* ``dirtylimit.vcpu..current`` - the dirty page rate for a virtual CPU + currently in MiB/s + The statistics in this group have the following naming scheme: =20 ``vm.$NAME.$TYPE`` diff --git a/tools/virsh-domain-monitor.c b/tools/virsh-domain-monitor.c index 89fdc7a050..efa2609719 100644 --- a/tools/virsh-domain-monitor.c +++ b/tools/virsh-domain-monitor.c @@ -2063,6 +2063,10 @@ static const vshCmdOptDef opts_domstats[] =3D { .type =3D VSH_OT_BOOL, .help =3D N_("report hypervisor-specific statistics"), }, + {.name =3D "dirtylimit", + .type =3D VSH_OT_BOOL, + .help =3D N_("report domain dirty page rate upper limit infomation"), + }, {.name =3D "list-active", .type =3D VSH_OT_BOOL, .help =3D N_("list only active domains"), @@ -2187,6 +2191,9 @@ cmdDomstats(vshControl *ctl, const vshCmd *cmd) if (vshCommandOptBool(cmd, "vm")) stats |=3D VIR_DOMAIN_STATS_VM; =20 + if (vshCommandOptBool(cmd, "dirtylimit")) + stats |=3D VIR_DOMAIN_STATS_DIRTYLIMIT; + if (vshCommandOptBool(cmd, "list-active")) flags |=3D VIR_CONNECT_GET_ALL_DOMAINS_STATS_ACTIVE; =20 --=20 2.38.5