1. 14 3月, 2014 1 次提交
  2. 04 3月, 2014 3 次提交
    • 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
      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
  3. 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
  4. 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
  5. 25 2月, 2014 3 次提交
    • 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: 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
  6. 21 2月, 2014 2 次提交
    • 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 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
  7. 20 2月, 2014 1 次提交
    • J
      virsh: fix memleak when starting a guest with invalid fd · 6c1059ef
      Jincheng Miao 提交于
      When start a guest with --pass-fd, if the argument of --pass-fd is invalid,
      virsh will exit, but doesn't free the variable 'dom'.
      
      The valgrind said:
      ...
      ==24569== 63 (56 direct, 7 indirect) bytes in 1 blocks are definitely lost in loss record 130 of 234
      ==24569==    at 0x4C2A1D4: calloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
      ==24569==    by 0x4E879A4: virAllocVar (viralloc.c:544)
      ==24569==    by 0x4EBD625: virObjectNew (virobject.c:190)
      ==24569==    by 0x4F3A18A: virGetDomain (datatypes.c:226)
      ==24569==    by 0x4F9311F: remoteDomainLookupByName (remote_driver.c:6636)
      ==24569==    by 0x4F44F20: virDomainLookupByName (libvirt.c:2277)
      ==24569==    by 0x12F616: vshCommandOptDomainBy (virsh-domain.c:105)
      ==24569==    by 0x131C79: cmdStart (virsh-domain.c:3330)
      ==24569==    by 0x12C4AB: vshCommandRun (virsh.c:1752)
      ==24569==    by 0x127001: main (virsh.c:3218)
      
      https://bugzilla.redhat.com/show_bug.cgi?id=1067338Signed-off-by: NJincheng Miao <jmiao@redhat.com>
      Signed-off-by: NEric Blake <eblake@redhat.com>
      6c1059ef
  8. 20 1月, 2014 2 次提交
  9. 08 1月, 2014 2 次提交
  10. 25 12月, 2013 1 次提交
    • M
      virkeycode: Allow ANSI_A · 72ffbd1b
      Michal Privoznik 提交于
      https://bugzilla.redhat.com/show_bug.cgi?id=1044806
      
      Currently, sending the ANSI_A keycode from os_x codepage doesn't work as
      it has a special value of 0x0. Our internal code handles that no
      different to other not defined keycodes. Hence, in order to allow it we
      must change all the undefined keycodes from 0 to -1 and adapt some code
      too.
      
        # virsh send-key guestname --codeset os_x ANSI_A
        error: invalid keycode: 'ANSI_A'
      
        # virsh send-key guestname --codeset os_x ANSI_B
        # virsh send-key guestname --codeset os_x ANSI_C
      Signed-off-by: NMichal Privoznik <mprivozn@redhat.com>
      72ffbd1b
  11. 18 12月, 2013 1 次提交
  12. 03 12月, 2013 1 次提交
  13. 21 11月, 2013 1 次提交
    • E
      maint: fix comma style issues: tests, tools · 57682aea
      Eric Blake 提交于
      Most of our code base uses space after comma but not before;
      fix the remaining uses before adding a syntax check.
      
      * tests/sysinfotest.c: Consistently use commas.
      * tests/viratomictest.c: Likewise.
      * tests/vircgroupmock.c: Likewise.
      * tools/virsh-domain.c: Likewise.
      * tools/virsh-volume.c: Likewise.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      57682aea
  14. 11 11月, 2013 1 次提交
    • P
      virsh-domain: Mark --live and --config mutually exclusive in vcpucount · bf45db60
      Peter Krempa 提交于
      The 'vcpucount' command is a getter command for the vCPUu count. When
      one or more of the filtering flags are specified the command returns the
      value only for the selected combination. In this case the --live and
      --config combination isn't valid. This however didn't cause errors as
      the combination of flags was rejected by the libvirt API but then the
      fallback code kicked in and requested the count in a way where the clash
      of the flags didn't matter.
      
      Mark the flag combination mutually exclusive so that users aren't
      confused.
      
      Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1024245
      bf45db60
  15. 24 10月, 2013 1 次提交
    • E
      virsh: undocument --shareable (--mode already covers it) · f919cf69
      Eric Blake 提交于
      Commit e962a579 added 'attach-disk --shareable', even though we
      already had 'attach-disk --mode=shareable'.  Worse, if the user
      types 'attach-disk --mode=readonly --shareable', we create
      non-sensical XML.  The best solution is just to undocument the
      duplicate spelling, by having it fall back to the preferred
      spelling.
      
      * tools/virsh-domain.c (cmdAttachDisk): Let alias handling fix our
      mistake in exposing a second spelling for an existing option.
      * tools/virsh.pod: Fix documentation.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      f919cf69
  16. 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
  17. 18 10月, 2013 1 次提交
  18. 17 10月, 2013 1 次提交
  19. 11 10月, 2013 1 次提交
  20. 01 10月, 2013 1 次提交
  21. 30 9月, 2013 1 次提交
  22. 27 9月, 2013 1 次提交
    • C
      virsh: Fix domdisplay when domain only uses TLS · 9976c4b9
      Christophe Fergeau 提交于
      It's possible to create a domain which will only use a TLS port
      and will not have a non-TLS port set by using:
      <graphics type='spice' autoport='yes' defaultMode='secure'/>
      In such a setup, the 'graphics' node for the running domain will be:
      <graphics type='spice' tlsPort='5900'
                autoport='yes' listen='127.0.0.1'
                defaultMode='secure'>
      
      However, cmdDomDisplay loops over all the 'graphics' node, and it
      ignores nodes which don't have a 'port' attribute. This means
      'virsh domdisplay' will only return an empty string for domains
      as the one above.
      
      This commit looks for both 'port' and 'tlsPort' before deciding
      to ignore a graphics node. It also makes sure 'port' is not printed
      when it's not set.
      This makes 'virsh domdisplay' return
      'spice://127.0.0.1?tls-port=5900' for domains using only a TLS
      port.
      Signed-off-by: NChristophe Fergeau <cfergeau@redhat.com>
      9976c4b9
  23. 25 9月, 2013 1 次提交
  24. 20 9月, 2013 1 次提交
  25. 17 9月, 2013 5 次提交
  26. 16 9月, 2013 1 次提交
  27. 12 9月, 2013 1 次提交
  28. 05 9月, 2013 1 次提交