1. 12 5月, 2011 1 次提交
    • L
      libvirt,logging: cleanup VIR_XXX0() · b65f37a4
      Lai Jiangshan 提交于
      These VIR_XXXX0 APIs make us confused, use the non-0-suffix APIs instead.
      
      How do these coversions works? The magic is using the gcc extension of ##.
      When __VA_ARGS__ is empty, "##" will swallow the "," in "fmt," to
      avoid compile error.
      
      example: origin				after CPP
      	high_level_api("%d", a_int)	low_level_api("%d", a_int)
      	high_level_api("a  string")	low_level_api("a  string")
      
      About 400 conversions.
      
      8 special conversions:
      VIR_XXXX0("") -> VIR_XXXX("msg") (avoid empty format) 2 conversions
      VIR_XXXX0(string_literal_with_%) -> VIR_XXXX(%->%%) 0 conversions
      VIR_XXXX0(non_string_literal) -> VIR_XXXX("%s", non_string_literal)
        (for security) 6 conversions
      Signed-off-by: NLai Jiangshan <laijs@cn.fujitsu.com>
      b65f37a4
  2. 11 5月, 2011 3 次提交
    • D
      Add support for YAJL version 2 API/ABI · 9f5d3a91
      Daniel P. Berrange 提交于
      Version 2.0.0 or yajl changed API. It is fairly trivial for us to
      cope with both APIs in libvirt, so adapt.
      
      * configure.ac: Probe for yajl2 API
      * src/util/json.c: Conditional support for yajl2 API
      9f5d3a91
    • C
      command: Add virCommandExec helper · f095398a
      Cole Robinson 提交于
      Actually execs the argv/env we've generated, replacing the current process.
      Kind of has a limited usage, but allows us to use virCommand in LXC
      driver to launch the 'init' process
      f095398a
    • C
      command: Add virCommandEnvAddFormat · 35c1b35e
      Cole Robinson 提交于
      Similar to virCommandArgAddFormat. We will use this shortly.
      
      v2:
          Convert virCommandEnvAddPair to use the new function
      35c1b35e
  3. 10 5月, 2011 1 次提交
  4. 09 5月, 2011 1 次提交
  5. 06 5月, 2011 3 次提交
    • M
      Add warning message to XML definition files stored on disk · 5d09c314
      Michal Privoznik 提交于
      Users often edit XML file stored in configuration directory
      thinking of modifying a domain/network/pool/etc. Thus it is wise
      to let them know they are using the wrong way and give them hint.
      5d09c314
    • E
      buf: add virBufferVasprintf · f09acccf
      Eric Blake 提交于
      Match the fact that we have virAsprintf and virVasprintf.
      
      * src/util/buf.h (virBufferVasprintf): New prototype.
      * src/util/buf.c (virBufferAsprintf): Move guts...
      (virBufferVasprintf): ...to new function.
      * src/libvirt_private.syms (buf.h): Export it.
      * bootstrap.conf (gnulib_modules): Add stdarg, for va_copy.
      f09acccf
    • E
      maint: rename virBufferVSprintf to virBufferAsprintf · 68ea80cf
      Eric Blake 提交于
      We already have virAsprintf, so picking a similar name helps for
      seeing a similar purpose.  Furthermore, the prefix V before printf
      generally implies 'va_list', even though this variant was '...', and
      the old name got in the way of adding a new va_list version.
      
      global rename performed with:
      
      $ git grep -l virBufferVSprintf \
        | xargs -L1 sed -i 's/virBufferVSprintf/virBufferAsprintf/g'
      
      then revert the changes in ChangeLog-old.
      68ea80cf
  6. 04 5月, 2011 3 次提交
    • E
      util: remove dead assignment · 44aa49ae
      Eric Blake 提交于
      Clang complained about this, and it was easy enough to fix.
      
      * src/util/util.c (virFileOpenAs): Drop dead assignment.
      44aa49ae
    • 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
      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
  7. 30 4月, 2011 2 次提交
    • M
      Fix memory leak in __virExec · 9d50b323
      Matthias Bolte 提交于
      Commit e0d014f2 made binary potentially allocated on the heap.
      It was freed in the parent in the error path, but not in the success path
      that doesn't goto the cleanup label.
      
      Found by 'make -C tests valgrind'.
      9d50b323
    • E
      hash: fix memory leak regression · 701bee01
      Eric Blake 提交于
      Commit 1671d1dc introduced a memory leak in virHashFree, and
      wholesale table corruption in virHashRemoveSet (elements not
      requested to be freed are lost).
      
      * src/util/hash.c (virHashFree): Free bucket array.
      (virHashRemoveSet): Don't lose elements.
      * tests/hashtest.c (testHashCheckForEachCount): New method.
      (testHashCheckCount): Expose the bug.
      701bee01
  8. 28 4月, 2011 3 次提交
  9. 27 4月, 2011 5 次提交
  10. 26 4月, 2011 1 次提交
    • 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
  11. 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
  12. 19 4月, 2011 1 次提交
  13. 17 4月, 2011 1 次提交
  14. 16 4月, 2011 1 次提交
    • E
      maint: use lighter-weight function for straight appends · dbe3bad9
      Eric Blake 提交于
      It costs quite a few processor cycles to go through printf parsing
      just to determine that we only meant to append.
      
      * src/xen/xend_internal.c (xend_op_ext): Consolidate multiple
      printfs into one.
      * src/qemu/qemu_command.c (qemuBuildWatchdogDevStr)
      (qemuBuildUSBInputDevStr, qemuBuildSoundDevStr)
      (qemuBuildSoundCodecStr, qemuBuildVideoDevStr): Likewise.
      (qemuBuildCpuArgStr, qemuBuildCommandLine): Prefer virBufferAdd
      over virBufferVsprintf for trivial appends.
      * src/phyp/phyp_driver.c (phypExec, phypUUIDTable_Push)
      (phypUUIDTable_Pull): Likewise.
      * src/conf/nwfilter_conf.c (macProtocolIDFormatter)
      (arpOpcodeFormatter, formatIPProtocolID, printStringItems)
      (virNWFilterPrintStateMatchFlags, virNWIPAddressFormat)
      (virNWFilterDefFormat): Likewise.
      * src/security/virt-aa-helper.c (main): Likewise.
      * src/util/sexpr.c (sexpr2string): Likewise.
      * src/xenxs/xen_sxpr.c (xenFormatSxprChr): Likewise.
      * src/xenxs/xen_xm.c (xenFormatXMDisk): Likewise.
      dbe3bad9
  15. 15 4月, 2011 1 次提交
    • C
      Fix gcc 4.6 warnings · 454e50be
      Christophe Fergeau 提交于
      gcc 4.6 warns when a variable is initialized but isn't used afterwards:
      
      vmware/vmware_driver.c:449:18: warning: variable 'vmxPath' set but not used [-Wunused-but-set-variable]
      
      This patch fixes these warnings. There are still 2 offending files:
      
      - vbox_tmpl.c: the variable is used inside an #ifdef and is assigned several
        times outside of #ifdef. Fixing the warning would have required wrapping
        all the assignment inside #ifdef which hurts readability.
      
      vbox/vbox_tmpl.c: In function 'vboxAttachDrives':
      vbox/vbox_tmpl.c:3918:22: warning: variable 'accessMode' set but not used [-Wunused-but-set-variable]
      
      - esx_vi_types.generated.c: the name implies it's generated code and I
        didn't want to dive into the code generator
      
      esx/esx_vi_types.generated.c: In function 'esxVI_FileQueryFlags_Free':
      esx/esx_vi_types.generated.c:1203:3: warning: variable 'item' set but not used [-Wunused-but-set-variable]
      454e50be
  16. 13 4月, 2011 1 次提交
  17. 12 4月, 2011 1 次提交
    • E
      maint: fix grammar errors · 99fa3080
      Eric Blake 提交于
      Jim Meyering recently improved gnulib to catch various grammar
      errors during 'make syntax-check'.
      
      * .gnulib: Update to latest, for syntax-check improvements.
      * include/libvirt/libvirt.h.in (virConnectAuthCallbackPtr): Use
      cannot rather than two words.
      * src/driver.c: Likewise.
      * src/driver.h (VIR_SECRET_GET_VALUE_INTERNAL_CALL): Likewise.
      * src/remote/remote_driver.c (initialize_gnutls): Likewise.
      * src/util/pci.c (pciBindDeviceToStub): Likewise.
      * src/storage/storage_backend.c (virStorageBackendCreateQemuImg):
      Likewise.
      (virStorageBackendUpdateVolTargetInfoFD): Avoid doubled word.
      * docs/formatdomain.html.in: Likewise.
      * src/qemu/qemu_process.c (qemuProcessStart): Likewise.
      * cfg.mk (exclude_file_name_regexp--sc_prohibit_can_not)
      (exclude_file_name_regexp--sc_prohibit_doubled_word): Exclude
      existing translation problems.
      99fa3080
  18. 08 4月, 2011 1 次提交
    • E
      virsh: fix mingw startup · 8ae5df5d
      Eric Blake 提交于
      * .gnulib: Update to latest, for pipe2.
      * bootstrap.conf (gnulib_modules): Add pipe2.
      * src/util/event_poll.c (virEventPollInit): Use it, to avoid
      problematic virSetCloseExec on mingw.
      8ae5df5d
  19. 07 4月, 2011 4 次提交
    • W
      reattach pci device when pciBindDeviceToStub() failed · 4e8969eb
      Wen Congyang 提交于
      We should bind pci device to original driver when pciBindDeviceToStub() failed.
      If the pci device is not bound to any driver before calling pciBindDeviceToStub(),
      we should only unbind it from pci-stub. If it is bound to pci-stub, we should not
      unbind it from pci-stub.
      4e8969eb
    • W
      rename pciUnBindDeviceFromStub() to pciUnbindDeviceFromStub() and float it up · 9121b193
      Wen Congyang 提交于
      This patch do the following things:
      1. rename the function as 'Unbind' is better than 'UnBind'.
      2. pciUnbindDeviceFromStub() will be used in the function pciBindDeviceToStub() in
         next patch. Float it up, instead of having to have a forward declaration
      9121b193
    • W
      pci: avoid invalid free, init path to NULL · d5981f1c
      Wen Congyang 提交于
      This bug was introduce by commit 57162db8, and it will cause libvirtd crashed.
      d5981f1c
    • E
      build: avoid compiler warning on cygwin · f6447e8a
      Eric Blake 提交于
      In file included from util/threads.c:31:
      util/threads-pthread.c: In function 'virThreadSelfID':
      util/threads-pthread.c:214: warning: cast from function call of type 'pthread_t' to non-matching type 'int' [-Wbad-function-cast]
      
      * src/util/threads-pthread.c (virThreadSelfID) [!SYS_gettid]:
      Add intermediate cast to silence gcc.
      f6447e8a
  20. 06 4月, 2011 1 次提交
    • D
      Avoid compiler warnings about int -> void * casts · 5b099250
      Daniel P. Berrange 提交于
      GCC is a little confused about the cast of beginthread/beginthreadex
      from unsigned long -> void *. Go via an intermediate variable avoids
      the bogus warning, and makes the code a little cleaner
      
      * src/util/threads-win32.c: Avoid compiler warning in cast
      5b099250
  21. 05 4月, 2011 4 次提交