[libvirt] Enable authentication for all virConnectOpen calls in virsh

Hello, virsh opens connections in three places (init, connect, migrate) but only connections initiated from the command line (the -c option) are opened with authentication. The attached patch enables the two other places to use authentication too. Ciao Matthias

On Sat, Mar 21, 2009 at 02:52:50PM +0100, Matthias Bolte wrote:
Hello,
virsh opens connections in three places (init, connect, migrate) but only connections initiated from the command line (the -c option) are opened with authentication.
The attached patch enables the two other places to use authentication too.
ACK, this looks good to me.
diff --git a/src/virsh.c b/src/virsh.c index 9a7b0ed..abbd93b 100644 --- a/src/virsh.c +++ b/src/virsh.c @@ -468,13 +468,14 @@ cmdConnect(vshControl *ctl, const vshCmd *cmd) ctl->name = vshStrdup(ctl, vshCommandOptString(cmd, "name", NULL));
if (!ro) { - ctl->conn = virConnectOpen(ctl->name); ctl->readonly = 0; } else { - ctl->conn = virConnectOpenReadOnly(ctl->name); ctl->readonly = 1; }
+ ctl->conn = virConnectOpenAuth(ctl->name, virConnectAuthPtrDefault, + ctl->readonly ? VIR_CONNECT_RO : 0); + if (!ctl->conn) vshError(ctl, FALSE, "%s", _("Failed to connect to the hypervisor"));
@@ -2315,7 +2316,7 @@ cmdMigrate (vshControl *ctl, const vshCmd *cmd) flags |= VIR_MIGRATE_LIVE;
/* Temporarily connect to the destination host. */ - dconn = virConnectOpen (desturi); + dconn = virConnectOpenAuth (desturi, virConnectAuthPtrDefault, 0); if (!dconn) goto done;
/* Migrate. */
Daniel -- |: Red Hat, Engineering, London -o- http://people.redhat.com/berrange/ :| |: http://libvirt.org -o- http://virt-manager.org -o- http://ovirt.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|
participants (2)
-
Daniel P. Berrange
-
Matthias Bolte