From nobody Wed May 15 18:47:10 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=1673291042; cv=none; d=zohomail.com; s=zohoarc; b=cwl5QhKsxCv3xGUJ1wwqkxk2tvKcn38bXObrjGWjfFBo+mca0bRsvPA+H0Mg8o4f1NeYX7Rxt9tBJS94morwFKEwv7//o/6j0rtMh2uSehtPWNeA2VNLJtCKLcnDEUSxn/pwsRjhxCei/PbQHcLO2waaCWbPbbOnLWeYfoYpT8U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1673291042; 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=HEsDidP6dhhgOH1NXjLSsVAhqjLxIUuegUoLyL6521M=; b=nLa1CiXaOpkdLuj41c5WaZxcnWk/zztJbrXEIxT+1KdiG7AAIUDi5WGOPxaAslf+oKJKnY/S6ROMVx7mlMKWHdBDRCtCdIIcfhlEkTBYgVOnXi2LXfvMBhKOM5JIRtCiM8bItko+e3+ygv8RW2LPb4DeaJ7J4DmkHVrdfdOn3wo= 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 16732910423831007.8065087613346; Mon, 9 Jan 2023 11:04:02 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pExR2-00043P-0A; Mon, 09 Jan 2023 14:03:52 -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 1pExQn-0003xK-UB for qemu-devel@nongnu.org; Mon, 09 Jan 2023 14:03:38 -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 1pExQj-0001Ho-Tx for qemu-devel@nongnu.org; Mon, 09 Jan 2023 14:03:37 -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-424-LatkG1FwM2eAMdEcPPPA1w-1; Mon, 09 Jan 2023 14:03:23 -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 EECBE811E6E; Mon, 9 Jan 2023 19:03:22 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.39.192.78]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C4C17492B00; Mon, 9 Jan 2023 19:03:22 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 8684221E5DF6; Mon, 9 Jan 2023 20:03:21 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1673291004; 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=HEsDidP6dhhgOH1NXjLSsVAhqjLxIUuegUoLyL6521M=; b=jDre8vF0ocqDvnLa3vJXOGRrolfisToBMohQM7JKu74VkS6japWwP3xwjshkJwOUHiwg+f ZMGrr+XUl3qJL/R53hQ8Cufk2xbXfzicJB993qiwCG7X9+3RffU09USk1xi1RNPyylTcuM 9988jCQKk9rwfiLsAfPKy9hgVickpRA= X-MC-Unique: LatkG1FwM2eAMdEcPPPA1w-1 From: Markus Armbruster To: qemu-devel@nongnu.org Cc: kraxel@redhat.com, dgilbert@redhat.com, berrange@redhat.com, philmd@linaro.org Subject: [PATCH v4 01/17] ui: Check numeric part of expire_password argument @time properly Date: Mon, 9 Jan 2023 20:03:05 +0100 Message-Id: <20230109190321.1056914-2-armbru@redhat.com> In-Reply-To: <20230109190321.1056914-1-armbru@redhat.com> References: <20230109190321.1056914-1-armbru@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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: 1673291044060100003 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 2932b3f3a5..a1695b6c96 100644 --- a/monitor/qmp-cmds.c +++ b/monitor/qmp-cmds.c @@ -201,15 +201,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.39.0 From nobody Wed May 15 18:47:10 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=1673291083; cv=none; d=zohomail.com; s=zohoarc; b=UyFFGdegoeC7Jp0Ux5XTBSxgRJLh5AhUYBr713Q0cu20yVB57STuarMZCbMiUEHES6W1pXHYpMNYLbH05mMGpvABu8ukPqQuKB1flAAzxoyvwHmJWHfq1hQw5QA8m3h27OFFZFMGt7yR19bKQs9ZcDC2I7TADaOuvWxCvLTFpB4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1673291083; 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=Iq3ircQk4NClykeCG1pk+aHE1+YGDN0nvrJCti317v8=; b=UWGaN6ZuGR43Khlsvcv5qwbGZ5WAmzcIkIbq1t41lP9hKVfCGOnBAgXkSQIAY1/lfUd2jtAaBNCPRhDaOmLfx0s39tsXPBmd2SCeYdLNQTbFI04WfhmH09iUln49dTuERJM3mOeK0GXKTgvtbIZjL6PQ/kEYtJV7GR4Q/JoKKnw= 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 1673291083191993.9029813977643; Mon, 9 Jan 2023 11:04:43 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pExRY-0004RT-LE; Mon, 09 Jan 2023 14:04: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 1pExQn-0003xI-RQ for qemu-devel@nongnu.org; Mon, 09 Jan 2023 14:03:38 -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 1pExQk-0001IF-6e for qemu-devel@nongnu.org; Mon, 09 Jan 2023 14:03:37 -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-649-T7vcFawOMamKMdD4dTiL-g-1; Mon, 09 Jan 2023 14:03:23 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id F3FEA80234E; Mon, 9 Jan 2023 19:03:22 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.39.192.78]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C450B53AA; Mon, 9 Jan 2023 19:03:22 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 89AA321E5DF8; Mon, 9 Jan 2023 20:03:21 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1673291006; 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=Iq3ircQk4NClykeCG1pk+aHE1+YGDN0nvrJCti317v8=; b=V1MsqjuUZonwRX+A7PVpYsfHnYkJCViFqGqbt8nytQacNMibbjLA7awhkCw+IFvzDu1A4S 4w/kguZOKGUUdhQGxBD4/x+HxQ6CuqvsIEe0jHjVEFeaDlDJQbiYcE5Uq2vNVq9C1gg3v9 mbZVSHOJrdS0P3eyi/wIHaFkOST95HI= X-MC-Unique: T7vcFawOMamKMdD4dTiL-g-1 From: Markus Armbruster To: qemu-devel@nongnu.org Cc: kraxel@redhat.com, dgilbert@redhat.com, berrange@redhat.com, philmd@linaro.org Subject: [PATCH v4 02/17] ui: Fix silent truncation of numeric keys in HMP sendkey Date: Mon, 9 Jan 2023 20:03:06 +0100 Message-Id: <20230109190321.1056914-3-armbru@redhat.com> In-Reply-To: <20230109190321.1056914-1-armbru@redhat.com> References: <20230109190321.1056914-1-armbru@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 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: 1673291084209100007 Keys are int. HMP sendkey assigns them from the value strtoul(), silently truncating values greater than INT_MAX. Fix to reject them. Signed-off-by: Markus Armbruster Reviewed-by: Daniel P. Berrang=C3=A9 Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- monitor/hmp-cmds.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c index ed78a87ddd..9947ff0b45 100644 --- a/monitor/hmp-cmds.c +++ b/monitor/hmp-cmds.c @@ -1549,8 +1549,12 @@ 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; + int value; + + if (qemu_strtoi(keys, &endp, 0, &value) < 0) { + goto err_out; + } assert(endp <=3D keys + keyname_len); if (endp !=3D keys + keyname_len) { goto err_out; --=20 2.39.0 From nobody Wed May 15 18:47:10 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=1673291311; cv=none; d=zohomail.com; s=zohoarc; b=frltxuaKcl11dcfl3NYh46olwiLScNg8FieCXrsorwhgwMhy+a+0tC8y+ZZJXfGRItr9Q6YnHz9MbiLAlwO3bwX6Rn2SrFBki/P6R0/U4h5piMiAfeo0IDD5yzLNEBfINoEQ+YSAt6SBQn2riDk1WmgTERqqsxXwCjzgPuhli7Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1673291311; 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=xR537m9WRO2ahsrbYoPqDxcs+cU2uG/AJ3h4T0n/E6Q=; b=fCDxjSE1B2ecquKKbXeeDK8Nzk/GXflv4xH6sYhWzFuDfuX4szbv1i8eqBX5lVsT4o4Yi/ZkYgYC7YdLkTQ6lhDaUaAvZHcgunJ/Mv3GVZf5LmsEiqM+n6GotiSOyX3Jn6iuA8pzPsfFbaBPLJgRMGMlMYFQQ96fdxJD3wSEfvQ= 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 1673291311186342.80861266384954; Mon, 9 Jan 2023 11:08:31 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pExRj-0004rU-FN; Mon, 09 Jan 2023 14:04:35 -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 1pExQl-0003ww-V2 for qemu-devel@nongnu.org; Mon, 09 Jan 2023 14:03:38 -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 1pExQh-0001Hk-QL for qemu-devel@nongnu.org; Mon, 09 Jan 2023 14:03:34 -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-649-xacOnqKlOgSKjz2z1ndArQ-1; Mon, 09 Jan 2023 14:03:23 -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 03864857F82; Mon, 9 Jan 2023 19:03:23 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.39.192.78]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C3E201121319; Mon, 9 Jan 2023 19:03:22 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 8E76021E5DF9; Mon, 9 Jan 2023 20:03:21 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1673291004; 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=xR537m9WRO2ahsrbYoPqDxcs+cU2uG/AJ3h4T0n/E6Q=; b=R+5UEoHb0I6myW4kiLhL3Pd+xTdZXlbHMcyJ+3S/asqZSBUSniTK9rb1Qy2sKfQcPmwpxt jWVgtDSjJ7fiO8cQkckL12I8O6lOd+oti6fLu0YA9Am8+18GVo/pK15zXaSkkyfBndRnHW cMaAB/XwRsvlejqQDkAs/Y7H4iYVtGY= X-MC-Unique: xacOnqKlOgSKjz2z1ndArQ-1 From: Markus Armbruster To: qemu-devel@nongnu.org Cc: kraxel@redhat.com, dgilbert@redhat.com, berrange@redhat.com, philmd@linaro.org Subject: [PATCH v4 03/17] ui/spice: Require spice-protocol >= 0.14.0 Date: Mon, 9 Jan 2023 20:03:07 +0100 Message-Id: <20230109190321.1056914-4-armbru@redhat.com> In-Reply-To: <20230109190321.1056914-1-armbru@redhat.com> References: <20230109190321.1056914-1-armbru@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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: 1673291311503100001 Version 0.14.0 is now old enough to have made it into the major distributions: Debian 11: 0.14.3 RHEL-8: 0.14.2 FreeBSD (ports): 0.14.4 Fedora 35: 0.14.0 Ubuntu 20.04: 0.14.0 OpenSUSE Leap 15.3: 0.14.3 Requiring it lets us drop two version checks in ui/vdagent.c. It also enables the next commit. Signed-off-by: Markus Armbruster Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Daniel P. Berrang=C3=A9 --- meson.build | 2 +- ui/vdagent.c | 4 ---- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/meson.build b/meson.build index 175517eafd..8fabfbcf95 100644 --- a/meson.build +++ b/meson.build @@ -742,7 +742,7 @@ endif =20 spice_protocol =3D not_found if not get_option('spice_protocol').auto() or have_system - spice_protocol =3D dependency('spice-protocol', version: '>=3D0.12.3', + spice_protocol =3D dependency('spice-protocol', version: '>=3D0.14.0', required: get_option('spice_protocol'), method: 'pkg-config', kwargs: static_kwargs) endif diff --git a/ui/vdagent.c b/ui/vdagent.c index 4bf50f0c4d..1f51a78da1 100644 --- a/ui/vdagent.c +++ b/ui/vdagent.c @@ -87,9 +87,7 @@ static const char *cap_name[] =3D { [VD_AGENT_CAP_MONITORS_CONFIG_POSITION] =3D "monitors-config-pos= ition", [VD_AGENT_CAP_FILE_XFER_DISABLED] =3D "file-xfer-disabled", [VD_AGENT_CAP_FILE_XFER_DETAILED_ERRORS] =3D "file-xfer-detailed-= errors", -#if CHECK_SPICE_PROTOCOL_VERSION(0, 14, 0) [VD_AGENT_CAP_GRAPHICS_DEVICE_INFO] =3D "graphics-device-inf= o", -#endif #if CHECK_SPICE_PROTOCOL_VERSION(0, 14, 1) [VD_AGENT_CAP_CLIPBOARD_NO_RELEASE_ON_REGRAB] =3D "clipboard-no-releas= e-on-regrab", [VD_AGENT_CAP_CLIPBOARD_GRAB_SERIAL] =3D "clipboard-grab-seri= al", @@ -112,9 +110,7 @@ static const char *msg_name[] =3D { [VD_AGENT_CLIENT_DISCONNECTED] =3D "client-disconnected", [VD_AGENT_MAX_CLIPBOARD] =3D "max-clipboard", [VD_AGENT_AUDIO_VOLUME_SYNC] =3D "audio-volume-sync", -#if CHECK_SPICE_PROTOCOL_VERSION(0, 14, 0) [VD_AGENT_GRAPHICS_DEVICE_INFO] =3D "graphics-device-info", -#endif }; =20 static const char *sel_name[] =3D { --=20 2.39.0 From nobody Wed May 15 18:47:10 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=1673291072; cv=none; d=zohomail.com; s=zohoarc; b=kE/tbSV0DImDS444toCi5ckFGQfGBatWLk8rDwGruYKqCKbTFcQI50q+KJKo6CsUMOKVHlDkXDZemTrSocEttf3vnL7wh1MHgwRC+YXHuvDpCQljIgtGQSYDIJjw0SYBUqgXGF+h2opFYXp7ymH1/5gr4yqAYD4zBk31lSKWQZs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1673291072; 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=xaJyR4agGYr5y49FQtiUz5de91ILyd/LcvQho4CUPhA=; b=L/Eg7WUuzZ8gsxMqtM80hUiBvBcxXZ1y5TvnTl5VKagiBni0+a3OndYP8ph8j2S92Gch8Rp+D6PvCzVB3vpsVdwSd13S73FBMn4Rp5h3r4O3vX++mLMP1II6TaYmsQNuutkeTYiYK4r5k1Pfp6YVlHGL88D6+knpFPIUxIauXoE= 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 1673291072628583.1656168547291; Mon, 9 Jan 2023 11:04:32 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pExRL-000456-33; Mon, 09 Jan 2023 14:04:11 -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 1pExQn-0003xD-57 for qemu-devel@nongnu.org; Mon, 09 Jan 2023 14:03:38 -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 1pExQj-0001Hm-JD for qemu-devel@nongnu.org; Mon, 09 Jan 2023 14:03:36 -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-613-Z2eZdWZEOxeCfI9mOiIjAA-1; Mon, 09 Jan 2023 14:03:23 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id F397B1C09040; Mon, 9 Jan 2023 19:03:22 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.39.192.78]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C46C8175AD; Mon, 9 Jan 2023 19:03:22 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 928AB21E5DFF; Mon, 9 Jan 2023 20:03:21 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1673291004; 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=xaJyR4agGYr5y49FQtiUz5de91ILyd/LcvQho4CUPhA=; b=eBWtijrU3asBMVfjv5ANNEVriBbEcKSJ7r74RuBsyAr5LTQpKUSXqocv4WDPJwNVKcv8MH fHNmA2JipZlt7rFnICphimXMcjkDDtvDPqXCqfMpOXvK2Ti+VQVqnF9g1R2HlWz1fsVw1a DTig5oPag0dKLjsDWu88hAGq6oi/t9I= X-MC-Unique: Z2eZdWZEOxeCfI9mOiIjAA-1 From: Markus Armbruster To: qemu-devel@nongnu.org Cc: kraxel@redhat.com, dgilbert@redhat.com, berrange@redhat.com, philmd@linaro.org Subject: [PATCH v4 04/17] Revert "hmp: info spice: take out webdav" Date: Mon, 9 Jan 2023 20:03:08 +0100 Message-Id: <20230109190321.1056914-5-armbru@redhat.com> In-Reply-To: <20230109190321.1056914-1-armbru@redhat.com> References: <20230109190321.1056914-1-armbru@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 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: 1673291074154100003 This reverts commit 7c6044a94e52db8aef9a71d616c7a0914adb71ab. We had to take it out because SPICE_CHANNEL_WEBDAV requires spice-protocol 0.12.7, but we had only 0.12.3. We have 0.14.0 now, so put it back in. Signed-off-by: Markus Armbruster Reviewed-by: Daniel P. Berrang=C3=A9 --- monitor/hmp-cmds.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c index 9947ff0b45..67e39f408e 100644 --- a/monitor/hmp-cmds.c +++ b/monitor/hmp-cmds.c @@ -622,12 +622,7 @@ 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.39.0 From nobody Wed May 15 18:47:10 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=1673291169; cv=none; d=zohomail.com; s=zohoarc; b=bcC9dRhBU8G9q5N9bxHlQtobSvp0LETDdOhOC/2SBjHFYNKuAjNIiccolOIg8ROxXPSbkVx0Me6S6Ai1Qbw6HGg4RFHrDj9aIT4v2jv5x/aok88eg4ipuGhIdv5OfA1dj4cKgYKqRCEVlsD+6krp7h+rDHkDgQH8NjI5YOAdOK0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1673291169; 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=jpRGMSnjdQBFdYzT7kRqcM9X4dCB5RwVGG+X1Gtf2KU=; b=c13k4qiFP8SqjXDKAAoEJjCOn/RwTo81vxGeeh97zwohhxhqKt8Lv+ceQR69QZvTDV0B3Nd+2lrgaouLXx6+AVWzfisAHM8CbPRS30oAXi+i19VAiI9jPSPwtPOuZc76ZqV9GnE1VkLCs6Pfd/6fsJMYe9Iabar49pp2GPAemcQ= 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 1673291169571638.0791476268092; Mon, 9 Jan 2023 11:06:09 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pExRY-0004Qn-AK; Mon, 09 Jan 2023 14:04: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 1pExQn-0003xF-9B for qemu-devel@nongnu.org; Mon, 09 Jan 2023 14:03:38 -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 1pExQj-0001JB-Jf for qemu-devel@nongnu.org; Mon, 09 Jan 2023 14:03:36 -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-256-I-fsgrzyPSmdTc_caZ8o1Q-1; Mon, 09 Jan 2023 14:03:24 -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 86B8E857F42; Mon, 9 Jan 2023 19:03:24 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.39.192.78]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 3EA3740C2004; Mon, 9 Jan 2023 19:03:24 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 9724121E675B; Mon, 9 Jan 2023 20:03:21 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1673291008; 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=jpRGMSnjdQBFdYzT7kRqcM9X4dCB5RwVGG+X1Gtf2KU=; b=QZ99nwupZmkr84umoPxYMMX14NRH3KqgZ7HV/zQWKeArhaJ46jk2rF8HvyJbDln7RcS76g Cz5C6VfCF9bCTQrVxaYWmHnFvGmxow3Z0A3etqg3g/ymETRzgh3RIf5PVm+03oP9VXODgK hKnBShUJHkfdSyd9mba7Cd0FA9RAvbA= X-MC-Unique: I-fsgrzyPSmdTc_caZ8o1Q-1 From: Markus Armbruster To: qemu-devel@nongnu.org Cc: kraxel@redhat.com, dgilbert@redhat.com, berrange@redhat.com, philmd@linaro.org Subject: [PATCH v4 05/17] ui/spice: Require spice-server >= 0.14.0 Date: Mon, 9 Jan 2023 20:03:09 +0100 Message-Id: <20230109190321.1056914-6-armbru@redhat.com> In-Reply-To: <20230109190321.1056914-1-armbru@redhat.com> References: <20230109190321.1056914-1-armbru@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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: 1673291170679100003 Version 0.14.0 is now old enough to have made it into the major distributions: Debian 11: 0.14.3 RHEL-8: 0.14.3 FreeBSD (ports): 0.15.0 Fedora 35: 0.15.0 Ubuntu 20.04: 0.14.2 OpenSUSE Leap 15.3: 0.14.3 Requiring it lets us drop a number of version checks. The next commit will clean up some more. Signed-off-by: Markus Armbruster Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Daniel P. Berrang=C3=A9 --- meson.build | 2 +- hw/display/qxl.h | 2 -- include/ui/qemu-spice.h | 6 +----- include/ui/spice-display.h | 2 -- chardev/spice.c | 2 -- hw/display/qxl.c | 7 +------ 6 files changed, 3 insertions(+), 18 deletions(-) diff --git a/meson.build b/meson.build index 8fabfbcf95..4bc0a482b5 100644 --- a/meson.build +++ b/meson.build @@ -748,7 +748,7 @@ if not get_option('spice_protocol').auto() or have_syst= em endif spice =3D not_found if not get_option('spice').auto() or have_system - spice =3D dependency('spice-server', version: '>=3D0.12.5', + spice =3D dependency('spice-server', version: '>=3D0.14.0', required: get_option('spice'), method: 'pkg-config', kwargs: static_kwargs) endif diff --git a/hw/display/qxl.h b/hw/display/qxl.h index 7894bd5134..5bec25cdd3 100644 --- a/hw/display/qxl.h +++ b/hw/display/qxl.h @@ -100,9 +100,7 @@ struct PCIQXLDevice { QXLModes *modes; uint32_t rom_size; MemoryRegion rom_bar; -#if SPICE_SERVER_VERSION >=3D 0x000c06 /* release 0.12.6 */ uint16_t max_outputs; -#endif =20 /* vram pci bar */ uint64_t vram_size; diff --git a/include/ui/qemu-spice.h b/include/ui/qemu-spice.h index 21fe195e18..a7a1890b3f 100644 --- a/include/ui/qemu-spice.h +++ b/include/ui/qemu-spice.h @@ -34,13 +34,9 @@ int qemu_spice_add_display_interface(QXLInstance *qxlin,= QemuConsole *con); int qemu_spice_migrate_info(const char *hostname, int port, int tls_port, const char *subject); =20 -#if !defined(SPICE_SERVER_VERSION) || (SPICE_SERVER_VERSION < 0xc06) -#define SPICE_NEEDS_SET_MM_TIME 1 -#else #define SPICE_NEEDS_SET_MM_TIME 0 -#endif =20 -#if defined(SPICE_SERVER_VERSION) && (SPICE_SERVER_VERSION >=3D 0x000f00) +#if SPICE_SERVER_VERSION >=3D 0x000f00 /* release 0.15.0 */ #define SPICE_HAS_ATTACHED_WORKER 1 #else #define SPICE_HAS_ATTACHED_WORKER 0 diff --git a/include/ui/spice-display.h b/include/ui/spice-display.h index e271e011da..5aa13664d6 100644 --- a/include/ui/spice-display.h +++ b/include/ui/spice-display.h @@ -28,11 +28,9 @@ #include "ui/console.h" =20 #if defined(CONFIG_OPENGL) && defined(CONFIG_GBM) -# if SPICE_SERVER_VERSION >=3D 0x000d01 /* release 0.13.1 */ # define HAVE_SPICE_GL 1 # include "ui/egl-helpers.h" # include "ui/egl-context.h" -# endif #endif =20 #define NUM_MEMSLOTS 8 diff --git a/chardev/spice.c b/chardev/spice.c index bbffef4913..e843d961a7 100644 --- a/chardev/spice.c +++ b/chardev/spice.c @@ -98,9 +98,7 @@ static SpiceCharDeviceInterface vmc_interface =3D { .write =3D vmc_write, .read =3D vmc_read, .event =3D vmc_event, -#if SPICE_SERVER_VERSION >=3D 0x000c06 .flags =3D SPICE_CHAR_DEVICE_NOTIFY_WRITABLE, -#endif }; =20 =20 diff --git a/hw/display/qxl.c b/hw/display/qxl.c index 6772849dec..ddca611804 100644 --- a/hw/display/qxl.c +++ b/hw/display/qxl.c @@ -260,8 +260,7 @@ static void qxl_spice_monitors_config_async(PCIQXLDevic= e *qxl, int replay) QXL_COOKIE_TYPE_POST_LOAD_MONITORS_CONFIG, 0)); } else { -/* >=3D release 0.12.6, < release 0.14.2 */ -#if SPICE_SERVER_VERSION >=3D 0x000c06 && SPICE_SERVER_VERSION < 0x000e02 +#if SPICE_SERVER_VERSION < 0x000e02 /* release 0.14.2 */ if (qxl->max_outputs) { spice_qxl_set_max_monitors(&qxl->ssd.qxl, qxl->max_outputs); } @@ -1089,12 +1088,10 @@ static int interface_client_monitors_config(QXLInst= ance *sin, return 1; } =20 -#if SPICE_SERVER_VERSION >=3D 0x000c06 /* release 0.12.6 */ /* limit number of outputs based on setting limit */ if (qxl->max_outputs && qxl->max_outputs <=3D max_outputs) { max_outputs =3D qxl->max_outputs; } -#endif =20 config_changed =3D qxl_rom_monitors_config_changed(rom, monitors_config, @@ -2487,9 +2484,7 @@ static Property qxl_properties[] =3D { DEFINE_PROP_UINT32("vram64_size_mb", PCIQXLDevice, vram_size_mb, -= 1), DEFINE_PROP_UINT32("vgamem_mb", PCIQXLDevice, vgamem_size_mb, 16), DEFINE_PROP_INT32("surfaces", PCIQXLDevice, ssd.num_surfaces, 1024= ), -#if SPICE_SERVER_VERSION >=3D 0x000c06 /* release 0.12.6 */ DEFINE_PROP_UINT16("max_outputs", PCIQXLDevice, max_outputs, 0), -#endif DEFINE_PROP_UINT32("xres", PCIQXLDevice, xres, 0), DEFINE_PROP_UINT32("yres", PCIQXLDevice, yres, 0), DEFINE_PROP_BOOL("global-vmstate", PCIQXLDevice, vga.global_vmstat= e, false), --=20 2.39.0 From nobody Wed May 15 18:47:10 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=1673291471; cv=none; d=zohomail.com; s=zohoarc; b=WROPk8GSWEJtHU+GeNP8OXlLF2DpFaHhEASA6vPxUNTqYU9Ho6oCm5W6SWZ2O4aBq2B4iaMkmYiX0H70HB2hy32bRlzX9Cpz3rYGEwjM28UVp2OLc1g5ZPoDDs+NnIS55Hk6cEBIoiDC4OqCjjXKSJ8EGuWUHZxgjZehsalWX3g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1673291471; 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=RpbsE2fyjkujcmeZQWxNTb24jacEp2MlGdC7VShemms=; b=NdjHeRg4LxrYOI9hzDQGrAh7okt9YqX+NlXSMvGyOROcWUD/1NRv6xrmtG47JmPQ4eySmSe9061w7mpcM3rphq01+M4KHdL8N37ePsIw2zedpRcqRN6/nsk1lawwswGVHTloWaxlj83Lrd5nJjcI/o6jg7cRUJi5rQAD3qWZSCM= 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 1673291471480459.28056887036746; Mon, 9 Jan 2023 11:11:11 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pExRc-0004ej-Qg; Mon, 09 Jan 2023 14:04: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 1pExQp-0003xu-64 for qemu-devel@nongnu.org; Mon, 09 Jan 2023 14:03:40 -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 1pExQk-0001I6-7G for qemu-devel@nongnu.org; Mon, 09 Jan 2023 14:03:38 -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-611-7KNvqhfEMpu7VVJuCIRoQQ-1; Mon, 09 Jan 2023 14:03:24 -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 6BB73857F82; Mon, 9 Jan 2023 19:03:24 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.39.192.78]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 3FCE9492B01; Mon, 9 Jan 2023 19:03:24 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 9B05B21E5A4F; Mon, 9 Jan 2023 20:03:21 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1673291005; 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=RpbsE2fyjkujcmeZQWxNTb24jacEp2MlGdC7VShemms=; b=O1N5TV8OudKCf5EWb3ItKeMD/GD4JkURLu1TQan7EmQZDSq2fvXw3De+xP5VjEwHSTnWBf ovsqokm+EnZpiLhxUbZujZvbMOs0s4O2tU3l+fJkY/f7p11xxmknwjIct3tmVKXIzcarFL IxM2nt/56i/KZKqWT4xCMKYieYZcta8= X-MC-Unique: 7KNvqhfEMpu7VVJuCIRoQQ-1 From: Markus Armbruster To: qemu-devel@nongnu.org Cc: kraxel@redhat.com, dgilbert@redhat.com, berrange@redhat.com, philmd@linaro.org Subject: [PATCH v4 06/17] ui/spice: QXLInterface method set_mm_time() is now dead, drop Date: Mon, 9 Jan 2023 20:03:10 +0100 Message-Id: <20230109190321.1056914-7-armbru@redhat.com> In-Reply-To: <20230109190321.1056914-1-armbru@redhat.com> References: <20230109190321.1056914-1-armbru@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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.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: 1673291472442100006 SPICE_NEEDS_SET_MM_TIME is now always off. Bury the dead code. Signed-off-by: Markus Armbruster Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Daniel P. Berrang=C3=A9 --- include/ui/qemu-spice.h | 2 -- hw/display/qxl.c | 19 ------------------- ui/spice-display.c | 10 ---------- hw/display/trace-events | 1 - 4 files changed, 32 deletions(-) diff --git a/include/ui/qemu-spice.h b/include/ui/qemu-spice.h index a7a1890b3f..b7d493742c 100644 --- a/include/ui/qemu-spice.h +++ b/include/ui/qemu-spice.h @@ -34,8 +34,6 @@ int qemu_spice_add_display_interface(QXLInstance *qxlin, = QemuConsole *con); int qemu_spice_migrate_info(const char *hostname, int port, int tls_port, const char *subject); =20 -#define SPICE_NEEDS_SET_MM_TIME 0 - #if SPICE_SERVER_VERSION >=3D 0x000f00 /* release 0.15.0 */ #define SPICE_HAS_ATTACHED_WORKER 1 #else diff --git a/hw/display/qxl.c b/hw/display/qxl.c index ddca611804..ec712d3ca2 100644 --- a/hw/display/qxl.c +++ b/hw/display/qxl.c @@ -543,22 +543,6 @@ static void interface_set_compression_level(QXLInstanc= e *sin, int level) qxl_rom_set_dirty(qxl); } =20 -#if SPICE_NEEDS_SET_MM_TIME -static void interface_set_mm_time(QXLInstance *sin, uint32_t mm_time) -{ - PCIQXLDevice *qxl =3D container_of(sin, PCIQXLDevice, ssd.qxl); - - if (!qemu_spice_display_is_running(&qxl->ssd)) { - return; - } - - trace_qxl_interface_set_mm_time(qxl->id, mm_time); - qxl->shadow_rom.mm_clock =3D cpu_to_le32(mm_time); - qxl->rom->mm_clock =3D cpu_to_le32(mm_time); - qxl_rom_set_dirty(qxl); -} -#endif - static void interface_get_init_info(QXLInstance *sin, QXLDevInitInfo *info) { PCIQXLDevice *qxl =3D container_of(sin, PCIQXLDevice, ssd.qxl); @@ -1145,9 +1129,6 @@ static const QXLInterface qxl_interface =3D { #endif =20 .set_compression_level =3D interface_set_compression_level, -#if SPICE_NEEDS_SET_MM_TIME - .set_mm_time =3D interface_set_mm_time, -#endif .get_init_info =3D interface_get_init_info, =20 /* the callbacks below are called from spice server thread context */ diff --git a/ui/spice-display.c b/ui/spice-display.c index 494168e7fe..0616a6982f 100644 --- a/ui/spice-display.c +++ b/ui/spice-display.c @@ -517,13 +517,6 @@ static void interface_set_compression_level(QXLInstanc= e *sin, int level) /* nothing to do */ } =20 -#if SPICE_NEEDS_SET_MM_TIME -static void interface_set_mm_time(QXLInstance *sin, uint32_t mm_time) -{ - /* nothing to do */ -} -#endif - static void interface_get_init_info(QXLInstance *sin, QXLDevInitInfo *info) { SimpleSpiceDisplay *ssd =3D container_of(sin, SimpleSpiceDisplay, qxl); @@ -715,9 +708,6 @@ static const QXLInterface dpy_interface =3D { .attache_worker =3D interface_attach_worker, #endif .set_compression_level =3D interface_set_compression_level, -#if SPICE_NEEDS_SET_MM_TIME - .set_mm_time =3D interface_set_mm_time, -#endif .get_init_info =3D interface_get_init_info, =20 /* the callbacks below are called from spice server thread context */ diff --git a/hw/display/trace-events b/hw/display/trace-events index 0c0ffcbe42..2336a0ca15 100644 --- a/hw/display/trace-events +++ b/hw/display/trace-events @@ -55,7 +55,6 @@ virtio_gpu_fence_ctrl(uint64_t fence, uint32_t type) "fen= ce 0x%" PRIx64 ", type virtio_gpu_fence_resp(uint64_t fence) "fence 0x%" PRIx64 =20 # qxl.c -disable qxl_interface_set_mm_time(int qid, uint32_t mm_time) "%d %d" disable qxl_io_write_vga(int qid, const char *mode, uint32_t addr, uint32_= t val) "%d %s addr=3D%u val=3D%u" qxl_create_guest_primary(int qid, uint32_t width, uint32_t height, uint64_= t mem, uint32_t format, uint32_t position) "%d %ux%u mem=3D0x%" PRIx64 " %u= ,%u" qxl_create_guest_primary_rest(int qid, int32_t stride, uint32_t type, uint= 32_t flags) "%d %d,%d,%d" --=20 2.39.0 From nobody Wed May 15 18:47:10 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=1673291093; cv=none; d=zohomail.com; s=zohoarc; b=Zgigeqv95KZqD92GTqC1eSA7xMS90yDZAAqUXj6vjU7cZQgvSLwZeA6jZ010It+vMOWo3fdaapqzlP0b1I5ompFpLP2V4ryUhLP9fOibipeXzGa1izDsc/owekFsVZHwFRJ8kN6QbTPfvRoZkLirJ508KamuHScvzzVHd6ni2hw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1673291093; 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=5phFSPLBhB4Uro3X25K33Knnd5TQdDQAixqJJxaBebA=; b=ImkosvjocCbkXAD/caqIh+DdF/Ypl3o+cPKP0V5kpKP5AmrUMcLzsMhwbJk4JmQ2hmHtDhtySf8txp3ExmDS1UemehF+PpcP5j8aXWtfYT600CGPxDigTSe/2ptZ64ATNliscFfAZg96bnCcAuBAWt6HRiKMfhqknl2tr96UZXg= 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 1673291093347107.69660690735213; Mon, 9 Jan 2023 11:04:53 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pExRb-0004YW-36; Mon, 09 Jan 2023 14:04:27 -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 1pExQp-0003xx-LQ for qemu-devel@nongnu.org; Mon, 09 Jan 2023 14:03:40 -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 1pExQk-0001I8-88 for qemu-devel@nongnu.org; Mon, 09 Jan 2023 14:03:39 -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-611-1JM4By53NcacuuDznC656w-1; Mon, 09 Jan 2023 14:03:24 -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 6EACB101A52E; Mon, 9 Jan 2023 19:03:24 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.39.192.78]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 3FE792026D4B; Mon, 9 Jan 2023 19:03:24 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 9E80621E5A69; Mon, 9 Jan 2023 20:03:21 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1673291006; 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=5phFSPLBhB4Uro3X25K33Knnd5TQdDQAixqJJxaBebA=; b=LiwriysOrG/Qe1RhqSaTcIl8nIOdoDmJULx/YmE3JuK/SpS7dGqS8bsV0s1Yp2DqG3q0Dq XsSQOrvOFXh+Mj1weG83inLb1F9G24b2+Z3J/PbDqYpO83hkuX9D4hrUOQlhvMJbWPR0R+ 5KQHv9jKSdPkaMQjjzepYxdeqvDgKgo= X-MC-Unique: 1JM4By53NcacuuDznC656w-1 From: Markus Armbruster To: qemu-devel@nongnu.org Cc: kraxel@redhat.com, dgilbert@redhat.com, berrange@redhat.com, philmd@linaro.org Subject: [PATCH v4 07/17] ui/spice: Give hmp_info_spice()'s channel_names[] static linkage Date: Mon, 9 Jan 2023 20:03:11 +0100 Message-Id: <20230109190321.1056914-8-armbru@redhat.com> In-Reply-To: <20230109190321.1056914-1-armbru@redhat.com> References: <20230109190321.1056914-1-armbru@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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: 1673291094254100001 Suggested-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Markus Armbruster Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- monitor/hmp-cmds.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c index 67e39f408e..f4d0d031df 100644 --- a/monitor/hmp-cmds.c +++ b/monitor/hmp-cmds.c @@ -611,7 +611,7 @@ void hmp_info_spice(Monitor *mon, const QDict *qdict) SpiceChannelList *chan; SpiceInfo *info; const char *channel_name; - const char * const channel_names[] =3D { + static const char *const channel_names[] =3D { [SPICE_CHANNEL_MAIN] =3D "main", [SPICE_CHANNEL_DISPLAY] =3D "display", [SPICE_CHANNEL_INPUTS] =3D "inputs", --=20 2.39.0 From nobody Wed May 15 18:47:10 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=1673291174; cv=none; d=zohomail.com; s=zohoarc; b=YEoGTU9aRgu+MB/y/nDwhHPJgYrnAfZU9vxsRAqffe2N9246EKsQsjdED1DQFgam9JTKvn2f9Z2FHaFOJkdQnOS6vEH3E8DVMomZrJkgGE0LbD+UcRc4meXlGQzDOUVLNOA0C21EMDclhTF8EgLJs2oy/I+aLiCZfIsylpFR8iY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1673291174; 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=L8oGPXucQfeURgnxHQPdGoETjCVJQjFwX3+9jG5ffdI=; b=DuldB2ATADs6DCVr0NQKk8X69YEp3kijrU7WPSwSA4pS7EVlGxUEQzONi3Zc6XYgouJJZSuArnpg67fx8ZNbKOLuzkywvw2lU8yUeeyH5qUM+eqA0t0MmsRRepPphitOA04OwDe1LzPUeU3d78+xqXqHl9+Y6Qi5swd5Jv2GVUM= 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 1673291174317505.08985629736947; Mon, 9 Jan 2023 11:06:14 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pExRb-0004ZJ-9x; Mon, 09 Jan 2023 14:04:27 -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 1pExQp-0003xt-5M for qemu-devel@nongnu.org; Mon, 09 Jan 2023 14:03:40 -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 1pExQk-0001J9-7R for qemu-devel@nongnu.org; Mon, 09 Jan 2023 14:03:38 -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-656-RTWfC7YzOLW1a9N2aSAj1A-1; Mon, 09 Jan 2023 14:03:24 -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 9DBBF101B44E; Mon, 9 Jan 2023 19:03:24 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.39.192.78]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 3EFCD492B00; Mon, 9 Jan 2023 19:03:24 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id A1D6A21E5A11; Mon, 9 Jan 2023 20:03:21 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1673291008; 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=L8oGPXucQfeURgnxHQPdGoETjCVJQjFwX3+9jG5ffdI=; b=Sy5QzL8wCEWGLvlCFnzjzmgQZis2fHGS85t0GWbJWsNZwTKfjYbJMZbX0A6860d0GpYUiu toHZK4cv3xeD4rCNEUiq8pdC0l/gruzBl1Y4EvZ4UZoip6nJMqZDVvLcd1GTaKQ7wMmcJg w+yk76uv4jDi1daVPEQSs9JdTCA7Jzc= X-MC-Unique: RTWfC7YzOLW1a9N2aSAj1A-1 From: Markus Armbruster To: qemu-devel@nongnu.org Cc: kraxel@redhat.com, dgilbert@redhat.com, berrange@redhat.com, philmd@linaro.org Subject: [PATCH v4 08/17] ui: Clean up a few things checkpatch.pl would flag later on Date: Mon, 9 Jan 2023 20:03:12 +0100 Message-Id: <20230109190321.1056914-9-armbru@redhat.com> In-Reply-To: <20230109190321.1056914-1-armbru@redhat.com> References: <20230109190321.1056914-1-armbru@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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: 1673291174697100001 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 Reviewed-by: Philippe Mathieu-Daud=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 f4d0d031df..c2249f77a6 100644 --- a/monitor/hmp-cmds.c +++ b/monitor/hmp-cmds.c @@ -587,9 +587,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 a1695b6c96..6d6df86607 100644 --- a/monitor/qmp-cmds.c +++ b/monitor/qmp-cmds.c @@ -186,8 +186,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 @@ -272,12 +274,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) { @@ -289,19 +289,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.39.0 From nobody Wed May 15 18:47:10 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=1673291396; cv=none; d=zohomail.com; s=zohoarc; b=mtcl0wOoQ4fMW6aPa87YG10QKnw6cjhnEWjIUDNca+gpRf4fvWhMylX1mcjWwtk1FhwT5R0GTz+pWay9kqmpzLlUXDNFmmHf2XsTXnQkBtPdF85/02tO0Xh2m2wz6cr/Rfo0/F3o181O7n4JIVL28GTwEC2rg7w5aIGC4fF5gP0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1673291396; 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=YcvaCart48pAdU6Sr3c//6WYKwCPBkYOCWtzS83av8w=; b=G8goKtrjLBPLQX2XuQ9BBKWMRAMW1vBj07T08o2WPjrjyh7X4t+LlWam7jMWxAXkfhW8Q+GD8c7hGSrfP4hmmUi+2ebRQvbk0I/H6SOWT9itI/bMHjQ6l6xkrVATPvVNU3A+j1/KrBnMa51mPOcAL/Mxx+HvcloS3eGYp68/eo0= 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 1673291396463809.963667836308; Mon, 9 Jan 2023 11:09:56 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pExRX-0004OA-Lh; Mon, 09 Jan 2023 14:04: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 1pExQn-0003xE-9o for qemu-devel@nongnu.org; Mon, 09 Jan 2023 14:03:38 -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 1pExQj-0001Im-Ko for qemu-devel@nongnu.org; Mon, 09 Jan 2023 14:03:36 -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-635-Ur0CHbKcPxC0b7q4qgS_kQ-1; Mon, 09 Jan 2023 14:03:24 -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 8EBBB1C09044; Mon, 9 Jan 2023 19:03:24 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.39.192.78]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 3FEA22026D76; Mon, 9 Jan 2023 19:03:24 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id A59B221E5A12; Mon, 9 Jan 2023 20:03:21 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1673291007; 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=YcvaCart48pAdU6Sr3c//6WYKwCPBkYOCWtzS83av8w=; b=aExWM6IqzvVx/7dIDU2WB7RHEftVaHJyc4OQJNFym5EO6gXDk8+LTd9AwyNMpTayDK0+Dg rua4kA16mZ5CBgWYoFrgQrwmjvhhY5oDlyoRZDvHk25MICV/leo6GzirAr59YogwK6tqX0 +bble+VFHQt+A9hJUo4E6AxvZShoE8c= X-MC-Unique: Ur0CHbKcPxC0b7q4qgS_kQ-1 From: Markus Armbruster To: qemu-devel@nongnu.org Cc: kraxel@redhat.com, dgilbert@redhat.com, berrange@redhat.com, philmd@linaro.org Subject: [PATCH v4 09/17] ui: Move QMP commands from monitor to new ui/ui-qmp-cmds.c Date: Mon, 9 Jan 2023 20:03:13 +0100 Message-Id: <20230109190321.1056914-10-armbru@redhat.com> In-Reply-To: <20230109190321.1056914-1-armbru@redhat.com> References: <20230109190321.1056914-1-armbru@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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: 1673291397977100003 This moves these commands from MAINTAINERS section "QMP" 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 Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- monitor/qmp-cmds.c | 118 --------------------------------------- ui/ui-qmp-cmds.c | 136 +++++++++++++++++++++++++++++++++++++++++++++ ui/meson.build | 1 + 3 files changed, 137 insertions(+), 118 deletions(-) create mode 100644 ui/ui-qmp-cmds.c diff --git a/monitor/qmp-cmds.c b/monitor/qmp-cmds.c index 6d6df86607..61449f1b58 100644 --- a/monitor/qmp-cmds.c +++ b/monitor/qmp-cmds.c @@ -36,9 +36,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" @@ -168,89 +166,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) @@ -305,7 +220,6 @@ void qmp_add_client(const char *protocol, const char *f= dname, } } =20 - MemoryDeviceInfoList *qmp_query_memory_devices(Error **errp) { return qmp_memory_device_list(); @@ -344,38 +258,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..c9f92caf1d --- /dev/null +++ b/ui/ui-qmp-cmds.c @@ -0,0 +1,136 @@ +/* + * 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 "qapi/qapi-commands-ui.h" +#include "qapi/qmp/qerror.h" +#include "qemu/cutils.h" +#include "ui/console.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_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.39.0 From nobody Wed May 15 18:47:10 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=1673291100; cv=none; d=zohomail.com; s=zohoarc; b=jPMC+2FFpFM6ZCL617OP8CCaJ2VafYIxbnjUu3rgYcp+i4M2cKBJ35V4yB8bzLsILT8bPIC31VvqpWGvIbsig0Datk4RoeMB/ybhHqJgVKs0ZOYHji5SZ9UKG8H0akhqmYbqvrnrMN/4CH08QII6f+vP8wYSwG0yA8QBuemwRlI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1673291100; 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=3TD4Bpl+eZ8t3BM63RawmS2vfji/HiFc1zAbxjW+24M=; b=W8X2agoOJuEsLy46bYjqwO54GB77cMpug9CMBCiKXucquw5oZuU3oRLxQz9gzfFmg8dsgc3i1N/2JFi4378xstrWrkeriePqgybOrfeMKcOq6AtcJApXUYC2z9GicA9vLVCWtbFD3AlmcCROp1eYfzmAJqRIJwNuIQ5U5GzTTUg= 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 1673291100748974.9726136868735; Mon, 9 Jan 2023 11:05:00 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pExRQ-0004GN-5Q; Mon, 09 Jan 2023 14:04:16 -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 1pExQo-0003xN-FL for qemu-devel@nongnu.org; Mon, 09 Jan 2023 14:03:40 -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 1pExQk-0001JD-73 for qemu-devel@nongnu.org; Mon, 09 Jan 2023 14:03:38 -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-551-rlMj2IoVNhGEcRZzGiXHkg-1; Mon, 09 Jan 2023 14:03:24 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 874E2857A81; Mon, 9 Jan 2023 19:03:24 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.39.192.78]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 3EC8451E5; Mon, 9 Jan 2023 19:03:24 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id A8E4521E5A13; Mon, 9 Jan 2023 20:03:21 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1673291008; 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=3TD4Bpl+eZ8t3BM63RawmS2vfji/HiFc1zAbxjW+24M=; b=dc3B4QRWXIejp0TApjD49CMPXw39q6csIklfR0NtFOMClbt8vCv07s+HaKyDv9Dn1scFt8 03zsEbE1SRoIjivw02VmCfRC9bngr98yPRWjlYzkOJ5N6hfJgphPQ86m3CWV9f0kOx7B3N id8Zxn9xP+vM+OvvfuZyQCXSUqJkvKI= X-MC-Unique: rlMj2IoVNhGEcRZzGiXHkg-1 From: Markus Armbruster To: qemu-devel@nongnu.org Cc: kraxel@redhat.com, dgilbert@redhat.com, berrange@redhat.com, philmd@linaro.org Subject: [PATCH v4 10/17] ui: Factor out qmp_add_client() parts and move to ui/ui-qmp-cmds.c Date: Mon, 9 Jan 2023 20:03:14 +0100 Message-Id: <20230109190321.1056914-11-armbru@redhat.com> In-Reply-To: <20230109190321.1056914-1-armbru@redhat.com> References: <20230109190321.1056914-1-armbru@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 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: 1673291102520100003 Signed-off-by: Markus Armbruster Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- include/monitor/qmp-helpers.h | 26 ++++++++++++ monitor/qmp-cmds.c | 74 ++++++++++++++++------------------- ui/ui-qmp-cmds.c | 41 +++++++++++++++++++ 3 files changed, 100 insertions(+), 41 deletions(-) create mode 100644 include/monitor/qmp-helpers.h diff --git a/include/monitor/qmp-helpers.h b/include/monitor/qmp-helpers.h new file mode 100644 index 0000000000..4718c63c73 --- /dev/null +++ b/include/monitor/qmp-helpers.h @@ -0,0 +1,26 @@ +/* + * QMP command helpers + * + * Copyright (c) 2022 Red Hat Inc. + * + * Authors: + * Markus Armbruster + * + * This work is licensed under the terms of the GNU GPL, version 2. See + * the COPYING file in the top-level directory. + */ + +#ifndef MONITOR_QMP_HELPERS_H + +bool qmp_add_client_spice(int fd, bool has_skipauth, bool skipauth, + bool has_tls, bool tls, Error **errp); +#ifdef CONFIG_VNC +bool qmp_add_client_vnc(int fd, bool has_skipauth, bool skipauth, + bool has_tls, bool tls, Error **errp); +#endif +#ifdef CONFIG_DBUS_DISPLAY +bool qmp_add_client_dbus_display(int fd, bool has_skipauth, bool skipauth, + bool has_tls, bool tls, Error **errp); +#endif + +#endif diff --git a/monitor/qmp-cmds.c b/monitor/qmp-cmds.c index 61449f1b58..b5b736761a 100644 --- a/monitor/qmp-cmds.c +++ b/monitor/qmp-cmds.c @@ -17,13 +17,11 @@ #include "qemu/cutils.h" #include "qemu/option.h" #include "monitor/monitor.h" +#include "monitor/qmp-helpers.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" @@ -170,54 +168,48 @@ void qmp_add_client(const char *protocol, const char = *fdname, bool has_skipauth, bool skipauth, bool has_tls, bool t= ls, Error **errp) { + static struct { + const char *name; + bool (*add_client)(int fd, bool has_skipauth, bool skipauth, + bool has_tls, bool tls, Error **errp); + } protocol_table[] =3D { + { "spice", qmp_add_client_spice }, +#ifdef CONFIG_VNC + { "vnc", qmp_add_client_vnc }, +#endif +#ifdef CONFIG_DBUS_DISPLAY + { "@dbus-display", qmp_add_client_dbus_display }, +#endif + }; Chardev *s; - int fd; + int fd, i; =20 fd =3D monitor_get_fd(monitor_cur(), fdname, errp); if (fd < 0) { return; } =20 - 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); + for (i =3D 0; i < ARRAY_SIZE(protocol_table); i++) { + if (!strcmp(protocol, protocol_table[i].name)) { + if (!protocol_table[i].add_client(fd, has_skipauth, skipauth, + has_tls, tls, errp)) { + close(fd); + } return; } } + + 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; + } } =20 MemoryDeviceInfoList *qmp_query_memory_devices(Error **errp) diff --git a/ui/ui-qmp-cmds.c b/ui/ui-qmp-cmds.c index c9f92caf1d..dbc4afcd73 100644 --- a/ui/ui-qmp-cmds.c +++ b/ui/ui-qmp-cmds.c @@ -14,10 +14,12 @@ */ =20 #include "qemu/osdep.h" +#include "monitor/qmp-helpers.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" =20 void qmp_set_password(SetPasswordOptions *opts, Error **errp) @@ -103,6 +105,45 @@ void qmp_change_vnc_password(const char *password, Err= or **errp) } #endif =20 +bool qmp_add_client_spice(int fd, bool has_skipauth, bool skipauth, + bool has_tls, bool tls, Error **errp) +{ + if (!qemu_using_spice(errp)) { + return false; + } + 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"); + return false; + } + return true; +} + +#ifdef CONFIG_VNC +bool qmp_add_client_vnc(int fd, bool has_skipauth, bool skipauth, + bool has_tls, bool tls, Error **errp) +{ + skipauth =3D has_skipauth ? skipauth : false; + vnc_display_add_client(NULL, fd, skipauth); + return true; +} +#endif + +#ifdef CONFIG_DBUS_DISPLAY +bool qmp_add_client_dbus_display(int fd, bool has_skipauth, bool skipauth, + bool has_tls, bool tls, Error **errp) +{ + if (!qemu_using_dbus_display(errp)) { + return false; + } + if (!qemu_dbus_display.add_client(fd, errp)) { + return false; + } + return true; +} +#endif + void qmp_display_reload(DisplayReloadOptions *arg, Error **errp) { switch (arg->type) { --=20 2.39.0 From nobody Wed May 15 18:47:10 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=1673291295; cv=none; d=zohomail.com; s=zohoarc; b=gC46DY+efb/kvKqs21zk/d8t7P+qWt12fLIoErRrhS1fZy+F2X5C5t+On4JwxAq4Y8WjjdkF34LJIxB4j3fvcFHKcAyEqeBhm4Kz/r7Jyj2zuF2xIsDE8/ALRBZvBifoNLbK3EdmF/nPQoAU6gsnQFATW6tzKqT1zmOjomwP9b8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1673291295; 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=vIrnKTHYbgT57vCVvnYIZSqlYG7L5vZnaKHKsJpNzmc=; b=i8k9izxq6iV7eiu0x7v0fXfQyuxdvznEXD6m9BlLmiFfe8W4aSVQysXEV9D2V7Yjz40fMbg/2oipJ6J/PtmQXU4DAaZAke4QLRfwzGoI1lHPqiel1dlmCDFvcypkPUVbarI7srm1wmBcolVwz9lz8q89rQ8WaU8wOedY/B8ENqk= 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 1673291295087994.1083579907743; Mon, 9 Jan 2023 11:08:15 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pExRY-0004RN-J5; Mon, 09 Jan 2023 14:04: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 1pExQq-0003zh-Ao for qemu-devel@nongnu.org; Mon, 09 Jan 2023 14:03:40 -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 1pExQk-0001JP-70 for qemu-devel@nongnu.org; Mon, 09 Jan 2023 14:03:40 -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-50-vgtbZcFgOOqP3se5Q2xkIA-1; Mon, 09 Jan 2023 14:03:25 -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 C64BF1C09049; Mon, 9 Jan 2023 19:03:24 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.39.192.78]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 3FB631121314; Mon, 9 Jan 2023 19:03:24 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id AD11E21E5A14; Mon, 9 Jan 2023 20:03:21 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1673291008; 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=vIrnKTHYbgT57vCVvnYIZSqlYG7L5vZnaKHKsJpNzmc=; b=YDbfyr46oCBwTTETxu8ogLrlGfO0v3gj1mqbY9nulzNx/jfxuZ59quF22XCC3+/KXZaEyy tGgbMdKT9wO9wlTVcPaAWiKLy9qRSmuCrkARwxx7GVcuzZrsiyEZ0T/t6qyTJjuCwjy3mK URTO8DCPmJ7/wGijop9MIbBl2WzdZbI= X-MC-Unique: vgtbZcFgOOqP3se5Q2xkIA-1 From: Markus Armbruster To: qemu-devel@nongnu.org Cc: kraxel@redhat.com, dgilbert@redhat.com, berrange@redhat.com, philmd@linaro.org Subject: [PATCH v4 11/17] ui: Move HMP commands from monitor to new ui/ui-hmp-cmds.c Date: Mon, 9 Jan 2023 20:03:15 +0100 Message-Id: <20230109190321.1056914-12-armbru@redhat.com> In-Reply-To: <20230109190321.1056914-1-armbru@redhat.com> References: <20230109190321.1056914-1-armbru@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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.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: 1673291295575100001 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 --- include/monitor/hmp.h | 2 + monitor/hmp-cmds.c | 338 --------------------------------- monitor/misc.c | 66 ------- ui/ui-hmp-cmds.c | 422 ++++++++++++++++++++++++++++++++++++++++++ ui/meson.build | 1 + 5 files changed, 425 insertions(+), 404 deletions(-) create mode 100644 ui/ui-hmp-cmds.c diff --git a/include/monitor/hmp.h b/include/monitor/hmp.h index 27f86399f7..b228a406f3 100644 --- a/include/monitor/hmp.h +++ b/include/monitor/hmp.h @@ -81,6 +81,8 @@ void hmp_netdev_add(Monitor *mon, const QDict *qdict); void hmp_netdev_del(Monitor *mon, const QDict *qdict); void hmp_getfd(Monitor *mon, const QDict *qdict); void hmp_closefd(Monitor *mon, const QDict *qdict); +void hmp_mouse_move(Monitor *mon, const QDict *qdict); +void hmp_mouse_button(Monitor *mon, const QDict *qdict); void hmp_sendkey(Monitor *mon, const QDict *qdict); void coroutine_fn hmp_screendump(Monitor *mon, const QDict *qdict); void hmp_chardev_add(Monitor *mon, const QDict *qdict); diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c index c2249f77a6..c4f161a596 100644 --- a/monitor/hmp-cmds.c +++ b/monitor/hmp-cmds.c @@ -51,7 +51,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" @@ -59,10 +58,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) { @@ -178,26 +173,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; @@ -516,168 +491,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->x509_dname ?: "none"); - monitor_printf(mon, " sasl_username: %s\n", - 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->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; - static 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", - [SPICE_CHANNEL_WEBDAV] =3D "webdav", - }; - - 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; @@ -1262,69 +1075,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.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.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) @@ -1521,94 +1271,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; - int value; - - if (qemu_strtoi(keys, &endp, 0, &value) < 0) { - 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, 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/monitor/misc.c b/monitor/misc.c index bf3f1c67ca..3d68940d28 100644 --- a/monitor/misc.c +++ b/monitor/misc.c @@ -34,7 +34,6 @@ #include "qemu/config-file.h" #include "qemu/ctype.h" #include "ui/console.h" -#include "ui/input.h" #include "audio/audio.h" #include "disas/disas.h" #include "qemu/timer.h" @@ -825,49 +824,6 @@ static void hmp_sum(Monitor *mon, const QDict *qdict) monitor_printf(mon, "%05d\n", sum); } =20 -static int mouse_button_state; - -static void hmp_mouse_move(Monitor *mon, const QDict *qdict) -{ - int dx, dy, dz, button; - const char *dx_str =3D qdict_get_str(qdict, "dx_str"); - const char *dy_str =3D qdict_get_str(qdict, "dy_str"); - const char *dz_str =3D qdict_get_try_str(qdict, "dz_str"); - - dx =3D strtol(dx_str, NULL, 0); - dy =3D strtol(dy_str, NULL, 0); - qemu_input_queue_rel(NULL, INPUT_AXIS_X, dx); - qemu_input_queue_rel(NULL, INPUT_AXIS_Y, dy); - - if (dz_str) { - dz =3D strtol(dz_str, NULL, 0); - if (dz !=3D 0) { - button =3D (dz > 0) ? INPUT_BUTTON_WHEEL_UP : INPUT_BUTTON_WHE= EL_DOWN; - qemu_input_queue_btn(NULL, button, true); - qemu_input_event_sync(); - qemu_input_queue_btn(NULL, button, false); - } - } - qemu_input_event_sync(); -} - -static void hmp_mouse_button(Monitor *mon, const QDict *qdict) -{ - static uint32_t bmap[INPUT_BUTTON__MAX] =3D { - [INPUT_BUTTON_LEFT] =3D MOUSE_EVENT_LBUTTON, - [INPUT_BUTTON_MIDDLE] =3D MOUSE_EVENT_MBUTTON, - [INPUT_BUTTON_RIGHT] =3D MOUSE_EVENT_RBUTTON, - }; - int button_state =3D qdict_get_int(qdict, "button_state"); - - if (mouse_button_state =3D=3D button_state) { - return; - } - qemu_input_update_buttons(NULL, bmap, mouse_button_state, button_state= ); - qemu_input_event_sync(); - mouse_button_state =3D button_state; -} - static void hmp_ioport_read(Monitor *mon, const QDict *qdict) { int size =3D qdict_get_int(qdict, "size"); @@ -1700,28 +1656,6 @@ void object_del_completion(ReadLineState *rs, int nb= _args, const char *str) qapi_free_ObjectPropertyInfoList(start); } =20 -void sendkey_completion(ReadLineState *rs, int nb_args, const char *str) -{ - int i; - char *sep; - size_t len; - - if (nb_args !=3D 2) { - return; - } - sep =3D strrchr(str, '-'); - if (sep) { - str =3D sep + 1; - } - len =3D strlen(str); - readline_set_completion_index(rs, len); - for (i =3D 0; i < Q_KEY_CODE__MAX; i++) { - if (!strncmp(str, QKeyCode_str(i), len)) { - readline_add_completion(rs, QKeyCode_str(i)); - } - } -} - void set_link_completion(ReadLineState *rs, int nb_args, const char *str) { size_t len; diff --git a/ui/ui-hmp-cmds.c b/ui/ui-hmp-cmds.c new file mode 100644 index 0000000000..4af92f8eaf --- /dev/null +++ b/ui/ui-hmp-cmds.c @@ -0,0 +1,422 @@ +/* + * HMP 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" +#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" +#include "ui/input.h" + +static int mouse_button_state; + +void hmp_mouse_move(Monitor *mon, const QDict *qdict) +{ + int dx, dy, dz, button; + const char *dx_str =3D qdict_get_str(qdict, "dx_str"); + const char *dy_str =3D qdict_get_str(qdict, "dy_str"); + const char *dz_str =3D qdict_get_try_str(qdict, "dz_str"); + + dx =3D strtol(dx_str, NULL, 0); + dy =3D strtol(dy_str, NULL, 0); + qemu_input_queue_rel(NULL, INPUT_AXIS_X, dx); + qemu_input_queue_rel(NULL, INPUT_AXIS_Y, dy); + + if (dz_str) { + dz =3D strtol(dz_str, NULL, 0); + if (dz !=3D 0) { + button =3D (dz > 0) ? INPUT_BUTTON_WHEEL_UP : INPUT_BUTTON_WHE= EL_DOWN; + qemu_input_queue_btn(NULL, button, true); + qemu_input_event_sync(); + qemu_input_queue_btn(NULL, button, false); + } + } + qemu_input_event_sync(); +} + +void hmp_mouse_button(Monitor *mon, const QDict *qdict) +{ + static uint32_t bmap[INPUT_BUTTON__MAX] =3D { + [INPUT_BUTTON_LEFT] =3D MOUSE_EVENT_LBUTTON, + [INPUT_BUTTON_MIDDLE] =3D MOUSE_EVENT_MBUTTON, + [INPUT_BUTTON_RIGHT] =3D MOUSE_EVENT_RBUTTON, + }; + int button_state =3D qdict_get_int(qdict, "button_state"); + + if (mouse_button_state =3D=3D button_state) { + return; + } + qemu_input_update_buttons(NULL, bmap, mouse_button_state, button_state= ); + qemu_input_event_sync(); + mouse_button_state =3D button_state; +} + +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->x509_dname ?: "none"); + monitor_printf(mon, " sasl_username: %s\n", + 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->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; + static 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", + [SPICE_CHANNEL_WEBDAV] =3D "webdav", + }; + + 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.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.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; + int value; + + if (qemu_strtoi(keys, &endp, 0, &value) < 0) { + 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 sendkey_completion(ReadLineState *rs, int nb_args, const char *str) +{ + int i; + char *sep; + size_t len; + + if (nb_args !=3D 2) { + return; + } + sep =3D strrchr(str, '-'); + if (sep) { + str =3D sep + 1; + } + len =3D strlen(str); + readline_set_completion_index(rs, len); + for (i =3D 0; i < Q_KEY_CODE__MAX; i++) { + if (!strncmp(str, QKeyCode_str(i), len)) { + readline_add_completion(rs, QKeyCode_str(i)); + } + } +} + +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, 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.39.0 From nobody Wed May 15 18:47:10 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=1673291425; cv=none; d=zohomail.com; s=zohoarc; b=Po8xFJ7ZxCPC18kSStpE8SsJ72WPEicjStMBY4gk28/+IjgOR6fR4XEGwSvGrURyLLBNlxUeA2qA9LOm+KyuFAFm5ScGAVVTWj9HigZ4qkgYW73dE1nQ6Bcw0w/+InBBceNVa5Ohppum1HcnHJY9DGBlKg5dGVE6/frD5A2ttTc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1673291425; 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=InnyMshX2DIySPILO6RKzf7M1ZwtRoM7sAO1/xlny/Q=; b=MVBKvdgGc2tRVVsrI35MR+Q96OZmcHtrfIiztq9+v7pN1tZohB2qAtAWb64pvS1RU2QfaznHPqtybWmnTXGA94pO8L8scb54gjM1eVGeTZhg1IwMea5/43jYs+X7OmFvDnAz8pNQxN6xSVrMlWSk67Go33m0/Qg/Tw4wVDa3HbY= 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 167329142575771.32189807198802; Mon, 9 Jan 2023 11:10:25 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pExRc-0004cV-3h; Mon, 09 Jan 2023 14:04: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 1pExQo-0003xs-V6 for qemu-devel@nongnu.org; Mon, 09 Jan 2023 14:03:40 -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 1pExQk-0001ID-6w for qemu-devel@nongnu.org; Mon, 09 Jan 2023 14:03:38 -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-551-NkyAZpurPS6kEn72nTvXBA-1; Mon, 09 Jan 2023 14:03:24 -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 6AF1E811E6E; Mon, 9 Jan 2023 19:03:24 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.39.192.78]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 3FD791121318; Mon, 9 Jan 2023 19:03:24 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id B0CC621E5A15; Mon, 9 Jan 2023 20:03:21 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1673291006; 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=InnyMshX2DIySPILO6RKzf7M1ZwtRoM7sAO1/xlny/Q=; b=DDFE10pQAiQjltLYqF065JHgaMq2MgXl0RsoYf9UQCaynNgMte6Ov3D3Xq/lIK7KrshJQH 6Ld+0Uq+TyNP03IFapSackH2kZ2M7vMuCU8VoVawlC6orosOpix5YTqe1l02yQluxKDJd/ 6r2uzsxdzKnySCaBapquQDUgqqGcV+U= X-MC-Unique: NkyAZpurPS6kEn72nTvXBA-1 From: Markus Armbruster To: qemu-devel@nongnu.org Cc: kraxel@redhat.com, dgilbert@redhat.com, berrange@redhat.com, philmd@linaro.org Subject: [PATCH v4 12/17] ui: Improve "change vnc" error reporting Date: Mon, 9 Jan 2023 20:03:16 +0100 Message-Id: <20230109190321.1056914-13-armbru@redhat.com> In-Reply-To: <20230109190321.1056914-1-armbru@redhat.com> References: <20230109190321.1056914-1-armbru@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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: 1673291426216100001 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 Reviewed-by: Daniel P. Berrang=C3=A9 Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- monitor/hmp-cmds.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c index c4f161a596..4340e71c90 100644 --- a/monitor/hmp-cmds.c +++ b/monitor/hmp-cmds.c @@ -1097,9 +1097,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) { @@ -1111,7 +1110,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 --=20 2.39.0 From nobody Wed May 15 18:47:10 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=1673291442; cv=none; d=zohomail.com; s=zohoarc; b=lHFOIPHFTq4wR/J14TivV/BFyCq3zoFnKcHevJBHtKraXAaNqoGvFZQvkGqV0+u4RSRqG1YUQZ4SoSD4VQqW4OVSAzK0VrvOatKn07fZQPQSSBGYLiJ6su4s3eKS98zcTMBkaDsJqkFrNcdMywtGQdb+wA76u2/sZkL5yei1ZWg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1673291442; 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=HcKOUJvb2FOhgRFXm+hMd9NFRhOneB0yJ7Prs7FFJX8=; b=U6QUwCHWhvDa6B6F1SYkB4rVza9BMJEmPibJ0EBy/kIzUPY0FUrs8hVt+xHJf+10VvWEcAzU1f6UcG+2tntbM5io7Oksn39WpXPN07zv55I9RQUtUx5cma4jNWEpiKdBSPZ3B4ZbwBuSozhz5M2CjwFFN+B+vhD3kr7x/0YPsqM= 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 16732914420991004.0201411115015; Mon, 9 Jan 2023 11:10:42 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pExRZ-0004VS-UG; Mon, 09 Jan 2023 14:04:25 -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 1pExQr-00041L-5J for qemu-devel@nongnu.org; Mon, 09 Jan 2023 14:03:41 -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 1pExQm-0001M8-Sr for qemu-devel@nongnu.org; Mon, 09 Jan 2023 14:03:40 -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-553-KnJm4SqUPJ23-EZL3sMP4Q-1; Mon, 09 Jan 2023 14:03:28 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 91FC4802C1D; Mon, 9 Jan 2023 19:03:24 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.39.192.78]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 3FDE42166B26; Mon, 9 Jan 2023 19:03:24 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id B52F621E5A16; Mon, 9 Jan 2023 20:03:21 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1673291015; 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=HcKOUJvb2FOhgRFXm+hMd9NFRhOneB0yJ7Prs7FFJX8=; b=Hq+Go4kpNeNxUUbTwOW1M3A2SClw4VlhxfLLoXgWj7dqWS7Oy4lHsyTQApSw8LBIlmKlIe 4M25q41JRUhYNuwV22d4MF4gbMVhHJqLgvAABIBKfI+MKYjyFNLpPrVuP7+aY+MrFAejql yx4fA/P272Jqr6Wv1FFrDJDOJWfCYS0= X-MC-Unique: KnJm4SqUPJ23-EZL3sMP4Q-1 From: Markus Armbruster To: qemu-devel@nongnu.org Cc: kraxel@redhat.com, dgilbert@redhat.com, berrange@redhat.com, philmd@linaro.org Subject: [PATCH v4 13/17] ui: Factor out hmp_change_vnc(), and move to ui/ui-hmp-cmds.c Date: Mon, 9 Jan 2023 20:03:17 +0100 Message-Id: <20230109190321.1056914-14-armbru@redhat.com> In-Reply-To: <20230109190321.1056914-1-armbru@redhat.com> References: <20230109190321.1056914-1-armbru@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 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: 1673291444214100003 Signed-off-by: Markus Armbruster Reviewed-by: Daniel P. Berrang=C3=A9 Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- include/monitor/hmp.h | 5 +++++ monitor/hmp-cmds.c | 30 ++---------------------------- monitor/qmp-cmds.c | 2 +- ui/ui-hmp-cmds.c | 35 ++++++++++++++++++++++++++++++++++- 4 files changed, 42 insertions(+), 30 deletions(-) diff --git a/include/monitor/hmp.h b/include/monitor/hmp.h index b228a406f3..df89eac22a 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 4340e71c90..1dba973092 100644 --- a/monitor/hmp-cmds.c +++ b/monitor/hmp-cmds.c @@ -25,7 +25,7 @@ #include "qemu/timer.h" #include "qemu/sockets.h" #include "qemu/help_option.h" -#include "monitor/monitor-internal.h" +#include "monitor/monitor.h" #include "qapi/error.h" #include "qapi/clone-visitor.h" #include "qapi/opts-visitor.h" @@ -41,7 +41,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" @@ -1075,15 +1074,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"); @@ -1096,23 +1086,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/monitor/qmp-cmds.c b/monitor/qmp-cmds.c index b5b736761a..14f0f78e51 100644 --- a/monitor/qmp-cmds.c +++ b/monitor/qmp-cmds.c @@ -168,7 +168,7 @@ void qmp_add_client(const char *protocol, const char *f= dname, bool has_skipauth, bool skipauth, bool has_tls, bool t= ls, Error **errp) { - static struct { + static const struct { const char *name; bool (*add_client)(int fd, bool has_skipauth, bool skipauth, bool has_tls, bool tls, Error **errp); diff --git a/ui/ui-hmp-cmds.c b/ui/ui-hmp-cmds.c index 4af92f8eaf..8ae96749f3 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" @@ -311,6 +312,38 @@ 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(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 { + error_setg(errp, "Expected 'password' after 'vnc'"); + return; + } +} +#endif + void hmp_sendkey(Monitor *mon, const QDict *qdict) { const char *keys =3D qdict_get_str(qdict, "keys"); --=20 2.39.0 From nobody Wed May 15 18:47:10 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=1673291372; cv=none; d=zohomail.com; s=zohoarc; b=mFR8tdF53QfWmFKVA4Lo6G+85JaFFr3D4NvfZLWQO2Gb6CYL8r3GBVv4FinpfxRK5L3WpEfDDRClK3XQthEe5WDMSMawR2ebrVETZBFKRYmmgDZVU1DR/tst4Z9FcOQHW9Xw4nNGWev0EbiC53ykbtVoAmFCeUdSuesb9vOPrVo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1673291372; 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=vYEN8u+nr8ehSNY8DBiXNicgkVNI0viYPy4uZwDn06Y=; b=ZQwxQZaSVquYZCiWYDGWohcMLf+LkuGB4iA94BUmCfhXqkcq0zEAVEh0KpoS2GcQWdqnRLuKdJmLTp3flHTKn7WPFHIzLjhFgsiKEKjJjFuOlxMmYI21hzETVbFMppatiZB9yg60u11glIUjkxpn4OZrkugSGj1pm8Ky5ZROxaQ= 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 1673291372902980.4364465591025; Mon, 9 Jan 2023 11:09:32 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pExRW-0004Lz-HG; Mon, 09 Jan 2023 14:04: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 1pExQn-0003xJ-Rq for qemu-devel@nongnu.org; Mon, 09 Jan 2023 14:03:38 -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 1pExQj-0001J7-T8 for qemu-devel@nongnu.org; Mon, 09 Jan 2023 14:03:37 -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-551-PDGj53_ROPu4L2VrXadlfA-1; Mon, 09 Jan 2023 14:03:24 -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 6AB6C101A521; Mon, 9 Jan 2023 19:03:24 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.39.192.78]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 3FEAA1121319; Mon, 9 Jan 2023 19:03:24 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id B8B1021E5A17; Mon, 9 Jan 2023 20:03:21 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1673291008; 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=vYEN8u+nr8ehSNY8DBiXNicgkVNI0viYPy4uZwDn06Y=; b=hVPRYoz6QFPpXrOz7aa0DoDxSm75Gj0Qnf2PkZMbIErvyOfuHxqYMadFWU66jA9pe8bTEW qi2/8bxzVGvV5nxNVX0EAIKM7i4RU7fI6yVAmAfBSnmjpfRw/QmVs3rp9jlgKp46ZR7ff6 LsPdkdDqRrNuRb56+nYpqYk5OpoFxx4= X-MC-Unique: PDGj53_ROPu4L2VrXadlfA-1 From: Markus Armbruster To: qemu-devel@nongnu.org Cc: kraxel@redhat.com, dgilbert@redhat.com, berrange@redhat.com, philmd@linaro.org Subject: [PATCH v4 14/17] ui: Reduce nesting in hmp_change_vnc() slightly Date: Mon, 9 Jan 2023 20:03:18 +0100 Message-Id: <20230109190321.1056914-15-armbru@redhat.com> In-Reply-To: <20230109190321.1056914-1-armbru@redhat.com> References: <20230109190321.1056914-1-armbru@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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: 1673291373822100003 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 8ae96749f3..7ca80c8626 100644 --- a/ui/ui-hmp-cmds.c +++ b/ui/ui-hmp-cmds.c @@ -328,19 +328,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.39.0 From nobody Wed May 15 18:47:10 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=1673291470; cv=none; d=zohomail.com; s=zohoarc; b=kvl2P3AmQ262cUhvurHb9B6sjRPaEG0ZK2c6ZIByVmg0QJsi9leS1oomVp5N45XaNDUmL4AyjG44PICBDPj7BKnFDHFcmkAX7qxLsxVyjBd7WKKZ8oJcnEimkHzn2onJjgaT1D8354ncy1lBW2PY205njrrQfhTZmvPBmSs38hM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1673291470; 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=yCA6um7Y9PdrDqtat9jUd//wgO5LOxZDJEFU0/Zq0CY=; b=PWSgSeEd5FRvswI2D659PCWG/DEMHUx5vYB0B1wWKFD0FZgfo7z8Z01KDvgV8BVy6RxneLlSO/sJ9W+N9CfdpCFV6fQFaw7fYl+OMoTwYh+sYuYzRtNbEU09RXmnPC9GP/bfQviIHh+ldH/yZsyasiCwN/4tjyTHPyrDFT2EUz8= 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 16732914708391003.2732929538744; Mon, 9 Jan 2023 11:11:10 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pExRZ-0004SZ-Kx; Mon, 09 Jan 2023 14:04:25 -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 1pExQq-0003zg-4J for qemu-devel@nongnu.org; Mon, 09 Jan 2023 14:03:40 -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 1pExQk-0001JT-8P for qemu-devel@nongnu.org; Mon, 09 Jan 2023 14:03:39 -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-629-WdltWZ-eNmunwoZEs0SVuQ-1; Mon, 09 Jan 2023 14:03:26 -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 D17E21C09041; Mon, 9 Jan 2023 19:03:25 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.39.192.78]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A72E51121314; Mon, 9 Jan 2023 19:03:25 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id BBB1A21E5A18; Mon, 9 Jan 2023 20:03:21 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1673291009; 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=yCA6um7Y9PdrDqtat9jUd//wgO5LOxZDJEFU0/Zq0CY=; b=gIePjHwrXBECsjDuYt7UBZH7SEUVa9tTkIdqjSk3hHFirVt5xAQ3A7JBsS1l3Xz8m1u0+Z GN1CrzZSeya7Gap331dgK8ml5ZsuEhNDoRNGdkdPWeP7Cn6+dKeX/0jGvrIpVmv1jPvXnc e95wWXAwOCBg3rzROHuOWaSZPbbkpjs= X-MC-Unique: WdltWZ-eNmunwoZEs0SVuQ-1 From: Markus Armbruster To: qemu-devel@nongnu.org Cc: kraxel@redhat.com, dgilbert@redhat.com, berrange@redhat.com, philmd@linaro.org Subject: [PATCH v4 15/17] ui: Don't check for mode change after mouse_set error Date: Mon, 9 Jan 2023 20:03:19 +0100 Message-Id: <20230109190321.1056914-16-armbru@redhat.com> In-Reply-To: <20230109190321.1056914-1-armbru@redhat.com> References: <20230109190321.1056914-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: 1673291472441100005 Content-Type: text/plain; charset="utf-8" hmp_mouse_set() doesn't bail out when it can't find a mouse. Harmless, since qemu_input_check_mode_change() should be a no-op then. Clean it up anyway. Signed-off-by: Markus Armbruster --- ui/input.c | 1 + 1 file changed, 1 insertion(+) diff --git a/ui/input.c b/ui/input.c index 8f4a87d1d7..d1c7605238 100644 --- a/ui/input.c +++ b/ui/input.c @@ -616,6 +616,7 @@ void hmp_mouse_set(Monitor *mon, const QDict *qdict) =20 if (!found) { error_report("Mouse at index '%d' not found", index); + return; } =20 qemu_input_check_mode_change(); --=20 2.39.0 From nobody Wed May 15 18:47:10 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=1673291149; cv=none; d=zohomail.com; s=zohoarc; b=IvTu15iIbaM6B5HcZCtjUll6YR2JK4JhPwIArXrHyP8VCgkxkggENG2ARhl0NaehJzB/CJaLbhl5zzhCTkbkaFu/2lOir75CoI1zDOvRt7G7BelXzPgt1WjMnDAJsZzBQoZyxAoJySroNQUnKXhf4ll3eRG1yxKp/qVLDGAldOM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1673291149; 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=5wbg4/JcoeLOoa8iu4c/rV+ZZn+8bDAypW/lvv/lo/Y=; b=Q9y7lCfqaER7vmBPDcvmvOk6NXSIsI5J/gkivKEdk2FTRbTSTo2cumzpG03FCQCllpa8p0s9VOu4ZvadFkcQpaZe6X1TNMYWXKIT6lD4O/J50JYFOdIDXQRUFcQ3udHko/cDy6Rjh0voHBc97fugU8gPQLTf4jAShEqnUDZR3lE= 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 1673291149430926.7211986538376; Mon, 9 Jan 2023 11:05:49 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pExRM-0004G7-DB; Mon, 09 Jan 2023 14:04:13 -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 1pExQn-0003xG-5d for qemu-devel@nongnu.org; Mon, 09 Jan 2023 14:03:38 -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 1pExQj-0001J0-IL for qemu-devel@nongnu.org; Mon, 09 Jan 2023 14:03:36 -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-416-LwgwWeAHO7e0Eu2ig-uh8g-1; Mon, 09 Jan 2023 14:03:26 -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 D2A6D885621; Mon, 9 Jan 2023 19:03:25 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.39.192.78]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A7A8E40C2064; Mon, 9 Jan 2023 19:03:25 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id BED0221E5A19; Mon, 9 Jan 2023 20:03:21 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1673291007; 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=5wbg4/JcoeLOoa8iu4c/rV+ZZn+8bDAypW/lvv/lo/Y=; b=FtBM1h6qxka+P8N0k8w4+Lh3R0LCSz07LQRXZgKvKNcYBQACymDMIp3E5Vl3UG5TFrE5vL PG3Zi6+Q9lR/+82BYu0toKhbDC5+lnFSfXBcbKpg8hEANE9StWO6Gr2ggiT0+UuIIjpOsS UYeh4x5DO0u2WVO4bUu1lMfwSRZcvm8= X-MC-Unique: LwgwWeAHO7e0Eu2ig-uh8g-1 From: Markus Armbruster To: qemu-devel@nongnu.org Cc: kraxel@redhat.com, dgilbert@redhat.com, berrange@redhat.com, philmd@linaro.org Subject: [PATCH v4 16/17] ui: Split hmp_mouse_set() and move the HMP part to ui/ Date: Mon, 9 Jan 2023 20:03:20 +0100 Message-Id: <20230109190321.1056914-17-armbru@redhat.com> In-Reply-To: <20230109190321.1056914-1-armbru@redhat.com> References: <20230109190321.1056914-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: 1673291150742100003 Content-Type: text/plain; charset="utf-8" Signed-off-by: Markus Armbruster --- include/monitor/hmp.h | 1 + include/ui/console.h | 2 +- monitor/misc.c | 1 - ui/input.c | 15 +++++++-------- ui/ui-hmp-cmds.c | 8 ++++++++ 5 files changed, 17 insertions(+), 10 deletions(-) diff --git a/include/monitor/hmp.h b/include/monitor/hmp.h index df89eac22a..8688769a27 100644 --- a/include/monitor/hmp.h +++ b/include/monitor/hmp.h @@ -88,6 +88,7 @@ void hmp_getfd(Monitor *mon, const QDict *qdict); void hmp_closefd(Monitor *mon, const QDict *qdict); void hmp_mouse_move(Monitor *mon, const QDict *qdict); void hmp_mouse_button(Monitor *mon, const QDict *qdict); +void hmp_mouse_set(Monitor *mon, const QDict *qdict); void hmp_sendkey(Monitor *mon, const QDict *qdict); void coroutine_fn hmp_screendump(Monitor *mon, const QDict *qdict); void hmp_chardev_add(Monitor *mon, const QDict *qdict); diff --git a/include/ui/console.h b/include/ui/console.h index e400ee9fa7..8e6cf782a1 100644 --- a/include/ui/console.h +++ b/include/ui/console.h @@ -65,7 +65,7 @@ void qemu_remove_led_event_handler(QEMUPutLEDEntry *entry= ); =20 void kbd_put_ledstate(int ledstate); =20 -void hmp_mouse_set(Monitor *mon, const QDict *qdict); +bool qemu_mouse_set(int index, Error **errp); =20 /* keysym is a unicode code except for special keys (see QEMU_KEY_xxx constants) */ diff --git a/monitor/misc.c b/monitor/misc.c index 3d68940d28..50cb9f008b 100644 --- a/monitor/misc.c +++ b/monitor/misc.c @@ -33,7 +33,6 @@ #include "ui/qemu-spice.h" #include "qemu/config-file.h" #include "qemu/ctype.h" -#include "ui/console.h" #include "audio/audio.h" #include "disas/disas.h" #include "qemu/timer.h" diff --git a/ui/input.c b/ui/input.c index d1c7605238..7048810a57 100644 --- a/ui/input.c +++ b/ui/input.c @@ -2,8 +2,6 @@ #include "sysemu/sysemu.h" #include "qapi/error.h" #include "qapi/qapi-commands-ui.h" -#include "qapi/qmp/qdict.h" -#include "qemu/error-report.h" #include "trace.h" #include "ui/input.h" #include "ui/console.h" @@ -594,10 +592,9 @@ MouseInfoList *qmp_query_mice(Error **errp) return mice_list; } =20 -void hmp_mouse_set(Monitor *mon, const QDict *qdict) +bool qemu_mouse_set(int index, Error **errp) { QemuInputHandlerState *s; - int index =3D qdict_get_int(qdict, "index"); int found =3D 0; =20 QTAILQ_FOREACH(s, &handlers, node) { @@ -606,8 +603,9 @@ void hmp_mouse_set(Monitor *mon, const QDict *qdict) } if (!(s->handler->mask & (INPUT_EVENT_MASK_REL | INPUT_EVENT_MASK_ABS))) { - error_report("Input device '%s' is not a mouse", s->handler->n= ame); - return; + error_setg(errp, "Input device '%s' is not a mouse", + s->handler->name); + return false; } found =3D 1; qemu_input_handler_activate(s); @@ -615,9 +613,10 @@ void hmp_mouse_set(Monitor *mon, const QDict *qdict) } =20 if (!found) { - error_report("Mouse at index '%d' not found", index); - return; + error_setg(errp, "Mouse at index '%d' not found", index); + return false; } =20 qemu_input_check_mode_change(); + return true; } diff --git a/ui/ui-hmp-cmds.c b/ui/ui-hmp-cmds.c index 7ca80c8626..5c456ecc02 100644 --- a/ui/ui-hmp-cmds.c +++ b/ui/ui-hmp-cmds.c @@ -69,6 +69,14 @@ void hmp_mouse_button(Monitor *mon, const QDict *qdict) mouse_button_state =3D button_state; } =20 +void hmp_mouse_set(Monitor *mon, const QDict *qdict) +{ + Error *err =3D NULL; + + qemu_mouse_set(qdict_get_int(qdict, "index"), &err); + hmp_handle_error(mon, err); +} + void hmp_info_mice(Monitor *mon, const QDict *qdict) { MouseInfoList *mice_list, *mouse; --=20 2.39.0 From nobody Wed May 15 18:47:10 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=1673291079; cv=none; d=zohomail.com; s=zohoarc; b=lF+KtGhbdn/L7X33gqN8amKCwOP0WV96ZcK3D+DK84WVXv+LARz7Nm09yPdzIShGtlYm6f+LEIYm8py/Isy5PPXtRbv94T6tL5I+YxJ2rBf7rjTvMvRk+nbgB1CsXdCfrjSmbl3Qv6N4qnhsWV2D/eI5mrLY7vXgqDilC2XTALE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1673291079; 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=gIbvA16meAt5BD6PeVn8Nm6nFOLlFS3dcrYUWfmlxQg=; b=XUBZ3+M/hTOl9Bq5dctn1uf9+0SzcYQGbSLWpsIvUQb3jzCws0l7iZBOidRcxbeqH9wgPvg6DfEEe2C0jNuCBTJzFwJysf5nfBLLjw4boN1loeIaG+2ArTYqs31Tq1IFb5z1HsYuK7XAX1Ilras0phHY0wz9c3t/h+Op+SnRHk8= 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 1673291079707791.0165935577262; Mon, 9 Jan 2023 11:04:39 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pExRR-0004H9-KZ; Mon, 09 Jan 2023 14:04:17 -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 1pExQn-0003xL-Uz for qemu-devel@nongnu.org; Mon, 09 Jan 2023 14:03:38 -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 1pExQk-0001Iy-6p for qemu-devel@nongnu.org; Mon, 09 Jan 2023 14:03:37 -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-575-ZeKWBditMPWKXR-jnnUDOQ-1; Mon, 09 Jan 2023 14:03:26 -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 D0F9780234E; Mon, 9 Jan 2023 19:03:25 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.39.192.78]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A767E1121318; Mon, 9 Jan 2023 19:03:25 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id C1A9321E59C1; Mon, 9 Jan 2023 20:03:21 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1673291007; 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=gIbvA16meAt5BD6PeVn8Nm6nFOLlFS3dcrYUWfmlxQg=; b=YLd7miryFJtddbSEW6dvSBNbj4w8h6y6gmMWRvkn3asNSLegDNKAWO/00iLtS1sUb9EeXT gZOEAWy4sCkOEo/8f+4QWMVs0QC1EsSz4WPH5v5O1L1tvOBhuOB1ubTUCbZ/U9rBW9TzOl BZiaYs3oFH9cyb9r3Tq6C5+6dqOTzbA= X-MC-Unique: ZeKWBditMPWKXR-jnnUDOQ-1 From: Markus Armbruster To: qemu-devel@nongnu.org Cc: kraxel@redhat.com, dgilbert@redhat.com, berrange@redhat.com, philmd@linaro.org Subject: [PATCH v4 17/17] ui: Simplify control flow in qemu_mouse_set() Date: Mon, 9 Jan 2023 20:03:21 +0100 Message-Id: <20230109190321.1056914-18-armbru@redhat.com> In-Reply-To: <20230109190321.1056914-1-armbru@redhat.com> References: <20230109190321.1056914-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: 1673291080205100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: Markus Armbruster --- ui/input.c | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/ui/input.c b/ui/input.c index 7048810a57..f2d1e7a3a7 100644 --- a/ui/input.c +++ b/ui/input.c @@ -595,28 +595,26 @@ MouseInfoList *qmp_query_mice(Error **errp) bool qemu_mouse_set(int index, Error **errp) { QemuInputHandlerState *s; - int found =3D 0; =20 QTAILQ_FOREACH(s, &handlers, node) { - if (s->id !=3D index) { - continue; + if (s->id =3D=3D index) { + break; } - if (!(s->handler->mask & (INPUT_EVENT_MASK_REL | - INPUT_EVENT_MASK_ABS))) { - error_setg(errp, "Input device '%s' is not a mouse", - s->handler->name); - return false; - } - found =3D 1; - qemu_input_handler_activate(s); - break; } =20 - if (!found) { + if (!s) { error_setg(errp, "Mouse at index '%d' not found", index); return false; } =20 + if (!(s->handler->mask & (INPUT_EVENT_MASK_REL | + INPUT_EVENT_MASK_ABS))) { + error_setg(errp, "Input device '%s' is not a mouse", + s->handler->name); + return false; + } + + qemu_input_handler_activate(s); qemu_input_check_mode_change(); return true; } --=20 2.39.0