1. 12 1月, 2018 2 次提交
    • M
      vshCommandOpt: Allow caller avoiding assert() · a26ff63a
      Michal Privoznik 提交于
      In the future, completer callbacks will receive partially parsed
      command (and thus possibly incomplete). However, we still want
      them to use command options fetching APIs we already have (e.g.
      vshCommandOpt*()) and at the same time don't report any errors
      (nor call any asserts).
      Signed-off-by: NMichal Privoznik <mprivozn@redhat.com>
      Reviewed-by: NJohn Ferlan <jferlan@redhat.com>
      a26ff63a
    • 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
  2. 03 11月, 2017 1 次提交
    • A
      Remove backslash alignment attempts · 3e7db8d3
      Andrea Bolognani 提交于
      Right-aligning backslashes when defining macros or using complex
      commands in Makefiles looks cute, but as soon as any changes is
      required to the code you end up with either distractingly broken
      alignment or unnecessarily big diffs where most of the changes
      are just pushing all backslashes a few characters to one side.
      
      Generated using
      
        $ git grep -El '[[:blank:]][[:blank:]]\\$' | \
          grep -E '*\.([chx]|am|mk)$$' | \
          while read f; do \
            sed -Ei 's/[[:blank:]]*[[:blank:]]\\$/ \\/g' "$f"; \
          done
      Signed-off-by: NAndrea Bolognani <abologna@redhat.com>
      3e7db8d3
  3. 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
  4. 20 9月, 2016 1 次提交
    • E
      virt-admin: Tweak command parsing logic so that aliases point to new commands · b9d8cade
      Erik Skultety 提交于
      Change the logic in a way, so that VSH_CMD_FLAG_ALIAS behaves similarly to
      how VSH_OT_ALIAS for command options, i.e. there is no need for code duplication
      for the alias and the aliased command structures. Along with that change,
      switch any existing VSH_CMD_FLAG_ALIAS occurrences to this new format. Also,
      since this patch introduces a new command structure element, adjust the
      virsh-self-test test to make sure we won't ever miss to specify the '.alias'
      member for an aliased command because doing that would lead to an internal
      error.
      Signed-off-by: NErik Skultety <eskultet@redhat.com>
      b9d8cade
  5. 14 9月, 2016 1 次提交
  6. 06 9月, 2016 1 次提交
  7. 28 7月, 2016 1 次提交
  8. 22 6月, 2016 1 次提交
  9. 29 3月, 2016 1 次提交
    • P
      vsh: Introduce helper to parse --bandwidth · d18e78c2
      Peter Krempa 提交于
      Historically we've used 'unsigned long' and allowed wrapping of negative
      numbers for bandwidth values. Add a helper that will simplify adding
      support for scaled integers and support for byte granularity while
      keeping the compatibility with the older approach.
      d18e78c2
  10. 15 2月, 2016 1 次提交
    • P
      vsh: Replace vshPrint macro with function · 27fa42b2
      Peter Krempa 提交于
      The macro would eat the first parameter. In some cases the format string
      for vshPrint was eaten. In other cases the calls referenced variables
      which did not exist in the given context. Avoid errors by doing compile
      time checking.
      27fa42b2
  11. 21 12月, 2015 1 次提交
    • E
      Revert "admin: Rename virAdmConnect to virAdmDaemon" · 3245e178
      Erik Skultety 提交于
      Commmit df8192aa introduced admin related rename and some minor
      (caused by automated approach, aka sed) and some more severe isues along with
      it. First reason to revert is the inconsistency with libvirt library.
      Although we deal with the daemon directly rather than with a specific
      hypervisor, we still do have a connection. That being said, contributors might
      get under the impression that AdmDaemonNew would spawn/start a new daemon
      (since it's admin API, why not...), or AdmDaemonClose would do the exact
      opposite or they might expect DaemonIsAlive report overall status of the daemon
      which definitely isn't the case.
      The second reason to revert this patch is renaming virt-admin client. The
      client tool does not necessarily have to reflect the names of the API's it's
      using in his internals. An example would be 's/vshAdmConnect/vshAdmDaemon'
      where noone can be certain of what the latter function really does. The former
      is quite expressive about some connection magic it performs, but the latter does
      not say anything, especially when vshAdmReconnect and vshAdmDisconnect were
      left untouched.
      3245e178
  12. 09 12月, 2015 1 次提交
  13. 01 12月, 2015 1 次提交
    • M
      admin: Rename virAdmConnect to virAdmDaemon · df8192aa
      Martin Kletzander 提交于
      virAdmConnect was named after virConnect, but after some discussions,
      most of the APIs called will be working with remote daemon and starting
      them virAdmDaemon will make more sense.  Only possibly controversal name
      is CloseCallback (de)registration, and connecting to the daemon (which
      will still be Open/Close), but even this makes sense if one thinks about
      the daemon being opened and closed, e.g. as file, etc.
      
      This way all the APIs working with the daemon will start with
      virAdmDaemon prefix, they will accept virAdmDaemonPtr as first parameter
      and that will better suit with other namings as well (virDomain*,
      virAdmServer*, etc.).
      
      Because in virt-admin, the connection name does not refer to a struct
      that would have a connect in its name, also adjust 'connname' in
      clients.  And because it is not used anywhere in the vsh code, move it
      from there into each client.
      Signed-off-by: NMartin Kletzander <mkletzan@redhat.com>
      df8192aa
  14. 04 9月, 2015 3 次提交
    • E
      vsh: Make vshInitDebug static · 682775fb
      Erik Skultety 提交于
      There's no reason why debug initialization could not be made completely
      hidden, just like readline initialization is. The point of the global
      initializer vshInit is to make initialization of smaller features transparent
      to the user/caller.
      682775fb
    • E
      vsh: Introduce vshInitReload · f59d51f5
      Erik Skultety 提交于
      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.
      f59d51f5
    • E
      vsh: adjust vshInit signature and remove redundant error label · 57b8a388
      Erik Skultety 提交于
      As part of the effort to stay consistent, change the vshInit signature
      from returning int to returning bool. Moreover, remove the
      unnecessary error label as there is no cleanup that would make use of
      it.
      57b8a388
  15. 14 8月, 2015 1 次提交
    • E
      tools: Introduce new client generic module vsh · 834c5720
      Erik Skultety 提交于
      In order to share as much virsh' logic as possible with upcomming
      virt-admin client we need to split virsh logic into virsh specific and
      client generic features.
      
      Since majority of virsh methods should be generic enough to be used by
      other clients, it's much easier to rename virsh specific data to virshX
      than doing this vice versa. It moved generic virsh commands (including info
      and opts structures) to generic module vsh.c.
      
      Besides renaming methods and structures, this patch also involves introduction
      of a client specific control structure being referenced as private data in the
      original control structure, introduction of a new global vsh Initializer,
      which currently doesn't do much, but there is a potential for added
      functionality in the future.
      Lastly it introduced client hooks which are especially necessary during
      client connecting phase.
      834c5720
  16. 02 6月, 2015 1 次提交
    • A
      virsh: Pass vshControl to all vshCommandOpt*() calls · be6ff4da
      Andrea Bolognani 提交于
      This will allow us to use vshError() to report errors from inside
      vshCommandOpt*(), instead of replicating the same logic and error
      messages all over the place.
      
      We also have more context inside the vshCommandOpt*() functions,
      for example the actual value used on the command line, which means
      we can produce more detailed error messages.
      
      vshCommandOptBool() is the exception here, because it's explicitly
      designed not to report any error.
      be6ff4da
  17. 04 5月, 2015 1 次提交
  18. 15 4月, 2015 1 次提交
    • E
      virsh: fix regression in 'virsh event' by domain · 31ef0836
      Eric Blake 提交于
      Commit a0670aef caused a regression in 'virsh event' and
      'virsh qemu-monitor-event' - if a user tries to filter the
      command to a specific domain, an error message is printed:
      
      $ virsh event dom --loop
      error: internal error: virsh qemu-monitor-event: no domain VSH_OT_DATA option
      
      and then the command continues as though no domain had been
      supplied (giving events for ALL domains, instead of the
      requested one).  This is because the code was incorrectly
      assuming that all "domain" options would be supplied via a
      mandatory VSH_OT_DATA, even though "domain" is optional for
      these two commands, so we had changed them to VSH_OT_STRING
      to quit failing for other reasons (ever since it was decided
      that VSH_OT_DATA and VSH_OT_STRING should no longer be
      synonyms).
      
      In looking at the situation, though, the code for looking up
      a domain was making a pointless check for whether the option
      exists prior to finding the option's string value, as
      vshCommandOptStringReq does just fine at reporting any errors
      when looking up a string whether or not the option was present.
      
      So this is a case of regression fixing by pure code deletion :)
      
      * tools/virsh-domain.c (vshCommandOptDomainBy): Drop useless filter.
      * tools/virsh-interface.c (vshCommandOptInterfaceBy): Likewise.
      * tools/virsh-network.c (vshCommandOptNetworkBy): Likewise.
      * tools/virsh-nwfilter.c (vshCommandOptNWFilterBy): Likewise.
      * tools/virsh-secret.c (vshCommandOptSecret): Likewise.
      * tools/virsh.h (vshCmdHasOption): Drop unused function.
      * tools/virsh.c (vshCmdHasOption): Likewise.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      31ef0836
  19. 02 4月, 2015 2 次提交
  20. 20 2月, 2015 1 次提交
    • M
      virsh-edit: Make force editing usable · 1bb1de83
      Martin Kletzander 提交于
      When editing a domain with 'virsh edit' and failing validation, the
      usual message pops up:
      
        Failed. Try again? [y,n,f,?]:
      
      Turning off validation can be useful, mainly for testing (but other
      purposes too), so this patch adds support for relaxing definition in
      virsh-edit and makes 'virsh edit <domain>' more usable.
      Signed-off-by: NMartin Kletzander <mkletzan@redhat.com>
      1bb1de83
  21. 06 9月, 2014 1 次提交
    • E
      blockjob: add new --bytes flag to virsh blockjob · 1105c1de
      Eric Blake 提交于
      Expose the new flag just added to virDomainGetBlockJobInfo.
      With --raw, the presence or absence of --bytes determines which
      flag to use in the single API call.  Without --raw, the use of
      --bytes forces an error if the server doesn't support it,
      otherwise, the code tries to silently fall back to scaling the
      MiB/s value.
      
      My goal is to eventually also support --bytes in bandwidth mode;
      but that's a bit further down the road (and needs a new API flag
      added in libvirt.h first).
      
      This changes the human output, but the previous patch added
      raw output precisely so that we can have flexibility with the
      human output.  For this commit, I used qemu-monitor-command to
      force an unusual bandwidth, but the same will be possible once
      qemu implements virDomainBlockCopy:
      
      Before:
      Block Copy: [100 %]    Bandwidth limit: 2 MiB/s
      After:
      Block Copy: [100 %]    Bandwidth limit: 1048577 bytes/s (1.000 MiB/s)
      
      The cache avoids having to repeatedly checking whether the flag
      works when talking to an older server, when multiple blockjob
      commands are issued during a batch session and the user is
      manually polling for job completion.
      
      * tools/virsh.h (_vshControl): Add a cache.
      * tools/virsh.c (cmdConnect, vshReconnect): Initialize the cache.
      * tools/virsh-domain.c (opts_block_job): Add --bytes.
      * tools/virsh.pod (blockjob): Document this.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      1105c1de
  22. 19 8月, 2014 1 次提交
    • C
      cmdMigrate: move vshConnect before vshWatchJob · 7eabd550
      Chunyan Liu 提交于
      A possible fix to issue:
      http://www.redhat.com/archives/libvir-list/2014-August/thread.html#00227
      
      While doing migration on KVM host, found problem sometimes:
      VM is already running on the target host and disappears from source
      host, but 'virsh migrate' command line hangs, cannot exit normally.
      If pressing "ENTER" key, it will exit.
      
      The code hangs at tools/virsh-domain.c: cmdMigrate
      ->vshWatchJob->poll():
      poll() is trying to select pipe_fd, which is used to receive message
      from doMigrate thread. In debugging, found that doMigrate finishes
      and at the end it does call safewrite() to write the retval ('0' or
      '1') to pipe_fd, and the write is completed. But cmdMigrate poll()
      cannot get the event. If pressing "ENTER" key, poll() can get the
      event and select pipe_fd, then command line can exit.
      
      In current code, authentication thread which is called by vshConnect
      will use stdin, and at the same time, in cmdMigrate main process,
      poll() is listening to stdin, that probably affect poll() to get
      pipe_fd event. Better to move authentication before vshWatchJob. With
      this change, above problem does not exist.
      Signed-off-by: NChunyan Liu <cyliu@suse.com>
      7eabd550
  23. 12 6月, 2014 3 次提交
    • P
      virsh: Reject negative numbers in vshCommandOptULongLong · c6212539
      Peter Krempa 提交于
      To follow the new semantics of the vshCommandOptToU* functions convert
      this one to reject negative numbers too. To allow using -1 for "maximum"
      semantics for the vol-*load two bandwidth functions that use this helper
      introduce vshCommandOptULongLongWrap.
      c6212539
    • P
      virsh: Reject negative numbers in vshCommandOptUL · 0e2d7305
      Peter Krempa 提交于
      To follow the new semantics of the vshCommandOptToU* functions convert
      this one to reject negative numbers too. To allow using -1 for "maximum"
      semantics for the two bandwidth functions that use this helper introduce
      vshCommandOptULWrap. Although currently the migrate-setspeed function
      for the qemu driver will reject -1 as maximum.
      0e2d7305
    • P
      virsh: Reject negative numbers in vshCommandOptUInt · 37e663ad
      Peter Krempa 提交于
      Use virStrToLong_uip instead of virStrToLong_ui to reject negative
      numbers in the helper. None of the callers expects the wraparound
      "feature" for negative numbers.
      
      Also add a function that allows wrapping of negative numbers as it might
      be used in the future and be explicit about the new semantics in the
      function docs.
      37e663ad
  24. 09 4月, 2014 1 次提交
  25. 18 3月, 2014 1 次提交
    • M
      virsh: Add keepalive in new vshConnect function · 676cb4f4
      Martin Kletzander 提交于
      Introducing keepalive similarly to Guannan around 2 years ago.  Since
      we want to introduce keepalive for every connection, it makes sense to
      wrap the connecting function into new virsh one that can deal
      keepalive as well.
      
      Function vshConnect() is now used for connecting and keepalive added
      in that function (if possible) helps preventing long waits e.g. while
      nework goes down during migration.
      
      This patch also adds the options for keepalive tuning into virsh and
      fails connecting only when keepalives are explicitly requested and
      cannot be set (whether it is due to missing support in connected
      driver or remote server).  If not explicitely requested, a debug
      message is printed (hence the addition to virsh-optparse test).
      
      Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1073506
      Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=822839Signed-off-by: NMartin Kletzander <mkletzan@redhat.com>
      676cb4f4
  26. 21 2月, 2014 2 次提交
    • E
      virsh: common code for waiting for an event · 4c29530d
      Eric Blake 提交于
      I plan to add 'virsh event' to virsh-domain.c and 'virsh
      net-event' to virsh-network.c; but as they will share quite
      a bit of common boilerplate, it's better to set that up now
      in virsh.c.
      
      * tools/virsh.h (_vshControl): Add fields.
      (vshEventStart, vshEventWait, vshEventDone, vshEventCleanup): New
      prototypes.
      * tools/virsh.c (vshEventFd, vshEventOldAction, vshEventInt)
      (vshEventTimeout): New helper variables and functions.
      (vshEventStart, vshEventWait, vshEventDone, vshEventCleanup):
      Implement new functions.
      (vshInit, vshDeinit, main): Manage event timeout.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      4c29530d
    • E
      virsh: common code for parsing --seconds · 5093b047
      Eric Blake 提交于
      Several virsh commands ask for a --timeout parameter in
      seconds, then use it to control interfaces that operate on
      millisecond limits; I also plan on adding a 'virsh event'
      command that also does this.  Factor this into a common
      function.
      
      * tools/virsh.h (vshCommandOptTimeoutToMs): New prototype.
      * tools/virsh.c (vshCommandOptTimeoutToMs): New function.
      * tools/virsh-domain.c (cmdBlockCommit, cmdBlockCopy)
      (cmdBlockPull, cmdMigrate): Use it.
      (vshWatchJob): Adjust timeout scale.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      5093b047
  27. 22 10月, 2013 1 次提交
    • P
      virsh: Fix job watching when STDIN is not a tty · 47e63966
      Peter Krempa 提交于
      In commit b46c4787 I changed the code to
      watch long running jobs in virsh. Unfortunately I didn't take into
      account that poll may get a hangup if the terminal is not a TTY and will
      be closed.
      
      This patch avoids polling the STDIN fd when there's no TTY.
      47e63966
  28. 18 9月, 2013 1 次提交
  29. 05 9月, 2013 1 次提交
    • E
      virsh: fix build on mingw, which lacks termios stuff · 7e1cbd14
      Eric Blake 提交于
      Recent patches to fix handling of Ctrl-C when interacting with
      ssh are not portable to mingw, which lacks termios handling.
      The simplest solution is to just compile that code out, and
      if someone ever appears that has a serious interest in getting
      virsh fully functional even with ssh connections, they can
      provide patches at that time.
      
      * tools/virsh.h (_vshControl): Make termattr conditional.
      * tools/virsh.c (vshTTYIsInterruptCharacter)
      (vshTTYDisableInterrupt, vshTTYRestore, cfmakeraw, vshTTYMakeRaw)
      (main): Likewise.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      7e1cbd14
  30. 03 9月, 2013 2 次提交
  31. 29 8月, 2013 1 次提交
    • E
      virsh: detect programming errors with option parsing · 8aecd351
      Eric Blake 提交于
      Noticed while reviewing another patch that had an accidental
      mismatch due to refactoring.  An audit of the code showed that
      very few callers of vshCommandOpt were expecting a return of
      -2, indicating programmer error, and of those that DID check,
      they just propagated that status to yet another caller that
      did not check.  Fix this by making the code blatantly warn
      the programmer, rather than silently ignoring it and possibly
      doing the wrong thing downstream.
      
      I know that we frown on assert()/abort() inside libvirtd
      (libraries should NEVER kill the program that linked them),
      but as virsh is an app rather than the library, and as this
      is not the first use of assert() in virsh, I think this
      approach is okay.
      
      * tools/virsh.h (vshCommandOpt): Drop declaration.
      * tools/virsh.c (vshCommandOpt): Make static, and add a
      parameter.  Abort on programmer errors rather than making callers
      repeat that logic.
      (vshCommandOptInt, vshCommandOptUInt, vshCommandOptUL)
      (vshCommandOptString, vshCommandOptStringReq)
      (vshCommandOptLongLong, vshCommandOptULongLong)
      (vshCommandOptBool): Adjust callers.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      8aecd351
  32. 20 8月, 2013 1 次提交
    • P
      virsh: modify vshStringToArray to duplicate the elements too · d64af6ce
      Peter Krempa 提交于
      At a slightly larger memory expense allow stealing of items from the
      string array returned from vshStringToArray and turn the result into a
      string list compatible with virStringSplit. This will allow to use the
      common dealloc function.
      
      This patch also fixes a few forgotten checks of return from
      vshStringToArray and one memory leak.
      d64af6ce