1. 12 1月, 2018 4 次提交
    • M
      vshCommandStringParse: Allow retrieving partial result · 2e688d96
      Michal Privoznik 提交于
      In the future, this function is going to be called from
      vshReadlineParse() to provide parsed input for completer
      callbacks. The idea is to allow the callbacks to provide more
      specific data. For instance, for the following input:
      
        virsh # domifaddr --domain fedora --interface <TAB><TAB>
      
      the --interface completer callback is going to be called. Now, it
      is more user friendly if the completer offers only those
      interfaces found in 'fedora' domain. But in order to do that it
      needs to be able to retrieve partially parsed result.
      Signed-off-by: NMichal Privoznik <mprivozn@redhat.com>
      2e688d96
    • M
      vshCommandParse: Don't leak @tkdata · 06e1d36f
      Michal Privoznik 提交于
      When parsing cmd line which has "--" on it, this is leaked.
      Problem is, parser->getNextArg() allocates new string and stores
      it into tkdata. But as soon as "--" is detected 'continue' is
      issued without any free of the allocated memory.
      
        ==5304== 3 bytes in 1 blocks are definitely lost in loss record 1 of 782
        ==5304==    at 0x4C2AF50: malloc (vg_replace_malloc.c:299)
        ==5304==    by 0x8BB5AA9: strdup (strdup.c:42)
        ==5304==    by 0x55842CA: virStrdup (virstring.c:941)
        ==5304==    by 0x172B21: _vshStrdup (vsh.c:162)
        ==5304==    by 0x175E8E: vshCommandArgvGetArg (vsh.c:1622)
        ==5304==    by 0x17551D: vshCommandParse (vsh.c:1418)
        ==5304==    by 0x175F25: vshCommandArgvParse (vsh.c:1638)
        ==5304==    by 0x130940: virshParseArgv (virsh.c:820)
        ==5304==    by 0x130C49: main (virsh.c:922)
      Signed-off-by: NMichal Privoznik <mprivozn@redhat.com>
      06e1d36f
    • M
      vsh: Drop useless check for cmd != NULL · f7844030
      Michal Privoznik 提交于
      All our internal *Free() functions are capable of handling NULL.
      Signed-off-by: NMichal Privoznik <mprivozn@redhat.com>
      f7844030
    • M
      vsh: Drop useless check for opts != NULL · 8010997e
      Michal Privoznik 提交于
      All our internal *Free() functions are capable of handling NULL.
      Signed-off-by: NMichal Privoznik <mprivozn@redhat.com>
      8010997e
  2. 24 11月, 2017 1 次提交
  3. 21 11月, 2017 1 次提交
  4. 12 4月, 2017 1 次提交
    • P
      vsh: Add helper for safe remembering of libvirt errors · 4f4c3b13
      Peter Krempa 提交于
      Avoid the annoying issue where the public object freeing APIs overwrite
      the error set by helper functions, since they don't invoke the callback.
      
      The new helper remembers the error only if no previous error was set.
      4f4c3b13
  5. 09 12月, 2016 1 次提交
  6. 25 11月, 2016 1 次提交
    • M
      virstring: Unify string list function names · c2a5a4e7
      Michal Privoznik 提交于
      We have couple of functions that operate over NULL terminated
      lits of strings. However, our naming sucks:
      
      virStringJoin
      virStringFreeList
      virStringFreeListCount
      virStringArrayHasString
      virStringGetFirstWithPrefix
      
      We can do better:
      
      virStringListJoin
      virStringListFree
      virStringListFreeCount
      virStringListHasString
      virStringListGetFirstWithPrefix
      Signed-off-by: NMichal Privoznik <mprivozn@redhat.com>
      c2a5a4e7
  7. 14 11月, 2016 2 次提交
    • E
      tools: use vshError rather than vshPrint on failure · 53525f91
      Erik Skultety 提交于
      There were a few places in our virsh* code where instead of calling vshError
      on failure we called vshPrint.
      Signed-off-by: NErik Skultety <eskultet@redhat.com>
      53525f91
    • E
      vsh: Drop conditional error reporting in vshErrorHandler · b98b3b74
      Erik Skultety 提交于
      First, since commit 834c5720 the error reporting within the vshErrorHandler
      doesn't work because there was a lot of renaming going on (dull mechanical
      renaming without much thinking about it, yep - shame on me) and so the original
      env variable VIRSH_DEBUG got renamed to VSH_DEBUG which we don't support nor
      document anywhere. Second, by specifying this env variable, the last libvirt
      error gets reported twice despite the fact we say the error reporting should be
      deferred until the command finishes, and last but not least the vintage code's
      logic is a bit 'odd', since the error would get reported iff the env variable
      is set, even if the value should be equal to our DEFAULT value in which case it
      doesn't make sense that we behave differently when an env variable is set to
      some value and when there's no env variable at all but we use the same value
      automatically as default.
      Signed-off-by: NErik Skultety <eskultet@redhat.com>
      b98b3b74
  8. 11 11月, 2016 1 次提交
  9. 04 11月, 2016 1 次提交
  10. 29 10月, 2016 1 次提交
    • J
      vsh: Pass correct values for command line completion · 06a7b1ff
      John Ferlan 提交于
      Commit id 'dcfdf341' passes 'opts_need_arg' and 'opts_seen' to
      vshCmddefGetData, but that seems to be incorrect as those values
      are not initialized properly (something at least one compiler found).
      Instead the static 'const_opts_need_arg' and 'const_opts_seen' values
      should be passed.
      
      By passing unitialized values leads to not finding possible options
      for simpler commands (domfsfreeze for example), where if you're in
      a virsh shell using command line completion - you'll get a list of
      files in your current directory instead of two options --domain and
      --mountpoint (as would happen with this patch applied.
      06a7b1ff
  11. 11 10月, 2016 1 次提交
    • J
      vsh: Fix some issues in auto completion code · f6a4ccdc
      John Ferlan 提交于
      1. Move the declaration of const vshCmdDef *help - it should be at the
         top of the "if" rather than in the middle.
      
      2. Change a comparison from && to || - without doing so we could crash
         on commands like 'virsh list' which would allow completion of some
         non -- option based on whatever was found in the current working
         directory and then as soon as that was completed, the next <tab>
         would crash since "opt" would be returned as NULL, but the check
         was dereferencing "&& opt->type"
      
      3. Before dereferencing opt->completer, be sure opt isn't NULL.
      f6a4ccdc
  12. 05 10月, 2016 1 次提交
    • J
      vsh: Fix warnings in command line completer · 7fe613af
      Jiri Denemark 提交于
      GCC complained that
      
      vsh.c: In function 'vshReadlineOptionsGenerator':
      vsh.c:2622:29: warning: unused variable 'opt' [-Wunused-variable]
               const vshCmdOptDef *opt = &cmd->opts[list_index];
                                   ^
      vsh.c: In function 'vshReadlineParse':
      vsh.c:2830:44: warning: 'opt' may be used uninitialized in this function
      [-Wmaybe-uninitialized]
                   completed_list = opt->completer(autoCompleteOpaque,
      Signed-off-by: NJiri Denemark <jdenemar@redhat.com>
      7fe613af
  13. 29 9月, 2016 1 次提交
    • J
      vsh: Write out history on "quit" or "exit" in interactive mode · bcfa2f42
      John Ferlan 提交于
      https://bugzilla.redhat.com/show_bug.cgi?id=1379895
      
      Introduced by commit id '834c5720'.
      
      During the code motion and creation of vsh.c, the function 'vshDeinit()'
      in the (new) vsh.c was altered from whence it came in virsh.c such that
      calling 'vshReadlineDeinit(ctl)' was conditional on "ctl->imode".
      
      This causes a problem for the interactive running if the "quit" and "exit"
      commands are used because 'cmdQuit' will clear ctl->imode, thus when the
      interactive loop in main() of virsh.c exits because ctl->mode is clear and
      virshDeinit is called which calls vshDeinit, the history file is now not
      written. Conversely, if one had exited the interactive loop via pressing
      <ctrl>D the file would be created because loop control is broken on EOF
      and ctl->imode is not set to false.
      
      This patch will remove the conditional call to vshReadlineDeinit and
      restore the former behaviour.
      bcfa2f42
  14. 20 9月, 2016 6 次提交
  15. 14 9月, 2016 1 次提交
  16. 06 9月, 2016 1 次提交
  17. 05 9月, 2016 3 次提交
  18. 28 7月, 2016 4 次提交
    • E
      tools: Make use of the correct environment variables · d02ef334
      Erik Skultety 提交于
      Since commit 834c5720 which extracted the generic functionality out of virsh
      and made it available for other clients like virt-admin to make use of it, it
      also introduced a bug when it renamed the original VIRSH_ environment variables
      to VSH_ variables. Virt-admin of course suffers from the same bug, so this
      patch modifies the generic module vsh.c to construct the correct name for
      environment variables of each client from information it has.
      
      Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1357363Signed-off-by: NErik Skultety <eskultet@redhat.com>
      d02ef334
    • E
      vsh: Make vshInitDebug return int instead of void · 0ef07e19
      Erik Skultety 提交于
      Well, the reason behind this change is that if the function is extended in some
      way that e.g. would involve allocation we do not have a way of telling it to
      the caller. More specifically, vshInitDebug only relies on some hardcoded
      environment variables (by a mistake) that aren't documented anywhere so neither
      virsh's nor virt-admin's documented environment variables take effect. One
      possible solution would be duplicate the code for each CLI client or leave the
      method be generic and provide means that it could figure out, which client
      called it, thus initializing the proper environment variables but that could
      involve operations that might as well fail in certain circumstances and the
      caller should know that an error occurred.
      Signed-off-by: NErik Skultety <eskultet@redhat.com>
      0ef07e19
    • M
      vshReadlineParse: Drop some unused variables · ea2ad171
      Michal Privoznik 提交于
      My compiler identified some variables that were set, but never
      actually used. For instance, opts_required, and data_acomplete.
      Signed-off-by: NMichal Privoznik <mprivozn@redhat.com>
      ea2ad171
    • M
      vshCmddefGetOption: Change type of opt_index · 2bc97f27
      Michal Privoznik 提交于
      This function tries to look up desired option for a given parsed
      command. Upon successful return it also stores option position
      into passed *opt_index. Now, this variable is type of int, even
      though it is never ever used to store negative value. Moreover,
      the variable is set from a local variable which is type of
      size_t.
      Signed-off-by: NMichal Privoznik <mprivozn@redhat.com>
      2bc97f27
  19. 19 7月, 2016 1 次提交
    • J
      vsh: Properly initialize res · bd93ba64
      John Ferlan 提交于
      The 'res' variable was only being initialized to NULL in the
      if (!state) path; however, that path never used res and evenutally
      res is assigned one of two results based on a pair of if then else if
      conditions. If for some reason neither of those paths was taken and
      the (!state) path wasn't taken, then 'res' would be indeterminate.
      
      Found by Coverity, probably a false positive based on code paths, but
      better safe than sorry for the future.
      Signed-off-by: NJohn Ferlan <jferlan@redhat.com>
      bd93ba64
  20. 11 7月, 2016 4 次提交
  21. 22 6月, 2016 1 次提交
  22. 18 6月, 2016 1 次提交
  23. 29 4月, 2016 1 次提交