1. 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
      Convert daemon/virsh over to use primary event APIs, rather than impl · 5d2c045c
      Daniel P. Berrange 提交于
      The daemon code calls virEventAddHandleImpl directly instead
      of calling the wrapper virEventAddHandle.
      
      * tools/console.c, daemon/libvirtd.c, daemon/mdns.c: Convert to
        use primary event APIs
      5d2c045c
  2. 04 3月, 2011 3 次提交
    • D
      Dump the debug buffer to libvirtd.log on fatal signal · a9f35c48
      Daniel Veillard 提交于
      In case of imminent crash or upon request (signal USR2),
      dump the logging buffer to the libvirtd.log file for
      post-mortem analysis
      * daemon/libvirtd.c: create a sig_fatal() handler connected to
        SIGFPE SIGSEGV SIGILL SIGABRT SIGBUS and SIGUSR2, just dumping
        the log buffer using virLogEmergencyDumpAll
      a9f35c48
    • D
      Add logrotate support for libvirtd.log · e7aeed00
      Daniel Veillard 提交于
      As the file may grow quite a bit especially with debug turned on.
      * daemon/libvirtd.logrotate.in daemon/Makefile.am libvirt.spec.in:
        add new logrotate file for the daemon log
      e7aeed00
    • D
      Change default log policy to libvirtd.log instead of syslog · 8ddf6d1e
      Daniel Veillard 提交于
      Syslog is not the best place to go search for libvirt error
      logs, change it to a default file output libvirtd.log, but
      still keep standard error if not run as a daemon.
      Depending on whether it's run as root or user, the log is saved
      in the local state dir or in $HOME/.libvirt.
      * daemon/libvirtd.c: change default logging to go to libvirtd.log
      8ddf6d1e
  3. 24 2月, 2011 1 次提交
  4. 22 2月, 2011 1 次提交
    • E
      build: don't require pod2man for tarball builds · 6db98a2d
      Eric Blake 提交于
      Right now, 'man libvirtd' includes information that depends on
      configure results, so it must be generated on the fly and live
      in $(builddir); however, requiring pod2man on all end user
      machines is overkill.  Meanwhile, 'man virsh' doesn't mention
      any configure results, so it can be built at 'make dist' time.
      If that situation changes in the future, we can generate virsh.1
      in the same way that we generate libvirtd.8.
      
      * daemon/Makefile.am (libvirtd.8.in): New rule, to run pod2man in
      advance of distribution.
      (libvirtd.8): Use only sed from tarball.
      (EXTRA_DIST): Ship new file.
      (libvirtd.pod): Delete unused rule.
      (man8_MANS): Let automake know which section to use.
      (CLEANFILES, MAINTAINERCLEANFILES): Adjust to new files.
      * tools/Makefile.am (dist_man1_MANS): Distribute pre-built man
      pages, fine since they don't require any substitution.
      (virt-xml-validate.1, virt-pki-validate.1): Change input source.
      (virsh.1): Build into srcdir.
      (CLEANFILES, MAINTAINERCLEANFILES): Adjust to new build style.
      * daemon/.gitignore: Update.
      Reported by Diego Elio Pettenò.
      6db98a2d
  5. 21 2月, 2011 1 次提交
    • 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
  6. 10 2月, 2011 1 次提交
    • D
      Add a little more debugging for async events · 2222bd24
      Daniel P. Berrange 提交于
      To make it easier to investigate problems with async event
      delivery, add two more debugging lines
      
      * daemon/remote.c: Debug when an event is queued for dispatch
      * src/remote/remote_driver.c: Debug when an event is received
        for processing
      2222bd24
  7. 09 2月, 2011 1 次提交
    • E
      sysinfo: implement the remote protocol · 5c8deddd
      Eric Blake 提交于
      Done by editing the first three files, then running
      'make -C src rpcgen', then editing src/remote_protocol-structs
      to match.
      
      * daemon/remote.c (remoteDispatchGetSysinfo): New function.
      * src/remote/remote_driver.c (remoteGetSysinfo, remote_driver):
      Client side serialization.
      * src/remote/remote_protocol.x (remote_get_sysinfo_args)
      (remote_get_sysinfo_ret): New types.
      (REMOTE_PROC_GET_SYSINFO): New enum value.
      * daemon/remote_dispatch_args.h: Regenerate.
      * daemon/remote_dispatch_prototypes.h: Likewise.
      * daemon/remote_dispatch_ret.h: Likewise.
      * daemon/remote_dispatch_table.h: Likewise.
      * src/remote/remote_protocol.c: Likewise.
      * src/remote/remote_protocol.h: Likewise.
      * src/remote_protocol-structs: Likewise.
      5c8deddd
  8. 29 1月, 2011 2 次提交
  9. 28 1月, 2011 1 次提交
    • E
      event: fix event-handling allocation crash · a7483a56
      Eric Blake 提交于
      Regression introduced in commit e6b68d74 (Nov 2010).
      
      Prior to that point, handlesAlloc was always a multiple of
      EVENT_ALLOC_EXTENT (10), and was an int (so even if the subtraction
      had been able to wrap, a negative value would be less than the count
      not try to free the handles array).  But after that point,
      VIR_RESIZE_N made handlesAlloc grow geometrically (with a pattern of
      10, 20, 30, 45 for the handles array) but still freed in multiples of
      EVENT_ALLOC_EXTENT; and the count changed to size_t.  Which means that
      after 31 handles have been created, then 30 handles destroyed,
      handlesAlloc is 5 while handlesCount is 1, and since (size_t)(1 - 5)
      is indeed greater than 1, this then tried to free 10 elements, which
      had the awful effect of nuking the handles array while there were
      still live handles.
      
      Nuking live handles puts libvirtd in an inconsistent state, and was
      easily reproducible by starting and then stopping 60 faqemu guests.
      
      * daemon/event.c (virEventCleanupTimeouts, virEventCleanupHandles):
      Avoid integer wrap-around causing us to delete the entire array
      while entries are still active.
      * tests/eventtest.c (mymain): Expose the bug.
      a7483a56
  10. 26 1月, 2011 2 次提交
    • D
      Filter out certain expected error messages from libvirtd · b8786c06
      Daniel P. Berrange 提交于
      Add a hook to the error reporting APIs to allow specific
      error messages to be filtered out. Wire up libvirtd to
      remove VIR_ERR_NO_DOMAIN & similar error codes from the
      logs. They are still logged at DEBUG level.
      
      * daemon/libvirtd.c: Filter VIR_ERR_NO_DOMAIN and friends
      * src/libvirt_private.syms, src/util/virterror.c,
        src/util/virterror_internal.h: Hook for changing error
        reporting level
      b8786c06
    • D
      Revert all previous error log priority hacks · dbfca3ff
      Daniel P. Berrange 提交于
      This reverts the additions in commit
      
        abff683f
      
      taking us back to state where all errors are fully logged
      in both libvirtd and normal clients.
      
      THe intent was to stop VIR_ERR_NO_DOMAIN (No such domain
      with UUID XXXX) messages from client apps polluting syslog
      The change affected all error codes, but more seriously,
      it also impacted errors from internal libvirtd infrastructure
      For example guest autostart no longer logged errors. The
      libvirtd network code no longer logged some errors. This
      makes debugging incredibly hard
      
      * daemon/libvirtd.c: Remove error log priority filter
      * src/util/virterror.c, src/util/virterror_internal.h: Remove
        callback for overriding log priority
      dbfca3ff
  11. 22 1月, 2011 2 次提交
    • E
      event: fix event-handling data race · a11bd2e6
      Eric Blake 提交于
      This bug has been present since before the time that commit
      f8a519 (Dec 2008) tried to make the dispatch loop re-entrant.
      
      Dereferencing eventLoop.handles outside the lock risks crashing, since
      any other thread could have reallocated the array in the meantime.
      It's a narrow race window, however, and one that would have most
      likely resulted in passing bogus data to the callback rather than
      actually causing a segv, which is probably why it has gone undetected
      this long.
      
      * daemon/event.c (virEventDispatchHandles): Cache data while
      inside the lock, as the array might be reallocated once outside.
      a11bd2e6
    • C
      Push unapplied fixups for previous patch · 1e1f7a89
      Cole Robinson 提交于
      - Add augeas tests
      - Clarify vnc_auto_unix_socket precedence in qemu.conf
      1e1f7a89
  12. 10 1月, 2011 1 次提交
    • J
      daemon: Fix core dumps if unix_sock_group is set · 5e5acbc8
      Jiri Denemark 提交于
      Setting unix_sock_group to something else than default "root" in
      /etc/libvirt/libvirtd.conf prevents system libvirtd from dumping core on
      crash. This is because we used setgid(unix_sock_group) before binding to
      /var/run/libvirt/libvirt-sock* and setgid() back to original group.
      However, if a process changes its effective or filesystem group ID, it
      will be forbidden from leaving core dumps unless fs.suid_dumpable sysctl
      is set to something else then 0 (and it is 0 by default).
      
      Changing socket's group ownership after bind works better. And we can do
      so without introducing a race condition since we loosen access rights by
      changing the group from root to something else.
      5e5acbc8
  13. 22 12月, 2010 1 次提交
    • E
      maint: avoid space-tab · 831aaf4a
      Eric Blake 提交于
      * daemon/Makefile.am: Avoid spurious space before tabs.
      * src/Makefile.am: Likewise.
      * examples/dominfo/Makefile.am: Likewise.
      * examples/domsuspend/Makefile.am: Likewise.
      * tools/Makefile.am: Likewise.
      * src/datatypes.h (VIR_CONNECT_MAGIC): Likewise.
      * src/internal.h (TODO): Likewise.
      * src/qemu/qemu_monitor.h (QEMU_MONITOR_MIGRATE): Likewise.
      * src/xen/xen_hypervisor.c (XEN_V2_OP_GETAVAILHEAP): Likewise.
      * src/xen/xs_internal.h: Likewise.
      831aaf4a
  14. 14 12月, 2010 4 次提交
    • J
      daemon: Change CWD to / before daemonizing · 99800e54
      Jiri Denemark 提交于
      We were doing so for child processes but not for libvirtd itself.
      99800e54
    • E
      daemon, threads: plug a memory leak · 6e9a29c8
      Eric Blake 提交于
      * daemon/libvirtd.c (qemudStartWorker, qemudStartEventLoop): Avoid
      leaking pthread_attr resources.
      * src/util/threads-pthread.c (virThreadCreate): Likewise.
      6e9a29c8
    • E
      build: update gnulib for pipe on mingw · 65c0f17a
      Eric Blake 提交于
      * .gnulib: Update to latest.
      * bootstrap.conf (gnulib_modules): Import pipe-posix and waitpid
      for mingw.
      * src/remote/remote_driver.c (pipe) [WIN32]: Drop dead macro.
      * daemon/event.c (pipe) [WIN32]: Drop dead function.
      65c0f17a
    • E
      daemon: plug a memory leak · 24384a75
      Eric Blake 提交于
      * daemon/libvirtd.c (qemudFreeClient): Avoid a leak.
      (qemudDispatchServer): Avoid null dereference.
      24384a75
  15. 07 12月, 2010 1 次提交
    • E
      threads: add virThreadID for debugging use · e4bc372e
      Eric Blake 提交于
      * src/util/threads.h (virThreadID): New prototype.
      * src/util/threads-pthread.c (virThreadID): New function.
      * src/util/threads-win32.c (virThreadID): Likewise.
      * src/libvirt_private.syms (threads.h): Export it.
      * daemon/event.c (virEventInterruptLocked): Use it to avoid
      warning on BSD systems.
      e4bc372e
  16. 02 12月, 2010 2 次提交
  17. 30 11月, 2010 1 次提交
    • M
      Log client errors in libvirtd at debug priority · abff683f
      Matthias Bolte 提交于
      This reverts commit
      
       Log all errors at level INFO to stop polluting syslog
       04bd0360.
      
      and makes virRaiseErrorFull() log errors at debug priority
      when called from inside libvirtd. This stops libvirtd from
      polluting it's own log with client errors at error priority
      that'll be reported and logged on the client side anyway.
      abff683f
  18. 24 11月, 2010 1 次提交
    • O
      implement the remote protocol · 313215e1
      Osier Yang 提交于
      * daemon/remote.c
      * daemon/remote_dispatch_args.h
      * daemon/remote_dispatch_prototypes.h
      * daemon/remote_dispatch_ret.h
      * daemon/remote_dispatch_table.h
      * src/remote/remote_driver.c
      * src/remote/remote_protocol.c
      * src/remote/remote_protocol.h
      * src/remote/remote_protocol.x
      * src/remote_protocol-structs
      313215e1
  19. 23 11月, 2010 2 次提交
    • E
      libvirtd: fix bug when shrinking number of clients · 149c4921
      Eric Blake 提交于
      * daemon/libvirtd.c (qemudRunLoop): Pass allocation size, not
      current count, to VIR_SHRINK_N.
      * docs/hacking.html.in: Update doc example.
      * HACKING: Regenerate.
      149c4921
    • D
      Don't catch SIGCHLD in libvirtd · 375ba36e
      Daniel P. Berrange 提交于
      libvirtd no longer deals with SIGCHLD in its signal handler
      since the QEMU driver switched to always daemonize processes.
      Thus remove the sigaction for it, to avoid warning log
      messages
      
      * daemon/libvirtd.c: Don't catch SIGCHLD
      375ba36e
  20. 22 11月, 2010 1 次提交
  21. 19 11月, 2010 1 次提交
    • E
      daemon: use safer memory growth macros · e6b68d74
      Eric Blake 提交于
      * daemon/libvirtd.h (qemud_server): Change types of members
      tracking array sizes, and add allocation trackers.
      * daemon/event.c (virEventLoop): Likewise.
      (virEventAddHandleImpl, virEventAddTimeoutImpl)
      (virEventCleanupTimeouts, virEventCleanupHandles): Use
      VIR_RESIZE_N instead of VIR_REALLOC_N.  Tweak debug messages to
      match type changes.
      * daemon/libvirtd.c (qemudDispatchServer, qemudRunLoop): Likewise.
      e6b68d74
  22. 18 11月, 2010 1 次提交
    • E
      maint: improve i18n on non-Linux · 981d2cda
      Eric Blake 提交于
      Per the gettext developer:
      http://lists.gnu.org/archive/html/bug-gnu-utils/2010-10/msg00019.html
      http://lists.gnu.org/archive/html/bug-gnu-utils/2010-10/msg00021.html
      
      gettext() doesn't work correctly on all platforms unless you have
      called setlocale().  Furthermore, gnulib's gettext.h has provisions
      for setting up a default locale, which is the preferred method for
      libraries to use gettext without having to call textdomain() and
      override the main program's default domain (virInitialize already
      calls bindtextdomain(), but this is insufficient without the
      setlocale() added in this patch; and a redundant bindtextdomain()
      in this patch doesn't hurt, but serves as a good example for other
      packages that need to bind a second translation domain).
      
      This patch is needed to silence a new gnulib 'make syntax-check'
      rule in the next patch.
      
      * daemon/libvirtd.c (main): Setup locale and gettext.
      * src/lxc/lxc_controller.c (main): Likewise.
      * src/security/virt-aa-helper.c (main): Likewise.
      * src/storage/parthelper.c (main): Likewise.
      * tools/virsh.c (main): Fix exit status.
      * src/internal.h (DEFAULT_TEXT_DOMAIN): Define, for gettext.h.
      (_): Simplify definition accordingly.
      * po/POTFILES.in: Add src/storage/parthelper.c.
      981d2cda
  23. 17 11月, 2010 3 次提交
    • E
      maint: use gnulib configmake rather than open-coding things · 0d5f54bb
      Eric Blake 提交于
      * bootstrap.conf (gnulib_modules): Add configmake.
      * daemon/Makefile.am (libvirtd_CFLAGS): Drop defines provided by
      gnulib.
      * src/Makefile.am (INCLUDES): Likewise.
      * tests/Makefile.am (INCLUDES): Likewise.
      * tools/Makefile.am (virsh_CFLAGS): Likewise.
      * daemon/libvirtd.c (qemudInitPaths, usage, main): Update
      clients.
      * src/cpu/cpu_map.c (CPUMAPFILE): Likewise.
      * src/driver.c (DEFAULT_DRIVER_DIR): Likewise.
      * src/internal.h (_): Likewise.
      * src/libvirt.c (virInitialize): Likewise.
      * src/lxc/lxc_conf.h (LXC_CONFIG_DIR, LXC_STATE_DIR, LXC_LOG_DIR):
      Likewise.
      * src/lxc/lxc_conf.c (lxcCapsInit, lxcLoadDriverConfig):
      Likewise.
      * src/network/bridge_driver.c (NETWORK_PID_DIR)
      (NETWORK_STATE_DIR, DNSMASQ_STATE_DIR, networkStartup): Likewise.
      * src/nwfilter/nwfilter_driver.c (nwfilterDriverStartup):
      Likewise.
      * src/qemu/qemu_conf.c (qemudLoadDriverConfig): Likewise.
      * src/qemu/qemu_driver.c (qemudStartup): Likewise.
      * src/remote/remote_driver.h (LIBVIRTD_PRIV_UNIX_SOCKET)
      (LIBVIRTD_PRIV_UNIX_SOCKET_RO, LIBVIRTD_CONFIGURATION_FILE)
      (LIBVIRT_PKI_DIR): Likewise.
      * src/secret/secret_driver.c (secretDriverStartup): Likewise.
      * src/security/security_apparmor.c (VIRT_AA_HELPER): Likewise.
      * src/security/virt-aa-helper.c (main): Likewise.
      * src/storage/storage_backend_disk.c (PARTHELPER): Likewise.
      * src/storage/storage_driver.c (storageDriverStartup): Likewise.
      * src/uml/uml_driver.c (TEMPDIR, umlStartup): Likewise.
      * src/util/hooks.c (LIBVIRT_HOOK_DIR): Likewise.
      * tools/virsh.c (main): Likewise.
      * docs/hooks.html.in: Likewise.
      0d5f54bb
    • S
      deprecate fclose() and introduce VIR_{FORCE_}FCLOSE() · 7b7cb1ec
      Stefan Berger 提交于
      Similarly to deprecating close(), I am now deprecating fclose() and
      introduce VIR_FORCE_FCLOSE() and VIR_FCLOSE(). Also, fdopen() is replaced with
      VIR_FDOPEN().
      
      Most of the files are opened in read-only mode, so usage of
      VIR_FORCE_CLOSE() seemed appropriate. Others that are opened in write
      mode already had the fclose()<  0 check and I converted those to
      VIR_FCLOSE()<  0.
      
      I did not find occurrences of possible double-closed files on the way.
      7b7cb1ec
    • O
      daemon: fix indention problem in daemon/libvirt.c · 7942fd1c
      Osier Yang 提交于
      * daemon/libvirtd.c
      7942fd1c
  24. 15 11月, 2010 1 次提交
  25. 12 11月, 2010 2 次提交
    • D
      Fix busy-wait loop on closed file descriptor · c5d1a995
      Daniel P. Berrange 提交于
      When closing open streams after a client quits, the event
      callback was not removed. This mean that poll() was using
      a closed FD and returning POLLNVAL in a busy-wait loop.
      
      * daemon/stream.c: Disconnect stream callbacks
      c5d1a995
    • D
      Convert daemon/events.c to use virMutex and virThread · 77960c0e
      Daniel P. Berrange 提交于
      The code currently uses pthreads APIs directly. This is not
      portable to Win32 threads. Switch it over to use the portability
      APIs. Also add a wrapper for pipe() which is subtely different
      on Win32
      
      * daemon/event.c: Switch to use virMutex & virThread.
      77960c0e