]> xenbits.xensource.com Git - libvirt.git/commitdiff
admin: add ability to connect to the per-driver daemon sockets
authorDaniel P. Berrangé <berrange@redhat.com>
Mon, 15 Jul 2019 16:35:07 +0000 (17:35 +0100)
committerDaniel P. Berrangé <berrange@redhat.com>
Fri, 9 Aug 2019 13:06:31 +0000 (14:06 +0100)
The admin client now supports addressing the per-driver daemons using
the obvious URI schemes for each daemon. eg virtqemud:///system
virtqemud:///session, etc.

Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
src/libvirt-admin.c

index e9ae765c5ad5a110ee400bac4ee67cd370a89789..6ad4436bff41e4449acec6728cd15b88d6f88fc5 100644 (file)
 
 #define VIR_FROM_THIS VIR_FROM_ADMIN
 
-#define LIBVIRTD_ADMIN_SOCK_NAME "libvirt-admin-sock"
-#define VIRTLOGD_ADMIN_SOCK_NAME "virtlogd-admin-sock"
-#define VIRTLOCKD_ADMIN_SOCK_NAME "virtlockd-admin-sock"
-
 
 VIR_LOG_INIT("libvirt-admin");
 
@@ -127,20 +123,31 @@ getSocketPath(virURIPtr uri)
     }
 
     if (!sock_path) {
-        const char *sockbase = NULL;
-        if (STREQ_NULLABLE(uri->scheme, "libvirtd")) {
-            sockbase = LIBVIRTD_ADMIN_SOCK_NAME;
-        } else if (STREQ_NULLABLE(uri->scheme, "virtlogd")) {
-            sockbase = VIRTLOGD_ADMIN_SOCK_NAME;
-        } else if (STREQ_NULLABLE(uri->scheme, "virtlockd")) {
-            sockbase = VIRTLOCKD_ADMIN_SOCK_NAME;
-        } else {
+        VIR_AUTOFREE(char *) sockbase = NULL;
+        bool legacy = false;
+
+        if (!uri->scheme) {
+            virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+                           "%s", _("No URI scheme specified"));
+            goto error;
+        }
+        if (STREQ(uri->scheme, "libvirtd")) {
+            legacy = true;
+        } else if (!STRPREFIX(uri->scheme, "virt")) {
             virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
                            _("Unsupported URI scheme '%s'"),
-                           NULLSTR(uri->scheme));
+                           uri->scheme);
             goto error;
         }
 
+        if (legacy) {
+            if (VIR_STRDUP(sockbase, "libvirt-admin-sock") < 0)
+                goto error;
+        } else {
+            if (virAsprintf(&sockbase, "%s-admin-sock", uri->scheme) < 0)
+                goto error;
+        }
+
         if (STREQ_NULLABLE(uri->path, "/system")) {
             if (virAsprintf(&sock_path, LOCALSTATEDIR "/run/libvirt/%s",
                             sockbase) < 0)