/*
- * Initialize connection.
+ * Initialize debug settings.
*/
-static bool
-vshInit(vshControl *ctl)
+static void
+vshInitDebug(vshControl *ctl)
{
char *debugEnv;
- if (ctl->conn)
- return false;
-
if (ctl->debug == VSH_DEBUG_DEFAULT) {
/* log level not set from commandline, check env variable */
debugEnv = getenv("VIRSH_DEBUG");
}
vshOpenLogFile(ctl);
+}
+
+/*
+ * Initialize connection.
+ */
+static bool
+vshInit(vshControl *ctl)
+{
+ if (ctl->conn)
+ return false;
/* set up the library error handler */
virSetErrorFunc(NULL, virshErrorHandler);
ctl->timing = true;
break;
case 'c':
+ VIR_FREE(ctl->name);
ctl->name = vshStrdup(ctl, optarg);
break;
case 'v':
ctl->name = vshStrdup(ctl, defaultConn);
}
- if (!vshInit(ctl)) {
- vshDeinit(ctl);
- exit(EXIT_FAILURE);
- }
+ vshInitDebug(ctl);
- if (!vshParseArgv(ctl, argc, argv)) {
+ if (!vshParseArgv(ctl, argc, argv) ||
+ !vshInit(ctl)) {
vshDeinit(ctl);
exit(EXIT_FAILURE);
}