From nobody Tue Jul 1 12:22:05 2025 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=git.sr.ht Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1686198243170913.3666004358001; Wed, 7 Jun 2023 21:24:03 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q77BE-00066Y-Tu; Thu, 08 Jun 2023 00:23:24 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q74z4-0006R3-JY for qemu-devel@nongnu.org; Wed, 07 Jun 2023 22:02:42 -0400 Received: from mail-b.sr.ht ([173.195.146.151]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q74z1-0000DC-QL for qemu-devel@nongnu.org; Wed, 07 Jun 2023 22:02:42 -0400 Received: from git.sr.ht (unknown [173.195.146.142]) by mail-b.sr.ht (Postfix) with ESMTPSA id DCC1D11F0E4; Thu, 8 Jun 2023 02:02:38 +0000 (UTC) Authentication-Results: mail-b.sr.ht; dkim=none From: ~hyman Date: Fri, 18 Nov 2022 10:08:54 +0800 Subject: [PATCH QEMU v5 1/8] softmmu/dirtylimit: Add parameter check for hmp "set_vcpu_dirty_limit" MIME-Version: 1.0 Message-ID: <168618975839.6361.17407633874747688653-1@git.sr.ht> X-Mailer: git.sr.ht In-Reply-To: <168618975839.6361.17407633874747688653-0@git.sr.ht> To: qemu-devel Cc: Peter Xu , Paolo Bonzini , Juan Quintela , "Dr. David Alan Gilbert" , Eric Blake , Markus Armbruster , Thomas Huth , Laurent Vivier , Richard Henderson , Philippe =?utf-8?q?Mathieu-Daud=C3=A9?= , Hyman =?utf-8?b?SHVhbmco6buE5YuHKQ==?= Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=173.195.146.151; envelope-from=outgoing@sr.ht; helo=mail-b.sr.ht X-Spam_score_int: 15 X-Spam_score: 1.5 X-Spam_bar: + X-Spam_report: (1.5 / 5.0 requ) BAYES_00=-1.9, DATE_IN_PAST_96_XX=3.405, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Thu, 08 Jun 2023 00:23:13 -0400 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: ~hyman Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZM-MESSAGEID: 1686198244675100009 From: Hyman Huang(=E9=BB=84=E5=8B=87) dirty_rate paraemter of hmp command "set_vcpu_dirty_limit" is invalid if less than 0, so add parameter check for it. Note that this patch also delete the unsolicited help message and clean up the code. Signed-off-by: Hyman Huang(=E9=BB=84=E5=8B=87) Signed-off-by: Markus Armbruster Reviewed-by: Peter Xu Reviewed-by: Juan Quintela --- softmmu/dirtylimit.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/softmmu/dirtylimit.c b/softmmu/dirtylimit.c index 015a9038d1..5c12d26d49 100644 --- a/softmmu/dirtylimit.c +++ b/softmmu/dirtylimit.c @@ -515,14 +515,15 @@ void hmp_set_vcpu_dirty_limit(Monitor *mon, const QDi= ct *qdict) int64_t cpu_index =3D qdict_get_try_int(qdict, "cpu_index", -1); Error *err =3D NULL; =20 - qmp_set_vcpu_dirty_limit(!!(cpu_index !=3D -1), cpu_index, dirty_rate,= &err); - if (err) { - hmp_handle_error(mon, err); - return; + if (dirty_rate < 0) { + error_setg(&err, "invalid dirty page limit %ld", dirty_rate); + goto out; } =20 - monitor_printf(mon, "[Please use 'info vcpu_dirty_limit' to query " - "dirty limit for virtual CPU]\n"); + qmp_set_vcpu_dirty_limit(!!(cpu_index !=3D -1), cpu_index, dirty_rate,= &err); + +out: + hmp_handle_error(mon, err); } =20 static struct DirtyLimitInfo *dirtylimit_query_vcpu(int cpu_index) --=20 2.38.5