1. 15 3月, 2011 3 次提交
    • D
      Fix misc bugs in virCommandPtr · 2a2a00eb
      Daniel P. Berrange 提交于
      The virCommandNewArgs() method would free the virCommandPtr
      if it failed to add the args. This meant errors reported in
      virCommandAddArgSet() were lost. Simply removing the check
      for errors from the constructor means they can be reported
      correctly later
      
      The virCommandAddEnvPassCommon() method failed to check for
      errors before reallocating the cmd->env array, causing a
      potential SEGV if cmd was NULL
      
      The virCommandAddArgSet() method needs to validate that at
      least 1 element in 'val's parameter is non-NULL, otherwise
      code like
      
          cmd = virCommandNew(binary)
          virCommandAddAtg(cmd, "foo")
      
      Would end up trying todo  execve("foo"), if binary was
      NULL.
      2a2a00eb
    • D
      Add virSetBlocking() to allow O_NONBLOCK to be toggle on or off · 2737b6c2
      Daniel P. Berrange 提交于
      The virSetNonBlock() API only allows enabling non-blocking
      operations. It doesn't allow turning blocking back on. Add
      a new API to allow arbitrary toggling.
      
      * src/libvirt_private.syms, src/util/util.h
        src/util/util.c: Add virSetBlocking
      2737b6c2
    • D
      Allow to dynamically set the size of the debug buffer · b16f47ab
      Daniel Veillard 提交于
      This is the part allowing to dynamically resize the debug log
      buffer from it's default 64kB size. The buffer is now dynamically
      allocated.
      It adds a new API virLogSetBufferSize() which resizes the buffer
      If passed a zero size, the buffer is deallocated and we do the small
      optimization of not formatting messages which are not output anymore.
      On the daemon side, it just adds a new option log_buffer_size to
      libvirtd.conf and call virLogSetBufferSize() if needed
      * src/util/logging.h src/util/logging.c src/libvirt_private.syms:
        make buffer dynamic and add virLogSetBufferSize() internal API
      * daemon/libvirtd.conf: document the new log_buffer_size option
      * daemon/libvirtd.c: read and use the new log_buffer_size option
      b16f47ab
  2. 10 3月, 2011 2 次提交
    • E
      cgroup: allow fine-tuning of device ACL permissions · 5564c575
      Eric Blake 提交于
      Adding audit points showed that we were granting too much privilege
      to qemu; it should not need any mknod rights to recreate any
      devices.  On the other hand, lxc should have all device privileges.
      The solution is adding a flag parameter.
      
      This also lets us restrict write access to read-only disks.
      
      * src/util/cgroup.h (virCgroup*Device*): Adjust prototypes.
      * src/util/cgroup.c (virCgroupAllowDevice)
      (virCgroupAllowDeviceMajor, virCgroupAllowDevicePath)
      (virCgroupDenyDevice, virCgroupDenyDeviceMajor)
      (virCgroupDenyDevicePath): Add parameter.
      * src/qemu/qemu_driver.c (qemudDomainSaveFlag): Update clients.
      * src/lxc/lxc_controller.c (lxcSetContainerResources): Likewise.
      * src/qemu/qemu_cgroup.c: Likewise.
      (qemuSetupDiskPathAllow): Also, honor read-only disks.
      5564c575
    • E
      audit: also audit cgroup controller path · f2512684
      Eric Blake 提交于
      Although the cgroup device ACL controller path can be worked out
      by researching the code, it is more efficient to include that
      information directly in the audit message.
      
      * src/util/cgroup.h (virCgroupPathOfController): New prototype.
      * src/util/cgroup.c (virCgroupPathOfController): Export.
      * src/libvirt_private.syms: Likewise.
      * src/qemu/qemu_audit.c (qemuAuditCgroup): Use it.
      f2512684
  3. 09 3月, 2011 2 次提交
    • E
      docs: silence warnings about generated API docs · b12a0280
      Eric Blake 提交于
      I noticed these while testing 'make dist'.
      
      Parsing ./../src/util/event.c
      Function comment for virEventRegisterDefaultImpl lacks description of return value
      Function comment for virEventRunDefaultImpl lacks description of return value
      Parsing ./../src/util/virterror.c
      Missing comment for function virSetErrorLogPriorityFunc
      
      * src/util/event.c (virEventRegisterDefaultImpl)
      (virEventRunDefaultImpl): Document return types.
      * src/util/virterror.c (virSetErrorLogPriorityFunc): Provide docs.
      b12a0280
    • E
      build: fix build on cygwin · b1a5aefc
      Eric Blake 提交于
      On cygwin:
      
        CC        libvirt_util_la-cgroup.lo
      util/cgroup.c: In function 'virCgroupKillRecursiveInternal':
      util/cgroup.c:1458: warning: implicit declaration of function 'virCgroupNew' [-Wimplicit-function-declaration]
      
      * src/util/cgroup.c (virCgroupKill): Don't build on platforms
      where virCgroupNew is unsupported.
      b1a5aefc
  4. 08 3月, 2011 2 次提交
    • D
      Fix build on cygwin · d299e1d0
      Daniel Veillard 提交于
      Apparently some signals found on Unix are not exposed, this led
      to a compilation failure
      * src/util/logging.c: make code related to each signal dependant
        upon the definition of that signal
      d299e1d0
    • W
      unlock eventLoop before calling callback function · ac9ee6b5
      Wen Congyang 提交于
      When I use newest libvirt to save a domain, libvirtd will be deadlock.
      Here is the output of gdb:
      (gdb) thread 3
      [Switching to thread 3 (Thread 0x7f972a1fc710 (LWP 30265))]#0  0x000000351fe0e034 in __lll_lock_wait () from /lib64/libpthread.so.0
      (gdb) bt
          at qemu/qemu_driver.c:2074
          ret=0x7f972a1fbbe0) at remote.c:2273
      (gdb) thread 7
      [Switching to thread 7 (Thread 0x7f9730bcd710 (LWP 30261))]#0  0x000000351fe0e034 in __lll_lock_wait () from /lib64/libpthread.so.0
      (gdb) bt
      (gdb) p *(virMutexPtr)0x6fdd60
      $2 = {lock = {__data = {__lock = 2, __count = 0, __owner = 30261, __nusers = 1, __kind = 0, __spins = 0, __list = {__prev = 0x0, __next = 0x0}},
          __size = "\002\000\000\000\000\000\000\000\065v\000\000\001", '\000' <repeats 26 times>, __align = 2}}
      (gdb) p *(virMutexPtr)0x1a63ac0
      $3 = {lock = {__data = {__lock = 2, __count = 0, __owner = 30265, __nusers = 1, __kind = 0, __spins = 0, __list = {__prev = 0x0, __next = 0x0}},
          __size = "\002\000\000\000\000\000\000\000\071v\000\000\001", '\000' <repeats 26 times>, __align = 2}}
      (gdb) info threads
        7 Thread 0x7f9730bcd710 (LWP 30261)  0x000000351fe0e034 in __lll_lock_wait () from /lib64/libpthread.so.0
        6 Thread 0x7f972bfff710 (LWP 30262)  0x000000351fe0b43c in pthread_cond_wait@@GLIBC_2.3.2 () from /lib64/libpthread.so.0
        5 Thread 0x7f972b5fe710 (LWP 30263)  0x000000351fe0b43c in pthread_cond_wait@@GLIBC_2.3.2 () from /lib64/libpthread.so.0
        4 Thread 0x7f972abfd710 (LWP 30264)  0x000000351fe0b43c in pthread_cond_wait@@GLIBC_2.3.2 () from /lib64/libpthread.so.0
      * 3 Thread 0x7f972a1fc710 (LWP 30265)  0x000000351fe0e034 in __lll_lock_wait () from /lib64/libpthread.so.0
        2 Thread 0x7f97297fb710 (LWP 30266)  0x000000351fe0b43c in pthread_cond_wait@@GLIBC_2.3.2 () from /lib64/libpthread.so.0
        1 Thread 0x7f9737aac800 (LWP 30260)  0x000000351fe0803d in pthread_join () from /lib64/libpthread.so.0
      
      The reason is that we will try to lock some object in callback function, and we may call event API with locking the same object.
      In the function virEventDispatchHandles(), we unlock eventLoop before calling callback function. I think we should
      do the same thing in the function virEventCleanupTimeouts() and virEventCleanupHandles().
      Signed-off-by: NWen Congyang <wency@cn.fujitsu.com>
      Signed-off-by: NEric Blake <eblake@redhat.com>
      ac9ee6b5
  5. 07 3月, 2011 3 次提交
    • D
      Expose event loop implementation as a public API · 2ed6cc7b
      Daniel P. Berrange 提交于
      Not all applications have an existing event loop they need
      to integrate with. Forcing them to implement the libvirt
      event loop integration APIs is an undue burden. This just
      exposes our simple poll() based implementation for apps
      to use. So instead of calling
      
         virEventRegister(....callbacks...)
      
      The app would call
      
         virEventRegisterDefaultImpl()
      
      And then have a thread somewhere calling
      
          static bool quit = false;
          ....
          while (!quit)
            virEventRunDefaultImpl()
      
      * daemon/libvirtd.c, tools/console.c,
        tools/virsh.c: Convert to public event loop APIs
      * include/libvirt/libvirt.h.in, src/libvirt_private.syms: Add
        virEventRegisterDefaultImpl and virEventRunDefaultImpl
      * src/util/event.c: Implement virEventRegisterDefaultImpl
        and virEventRunDefaultImpl using poll() event loop
      * src/util/event_poll.c: Add full error reporting
      * src/util/virterror.c, include/libvirt/virterror.h: Add
        VIR_FROM_EVENTS
      2ed6cc7b
    • D
      Move event code out of the daemon/ into src/util/ · 343eaa15
      Daniel P. Berrange 提交于
      The event loop implementation is used by more than just the
      daemon, so move it into the shared area.
      
      * daemon/event.c, src/util/event_poll.c: Renamed
      * daemon/event.h, src/util/event_poll.h: Renamed
      * tools/Makefile.am, tools/console.c, tools/virsh.c: Update
        to use new virEventPoll APIs
      * daemon/mdns.c, daemon/mdns.c, daemon/Makefile.am: Update
        to use new virEventPoll APIs
      343eaa15
    • D
      Cleaning up some of the logging code · bcb40b85
      Daniel Veillard 提交于
      * src/util/logging.c: fix virLogDumpAllFD() to avoid snprintf, simplify
        the code and provide more useful signal descriptions. Also remove an
        unused variable.
      bcb40b85
  6. 05 3月, 2011 1 次提交
  7. 04 3月, 2011 3 次提交
  8. 03 3月, 2011 3 次提交
    • E
      util: correct retry path in virFileOperation · d152f647
      Eric Blake 提交于
      In virFileOperation, the parent does a fallback to a non-fork
      attempt if it detects that the child returned EACCES.  However,
      the child was calling _exit(-EACCES), which does _not_ appear
      as EACCES in the parent.
      
      * src/util/util.c (virFileOperation): Correctly pass EACCES from
      child to parent.
      d152f647
    • J
      util: Allow removing hash entries in virHashForEach · 9677cd33
      Jiri Denemark 提交于
      This fixes a possible crash of libvirtd during its startup. When qemu
      driver reconnects to running domains, it iterates over all domain
      objects in a hash. When reconnecting to an associated qemu monitor
      fails and the domain is transient, it's immediately removed from the
      hash. Despite the fact that it's explicitly forbidden to do so. If
      libvirtd is lucky enough, virHashForEach will access random memory when
      the callback finishes and the deamon will crash.
      
      Since it's trivial to fix virHashForEach to allow removal of hash
      entries while iterating through them, I went this way instead of fixing
      qemuReconnectDomain callback (and possibly others) to avoid deleting the
      entries.
      9677cd33
    • D
      Attempt to improve an error message · d6d30cd4
      Daniel P. Berrange 提交于
      Replace the 'Unknown failure' error message with something a
      little bit more descriptive.
      
      * src/util/virterror.c: Improve error message
      d6d30cd4
  9. 28 2月, 2011 1 次提交
  10. 25 2月, 2011 6 次提交
    • D
      Add APIs for killing off processes inside a cgroup · 33191b41
      Daniel P. Berrange 提交于
      The virCgroupKill method kills all PIDs found in a cgroup
      
      The virCgroupKillRecursively method does this recursively
      for child cgroups.
      
      The virCgroupKillPainfully method does a recursive kill
      several times in a row until everything has really died
      33191b41
    • D
      Allow hash tables to use generic pointers as keys · 16ba2aaf
      Daniel P. Berrange 提交于
      Relax the restriction that the hash table key must be a string
      by allowing an arbitrary hash code generator + comparison func
      to be provided
      
      * util/hash.c, util/hash.h: Allow any pointer as a key
      * internal.h: Include stdbool.h as standard.
      * conf/domain_conf.c, conf/domain_conf.c,
        conf/nwfilter_params.c, nwfilter/nwfilter_gentech_driver.c,
        nwfilter/nwfilter_gentech_driver.h, nwfilter/nwfilter_learnipaddr.c,
        qemu/qemu_command.c, qemu/qemu_driver.c,
        qemu/qemu_process.c, uml/uml_driver.c,
        xen/xm_internal.c: s/char */void */ in hash callbacks
      16ba2aaf
    • D
      Remove deallocator parameter from hash functions · 6952708c
      Daniel P. Berrange 提交于
      Since the deallocator is passed into the constructor of
      a hash table it is not desirable to pass it into each
      function again. Remove it from all functions, but provide
      a virHashSteal to allow a item to be removed from a hash
      table without deleteing it.
      
      * src/util/hash.c, src/util/hash.h: Remove deallocator
        param from all functions. Add virHashSteal
      * src/libvirt_private.syms: Add virHashSteal
      * src/conf/domain_conf.c, src/conf/nwfilter_params.c,
        src/nwfilter/nwfilter_learnipaddr.c,
        src/qemu/qemu_command.c, src/xen/xm_internal.c: Update
        for changed hash API
      6952708c
    • P
      Fix spelling mistake: seek · 0905d1ee
      Philipp Hahn 提交于
      Replace wrong "set" by correct "seek" in error message.
      Signed-off-by: NPhilipp Hahn <hahn@univention.de>
      0905d1ee
    • E
      cgroup: determine when skipping non-devices · 06173876
      Eric Blake 提交于
      * src/util/cgroup.c (virCgroupAllowDevicePath)
      (virCgroupDenyDevicePath): Don't fail with EINVAL for
      non-devices.
      * src/qemu/qemu_driver.c (qemudDomainSaveFlag): Update caller.
      * src/qemu/qemu_cgroup.c (qemuSetupDiskPathAllow)
      (qemuSetupChardevCgroup, qemuSetupHostUsbDeviceCgroup)
      (qemuSetupCgroup, qemuTeardownDiskPathDeny): Likewise.
      06173876
    • E
      virExec: avoid uninitialized memory usage · fd21ecfd
      Eric Blake 提交于
      valgrind warns:
      
      ==21079== Syscall param rt_sigaction(act->sa_mask) points to uninitialised byte(s)
      ==21079==    at 0x329840F63E: __libc_sigaction (sigaction.c:67)
      ==21079==    by 0x4E5A8E7: __virExec (util.c:661)
      
      Regression introduced in commit ab07533e.  Technically, sa_mask
      shouldn't affect operation if sa_flags selects sa_handler, and
      sa_handler selects SIG_IGN, but better safe than sorry.
      
      * src/util/util.c (__virExec): Supply missing sigemptyset.
      fd21ecfd
  11. 24 2月, 2011 3 次提交
  12. 23 2月, 2011 1 次提交
    • D
      Fix off-by-1 in virFileAbsPath. · 9f5bbe3b
      Daniel P. Berrange 提交于
      The virFileAbsPath was not taking into account the '/' directory
      separator when allocating memory for combining cwd + path. Convert
      to use virAsprintf to avoid this type of bug completely.
      
      * src/util/util.c: Convert virFileAbsPath to use virAsprintf
      9f5bbe3b
  13. 22 2月, 2011 3 次提交
    • R
      802.1Qbh: Delay IFF_UP'ing interface until migration final stage · dfd39ccd
      Roopa Prabhu 提交于
      Current code does an IFF_UP on a 8021Qbh interface immediately after a port
      profile set. This is ok in most cases except when its the migration prepare
      stage. During migration we want to postpone IFF_UP'ing the interface on the
      destination host until the source host has disassociated the interface.
      This patch moves IFF_UP of the interface to the final stage of migration.
      The motivation for this change is to postpone any addr registrations on the
      destination host until the source host has done the addr deregistrations.
      
      While at it, for symmetry with associate move ifDown of a 8021Qbh interface
      to before disassociate
      dfd39ccd
    • M
      Moved some SEXPR functions from xen-unified · c71328b9
      Markus Groß 提交于
      c71328b9
    • M
      Moved SEXPR unit to utils · 8606ca0d
      Markus Groß 提交于
      8606ca0d
  14. 21 2月, 2011 2 次提交
    • E
      maint: kill all remaining uses of old DEBUG macro · 994e7567
      Eric Blake 提交于
      Done mechanically with:
      $ git grep -l '\bDEBUG0\? *(' | xargs -L1 sed -i 's/\bDEBUG0\? *(/VIR_&/'
      
      followed by manual deletion of qemudDebug in daemon/libvirtd.c, along
      with a single 'make syntax-check' fallout in the same file, and the
      actual deletion in src/util/logging.h.
      
      * src/util/logging.h (DEBUG, DEBUG0): Delete.
      * daemon/libvirtd.h (qemudDebug): Likewise.
      * global: Change remaining clients over to VIR_DEBUG counterpart.
      994e7567
    • E
      hash: make virHashFree more free-like · 03ba07cb
      Eric Blake 提交于
      Two-argument free functions are uncommon; match the style elsewhere
      by caching the callback at creation.
      
      * src/util/hash.h (virHashCreate, virHashFree): Move deallocator
      argument to creation.
      * cfg.mk (useless_free_options): Add virHashFree.
      * src/util/hash.c (_virHashTable): Track deallocator.
      (virHashCreate, virHashFree): Update to new signature.
      * src/conf/domain_conf.c (virDomainObjListDeinit)
      (virDomainObjListInit, virDomainDiskDefForeachPath)
      (virDomainSnapshotObjListDeinit, virDomainSnapshotObjListInit):
      Update callers.
      * src/conf/nwfilter_params.c (virNWFilterHashTableFree)
      (virNWFilterHashTableCreate): Likewise.
      * src/conf/nwfilter_conf.c (virNWFilterTriggerVMFilterRebuild):
      Likewise.
      * src/cpu/cpu_generic.c (genericHashFeatures, genericBaseline):
      Likewise.
      * src/xen/xm_internal.c (xenXMOpen, xenXMClose): Likewise.
      * src/nwfilter/nwfilter_learnipaddr.c (virNWFilterLearnInit)
      (virNWFilterLearnShutdown): Likewise.
      * src/qemu/qemu_command.c (qemuDomainPCIAddressSetCreate)
      (qemuDomainPCIAddressSetFree): Likewise.
      * src/qemu/qemu_process.c (qemuProcessWaitForMonitor): Likewise.
      03ba07cb
  15. 19 2月, 2011 1 次提交
    • E
      build: fix broken mingw cross-compilation · 7b6286b7
      Eric Blake 提交于
      Two regressions:
      Commit df1011ca broke builds for systems that lack devmapper
      (non-Linux, as well as Linux with ./autogen.sh --without-libvirtd
      and without the libraries present).
      Commit ce6fd650 broke cross-compilation, due to a gnulib bug.
      
      * .gnulib: Update to latest, for cross-compilation fix.
      * src/util/util.c (virIsDevMapperDevice): Provide stub for
      platforms not using storage driver.
      * configure.ac (devmapper): Arrange to define HAVE_LIBDEVMAPPER_H.
      devmapper issue reported by Wen Congyang.
      7b6286b7
  16. 18 2月, 2011 4 次提交