1. 13 6月, 2012 1 次提交
  2. 11 6月, 2012 1 次提交
    • M
      rpc: Fix memleak in virNetMessageEncodeHeader · 539e9b34
      Michal Privoznik 提交于
      My latest patch for RPC rework (a2c304f6) introduced a memory leak.
      virNetMessageEncodeHeader() is calling VIR_ALLOC_N(msg->buffer, ...)
      despite fact, that msg->buffer isn't VIR_FREE()'d on all paths calling
      the function. Therefore, rather than injecting free statement switch to
      VIR_REALLOC_N().
      539e9b34
  3. 05 6月, 2012 2 次提交
    • M
      rpc: Size up RPC limits · eb635de1
      Michal Privoznik 提交于
      Since we are allocating RPC buffer dynamically, we can increase limits
      for max. size of RPC message and RPC string. This is needed to cover
      some corner cases where libvirt is run on such huge machines that their
      capabilities XML is 4 times bigger than our current limit. This leaves
      users with inability to even connect.
      eb635de1
    • M
      rpc: Switch to dynamically allocated message buffer · a2c304f6
      Michal Privoznik 提交于
      Currently, we are allocating buffer for RPC messages statically.
      This is not such pain when RPC limits are small. However, if we want
      ever to increase those limits, we need to allocate buffer dynamically,
      based on RPC message len (= the first 4 bytes). Therefore we will
      decrease our mem usage in most cases and still be flexible enough in
      corner cases.
      a2c304f6
  4. 04 6月, 2012 1 次提交
  5. 28 5月, 2012 2 次提交
  6. 23 5月, 2012 1 次提交
    • J
      Revert "rpc: Discard non-blocking calls only when necessary" · 63643f67
      Jiri Denemark 提交于
      This reverts commit b1e374a7, which was
      rather bad since I failed to consider all sides of the issue. The main
      things I didn't consider properly are:
      
      - a thread which sends a non-blocking call waits for the thread with
        the buck to process the call
      - the code doesn't expect non-blocking calls to remain in the queue
        unless they were already partially sent
      
      Thus, the reverted patch actually breaks more than what it fixes and
      clients (which may even be libvirtd during p2p migrations) will likely
      end up in a deadlock.
      63643f67
  7. 26 4月, 2012 2 次提交
    • J
      rpc: Discard non-blocking calls only when necessary · b1e374a7
      Jiri Denemark 提交于
      Currently, non-blocking calls are either sent immediately or discarded
      in case sending would block. This was implemented based on the
      assumption that the non-blocking keepalive call is not needed as there
      are other calls in the queue which would keep the connection alive.
      However, if those calls are no-reply calls (such as those carrying
      stream data), the remote party knows the connection is alive but since
      we don't get any reply from it, we think the connection is dead.
      
      This is most visible in tunnelled migration. If it happens to be longer
      than keepalive timeout (30s by default), it may be unexpectedly aborted
      because the connection is considered to be dead.
      
      With this patch, we only discard non-blocking calls when the last call
      with a thread is completed and thus there is no thread left to keep
      sending the remaining non-blocking calls.
      b1e374a7
    • P
      keepalive: Add ability to disable keepalive messages · 6446a9e2
      Peter Krempa 提交于
      The docs for virConnectSetKeepAlive() advertise that this function
      should be able to disable keepalives on negative or zero interval time.
      
      This patch removes the check that prohibited this and adds code to
      disable keepalives on negative/zero interval.
      
      * src/libvirt.c: virConnectSetKeepAlive(): - remove check for negative
                                                   values
      * src/rpc/virnetclient.c
      * src/rpc/virnetclient.h: - add virNetClientKeepAliveStop() to disable
                                  keepalive messages
      * src/remote/remote_driver.c: remoteSetKeepAlive(): -add ability to
                                                           disable keepalives
      6446a9e2
  8. 20 4月, 2012 2 次提交
    • E
      virnetserver: handle sigaction correctly · f4346173
      Eric Blake 提交于
      POSIX says that sa_sigaction is only safe to use if sa_flags
      includes SA_SIGINFO; conversely, sa_handler is only safe to
      use when flags excludes that bit.  Gnulib doesn't guarantee
      an implementation of SA_SIGINFO, but does guarantee that
      if SA_SIGINFO is undefined, we can safely define it to 0 as
      long as we don't dereference the 2nd or 3rd argument of
      any handler otherwise registered via sa_sigaction.
      
      Based on a report by Wen Congyang.
      
      * src/rpc/virnetserver.c (SA_SIGINFO): Stub for mingw.
      (virNetServerSignalHandler): Avoid bogus dereference.
      (virNetServerFatalSignal, virNetServerNew): Set flags properly.
      (virNetServerAddSignalHandler): Drop unneeded #ifdef.
      f4346173
    • D
      The policy kit and HAL node device drivers both require a · 2223ea98
      Daniel P. Berrange 提交于
      DBus connection. The HAL device code further requires that
      the DBus connection is integrated with the event loop and
      provides such glue logic itself.
      
      The forthcoming FirewallD integration also requires a
      dbus connection with event loop integration. Thus we need
      to pull the current event loop glue out of the HAL driver.
      
      Thus we create src/util/virdbus.{c,h} files. This contains
      just one method virDBusGetSystemBus() which obtains a handle
      to the single shared system bus instance, with event glue
      automagically setup.
      2223ea98
  9. 10 4月, 2012 1 次提交
  10. 30 3月, 2012 1 次提交
  11. 08 3月, 2012 2 次提交
    • E
      rpc: generalize solution for VPATH builds · 4d2e8355
      Eric Blake 提交于
      Commit 5d4b0c4c tried to fix certain classes of VPATH builds,
      but was too limited.  In particular, Guannan Ren reported:
      
      >    For example: The libvirt source code resides in /home/testuser,
      >                 I make dist in /tmp/buildvpath, the XDR routine .c file will
      >                 include full path of the header file like:
      >
      >                 #include "/home/testuser/src/rpc/virnetprotocol.h"
      >                 #include "internal.h"
      >                 #include <arpa/inet.h>
      >
      >    If we distribute the tarball to another machine to compile,
      >    it will report error as follows:
      >
      >    rpc/virnetprotocol.c:7:59: fatal error:
      >    /home/testuser/src/rpc/virnetprotocol.h: No such file or directory
      
      * src/rpc/genprotocol.pl: Fix more include lines.
      4d2e8355
    • E
      xml: use long long internally, to centralize overflow checks · 73b99771
      Eric Blake 提交于
      On 64-bit platforms, unsigned long and unsigned long long are
      identical, so we don't have to worry about overflow checks.
      On 32-bit platforms, anywhere we narrow unsigned long long back
      to unsigned long, we have to worry about overflow; it's easier
      to do this in one place by having most of the code use the same
      or wider types, and only doing the narrowing at the last minute.
      Therefore, the memory set commands remain unsigned long, and
      the memory get command now centralizes the overflow check into
      libvirt.c, so that drivers don't have to repeat the work.
      
      This also fixes a bug where xen returned the wrong value on
      failure (most APIs return -1 on failure, but getMaxMemory
      must return 0 on failure).
      
      * src/driver.h (virDrvDomainGetMaxMemory): Use long long.
      * src/libvirt.c (virDomainGetMaxMemory): Raise overflow.
      * src/test/test_driver.c (testGetMaxMemory): Fix driver.
      * src/rpc/gendispatch.pl (name_to_ProcName): Likewise.
      * src/xen/xen_hypervisor.c (xenHypervisorGetMaxMemory): Likewise.
      * src/xen/xen_driver.c (xenUnifiedDomainGetMaxMemory): Likewise.
      * src/xen/xend_internal.c (xenDaemonDomainGetMaxMemory):
      Likewise.
      * src/xen/xend_internal.h (xenDaemonDomainGetMaxMemory):
      Likewise.
      * src/xen/xm_internal.c (xenXMDomainGetMaxMemory): Likewise.
      * src/xen/xm_internal.h (xenXMDomainGetMaxMemory): Likewise.
      * src/xen/xs_internal.c (xenStoreDomainGetMaxMemory): Likewise.
      * src/xen/xs_internal.h (xenStoreDomainGetMaxMemory): Likewise.
      * src/xenapi/xenapi_driver.c (xenapiDomainGetMaxMemory):
      Likewise.
      * src/esx/esx_driver.c (esxDomainGetMaxMemory): Likewise.
      * src/libxl/libxl_driver.c (libxlDomainGetMaxMemory): Likewise.
      * src/qemu/qemu_driver.c (qemudDomainGetMaxMemory): Likewise.
      * src/lxc/lxc_driver.c (lxcDomainGetMaxMemory): Likewise.
      * src/uml/uml_driver.c (umlDomainGetMaxMemory): Likewise.
      73b99771
  12. 05 3月, 2012 1 次提交
    • J
      rpc: Fix client crash on connection close · 720bee30
      Jiri Denemark 提交于
      A multi-threaded client with event loop may crash if one of its threads
      closes a connection while event loop is in the middle of sending
      keep-alive message (either request or response). The right place for it
      is inside virNetClientIOEventLoop() between poll() and
      virNetClientLock(). We should only close a connection directly if no-one
      is using it and defer the closing to the last user otherwise. So far we
      only did so if the close was initiated by keep-alive timeout.
      720bee30
  13. 02 3月, 2012 1 次提交
    • E
      build: fix output of pid values · 355ec281
      Eric Blake 提交于
      Nuke the last vestiges of printing pid_t values with the wrong
      types, at least in code compiled on mingw64.  There may be other
      places, but for now they are only compiled on systems where the
      existing %d doesn't trigger gcc warnings.
      
      * src/rpc/virnetsocket.c (virNetSocketNew): Use %lld and casting,
      rather than assuming any particular int type for pid_t.
      * src/util/command.c (virCommandRunAsync, virPidWait)
      (virPidAbort): Likewise.
      (verify): Drop a now stale assertion.
      355ec281
  14. 04 2月, 2012 2 次提交
    • P
      virterror.c: Fix several spelling mistakes · 99d24ab2
      Philipp Hahn 提交于
      compat{a->i}bility
      erron{->e}ous
      nec{c->}essary.
      Either "the" or "a".
      Signed-off-by: NPhilipp Hahn <hahn@univention.de>
      99d24ab2
    • E
      build: prohibit raw malloc and free · a7cfd709
      Eric Blake 提交于
      Our HACKING discourages use of malloc and free, for at least
      a couple of years now.  But we weren't enforcing it, until now :)
      
      For now, I've exempted python and tests, and will clean those up
      in subsequent patches.  Examples should be permanently exempt,
      since anyone copying our examples won't have use of our
      internal-only memory.h via libvirt_util.la.
      
      * cfg.mk (sc_prohibit_raw_allocation): New rule.
      (exclude_file_name_regexp--sc_prohibit_raw_allocation): and
      exemptions.
      * src/cpu/cpu.c (cpuDataFree): Avoid false positive.
      * src/conf/network_conf.c (virNetworkDNSSrvDefParseXML): Fix
      offenders.
      * src/libxl/libxl_conf.c (libxlMakeDomBuildInfo, libxlMakeVfb)
      (libxlMakeDeviceModelInfo): Likewise.
      * src/rpc/virnetmessage.c (virNetMessageSaveError): Likewise.
      * tools/virsh.c (_vshMalloc, _vshCalloc): Likewise.
      a7cfd709
  15. 02 2月, 2012 1 次提交
    • E
      block rebase: add new API virDomainBlockRebase · 99fd69c3
      Eric Blake 提交于
      Qemu is adding the ability to do a partial rebase.  That is, given:
      
      base <- intermediate <- current
      
      virDomainBlockPull will produce:
      
      current
      
      but qemu now has the ability to leave base in the chain, to produce:
      
      base <- current
      
      Note that current qemu can only do a forward merge, and only with
      the current image as the destination, which is fully described by
      this API without flags.  But in the future, it may be possible to
      enhance this API for additional scenarios by using flags:
      
      Merging the current image back into a previous image (that is,
      undoing a live snapshot), could be done by passing base as the
      destination and flags with a bit requesting a backward merge.
      
      Merging any other part of the image chain, whether forwards (the
      backing image contents are pulled into the newer file) or backwards
      (the deltas recorded in the newer file are merged back into the
      backing file), could also be done by passing a new flag that says
      that base should be treated as an XML snippet rather than an
      absolute path name, where the XML could then supply the additional
      instructions of which part of the image chain is being merged into
      any other part.
      
      * include/libvirt/libvirt.h.in (virDomainBlockRebase): New
      declaration.
      * src/libvirt.c (virDomainBlockRebase): Implement it.
      * src/libvirt_public.syms (LIBVIRT_0.9.10): Export it.
      * src/driver.h (virDrvDomainBlockRebase): New driver callback.
      * src/rpc/gendispatch.pl (long_legacy): Add exemption.
      * docs/apibuild.py (long_legacy_functions): Likewise.
      99fd69c3
  16. 28 1月, 2012 1 次提交
    • M
      Introduce virDomainPMSuspendForDuration API · 8f8b0802
      Michal Privoznik 提交于
      This API allows a domain to be put into one of S# ACPI states.
      Currently, S3 and S4 are supported. These states are shared
      with virNodeSuspendForDuration.
      However, for now we don't support any duration other than zero.
      The same apply for flags.
      8f8b0802
  17. 19 1月, 2012 3 次提交
    • D
      Fix rpc generator to anchor matches for method names · 91f79d27
      Daniel P. Berrange 提交于
      The RPC generator transforms methods matching certain
      patterns like 'id' or 'uuid', etc but does not anchor
      its matches to the end of the word. So if a method
      contains 'id' in the middle (eg virIdentity) then the
      RPC generator munges that.
      
      * src/rpc/gendispatch.pl: Anchor matches
      91f79d27
    • D
      Rename APIs for fetching UNIX socket credentials · 2f9dc36d
      Daniel P. Berrange 提交于
      To avoid a namespace clash with forthcoming identity APIs,
      rename the virNet*GetLocalIdentity() APIs to have the form
      virNet*GetUNIXIdentity()
      
      * daemon/remote.c, src/libvirt_private.syms: Update
        for renamed APIs
      * src/rpc/virnetserverclient.c, src/rpc/virnetserverclient.h,
        src/rpc/virnetsocket.c, src/rpc/virnetsocket.h: s/LocalIdentity/UNIXIdentity/
      2f9dc36d
    • D
      Also retrieve GID from SO_PEERCRED · 59cf0398
      Daniel P. Berrange 提交于
      * daemon/remote.c, src/rpc/virnetserverclient.c,
        src/rpc/virnetserverclient.h, src/rpc/virnetsocket.c,
        src/rpc/virnetsocket.h: Add gid parameter
      59cf0398
  18. 12 1月, 2012 1 次提交
    • M
      stream: Check for stream EOF · 833b901c
      Michal Privoznik 提交于
      If client stream does not have any data to sink and neither received
      EOF, a dummy packet is sent to the daemon signalising client is ready to
      sink some data. However, after we added event loop to client a race may
      occur:
      
      Thread 1 calls virNetClientStreamRecvPacket and since no data are cached
      nor stream has EOF, it decides to send dummy packet to server which will
      sent some data in turn. However, during this decision and actual message
      exchange with server -
      
      Thread 2 receives last stream data from server. Therefore an EOF is set
      on stream and if there is a call waiting (which is not yet) it is woken
      up. However, Thread 1 haven't sent anything so far, so there is no call
      to be woken up. So this thread sent dummy packet to daemon, which
      ignores that as no stream is associated with such packet and therefore
      no reply will ever come.
      
      This race causes client to hang indefinitely.
      833b901c
  19. 20 12月, 2011 1 次提交
    • E
      rpc: handle param_int, plug memory leaks · 4e394dea
      Eric Blake 提交于
      The RPC code had several latent memory leaks and an attempt to
      free the wrong string, but thankfully nothing triggered them
      (blkiotune was the only one returning a string, and always as
      the last parameter).  Also, our cleanups for rpcgen ended up
      nuking a line of code that renders VIR_TYPED_PARAM_INT broken,
      because it was the only use of 'i' in a function, even though
      it was a member usage rather than a standalone declaration.
      
      * daemon/remote.c (remoteSerializeTypedParameters): Free the
      correct array element.
      (remoteDispatchDomainGetSchedulerParameters)
      (remoteDispatchDomainGetSchedulerParametersFlags)
      (remoteDispatchDomainBlockStatsFlags)
      (remoteDispatchDomainGetMemoryParameters): Don't leak strings.
      * src/rpc/genprotocol.pl: Don't nuke member-usage of 'buf' or 'i'.
      4e394dea
  20. 08 12月, 2011 2 次提交
    • D
      Fix updating of haveTheBuck in RPC client to be race-free · e9708637
      Daniel P. Berrange 提交于
      When one thread passes the buck to another thread, it uses
      virCondSignal to wake up the target thread. The variable
      'haveTheBuck' is not updated in a race-free manner when
      this occurs. The current thread sets it to false, and the
      woken up thread sets it to true. There is a window where
      a 3rd thread can come in and grab the buck.
      
      Even if this didn't lead to crashes & deadlocks, this would
      still result in unfairness in the buckpassing algorithm.
      
      A better solution is to *never* set haveTheBuck to false
      when we're passing the buck. Only set it to false when there
      is no further thread waiting for the buck.
      
      * src/rpc/virnetclient.c: Only set haveTheBuck to false
        if no thread is waiting
      e9708637
    • D
      Revert fd066925 · 50a4f49c
      Daniel P. Berrange 提交于
      Commit fd066925 tried to fix
      a race condition in
      
        commit fa959500
        Author: Daniel P. Berrange <berrange@redhat.com>
        Date:   Fri Nov 11 15:28:41 2011 +0000
      
          Explicitly track whether the buck is held in remote client
      
      Unfortunately there is a second race condition whereby the
      event loop can trigger due to incoming data to read. Revert
      this fix, so a complete fix for the problem can be cleanly
      applied
      
      * src/rpc/virnetclient.c: Revert fd066925
      50a4f49c
  21. 07 12月, 2011 1 次提交
    • D
      Improve error reporting when libvirtd is not installed · 13c881dc
      Daniel P. Berrange 提交于
      Currently if you try to connect to a local libvirtd when
      libvirtd is not in $PATH, you'll get an error
      
        error: internal error invalid use of command API
      
      This is because remoteFindDaemonPath() returns NULL, which
      causes us to pass NULL into virNetSocketConnectUNIX which
      in turn causes us to pass NULL into virCommandNewArgList.
      
      Adding missing error checks improves this to
      
        error: internal error Unable to locate libvirtd daemon in $PATH
      
      * src/remote/remote_driver.c: Report error if libvirtd
        cannot be found
      * src/rpc/virnetsocket.c: Report error if caller requested
        spawning of daemon, but provided no binary path
      13c881dc
  22. 04 12月, 2011 2 次提交
    • E
      maint: fix improper use of 'an' · 3a9ce767
      Eric Blake 提交于
      https://bugzilla.redhat.com/show_bug.cgi?id=648855 mentioned a
      misuse of 'an' where 'a' is proper; that has since been fixed,
      but a search found other problems (some were a spelling error for
      'and', while most were fixed by 'a').
      
      * daemon/stream.c: Fix grammar.
      * src/conf/domain_conf.c: Likewise.
      * src/conf/domain_event.c: Likewise.
      * src/esx/esx_driver.c: Likewise.
      * src/esx/esx_vi.c: Likewise.
      * src/rpc/virnetclient.c: Likewise.
      * src/rpc/virnetserverprogram.c: Likewise.
      * src/storage/storage_backend_fs.c: Likewise.
      * src/util/conf.c: Likewise.
      * src/util/dnsmasq.c: Likewise.
      * src/util/iptables.c: Likewise.
      * src/xen/xen_hypervisor.c: Likewise.
      * src/xen/xend_internal.c: Likewise.
      * src/xen/xs_internal.c: Likewise.
      * tools/virsh.c: Likewise.
      3a9ce767
    • E
      build: fix build on Cygwin · c74a2a03
      Eric Blake 提交于
      The RPC fixups needed on Linux are also needed on cygwin, and
      worked without further tweaking to the list of fixups.  Also,
      unlike BSD, Cygwin exports 'struct ifreq', but unlike Linux,
      Cygwin lacks the ioctls that we were using 'struct ifreq' to
      access.  This patch allows compilation under cygwin.
      
      * src/rpc/genprotocol.pl: Also perform fixups on cygwin.
      * src/util/virnetdev.c (HAVE_STRUCT_IFREQ): Also require AF_PACKET
      definition.
      * src/util/virnetdevbridge.c (virNetDevSetupControlFull): Only
      compile if SIOCBRADDBR works.
      c74a2a03
  23. 02 12月, 2011 1 次提交
    • P
      client: Check if other thread claims it has the buck before claiming it. · fd066925
      Peter Krempa 提交于
      Originaly, the code checked if another client is the queue and infered
      ownership of the buck from that. Commit fa959500
      added a separate variable to track the buck. That caused, that a new
      call might enter claiming it has the buck, while another thread was
      signalled to take the buck. This ends in two threads claiming they hold
      the buck and entering poll(). This happens due to a race on waking up
      threads on the client lock mutex.
      
      This caused multi-threaded clients to hang, most prominently visible and
      reproducible on python based clients, like virt-manager.
      
      This patch causes threads, that have been signalled to take the buck to
      re-check if buck is held by another thread.
      fd066925
  24. 01 12月, 2011 1 次提交
  25. 29 11月, 2011 2 次提交
  26. 24 11月, 2011 4 次提交