[libvirt PATCH v4 05/11] virsh: report the D-Bus bus URI for domdisplay

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Marc-André Lureau <marcandre.lureau@xxxxxxxxxx>

This implementation reports only Unix bus address using the URI format
proposed in https://gitlab.freedesktop.org/dbus/dbus/-/issues/348.

We prefer a URI form over the D-Bus address form, since all other
display protocols use a URI, allowing to distinguish between protocols
and making client implementation simpler.

Other transports (for example TCP) are not yet handled.

The client is assumed to know what to lookup on the bus (the bus name,
path & interface of the VM, eventually matching its UUID)

P2P mode doesn't report any available URI.

Signed-off-by: Marc-André Lureau <marcandre.lureau@xxxxxxxxxx>
---
 tools/virsh-domain.c | 24 ++++++++++++++++++++++--
 1 file changed, 22 insertions(+), 2 deletions(-)

diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
index ba492e807e..bac4cc0fb6 100644
--- a/tools/virsh-domain.c
+++ b/tools/virsh-domain.c
@@ -11675,7 +11675,7 @@ static const vshCmdOptDef opts_domdisplay[] = {
     {.name = "type",
      .type = VSH_OT_STRING,
      .help = N_("select particular graphical display "
-                "(e.g. \"vnc\", \"spice\", \"rdp\")")
+                "(e.g. \"vnc\", \"spice\", \"rdp\", \"dbus\")")
     },
     {.name = "all",
      .type = VSH_OT_BOOL,
@@ -11684,6 +11684,23 @@ static const vshCmdOptDef opts_domdisplay[] = {
     {.name = NULL}
 };
 
+static char *
+virshGetDBusDisplay(vshControl *ctl, xmlXPathContext *ctxt)
+{
+    g_autofree char *addr = NULL;
+    const char *xpath = "string(/domain/devices/graphics[@type='dbus']/@address)";
+
+    addr = virXPathString(xpath, ctxt);
+    if (!addr)
+        return false;
+
+    if (STRPREFIX(addr, "unix:path=")) {
+        return g_strdup_printf("dbus+unix://%s", addr + 10);
+    }
+
+    vshError(ctl, _("'%s' D-Bus address is not handled"), addr);
+    return NULL;
+}
 
 static char *
 virshGetOneDisplay(vshControl *ctl,
@@ -11704,6 +11721,9 @@ virshGetOneDisplay(vshControl *ctl,
     g_autofree char *sockpath = NULL;
     g_autofree char *passwd = NULL;
 
+    if (STREQ(scheme, "dbus"))
+        return virshGetDBusDisplay(ctl, ctxt);
+
     /* Attempt to get the port number for the current graphics scheme */
     xpathPort = g_strdup_printf(xpath_fmt, scheme, "@port");
 
@@ -11830,7 +11850,7 @@ cmdDomDisplay(vshControl *ctl, const vshCmd *cmd)
     g_autoptr(xmlXPathContext) ctxt = NULL;
     g_autoptr(virshDomain) dom = NULL;
     bool ret = false;
-    const char *scheme[] = { "vnc", "spice", "rdp", NULL };
+    const char *scheme[] = { "vnc", "spice", "rdp", "dbus", NULL };
     const char *type = NULL;
     int iter = 0;
     int flags = 0;
-- 
2.36.1




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux