
On 06/04/16 10:51, Ján Tomko wrote:
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 | 6 +++--- tools/virt-admin.c | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/tools/virsh.c b/tools/virsh.c index 57b4ff3..8c616d6 100644 --- a/tools/virsh.c +++ b/tools/virsh.c @@ -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 {
^^This one's correct.
diff --git a/tools/virt-admin.c b/tools/virt-admin.c index edb8690..da847d2 100644 --- a/tools/virt-admin.c +++ b/tools/virt-admin.c @@ -719,9 +719,6 @@ main(int argc, char **argv)
virFileActivateDirOverride(argv[0]);
- if ((defaultConn = virGetEnvBlockSUID("LIBVIRT_DEFAULT_ADMIN_URI"))) - ctl->connname = vshStrdup(ctl, defaultConn); - if (!vshInit(ctl, cmdGroups, NULL)) exit(EXIT_FAILURE);
@@ -731,6 +728,9 @@ main(int argc, char **argv) exit(EXIT_FAILURE); }
+ if ((defaultConn = virGetEnvBlockSUID("LIBVIRT_DEFAULT_ADMIN_URI"))) + ctl->connname = vshStrdup(ctl, defaultConn); + if (!ctl->imode) { ret = vshCommandRun(ctl, ctl->cmd); } else {
^^But I don't think you need this one here, because unlike VIRSH_DEFAULT_CONNECT_URI which is deprecated by LIBVIRT_DEFAULT_URI and we can't drop it, LIBVIRT_DEFAULT_ADMIN_URI isn't and from my perspective the only way for this to not work would be a new virt-admin client and old libvirt-admin library which would not support NULL as connection name which is impossible since none of those were released yet, so in conclusion I don't think that getting the default conn in virt-admin is necessary at all and could be removed. ACK to the first part (for virsh) of the patch. Erik