]> xenbits.xensource.com Git - libvirt.git/commitdiff
virsh: read default connection uri from env later
authorJán Tomko <jtomko@redhat.com>
Wed, 6 Apr 2016 08:08:55 +0000 (10:08 +0200)
committerJán Tomko <jtomko@redhat.com>
Wed, 6 Apr 2016 12:47:41 +0000 (14:47 +0200)
Postpone filling out the default connection in ctl->connname
after calling virshInit.

This allows printing help without a connection to the daemon.

tools/virsh.c

index 57b4ff34751e471def7be2d8b8f9f8861f0d3cb8..8c616d6373953dd6ef6e0155ad864aacded4adb4 100644 (file)
@@ -968,9 +968,6 @@ main(int argc, char **argv)
 
     virFileActivateDirOverride(argv[0]);
 
-    if ((defaultConn = virGetEnvBlockSUID("VIRSH_DEFAULT_CONNECT_URI")))
-        ctl->connname = vshStrdup(ctl, defaultConn);
-
     if (!vshInit(ctl, cmdGroups, NULL))
         exit(EXIT_FAILURE);
 
@@ -980,6 +977,9 @@ main(int argc, char **argv)
         exit(EXIT_FAILURE);
     }
 
+    if ((defaultConn = virGetEnvBlockSUID("VIRSH_DEFAULT_CONNECT_URI")))
+        ctl->connname = vshStrdup(ctl, defaultConn);
+
     if (!ctl->imode) {
         ret = vshCommandRun(ctl, ctl->cmd);
     } else {