From nobody Wed May 14 15:51:38 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1520347639981810.7743267154876; Tue, 6 Mar 2018 06:47:19 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 3069A8B101; Tue, 6 Mar 2018 14:47:17 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 97D3360BF1; Tue, 6 Mar 2018 14:47:16 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 3AF994A472; Tue, 6 Mar 2018 14:47:16 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w26El9pY027283 for ; Tue, 6 Mar 2018 09:47:09 -0500 Received: by smtp.corp.redhat.com (Postfix) id 5506A61F2B; Tue, 6 Mar 2018 14:47:09 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-116-18.phx2.redhat.com [10.3.116.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1698161F55 for ; Tue, 6 Mar 2018 14:47:09 +0000 (UTC) From: John Ferlan To: libvir-list@redhat.com Date: Tue, 6 Mar 2018 09:47:02 -0500 Message-Id: <20180306144702.17094-5-jferlan@redhat.com> In-Reply-To: <20180306144702.17094-1-jferlan@redhat.com> References: <20180306144702.17094-1-jferlan@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 4/4] qemu: Add support for change-vnc-password X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Tue, 06 Mar 2018 14:47:18 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Rather than use the to be deprecated "change" command, use the change-vnc-password command to perform VNC password changes instead of the set_password command. Since changing VNC password only accepts "keep" for connect and that's the default, no sense in vectoring through "set_password" as we've already checked that the XML 'connected' was set to "keep" in virDomainGraphicsAuthDefParseXML. Signed-off-by: John Ferlan --- src/qemu/qemu_hotplug.c | 10 +++++++++- src/qemu/qemu_monitor.c | 15 +++++++++++++++ src/qemu/qemu_monitor.h | 2 ++ src/qemu/qemu_monitor_json.c | 28 ++++++++++++++++++++++++++++ src/qemu/qemu_monitor_json.h | 2 ++ tests/qemumonitorjsontest.c | 2 ++ 6 files changed, 58 insertions(+), 1 deletion(-) diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index 0ee9b2bfc..a012b3dcd 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -5333,7 +5333,15 @@ qemuDomainChangeGraphicsPasswords(virQEMUDriverPtr d= river, =20 if (qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) < 0) goto cleanup; - ret =3D qemuMonitorSetPassword(priv->mon, type, password, connected); + + /* The connected parameter can only be keep for VNC, thus QMP command + * set_password makes the same call hence if available just use the + * newer change-vnc-password command. */ + if (type =3D=3D VIR_DOMAIN_GRAPHICS_TYPE_VNC && + virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_CHANGE_VNC_PASSWORD)) + ret =3D qemuMonitorSetVNCPassword(priv->mon, password); + else + ret =3D qemuMonitorSetPassword(priv->mon, type, password, connecte= d); =20 if (ret =3D=3D -2) { if (type !=3D VIR_DOMAIN_GRAPHICS_TYPE_VNC) { diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c index 56c8345d5..c88634a38 100644 --- a/src/qemu/qemu_monitor.c +++ b/src/qemu/qemu_monitor.c @@ -2387,6 +2387,21 @@ qemuMonitorSetVNCPasswordLegacy(qemuMonitorPtr mon, } =20 =20 +int +qemuMonitorSetVNCPassword(qemuMonitorPtr mon, + const char *password) +{ + VIR_DEBUG("password=3D%p", password); + + QEMU_CHECK_MONITOR_JSON(mon); + + if (!password) + password =3D ""; + + return qemuMonitorJSONSetVNCPassword(mon, password); +} + + static const char * qemuMonitorTypeToProtocol(int type) { diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h index cf9ab7cb3..eeae72928 100644 --- a/src/qemu/qemu_monitor.h +++ b/src/qemu/qemu_monitor.h @@ -597,6 +597,8 @@ int qemuMonitorBlockResize(qemuMonitorPtr mon, unsigned long long size); int qemuMonitorSetVNCPasswordLegacy(qemuMonitorPtr mon, const char *password); +int qemuMonitorSetVNCPassword(qemuMonitorPtr mon, + const char *password); int qemuMonitorSetPassword(qemuMonitorPtr mon, int type, const char *password, diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index ad81b70db..f8131ac4d 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -2384,6 +2384,34 @@ qemuMonitorJSONSetVNCPasswordLegacy(qemuMonitorPtr m= on, return ret; } =20 + +int +qemuMonitorJSONSetVNCPassword(qemuMonitorPtr mon, + const char *password) +{ + int ret =3D -1; + virJSONValuePtr cmd =3D qemuMonitorJSONMakeCommand("change-vnc-passwor= d", + "s:password", passwor= d, + NULL); + virJSONValuePtr reply =3D NULL; + + if (!cmd) + return -1; + + if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0) + goto cleanup; + + if (qemuMonitorJSONCheckError(cmd, reply) < 0) + goto cleanup; + + ret =3D 0; + cleanup: + virJSONValueFree(cmd); + virJSONValueFree(reply); + return ret; +} + + /* Returns -1 on error, -2 if not supported */ int qemuMonitorJSONSetPassword(qemuMonitorPtr mon, const char *protocol, diff --git a/src/qemu/qemu_monitor_json.h b/src/qemu/qemu_monitor_json.h index dec7a5cf9..b3254ac05 100644 --- a/src/qemu/qemu_monitor_json.h +++ b/src/qemu/qemu_monitor_json.h @@ -94,6 +94,8 @@ int qemuMonitorJSONBlockResize(qemuMonitorPtr mon, =20 int qemuMonitorJSONSetVNCPasswordLegacy(qemuMonitorPtr mon, const char *password); +int qemuMonitorJSONSetVNCPassword(qemuMonitorPtr mon, + const char *password); int qemuMonitorJSONSetPassword(qemuMonitorPtr mon, const char *protocol, const char *password, diff --git a/tests/qemumonitorjsontest.c b/tests/qemumonitorjsontest.c index f9c59f2f0..6d33333a0 100644 --- a/tests/qemumonitorjsontest.c +++ b/tests/qemumonitorjsontest.c @@ -1317,6 +1317,7 @@ cleanup: \ GEN_TEST_FUNC(qemuMonitorJSONSetLink, "vnet0", VIR_DOMAIN_NET_INTERFACE_LI= NK_STATE_DOWN) GEN_TEST_FUNC(qemuMonitorJSONBlockResize, "vda", 123456) GEN_TEST_FUNC(qemuMonitorJSONSetVNCPasswordLegacy, "secret_password") +GEN_TEST_FUNC(qemuMonitorJSONSetVNCPassword, "secret_password") GEN_TEST_FUNC(qemuMonitorJSONSetPassword, "spice", "secret_password", "dis= connect") GEN_TEST_FUNC(qemuMonitorJSONExpirePassword, "spice", "123456") GEN_TEST_FUNC(qemuMonitorJSONSetBalloon, 1024) @@ -2906,6 +2907,7 @@ mymain(void) DO_TEST_GEN(qemuMonitorJSONSetLink); DO_TEST_GEN(qemuMonitorJSONBlockResize); DO_TEST_GEN(qemuMonitorJSONSetVNCPasswordLegacy); + DO_TEST_GEN(qemuMonitorJSONSetVNCPassword); DO_TEST_GEN(qemuMonitorJSONSetPassword); DO_TEST_GEN(qemuMonitorJSONExpirePassword); DO_TEST_GEN(qemuMonitorJSONSetBalloon); --=20 2.13.6 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list