mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 13:45:38 +00:00
virsh: Fix debugging
Commita0b6a36f
"fixed" whatabfff210
broke (URI precedence), but there was still one more thing missing to fix. When using virsh parameters to setup debugging, those weren't honored, because at the time debugging was initializing, arguments weren't parsed yet. To make ewerything work as expected, we need to initialize the debugging twice, once before debugging (so we can debug option parsing properly) and then again after these options are parsed. As a side effect, this patch also fixes a leak when virsh is ran with multiple '-l' parameters. Signed-off-by: Martin Kletzander <mkletzan@redhat.com> (cherry picked from commitac43da705f
)
This commit is contained in:
parent
b2dff00160
commit
7ccb873552
@ -2321,10 +2321,9 @@ vshInitDebug(vshControl *ctl)
|
|||||||
debugEnv = getenv("VIRSH_LOG_FILE");
|
debugEnv = getenv("VIRSH_LOG_FILE");
|
||||||
if (debugEnv && *debugEnv) {
|
if (debugEnv && *debugEnv) {
|
||||||
ctl->logfile = vshStrdup(ctl, debugEnv);
|
ctl->logfile = vshStrdup(ctl, debugEnv);
|
||||||
|
vshOpenLogFile(ctl);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
vshOpenLogFile(ctl);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -2333,6 +2332,10 @@ vshInitDebug(vshControl *ctl)
|
|||||||
static bool
|
static bool
|
||||||
vshInit(vshControl *ctl)
|
vshInit(vshControl *ctl)
|
||||||
{
|
{
|
||||||
|
/* Since we have the commandline arguments parsed, we need to
|
||||||
|
* re-initialize all the debugging to make it work properly */
|
||||||
|
vshInitDebug(ctl);
|
||||||
|
|
||||||
if (ctl->conn)
|
if (ctl->conn)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@ -3039,7 +3042,9 @@ vshParseArgv(vshControl *ctl, int argc, char **argv)
|
|||||||
ctl->readonly = true;
|
ctl->readonly = true;
|
||||||
break;
|
break;
|
||||||
case 'l':
|
case 'l':
|
||||||
|
vshCloseLogFile(ctl);
|
||||||
ctl->logfile = vshStrdup(ctl, optarg);
|
ctl->logfile = vshStrdup(ctl, optarg);
|
||||||
|
vshOpenLogFile(ctl);
|
||||||
break;
|
break;
|
||||||
case 'e':
|
case 'e':
|
||||||
len = strlen(optarg);
|
len = strlen(optarg);
|
||||||
|
Loading…
Reference in New Issue
Block a user