mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-21 22:03:49 +03:00
Fix URI connect precedence
Commit abfff210 changed the order of vshParseArgv() and vshInit() in order to make fix debugging of parameter parsing. However, vshInit() did a vshReconnect() even though ctl->name wasn't set according to the '-c' parameter yet. In order to keep both issues fixed, I've split the vshInit() into vshInitDebug() and vshInit(). One simple memleak of ctl->name is fixed as a part of this patch, since it is related to the issue it's fixing. Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=999323 (cherry picked from commit a0b6a36f9456dae895f50d344fd2d38be1167c58)
This commit is contained in:
parent
011d67bfaa
commit
900d44d70b
@ -2293,16 +2293,13 @@ vshEventLoop(void *opaque)
|
|||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Initialize connection.
|
* Initialize debug settings.
|
||||||
*/
|
*/
|
||||||
static bool
|
static void
|
||||||
vshInit(vshControl *ctl)
|
vshInitDebug(vshControl *ctl)
|
||||||
{
|
{
|
||||||
char *debugEnv;
|
char *debugEnv;
|
||||||
|
|
||||||
if (ctl->conn)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
if (ctl->debug == VSH_DEBUG_DEFAULT) {
|
if (ctl->debug == VSH_DEBUG_DEFAULT) {
|
||||||
/* log level not set from commandline, check env variable */
|
/* log level not set from commandline, check env variable */
|
||||||
debugEnv = getenv("VIRSH_DEBUG");
|
debugEnv = getenv("VIRSH_DEBUG");
|
||||||
@ -2327,6 +2324,16 @@ vshInit(vshControl *ctl)
|
|||||||
}
|
}
|
||||||
|
|
||||||
vshOpenLogFile(ctl);
|
vshOpenLogFile(ctl);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Initialize connection.
|
||||||
|
*/
|
||||||
|
static bool
|
||||||
|
vshInit(vshControl *ctl)
|
||||||
|
{
|
||||||
|
if (ctl->conn)
|
||||||
|
return false;
|
||||||
|
|
||||||
/* set up the library error handler */
|
/* set up the library error handler */
|
||||||
virSetErrorFunc(NULL, virshErrorHandler);
|
virSetErrorFunc(NULL, virshErrorHandler);
|
||||||
@ -3016,6 +3023,7 @@ vshParseArgv(vshControl *ctl, int argc, char **argv)
|
|||||||
ctl->timing = true;
|
ctl->timing = true;
|
||||||
break;
|
break;
|
||||||
case 'c':
|
case 'c':
|
||||||
|
VIR_FREE(ctl->name);
|
||||||
ctl->name = vshStrdup(ctl, optarg);
|
ctl->name = vshStrdup(ctl, optarg);
|
||||||
break;
|
break;
|
||||||
case 'v':
|
case 'v':
|
||||||
@ -3191,12 +3199,10 @@ main(int argc, char **argv)
|
|||||||
ctl->name = vshStrdup(ctl, defaultConn);
|
ctl->name = vshStrdup(ctl, defaultConn);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!vshInit(ctl)) {
|
vshInitDebug(ctl);
|
||||||
vshDeinit(ctl);
|
|
||||||
exit(EXIT_FAILURE);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!vshParseArgv(ctl, argc, argv)) {
|
if (!vshParseArgv(ctl, argc, argv) ||
|
||||||
|
!vshInit(ctl)) {
|
||||||
vshDeinit(ctl);
|
vshDeinit(ctl);
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user