1. 13 3月, 2014 2 次提交
  2. 12 3月, 2014 2 次提交
  3. 11 3月, 2014 8 次提交
  4. 10 3月, 2014 2 次提交
  5. 08 3月, 2014 1 次提交
    • J
      virscsi: Introduce virSCSIDeviceUsedByInfoFree · ea1eadd6
      John Ferlan 提交于
      This resolves a Coverity RESOURCE_LEAK issue introduced by commit
      id 'de6fa535' where the virSCSIDeviceSetUsedBy() didn't VIR_FREE
      the 'copy' or possibly VIR_STRDUP()'d values.  It also ensures that
      the VIR_APPEND_ELEMENT is successful...
      ea1eadd6
  6. 07 3月, 2014 1 次提交
  7. 04 3月, 2014 10 次提交
    • C
      6b4c0a63
    • C
      add 'driver' info to used_by · de6fa535
      Chunyan Liu 提交于
      Specify which driver and which domain in used_by area to avoid conflict among
      different drivers.
      Signed-off-by: NChunyan Liu <cyliu@suse.com>
      de6fa535
    • J
      Check if systemd is running before creating machines · 12ee0b98
      Ján Tomko 提交于
      If systemd is installed, but is not the init system,
      systemd-machined fails with an unhelpful error message:
      Launch helper exited with unknown return code 1
      
      Currently we only check if the "machine1" service is
      available (in ListActivatableNames).
      Also check if "systemd1" service is registered with DBus
      (ListNames).
      
      This fixes https://bugs.gentoo.org/show_bug.cgi?id=493246#c22
      12ee0b98
    • J
      Split out most of virDBusIsServiceEnabled · 65a4cb03
      Ján Tomko 提交于
      Introduce virDBusIsServiceInList which can be used to call other
      methods for listing services (ListNames), not just ListActivatableNames.
      
      No functional change, fixed the 'Retruns' typo.
      65a4cb03
    • 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 command exit · b9dd878f
      Eric Blake 提交于
      Auditing all callers of virCommandRun and virCommandWait that
      passed a non-NULL pointer for exit status turned up some
      interesting observations.  Many callers were merely passing
      a pointer to avoid the overall command dying, but without
      caring what the exit status was - but these callers would
      be better off treating a child death by signal as an abnormal
      exit.  Other callers were actually acting on the status, but
      not all of them remembered to filter by WIFEXITED and convert
      with WEXITSTATUS; depending on the platform, this can result
      in a status being reported as 256 times too big.  And among
      those that correctly parse the output, it gets rather verbose.
      Finally, there were the callers that explicitly checked that
      the status was 0, and gave their own message, but with fewer
      details than what virCommand gives for free.
      
      So the best idea is to move the complexity out of callers and
      into virCommand - by default, we return the actual exit status
      already cleaned through WEXITSTATUS and treat signals as a
      failed command; but the few callers that care can ask for raw
      status and act on it themselves.
      
      * src/util/vircommand.h (virCommandRawStatus): New prototype.
      * src/libvirt_private.syms (util/command.h): Export it.
      * docs/internals/command.html.in: Document it.
      * src/util/vircommand.c (virCommandRawStatus): New function.
      (virCommandWait): Adjust semantics.
      * tests/commandtest.c (test1): Test it.
      * daemon/remote.c (remoteDispatchAuthPolkit): Adjust callers.
      * src/access/viraccessdriverpolkit.c (virAccessDriverPolkitCheck):
      Likewise.
      * src/fdstream.c (virFDStreamCloseInt): Likewise.
      * src/lxc/lxc_process.c (virLXCProcessStart): Likewise.
      * src/qemu/qemu_command.c (qemuCreateInBridgePortWithHelper):
      Likewise.
      * src/xen/xen_driver.c (xenUnifiedXendProbe): Simplify.
      * tests/reconnect.c (mymain): Likewise.
      * tests/statstest.c (mymain): Likewise.
      * src/bhyve/bhyve_process.c (virBhyveProcessStart)
      (virBhyveProcessStop): Don't overwrite virCommand error.
      * src/libvirt.c (virConnectAuthGainPolkit): Likewise.
      * src/openvz/openvz_driver.c (openvzDomainGetBarrierLimit)
      (openvzDomainSetBarrierLimit): Likewise.
      * src/util/virebtables.c (virEbTablesOnceInit): Likewise.
      * src/util/viriptables.c (virIpTablesOnceInit): Likewise.
      * src/util/virnetdevveth.c (virNetDevVethCreate): Fix debug
      message.
      * src/qemu/qemu_capabilities.c (virQEMUCapsInitQMP): Add comment.
      * src/storage/storage_backend_iscsi.c
      (virStorageBackendISCSINodeUpdate): Likewise.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      b9dd878f
    • 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
    • E
      util: preserve exit status from mount namespace callback · 8b24a803
      Eric Blake 提交于
      The documentation of namespace callbacks was inconsistent on whether
      it preserved positive return values.  Now that we have a dedicated
      EXIT_CANCELED to flag all errors before getting to the callback,
      it is possible to use positive return values (not that any of the
      current callers do, but it is better to match the docs).
      
      Also, while vircommand.c is careful to close fds that a child should
      not have, it's still better to be in the practice of setting
      FD_CLOEXEC up front.
      
      * src/util/virprocess.c (virProcessRunInMountNamespace): Tweak
      return value to pass back non-zero status.  Avoid leaking pipe fds
      to other threads.
      * src/util/virprocess.h: Fix comment.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      8b24a803
    • E
      util: make it easier to reflect child exit status · 2b4f162e
      Eric Blake 提交于
      Thanks to namespaces, we have a couple of places in the code
      base that want to reflect a child exit status, including the
      ability to detect death by a signal, back to a grandparent.
      Best to make it a reusable function.
      
      * src/util/virprocess.h (virProcessExitWithStatus): New prototype.
      * src/libvirt_private.syms (util/virprocess.h): Export it.
      * src/util/virprocess.c (virProcessExitWithStatus): New function.
      * tests/commandtest.c (test23): Test it.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      2b4f162e
    • E
      virFork: give specific status on failure prior to exec · 631923e7
      Eric Blake 提交于
      When a child fails without exec'ing, we want a well-known status;
      best is to match what env(1), nice(1), su(1), and other wrapper
      programs do.  This patch adds enum values that later patches will
      use, and sets up virFork as the first client of EXIT_CANCELED
      for errors detected prior to even attempting exec, as well as
      virExec to distinguish between a missing executable vs. a binary
      that cannot be executed.
      
      This is a slight semantic change in the unlikely case of a child
      process failing to restore its signal mask - we now kill the
      child with a known status instead of relying on the caller to
      notice and do an appropriate _exit().  A subsequent patch will
      make further cleanups based on an audit of all callers.
      
      * src/internal.h (EXIT_CANCELED, EXIT_CANNOT_INVOKE)
      (EXIT_ENOENT): New enum.
      * src/util/vircommand.c (virFork): Document specific exit value if
      child aborts early.
      (virExec): Distinguish between various exec failures.
      * tests/commandtest.c (test1): Enhance test.
      (test22): New test.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      631923e7
  8. 01 3月, 2014 4 次提交
  9. 26 2月, 2014 3 次提交
    • N
      Fix memory leak in virSCSIDeviceListDel() · 969493f9
      Nehal J Wani 提交于
      While running virscsitest, it was found that valgrind pointed out the following
      memory leak:
      
      ==320== 5 bytes in 1 blocks are definitely lost in loss record 4 of 37
      ==320==    at 0x4A069EE: malloc (vg_replace_malloc.c:270)
      ==320==    by 0x3E6CE81171: strdup (strdup.c:43)
      ==320==    by 0x4CB28DF: virStrdup (virstring.c:554)
      ==320==    by 0x4CAC987: virSCSIDeviceSetUsedBy (virscsi.c:289)
      ==320==    by 0x402321: test2 (virscsitest.c:100)
      ==320==    by 0x403231: virtTestRun (testutils.c:199)
      ==320==    by 0x402121: mymain (virscsitest.c:180)
      ==320==    by 0x4039AD: virtTestMain (testutils.c:782)
      ==320==    by 0x3E6CE1ED1C: (below main) (libc-start.c:226)
      ==320==
      
      Introduced by commit fd243fc4.
      Signed-off-by: NJán Tomko <jtomko@redhat.com>
      969493f9
    • M
      virNetDevVethCreate: Serialize callers · c0d162c6
      Michal Privoznik 提交于
      Consider dozen of LXC domains, each of them having this type of interface:
      
          <interface type='network'>
            <mac address='52:54:00:a7:05:4b'/>
            <source network='default'/>
          </interface>
      
      When starting these domain in parallel, all workers may meet in
      virNetDevVethCreate() where a race starts. Race over allocating veth
      pairs because allocation requires two steps:
      
        1) find first nonexistent '/sys/class/net/vnet%d/'
        2) run 'ip link add ...' command
      
      Now consider two threads. Both of them find N as the first unused veth
      index but only one of them succeeds allocating it. The other one fails.
      For such cases, we are running the allocation in a loop with 10 rounds.
      However this is very flaky synchronization. It should be rather used
      when libvirt is competing with other process than when libvirt threads
      fight each other. Therefore, internally we should use mutex to serialize
      callers, and do the allocation in loop (just in case we are competing
      with a different process). By the way we have something similar already
      since 1cf97c87.
      Signed-off-by: NMichal Privoznik <mprivozn@redhat.com>
      c0d162c6
    • E
      build: fix cgroups on non-Linux · fa2e4dbf
      Eric Blake 提交于
      Running ./autobuild.sh detected a mingw failure:
      
        CCLD     libvirt.la
      Cannot export virCgroupGetPercpuStats: symbol not defined
      Cannot export virCgroupSetOwner: symbol not defined
      
      * src/util/vircgroup.c (virCgroupGetPercpuStats)
      (virCgroupSetOwner): Implement stubs.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      fa2e4dbf
  10. 24 2月, 2014 5 次提交
  11. 21 2月, 2014 1 次提交
  12. 20 2月, 2014 1 次提交