From nobody Tue Feb 10 00:22:08 2026 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; dkim=fail; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 15005851285022.9725537572849134; Thu, 20 Jul 2017 14:12:08 -0700 (PDT) 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 8E8554E4D0; Thu, 20 Jul 2017 21:12:04 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8E9AE17F23; Thu, 20 Jul 2017 21:12:03 +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 443AC1800C8B; Thu, 20 Jul 2017 21:12:02 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v6KLC009029076 for ; Thu, 20 Jul 2017 17:12:00 -0400 Received: by smtp.corp.redhat.com (Postfix) id 3E24C17F45; Thu, 20 Jul 2017 21:12:00 +0000 (UTC) Received: from mx1.redhat.com (ext-mx05.extmail.prod.ext.phx2.redhat.com [10.5.110.29]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 3584417F23 for ; Thu, 20 Jul 2017 21:11:58 +0000 (UTC) Received: from mail-qk0-f196.google.com (mail-qk0-f196.google.com [209.85.220.196]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 1CE262FFC38 for ; Thu, 20 Jul 2017 21:11:57 +0000 (UTC) Received: by mail-qk0-f196.google.com with SMTP id d145so66374qkc.0 for ; Thu, 20 Jul 2017 14:11:57 -0700 (PDT) Received: from localhost.localdomain ([187.107.160.64]) by smtp.googlemail.com with ESMTPSA id s24sm2384983qtc.7.2017.07.20.14.11.54 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 20 Jul 2017 14:11:54 -0700 (PDT) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 8E8554E4D0 Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=libvir-list-bounces@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 8E8554E4D0 Authentication-Results: mx1.redhat.com; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="fackb5F4" DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 1CE262FFC38 Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=jcfaracco@gmail.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 1CE262FFC38 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id; bh=WvsnB7l+ru6KUZ3B73jRs11xXS0pSn2NGd7WzqkBEbM=; b=fackb5F4o4+wCXYQwWtHZGWO0De/EMtH8zrVEVT9b/CzU+cmXZO1lUURcb/fyvMBmc FJOpJypa/+mJQM5MOEyRsFvBCVkBAdLAjXht0vYZf4PRmIEBe65N4h2jAv0hk9HwFo2+ HkprQ7+CdtKsU9TO8Karb6KOS9BfvecUCQFQUTQRGwPGLUGs6ES8EYz0BarvtXI7lKpt Hhs/iCpmCpbql2tK8B66THD3aNXEAvlMbTRN/mocgcTK0e9Ri5VZo1rMbHEbKQ/3v6Ji elSCuxYF3OfOWw6K/1Nqf2CPwhQ/QaWb0bbQLhtADzCdVGYDqmJ4qWg7+BQPTTa4TtVH yAVA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id; bh=WvsnB7l+ru6KUZ3B73jRs11xXS0pSn2NGd7WzqkBEbM=; b=Kp2sbaLx97rnwKTA40OpL/X5BSPn5jvnx4IH8Uv6C1LbUT3RPcEJMx88daTSm10GD0 nzW/SgTkbxSFttFn5STbDNIj/KJkh5Ae6JLtcfPUwaFNnKUvvuwvoJPXHs5UGycGO/LI e55aMLF2wP25cS+2yx/Ip+cww3Qx8RwNOPUuyML4eNXEjrGL8EfnEkUNkuIH1kEiiXan UYFZMQXmVqxNwOnAt8UNsjtmjOo4QPntUVNYny/SzoBP+el3ojYERHiLEal2aO9ddw+S Z0ECYff+7gQzR33ZsS1gEOqcHmUYNqTWzOSOgp6BVKVPLKLNWJruspQ4+5l29WicwFr5 cd3g== X-Gm-Message-State: AIVw110QMZDufZ+kKpz5ZeNVGa6cyrvlaOvJwyknAd3sdlnJcLeuMtHO 5Qzw/QeDHyWSyl/q X-Received: by 10.55.20.224 with SMTP id 93mr100587qku.66.1500585116195; Thu, 20 Jul 2017 14:11:56 -0700 (PDT) From: Julio Faracco To: libvir-list@redhat.com Date: Thu, 20 Jul 2017 18:11:28 -0300 Message-Id: <1500585088-19492-1-git-send-email-jcfaracco@gmail.com> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Thu, 20 Jul 2017 21:11:57 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Thu, 20 Jul 2017 21:11:57 +0000 (UTC) for IP:'209.85.220.196' DOMAIN:'mail-qk0-f196.google.com' HELO:'mail-qk0-f196.google.com' FROM:'jcfaracco@gmail.com' RCPT:'' X-RedHat-Spam-Score: 0.37 (DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, RCVD_IN_SORBS_SPAM, SPF_PASS) 209.85.220.196 mail-qk0-f196.google.com 209.85.220.196 mail-qk0-f196.google.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.29 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH] tools: virsh: Adding unix socket support to 'domdisplay' command. 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.38]); Thu, 20 Jul 2017 21:12:05 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" This commit adds the unix socket URL support to 'domdisplay' command. Before, even if an user was using unix socket to define a spice graphics, the command 'domdisplay' showed that the settings were not supported. Now, the command shows the proper URL: spice+unix://foo/bar.sock. Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=3D1336720 Signed-off-by: Julio Faracco --- tools/virsh-domain.c | 49 ++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 38 insertions(+), 11 deletions(-) diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index 0684979..090714b 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -10948,6 +10948,8 @@ cmdDomDisplay(vshControl *ctl, const vshCmd *cmd) char *xpath =3D NULL; char *listen_addr =3D NULL; int port, tls_port =3D 0; + char *type_conn =3D NULL; + char *socket =3D NULL; char *passwd =3D NULL; char *output =3D NULL; const char *scheme[] =3D { "vnc", "spice", "rdp", NULL }; @@ -11008,9 +11010,6 @@ cmdDomDisplay(vshControl *ctl, const vshCmd *cmd) if (tmp) tls_port =3D 0; =20 - if (!port && !tls_port) - continue; - /* Create our XPATH lookup for the current display's address */ if (virAsprintf(&xpath, xpath_fmt, scheme[iter], "@listen") < 0) goto cleanup; @@ -11021,6 +11020,29 @@ cmdDomDisplay(vshControl *ctl, const vshCmd *cmd) listen_addr =3D virXPathString(xpath, ctxt); VIR_FREE(xpath); =20 + /* Create our XPATH lookup for the current spice type. */ + if (virAsprintf(&xpath, xpath_fmt, scheme[iter], "listen/@type") <= 0) + goto cleanup; + + /* Attempt to get the type of spice connection */ + VIR_FREE(type_conn); + type_conn =3D virXPathString(xpath, ctxt); + VIR_FREE(xpath); + + if (STREQ_NULLABLE(type_conn, "socket")) { + if (!socket) { + if (virAsprintf(&xpath, xpath_fmt, scheme[iter], "listen/@= socket") < 0) + goto cleanup; + + socket =3D virXPathString(xpath, ctxt); + + VIR_FREE(xpath); + } + } + + if (!port && !tls_port && !socket) + continue; + if (!listen_addr) { /* The subelement address - - * *should* have been automatically backfilled into its @@ -11035,11 +11057,9 @@ cmdDomDisplay(vshControl *ctl, const vshCmd *cmd) =20 listen_addr =3D virXPathString(xpath, ctxt); VIR_FREE(xpath); - } - - /* If listen_addr is 0.0.0.0 or [::] we should try to parse URI an= d set - * listen_addr based on current URI. */ - if (listen_addr) { + } else { + /* If listen_addr is 0.0.0.0 or [::] we should try to parse UR= I and set + * listen_addr based on current URI. */ if (virSocketAddrParse(&addr, listen_addr, AF_UNSPEC) > 0 && virSocketAddrIsWildcard(&addr)) { =20 @@ -11078,17 +11098,22 @@ cmdDomDisplay(vshControl *ctl, const vshCmd *cmd) VIR_FREE(xpath); =20 /* Build up the full URI, starting with the scheme */ - virBufferAsprintf(&buf, "%s://", scheme[iter]); + if (socket) + virBufferAsprintf(&buf, "%s+unix://", scheme[iter]); + else + virBufferAsprintf(&buf, "%s://", scheme[iter]); =20 /* There is no user, so just append password if there's any */ if (STREQ(scheme[iter], "vnc") && passwd) virBufferAsprintf(&buf, ":%s@", passwd); =20 /* Then host name or IP */ - if (!listen_addr) + if (!listen_addr && !socket) virBufferAddLit(&buf, "localhost"); - else if (strchr(listen_addr, ':')) + else if (!socket && strchr(listen_addr, ':')) virBufferAsprintf(&buf, "[%s]", listen_addr); + else if (STREQ(scheme[iter], "spice")) + virBufferAsprintf(&buf, "%s", socket); else virBufferAsprintf(&buf, "%s", listen_addr); =20 @@ -11148,6 +11173,8 @@ cmdDomDisplay(vshControl *ctl, const vshCmd *cmd) =20 cleanup: VIR_FREE(xpath); + VIR_FREE(socket); + VIR_FREE(type_conn); VIR_FREE(passwd); VIR_FREE(listen_addr); VIR_FREE(output); --=20 2.7.4 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list