From nobody Thu May 2 09:51:03 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1669875305; cv=none; d=zohomail.com; s=zohoarc; b=m19uBXSiLK9x1uex1nGZIsfuvxquVc70dX1DCezWE2Hxsf5Xh1tClv6yro9wLv2iixkwImpupZt9M5yim6U2EioYuytpZiU8rVDd95YhGl/LJDUTPTmbJWDQGSYi/qPIClxMHa/5H5IdT8NP/wZhrcBwpcQAzLh9YbJnhyRSkYM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1669875305; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=6UAA36rMdL7CoNHGmLtZbZHnNDvSVBvjzxdayga4Qtw=; b=Ie2OwT8QFquY+Pzg7JxiGrT8ruZdg5XbKKUqukeZG48UJylTVXD2Q6VZJtMkOBRZA2OOlPrYbolSLaYOLbvgUaxJd7Dct++fY+mPKoKeLBK/J5IvNf4hRnaCSbSA7zL/gBQWH82p+AyF0x0lwvkb3A47g2QXSocNQzbQeLNKyTM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 166987530506042.61169409933473; Wed, 30 Nov 2022 22:15:05 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p0cp1-0005fs-0p; Thu, 01 Dec 2022 01:13:23 -0500 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 1p0coy-0005eI-Hc for qemu-devel@nongnu.org; Thu, 01 Dec 2022 01:13:20 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p0cow-0005ln-Lc for qemu-devel@nongnu.org; Thu, 01 Dec 2022 01:13:20 -0500 Received: from mimecast-mx02.redhat.com (mx3-rdu2.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-281-SZBf_tu5NlaubxrnUnDmxQ-1; Thu, 01 Dec 2022 01:13:15 -0500 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 5084629DD9B0 for ; Thu, 1 Dec 2022 06:13:15 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.39.192.19]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 212271121314; Thu, 1 Dec 2022 06:13:15 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id E062821E6930; Thu, 1 Dec 2022 07:13:11 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1669875197; h=from:from: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:references:references; bh=6UAA36rMdL7CoNHGmLtZbZHnNDvSVBvjzxdayga4Qtw=; b=Hlk0oOhNWF1hzrJZNQaRPOqJIVX3W55RSZLleqdvEkXKN1OFIgUOFHO93+XrRh6UYl/VIZ f3SGoZvLrKdZyYdlKJmA4K1ywUDWDBbMHuGT1N0KrSW6onHE7MGBNW9MjeO/M21BbueFcJ 6dm8G4fRbG1LeuzOOvobonfMYbPTNYQ= X-MC-Unique: SZBf_tu5NlaubxrnUnDmxQ-1 From: Markus Armbruster To: qemu-devel@nongnu.org Cc: kraxel@redhat.com, dgilbert@redhat.com Subject: [PATCH 1/9] ui: Check numeric part of expire_password argument @time properly Date: Thu, 1 Dec 2022 07:13:03 +0100 Message-Id: <20221201061311.3619052-2-armbru@redhat.com> In-Reply-To: <20221201061311.3619052-1-armbru@redhat.com> References: <20221201061311.3619052-1-armbru@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.3 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+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1669875306279100003 Content-Type: text/plain; charset="utf-8" When argument @time isn't 'now' or 'never', we parse it as an integer, optionally prefixed with '+'. If parsing fails, we silently assume zero. Report an error and fail instead. While there, use qemu_strtou64() instead of strtoull() so checkpatch.pl won't complain. Aside: encoding numbers in strings is bad QMP practice. Signed-off-by: Markus Armbruster Reviewed-by: Daniel P. Berrang=C3=A9 --- monitor/qmp-cmds.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/monitor/qmp-cmds.c b/monitor/qmp-cmds.c index 81c8fdadf8..054d7648b1 100644 --- a/monitor/qmp-cmds.c +++ b/monitor/qmp-cmds.c @@ -205,15 +205,28 @@ void qmp_expire_password(ExpirePasswordOptions *opts,= Error **errp) time_t when; int rc; const char *whenstr =3D opts->time; + const char *numstr =3D NULL; + uint64_t num; =20 if (strcmp(whenstr, "now") =3D=3D 0) { when =3D 0; } else if (strcmp(whenstr, "never") =3D=3D 0) { when =3D TIME_MAX; } else if (whenstr[0] =3D=3D '+') { - when =3D time(NULL) + strtoull(whenstr+1, NULL, 10); + when =3D time(NULL); + numstr =3D whenstr + 1; } else { - when =3D strtoull(whenstr, NULL, 10); + when =3D 0; + numstr =3D whenstr; + } + + if (numstr) { + if (qemu_strtou64(numstr, NULL, 10, &num) < 0) { + error_setg(errp, "Parameter 'time' doesn't take value '%s'", + whenstr); + return; + } + when +=3D num; } =20 if (opts->protocol =3D=3D DISPLAY_PROTOCOL_SPICE) { --=20 2.37.3 From nobody Thu May 2 09:51:03 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1669875298; cv=none; d=zohomail.com; s=zohoarc; b=ZWQPorYyaXv0clRD0ZeyY9rxeaoFqOyLCYY+JZKyNOd7rKoAhc4EftcrrnCHKsZdldwVM072GXqLkfFf6llVi2mh/8t2pXUnGrkH+oQ72Izqu4I3YiS07pGTBjmJoAiP1GH3Dd4vXmtc6aiQjtMyX6bJ3lWjoVbLtA3fKCG8Dz4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1669875298; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=CEncH5jWuMoGUOCPEM0Co8w+5YqVTzL+43gIV+1rwA8=; b=VR+Q+YVYL10XWFCRLDMNA9Z3RY8TxidkoM4XRfWYP610qqpmY2llS2SNbzdmt2wpXDYyslVAqVF2+z7OaHoiKaogBAuerg1wdpF5rcP5QNPW2u6b+jZtjxcqewEMRbciGc9+3RFqviCf6+W295XLageEoRc6kEuG5tZxYh2cPfs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1669875298845392.1692798879054; Wed, 30 Nov 2022 22:14:58 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p0cp2-0005gI-JL; Thu, 01 Dec 2022 01:13:24 -0500 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 1p0coy-0005eH-Gl for qemu-devel@nongnu.org; Thu, 01 Dec 2022 01:13:20 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p0cow-0005lw-TG for qemu-devel@nongnu.org; Thu, 01 Dec 2022 01:13:20 -0500 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-356-oC-RKTEPOdWtBwfpdfHLCQ-1; Thu, 01 Dec 2022 01:13:15 -0500 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 4A3B585A588 for ; Thu, 1 Dec 2022 06:13:15 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.39.192.19]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 21111140EBF5; Thu, 1 Dec 2022 06:13:15 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id E27C321E6681; Thu, 1 Dec 2022 07:13:11 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1669875198; h=from:from: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:references:references; bh=CEncH5jWuMoGUOCPEM0Co8w+5YqVTzL+43gIV+1rwA8=; b=V2QHJNNNaIj/qYI7c2YL1bsWdE2WArlH1NBsqwYSFwQYJ30LcMrCjCHwXyjhpXIBJzRrjJ a76Xfu4ojAb00gPvs3nImdhVekNr3JNFXWSSORxOUdHEDwpPkauN/hqRkxghsAYBZd4W83 Q9MzbMV1MUUuUJDoJMucmiZUFXcgrSM= X-MC-Unique: oC-RKTEPOdWtBwfpdfHLCQ-1 From: Markus Armbruster To: qemu-devel@nongnu.org Cc: kraxel@redhat.com, dgilbert@redhat.com Subject: [PATCH 2/9] ui: Fix silent truncation of numeric keys in HMP sendkey Date: Thu, 1 Dec 2022 07:13:04 +0100 Message-Id: <20221201061311.3619052-3-armbru@redhat.com> In-Reply-To: <20221201061311.3619052-1-armbru@redhat.com> References: <20221201061311.3619052-1-armbru@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 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+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1669875300287100001 Content-Type: text/plain; charset="utf-8" Keys are int. HMP sendkey assigns them from the value strtoul(), silently truncating values greater than INT_MAX. Fix to reject them. While there, use qemu_strtoul() instead of strtoul() so checkpatch.pl won't complain. Signed-off-by: Markus Armbruster Reviewed-by: Daniel P. Berrang=C3=A9 --- monitor/hmp-cmds.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c index 01b789a79e..a7c9ae2520 100644 --- a/monitor/hmp-cmds.c +++ b/monitor/hmp-cmds.c @@ -1666,8 +1666,13 @@ void hmp_sendkey(Monitor *mon, const QDict *qdict) v =3D g_malloc0(sizeof(*v)); =20 if (strstart(keys, "0x", NULL)) { - char *endp; - int value =3D strtoul(keys, &endp, 0); + const char *endp; + unsigned long value; + + if (qemu_strtoul(keys, &endp, 0, &value) < 0 + || value >=3D INT_MAX) { + goto err_out; + } assert(endp <=3D keys + keyname_len); if (endp !=3D keys + keyname_len) { goto err_out; --=20 2.37.3 From nobody Thu May 2 09:51:03 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1669875300; cv=none; d=zohomail.com; s=zohoarc; b=P5ekw2DCaYIvsiopEUwK4QUmcd0BfLT068UK+239XucjeifxP50tnFFOv1KVfHJnECJXbk8XX3ovZImg2MflORxbfgmTNLsCvtUjlOixgkPhG1KsSOqyPJvBuFaN4Utc63tepQUgAgBWoaiZV+t32zUTrKyFX/LZVzx957i4JWs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1669875300; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=yU9CQzTNwyegt6aMM4ArVHYH5uDT6h6ZXWrpMhPsUy8=; b=Ga5SPAdqXDlhDfIPyvyX4VlBzsgjmmlkHfxk8nzPAfl8uETCR/TpxDZtx6KkjMYKPL6sZANdjgVquMUpaWVHefKOh3a8PvuCu7xx9LZp323ZUZaIXXDbCrVFnCnWNNMcBV1MW+CXGv57KXUSLrAk2MEZSC/THkW/laKBw3qifTg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1669875300340674.5656225826334; Wed, 30 Nov 2022 22:15:00 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p0coz-0005f1-DB; Thu, 01 Dec 2022 01:13:21 -0500 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 1p0cox-0005e7-3g for qemu-devel@nongnu.org; Thu, 01 Dec 2022 01:13:19 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p0cov-0005lW-Mh for qemu-devel@nongnu.org; Thu, 01 Dec 2022 01:13:18 -0500 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-77-WnLoALm-OLy7H5sWj6HJEw-1; Thu, 01 Dec 2022 01:13:15 -0500 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 4BC0D185A7A3 for ; Thu, 1 Dec 2022 06:13:15 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.39.192.19]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 2145E40C2064; Thu, 1 Dec 2022 06:13:15 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id E4DDA21E6936; Thu, 1 Dec 2022 07:13:11 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1669875196; h=from:from: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:references:references; bh=yU9CQzTNwyegt6aMM4ArVHYH5uDT6h6ZXWrpMhPsUy8=; b=eDA36HglGXDZ4UtO5VQIW0gUCSKjXXwTXVMO26l2ND6HJA8dGbgkRj+CgiafA57CzKeV4o P2Kdy3oammvxrv1cfRO8kIkhRxOEROf5fpbukMetZSa5nDoPmCci6Gcx32JTbCZiXje1UT V13LDB9vvOTp4EK8AhMyYUc64IC83OU= X-MC-Unique: WnLoALm-OLy7H5sWj6HJEw-1 From: Markus Armbruster To: qemu-devel@nongnu.org Cc: kraxel@redhat.com, dgilbert@redhat.com Subject: [PATCH 3/9] ui: Drop disabled code for SPICE_CHANNEL_WEBDAV Date: Thu, 1 Dec 2022 07:13:05 +0100 Message-Id: <20221201061311.3619052-4-armbru@redhat.com> In-Reply-To: <20221201061311.3619052-1-armbru@redhat.com> References: <20221201061311.3619052-1-armbru@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 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+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1669875302229100007 Content-Type: text/plain; charset="utf-8" HMP "info spice" has a bit of code to show channel type SPICE_CHANNEL_WEBDAV as "webdav", disabled since commit 7c6044a94e "hmp: info spice: take out webdav" (v2.3.0), because it compiles only with Spice versions 0.12.7 and later. Our minimum version is 0.12.5. Looks like nobody minded in more than seven years. Drop it, so that checkpatch.pl won't complain when I move the code. Signed-off-by: Markus Armbruster --- monitor/hmp-cmds.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c index a7c9ae2520..86dd961462 100644 --- a/monitor/hmp-cmds.c +++ b/monitor/hmp-cmds.c @@ -626,12 +626,6 @@ void hmp_info_spice(Monitor *mon, const QDict *qdict) [SPICE_CHANNEL_SMARTCARD] =3D "smartcard", [SPICE_CHANNEL_USBREDIR] =3D "usbredir", [SPICE_CHANNEL_PORT] =3D "port", -#if 0 - /* minimum spice-protocol is 0.12.3, webdav was added in 0.12.7, - * no easy way to #ifdef (SPICE_CHANNEL_* is a enum). Disable - * as quick fix for build failures with older versions. */ - [SPICE_CHANNEL_WEBDAV] =3D "webdav", -#endif }; =20 info =3D qmp_query_spice(NULL); --=20 2.37.3 From nobody Thu May 2 09:51:03 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1669875410; cv=none; d=zohomail.com; s=zohoarc; b=NPkreIqqVxxGEnyiMY58C42Abu8AfKIXlYSFd33gtWICBcC91NEMkjW6neRsnqEhWtXcVMByu9pBnYVtSssHdBakT0CX0cfFunFUj1L89xjI+Sh53ka+orFEP3nJUAcXYNFm0Wjji7dw1ehgjn8uh62RPey58sRK2NKAETLTbgk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1669875410; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Qr38nbHfyA2i6ANHY9JyOGXgOqr8gaXsLmR5SlHt6x0=; b=AFqI/BdsW+gEkOvQTdPwIpjJPJU8wYmSqfdok1DmlrLjvU+O47GGG/eqRfQm52Kqyl13dQkPXHBjF9B3o/1+sJLymlCVU7pP37jrIqGCHz5+AxNdwS6P7QcfXgzZAU3+xHI+71aH1YEWizM+mWI17sMI1cX37/GZTU1emllu+C8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1669875410049422.4936355072855; Wed, 30 Nov 2022 22:16:50 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p0cp0-0005fN-Bo; Thu, 01 Dec 2022 01:13:22 -0500 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 1p0coy-0005eF-GW for qemu-devel@nongnu.org; Thu, 01 Dec 2022 01:13:20 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p0cow-0005lo-OY for qemu-devel@nongnu.org; Thu, 01 Dec 2022 01:13:20 -0500 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-281-qEVTFANBNUq5gEl7JVFRWw-1; Thu, 01 Dec 2022 01:13:15 -0500 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 512F2811E75 for ; Thu, 1 Dec 2022 06:13:15 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.39.192.19]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 211882028CE4; Thu, 1 Dec 2022 06:13:15 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id E726A21E66CA; Thu, 1 Dec 2022 07:13:11 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1669875197; h=from:from: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:references:references; bh=Qr38nbHfyA2i6ANHY9JyOGXgOqr8gaXsLmR5SlHt6x0=; b=AkK1CBionoVTL2ZA/HT6Tzdtf9e5BrVqpWOyfop15hqEKOYHM+xx91p80R6YG6DWz+CmJU 5rG34ykr0LpWY66JkTfd4mdb7iDfD2m2iFGv9jI9BwinHHzLKGf+wcdUUGusxj8QRfCvgt +dLPIDtgWqu3GjwMzjg7BcIO+fQfPug= X-MC-Unique: qEVTFANBNUq5gEl7JVFRWw-1 From: Markus Armbruster To: qemu-devel@nongnu.org Cc: kraxel@redhat.com, dgilbert@redhat.com Subject: [PATCH 4/9] ui: Clean up a few things checkpatch.pl would flag later on Date: Thu, 1 Dec 2022 07:13:06 +0100 Message-Id: <20221201061311.3619052-5-armbru@redhat.com> In-Reply-To: <20221201061311.3619052-1-armbru@redhat.com> References: <20221201061311.3619052-1-armbru@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 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+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1669875410679100001 Content-Type: text/plain; charset="utf-8" Fix a few style violations so that checkpatch.pl won't complain when I move this code. Signed-off-by: Markus Armbruster Reviewed-by: Daniel P. Berrang=C3=A9 --- monitor/hmp-cmds.c | 7 ++++--- monitor/qmp-cmds.c | 21 +++++++++++---------- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c index 86dd961462..29fcc730cb 100644 --- a/monitor/hmp-cmds.c +++ b/monitor/hmp-cmds.c @@ -591,9 +591,10 @@ void hmp_info_vnc(Monitor *mon, const QDict *qdict) hmp_info_vnc_servers(mon, info->server); hmp_info_vnc_clients(mon, info->clients); if (!info->server) { - /* The server entry displays its auth, we only - * need to display in the case of 'reverse' connections - * where there's no server. + /* + * The server entry displays its auth, we only need to + * display in the case of 'reverse' connections where + * there's no server. */ hmp_info_vnc_authcrypt(mon, " ", info->auth, info->has_vencrypt ? &info->vencrypt : NULL= ); diff --git a/monitor/qmp-cmds.c b/monitor/qmp-cmds.c index 054d7648b1..a7c95e8e39 100644 --- a/monitor/qmp-cmds.c +++ b/monitor/qmp-cmds.c @@ -190,8 +190,10 @@ void qmp_set_password(SetPasswordOptions *opts, Error = **errp) error_setg(errp, QERR_INVALID_PARAMETER, "connected"); return; } - /* Note that setting an empty password will not disable login thro= ugh - * this interface. */ + /* + * Note that setting an empty password will not disable login + * through this interface. + */ rc =3D vnc_display_password(opts->u.vnc.display, opts->password); } =20 @@ -276,12 +278,10 @@ void qmp_add_client(const char *protocol, const char = *fdname, error_setg(errp, "spice failed to add client"); close(fd); } - return; #ifdef CONFIG_VNC } else if (strcmp(protocol, "vnc") =3D=3D 0) { skipauth =3D has_skipauth ? skipauth : false; vnc_display_add_client(NULL, fd, skipauth); - return; #endif #ifdef CONFIG_DBUS_DISPLAY } else if (strcmp(protocol, "@dbus-display") =3D=3D 0) { @@ -293,19 +293,20 @@ void qmp_add_client(const char *protocol, const char = *fdname, close(fd); return; } - return; #endif - } else if ((s =3D qemu_chr_find(protocol)) !=3D NULL) { + } else { + s =3D qemu_chr_find(protocol); + if (!s) { + error_setg(errp, "protocol '%s' is invalid", protocol); + close(fd); + return; + } if (qemu_chr_add_client(s, fd) < 0) { error_setg(errp, "failed to add client"); close(fd); return; } - return; } - - error_setg(errp, "protocol '%s' is invalid", protocol); - close(fd); } =20 =20 --=20 2.37.3 From nobody Thu May 2 09:51:03 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1669875403; cv=none; d=zohomail.com; s=zohoarc; b=i1jVz4+akswVArrskbt/9XQhRvsQs+6TxmHk/bgIucozU2n+zET+uwAVEYAF54yC1EoeWHcdyiY66tnlcjKTYAt6lrOJbAVKuaQygl5DC33rxAgkmhh5zX4O9Mbv3qhT2Jtidb5W+cbiwP5hAGgFL4SNUQQnVw4JLHZHrPvEDhE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1669875403; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=RyfrnBGbFz4gu436RxEUKUfyWtRrBHWQKVJEI1cObxw=; b=JRzNe6g+O1FAnEch51Nh3opnF/JWDRu1cny+EmJhGVPib0xZH0uG0GkuIdOz4af1vKt6aLNMGumjUvszsgWwrZzn7Hs5qMn8NnNYKfdDA0FkWj83gvMRx839WX4Wn44u1kji1QEH4PcerkApDBhEi8I+AfVRCl8iAHIubUVgoBM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1669875403062139.92047717613673; Wed, 30 Nov 2022 22:16:43 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p0cpA-0005kK-IT; Thu, 01 Dec 2022 01:13:32 -0500 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 1p0cp6-0005jj-AI for qemu-devel@nongnu.org; Thu, 01 Dec 2022 01:13:29 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p0cp4-0005ml-7V for qemu-devel@nongnu.org; Thu, 01 Dec 2022 01:13:27 -0500 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-302-k5mu79EGM3agVqDciuhn2g-1; Thu, 01 Dec 2022 01:13:19 -0500 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 F00D285A5A6 for ; Thu, 1 Dec 2022 06:13:18 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.39.192.19]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 85BEBC15BA5; Thu, 1 Dec 2022 06:13:18 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id E9B0121E65C5; Thu, 1 Dec 2022 07:13:11 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1669875200; h=from:from: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:references:references; bh=RyfrnBGbFz4gu436RxEUKUfyWtRrBHWQKVJEI1cObxw=; b=DVcm2JunQ+pZapqZKpuaSshbU8TjVyTGBM/U9yrhbvWYd3cWvtTpllydC0qRKkzyvVglEd /WOuVLK+v2NmkQYDrUYVfWmb26j2fBXTiwRe1h/2rkBSm0NlZ+kRrybtGFZZ9rMcCaKpoy q8l8Gt0qdy6TKBDiCSqjqZEIoL4CwME= X-MC-Unique: k5mu79EGM3agVqDciuhn2g-1 From: Markus Armbruster To: qemu-devel@nongnu.org Cc: kraxel@redhat.com, dgilbert@redhat.com Subject: [PATCH 5/9] ui: Move QMP commands from monitor to new ui/ui-qmp-cmds.c Date: Thu, 1 Dec 2022 07:13:07 +0100 Message-Id: <20221201061311.3619052-6-armbru@redhat.com> In-Reply-To: <20221201061311.3619052-1-armbru@redhat.com> References: <20221201061311.3619052-1-armbru@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 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+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1669875404698100003 Content-Type: text/plain; charset="utf-8" This moves these commands from MAINTAINERS section "Human Monitor (HMP)" to "Graphics". Command add-client applies to socket character devices in addition to display devices. Move it anyway. Aside: the way @protocol character device IDs and display types is bad design. Signed-off-by: Markus Armbruster Reviewed-by: Daniel P. Berrang=C3=A9 --- monitor/qmp-cmds.c | 177 ----------------------------------------- ui/ui-qmp-cmds.c | 194 +++++++++++++++++++++++++++++++++++++++++++++ ui/meson.build | 1 + 3 files changed, 195 insertions(+), 177 deletions(-) create mode 100644 ui/ui-qmp-cmds.c diff --git a/monitor/qmp-cmds.c b/monitor/qmp-cmds.c index a7c95e8e39..85b2089873 100644 --- a/monitor/qmp-cmds.c +++ b/monitor/qmp-cmds.c @@ -16,14 +16,9 @@ #include "qemu/osdep.h" #include "qemu/cutils.h" #include "qemu/option.h" -#include "monitor/monitor.h" #include "sysemu/sysemu.h" #include "qemu/config-file.h" #include "qemu/uuid.h" -#include "chardev/char.h" -#include "ui/qemu-spice.h" -#include "ui/console.h" -#include "ui/dbus-display.h" #include "sysemu/kvm.h" #include "sysemu/runstate.h" #include "sysemu/runstate-action.h" @@ -36,9 +31,7 @@ #include "qapi/qapi-commands-machine.h" #include "qapi/qapi-commands-misc.h" #include "qapi/qapi-commands-stats.h" -#include "qapi/qapi-commands-ui.h" #include "qapi/type-helpers.h" -#include "qapi/qmp/qerror.h" #include "exec/ramlist.h" #include "hw/mem/memory-device.h" #include "hw/acpi/acpi_dev_interface.h" @@ -172,144 +165,6 @@ void qmp_system_wakeup(Error **errp) qemu_system_wakeup_request(QEMU_WAKEUP_REASON_OTHER, errp); } =20 -void qmp_set_password(SetPasswordOptions *opts, Error **errp) -{ - int rc; - - if (opts->protocol =3D=3D DISPLAY_PROTOCOL_SPICE) { - if (!qemu_using_spice(errp)) { - return; - } - rc =3D qemu_spice.set_passwd(opts->password, - opts->connected =3D=3D SET_PASSWORD_ACTION_FAIL, - opts->connected =3D=3D SET_PASSWORD_ACTION_DISCONNECT); - } else { - assert(opts->protocol =3D=3D DISPLAY_PROTOCOL_VNC); - if (opts->connected !=3D SET_PASSWORD_ACTION_KEEP) { - /* vnc supports "connected=3Dkeep" only */ - error_setg(errp, QERR_INVALID_PARAMETER, "connected"); - return; - } - /* - * Note that setting an empty password will not disable login - * through this interface. - */ - rc =3D vnc_display_password(opts->u.vnc.display, opts->password); - } - - if (rc !=3D 0) { - error_setg(errp, "Could not set password"); - } -} - -void qmp_expire_password(ExpirePasswordOptions *opts, Error **errp) -{ - time_t when; - int rc; - const char *whenstr =3D opts->time; - const char *numstr =3D NULL; - uint64_t num; - - if (strcmp(whenstr, "now") =3D=3D 0) { - when =3D 0; - } else if (strcmp(whenstr, "never") =3D=3D 0) { - when =3D TIME_MAX; - } else if (whenstr[0] =3D=3D '+') { - when =3D time(NULL); - numstr =3D whenstr + 1; - } else { - when =3D 0; - numstr =3D whenstr; - } - - if (numstr) { - if (qemu_strtou64(numstr, NULL, 10, &num) < 0) { - error_setg(errp, "Parameter 'time' doesn't take value '%s'", - whenstr); - return; - } - when +=3D num; - } - - if (opts->protocol =3D=3D DISPLAY_PROTOCOL_SPICE) { - if (!qemu_using_spice(errp)) { - return; - } - rc =3D qemu_spice.set_pw_expire(when); - } else { - assert(opts->protocol =3D=3D DISPLAY_PROTOCOL_VNC); - rc =3D vnc_display_pw_expire(opts->u.vnc.display, when); - } - - if (rc !=3D 0) { - error_setg(errp, "Could not set password expire time"); - } -} - -#ifdef CONFIG_VNC -void qmp_change_vnc_password(const char *password, Error **errp) -{ - if (vnc_display_password(NULL, password) < 0) { - error_setg(errp, "Could not set password"); - } -} -#endif - -void qmp_add_client(const char *protocol, const char *fdname, - bool has_skipauth, bool skipauth, bool has_tls, bool t= ls, - Error **errp) -{ - Chardev *s; - int fd; - - fd =3D monitor_get_fd(monitor_cur(), fdname, errp); - if (fd < 0) { - return; - } - - if (strcmp(protocol, "spice") =3D=3D 0) { - if (!qemu_using_spice(errp)) { - close(fd); - return; - } - skipauth =3D has_skipauth ? skipauth : false; - tls =3D has_tls ? tls : false; - if (qemu_spice.display_add_client(fd, skipauth, tls) < 0) { - error_setg(errp, "spice failed to add client"); - close(fd); - } -#ifdef CONFIG_VNC - } else if (strcmp(protocol, "vnc") =3D=3D 0) { - skipauth =3D has_skipauth ? skipauth : false; - vnc_display_add_client(NULL, fd, skipauth); -#endif -#ifdef CONFIG_DBUS_DISPLAY - } else if (strcmp(protocol, "@dbus-display") =3D=3D 0) { - if (!qemu_using_dbus_display(errp)) { - close(fd); - return; - } - if (!qemu_dbus_display.add_client(fd, errp)) { - close(fd); - return; - } -#endif - } else { - s =3D qemu_chr_find(protocol); - if (!s) { - error_setg(errp, "protocol '%s' is invalid", protocol); - close(fd); - return; - } - if (qemu_chr_add_client(s, fd) < 0) { - error_setg(errp, "failed to add client"); - close(fd); - return; - } - } -} - - MemoryDeviceInfoList *qmp_query_memory_devices(Error **errp) { return qmp_memory_device_list(); @@ -348,38 +203,6 @@ MemoryInfo *qmp_query_memory_size_summary(Error **errp) return mem_info; } =20 -void qmp_display_reload(DisplayReloadOptions *arg, Error **errp) -{ - switch (arg->type) { - case DISPLAY_RELOAD_TYPE_VNC: -#ifdef CONFIG_VNC - if (arg->u.vnc.has_tls_certs && arg->u.vnc.tls_certs) { - vnc_display_reload_certs(NULL, errp); - } -#else - error_setg(errp, "vnc is invalid, missing 'CONFIG_VNC'"); -#endif - break; - default: - abort(); - } -} - -void qmp_display_update(DisplayUpdateOptions *arg, Error **errp) -{ - switch (arg->type) { - case DISPLAY_UPDATE_TYPE_VNC: -#ifdef CONFIG_VNC - vnc_display_update(&arg->u.vnc, errp); -#else - error_setg(errp, "vnc is invalid, missing 'CONFIG_VNC'"); -#endif - break; - default: - abort(); - } -} - static int qmp_x_query_rdma_foreach(Object *obj, void *opaque) { RdmaProvider *rdma; diff --git a/ui/ui-qmp-cmds.c b/ui/ui-qmp-cmds.c new file mode 100644 index 0000000000..5d145c26f7 --- /dev/null +++ b/ui/ui-qmp-cmds.c @@ -0,0 +1,194 @@ +/* + * QMP commands related to UI + * + * Copyright IBM, Corp. 2011 + * + * Authors: + * Anthony Liguori + * + * This work is licensed under the terms of the GNU GPL, version 2. See + * the COPYING file in the top-level directory. + * + * Contributions after 2012-01-13 are licensed under the terms of the + * GNU GPL, version 2 or (at your option) any later version. + */ + +#include "qemu/osdep.h" +#include "chardev/char.h" +#include "monitor/monitor.h" +#include "qapi/qapi-commands-misc.h" +#include "qapi/qapi-commands-ui.h" +#include "qapi/qmp/qerror.h" +#include "qemu/cutils.h" +#include "ui/console.h" +#include "ui/dbus-display.h" +#include "ui/qemu-spice.h" + +void qmp_set_password(SetPasswordOptions *opts, Error **errp) +{ + int rc; + + if (opts->protocol =3D=3D DISPLAY_PROTOCOL_SPICE) { + if (!qemu_using_spice(errp)) { + return; + } + rc =3D qemu_spice.set_passwd(opts->password, + opts->connected =3D=3D SET_PASSWORD_ACTION_FAIL, + opts->connected =3D=3D SET_PASSWORD_ACTION_DISCONNECT); + } else { + assert(opts->protocol =3D=3D DISPLAY_PROTOCOL_VNC); + if (opts->connected !=3D SET_PASSWORD_ACTION_KEEP) { + /* vnc supports "connected=3Dkeep" only */ + error_setg(errp, QERR_INVALID_PARAMETER, "connected"); + return; + } + /* + * Note that setting an empty password will not disable login + * through this interface. + */ + rc =3D vnc_display_password(opts->u.vnc.display, opts->password); + } + + if (rc !=3D 0) { + error_setg(errp, "Could not set password"); + } +} + +void qmp_expire_password(ExpirePasswordOptions *opts, Error **errp) +{ + time_t when; + int rc; + const char *whenstr =3D opts->time; + const char *numstr =3D NULL; + uint64_t num; + + if (strcmp(whenstr, "now") =3D=3D 0) { + when =3D 0; + } else if (strcmp(whenstr, "never") =3D=3D 0) { + when =3D TIME_MAX; + } else if (whenstr[0] =3D=3D '+') { + when =3D time(NULL); + numstr =3D whenstr + 1; + } else { + when =3D 0; + numstr =3D whenstr; + } + + if (numstr) { + if (qemu_strtou64(numstr, NULL, 10, &num) < 0) { + error_setg(errp, "Parameter 'time' doesn't take value '%s'", + whenstr); + return; + } + when +=3D num; + } + + if (opts->protocol =3D=3D DISPLAY_PROTOCOL_SPICE) { + if (!qemu_using_spice(errp)) { + return; + } + rc =3D qemu_spice.set_pw_expire(when); + } else { + assert(opts->protocol =3D=3D DISPLAY_PROTOCOL_VNC); + rc =3D vnc_display_pw_expire(opts->u.vnc.display, when); + } + + if (rc !=3D 0) { + error_setg(errp, "Could not set password expire time"); + } +} + +#ifdef CONFIG_VNC +void qmp_change_vnc_password(const char *password, Error **errp) +{ + if (vnc_display_password(NULL, password) < 0) { + error_setg(errp, "Could not set password"); + } +} +#endif + +void qmp_add_client(const char *protocol, const char *fdname, + bool has_skipauth, bool skipauth, bool has_tls, bool t= ls, + Error **errp) +{ + Chardev *s; + int fd; + + fd =3D monitor_get_fd(monitor_cur(), fdname, errp); + if (fd < 0) { + return; + } + + if (strcmp(protocol, "spice") =3D=3D 0) { + if (!qemu_using_spice(errp)) { + close(fd); + return; + } + skipauth =3D has_skipauth ? skipauth : false; + tls =3D has_tls ? tls : false; + if (qemu_spice.display_add_client(fd, skipauth, tls) < 0) { + error_setg(errp, "spice failed to add client"); + close(fd); + } +#ifdef CONFIG_VNC + } else if (strcmp(protocol, "vnc") =3D=3D 0) { + skipauth =3D has_skipauth ? skipauth : false; + vnc_display_add_client(NULL, fd, skipauth); +#endif +#ifdef CONFIG_DBUS_DISPLAY + } else if (strcmp(protocol, "@dbus-display") =3D=3D 0) { + if (!qemu_using_dbus_display(errp)) { + close(fd); + return; + } + if (!qemu_dbus_display.add_client(fd, errp)) { + close(fd); + return; + } +#endif + } else { + s =3D qemu_chr_find(protocol); + if (!s) { + error_setg(errp, "protocol '%s' is invalid", protocol); + close(fd); + return; + } + if (qemu_chr_add_client(s, fd) < 0) { + error_setg(errp, "failed to add client"); + close(fd); + return; + } + } +} + +void qmp_display_reload(DisplayReloadOptions *arg, Error **errp) +{ + switch (arg->type) { + case DISPLAY_RELOAD_TYPE_VNC: +#ifdef CONFIG_VNC + if (arg->u.vnc.has_tls_certs && arg->u.vnc.tls_certs) { + vnc_display_reload_certs(NULL, errp); + } +#else + error_setg(errp, "vnc is invalid, missing 'CONFIG_VNC'"); +#endif + break; + default: + abort(); + } +} + +void qmp_display_update(DisplayUpdateOptions *arg, Error **errp) +{ + switch (arg->type) { + case DISPLAY_UPDATE_TYPE_VNC: +#ifdef CONFIG_VNC + vnc_display_update(&arg->u.vnc, errp); +#else + error_setg(errp, "vnc is invalid, missing 'CONFIG_VNC'"); +#endif + break; + default: + abort(); + } +} diff --git a/ui/meson.build b/ui/meson.build index c1b137bf33..9194ea335b 100644 --- a/ui/meson.build +++ b/ui/meson.build @@ -14,6 +14,7 @@ softmmu_ss.add(files( 'kbd-state.c', 'keymaps.c', 'qemu-pixman.c', + 'ui-qmp-cmds.c', 'util.c', )) if dbus_display --=20 2.37.3 From nobody Thu May 2 09:51:03 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1669875335; cv=none; d=zohomail.com; s=zohoarc; b=D9pQXe/keVN9Ga/TBaiuXDywj+zA0HlxBIpCbR/zflkP880pjbTvfIHEQMlXGwff/PMm0XF17+pEEbK7iNdwjMf+dRV5h+MX1MHYVAQKffg7RnKo3qz5Gst3WTBa4zznnH/FZszyKMOs+yPpBTktX3E5fKgBy4db10nMbhb4vYM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1669875335; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=+chbUGXcg1zhKLysWRz6t1/rxyszaLR1UqSqOtSB1qs=; b=LDMWw5x5lz1DtLmq6XdXA3uKNjiqcx5ssvKndRa41ZKZMMjQ2VlytFsW97HY7Carg0AMq6gVSlOOzpnICgBgLbMKCL6OxLK2HvvazW6xmcYpsKvQUXMUV1Em/sksRfn7u8zbcxuYlfZUqOwzDZD5fpzPKk+9YOrtjwcXqdpD354= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 166987533510424.106280292841006; Wed, 30 Nov 2022 22:15:35 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p0cp5-0005je-OK; Thu, 01 Dec 2022 01:13:28 -0500 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 1p0cp3-0005iG-VB for qemu-devel@nongnu.org; Thu, 01 Dec 2022 01:13:25 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p0cp0-0005mZ-G5 for qemu-devel@nongnu.org; Thu, 01 Dec 2022 01:13:25 -0500 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-468-PbiLaFO_MqKFWTYCBnwuAA-1; Thu, 01 Dec 2022 01:13:19 -0500 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 EF31D800186 for ; Thu, 1 Dec 2022 06:13:18 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.39.192.19]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8634C40C83C5; Thu, 1 Dec 2022 06:13:18 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id EC68421E65C6; Thu, 1 Dec 2022 07:13:11 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1669875200; h=from:from: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:references:references; bh=+chbUGXcg1zhKLysWRz6t1/rxyszaLR1UqSqOtSB1qs=; b=U1E/6L5N1DnWDID/T+F0NL36t19sPQ299lcUagy8Rw+d2GJ0ebVe92L3KFSGzz33z9uJU0 ttbZILqdawIZQ3hTg+RpuYvtCnH/G95IH0eYPsQEf2KyOJaFz2m39gSpCY1gVsk1fy0m9L BzY0neFXIko+WUf6giWC+72o8gsJTpg= X-MC-Unique: PbiLaFO_MqKFWTYCBnwuAA-1 From: Markus Armbruster To: qemu-devel@nongnu.org Cc: kraxel@redhat.com, dgilbert@redhat.com Subject: [PATCH 6/9] ui: Move HMP commands from monitor to new ui/ui-hmp-cmds.c Date: Thu, 1 Dec 2022 07:13:08 +0100 Message-Id: <20221201061311.3619052-7-armbru@redhat.com> In-Reply-To: <20221201061311.3619052-1-armbru@redhat.com> References: <20221201061311.3619052-1-armbru@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 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+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1669875336402100003 Content-Type: text/plain; charset="utf-8" This moves these commands from MAINTAINERS section "Human Monitor (HMP)" to "Graphics". Signed-off-by: Markus Armbruster Reviewed-by: Daniel P. Berrang=C3=A9 Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- monitor/hmp-cmds.c | 342 ------------------------------------------ ui/ui-hmp-cmds.c | 360 +++++++++++++++++++++++++++++++++++++++++++++ ui/meson.build | 1 + 3 files changed, 361 insertions(+), 342 deletions(-) create mode 100644 ui/ui-hmp-cmds.c diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c index 29fcc730cb..f0f7b74fb3 100644 --- a/monitor/hmp-cmds.c +++ b/monitor/hmp-cmds.c @@ -52,7 +52,6 @@ #include "qapi/string-input-visitor.h" #include "qapi/string-output-visitor.h" #include "qom/object_interfaces.h" -#include "ui/console.h" #include "qemu/cutils.h" #include "qemu/error-report.h" #include "hw/core/cpu.h" @@ -60,10 +59,6 @@ #include "migration/snapshot.h" #include "migration/misc.h" =20 -#ifdef CONFIG_SPICE -#include -#endif - bool hmp_handle_error(Monitor *mon, Error *err) { if (err) { @@ -179,26 +174,6 @@ void hmp_info_chardev(Monitor *mon, const QDict *qdict) qapi_free_ChardevInfoList(char_info); } =20 -void hmp_info_mice(Monitor *mon, const QDict *qdict) -{ - MouseInfoList *mice_list, *mouse; - - mice_list =3D qmp_query_mice(NULL); - if (!mice_list) { - monitor_printf(mon, "No mouse devices connected\n"); - return; - } - - for (mouse =3D mice_list; mouse; mouse =3D mouse->next) { - monitor_printf(mon, "%c Mouse #%" PRId64 ": %s%s\n", - mouse->value->current ? '*' : ' ', - mouse->value->index, mouse->value->name, - mouse->value->absolute ? " (absolute)" : ""); - } - - qapi_free_MouseInfoList(mice_list); -} - void hmp_info_migrate(Monitor *mon, const QDict *qdict) { MigrationInfo *info; @@ -518,169 +493,6 @@ void hmp_info_migrate_parameters(Monitor *mon, const = QDict *qdict) qapi_free_MigrationParameters(params); } =20 - -#ifdef CONFIG_VNC -/* Helper for hmp_info_vnc_clients, _servers */ -static void hmp_info_VncBasicInfo(Monitor *mon, VncBasicInfo *info, - const char *name) -{ - monitor_printf(mon, " %s: %s:%s (%s%s)\n", - name, - info->host, - info->service, - NetworkAddressFamily_str(info->family), - info->websocket ? " (Websocket)" : ""); -} - -/* Helper displaying and auth and crypt info */ -static void hmp_info_vnc_authcrypt(Monitor *mon, const char *indent, - VncPrimaryAuth auth, - VncVencryptSubAuth *vencrypt) -{ - monitor_printf(mon, "%sAuth: %s (Sub: %s)\n", indent, - VncPrimaryAuth_str(auth), - vencrypt ? VncVencryptSubAuth_str(*vencrypt) : "none"); -} - -static void hmp_info_vnc_clients(Monitor *mon, VncClientInfoList *client) -{ - while (client) { - VncClientInfo *cinfo =3D client->value; - - hmp_info_VncBasicInfo(mon, qapi_VncClientInfo_base(cinfo), "Client= "); - monitor_printf(mon, " x509_dname: %s\n", - cinfo->has_x509_dname ? - cinfo->x509_dname : "none"); - monitor_printf(mon, " sasl_username: %s\n", - cinfo->has_sasl_username ? - cinfo->sasl_username : "none"); - - client =3D client->next; - } -} - -static void hmp_info_vnc_servers(Monitor *mon, VncServerInfo2List *server) -{ - while (server) { - VncServerInfo2 *sinfo =3D server->value; - hmp_info_VncBasicInfo(mon, qapi_VncServerInfo2_base(sinfo), "Serve= r"); - hmp_info_vnc_authcrypt(mon, " ", sinfo->auth, - sinfo->has_vencrypt ? &sinfo->vencrypt : NU= LL); - server =3D server->next; - } -} - -void hmp_info_vnc(Monitor *mon, const QDict *qdict) -{ - VncInfo2List *info2l, *info2l_head; - Error *err =3D NULL; - - info2l =3D qmp_query_vnc_servers(&err); - info2l_head =3D info2l; - if (hmp_handle_error(mon, err)) { - return; - } - if (!info2l) { - monitor_printf(mon, "None\n"); - return; - } - - while (info2l) { - VncInfo2 *info =3D info2l->value; - monitor_printf(mon, "%s:\n", info->id); - hmp_info_vnc_servers(mon, info->server); - hmp_info_vnc_clients(mon, info->clients); - if (!info->server) { - /* - * The server entry displays its auth, we only need to - * display in the case of 'reverse' connections where - * there's no server. - */ - hmp_info_vnc_authcrypt(mon, " ", info->auth, - info->has_vencrypt ? &info->vencrypt : NULL= ); - } - if (info->has_display) { - monitor_printf(mon, " Display: %s\n", info->display); - } - info2l =3D info2l->next; - } - - qapi_free_VncInfo2List(info2l_head); - -} -#endif - -#ifdef CONFIG_SPICE -void hmp_info_spice(Monitor *mon, const QDict *qdict) -{ - SpiceChannelList *chan; - SpiceInfo *info; - const char *channel_name; - const char * const channel_names[] =3D { - [SPICE_CHANNEL_MAIN] =3D "main", - [SPICE_CHANNEL_DISPLAY] =3D "display", - [SPICE_CHANNEL_INPUTS] =3D "inputs", - [SPICE_CHANNEL_CURSOR] =3D "cursor", - [SPICE_CHANNEL_PLAYBACK] =3D "playback", - [SPICE_CHANNEL_RECORD] =3D "record", - [SPICE_CHANNEL_TUNNEL] =3D "tunnel", - [SPICE_CHANNEL_SMARTCARD] =3D "smartcard", - [SPICE_CHANNEL_USBREDIR] =3D "usbredir", - [SPICE_CHANNEL_PORT] =3D "port", - }; - - info =3D qmp_query_spice(NULL); - - if (!info->enabled) { - monitor_printf(mon, "Server: disabled\n"); - goto out; - } - - monitor_printf(mon, "Server:\n"); - if (info->has_port) { - monitor_printf(mon, " address: %s:%" PRId64 "\n", - info->host, info->port); - } - if (info->has_tls_port) { - monitor_printf(mon, " address: %s:%" PRId64 " [tls]\n", - info->host, info->tls_port); - } - monitor_printf(mon, " migrated: %s\n", - info->migrated ? "true" : "false"); - monitor_printf(mon, " auth: %s\n", info->auth); - monitor_printf(mon, " compiled: %s\n", info->compiled_version); - monitor_printf(mon, " mouse-mode: %s\n", - SpiceQueryMouseMode_str(info->mouse_mode)); - - if (!info->has_channels || info->channels =3D=3D NULL) { - monitor_printf(mon, "Channels: none\n"); - } else { - for (chan =3D info->channels; chan; chan =3D chan->next) { - monitor_printf(mon, "Channel:\n"); - monitor_printf(mon, " address: %s:%s%s\n", - chan->value->host, chan->value->port, - chan->value->tls ? " [tls]" : ""); - monitor_printf(mon, " session: %" PRId64 "\n", - chan->value->connection_id); - monitor_printf(mon, " channel: %" PRId64 ":%" PRId64 "\n", - chan->value->channel_type, chan->value->channel= _id); - - channel_name =3D "unknown"; - if (chan->value->channel_type > 0 && - chan->value->channel_type < ARRAY_SIZE(channel_names) && - channel_names[chan->value->channel_type]) { - channel_name =3D channel_names[chan->value->channel_type]; - } - - monitor_printf(mon, " channel name: %s\n", channel_name); - } - } - -out: - qapi_free_SpiceInfo(info); -} -#endif - void hmp_info_balloon(Monitor *mon, const QDict *qdict) { BalloonInfo *info; @@ -1375,71 +1187,6 @@ void hmp_x_colo_lost_heartbeat(Monitor *mon, const Q= Dict *qdict) hmp_handle_error(mon, err); } =20 -void hmp_set_password(Monitor *mon, const QDict *qdict) -{ - const char *protocol =3D qdict_get_str(qdict, "protocol"); - const char *password =3D qdict_get_str(qdict, "password"); - const char *display =3D qdict_get_try_str(qdict, "display"); - const char *connected =3D qdict_get_try_str(qdict, "connected"); - Error *err =3D NULL; - - SetPasswordOptions opts =3D { - .password =3D (char *)password, - .has_connected =3D !!connected, - }; - - opts.connected =3D qapi_enum_parse(&SetPasswordAction_lookup, connecte= d, - SET_PASSWORD_ACTION_KEEP, &err); - if (err) { - goto out; - } - - opts.protocol =3D qapi_enum_parse(&DisplayProtocol_lookup, protocol, - DISPLAY_PROTOCOL_VNC, &err); - if (err) { - goto out; - } - - if (opts.protocol =3D=3D DISPLAY_PROTOCOL_VNC) { - opts.u.vnc.has_display =3D !!display; - opts.u.vnc.display =3D (char *)display; - } - - qmp_set_password(&opts, &err); - -out: - hmp_handle_error(mon, err); -} - -void hmp_expire_password(Monitor *mon, const QDict *qdict) -{ - const char *protocol =3D qdict_get_str(qdict, "protocol"); - const char *whenstr =3D qdict_get_str(qdict, "time"); - const char *display =3D qdict_get_try_str(qdict, "display"); - Error *err =3D NULL; - - ExpirePasswordOptions opts =3D { - .time =3D (char *)whenstr, - }; - - opts.protocol =3D qapi_enum_parse(&DisplayProtocol_lookup, protocol, - DISPLAY_PROTOCOL_VNC, &err); - if (err) { - goto out; - } - - if (opts.protocol =3D=3D DISPLAY_PROTOCOL_VNC) { - opts.u.vnc.has_display =3D !!display; - opts.u.vnc.display =3D (char *)display; - } - - qmp_expire_password(&opts, &err); - -out: - hmp_handle_error(mon, err); -} - - #ifdef CONFIG_VNC static void hmp_change_read_arg(void *opaque, const char *password, void *readline_opaque) @@ -1637,95 +1384,6 @@ void hmp_closefd(Monitor *mon, const QDict *qdict) hmp_handle_error(mon, err); } =20 -void hmp_sendkey(Monitor *mon, const QDict *qdict) -{ - const char *keys =3D qdict_get_str(qdict, "keys"); - KeyValue *v =3D NULL; - KeyValueList *head =3D NULL, **tail =3D &head; - int has_hold_time =3D qdict_haskey(qdict, "hold-time"); - int hold_time =3D qdict_get_try_int(qdict, "hold-time", -1); - Error *err =3D NULL; - const char *separator; - int keyname_len; - - while (1) { - separator =3D qemu_strchrnul(keys, '-'); - keyname_len =3D separator - keys; - - /* Be compatible with old interface, convert user inputted "<" */ - if (keys[0] =3D=3D '<' && keyname_len =3D=3D 1) { - keys =3D "less"; - keyname_len =3D 4; - } - - v =3D g_malloc0(sizeof(*v)); - - if (strstart(keys, "0x", NULL)) { - const char *endp; - unsigned long value; - - if (qemu_strtoul(keys, &endp, 0, &value) < 0 - || value >=3D INT_MAX) { - goto err_out; - } - assert(endp <=3D keys + keyname_len); - if (endp !=3D keys + keyname_len) { - goto err_out; - } - v->type =3D KEY_VALUE_KIND_NUMBER; - v->u.number.data =3D value; - } else { - int idx =3D index_from_key(keys, keyname_len); - if (idx =3D=3D Q_KEY_CODE__MAX) { - goto err_out; - } - v->type =3D KEY_VALUE_KIND_QCODE; - v->u.qcode.data =3D idx; - } - QAPI_LIST_APPEND(tail, v); - v =3D NULL; - - if (!*separator) { - break; - } - keys =3D separator + 1; - } - - qmp_send_key(head, has_hold_time, hold_time, &err); - hmp_handle_error(mon, err); - -out: - qapi_free_KeyValue(v); - qapi_free_KeyValueList(head); - return; - -err_out: - monitor_printf(mon, "invalid parameter: %.*s\n", keyname_len, keys); - goto out; -} - -void coroutine_fn -hmp_screendump(Monitor *mon, const QDict *qdict) -{ - const char *filename =3D qdict_get_str(qdict, "filename"); - const char *id =3D qdict_get_try_str(qdict, "device"); - int64_t head =3D qdict_get_try_int(qdict, "head", 0); - const char *input_format =3D qdict_get_try_str(qdict, "format"); - Error *err =3D NULL; - ImageFormat format; - - format =3D qapi_enum_parse(&ImageFormat_lookup, input_format, - IMAGE_FORMAT_PPM, &err); - if (err) { - goto end; - } - - qmp_screendump(filename, id !=3D NULL, id, id !=3D NULL, head, - input_format !=3D NULL, format, &err); -end: - hmp_handle_error(mon, err); -} - void hmp_chardev_add(Monitor *mon, const QDict *qdict) { const char *args =3D qdict_get_str(qdict, "args"); diff --git a/ui/ui-hmp-cmds.c b/ui/ui-hmp-cmds.c new file mode 100644 index 0000000000..af290da9e1 --- /dev/null +++ b/ui/ui-hmp-cmds.c @@ -0,0 +1,360 @@ +/* + * Human Monitor Interface commands + * + * Copyright IBM, Corp. 2011 + * + * Authors: + * Anthony Liguori + * + * This work is licensed under the terms of the GNU GPL, version 2. See + * the COPYING file in the top-level directory. + * + * Contributions after 2012-01-13 are licensed under the terms of the + * GNU GPL, version 2 or (at your option) any later version. + */ + +#include "qemu/osdep.h" +#ifdef CONFIG_SPICE +#include +#endif +#include "monitor/hmp.h" +#include "monitor/monitor.h" +#include "qapi/qapi-commands-ui.h" +#include "qapi/qmp/qdict.h" +#include "qemu/cutils.h" +#include "ui/console.h" + +void hmp_info_mice(Monitor *mon, const QDict *qdict) +{ + MouseInfoList *mice_list, *mouse; + + mice_list =3D qmp_query_mice(NULL); + if (!mice_list) { + monitor_printf(mon, "No mouse devices connected\n"); + return; + } + + for (mouse =3D mice_list; mouse; mouse =3D mouse->next) { + monitor_printf(mon, "%c Mouse #%" PRId64 ": %s%s\n", + mouse->value->current ? '*' : ' ', + mouse->value->index, mouse->value->name, + mouse->value->absolute ? " (absolute)" : ""); + } + + qapi_free_MouseInfoList(mice_list); +} + +#ifdef CONFIG_VNC +/* Helper for hmp_info_vnc_clients, _servers */ +static void hmp_info_VncBasicInfo(Monitor *mon, VncBasicInfo *info, + const char *name) +{ + monitor_printf(mon, " %s: %s:%s (%s%s)\n", + name, + info->host, + info->service, + NetworkAddressFamily_str(info->family), + info->websocket ? " (Websocket)" : ""); +} + +/* Helper displaying and auth and crypt info */ +static void hmp_info_vnc_authcrypt(Monitor *mon, const char *indent, + VncPrimaryAuth auth, + VncVencryptSubAuth *vencrypt) +{ + monitor_printf(mon, "%sAuth: %s (Sub: %s)\n", indent, + VncPrimaryAuth_str(auth), + vencrypt ? VncVencryptSubAuth_str(*vencrypt) : "none"); +} + +static void hmp_info_vnc_clients(Monitor *mon, VncClientInfoList *client) +{ + while (client) { + VncClientInfo *cinfo =3D client->value; + + hmp_info_VncBasicInfo(mon, qapi_VncClientInfo_base(cinfo), "Client= "); + monitor_printf(mon, " x509_dname: %s\n", + cinfo->has_x509_dname ? + cinfo->x509_dname : "none"); + monitor_printf(mon, " sasl_username: %s\n", + cinfo->has_sasl_username ? + cinfo->sasl_username : "none"); + + client =3D client->next; + } +} + +static void hmp_info_vnc_servers(Monitor *mon, VncServerInfo2List *server) +{ + while (server) { + VncServerInfo2 *sinfo =3D server->value; + hmp_info_VncBasicInfo(mon, qapi_VncServerInfo2_base(sinfo), "Serve= r"); + hmp_info_vnc_authcrypt(mon, " ", sinfo->auth, + sinfo->has_vencrypt ? &sinfo->vencrypt : NU= LL); + server =3D server->next; + } +} + +void hmp_info_vnc(Monitor *mon, const QDict *qdict) +{ + VncInfo2List *info2l, *info2l_head; + Error *err =3D NULL; + + info2l =3D qmp_query_vnc_servers(&err); + info2l_head =3D info2l; + if (hmp_handle_error(mon, err)) { + return; + } + if (!info2l) { + monitor_printf(mon, "None\n"); + return; + } + + while (info2l) { + VncInfo2 *info =3D info2l->value; + monitor_printf(mon, "%s:\n", info->id); + hmp_info_vnc_servers(mon, info->server); + hmp_info_vnc_clients(mon, info->clients); + if (!info->server) { + /* + * The server entry displays its auth, we only need to + * display in the case of 'reverse' connections where + * there's no server. + */ + hmp_info_vnc_authcrypt(mon, " ", info->auth, + info->has_vencrypt ? &info->vencrypt : NULL= ); + } + if (info->has_display) { + monitor_printf(mon, " Display: %s\n", info->display); + } + info2l =3D info2l->next; + } + + qapi_free_VncInfo2List(info2l_head); + +} +#endif + +#ifdef CONFIG_SPICE +void hmp_info_spice(Monitor *mon, const QDict *qdict) +{ + SpiceChannelList *chan; + SpiceInfo *info; + const char *channel_name; + const char * const channel_names[] =3D { + [SPICE_CHANNEL_MAIN] =3D "main", + [SPICE_CHANNEL_DISPLAY] =3D "display", + [SPICE_CHANNEL_INPUTS] =3D "inputs", + [SPICE_CHANNEL_CURSOR] =3D "cursor", + [SPICE_CHANNEL_PLAYBACK] =3D "playback", + [SPICE_CHANNEL_RECORD] =3D "record", + [SPICE_CHANNEL_TUNNEL] =3D "tunnel", + [SPICE_CHANNEL_SMARTCARD] =3D "smartcard", + [SPICE_CHANNEL_USBREDIR] =3D "usbredir", + [SPICE_CHANNEL_PORT] =3D "port", + }; + + info =3D qmp_query_spice(NULL); + + if (!info->enabled) { + monitor_printf(mon, "Server: disabled\n"); + goto out; + } + + monitor_printf(mon, "Server:\n"); + if (info->has_port) { + monitor_printf(mon, " address: %s:%" PRId64 "\n", + info->host, info->port); + } + if (info->has_tls_port) { + monitor_printf(mon, " address: %s:%" PRId64 " [tls]\n", + info->host, info->tls_port); + } + monitor_printf(mon, " migrated: %s\n", + info->migrated ? "true" : "false"); + monitor_printf(mon, " auth: %s\n", info->auth); + monitor_printf(mon, " compiled: %s\n", info->compiled_version); + monitor_printf(mon, " mouse-mode: %s\n", + SpiceQueryMouseMode_str(info->mouse_mode)); + + if (!info->has_channels || info->channels =3D=3D NULL) { + monitor_printf(mon, "Channels: none\n"); + } else { + for (chan =3D info->channels; chan; chan =3D chan->next) { + monitor_printf(mon, "Channel:\n"); + monitor_printf(mon, " address: %s:%s%s\n", + chan->value->host, chan->value->port, + chan->value->tls ? " [tls]" : ""); + monitor_printf(mon, " session: %" PRId64 "\n", + chan->value->connection_id); + monitor_printf(mon, " channel: %" PRId64 ":%" PRId64 "\n", + chan->value->channel_type, chan->value->channel= _id); + + channel_name =3D "unknown"; + if (chan->value->channel_type > 0 && + chan->value->channel_type < ARRAY_SIZE(channel_names) && + channel_names[chan->value->channel_type]) { + channel_name =3D channel_names[chan->value->channel_type]; + } + + monitor_printf(mon, " channel name: %s\n", channel_name); + } + } + +out: + qapi_free_SpiceInfo(info); +} +#endif + +void hmp_set_password(Monitor *mon, const QDict *qdict) +{ + const char *protocol =3D qdict_get_str(qdict, "protocol"); + const char *password =3D qdict_get_str(qdict, "password"); + const char *display =3D qdict_get_try_str(qdict, "display"); + const char *connected =3D qdict_get_try_str(qdict, "connected"); + Error *err =3D NULL; + + SetPasswordOptions opts =3D { + .password =3D (char *)password, + .has_connected =3D !!connected, + }; + + opts.connected =3D qapi_enum_parse(&SetPasswordAction_lookup, connecte= d, + SET_PASSWORD_ACTION_KEEP, &err); + if (err) { + goto out; + } + + opts.protocol =3D qapi_enum_parse(&DisplayProtocol_lookup, protocol, + DISPLAY_PROTOCOL_VNC, &err); + if (err) { + goto out; + } + + if (opts.protocol =3D=3D DISPLAY_PROTOCOL_VNC) { + opts.u.vnc.has_display =3D !!display; + opts.u.vnc.display =3D (char *)display; + } + + qmp_set_password(&opts, &err); + +out: + hmp_handle_error(mon, err); +} + +void hmp_expire_password(Monitor *mon, const QDict *qdict) +{ + const char *protocol =3D qdict_get_str(qdict, "protocol"); + const char *whenstr =3D qdict_get_str(qdict, "time"); + const char *display =3D qdict_get_try_str(qdict, "display"); + Error *err =3D NULL; + + ExpirePasswordOptions opts =3D { + .time =3D (char *)whenstr, + }; + + opts.protocol =3D qapi_enum_parse(&DisplayProtocol_lookup, protocol, + DISPLAY_PROTOCOL_VNC, &err); + if (err) { + goto out; + } + + if (opts.protocol =3D=3D DISPLAY_PROTOCOL_VNC) { + opts.u.vnc.has_display =3D !!display; + opts.u.vnc.display =3D (char *)display; + } + + qmp_expire_password(&opts, &err); + +out: + hmp_handle_error(mon, err); +} + +void hmp_sendkey(Monitor *mon, const QDict *qdict) +{ + const char *keys =3D qdict_get_str(qdict, "keys"); + KeyValue *v =3D NULL; + KeyValueList *head =3D NULL, **tail =3D &head; + int has_hold_time =3D qdict_haskey(qdict, "hold-time"); + int hold_time =3D qdict_get_try_int(qdict, "hold-time", -1); + Error *err =3D NULL; + const char *separator; + int keyname_len; + + while (1) { + separator =3D qemu_strchrnul(keys, '-'); + keyname_len =3D separator - keys; + + /* Be compatible with old interface, convert user inputted "<" */ + if (keys[0] =3D=3D '<' && keyname_len =3D=3D 1) { + keys =3D "less"; + keyname_len =3D 4; + } + + v =3D g_malloc0(sizeof(*v)); + + if (strstart(keys, "0x", NULL)) { + const char *endp; + unsigned long value; + + if (qemu_strtoul(keys, &endp, 0, &value) < 0 + || value >=3D INT_MAX) { + goto err_out; + } + assert(endp <=3D keys + keyname_len); + if (endp !=3D keys + keyname_len) { + goto err_out; + } + v->type =3D KEY_VALUE_KIND_NUMBER; + v->u.number.data =3D value; + } else { + int idx =3D index_from_key(keys, keyname_len); + if (idx =3D=3D Q_KEY_CODE__MAX) { + goto err_out; + } + v->type =3D KEY_VALUE_KIND_QCODE; + v->u.qcode.data =3D idx; + } + QAPI_LIST_APPEND(tail, v); + v =3D NULL; + + if (!*separator) { + break; + } + keys =3D separator + 1; + } + + qmp_send_key(head, has_hold_time, hold_time, &err); + hmp_handle_error(mon, err); + +out: + qapi_free_KeyValue(v); + qapi_free_KeyValueList(head); + return; + +err_out: + monitor_printf(mon, "invalid parameter: %.*s\n", keyname_len, keys); + goto out; +} + +void coroutine_fn +hmp_screendump(Monitor *mon, const QDict *qdict) +{ + const char *filename =3D qdict_get_str(qdict, "filename"); + const char *id =3D qdict_get_try_str(qdict, "device"); + int64_t head =3D qdict_get_try_int(qdict, "head", 0); + const char *input_format =3D qdict_get_try_str(qdict, "format"); + Error *err =3D NULL; + ImageFormat format; + + format =3D qapi_enum_parse(&ImageFormat_lookup, input_format, + IMAGE_FORMAT_PPM, &err); + if (err) { + goto end; + } + + qmp_screendump(filename, id !=3D NULL, id, id !=3D NULL, head, + input_format !=3D NULL, format, &err); +end: + hmp_handle_error(mon, err); +} diff --git a/ui/meson.build b/ui/meson.build index 9194ea335b..612ea2325b 100644 --- a/ui/meson.build +++ b/ui/meson.build @@ -14,6 +14,7 @@ softmmu_ss.add(files( 'kbd-state.c', 'keymaps.c', 'qemu-pixman.c', + 'ui-hmp-cmds.c', 'ui-qmp-cmds.c', 'util.c', )) --=20 2.37.3 From nobody Thu May 2 09:51:03 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1669875313; cv=none; d=zohomail.com; s=zohoarc; b=ezeTT4K6AiMKanGwReF8QsjOFbLvgKK3CAQoK6oT/D4C8JlPtvribKx2/y9O3Ptg/FLeBCfNgtCagU4kHzN07h+ep9hp45qAVAn3jdIJjBLEv0qIAzXOcOfTcjgB1mjEP7bs14bB8YWlNB0hprRW9I+WH4VKL20iU7Q70Yuht1c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1669875313; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=s3mraL02whqE7GGSbymR+PEsAwhNJpgNaTJIuOzmgZI=; b=Wa83lhmnTOvyaqvWW15sDyYuHPQHuQbW+r60QaHNlclIM8Eb3U4H5zQHx+gMhOydajNjZwpWyzsxpJwF7uMNKrLlNgznPzM6EzBZLOmyyUU0PzBuRjdBZfGr2hNQnhQ2Fya7vbRyPZ2gtI2ACEFllxZNhIW8zDZl2J8CejAu0QI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1669875313268374.882963678191; Wed, 30 Nov 2022 22:15:13 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p0cp4-0005ib-Ae; Thu, 01 Dec 2022 01:13:26 -0500 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 1p0cp1-0005fu-AM for qemu-devel@nongnu.org; Thu, 01 Dec 2022 01:13:23 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p0coz-0005mg-PW for qemu-devel@nongnu.org; Thu, 01 Dec 2022 01:13:23 -0500 Received: from mimecast-mx02.redhat.com (mx3-rdu2.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-36-dWCO-t17PWWbA756qldnkA-1; Thu, 01 Dec 2022 01:13:18 -0500 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id B1FFB3C0D194 for ; Thu, 1 Dec 2022 06:13:18 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.39.192.19]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 862C2492B04; Thu, 1 Dec 2022 06:13:18 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id EEF0821E65C7; Thu, 1 Dec 2022 07:13:11 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1669875200; h=from:from: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:references:references; bh=s3mraL02whqE7GGSbymR+PEsAwhNJpgNaTJIuOzmgZI=; b=ePWk6b6DE2Hf8nyN+0nSxtCKpRkTnFoC/jzifHJOhh9NnlMNPnw4w4eEDw6yVdq+VxazDU pESpYLHZ+2KxFP27xAbJFyzIvLBnMWPGqc+ucfw8u1w8wuW5zmn7Rarq/xhWl+LsUY0Gfw FKXChfcFzNHX9zKqJ10kTDiruxLJryk= X-MC-Unique: dWCO-t17PWWbA756qldnkA-1 From: Markus Armbruster To: qemu-devel@nongnu.org Cc: kraxel@redhat.com, dgilbert@redhat.com Subject: [PATCH 7/9] ui: Improve "change vnc" error reporting Date: Thu, 1 Dec 2022 07:13:09 +0100 Message-Id: <20221201061311.3619052-8-armbru@redhat.com> In-Reply-To: <20221201061311.3619052-1-armbru@redhat.com> References: <20221201061311.3619052-1-armbru@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 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+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1669875314320100001 Content-Type: text/plain; charset="utf-8" Switch from monitor_printf() to error_setg() and hmp_handle_error(). This makes "this is an error" more obvious both in the source and in the monitor, where hmp_handle_error() prefixes the message with "Error: ". Signed-off-by: Markus Armbruster --- monitor/hmp-cmds.c | 8 ++++---- ui/ui-hmp-cmds.c | 22 ++++++++++++++++++++++ 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c index f0f7b74fb3..8542eee3d4 100644 --- a/monitor/hmp-cmds.c +++ b/monitor/hmp-cmds.c @@ -1209,9 +1209,8 @@ void hmp_change(Monitor *mon, const QDict *qdict) #ifdef CONFIG_VNC if (strcmp(device, "vnc") =3D=3D 0) { if (read_only) { - monitor_printf(mon, - "Parameter 'read-only-mode' is invalid for VNC\= n"); - return; + error_setg(&err, "Parameter 'read-only-mode' is invalid for VN= C"); + goto end; } if (strcmp(target, "passwd") =3D=3D 0 || strcmp(target, "password") =3D=3D 0) { @@ -1223,7 +1222,8 @@ void hmp_change(Monitor *mon, const QDict *qdict) qmp_change_vnc_password(arg, &err); } } else { - monitor_printf(mon, "Expected 'password' after 'vnc'\n"); + error_setg(&err, "Expected 'password' after 'vnc'"); + goto end; } } else #endif diff --git a/ui/ui-hmp-cmds.c b/ui/ui-hmp-cmds.c index af290da9e1..90a4f86f25 100644 --- a/ui/ui-hmp-cmds.c +++ b/ui/ui-hmp-cmds.c @@ -270,6 +270,28 @@ out: hmp_handle_error(mon, err); } =20 +void hmp_change_vnc(Monitor *mon, const char *device, const char *target, + const char *arg, const char *read_only, bool force, + Error **errp) +{ + if (read_only) { + error_setg(mon, "Parameter 'read-only-mode' is invalid for VNC"); + return; + } + if (strcmp(target, "passwd") =3D=3D 0 || + strcmp(target, "password") =3D=3D 0) { + if (!arg) { + MonitorHMP *hmp_mon =3D container_of(mon, MonitorHMP, common); + monitor_read_password(hmp_mon, hmp_change_read_arg, NULL); + return; + } else { + qmp_change_vnc_password(arg, &err); + } + } else { + monitor_printf(mon, "Expected 'password' after 'vnc'\n"); + } +} + void hmp_sendkey(Monitor *mon, const QDict *qdict) { const char *keys =3D qdict_get_str(qdict, "keys"); --=20 2.37.3 From nobody Thu May 2 09:51:03 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1669875348; cv=none; d=zohomail.com; s=zohoarc; b=hesj83B11JQdAO+zq3PEZHZxFnqecOuJDPC/I/AgN+1CRwfpJr/pK+ZYnMbf9rnrJqf93tVchtSNqT1J53MP+p2SaUkbSYzyMOQYpyOaoD+8hDzktAspEHl/tZbfxfHA3x0gFXH71WD7/+wHjfC+chKMblWT5kUNKPyvkAA7E7g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1669875348; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=fj06805Kwrz1rD5wI/A6Rga13IT0lfpTTqD194gMza8=; b=SYqJPXwExCOy4oQd6/xTFkmzvQFvb4FI+G0mERrUTjVMwHB5y9FaEEoSu5DHyq8smeBFSd8et7rVQK0yvOLSaTuVOmSNaVZJziOqGzcUKfNyXU35+ohL3c1jvyaKsg170d3eUBVaRuDzp/9/R4acfOpMMk+e4pshykv9oPROZjs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1669875348732282.9200781273611; Wed, 30 Nov 2022 22:15:48 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p0cp4-0005iv-VB; Thu, 01 Dec 2022 01:13:26 -0500 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 1p0cp2-0005gJ-Mb for qemu-devel@nongnu.org; Thu, 01 Dec 2022 01:13:24 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p0cp0-0005mq-5D for qemu-devel@nongnu.org; Thu, 01 Dec 2022 01:13:24 -0500 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-587-aqAK1NQhNB6BNmuGK_DbDg-1; Thu, 01 Dec 2022 01:13:19 -0500 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 D053685A588 for ; Thu, 1 Dec 2022 06:13:18 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.39.192.19]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8630940C2064; Thu, 1 Dec 2022 06:13:18 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id F151821E65C8; Thu, 1 Dec 2022 07:13:11 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1669875201; h=from:from: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:references:references; bh=fj06805Kwrz1rD5wI/A6Rga13IT0lfpTTqD194gMza8=; b=drCfzH3g/Gadndd3WapEtaz3CX4v8tRuihrSftM2KnyCtB3Jnud27FF0ffeXjmuk8thR8a rK9BaLYedeGb11cT5ap4tXEcWjjBmUaL3+iQrQx7LV90ZgxYCI6nkIVkmB4447rJU5xNPL YCbUcEcn5ptBTMDOYYT8eYBsLKVIo1k= X-MC-Unique: aqAK1NQhNB6BNmuGK_DbDg-1 From: Markus Armbruster To: qemu-devel@nongnu.org Cc: kraxel@redhat.com, dgilbert@redhat.com Subject: [PATCH 8/9] ui: Factor out hmp_change_vnc(), and move to ui/ui-hmp-cmds.c Date: Thu, 1 Dec 2022 07:13:10 +0100 Message-Id: <20221201061311.3619052-9-armbru@redhat.com> In-Reply-To: <20221201061311.3619052-1-armbru@redhat.com> References: <20221201061311.3619052-1-armbru@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 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+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1669875350425100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: Markus Armbruster Reviewed-by: Daniel P. Berrang=C3=A9 --- include/monitor/hmp.h | 5 +++++ monitor/hmp-cmds.c | 28 +--------------------------- ui/ui-hmp-cmds.c | 19 +++++++++++++++---- 3 files changed, 21 insertions(+), 31 deletions(-) diff --git a/include/monitor/hmp.h b/include/monitor/hmp.h index dfbc0c9a2f..992d91f181 100644 --- a/include/monitor/hmp.h +++ b/include/monitor/hmp.h @@ -73,6 +73,11 @@ void hmp_x_colo_lost_heartbeat(Monitor *mon, const QDict= *qdict); void hmp_set_password(Monitor *mon, const QDict *qdict); void hmp_expire_password(Monitor *mon, const QDict *qdict); void hmp_change(Monitor *mon, const QDict *qdict); +#ifdef CONFIG_VNC +void hmp_change_vnc(Monitor *mon, const char *device, const char *target, + const char *arg, const char *read_only, bool force, + Error **errp); +#endif void hmp_migrate(Monitor *mon, const QDict *qdict); void hmp_device_add(Monitor *mon, const QDict *qdict); void hmp_device_del(Monitor *mon, const QDict *qdict); diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c index 8542eee3d4..78bcdede85 100644 --- a/monitor/hmp-cmds.c +++ b/monitor/hmp-cmds.c @@ -42,7 +42,6 @@ #include "qapi/qapi-commands-run-state.h" #include "qapi/qapi-commands-stats.h" #include "qapi/qapi-commands-tpm.h" -#include "qapi/qapi-commands-ui.h" #include "qapi/qapi-commands-virtio.h" #include "qapi/qapi-visit-virtio.h" #include "qapi/qapi-visit-net.h" @@ -1187,15 +1186,6 @@ void hmp_x_colo_lost_heartbeat(Monitor *mon, const Q= Dict *qdict) hmp_handle_error(mon, err); } =20 -#ifdef CONFIG_VNC -static void hmp_change_read_arg(void *opaque, const char *password, - void *readline_opaque) -{ - qmp_change_vnc_password(password, NULL); - monitor_read_command(opaque, 1); -} -#endif - void hmp_change(Monitor *mon, const QDict *qdict) { const char *device =3D qdict_get_str(qdict, "device"); @@ -1208,23 +1198,7 @@ void hmp_change(Monitor *mon, const QDict *qdict) =20 #ifdef CONFIG_VNC if (strcmp(device, "vnc") =3D=3D 0) { - if (read_only) { - error_setg(&err, "Parameter 'read-only-mode' is invalid for VN= C"); - goto end; - } - if (strcmp(target, "passwd") =3D=3D 0 || - strcmp(target, "password") =3D=3D 0) { - if (!arg) { - MonitorHMP *hmp_mon =3D container_of(mon, MonitorHMP, comm= on); - monitor_read_password(hmp_mon, hmp_change_read_arg, NULL); - return; - } else { - qmp_change_vnc_password(arg, &err); - } - } else { - error_setg(&err, "Expected 'password' after 'vnc'"); - goto end; - } + hmp_change_vnc(mon, device, target, arg, read_only, force, &err); } else #endif { diff --git a/ui/ui-hmp-cmds.c b/ui/ui-hmp-cmds.c index 90a4f86f25..b1b18d5a5d 100644 --- a/ui/ui-hmp-cmds.c +++ b/ui/ui-hmp-cmds.c @@ -18,7 +18,8 @@ #include #endif #include "monitor/hmp.h" -#include "monitor/monitor.h" +#include "monitor/monitor-internal.h" +#include "qapi/error.h" #include "qapi/qapi-commands-ui.h" #include "qapi/qmp/qdict.h" #include "qemu/cutils.h" @@ -270,12 +271,20 @@ out: hmp_handle_error(mon, err); } =20 +#ifdef CONFIG_VNC +static void hmp_change_read_arg(void *opaque, const char *password, + void *readline_opaque) +{ + qmp_change_vnc_password(password, NULL); + monitor_read_command(opaque, 1); +} + void hmp_change_vnc(Monitor *mon, const char *device, const char *target, const char *arg, const char *read_only, bool force, Error **errp) { if (read_only) { - error_setg(mon, "Parameter 'read-only-mode' is invalid for VNC"); + error_setg(errp, "Parameter 'read-only-mode' is invalid for VNC"); return; } if (strcmp(target, "passwd") =3D=3D 0 || @@ -285,12 +294,14 @@ void hmp_change_vnc(Monitor *mon, const char *device,= const char *target, monitor_read_password(hmp_mon, hmp_change_read_arg, NULL); return; } else { - qmp_change_vnc_password(arg, &err); + qmp_change_vnc_password(arg, errp); } } else { - monitor_printf(mon, "Expected 'password' after 'vnc'\n"); + error_setg(errp, "Expected 'password' after 'vnc'"); + return; } } +#endif =20 void hmp_sendkey(Monitor *mon, const QDict *qdict) { --=20 2.37.3 From nobody Thu May 2 09:51:03 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1669875269; cv=none; d=zohomail.com; s=zohoarc; b=IHZRLHhRkUIFCjne1S8z5DmvM9AwtbzJZxaKqb17RzdSmsz7gefV2fbXQksapTxid99bk5FF5U0MGkr7tTms6zJN3jzlsLNDx+mRfEh67vXNXh1el1QiVz9Qw7iQsmwoxwskarfSSMw6IAmE2Hlt/7illiwSDPBTYkpD0WivcKE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1669875269; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=w53NfcJyeWiZyvfE3+PIaAUAWPbIvdAyglWPwpEtIcs=; b=iCU+bQBXGGB4aVWwwOcz595rf7rC4V8osj1j/cDmjEbXdQ98l60LR9wRqlCwbEr1IKkRttbMpgYOItI+m2uZyAp9RKd4NcBRHHvYF/cDrqpPni4aPjcaCs0s645uZGUB7+0L9ENThw4LHJpaBv8QjQtkqZgelj4+o1DbNSsTOnk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1669875269169651.2882590120131; Wed, 30 Nov 2022 22:14:29 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p0cp9-0005kE-OW; Thu, 01 Dec 2022 01:13:31 -0500 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 1p0cp5-0005jK-C5 for qemu-devel@nongnu.org; Thu, 01 Dec 2022 01:13:27 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p0cp3-0005mb-Vu for qemu-devel@nongnu.org; Thu, 01 Dec 2022 01:13:27 -0500 Received: from mimecast-mx02.redhat.com (mx3-rdu2.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-300-TADqhg8CNrq7BsnYUvfs3Q-1; Thu, 01 Dec 2022 01:13:18 -0500 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 AD8623C0D192 for ; Thu, 1 Dec 2022 06:13:18 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.39.192.19]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 85C264B3FC6; Thu, 1 Dec 2022 06:13:18 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id F36FE21E65C9; Thu, 1 Dec 2022 07:13:11 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1669875200; h=from:from: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:references:references; bh=w53NfcJyeWiZyvfE3+PIaAUAWPbIvdAyglWPwpEtIcs=; b=HRKml1TZFWWzVcgasM3gvs6F+H4RNN13TomjfiXiRnxrRtf8O+GFQxfEqfw+EseJk3SNUL ZWJ8hyixzlIft8v55yAGkyMkRSKjRqIfRe/QsXh6BnDUTCc9vZCxTtQpGqdtMWKrYrKPCA iRqRzoxQluQavfrZVPSE5V8DQBT1ZsE= X-MC-Unique: TADqhg8CNrq7BsnYUvfs3Q-1 From: Markus Armbruster To: qemu-devel@nongnu.org Cc: kraxel@redhat.com, dgilbert@redhat.com Subject: [PATCH 9/9] ui: Reduce nesting in hmp_change_vnc() slightly Date: Thu, 1 Dec 2022 07:13:11 +0100 Message-Id: <20221201061311.3619052-10-armbru@redhat.com> In-Reply-To: <20221201061311.3619052-1-armbru@redhat.com> References: <20221201061311.3619052-1-armbru@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 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+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1669875270120100001 Content-Type: text/plain; charset="utf-8" Transform if (good) { do stuff } else { handle error } to if (!good) { handle error return; } do stuff Signed-off-by: Markus Armbruster Reviewed-by: Daniel P. Berrang=C3=A9 Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- ui/ui-hmp-cmds.c | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/ui/ui-hmp-cmds.c b/ui/ui-hmp-cmds.c index b1b18d5a5d..31778122d3 100644 --- a/ui/ui-hmp-cmds.c +++ b/ui/ui-hmp-cmds.c @@ -287,19 +287,16 @@ void hmp_change_vnc(Monitor *mon, const char *device,= const char *target, error_setg(errp, "Parameter 'read-only-mode' is invalid for VNC"); return; } - if (strcmp(target, "passwd") =3D=3D 0 || - strcmp(target, "password") =3D=3D 0) { - if (!arg) { - MonitorHMP *hmp_mon =3D container_of(mon, MonitorHMP, common); - monitor_read_password(hmp_mon, hmp_change_read_arg, NULL); - return; - } else { - qmp_change_vnc_password(arg, errp); - } - } else { + if (strcmp(target, "passwd") && strcmp(target, "password")) { error_setg(errp, "Expected 'password' after 'vnc'"); return; } + if (!arg) { + MonitorHMP *hmp_mon =3D container_of(mon, MonitorHMP, common); + monitor_read_password(hmp_mon, hmp_change_read_arg, NULL); + } else { + qmp_change_vnc_password(arg, errp); + } } #endif =20 --=20 2.37.3