From nobody Mon Feb 9 10:29:51 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=git.sr.ht ARC-Seal: i=1; a=rsa-sha256; t=1691423806; cv=none; d=zohomail.com; s=zohoarc; b=RBmgPkw4fi33+ZHkfC2e2Ff1njNOdeLFBSTSpj2F/OnRruWdZvcQyfetCldwoRa3sB+wMbZLBnJuFC4vTFEexZ+1YiRhxZ7GmJTTxbCZYncM9pfU77kwe9cY0aAQrBLwwTpr8YUsbRi2xZkhPkNdthTDbbfAuWvBPoXgxLibOsk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1691423806; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Sender:Subject:To; bh=wMhdATVX7kyQpflqds6G6PS6S9Q5zZHqGS0Ekxp+U6Y=; b=nHI+sgg2otbM0ru6L0int11CkcewU3rdP/RF/Lco+M+ZaK7l/AUtBWS9gV29j8faJg7wi0Uz0kwkYERVjbqRS0o6flQMCgkrL64rp677UGAqEcTBjrwlhJy0Q1gxXPdnaZgNEZq6JMxmIVHE4UMoKGWsnnIfYJZ4gvbuQDHHA84= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1691423806909280.3914268860716; Mon, 7 Aug 2023 08:56:46 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-484-FRKejqnfOEmCDcyrtaPz5g-1; Mon, 07 Aug 2023 11:56:43 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 05B108019CC; Mon, 7 Aug 2023 15:56:41 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id DE06B140E962; Mon, 7 Aug 2023 15:56:40 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 589961946A41; Mon, 7 Aug 2023 15:56:25 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 58A551946A6D for ; Mon, 7 Aug 2023 15:56:17 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 38BCA40C2078; Mon, 7 Aug 2023 15:56:12 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast02.extmail.prod.ext.rdu2.redhat.com [10.11.55.18]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 3206240C2076 for ; Mon, 7 Aug 2023 15:56:12 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-1.mimecast.com [207.211.31.81]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 177AA805AF6 for ; Mon, 7 Aug 2023 15:56:12 +0000 (UTC) Received: from mail-b.sr.ht (mail-b.sr.ht [173.195.146.151]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-187-lahIoXGhM0KcoxBJ6QUpSA-1; Mon, 07 Aug 2023 11:56:09 -0400 Received: from git.sr.ht (unknown [173.195.146.142]) by mail-b.sr.ht (Postfix) with ESMTPSA id 4BD4A11EFD1; Mon, 7 Aug 2023 15:56:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1691423806; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:list-id:list-help:list-unsubscribe: list-subscribe:list-post; bh=wMhdATVX7kyQpflqds6G6PS6S9Q5zZHqGS0Ekxp+U6Y=; b=XE5HAsJazMBqzxHjtUHQtrjHI7xh3BxWmmY9p0/G7NTCJKCVVjw1cbsa54xGshGrp0zaWH T4xq+zaNyT+XBn6/v3jHT/JenxdWL+/ZMo6Niye/C4P8SEu6DB+rat7Se9PTxo1pF20JJv xcgyDokpoNro6EkUjH+0eZq80PTpWGE= X-MC-Unique: FRKejqnfOEmCDcyrtaPz5g-1 X-Original-To: libvir-list@listman.corp.redhat.com X-MC-Unique: lahIoXGhM0KcoxBJ6QUpSA-1 From: ~hyman Date: Tue, 01 Aug 2023 18:38:15 +0800 Subject: [PATCH Libvirt v2 06/10] qemu_process: Setup dirty limit after launching VM MIME-Version: 1.0 Message-ID: <169142376567.1452.17600824269401067909-6@git.sr.ht> In-Reply-To: <169142376567.1452.17600824269401067909-0@git.sr.ht> To: libvir-list@redhat.com X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: ~hyman Cc: Peter Krempa , yong.huang@smartx.com Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: git.sr.ht Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1691423808759100001 From: Hyman Huang(=E9=BB=84=E5=8B=87) The dirty_limit attribute in XML requires setting up the upper limit of dirty page rate once after launching the VM, so add the implementation. Signed-off-by: Hyman Huang(=E9=BB=84=E5=8B=87) --- src/qemu/qemu_process.c | 44 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 0644f80161..47763bbefc 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -6161,6 +6161,46 @@ qemuDomainHasHotpluggableStartupVcpus(virDomainDef *= def) } =20 =20 +static int +qemuProcessSetupDirtyLimit(virDomainObj *vm, + virDomainAsyncJob asyncJob) +{ + qemuDomainObjPrivate *priv =3D vm->privateData; + virDomainDef *def =3D vm->def; + int ret =3D -1; + + /* Dirty limit capability is not present, skip the setup */ + if (!virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_VCPU_DIRTY_LIMIT)) + return 0; + + if (virDomainDefHasDirtyLimitStartupVcpus(def)) { + size_t maxvcpus =3D virDomainDefGetVcpusMax(def); + virDomainVcpuDef *vcpu; + size_t i; + + if (qemuDomainObjEnterMonitorAsync(vm, asyncJob) < 0) + return -1; + + for (i =3D 0; i < maxvcpus; i++) { + vcpu =3D virDomainDefGetVcpu(def, i); + + if (vcpu->dirtyLimitSet && (vcpu->dirty_limit !=3D 0)) { + if ((ret =3D qemuMonitorSetVcpuDirtyLimit(priv->mon, i, vc= pu->dirty_limit)) < 0) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Failed to set dirty page rate limit = of vcpu[%1$zu]"), i); + qemuDomainObjExitMonitor(vm); + return ret; + } + VIR_DEBUG("Set vcpu[%zu] dirty page rate limit %lld", i, v= cpu->dirty_limit); + } + } + qemuDomainObjExitMonitor(vm); + } + + return 0; +} + + static int qemuProcessVcpusSortOrder(const void *a, const void *b) @@ -7839,6 +7879,10 @@ qemuProcessLaunch(virConnectPtr conn, if (qemuProcessUpdateAndVerifyCPU(vm, asyncJob) < 0) goto cleanup; =20 + VIR_DEBUG("Setting Dirty Limit for virtual CPUs"); + if (qemuProcessSetupDirtyLimit(vm, asyncJob) < 0) + goto cleanup; + VIR_DEBUG("Detecting IOThread PIDs"); if (qemuProcessDetectIOThreadPIDs(vm, asyncJob) < 0) goto cleanup; --=20 2.38.5