On Fri, Sep 04, 2015 at 01:10:05PM +0200, Erik Skultety wrote: > 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 | 5 +++-- > tools/vsh.c | 16 ++++++++++++++++ > tools/vsh.h | 1 + > 3 files changed, 20 insertions(+), 2 deletions(-) > > diff --git a/tools/virsh.c b/tools/virsh.c > index 5317be8..bb12dec 100644 > --- a/tools/virsh.c > +++ b/tools/virsh.c > @@ -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; > diff --git a/tools/vsh.c b/tools/vsh.c > index e6ecc03..d4059fc 100644 > --- a/tools/vsh.c > +++ b/tools/vsh.c > @@ -2738,6 +2738,22 @@ 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 && vshReadlineInit(ctl) < 0) You add another vshReadlineInit call here, but do not remove the one in vshInit. Just calling vshInit might make sense for callers that know upfront they are running in interactive mode. But we should call vshReadlineDeInit to prevent a memory leak if they call vshInitReload too. Jan
Attachment:
signature.asc
Description: Digital signature
-- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list