1. 04 5月, 2011 9 次提交
    • E
      lxc: report correct error · 32388f12
      Eric Blake 提交于
      Clang noticed a dead assignment, which turned out to be the use
      of the wrong variable.  rc starts life as -1, and is only ever
      assigned to 0 just before a successful cleanup.
      
      * src/lxc/lxc_driver.c (lxcSetupInterfaces): Don't call
      virReportSystemError(-1).
      32388f12
    • E
      libxl: avoid compiler warning · 710f8811
      Eric Blake 提交于
      Detected by gcc:
      
      libxl/libxl_driver.c: In function 'libxlDomainDestroy':
      libxl/libxl_drier.c:1351:30: error: variable 'priv' set but not used [-Werror=unused-but-set-variable]
      
      * src/libxl/libxl_driver.c (libxlDomainDestroy): Delete unused
      variable.
      710f8811
    • E
      qemu: remove dead assignment · 5f929dd3
      Eric Blake 提交于
      Detected by clang.
      
      * src/qemu/qemu_migration.c (qemuMigrationToFile): Nothing later
      uses is_reg.
      5f929dd3
    • E
      storage: use virCommand to avoid compiler warning · f72393fa
      Eric Blake 提交于
      clang didn't like the last increment to nargs.  But why even
      track nargs ourselves, when virCommand does it for us?
      
      * src/storage/storage_backend_iscsi.c
      (virStorageBackendISCSIConnection): Switch to virCommand to avoid
      a dead-store warning on nargs.
      f72393fa
    • E
      cgroup: avoid leaking a file · ead2b433
      Eric Blake 提交于
      Clang detected a dead store to rc.  It turns out that in fixing this,
      I also found a FILE* leak.
      
      This is a subtle change in behavior, although unlikely to hit.  The
      pidfile is a kernel file, so we've probably got more serious problems
      under foot if we fail to parse one.  However, the previous behavior
      was that even if one pid file failed to parse, we tried others,
      whereas now we give up on the first failure.  Either way, though,
      the function returns -1, so the caller will know that something is
      going wrong, and that not all pids were necessarily reaped.  Besides,
      there were other instances already in the code where failure in the
      inner loop aborted the outer loop.
      
      * src/util/cgroup.c (virCgroupKillInternal): Abort rather than
      resuming loop on fscanf failure, and cleanup file on error.
      ead2b433
    • E
      qemu: silence clang false positives · d8f75281
      Eric Blake 提交于
      Clang 2.8 wasn't quite able to follow that persistentDef was
      assigned earlier if (flags & VIR_DOMAIN_MEM_CONFIG) is true.
      Silence this false positive, to make clang analysis easier to use.
      
      * src/qemu/qemu_driver.c (qemudDomainSetMemoryFlags): Add an
      annotation to silence clang's claim of a NULL dereference.
      d8f75281
    • E
      pci: fix null pointer dereference · 1164e1a2
      Eric Blake 提交于
      Clang detected a null-pointer dereference regression, introduced
      in commit 4e8969eb.  Without this patch, a device with
      unbind_from_stub set to false would eventually try to call
      virFileExists on uncomputed drvdir.
      
      * src/util/pci.c (pciUnbindDeviceFromStub): Ensure drvdir is set
      before use.
      1164e1a2
    • E
      qemu: avoid null pointer dereference · 4d080ee4
      Eric Blake 提交于
      This code has had problems historically.  As originally
      written, in commit 6bcf2501 (Jun 08), it could call unlink
      on a random string, nuking an unrelated file.
      
      Then commit 182a80b9 (Sep 09), the code was rewritten to
      allocate tmp, with both a use-after-free bug and a chance to
      call unlink(NULL).
      
      Commit e206946d (Mar 11) fixed the use-after-free, but not the
      NULL dereference.  Thanks to clang for catching this!
      
      * src/qemu/qemu_driver.c (qemudDomainMemoryPeek): Don't call
      unlink on NULL.
      4d080ee4
    • E
      Revert "lxc: Do not try to reconnect inactive domain when do lxcStartup" · 6e177fa1
      Eric Blake 提交于
      This reverts commit 0e7f7f85.
      
      From the mailing list:
      
      > So, AFAICT, this patch means we will never reconnect to any LXC
      > VMs now.
      >
      > The correct solution, is to refactor LXC driver startup to work
      > the same way as the QEMU driver startup.
      >
      >   - Load all the live state XML files (to pick up running VMs)
      >   - Reconnect to all VMs
      >   - Load all the persistent config XML files (to pick up any additional
      >     inactive guets)
      
      But that solution is invasive enough to be post-0.9.1.
      6e177fa1
  2. 03 5月, 2011 2 次提交
  3. 02 5月, 2011 1 次提交
    • C
      qemu: fix uninitialized variable warning · b15a8a1b
      Christophe Fergeau 提交于
      This commit fixes
      qemu/qemu_driver.c: In function 'qemuDomainModifyDeviceFlags':
      qemu/qemu_driver.c:4041:8: warning: 'ret' may be used uninitialized in this
      function [-Wuninitialized]
      qemu/qemu_driver.c:4013:9: note: 'ret' was declared here
      
      The variable is set to -1 so that the error paths are taken when the code
      to set it didn't get a chance to run. Without initializing it, we could
      return some an undefined value from this function.
      
      While I was at it, I made a trivial whitespace change in the same function
      to improve readability.
      b15a8a1b
  4. 30 4月, 2011 4 次提交
  5. 29 4月, 2011 3 次提交
  6. 28 4月, 2011 5 次提交
    • L
      network: fix return value of hostsFileWrite · f7bd72fa
      Laine Stump 提交于
      The lone caller to hostsFileWrite (and the callers for at least 3
      levels up the return stack) assume that the return value will be < 0
      on failure. However, hostsFileWrite returns 0 on success, and a
      positive errno on failure. This patch changes hostsFileWrite to return
      -errno on failure.
      f7bd72fa
    • E
      maint: fix comment typos · a372c405
      Eric Blake 提交于
      * src/esx/esx_driver.c: Fix spelling of 'relative'.
      * src/util/util.c: Likewise.
      a372c405
    • O
      util: Initialize hooks at daemon shutdown if no hooks defined · 32398e12
      Osier Yang 提交于
      We support to initialize the hooks at daemon reload if there is no
      hooks script is defined, we should also support initialize the hooks
      at daemon shutdown if no hooks is defined.
      
      To address bz: https://bugzilla.redhat.com/show_bug.cgi?id=688859
      32398e12
    • K
      libvirt/qemu - support persistent attach/detach disks · ab9102c2
      KAMEZAWA Hiroyuki 提交于
      Support changes of disks by MODIFY_CONFIG for qemu.
      
      This patch includes patches for qemu's disk to support
      virDomainAt(De)tachDeviceFlags with VIR_DOMAIN_DEVICE_MODIFY_CONFIG.
      
      Other devices can be added incrementally.
      Signed-off-by: NKAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
      
      * /src/conf/domain_conf.c
      (virDomainDiskIndexByName): returns array index of disk in vmdef.
      (virDomainDiskRemoveByName): removes a disk which has the name in vmdef.
      * src/qemu/qemu_driver.c
      (qemuDomainAttachDeviceConfig): add support for Disks.
      (qemuDomainDetachDeviceConfig): add support for Disks.
      ab9102c2
    • K
      libvirt/qemu - support persistent modification of devices · da1eba6b
      KAMEZAWA Hiroyuki 提交于
      This patch adds functions for modify domain's persistent definition.
      To do error recovery in easy way, we use a copy of vmdef and update it.
      
      The whole sequence will be:
      
        make a copy of domain definition.
      
        if (flags & MODIFY_CONFIG)
            update copied domain definition
        if (flags & MODIF_LIVE)
            do hotplug.
        if (no error)
            save copied one to the file and update cached definition.
        else
            discard copied definition.
      
      This patch is mixuture of Eric Blake's work and mine.
      From: Eric Blake <eblake@redhat.com>
      Signed-off-by: NKAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
      
      (virDomainObjCopyPersistentDef): make a copy of persistent vm definition
      (qemuDomainAttach/Detach/UpdateDeviceConfig) : callbacks. now empty
      (qemuDomainModifyDeviceFlags): add support for MODIFY_CONFIG and MODIFY_CURRENT
      da1eba6b
  7. 27 4月, 2011 7 次提交
    • J
      util: Simplify hash implementation · 1671d1dc
      Jiri Denemark 提交于
      So far first entries for each hash key are stored directly in the hash
      table while other entries mapped to the same key are linked through
      pointers. As a result of that, the code is cluttered with special
      handling for the first items.
      
      This patch makes all entries (even the first ones) linked through
      pointers, which significantly simplifies the code and makes it more
      maintainable.
      1671d1dc
    • J
      tests: More unit tests for internal hash APIs · 91e12a50
      Jiri Denemark 提交于
      This adds several tests for remaining hash APIs (custom
      hasher/comparator functions are not covered yet, though).
      
      All tests pass both before and after the "Simplify hash implementation".
      91e12a50
    • W
      release PCI address only when we have ensured it successfully · 968fd011
      Wen Congyang 提交于
      Steps to reproduce this bug:
      1. # cat net.xml # 00:03.0 has been used
          <interface type='network'>
            <mac address='52:54:00:04:72:f3'/>
            <source network='default'/>
            <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
          </interface>
      
      2. # virsh attach-device vm1 net.xml
         error: Failed to attach device from net.xml
         error: internal error unable to reserve PCI address 0:0:3
      
      3. # virsh attach-device vm1 net.xml
         error: Failed to attach device from net.xml
         error: internal error unable to execute QEMU command 'device_add': Device 'rtl8139' could not be initialized
      
      The reason of this bug is that: we can not reserve PCI address 0:0:3 because it has
      been used, but we release PCI address when we reserve it failed.
      968fd011
    • W
      free buf->content when vsnprintf() failed · 6fee3da2
      Wen Congyang 提交于
      When buf->error is 1, we do not return buf->content in the function
      virBufferContentAndReset(). So we should free buf->content when
      vsnprintf() failed.
      6fee3da2
    • M
      esx: Fix dynamic dispatch for CastFromAnyType functions · 4a9019af
      Matthias Bolte 提交于
      This was broken by the refactoring in ac1e6586. It resulted in a
      segfault for 'virsh vol-dumpxml' and related volume functions.
      
      Before the refactoring all users of the ESX_VI__TEMPLATE__DISPATCH
      macro dispatched on the item type, as the item is the input to all those
      functions.
      
      Commit ac1e6586 made the dynamically dispatched CastFromAnyType
      functions use this macro too, but this functions dispatched on the
      actual type of the AnyType object. The item is the output of the
      CastFromAnyType functions.
      
      This difference was missed in the refactoring, making CastFromAnyType
      functions dereferencing the item pointer that is NULL at the time of
      the dispatch.
      4a9019af
    • M
      Move call to virReportOOMError into virFileBuildPath · 3ba5d77f
      Matthias Bolte 提交于
      Suggested by Daniel P. Berrange
      3ba5d77f
    • E
      build: use gnulib passfd for simpler SCM_RIGHTS code · 59a5981d
      Eric Blake 提交于
      * .gnulib: Update to latest for passfd fixes.
      * bootstrap.conf (gnulib_modules): Add passfd.
      * src/util/util.c (virFileOpenAs): Simplify.
      59a5981d
  8. 26 4月, 2011 6 次提交
    • J
      qemu: Add flags checking in DomainCoreDump · 1c842378
      Jiri Denemark 提交于
      1c842378
    • M
      Make crash and live flags mutually exclusive in virDomainCoreDump · d9b46a0d
      Mark Wu 提交于
      They don't make any sense when used together.
      d9b46a0d
    • G
      Make sure DNSMASQ_STATE_DIR exists · bf5e3f65
      Guido Günther 提交于
      otherwise the directory returned by networkDnsmasqLeaseFileName will not
      be created if ipdef->nhosts == 0 in networkBuildDnsmasqArgv.
      bf5e3f65
    • M
      Fix small memory leaks in config parsing related functions · bf130d2c
      Matthias Bolte 提交于
      Found by 'make -C tests valgrind'.
      
      xen_xm.c: Dummy allocation via virDomainChrDefNew is directly
      overwritten and lost. Free 'script' in success path too.
      
      vmx.c: Free virtualDev_string in success path too.
      
      domain_conf.c: Free compression in success path too.
      bf130d2c
    • M
      Add virDomainEventRebootNew · 14a961ca
      Matthias Bolte 提交于
      This will be used in the ESX driver event handling.
      14a961ca
    • E
      build: make VIR_FREE do some type checking · 90d761ee
      Eric Blake 提交于
      We can exploit the fact that gcc warns about int-to-pointer conversion
      in ternary cond?(void*):(int) in order to prevent future mistakes of
      calling VIR_FREE on a scalar lvalue.  For example, between commits
      158ba873 and 802e2df9, we would have had this warning:
      
      cc1: warnings being treated as errors
      remote.c: In function 'remoteDispatchListNetworks':
      remote.c:3684:70: error: pointer/integer type mismatch in conditional expression
      
      There are still a number of places that malloc into a const char*;
      while it would probably be worth scrubbing them to use char*
      instead, that is a separate patch, so we have to cast away const
      in VIR_FREE for now.
      
      * src/util/memory.h (VIR_FREE): Make gcc warn about integers.
      Iteratively developed from a patch by Christophe Fergeau.
      90d761ee
  9. 25 4月, 2011 1 次提交
    • E
      threads: add one-time initialization support · 99de5990
      Eric Blake 提交于
      mingw lacks the counterpart to PTHREAD_MUTEX_INITIALIZER, so the
      best we can do is portably expose once-only runtime initialization.
      
      * src/util/threads.h (virOnceControlPtr): New opaque type.
      (virOnceFunc): New callback type.
      (virOnce): New prototype.
      * src/util/threads-pthread.h (virOnceControl): Declare.
      (VIR_ONCE_CONTROL_INITIALIZER): Define.
      * src/util/threads-win32.h (virOnceControl)
      (VIR_ONCE_CONTROL_INITIALIZER): Likewise.
      * src/util/threads-pthread.c (virOnce): Implement in pthreads.
      * src/util/threads-win32.c (virOnce): Implement in WIN32.
      * src/libvirt_private.syms: Export it.
      99de5990
  10. 24 4月, 2011 2 次提交