1. 11 6月, 2012 2 次提交
    • E
      virsh: remove limits on tree listing · ef981053
      Eric Blake 提交于
      I am not a fan of fixed-width buffers.  All it takes is a
      linear chain of more than 100 snapshots to mess up 'virsh
      snapshot-list --tree'.  Now that virBuffer is more powerful,
      we might as well exploit its power.
      
      * tools/virsh.c (cmdNodeListDevicesPrint): Simplify to use a
      virBuffer instead of fixed-width prefix, factor guts, and rename...
      (vshTreePrint, vshTreePrintInternal): ...along with new helper.
      (cmdNodeListDevices, cmdSnapshotList): Update callers.
      ef981053
    • E
      snapshot: avoid virsh crash with older servers · d9f60665
      Eric Blake 提交于
      Commits 51082301, 16d7b390, and 521cc447 introduced support for
      'virsh snapshot-list --from' when talking to a server older than
      0.9.5, but broke support for plain 'virsh snapshot-list' for the
      same old server in the process.  Because the code is not properly
      gated, we end up with a SIGSEGV during a strcmp with a NULL argument.
      
      * tools/virsh.c (cmdSnapshotList): Don't waste time on fallbacks
      when --from is not present.
      d9f60665
  2. 07 6月, 2012 1 次提交
    • E
      build: fix build without i18n · b2ecfe97
      Eric Blake 提交于
      If you compile without NLS support, where _() is a no-op macro,
      then we end up passing a string literal to a char*, provoking:
      
      In file included from virsh.c:3639:0:
      virsh-edit.c: In function ‘cmdSaveImageEdit’:
      virsh-edit.c:97:13: error: assignment discards ‘const’ qualifier from pointer target type [-Werror]
      virsh-edit.c:106:13: error: assignment discards ‘const’ qualifier from pointer target type [-Werror]
      
      * tools/virsh-edit.c: Be const-safe.
      b2ecfe97
  3. 05 6月, 2012 3 次提交
  4. 04 6月, 2012 1 次提交
  5. 02 6月, 2012 2 次提交
    • M
      virsh: Allow users to reedit rejected XML · a7de0523
      Michal Privoznik 提交于
      If users *-edit but make a mistake in XML all changes are
      permanently lost. However, if virsh is not running within
      a script we can ask user if he wants to re-edit the file
      and correct the mistakes.
      a7de0523
    • M
      virsh: Switch from generated cmd*Edit commands to nongenerated · 0766783a
      Michal Privoznik 提交于
      Currently, we either generate some cmd*Edit commands (cmdPoolEdit
      and cmdNetworkEdit) via sed script or copy the body of cmdEdit
      (e.g. cmdInterfaceEdit, cmdNWFilterEdit, etc.). This fact makes
      it harder to implement any new feature to our editing system.
      Therefore switch to new implementation - define macros to:
      - dump XML (EDIT_GET_XML)
      - take an action if XML wasn't changed,
        usually just vshPrint() (EDIT_NOT_CHANGED)
      - define new object (EDIT_DEFINE) - the edited XML is in @doc_edited
      - free object defined by EDIT_DEFINE (EDIT_FREE)
      and #include "virsh-edit.c"
      0766783a
  6. 31 5月, 2012 1 次提交
  7. 29 5月, 2012 1 次提交
    • E
      virsh: avoid strncpy · dc4301c7
      Eric Blake 提交于
      strncpy is generally evil - it runs the risk of missing NUL
      termination, and more often than not wastes time zeroing way
      more bytes than strictly necessary.  We've avoided this evil
      in our virStrncpy wrapper, except for places where we forgot
      to use the wrapper; meanwhile, we have also added an even
      higher layer wrapper for setting virTypedParameter values.
      
      * tools/virsh.c (cmdMemtune, cmdBlkdeviotune): Use modern API.
      * cfg.mk (exclude_file_name_regexp--sc_prohibit_strncpy): Tighten.
      dc4301c7
  8. 28 5月, 2012 2 次提交
  9. 22 5月, 2012 1 次提交
    • W
      storage backend: Add RBD (RADOS Block Device) support · 74951ead
      Wido den Hollander 提交于
      This patch adds support for a new storage backend with RBD support.
      
      RBD is the RADOS Block Device and is part of the Ceph distributed storage
      system.
      
      It comes in two flavours: Qemu-RBD and Kernel RBD, this storage backend only
      supports Qemu-RBD, thus limiting the use of this storage driver to Qemu only.
      
      To function this backend relies on librbd and librados being present on the
      local system.
      
      The backend also supports Cephx authentication for safe authentication with
      the Ceph cluster.
      
      For storing credentials it uses the built-in secret mechanism of libvirt.
      Signed-off-by: NWido den Hollander <wido@widodh.nl>
      74951ead
  10. 18 5月, 2012 1 次提交
    • H
      Add a new param 'vcpu_time' to virDomainGetCPUStats · d29a7aaa
      Hu Tao 提交于
      Currently virDomainGetCPUStats gets total cpu usage, which consists
      of:
      
        1. vcpu usage: the physical cpu time consumed by virtual cpu(s) of
           domain
        2. hypervisor: `total cpu usage' - `vcpu usage'
      
      The param 'vcpu_time' is for getting vcpu usages.
      d29a7aaa
  11. 15 5月, 2012 1 次提交
  12. 14 5月, 2012 1 次提交
    • W
      Use XDG Base Directories instead of storing in home directory · 32a9aac2
      William Jon McCann 提交于
      As defined in:
      http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html
      
      This offers a number of advantages:
       * Allows sharing a home directory between different machines, or
      sessions (eg. using NFS)
       * Cleanly separates cache, runtime (eg. sockets), or app data from
      user settings
       * Supports performing smart or selective migration of settings
      between different OS versions
       * Supports reseting settings without breaking things
       * Makes it possible to clear cache data to make room when the disk
      is filling up
       * Allows us to write a robust and efficient backup solution
       * Allows an admin flexibility to change where data and settings are stored
       * Dramatically reduces the complexity and incoherence of the
      system for administrators
      32a9aac2
  13. 08 5月, 2012 1 次提交
  14. 02 5月, 2012 2 次提交
    • E
      virsh: output scaled values with correct units · 706aa7c5
      Eric Blake 提交于
      The recent push to use correct scaling terms (kB for 1000, KiB for
      1024 - such as commit 9dfdeadc) missed some places in virsh.
      
      * tools/virsh.c (prettyCapacity, cmdDominfo, cmdFreecell)
      (cmdNodeinfo, cmdNodeMemStats, cmdMigrateSetMaxSpeed)
      (cmdBlockCopy, cmdBlockPull, cmdBlockJob): Use KiB, not kB, when
      referring to multiples of 1024.
      * tests/virshtest.c: Update expected output to match.
      706aa7c5
    • E
      virsh: make -h always give help · 46e5d36b
      Eric Blake 提交于
      https://bugzilla.redhat.com/show_bug.cgi?id=817244 mentions that
      unlike most other tools, where --help or --version prevent all
      further parsing of all later options, virsh was strange in that
      --version stopped parsing but --help tried to plow on to the end.
      There was no rationale for this original implementation (since
      2005!), so I think we can safely conform to common usage patterns.
      
      * tools/virsh.c (main): Drop useless 'help' variable.
      46e5d36b
  15. 23 4月, 2012 1 次提交
    • E
      blockjob: add 'blockcopy' to virsh · 1f06c007
      Eric Blake 提交于
      Rather than further overloading 'blockpull', I decided to create a
      new virsh command to expose the new flags of virDomainBlockRebase.
      
      Blocking until the command completes naturally is pointless, since
      the block copy job is intended to run indefinitely.  Instead, I
      made the command support three --wait modes: by default, it runs until
      mirroring is started; with --pivot, it pivots as soon as mirroring
      is started; and with --finish, it aborts (for a clean copy) as
      soon as mirroring is started.
      
      * tools/virsh.c (VSH_CMD_BLOCK_JOB_COPY): New mode.
      (blockJobImpl): Support new flags.
      (cmdBlockCopy): New command.
      (cmdBlockJob): Support new job info, new abort flag.
      * tools/virsh.pod (blockcopy, blockjob): Document the new command
      and flags.
      1f06c007
  16. 20 4月, 2012 2 次提交
    • E
      virsh: avoid strtol · bb65c8af
      Eric Blake 提交于
      We were forgetting to check errno for overflow.
      
      * tools/virsh.c (get_integer_keycode, vshCommandOptInt)
      (vshCommandOptUInt, vshCommandOptUL, vshCommandOptLongLong)
      (vshCommandOptULongLong): Rewrite to be safer.
      bb65c8af
    • E
      virsh: avoid uninitialized memory usage · 2aed9a97
      Eric Blake 提交于
      Detected by valgrind, via Alex Jia.  Caused by imcomplete
      copy-and-paste from vshWatchJob in commit 3b96a892.
      
      * tools/virsh.c (cmdBlockPull): fix uninitialized memory usage.
      
      * How to reproduce?
      $ qemu-img create /var/lib/libvirt/images/test 1M
      $ cat > /tmp/test.xml <<EOF
      <domain type='qemu'>
        <name>test</name>
        <memory>219200</memory>
        <vcpu>1</vcpu>
        <os>
          <type arch='x86_64'>hvm</type>
          <boot dev='hd'/>
        </os>
        <devices>
          <disk type='file' device='disk'>
            <driver name='qemu' type='raw'/>
            <source file='/var/lib/libvirt/images/test'/>
            <target dev='vda' bus='virtio'/>
          </disk>
          <input type='mouse' bus='ps2'/>
          <graphics type='spice' autoport='yes' listen='0.0.0.0'/>
        </devices>
      </domain>
      EOF
      $ virsh define /tmp/test.xml
      $ valgrind -v virsh blockpull test /var/lib/libvirt/images/test --wait
      
      actual result:
      
      ==10906== 1 errors in context 1 of 1:
      ==10906== Syscall param rt_sigaction(act->sa_flags) points to uninitialised byte(s)
      ==10906==    at 0x39CF80F5BE: __libc_sigaction (sigaction.c:67)
      ==10906==    by 0x43016C: cmdBlockPull (virsh.c:7638)
      ==10906==    by 0x4150D4: vshCommandRun (virsh.c:18574)
      ==10906==    by 0x425E73: main (virsh.c:20178)
      ==10906==  Address 0x7fefffae8 is on thread 1's stack
      2aed9a97
  17. 19 4月, 2012 1 次提交
  18. 18 4月, 2012 2 次提交
    • E
      blockjob: add virsh blockpull --wait · 3b96a892
      Eric Blake 提交于
      I'm tired of shell-scripting to wait for completion of a block pull,
      when virsh can be taught to do the same.  I couldn't quite reuse
      vshWatchJob, as this is not a case of a long-running command where
      a second thread must be used to probe job status (at least, not unless
      I make virsh start doing blocking waits for an event to fire), but it
      served as inspiration for my simpler single-threaded loop.  There is
      up to a half-second delay between sending SIGINT and the job being
      aborted, but I didn't think it worth the complexity of a second thread
      and use of poll() just to minimize that delay.
      
      * tools/virsh.c (cmdBlockPull): Add new options to wait for
      completion.
      (blockJobImpl): Add argument.
      (cmdBlockJob): Adjust caller.
      * tools/virsh.pod (blockjob): Document new mode.
      3b96a892
    • E
      virsh: minor syntactic cleanups · 4f06777e
      Eric Blake 提交于
      No semantic change.
      
      * tools/virsh.c: Fix some spacing issues, {} usage, long lines,
      and redundant ().
      4f06777e
  19. 12 4月, 2012 1 次提交
    • A
      blockjob: add API for async virDomainBlockJobAbort · a696f8b7
      Adam Litke 提交于
      Block job cancellation can take a while.  Now that upstream qemu 1.1
      has asynchronous block cancellation, we want to expose that to the user.
      Therefore, the following updates are made to the virDomainBlockJob API:
      
      A new block job event type VIR_DOMAIN_BLOCK_JOB_CANCELED is managed by
      libvirt.  Regardless of the flags used with virDomainBlockJobAbort, this
      event will be raised: 1. when using synchronous block_job_cancel (the
      event will be synthesized by libvirt), and 2. whenever it is received
      from qemu (via asynchronous block-job-cancel).  Note that the event
      may be detected by libvirt even before the virDomainBlockJobAbort
      completes (always true when it is synthesized, but also possible if
      cancellation was fast).
      
      A new extension flag VIR_DOMAIN_BLOCK_JOB_ABORT_ASYNC is added to the
      virDomainBlockJobAbort API.  When enabled, this function will allow
      (but not require) asynchronous operation (ie, it returns as soon as
      possible, which might be before the job has actually been canceled).
      When the API is used in this mode, it is the responsibility of the
      caller to wait for a VIR_DOMAIN_BLOCK_JOB_CANCELED event or poll via
      the virDomainGetBlockJobInfo API to check the cancellation status.
      
      This patch also exposes the new flag through virsh, and makes virsh
      slightly easier to use (--async implies --abort, and lack of any options
      implies --info), although it leaves the qemu implementation for later
      patches.
      Signed-off-by: NAdam Litke <agl@us.ibm.com>
      Cc: Stefan Hajnoczi <stefanha@gmail.com>
      Signed-off-by: NEric Blake <eblake@redhat.com>
      a696f8b7
  20. 10 4月, 2012 2 次提交
  21. 03 4月, 2012 1 次提交
    • M
      virsh: Clarify escape sequence · 7960ce84
      Michal Privoznik 提交于
      Currently, we put no strains on escape sequence possibly leaving users
      with console that cannot be terminated. However, not all ASCII
      characters can be used as escape sequence. Only those falling in
      @ - _ can be; implement and document this constraint.
      7960ce84
  22. 02 4月, 2012 1 次提交
  23. 30 3月, 2012 2 次提交
  24. 28 3月, 2012 2 次提交
    • A
      virsh: plug memory leaks on failure path · 03ca3317
      Alex Jia 提交于
      Leaks are introduced in commit 1cf0e3db and fe383bb5.
      
      Fixing memory leaks, in addition, the patch also fixes a potential missing
      return value issue in 'if (from)' statement, without the fixing, although
      the programming met a error, the subsequent codes will be executed
      continually.
      
      * tools/virsh.c (cmdSnapshotList): fix memory leaks and missing return value.
      
      * How to reproduce?
      
      % virsh snapshot-list <domain> --parent --roots
      % virsh snapshot-list <domain> --parent --tree
      % virsh snapshot-list <domain> --roots --tree
      
      actual result:
      error: --parent and --roots are mutually exclusive
      error: Failed to disconnect from the hypervisor, 1 leaked reference(s)
      
      error: --parent and --tree are mutually exclusive
      error: Failed to disconnect from the hypervisor, 1 leaked reference(s)
      
      error: --roots and --tree are mutually exclusive
      error: Failed to disconnect from the hypervisor, 1 leaked reference(s)
      
      % virsh snapshot-create-as <domain> --name "hello"
      % virsh snapshot-create-as <domain> --name "libvirt"
      % virsh snapshot-list <domain> --roots --from "hello"
      
      actual result:
      error: --roots and --from are mutually exclusive
       Name                 Creation Time             State
      ------------------------------------------------------------
       libvirt              2012-03-28 13:46:51 +0800 running
      Signed-off-by: NAlex Jia <ajia@redhat.com>
      03ca3317
    • E
      snapshot: fix virsh docs · 3ff4b069
      Eric Blake 提交于
      Commit d42a2ffc forgot to touch up virsh documentation, and commit
      4e9953a4 mis-spelled the option name.
      
      * tools/virsh.pod (snapshot-create, snapshot-create-as): Fix typo
      and match recent change in flag meaning.
      3ff4b069
  25. 27 3月, 2012 2 次提交
    • L
      build: fix "missing initializer" errors in virsh.c · 05c25e60
      Laine Stump 提交于
      Found when attempting to build on Fedora 17 alpha with:
      
         ./autogen.sh --system --enable-compile-warnings=error
      
      (this same build command works without problem on Fedora 16). All
      other struct initializers for this struct have the extra field filled
      in (almost always to 0), so the two errant ones were fixed by adding
      in the extra 0 field.
      05c25e60
    • M
      Cleanup for a return statement in source files · 9943276f
      Martin Kletzander 提交于
      Return statements with parameter enclosed in parentheses were modified
      and parentheses were removed. The whole change was scripted, here is how:
      
      List of files was obtained using this command:
      git grep -l -e '\<return\s*([^()]*\(([^()]*)[^()]*\)*)\s*;' |             \
      grep -e '\.[ch]$' -e '\.py$'
      
      Found files were modified with this command:
      sed -i -e                                                                 \
      's_^\(.*\<return\)\s*(\(\([^()]*([^()]*)[^()]*\)*\))\s*\(;.*$\)_\1 \2\4_' \
      -e 's_^\(.*\<return\)\s*(\([^()]*\))\s*\(;.*$\)_\1 \2\3_'
      
      Then checked for nonsense.
      
      The whole command looks like this:
      git grep -l -e '\<return\s*([^()]*\(([^()]*)[^()]*\)*)\s*;' |             \
      grep -e '\.[ch]$' -e '\.py$' | xargs sed -i -e                            \
      's_^\(.*\<return\)\s*(\(\([^()]*([^()]*)[^()]*\)*\))\s*\(;.*$\)_\1 \2\4_' \
      -e 's_^\(.*\<return\)\s*(\([^()]*\))\s*\(;.*$\)_\1 \2\3_'
      9943276f
  26. 24 3月, 2012 1 次提交
    • E
      snapshot: add atomic create flag · 4d5533ca
      Eric Blake 提交于
      Right now, it is appallingly easy to cause qemu disk snapshots
      to alter a domain then fail; for example, by requesting a two-disk
      snapshot where the second disk name resides on read-only storage.
      In this failure scenario, libvirt reports failure, but modifies
      the live domain XML in-place to record that the first disk snapshot
      was taken; and places a difficult burden on the management app
      to grab the XML and reparse it to see which disks, if any, were
      altered by the partial snapshot.
      
      This patch adds a new flag where implementations can request that
      the hypervisor make snapshots atomically; either no changes to
      XML occur, or all disks were altered as a group.  If you request
      the flag, you either get outright failure up front, or you take
      advantage of hypervisor abilities to make an atomic snapshot. Of
      course, drivers should prefer the atomic means even without the
      flag explicitly requested.
      
      There's no way to make snapshots 100% bulletproof - even if the
      hypervisor does it perfectly atomic, we could run out of memory
      during the followup tasks of updating our in-memory XML, and report
      a failure.  However, these sorts of catastrophic failures are rare
      and unlikely, and it is still nicer to know that either all
      snapshots happened or none of them, as that is an easier state to
      recover from.
      
      * include/libvirt/libvirt.h.in
      (VIR_DOMAIN_SNAPSHOT_CREATE_ATOMIC): New flag.
      * src/libvirt.c (virDomainSnapshotCreateXML): Document it.
      * tools/virsh.c (cmdSnapshotCreate, cmdSnapshotCreateAs): Expose it.
      * tools/virsh.pod (snapshot-create, snapshot-create-as): Document
      it.
      4d5533ca
  27. 23 3月, 2012 2 次提交
    • O
      qemu: Update domain status to running while wakeup event is emitted · 7c5a0c94
      Osier Yang 提交于
      This introduces a new running reason VIR_DOMAIN_RUNNING_WAKEUP,
      and new suspend event type VIR_DOMAIN_EVENT_STARTED_WAKEUP.
      
      While a wakeup event is emitted, the domain which entered into
      VIR_DOMAIN_PMSUSPENDED will be transferred to "running"
      with reason VIR_DOMAIN_RUNNING_WAKEUP, and a new domain lifecycle
      event emitted with type VIR_DOMAIN_EVENT_STARTED_WAKEUP.
      7c5a0c94
    • O
      New domain state pmsuspended · 54d9026a
      Osier Yang 提交于
      This introduces a new domain state pmsuspended to represent
      the domain which has been suspended by guest power management,
      e.g. (entered itno s3 state). Because a "running" state could
      be confused in this case, one will see the guest is paused
      actually while playing. And state "paused" is for the domain
      which was paused by virDomainSuspend.
      54d9026a