From nobody Sun May 12 22:13:57 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=1693970848; cv=none; d=zohomail.com; s=zohoarc; b=bUnBtZd+DjA3CSJ+9ddNs7EDse3MwR99ZsufAAn55iEhhurPn8QUSHMyCLZrBiXcZ05hLLn6PY+lo2f9C7MIr5dfDyPJlNPAx119qX4pWiba9LUQ9kFKojvw/sSujJgOkIi5SnV1JP37UfYxYjcURCxlsa+M39/YLBgCgElqY98= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1693970848; 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=rWSiAWwY6P/LNLarQfvsfPgINgX2jckNAO6scgNKBWU=; b=Dwy4SNAG+pmCMiKzKBTkpHJ7Orw6ZhqKENTzn1KTEsQsgog/GUXH9OYlcc6HxtXjCvI02JJTkWYEf0L6sCqoGqPhjVJW0E7THE5VWr8WW4C8uKo5MrbeoFGbcLWr01fl4Hka/RSs80yhFruWN1MsnJnXaSqrpYa0T4BFIkcjSnM= 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 1693970848066736.7851232277087; Tue, 5 Sep 2023 20:27:28 -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-358-AQy8sTvuPq6bDGquV_Cp8w-1; Tue, 05 Sep 2023 23:27:24 -0400 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 22C7D805BFB; Wed, 6 Sep 2023 03:27:19 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id A6348493112; Wed, 6 Sep 2023 03:27: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 A383719465B3; Wed, 6 Sep 2023 03:27: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 903C819465B1 for ; Wed, 6 Sep 2023 03:27:16 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 7F45C2026D76; Wed, 6 Sep 2023 03:27:16 +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 773422026D68 for ; Wed, 6 Sep 2023 03:27:16 +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 5B52429DD992 for ; Wed, 6 Sep 2023 03:27:16 +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-304-pijBu3-fP0-H-23rEwevGw-1; Tue, 05 Sep 2023 23:27:12 -0400 Received: from git.sr.ht (unknown [173.195.146.142]) by mail-b.sr.ht (Postfix) with ESMTPSA id 789C511F0C5; Wed, 6 Sep 2023 03:27:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1693970846; 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=rWSiAWwY6P/LNLarQfvsfPgINgX2jckNAO6scgNKBWU=; b=C+TRiVcC+KPmG5g2tX9VjtD163pY8TMiqqRDcHPYRs160ADJboUId8A0sVH80Rd4KbYPTa JVYwq3g5T5Uj0Yl2Rgj2GnC1ItwS6HS7T0gQ89vZVmu1b7LjTOIowGpj3rFIGMbGOBGaB0 wZb9lY9vPKZ96OUiGzyWFv0FGZf/ExE= X-MC-Unique: AQy8sTvuPq6bDGquV_Cp8w-1 X-Original-To: libvir-list@listman.corp.redhat.com X-MC-Unique: pijBu3-fP0-H-23rEwevGw-1 From: ~hyman Date: Tue, 02 Aug 2022 22:49:24 +0800 Subject: [PATCH Libvirt v3 01/10] qemu_capabilities: Introduce QEMU_CAPS_VCPU_DIRTY_LIMIT capability MIME-Version: 1.0 Message-ID: <169397083100.4628.15196043252714532301-1@git.sr.ht> In-Reply-To: <169397083100.4628.15196043252714532301-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: Martin Kletzander , 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.9 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: 1693970850427100001 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 ea4e248349..cf3f7efc7a 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 @@ -1220,6 +1221,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 ba289ba6b9..623acc9fe7 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 310b8f9d75..3e386357b1 100644 --- a/tests/qemucapabilitiesdata/caps_7.1.0_ppc64.xml +++ b/tests/qemucapabilitiesdata/caps_7.1.0_ppc64.xml @@ -157,6 +157,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 07e8c57f27..dc7cdd2877 100644 --- a/tests/qemucapabilitiesdata/caps_7.1.0_x86_64.xml +++ b/tests/qemucapabilitiesdata/caps_7.1.0_x86_64.xml @@ -194,6 +194,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 b8d4d4888c..4484a56e0a 100644 --- a/tests/qemucapabilitiesdata/caps_7.2.0_ppc.xml +++ b/tests/qemucapabilitiesdata/caps_7.2.0_ppc.xml @@ -152,6 +152,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 928270d287..f3fe6076ef 100644 --- a/tests/qemucapabilitiesdata/caps_7.2.0_x86_64+hvf.xml +++ b/tests/qemucapabilitiesdata/caps_7.2.0_x86_64+hvf.xml @@ -198,6 +198,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 a889c1b034..7dc2a0ddd7 100644 --- a/tests/qemucapabilitiesdata/caps_7.2.0_x86_64.xml +++ b/tests/qemucapabilitiesdata/caps_7.2.0_x86_64.xml @@ -198,6 +198,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 4aeb210ca7..49075a9194 100644 --- a/tests/qemucapabilitiesdata/caps_8.0.0_riscv64.xml +++ b/tests/qemucapabilitiesdata/caps_8.0.0_riscv64.xml @@ -139,6 +139,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 6d105e78a9..6cae74ac72 100644 --- a/tests/qemucapabilitiesdata/caps_8.0.0_x86_64.xml +++ b/tests/qemucapabilitiesdata/caps_8.0.0_x86_64.xml @@ -202,6 +202,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 a7519021e2..b8774781eb 100644 --- a/tests/qemucapabilitiesdata/caps_8.1.0_s390x.xml +++ b/tests/qemucapabilitiesdata/caps_8.1.0_s390x.xml @@ -113,6 +113,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 adcf594138..9cd5d2cea7 100644 --- a/tests/qemucapabilitiesdata/caps_8.1.0_x86_64.xml +++ b/tests/qemucapabilitiesdata/caps_8.1.0_x86_64.xml @@ -203,6 +203,7 @@ + 8001000 43100245 v8.1.0 --=20 2.38.5 From nobody Sun May 12 22:13:57 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=1693970849; cv=none; d=zohomail.com; s=zohoarc; b=DoxbBSGC1NvjbGPIbM3bJSEtQ5sbu0FIP9JshOAdu1kQbwhnORmuOBWW7BrHmhnu4VoKaBiUp0Yx+fZb4nYKy/PWirFCKLHk+iDfyPC4o3iaYXB+LY6/Szj2wLpdHm3iMvv9Im129ZK91EHZVjPg8+fToQScH9t5IdBg9Qrz/Ks= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1693970849; 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=iv6EXI2shWEcj8QC3zhMpinn+QfBl2ckw+z6pVMq7dk=; b=F+CDN+rm8q7gQiWLMn9RCeDa8G5p4l07i7IWFl6wxu7dcCFz6AYOt6vAlKuw3iJJOOnqNOtpmFS2CN9HEp1/0Z0kaebHCptLCDBiDlY3hBnzblAYXcffeXeC7X7rUQ9p6co6jfWhp4Ld1RFle98ozgxQ2UNZSQPFAjZ1tUbHEXc= 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 1693970849183131.79093283919588; Tue, 5 Sep 2023 20:27:29 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [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-631-2Da1iwzcMqGwxoRuCMlq5A-1; Tue, 05 Sep 2023 23:27:23 -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 888BC3C0E238; Wed, 6 Sep 2023 03:27:19 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 752451121314; Wed, 6 Sep 2023 03:27: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 DCB9F19472A4; Wed, 6 Sep 2023 03:27:17 +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 9947D1946A42 for ; Wed, 6 Sep 2023 03:27:16 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 78640C03292; Wed, 6 Sep 2023 03:27:16 +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 70AC1C15BB8 for ; Wed, 6 Sep 2023 03:27:16 +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 4635D91BC28 for ; Wed, 6 Sep 2023 03:27:16 +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-86-injBSwR_M5KEfsYluT-2GA-1; Tue, 05 Sep 2023 23:27:12 -0400 Received: from git.sr.ht (unknown [173.195.146.142]) by mail-b.sr.ht (Postfix) with ESMTPSA id A3A4511F0CA; Wed, 6 Sep 2023 03:27:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1693970848; 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=iv6EXI2shWEcj8QC3zhMpinn+QfBl2ckw+z6pVMq7dk=; b=T/cZHkcmjMOhOv05GKFoTydZ6h/uQeNpfFPIMW8jZzrDGt2+DLepy5H+oKirMJGLkLICMj 7XWi5oB/Wnu2K7H2XAhdEcWirtGKGkRHK+EVVVjfWPNoTf0OZalAGZaOOWzc5l04d2wLP2 v3u40rnhKNF5EVRjF2lcya7hwretHV4= X-MC-Unique: 2Da1iwzcMqGwxoRuCMlq5A-1 X-Original-To: libvir-list@listman.corp.redhat.com X-MC-Unique: injBSwR_M5KEfsYluT-2GA-1 From: ~hyman Date: Tue, 01 Aug 2023 17:31:12 +0800 Subject: [PATCH Libvirt v3 02/10] conf: Introduce XML for dirty limit configuration MIME-Version: 1.0 Message-ID: <169397083100.4628.15196043252714532301-2@git.sr.ht> In-Reply-To: <169397083100.4628.15196043252714532301-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: Martin Kletzander , 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: 1693970850438100002 From: Hyman Huang(=E9=BB=84=E5=8B=87) The upper limit (megabyte/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 bc469e5f9f..337b7ec9cc 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.7.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 2c8727de54..aff0dba84a 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -17088,6 +17088,7 @@ virDomainVcpuParse(virDomainDef *def, virDomainXMLOption *xmlopt) { int n; + int rv; xmlNodePtr vcpuNode; size_t i; unsigned int maxvcpus; @@ -17175,6 +17176,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) @@ -21219,6 +21227,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; @@ -26822,6 +26844,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 ca195a52d2..0bca85bec6 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -2812,6 +2812,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 b050f21edb..2df9db3467 100644 --- a/src/conf/domain_validate.c +++ b/src/conf/domain_validate.c @@ -1785,6 +1785,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, @@ -1841,6 +1871,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 2f9ba31c0a..2e6a744eb4 100644 --- a/src/conf/schemas/domaincommon.rng +++ b/src/conf/schemas/domaincommon.rng @@ -844,6 +844,11 @@ + + + + + --=20 2.38.5 From nobody Sun May 12 22:13:57 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=1693970848; cv=none; d=zohomail.com; s=zohoarc; b=XvYT+u2tiLKsnS/fkUKT4lFy3Gw630V3JvyG5ZIGmocwiHDSMjifflhC5bUkJGEnfJpm6bKw06/4Lk/eHe5GGTVd7pAtkt3V90xQYGsv6CWQnQO/855bt6z4rhmvhzELebc4FZGWKwjSXW3NQmvLEJ++x/hjmuhNKIzA+ccRtgY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1693970848; 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=wdY/FoE7P8zyJ1qwbnp0YY87oGcdmG5fnbRC1FuV2zc=; b=eE+RbhTk4LPiyFH749XCGbWyrfuTUH+VkMxRfkEnG1G1DQvDKHXLbHKELWg1UH0ML0xPjJ9BN+bi+Jze9FLErS2QorKsBl0yYp0M/XLk5d5M5djT/8sWLrhemiD1Bb10bXnS6LlruWTu0kJDK6TFArPSQ+sG4P/eVYdFY2Z+MHE= 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 1693970848138827.3595699991182; Tue, 5 Sep 2023 20:27:28 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [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-627-VyyqIcvDPjCGNFMkNhYljg-1; Tue, 05 Sep 2023 23:27:24 -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 23ECC1C0725C; Wed, 6 Sep 2023 03:27:19 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0133F405D476; Wed, 6 Sep 2023 03:27: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 D49441946A52; Wed, 6 Sep 2023 03:27:16 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 48C9E1946589 for ; Wed, 6 Sep 2023 03:27:15 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 29D8AC124A; Wed, 6 Sep 2023 03:27:15 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast05.extmail.prod.ext.rdu2.redhat.com [10.11.55.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 228416B5AA for ; Wed, 6 Sep 2023 03:27:15 +0000 (UTC) Received: from us-smtp-inbound-delivery-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 0518B81B14B for ; Wed, 6 Sep 2023 03:27:15 +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-54-mrdsuuQ4P32HKVYIAtbkjA-1; Tue, 05 Sep 2023 23:27:12 -0400 Received: from git.sr.ht (unknown [173.195.146.142]) by mail-b.sr.ht (Postfix) with ESMTPSA id DE55511F0D8; Wed, 6 Sep 2023 03:27:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1693970847; 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=wdY/FoE7P8zyJ1qwbnp0YY87oGcdmG5fnbRC1FuV2zc=; b=LbfuA0gVM505+qJQ+o6/6mQsWxNks6QCrGqfZL24skhd0wmwVIRnC9hGiDsLETGye1SIb9 coxkCauQINUC2hVA1PcqryCQMn/NqRgNdQyM/jNlbZ1cpLN4ibSq0taED/tPTm6IMCLc1O fW2yrz5U9a9L+ptldoh8soSWsnmN1SE= X-MC-Unique: VyyqIcvDPjCGNFMkNhYljg-1 X-Original-To: libvir-list@listman.corp.redhat.com X-MC-Unique: mrdsuuQ4P32HKVYIAtbkjA-1 From: ~hyman Date: Tue, 02 Aug 2022 22:13:40 +0800 Subject: [PATCH Libvirt v3 03/10] libvirt: Add virDomainSetVcpuDirtyLimit API MIME-Version: 1.0 Message-ID: <169397083100.4628.15196043252714532301-3@git.sr.ht> In-Reply-To: <169397083100.4628.15196043252714532301-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.5 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: Martin Kletzander , 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: 1693970850438100003 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. Since it just throttles the virtual CPU, which dirties memory, read processes in the guest OS aren't penalized. The feature therefor 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 | 1 + src/remote/remote_driver.c | 1 + src/remote/remote_protocol.x | 18 +++++++++- src/remote_protocol-structs | 7 ++++ 7 files changed, 96 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 6616294fc1..5b505cc519 100644 --- a/src/libvirt-domain.c +++ b/src/libvirt-domain.c @@ -14041,3 +14041,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.7.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 bd1e916d2a..602494935d 100644 --- a/src/libvirt_public.syms +++ b/src/libvirt_public.syms @@ -934,6 +934,7 @@ LIBVIRT_9.0.0 { =20 LIBVIRT_9.7.0 { global: + virDomainSetVcpuDirtyLimit; virNetworkGetMetadata; virNetworkSetMetadata; } LIBVIRT_9.0.0; diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c index 0b925f8edc..15d023154b 100644 --- a/src/remote/remote_driver.c +++ b/src/remote/remote_driver.c @@ -8110,6 +8110,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.7.0 */ }; =20 static virNetworkDriver network_driver =3D { diff --git a/src/remote/remote_protocol.x b/src/remote/remote_protocol.x index 7ff059e393..72b2684912 100644 --- a/src/remote/remote_protocol.x +++ b/src/remote/remote_protocol.x @@ -3955,6 +3955,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.= */ @@ -7008,5 +7016,13 @@ enum remote_procedure { * @generate: both * @acl: network:read */ - REMOTE_PROC_NETWORK_GET_METADATA =3D 445 + REMOTE_PROC_NETWORK_GET_METADATA =3D 445, + + /** + * @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 446 }; diff --git a/src/remote_protocol-structs b/src/remote_protocol-structs index c07e0af1e6..715a121f36 100644 --- a/src/remote_protocol-structs +++ b/src/remote_protocol-structs @@ -3290,6 +3290,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, @@ -3736,4 +3742,5 @@ enum remote_procedure { REMOTE_PROC_DOMAIN_FD_ASSOCIATE =3D 443, REMOTE_PROC_NETWORK_SET_METADATA =3D 444, REMOTE_PROC_NETWORK_GET_METADATA =3D 445, + REMOTE_PROC_DOMAIN_SET_VCPU_DIRTY_LIMIT =3D 446, }; --=20 2.38.5 From nobody Sun May 12 22:13:57 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=1693970855; cv=none; d=zohomail.com; s=zohoarc; b=n2XhFFdTLsCka8uCTZo3okSRLx5PZnpeWYhTVbI5v8BzcI+W45MajVOsHinkMOHmtunLBiMUiQZDLhsljjhrA9X4N0SP4OOsZUiM16TiOnbklI9SOhFrBGAx4FNx1hLhcHhlNj6jepgaPt8qlv4OMHKlhIdsoBIdEhU34wcJrgg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1693970855; 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=EU3Hdrus5ZmNaEAvmc3i9qjpqwEzzup5i8GRfTzI1rY=; b=WE0KC7+hYj+qvzuXzJ7zaupi3j3XOVY/bFF63rC2Xubk2iOFSffXygzsyLughSzGu0Oa7kxjzrgxZASXJy31bwNwWDgyZtIK+ZBGFtiZA0JFNR99f47iolc8F5OHAjmtmG1oU/w6ZPrHzvsS6Io+ct9KN1LBLeadEQBY26aIRis= 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 169397085582321.26786716606705; Tue, 5 Sep 2023 20:27:35 -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-170-p9lxIMKMN5q_OfDl9gzilQ-1; Tue, 05 Sep 2023 23:27:28 -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 AA6148164FE; Wed, 6 Sep 2023 03:27:21 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8B2712026D2B; Wed, 6 Sep 2023 03:27:21 +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 A5C131946A45; Wed, 6 Sep 2023 03:27:20 +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 031C71946A70 for ; Wed, 6 Sep 2023 03:27:17 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id E53B1140E966; Wed, 6 Sep 2023 03:27:16 +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 DDA4F140E965 for ; Wed, 6 Sep 2023 03:27:16 +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 BE0C591BC21 for ; Wed, 6 Sep 2023 03:27:16 +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-412-RVa4P0_fPr-S8c1vM4xWcA-1; Tue, 05 Sep 2023 23:27:13 -0400 Received: from git.sr.ht (unknown [173.195.146.142]) by mail-b.sr.ht (Postfix) with ESMTPSA id 10EAC11F0D9; Wed, 6 Sep 2023 03:27:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1693970854; 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=EU3Hdrus5ZmNaEAvmc3i9qjpqwEzzup5i8GRfTzI1rY=; b=gxCm01/ds5NNHEHimIjd5KzD3Kc6PuOwabLxPGRbA1l69T7oLPVJA2Wu1923brvKJRJUMt TKAr1pZnkylSl+QXuU70yPTGtEToHDQtvGv3wptzxIHkqI8+7lXO2Uraf21Gh0SWrMzWsZ /Py1x0ghpyIndBiH5ZExM2lKhDrxQ4A= X-MC-Unique: p9lxIMKMN5q_OfDl9gzilQ-1 X-Original-To: libvir-list@listman.corp.redhat.com X-MC-Unique: RVa4P0_fPr-S8c1vM4xWcA-1 From: ~hyman Date: Wed, 03 Aug 2022 00:27:47 +0800 Subject: [PATCH Libvirt v3 04/10] qemu_driver: Implement qemuDomainSetVcpuDirtyLimit MIME-Version: 1.0 Message-ID: <169397083100.4628.15196043252714532301-4@git.sr.ht> In-Reply-To: <169397083100.4628.15196043252714532301-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: Martin Kletzander , 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: 1693970856356100002 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 0d4da937b0..64d97c0fba 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -19876,6 +19876,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, @@ -20126,6 +20256,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.7.0 */ }; =20 =20 diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c index 7053539c7d..90bc0e62c9 100644 --- a/src/qemu/qemu_monitor.c +++ b/src/qemu/qemu_monitor.c @@ -4500,3 +4500,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 5b9edadcf7..c8f6069566 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -8852,3 +8852,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 12 22:13:57 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=1693970854; cv=none; d=zohomail.com; s=zohoarc; b=EWQz37DaWG4AIw40fMeAGM8prPVQltodd83lRaTWJwkcuzypXWCUon4BqgwJbuKrJRD0Hm3WdzPePpGMiuHQMaoDbO/KsN6THNyusLJkVZygBNhy+OwDr0pVM8ZCZm6wFoB9D0cRMVjGB0OIiwv/VGmjeVdv5ghlC9dnoGDKyJs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1693970854; 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=XGSIHUFl0899Mf7rgWyXPC+QX0ZkFz587Xis4vwsuIM=; b=WDwA2YYtLtlJNedv2y/GaUCIP5POxn95QcGhGKTWuEr0SDLfaX8hj83B8xKUdGP0j6hDe1kQ4prRVcnnca7Tfk4DzaVnjoHbIrQTMVYD6I5quy2iMGAzs/ioDazwgOuig6GYCfcEM61asvLXQzXos6XxTVsTqVRJZ6bNES4PTTs= 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 1693970854110476.385415409865; Tue, 5 Sep 2023 20:27:34 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [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-609-EvmQ3u7qPryyxlfYqG9P3A-1; Tue, 05 Sep 2023 23:27: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 63174280FEC2; Wed, 6 Sep 2023 03:27:20 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4F18EC4FA21; Wed, 6 Sep 2023 03:27:20 +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 2B52419465B3; Wed, 6 Sep 2023 03:27:19 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 42A98194658C for ; Wed, 6 Sep 2023 03:27:18 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 22C29C124A; Wed, 6 Sep 2023 03:27:18 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast01.extmail.prod.ext.rdu2.redhat.com [10.11.55.17]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 1B2731182EE for ; Wed, 6 Sep 2023 03:27:18 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id E66D28164F7 for ; Wed, 6 Sep 2023 03:27:17 +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-V_etZAoqPKSrnRW8s_pO2Q-1; Tue, 05 Sep 2023 23:27:14 -0400 Received: from git.sr.ht (unknown [173.195.146.142]) by mail-b.sr.ht (Postfix) with ESMTPSA id 377B011F0E0; Wed, 6 Sep 2023 03:27:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1693970853; 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=XGSIHUFl0899Mf7rgWyXPC+QX0ZkFz587Xis4vwsuIM=; b=QYnKyDDBtsFJjtV/7HFw+2WquxJtu3aC2O6jw9DHYVL+xc9fOz5gyQO2bVArTegiJ9DqfN AdVCpEWe4bCAbZfnADTVFVOKPov4G0w00C1ibxioFwXK89Rch8sK7F02E9r2COZ4azJl5M dBUn4EmIc5+bHmnbQ2jgCTxZ3ri1zn0= X-MC-Unique: EvmQ3u7qPryyxlfYqG9P3A-1 X-Original-To: libvir-list@listman.corp.redhat.com X-MC-Unique: V_etZAoqPKSrnRW8s_pO2Q-1 From: ~hyman Date: Fri, 04 Aug 2023 10:03:06 +0800 Subject: [PATCH Libvirt v3 05/10] domain_validate: Export virDomainDefHasDirtyLimitStartupVcpus symbol MIME-Version: 1.0 Message-ID: <169397083100.4628.15196043252714532301-5@git.sr.ht> In-Reply-To: <169397083100.4628.15196043252714532301-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.5 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: Martin Kletzander , 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: 1693970856263100001 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 2df9db3467..04c18462da 100644 --- a/src/conf/domain_validate.c +++ b/src/conf/domain_validate.c @@ -1785,7 +1785,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 f8cda2f773..32656dea7a 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 12 22:13:57 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=1693970851; cv=none; d=zohomail.com; s=zohoarc; b=FwDuLetUWbdSCUsB/+4eQejv/RJ1i2YsPB2clvdRgfWigsKVlB0ucrOGFCUIFVnelYB/gfFsGOXnh8Fg6M02U7SsWgYms1SoycQko9Nvsn4tr5F69CX7K2ELZDmfewvuSKhHyIaZRPigp6GHjZ87JPBHOsl7ugr4zcZDCEtlMQo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1693970851; 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=2BcJkJgEXqF9x+xSPxaDqBzq/WZOUGEh/WkTTECN85E=; b=BIRvs8HPCcpYReRxeseT0hUE63A5k93Nxw7AulslJFhHhWrUU8mN5v/4ycZ1r+1FP3uNXn7SAhJ75vKKHKZB0pD2NM59bw4s+pMFmUMYCl+c23pTqpUwYPl22uO2NdAAN9y4N9KcGc+3WwyDbZGqI00r9RHNVf/Km8CsKb65YQ0= 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 1693970851958344.24156321742475; Tue, 5 Sep 2023 20:27:31 -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-622-buH21jmjOJGcr4WKGcTs0w-1; Tue, 05 Sep 2023 23:27:26 -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 332FA91BC43; Wed, 6 Sep 2023 03:27:23 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1CF03C03296; Wed, 6 Sep 2023 03:27:23 +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 A79C01946595; Wed, 6 Sep 2023 03:27:22 +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 6991719472BD for ; Wed, 6 Sep 2023 03:27:19 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 4F7C3140E968; Wed, 6 Sep 2023 03:27:19 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast04.extmail.prod.ext.rdu2.redhat.com [10.11.55.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 2D38A140E966 for ; Wed, 6 Sep 2023 03:27:19 +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 13B651040892 for ; Wed, 6 Sep 2023 03:27:19 +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-416-Be5qvkgNOsqygrGNSTTetw-1; Tue, 05 Sep 2023 23:27:14 -0400 Received: from git.sr.ht (unknown [173.195.146.142]) by mail-b.sr.ht (Postfix) with ESMTPSA id 6045D11F0E2; Wed, 6 Sep 2023 03:27:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1693970851; 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=2BcJkJgEXqF9x+xSPxaDqBzq/WZOUGEh/WkTTECN85E=; b=HvkySyts4QnQieXYW09PMcMWWq9N70a1qpkM9qDpb3TE5nxweno15jJH2/qKWCvpCGv/Gg 3oxpSz2Z86yoyOh62h984HzDVpPBDaEmH7tTSLWJ5KVhSWdkyY/o7bo1kBidPIS0BrA0Ex IsuC2RhkmSnzv/IjDLY80I8Ri1nRZMg= X-MC-Unique: buH21jmjOJGcr4WKGcTs0w-1 X-Original-To: libvir-list@listman.corp.redhat.com X-MC-Unique: Be5qvkgNOsqygrGNSTTetw-1 From: ~hyman Date: Tue, 01 Aug 2023 18:38:15 +0800 Subject: [PATCH Libvirt v3 06/10] qemu_process: Setup dirty limit after launching VM MIME-Version: 1.0 Message-ID: <169397083100.4628.15196043252714532301-6@git.sr.ht> In-Reply-To: <169397083100.4628.15196043252714532301-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: Martin Kletzander , 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: 1693970852342100010 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 7a1cdb0302..560051bcaf 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -6156,6 +6156,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) @@ -7833,6 +7873,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 12 22:13:57 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=1693970850; cv=none; d=zohomail.com; s=zohoarc; b=d+p3QwZMgyT4LhIeV6dfOFJaZV5/vA0ElIQMyDtEY8yfuREfI07gnacSJEMsrnLQ9sMDLFLVHsZFcbz88wRIRoprdwyK6EaQ4Nd2ObtZIpG6XBZnsme9WNquRM69zKggccstLEHLtIBloNMT0hfQJD8OYrz2/clecWpzLd4t+ko= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1693970850; 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=nvQOVFho/+F+elliPiAnbwt3GFVgO42cMtNnIQWiiVw=; b=imCe/Pt/KxxwypJU7jrqn1Q2bMSeYihgOjtgAuWA6xEQa+Dk5bDBL/QGcz9PINt2kw4q9SHEFlyva9l5wFWwMJylBnUiCiN4hK4D02rQH7GdEXBVbaUL/hiMROYfGu2MImnBdYBrx2FU5cDbCHTp0K7AsVWEb03fzROj7QsPsfs= 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 1693970850731211.71764180245407; Tue, 5 Sep 2023 20:27:30 -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-350-m6bQAftEM9K2ILGPfMBBJQ-1; Tue, 05 Sep 2023 23:27:27 -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 27A541040889; Wed, 6 Sep 2023 03:27:22 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0F9ED2026D33; Wed, 6 Sep 2023 03:27:22 +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 DF2741946A6F; Wed, 6 Sep 2023 03:27:20 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 4C70919472B5 for ; Wed, 6 Sep 2023 03:27:18 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 2CAA1412F2CD; Wed, 6 Sep 2023 03:27:18 +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 25D83412F2D6 for ; Wed, 6 Sep 2023 03:27:18 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id F2FE218DA730 for ; Wed, 6 Sep 2023 03:27:17 +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-70-jM6wMXv0O_G9YluNZOqNGw-1; Tue, 05 Sep 2023 23:27:15 -0400 Received: from git.sr.ht (unknown [173.195.146.142]) by mail-b.sr.ht (Postfix) with ESMTPSA id 8B24C11F0E4; Wed, 6 Sep 2023 03:27:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1693970849; 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=nvQOVFho/+F+elliPiAnbwt3GFVgO42cMtNnIQWiiVw=; b=IwFxn/6vGcxbMmLfXdFGR0EMIWL1vzfyBXS5ZYggjSCNAOWdCb74u+2KETB2mz5d4A+BoE LCU+X7ArB2xnNLrQhyNSrOZ6mls+8JAgM4H3sB+Oh6iFLMDHyl6RJ+3CO6vaYRLxoIIRFe yGQBFjKM6Vf0cewHJihhmq7yagaB7Ds= X-MC-Unique: m6bQAftEM9K2ILGPfMBBJQ-1 X-Original-To: libvir-list@listman.corp.redhat.com X-MC-Unique: jM6wMXv0O_G9YluNZOqNGw-1 From: ~hyman Date: Mon, 08 Aug 2022 23:41:27 +0800 Subject: [PATCH Libvirt v3 07/10] virsh: Introduce limit-dirty-page-rate api MIME-Version: 1.0 Message-ID: <169397083100.4628.15196043252714532301-7@git.sr.ht> In-Reply-To: <169397083100.4628.15196043252714532301-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.2 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: Martin Kletzander , 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: 1693970852556100014 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 ] [--config] [--live] [--current] 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 | 26 ++++++++++ tools/virsh-domain.c | 109 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 135 insertions(+) diff --git a/docs/manpages/virsh.rst b/docs/manpages/virsh.rst index 91e1d5de37..33a8f3b9fe 100644 --- a/docs/manpages/virsh.rst +++ b/docs/manpages/virsh.rst @@ -5273,6 +5273,32 @@ 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 ] + [--config] [--live] [--current] + +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. + +Virtual CPUs will be throttled as needed to keep their dirty page rate wit= hin +the limit if the feature enabled. This could, in some scenes, be used to p= rovide +quality-of-service in the aspect of the memory workload for virtual CPUs. + +If *--live* is specified, affect a running domain. +If *--config* is specified, affect the next startup of a persistent domain. +If *--current* is specified, it is equivalent to either *--live* or +*--config*, depending on the current state of the domain. +Both *--live* and *--config* flags may be given, but *--current* is +exclusive. Not specifying any flag is the same as specifying *--current*. + + 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 7abafe2ba3..ae51d9fdfb 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -13732,6 +13732,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 in= dex")); + 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 al= l virtual CPUs successfully\n"), + rate); + } + + return true; +} =20 const vshCmdDef domManagementCmds[] =3D { {.name =3D "attach-device", @@ -14396,5 +14499,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 12 22:13:57 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=1693970851; cv=none; d=zohomail.com; s=zohoarc; b=GY03cojE1k8QqEXuZKbsprHdxujAl51VVTMB89MVLp9oV6BvnfHzO2ODbOr+l9/gU9guZcIoMBbMO4ge2fR2UCGcfhuET13bNV21YkoGXqHhG10aASVAo0/wOdRNYfo6d4UkkBIsPP0//56eB0dqZoFWn1GVOup/+zaRED/GF24= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1693970851; 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=FMV0EfFHBCDT7l71CTWFBOXiDk3OGzYGKl1L9YNXB7Q=; b=V/P+M4+bWAPpIXE79gWuoAoxxZwWEgj09HzWcIUJ9vCwJzWJxoh6RSMA29ch1kinRcCRQsUq2VadoZAcbOFoOv7EttFYkIllfUAPyCmSe4Zq80iWDbq1+W/+7FZSALm5EJpT9S6vaOsHFwnwRAsIlRpxoNUv66V4RKJ/XIelgNo= 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 1693970851438534.5520647809178; Tue, 5 Sep 2023 20:27:31 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [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-609-wT65BnOoMRO8smwX0mYHIA-1; Tue, 05 Sep 2023 23:27:25 -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 666913801BEA; Wed, 6 Sep 2023 03:27:20 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4F73E2026D33; Wed, 6 Sep 2023 03:27:20 +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 2782A194658C; Wed, 6 Sep 2023 03:27:19 +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 25C671946A70 for ; Wed, 6 Sep 2023 03:27:17 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id F1084140E967; Wed, 6 Sep 2023 03:27:16 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast01.extmail.prod.ext.rdu2.redhat.com [10.11.55.17]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E84C6140E965 for ; Wed, 6 Sep 2023 03:27:16 +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 CCB9F800C78 for ; Wed, 6 Sep 2023 03:27:16 +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-635-6mlEfQRrOMaEmMjw3bkk7w-1; Tue, 05 Sep 2023 23:27:15 -0400 Received: from git.sr.ht (unknown [173.195.146.142]) by mail-b.sr.ht (Postfix) with ESMTPSA id B3EAF11F0E5; Wed, 6 Sep 2023 03:27:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1693970849; 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=FMV0EfFHBCDT7l71CTWFBOXiDk3OGzYGKl1L9YNXB7Q=; b=bJ4mRDD27vE42x6NYtRn4bHRf2v7Ri5vevTZn69e+NfNAKNNCBETray+YxQ8oshIz+ePrn 4OqwiNjOsCeJQeANq/WMBfVzJhWrlE4oeHfv9/+9alXfi5FtKJxHzDg/RmSSQJt0S3x9AZ FFVK3KUja2qzChVuxp5tnsJgKdR9ktw= X-MC-Unique: wT65BnOoMRO8smwX0mYHIA-1 X-Original-To: libvir-list@listman.corp.redhat.com X-MC-Unique: 6mlEfQRrOMaEmMjw3bkk7w-1 From: ~hyman Date: Fri, 12 Aug 2022 23:50:36 +0800 Subject: [PATCH Libvirt v3 08/10] qemu_monitor: Implement qemuMonitorQueryVcpuDirtyLimit MIME-Version: 1.0 Message-ID: <169397083100.4628.15196043252714532301-8@git.sr.ht> In-Reply-To: <169397083100.4628.15196043252714532301-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: Martin Kletzander , 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: 1693970852251100007 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 90bc0e62c9..9b18b4e46b 100644 --- a/src/qemu/qemu_monitor.c +++ b/src/qemu/qemu_monitor.c @@ -4513,3 +4513,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 c8f6069566..8a72abf28d 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -8895,3 +8895,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 12 22:13:57 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=1693970854; cv=none; d=zohomail.com; s=zohoarc; b=C0fLs3D1d2N+RvsLzNS/X80EAADCGRJKXLYu/4WqknxKgvGoa+0GSN27RENo8OQuqBX/bsfZSofxYihLeKXJUdEaI9LieavJwOIlenFvyDgTjfOKPK9pdQOKDFIXR6sxIPXqCnG4ABidNil6FXmdnlYF1uHT/oH49xU4qMFmNWs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1693970854; 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=9RS4spT0Ttt2KDSgbVnjJ3uin/lQGHQzkbcjyAgzXjI=; b=k0CibQzwvmnIfDmEfSSDcTTZOSeVTb+HoGw7U4rjunr/hteI1G2jUlQsn5srSyUxmfTXC5f9QRGmxLL4N/4z9zRb0G5Lw3fzUnVG3UU9Hu4b6ZSouBy8w/akHg5rc1OtrSqmu8A/Vy4XeuhtDx7Al4n8AlwL6YWJfBbFSW2ZCkE= 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 1693970854895536.6851797097968; Tue, 5 Sep 2023 20:27:34 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [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-32-yu0NWE2_NDSIIgA1AP0Gxw-1; Tue, 05 Sep 2023 23:27:28 -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 3AE16280FEC4; Wed, 6 Sep 2023 03:27:21 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 24EE0101328A; Wed, 6 Sep 2023 03:27:21 +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 6D4481946595; Wed, 6 Sep 2023 03:27:20 +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 63B10194658C for ; Wed, 6 Sep 2023 03:27:18 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 4511A58FDC0; Wed, 6 Sep 2023 03:27:18 +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 3C18858FDC5 for ; Wed, 6 Sep 2023 03:27:18 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 0F9CE1C06EE7 for ; Wed, 6 Sep 2023 03:27:18 +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-642-kbA5GCBOP9mhUoETmr6BxQ-1; Tue, 05 Sep 2023 23:27:15 -0400 Received: from git.sr.ht (unknown [173.195.146.142]) by mail-b.sr.ht (Postfix) with ESMTPSA id DEB2C11F0E6; Wed, 6 Sep 2023 03:27:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1693970853; 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=9RS4spT0Ttt2KDSgbVnjJ3uin/lQGHQzkbcjyAgzXjI=; b=XCAbfV/BEuE4lj0xOFwQAPviZMLiR+d7IfRSPgi0lCb3YAUgajDlSa5gqelmq8ih8xUXpd ijJwW6BdXekKNDE5F4QgEHHrPqOCHzalUlAbbmdMZUwp1Po8aDee58H2QlOYiyKJaiBG4C r9Mi7kll0H03UydF3usmIk1JlI5+NUo= X-MC-Unique: yu0NWE2_NDSIIgA1AP0Gxw-1 X-Original-To: libvir-list@listman.corp.redhat.com X-MC-Unique: kbA5GCBOP9mhUoETmr6BxQ-1 From: ~hyman Date: Sun, 06 Aug 2023 16:02:49 +0800 Subject: [PATCH Libvirt v3 09/10] qemu_driver: Extend dirtlimit statistics for domGetStats MIME-Version: 1.0 Message-ID: <169397083100.4628.15196043252714532301-9@git.sr.ht> In-Reply-To: <169397083100.4628.15196043252714532301-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: Martin Kletzander , 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: 1693970856374100003 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 5b505cc519..08c354617c 100644 --- a/src/libvirt-domain.c +++ b/src/libvirt-domain.c @@ -12514,6 +12514,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 64d97c0fba..a23c86180d 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -17649,6 +17649,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, @@ -17673,6 +17717,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 }, @@ -17685,6 +17734,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 12 22:13:57 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=1693970849; cv=none; d=zohomail.com; s=zohoarc; b=LaQ/fm8H+sH+bKHLcwanR86gE7gTbMKUhJaFpa/wvRZMKw5QWfQcHa/KUdfTvX+6u8HeaD1QKnm/cRbjsHPpsbFAEqBep/d3Sp9YuAJqpvYeZsQje0oyKhJIpnEqY1cmA+cdMCeLwaiGv8VvIqGcquRFCVRSm3KH2qVwTFQDQpA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1693970849; 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=96T9wZVsXpCLNeENQdPV8owb9+RIfPFw4Pzhme14oIE=; b=IPZZophC80OnNhipjzIqsvtTC15IUuamZTx80ONhHi9o2mSepJ++vjCaCr8GX91IprfamG1pNhjGXOFn96Ur/nB98biakca/U6IiYFsCNkdDrsYf1QnV6gEc/4G+vSBWpHEPN88Uu/JPVZfbjlDH+a61PDznlbEPIJy17+zMKRM= 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 1693970849746279.43536398832896; Tue, 5 Sep 2023 20:27:29 -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-495-bGqf1secPjy7zsrbmCoqnw-1; Tue, 05 Sep 2023 23:27:26 -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 97BAC91BC3A; Wed, 6 Sep 2023 03:27:22 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8275240F2D26; Wed, 6 Sep 2023 03:27:22 +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 6D6FF1946595; Wed, 6 Sep 2023 03:27:21 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id A262E1946A7F for ; Wed, 6 Sep 2023 03:27:19 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 96500412F2D4; Wed, 6 Sep 2023 03:27:19 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast05.extmail.prod.ext.rdu2.redhat.com [10.11.55.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8EE7C412F2D0 for ; Wed, 6 Sep 2023 03:27:19 +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 745D881B14B for ; Wed, 6 Sep 2023 03:27:19 +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-642-ZiFXmRvrPlC0MkluFUXDWw-1; Tue, 05 Sep 2023 23:27:15 -0400 Received: from git.sr.ht (unknown [173.195.146.142]) by mail-b.sr.ht (Postfix) with ESMTPSA id 1126C11F0E7; Wed, 6 Sep 2023 03:27:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1693970848; 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=96T9wZVsXpCLNeENQdPV8owb9+RIfPFw4Pzhme14oIE=; b=WsWvvElJRC5P4+K3QOizISblFsA8CPyZ9zIBrB1n+G61pua+KzMBCQvcBbhPM7rHzY0t5M 1aeFSIpouZDtFICruBvbBGGncZZNdt3dVCwkK1VSCtUj663mcReIIF1cl5MT3F5uy7m3iI XxwdJaJXR45iU2++dnGLhKx1xrG7znY= X-MC-Unique: bGqf1secPjy7zsrbmCoqnw-1 X-Original-To: libvir-list@listman.corp.redhat.com X-MC-Unique: ZiFXmRvrPlC0MkluFUXDWw-1 From: ~hyman Date: Sun, 06 Aug 2023 16:17:14 +0800 Subject: [PATCH Libvirt v3 10/10] virsh: Introduce command 'virsh domstats --dirtylimit' MIME-Version: 1.0 Message-ID: <169397083100.4628.15196043252714532301-10@git.sr.ht> In-Reply-To: <169397083100.4628.15196043252714532301-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.2 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: Martin Kletzander , 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: 1693970852538100013 From: Hyman Huang(=E9=BB=84=E5=8B=87) Introduce command 'virsh domstats --dirtylimit' for reporting dirty page rate upper limit (megabyte/s) 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 33a8f3b9fe..5bd06cb3a5 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 megabyte/s +* ``dirtylimit.vcpu..current`` - the dirty page rate for a virtual CPU + currently in megabyte/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