1. 02 4月, 2014 2 次提交
    • S
      34a43163
    • E
      conf: move storage source type to util/ · 8a20e227
      Eric Blake 提交于
      With this patch, all information related to a host resource in
      a storage file backing chain now lives in util/virstoragefile.h.
      The next step will be to consolidate various places that have
      been tracking backing chain details to all use a common struct.
      
      The changes to tools/Makefile.am were made necessary by the
      fact that virstorageencryption includes uses of libxml, and is
      now pulled in by inclusion from virstoragefile.h.  No
      additional libraries are linked into the final image, and in
      comparison, the build of the setuid library in src/Makefile.am
      already was using LIBXML_CFLAGS via AM_CFLAGS.
      
      * src/conf/domain_conf.h (virDomainDiskSourceDef): Move...
      * src/util/virstoragefile.h (virStorageSource): ...and rename.
      * src/conf/domain_conf.c (virDomainDiskSourceDefClear)
      (virDomainDiskAuthClear): Adjust clients.
      * tools/Makefile.am (virt_login_shell_CFLAGS)
      (virt_host_validate_CFLAGS): Add libxml headers.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      8a20e227
  2. 31 3月, 2014 2 次提交
  3. 27 3月, 2014 1 次提交
  4. 25 3月, 2014 2 次提交
  5. 21 3月, 2014 3 次提交
    • C
      libvirt support to force convergence of live guest migration · 05e1b06a
      Chegu Vinod 提交于
      Busy enterprise workloads hosted on large sized VM's tend to dirty
      memory faster than the transfer rate achieved via live guest migration.
      Despite some good recent improvements (& using dedicated 10Gig NICs
      between hosts) the live migration may NOT converge.
      
      Recently support was added in qemu (version 1.6) to allow a user to
      choose if they wish to force convergence of their migration via a
      new migration capability : "auto-converge". This feature allows for qemu
      to auto-detect lack of convergence and trigger a throttle-down of the
      VCPUs.
      
      This patch includes the libvirt support needed to trigger this
      feature. (Testing is in progress)
      Signed-off-by: NChegu Vinod <chegu_vinod@hp.com>
      Signed-off-by: NJiri Denemark <jdenemar@redhat.com>
      05e1b06a
    • E
      qemu: allow filtering events by regex · 43b17dd4
      Eric Blake 提交于
      When listening for a subset of monitor events, it can be tedious
      to register for each event name in series; nicer is to register
      for multiple events in one go.  Implement a flag to use regex
      interpretation of the event filter.
      
      While at it, prove how much I hate the shift key, by adding a
      way to filter for 'shutdown' instead of 'SHUTDOWN'. :)
      
      * include/libvirt/libvirt-qemu.h
      (virConnectDomainQemuMonitorEventRegisterFlags): New enum.
      * src/libvirt-qemu.c (virConnectDomainQemuMonitorEventRegister):
      Document flags.
      * tools/virsh-domain.c (cmdQemuMonitorEvent): Expose them.
      * tools/virsh.pod (qemu-monitor-event): Document this.
      * src/conf/domain_event.c
      (virDomainQemuMonitorEventStateRegisterID): Add flags.
      (virDomainQemuMonitorEventFilter): Handle regex, and optimize
      client side.
      (virDomainQemuMonitorEventCleanup): Clean up regex.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      43b17dd4
    • E
      qemu: virsh wrapper for qemu events · 88996de1
      Eric Blake 提交于
      Any new API deserves a good virsh wrapper :)
      
          qemu-monitor-event [<domain>] [<event>] [--pretty] [--loop] [--timeout <number>]
      
      Very similar to the previous work on 'virsh event'.  For an
      example session:
      
      $ virsh -c qemu:///system qemu-monitor-event --event SHUTDOWN&
      $ virsh -c qemu:///system start f18-live
      Domain f18-live started
      
      $ virsh -c qemu:///system destroy f18-live
      Domain f18-live destroyed
      
      event SHUTDOWN at 1391212552.026544 for domain f18-live: (null)
      events received: 1
      
      [1]+  Done                    virsh -c qemu:///system qemu-monitor-event --event SHUTDOWN
      $
      
      * tools/virsh-domain.c (cmdQemuMonitorEvent): New command.
      * tools/virsh.pod (qemu-monitor-event): Document it.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      88996de1
  6. 19 3月, 2014 1 次提交
  7. 18 3月, 2014 4 次提交
  8. 14 3月, 2014 1 次提交
  9. 10 3月, 2014 3 次提交
  10. 06 3月, 2014 1 次提交
    • E
      virt-login-shell: silence coverity warning · cb9bd796
      Eric Blake 提交于
      Coverity spotted that 'nfdlist' (ssize_t) could be -1, but that we
      were using 'i' (size_t) to iterate over the list at cleanup, with
      crashing results because it promotes to a really big unsigned number.
      
      * tools/virt-login-shell.c (main): Avoid treating -1 as unsigned.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      cb9bd796
  11. 05 3月, 2014 1 次提交
    • P
      virsh: volume: Fix lookup of volumes to provide better error messages · a751e345
      Peter Krempa 提交于
      If a user specifies the pool explicitly, we should make sure to point
      out that it's inactive instead of falling back to lookup by key/path and
      failing at the end. Also if the pool isn't found there's no use in
      continuing the lookup.
      
      This changes the error in case the user-selected pool is inactive from:
      
       $ virsh vol-upload --pool inactivepool --vol somevolname volcontents
       error: failed to get vol 'somevolname'
       error: Storage volume not found: no storage vol with matching path
       somevolname
      
      To a more descriptive:
      
       $ virsh vol-upload --pool inactivepool --vol somevolname volcontents
       error: pool 'inactivepool' is not active
      
      And in case a user specifies an invalid pool from:
      
       $ virsh vol-upload --pool invalidpool --vol somevolname volcontents
       error: failed to get pool 'invalidpool'
       error: failed to get vol 'somevolname', specifying --pool might help
       error: Storage volume not found: no storage vol with matching path somevolname
      
      To something less confusing:
      
       $ virsh vol-upload --pool invalidpool --vol somevolname volcontents
       error: failed to get pool 'invalidpool'
       error: Storage pool not found: no storage pool with matching name 'invalidpool'
      a751e345
  12. 04 3月, 2014 5 次提交
    • E
      virsh: report exit status of failed lxc-enter-namespace · 2ebf593a
      Eric Blake 提交于
      'virsh lxc-enter-namespace' does not have a way to reflect exit
      status to the caller in single-command mode, but we might as well
      at least report the exit status.  Prior to this patch,
      
      $ virsh -c lxc:/// lxc-enter-namespace shell /bin/sh 'exit 3'; echo $?
      1
      
      now it gives some details:
      
      $ virsh -c lxc:/// lxc-enter-namespace shell /bin/sh -c 'exit 3'; echo $?
      error: internal error: Child process (31557) unexpected exit status 3
      1
      
      Also useful:
      
      $ virsh -c lxc:/// lxc-enter-namespace shell /bin/sh -c 'kill $$'; echo $?
      error: internal error: Child process (31585) unexpected fatal signal 15
      1
      
      * tools/virsh-domain.c (cmdLxcEnterNamespace): Avoid magic numbers.
      Dispatch any error.
      * tools/virsh.pod: Document that non-zero exit status is collapsed.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      2ebf593a
    • E
      virt-login-shell: saner exit value · 730fc962
      Eric Blake 提交于
      virt-login-shell was exiting with status 0, regardless of what the
      wrapped shell returned.  This is unkind to users; we should behave
      more like env(1), nice(1), su(1), and other wrapper programs, by
      preserving the invoked application's status (which includes the
      distinction between death due to signal vs. normal death).
      
      * tools/virt-login-shell.c (main): Pass through child exit status.
      * tools/virt-login-shell.pod: Document exit status.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      730fc962
    • E
      virt-login-shell: use single instead of double fork · 4594a33b
      Eric Blake 提交于
      Note that 'virsh lxc-enter-namespace' must double-fork, for two
      reasons: some namespaces can only be done from a single thread,
      while virsh is multithreaded; and because virsh can be run in
      batch mode where we must not corrupt the namespace of that
      execution upon return from the subsidiary command.
      
      When virt-login-shell was first written, it blindly copied from
      'virsh lxc-enter-namespace', including the double-fork.  But
      neither of the reasons for double forking apply to
      virt-login-shell (we are single-threaded, and we have nothing to
      do after the child completes that would require us to preserve a
      namespace), so we can simplify life by using a single fork.
      In turn, this will make it easier for a future patch to pass the
      child's exit status on to the invoking shell.
      
      In flattening to a single fork, note that closing the fds must
      be done after fork, because the parent process still needs to
      use fds to control the virConnectPtr; meanwhile, chdir can be
      done prior to forking (in fact, it's easier to report errors
      on anything attempted before forking).
      
      * tools/virt-login-shell.c (main): Single rather than double fork.
      (virLoginShellFini): Delete, by inlining actions instead.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      4594a33b
    • E
      virFork: simplify semantics · 25f87817
      Eric Blake 提交于
      The old semantics of virFork() violates the priciple of good
      usability: it requires the caller to check the pid argument
      after use, *even when virFork returned -1*, in order to properly
      abort a child process that failed setup done immediately after
      fork() - that is, the caller must call _exit() in the child.
      While uses in virfile.c did this correctly, uses in 'virsh
      lxc-enter-namespace' and 'virt-login-shell' would happily return
      from the calling function in both the child and the parent,
      leading to very confusing results. [Thankfully, I found the
      problem by inspection, and can't actually trigger the double
      return on error without an LD_PRELOAD library.]
      
      It is much better if the semantics of virFork are impossible
      to abuse.  Looking at virFork(), the parent could only ever
      return -1 with a non-negative pid if it misused pthread_sigmask,
      but this never happens.  Up until this patch series, the child
      could return -1 with non-negative pid if it fails to set up
      signals correctly, but we recently fixed that to make the child
      call _exit() at that point instead of forcing the caller to do
      it.  Thus, the return value and contents of the pid argument are
      now redundant (a -1 return now happens only for failure to fork,
      a child 0 return only happens for a successful 0 pid, and a
      parent 0 return only happens for a successful non-zero pid),
      so we might as well return the pid directly rather than an
      integer of whether it succeeded or failed; this is also good
      from the interface design perspective as users are already
      familiar with fork() semantics.
      
      One last change in this patch: before returning the pid directly,
      I found cases where using virProcessWait unconditionally on a
      cleanup path of a virFork's -1 pid return would be nicer if there
      were a way to avoid it overwriting an earlier message.  While
      such paths are a bit harder to come by with my change to a direct
      pid return, I decided to keep the virProcessWait change in this
      patch.
      
      * src/util/vircommand.h (virFork): Change signature.
      * src/util/vircommand.c (virFork): Guarantee that child will only
      return on success, to simplify callers.  Return pid rather than
      status, now that the situations are always the same.
      (virExec): Adjust caller, also avoid open-coding process death.
      * src/util/virprocess.c (virProcessWait): Tweak semantics when pid
      is -1.
      (virProcessRunInMountNamespace): Adjust caller.
      * src/util/virfile.c (virFileAccessibleAs, virFileOpenForked)
      (virDirCreate): Likewise.
      * tools/virt-login-shell.c (main): Likewise.
      * tools/virsh-domain.c (cmdLxcEnterNamespace): Likewise.
      * tests/commandtest.c (test23): Likewise.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      25f87817
    • E
      util: make it easier to grab only regular process exit · c72e76c3
      Eric Blake 提交于
      Right now, a caller waiting for a child process either requires
      the child to have status 0, or must use WIFEXITED() and friends
      itself.  But in many cases, we want the middle ground of treating
      fatal signals as an error, and directly accessing the normal exit
      value without having to use WEXITSTATUS(), in order to easily
      detect an expected non-zero exit status.  This adds the middle
      ground to the low-level virProcessWait; the next patch will add
      it to virCommand.
      
      * src/util/virprocess.h (virProcessWait): Alter signature.
      * src/util/virprocess.c (virProcessWait): Add parameter.
      (virProcessRunInMountNamespace): Adjust caller.
      * src/util/vircommand.c (virCommandWait): Likewise.
      * src/util/virfile.c (virFileAccessibleAs): Likewise.
      * src/lxc/lxc_container.c (lxcContainerHasReboot)
      (lxcContainerAvailable): Likewise.
      * daemon/libvirtd.c (daemonForkIntoBackground): Likewise.
      * tools/virt-login-shell.c (main): Likewise.
      * tools/virsh-domain.c (cmdLxcEnterNamespace): Likewise.
      * tests/testutils.c (virtTestCaptureProgramOutput): Likewise.
      * tests/commandtest.c (test23): Likewise.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      c72e76c3
  13. 01 3月, 2014 2 次提交
    • E
      virsh: add --all flag to 'event' command · 0e16ae40
      Eric Blake 提交于
      Similar to our event-test demo program, it's nice to be able to
      have a mode where we can sniff all events at once, rather than
      having to spawn multiple virsh in parallel with one for each
      event type.
      
      (Can I just say our RegisterAny design is lousy?  The fact that
      the majority of our callback pointers have a function signature
      with the opaque data in a different position, and that we have
      to cast the function signature before registering it, makes it
      hard to write a generic callback function; we have to write one
      for every type of event id.  Life would have been easier if we
      had designed the callback as a fixed signature with a void*
      and size parameter, and then allowed the caller to downcast
      the void* to a particular struct for data specific to their
      callback id, where we could have then had a single function
      with a switch statement for each event id, and register that
      one function for all types of events.  It would also be nicer
      if the callback functions knew which callbackID was being used
      when invoking that callback, so that I could use a common data
      structure among all registrations instead of having to create
      an array of one data per callback.  But I really don't want to
      go add yet another event API design.)
      
      * tools/virsh-domain.c (cmdEvent): Add --all parameter; convert
      all callbacks to support shared counter.
      * tools/virsh.pod (event): Document it.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      0e16ae40
    • E
      virsh: support remaining domain events · bb4a9a52
      Eric Blake 提交于
      Earlier, I added 'virsh event' for lifecycle events, to get the
      concept approved; this patch finishes the support for all other
      events, although the user still has to register for one event
      type at a time.  A future patch may add an --all parameter to
      make it possible to register for all events through a single
      call.
      
      * tools/virsh-domain.c (vshDomainEventWatchdogToString)
      (vshDomainEventIOErrorToString, vshGraphicsPhaseToString)
      (vshGraphicsAddressToString, vshDomainBlockJobStatusToString)
      (vshDomainEventDiskChangeToString)
      (vshDomainEventTrayChangeToString, vshEventGenericPrint)
      (vshEventRTCChangePrint, vshEventWatchdogPrint)
      (vshEventIOErrorPrint, vshEventGraphicsPrint)
      (vshEventIOErrorReasonPrint, vshEventBlockJobPrint)
      (vshEventDiskChangePrint, vshEventTrayChangePrint)
      (vshEventPMChangePrint, vshEventBalloonChangePrint)
      (vshEventDeviceRemovedPrint): New helper routines.
      (cmdEvent): Support full array of event callbacks.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      bb4a9a52
  14. 28 2月, 2014 1 次提交
  15. 27 2月, 2014 1 次提交
  16. 26 2月, 2014 1 次提交
    • M
      virsh: Honour -q in domblklist, vcpupin and emulatorpin · e53b0624
      Michal Privoznik 提交于
      If user wants to grep some info from domain, e.g. disk paths:
      
          # virsh -q domblklist win7 | awk '{print $2}'
          Source
      
          /var/lib/libvirt/images/windows.qcow2
          /home/zippy/work/tmp/en_windows_7_professional_x64_dvd_X15-65805.iso
      
      while with my change:
      
          # virsh -q domblklist win7 | awk '{print $2}'
          /var/lib/libvirt/images/windows.qcow2
          /home/zippy/work/tmp/en_windows_7_professional_x64_dvd_X15-65805.iso
      
      We don't print table header in other commands, like list.
      Signed-off-by: NMichal Privoznik <mprivozn@redhat.com>
      e53b0624
  17. 25 2月, 2014 5 次提交
    • J
      virsh: mark CPU usage field names as translatable · 723e2f84
      Ján Tomko 提交于
      My commit ac758012 removed the translation markers when
      moving the field names into an array.
      723e2f84
    • C
      virsh: initialize str to NULL to solve a build issue · 7a8d7af6
      Chen Hanxiao 提交于
      Fix a -Werror=maybe-uninitialized issue.
      Signed-off-by: NChen Hanxiao <chenhanxiao@cn.fujitsu.com>
      Signed-off-by: NJán Tomko <jtomko@redhat.com>
      7a8d7af6
    • E
      virsh: kill over-engineered asprintf failure recovery · 50f7960d
      Eric Blake 提交于
      I noticed this while shortening switch statements via VIR_ENUM.
      Basically, the only ways virAsprintf can fail are if we pass a
      bogus format string (but we're not THAT bad) or if we run out
      of memory (but it already warns on our behalf in that case).
      Throw away the cruft that tries too hard to diagnose a printf
      failure.
      
      * tools/virsh-volume.c (cmdVolList): Simplify.
      * tools/virsh-pool.c (cmdPoolList): Likewise.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      50f7960d
    • E
      virsh: use more compact VIR_ENUM_IMPL · 466b12ab
      Eric Blake 提交于
      Dan Berrange suggested that using VIR_ENUM_IMPL is more compact
      than open-coding switch statements, and still just as forceful
      at making us remember to update lists if we add enum values
      in the future.  Make this change throughout virsh.
      
      Sure enough, doing this change caught that we missed at least
      VIR_STORAGE_VOL_NETDIR.
      
      * tools/virsh-domain-monitor.c (vshDomainIOErrorToString)
      (vshDomainControlStateToString, vshDomainStateToString)
      (vshDomainStateReasonToString): Change switch to enum lookup.
      (cmdDomControl, cmdDominfo): Update caller.
      * tools/virsh-domain.c (vshDomainVcpuStateToString)
      (vshDomainEventToString, vshDomainEventDetailToString): Change
      switch to enum lookup.
      (vshDomainBlockJobToString, vshDomainJobToString): New functions.
      (cmdVcpuinfo, cmdBlockJob, cmdDomjobinfo, cmdEvent): Update
      callers.
      * tools/virsh-network.c (vshNetworkEventToString): Change switch
      to enum lookup.
      * tools/virsh-pool.c (vshStoragePoolStateToString): New function.
      (cmdPoolList, cmdPoolInfo): Update callers.
      * tools/virsh-volume.c (vshVolumeTypeToString): Change switch to
      enum lookup.
      (cmdVolInfo, cmdVolList): Update callers.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      466b12ab
    • J
      virsh: Don't leak buffer if GetFDs fails in cmdCreate · fe1b6e72
      Ján Tomko 提交于
      Change the logic of the function to return false by default
      and move the freeing of the buffer to the cleanup section.
      
      https://bugzilla.redhat.com/show_bug.cgi?id=1067338
      fe1b6e72
  18. 24 2月, 2014 1 次提交
    • M
      libvirt-guests: Wait for libvirtd to initialize · 4e7fc830
      Michal Privoznik 提交于
      I've noticed that in some cases systemd was quick enough and even
      if libvirt-guests.service is marked to be started after the
      libvirtd.service my guests were not resumed as
      libvirt-guests.sh failed to connect. This is because of a
      simple fact: systemd correctly starts libvirt-guests after it
      execs libvirtd. However, the daemon is not able to accept
      connections right from the start. It's doing some
      initialization which may take ages. This problem is not limited
      to systemd only, indeed. Any init system that is able to startup
      services in parallel (e.g. OpenRC) may run into this situation.
      The fix is to try connecting not only once, but continuously a few
      times with a small sleep in between tries.
      Signed-off-by: NMichal Privoznik <mprivozn@redhat.com>
      4e7fc830
  19. 21 2月, 2014 3 次提交
    • E
      virsh: add net-event command · de87691f
      Eric Blake 提交于
      Add 'virsh net-event --list' and 'virsh net-event [net] --event=name
      [--loop] [--timeout]'.  Very similar to 'virsh event'.
      
      * tools/virsh.pod (net-event): Document new command.
      * tools/virsh-network.c (vshNetworkEventToString, vshNetEventData)
      (vshEventLifecyclePrint, cmdNetworkEvent): New struct and
      functions.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      de87691f
    • E
      virsh: add event command, for lifecycle events · 99fa96c3
      Eric Blake 提交于
      Add 'virsh event --list' and 'virsh event [dom] --event=name
      [--loop] [--timeout]'.  Borrows somewhat from event-test.c,
      but defaults to a one-shot notification, and takes advantage
      of the event loop integration to allow Ctrl-C to interrupt the
      wait for an event.  For now, this just does lifecycle events.
      
      * tools/virsh.pod (event): Document new command.
      * tools/virsh-domain.c (vshDomainEventToString)
      (vshDomainEventDetailToString, vshDomEventData)
      (vshEventLifecyclePrint, cmdEvent): New struct and functions.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      99fa96c3
    • 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