From nobody Thu May 2 11:17:37 2024 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 150127859816581.43201477060632; Fri, 28 Jul 2017 14:49:58 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 69A3241A00; Fri, 28 Jul 2017 21:49:55 +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 E064B5D6A6; Fri, 28 Jul 2017 21:49:53 +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 3F60D1805977; Fri, 28 Jul 2017 21:49:51 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v6SLnnUU026808 for ; Fri, 28 Jul 2017 17:49:49 -0400 Received: by smtp.corp.redhat.com (Postfix) id 000985D759; Fri, 28 Jul 2017 21:49:49 +0000 (UTC) Received: from mx1.redhat.com (ext-mx09.extmail.prod.ext.phx2.redhat.com [10.5.110.38]) by smtp.corp.redhat.com (Postfix) with ESMTPS id EEA925DD64 for ; Fri, 28 Jul 2017 21:49:47 +0000 (UTC) Received: from mail-qt0-f196.google.com (mail-qt0-f196.google.com [209.85.216.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 265EA11F873 for ; Fri, 28 Jul 2017 21:49:46 +0000 (UTC) Received: by mail-qt0-f196.google.com with SMTP id t37so10826464qtg.2 for ; Fri, 28 Jul 2017 14:49:46 -0700 (PDT) Received: from localhost.localdomain ([177.25.93.207]) by smtp.googlemail.com with ESMTPSA id z1sm13163838qkb.92.2017.07.28.14.49.43 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 28 Jul 2017 14:49:44 -0700 (PDT) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 69A3241A00 Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=libvir-list-bounces@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 69A3241A00 Authentication-Results: mx1.redhat.com; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="NjL51br4" DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 265EA11F873 Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=jcfaracco@gmail.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 265EA11F873 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id; bh=Zq/LzCtxq4V3BwZbI3V89uPJk0tIK5zEJzNKI/mIxXE=; b=NjL51br4hNQKwdNDgSBMFb65LYC/84mKQwQvIuX0sG1rnd8/lD8HBEgT3mMk9xYyZX p6dfXsr57QfUj1bUl6atwVw4SqdqICW/DmpNOtMlpcybGlr35QcSRsC7u4hCJSRwVf/J X7jdAJR8CA+GFY24wlh+0cvlNo6Gzlo1e0KOUAoEl1jItKjuRsd95k3CR9J8b7A2gIUk ahGbDlfPjKy7r2Jj/U81xNWDp+LGmF1p+TERQuzgcZyhDYZkDNid/ga8Nk88AqZZx6kb /27oK55/wDzFeHswhilCrdXmVUkpi/jgEuSZFFSlAJa3oyr0CKw1K04JHGo52csUqgMH 5KBA== 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=Zq/LzCtxq4V3BwZbI3V89uPJk0tIK5zEJzNKI/mIxXE=; b=dpmOkVNqNafhDohpdCQLs39EQGSkqUw9Qk2mOBPWhqnsmALedXnzInQNmep0DxuCdF rp5Cr+R7tCcEsAxzz0INp5Wd1VFy7uiLQpNRT3tls4k06GsjxbOG1qo82jmA6I/LHA62 8FodDbDWpuhUQiyA/TjNHkwWAb0JvrhkQ29/yJKCd9fyeVCSshB5mR83RYPFxkoWnbhR EsTPtgU7QQekZTAXRuqgZv2IUkjkQlKd0gweBjJ6mjpC4sSkt095u7Lby1gy1NzX+1ZR R0qSD2Lji+rjNpRh6mwJ0ZodKvVz6AwLffupcyMzZykAz1C0V9WIV9NenoTTPVLunUvb pVzw== X-Gm-Message-State: AIVw1137St8UiwrRIvRNnwMsG/cJScCTMV7TlXg3RrY9pRINs8b/Jid8 1Jn52sjupnNqt+k87Qg= X-Received: by 10.237.63.163 with SMTP id s32mr12962951qth.61.1501278585237; Fri, 28 Jul 2017 14:49:45 -0700 (PDT) From: Julio Faracco To: libvir-list@redhat.com Date: Fri, 28 Jul 2017 18:49:35 -0300 Message-Id: <1501278575-22627-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.38]); Fri, 28 Jul 2017 21:49:46 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Fri, 28 Jul 2017 21:49:46 +0000 (UTC) for IP:'209.85.216.196' DOMAIN:'mail-qt0-f196.google.com' HELO:'mail-qt0-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.216.196 mail-qt0-f196.google.com 209.85.216.196 mail-qt0-f196.google.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.38 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v2] 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.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Fri, 28 Jul 2017 21:49:56 +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. Settings: Before: virsh # domdisplay --all Windows7 vnc://127.0.0.1:0 After: virsh # domdisplay --all Windows7 vnc://127.0.0.1:0 spice+unix:///tmp/spice.sock Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=3D1336720 Signed-off-by: Julio Faracco --- tools/virsh-domain.c | 52 +++++++++++++++++++++++++++++++++++++++++-------= ---- 1 file changed, 41 insertions(+), 11 deletions(-) diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index 0684979..935ef8a 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,20 +11098,28 @@ 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 (socket) + virBufferAsprintf(&buf, "%s", socket); else virBufferAsprintf(&buf, "%s", listen_addr); =20 + /* Free socket to prepare the pointer for the next iteration */ + VIR_FREE(socket); + /* Add the port */ if (port) { if (STREQ(scheme[iter], "vnc")) { @@ -11148,6 +11176,8 @@ cmdDomDisplay(vshControl *ctl, const vshCmd *cmd) =20 cleanup: VIR_FREE(xpath); + VIR_FREE(type_conn); + VIR_FREE(socket); 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