]> xenbits.xensource.com Git - libvirt.git/commitdiff
vsh: Introduce vshInitReload
authorErik Skultety <eskultet@redhat.com>
Thu, 3 Sep 2015 14:59:01 +0000 (16:59 +0200)
committerErik Skultety <eskultet@redhat.com>
Fri, 4 Sep 2015 12:12:34 +0000 (14:12 +0200)
Commit a0b6a36f separated vshInitDebug from the original vshInit
(before virsh got split and vshInit became virshInit - commit 834c5720)
in order to be able to debug command line parsing.
After the parsing is finished, debugging is reinitialized to work properly.
There might as well be other features that require re-initialization as
the command line could specify parameters that override our defaults which
had been set prior to calling vshArgvParse.

tools/virsh.c
tools/vsh.c
tools/vsh.h

index 77d3754efdfdd477e3f2698af6d43c8ad5e798e2..513c22cde2a47f609fff38daef55d3e0aeca5a03 100644 (file)
@@ -347,8 +347,9 @@ virshInit(vshControl *ctl)
     virshControlPtr priv = ctl->privData;
 
     /* Since we have the commandline arguments parsed, we need to
-     * re-initialize all the debugging to make it work properly */
-    vshInitDebug(ctl);
+     * reload our initial settings to make debugging and readline
+     * work properly */
+    vshInitReload(ctl);
 
     if (priv->conn)
         return false;
index e6ecc0385494c96e55dc1642d4b5ba6e426c113b..1aa8f5bc9d095a9b52a18c4c7504d8bc27141596 100644 (file)
@@ -2738,6 +2738,25 @@ vshInit(vshControl *ctl, const vshCmdGrp *groups, const vshCmdDef *set)
     return true;
 }
 
+bool
+vshInitReload(vshControl *ctl)
+{
+    if (!cmdGroups && !cmdSet) {
+        vshError(ctl, "%s", _("command groups and command are both NULL "
+                              "run vshInit before reloading"));
+        return false;
+    }
+
+    vshInitDebug(ctl);
+
+    if (ctl->imode)
+        vshReadlineDeinit(ctl);
+    if (ctl->imode && vshReadlineInit(ctl) < 0)
+        return false;
+
+    return true;
+}
+
 void
 vshDeinit(vshControl *ctl)
 {
index e2e33ba160e4146affd6955cd1d8f4e4553fb6bc..b6876048cbd9187fd3be01c84337f6324336650b 100644 (file)
@@ -303,6 +303,7 @@ int vshCommandOptTimeoutToMs(vshControl *ctl, const vshCmd *cmd, int *timeout);
 void vshPrintExtra(vshControl *ctl, const char *format, ...)
     ATTRIBUTE_FMT_PRINTF(2, 3);
 bool vshInit(vshControl *ctl, const vshCmdGrp *groups, const vshCmdDef *set);
+bool vshInitReload(vshControl *ctl);
 void vshDeinit(vshControl *ctl);
 void vshInitDebug(vshControl *ctl);
 void vshDebug(vshControl *ctl, int level, const char *format, ...)