1. 30 1月, 2011 1 次提交
    • E
      build: avoid close, system · e67ae619
      Eric Blake 提交于
      * src/fdstream.c (virFDStreamOpenFile, virFDStreamCreateFile):
      Use VIR_FORCE_CLOSE instead of close.
      * tests/commandtest.c (mymain): Likewise.
      * tools/virsh.c (editFile): Use virCommand instead of system.
      * src/util/util.c (__virExec): Special case preservation of std
      file descriptors to child.
      e67ae619
  2. 29 1月, 2011 1 次提交
  3. 26 1月, 2011 3 次提交
    • 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
    • D
      Cleanup code style in logging APIs · 2b7ac883
      Daniel P. Berrange 提交于
      Remove use of brackets around following return statement.
      Fix indentation of two switch statements
      2b7ac883
  4. 19 1月, 2011 1 次提交
    • E
      build: use more gnulib modules for simpler code · c5b11b3c
      Eric Blake 提交于
      * .gnulib: Update to latest, for sigpipe and sigaction modules.
      * bootstrap.conf (gnulib_modules): Add siaction, sigpipe, strerror_r.
      * tools/virsh.c (vshSetupSignals) [!SIGPIPE]: Delete, now that
      gnulib guarantees it.
      (SA_SIGINFO): Define for mingw fallback.
      * src/util/virterror.c (virStrerror): Simplify, now that gnulib
      guarantees the POSIX interface.
      * configure.ac (AC_CHECK_FUNCS_ONCE): Drop redundant check.
      (AM_PROG_CC_STDC): Move earlier, to keep autoconf happy.
      c5b11b3c
  5. 15 1月, 2011 1 次提交
  6. 14 1月, 2011 1 次提交
    • E
      util: add missing string->integer conversion functions · 1ff03b28
      Eric Blake 提交于
      It was awkward having only int conversion in the virStrToLong family,
      but only long conversion in the virXPath family.  Make both families
      support both types.
      
      * src/util/util.h (virStrToLong_l, virStrToLong_ul): New
      prototypes.
      * src/util/xml.h (virXPathInt, virXPathUInt): Likewise.
      * src/util/util.c (virStrToLong_l, virStrToLong_ul): New
      functions.
      * src/util/xml.c (virXPathInt, virXPathUInt): Likewise.
      * src/libvirt_private.syms (util.h, xml.h): Export them.
      1ff03b28
  7. 13 1月, 2011 1 次提交
    • E
      virFindFileInPath: only find executable non-directory · 9ae992f2
      Eric Blake 提交于
      Without this patch, at least tests/daemon-conf (which sticks
      $builddir/src in the PATH) tries to execute the directory
      $builddir/src/qemu rather than a real qemu binary.
      
      * src/util/util.h (virFileExists): Adjust prototype.
      (virFileIsExecutable): New prototype.
      * src/util/util.c (virFindFileInPath): Reject non-executables and
      directories.  Avoid huge stack allocation.
      (virFileExists): Use lighter-weight syscall.
      (virFileIsExecutable): New function.
      * src/libvirt_private.syms (util.h): Export new function.
      9ae992f2
  8. 11 1月, 2011 1 次提交
  9. 06 1月, 2011 1 次提交
    • L
      Log an error on attempts to add a NAT rule for non-IPv4 addresses · cd6a8f9c
      Laine Stump 提交于
      Although the upper-layer code protected against it, it was possible to
      call iptablesForwardMasquerade() with an IPv6 address and have it
      attempt to add a rule to the MASQUERADE chain of ip6tables (which
      doesn't exist).
      
      This patch changes that function to check the protocol of the given
      address, generate an error log if it's not IPv4 (AF_INET), and finally
      hardcodes all the family parameters sent down to lower-level functions.
      cd6a8f9c
  10. 04 1月, 2011 2 次提交
    • E
      build: avoid compilation warnings · c685993d
      Eric Blake 提交于
      Detected on cygwin:
      util/util.c: In function 'virSetUIDGID':
      util/util.c:2824: warning: format '%d' expects type 'int', but argument 7 has type 'gid_t' [-Wformat]
      (and three other lines)
      
      * src/util/util.c (virSetUIDGID): Cast, as is done elsewhere in
      this file, to avoid printf type mismatch warnings.
      c685993d
    • H
      threadpool: allow NULL jobdata · b2dbc160
      Hu Tao 提交于
      Don't require non-null jobdata to virThreadPoolSendJob().
      b2dbc160
  11. 01 1月, 2011 4 次提交
    • E
      virExec: fix logic bug · e80ed3fd
      Eric Blake 提交于
      As pointed out in https://bugzilla.redhat.com/show_bug.cgi?id=659855#c9,
      commit c3568ec2 introduced a regression where we no longer close any
      fd's beyond FD_SETSIZE.
      
      * src/util/util.c (__virExec): Continue to close fd's beyond
      keepfd range.
      Reported by Stefan Praszalowicz.
      e80ed3fd
    • L
      Improve virSocketAddrMask[ByPrefix] API · 77094eaf
      Laine Stump 提交于
      The original version of these functions would modify the address sent
      in, meaning that the caller would usually need to copy the address
      first. This change makes the original a const, and puts the resulting
      masked address into a new arg (which could point to the same
      virSocketAddr as the original, if the caller really wants to modify
      it).
      
      This also makes the API consistent with virSocketAddrBroadcast[ByPrefix].
      77094eaf
    • L
      Set broadcast address for IPv4 addresses on virtual network bridges · 2eeeb601
      Laine Stump 提交于
      Previously we used ioctl() to set the IP address and netmask of the
      bridges used for virtual networks, and apparently the SIOCSIFNETMASK
      ioctl implicitly set the broadcast address for the interface. The new
      method of using the "ip" command requires broadcast address to be
      explicitly specified though.
      2eeeb601
    • L
      Utility functions to produce an IPv4 broadcast address · 86387878
      Laine Stump 提交于
      These functions work only for IPv4, becasue IPv6 doesn't have the same
      concept of "broadcast address" as IPv4. They merely OR the inverse of
      the netmask with the given host address, thus turning on all the host
      bits.
      86387878
  12. 24 12月, 2010 7 次提交
    • J
      bridge: Fix uninitialized variable · 0ecac8aa
      Jiri Denemark 提交于
      0ecac8aa
    • L
      new virSetUIDGID() utility function · d596c6dc
      Laine Stump 提交于
      virSetUIDGID() sets both the real and effective group and user of the
      process, and additionally calls initgroups() to assure that the
      process joins all the auxiliary groups that the given uid is a member
      of.
      d596c6dc
    • L
      Preserve errno across calls to error reporting functions & VIR_FREE · 17e19add
      Laine Stump 提交于
      There are cases when we want log an error message, and possibly free
      some memory as part of the cleanup, while still preserving errno for a
      caller, but the functions that log errors, and virFree (VIR_FREE) make
      system calls that will clear errno. This patch preserves errno during
      those most basic functions (corresponding to virReportSystemError(),
      virReportOOMError(), networkReportError(), etc, as well as
      virStrError()). It does *not preserve errno across calls to higher
      level items such as virDispatchError(), as it's assumed the caller is
      all finished with any need for errno by the time it dispatches the
      error.
      17e19add
    • L
      Update iptables.c to also support ip6tables. · 537e65e7
      Laine Stump 提交于
      All of the iptables functions eventually call down to a single
      bottom-level function, and fortunately, ip6tables syntax (for all the
      args that we use) is identical to iptables format (except the
      addresses), so all we need to do is:
      
      1) Get an address family down to the lowest level function in each
         case, either implied through an address, or explicitly when no
         address is in the parameter list, and
      
      2) At the lowest level, just decide whether to call "iptables" or
         "ip6tables" based on the family.
      
      The location of the ip6tables binary is determined at build time by
      autoconf. If a particular target system happens to not have ip6tables
      installed, any attempts to run it will generate an error, but that
      won't happen unless someone tries to define an IPv6 address for a
      network. This is identical behavior to IPv4 addresses and iptables.
      537e65e7
    • L
      Replace brSetInetAddress/brSetInetNetmask with brAddInetAddress · 20718b8b
      Laine Stump 提交于
      brSetInetAddress can only set a single IP address on the bridge, and
      uses a method (ioctl(SIOCSETIFADDR)) that only works for IPv4. Replace
      it and brSetInetNetmask with a single function that uses the external
      "ip addr add" command to add an address/prefix to the interface - this
      supports IPv6, and allows adding multiple addresses to the interface.
      
      Although it isn't currently used in the code, we also add a
      brDelInetAddress for completeness' sake.
      
      Also, while we're modifying bridge.c, we change brSetForwardDelay and
      brSetEnableSTP to use the new virCommand API rather than the
      deprecated virRun, and also log an error message in bridge_driver.c if
      either of those fail (previously the failure would be completely
      silent).
      20718b8b
    • L
      Pass prefix rather than netmask into iptables functions · b23d417c
      Laine Stump 提交于
      IPv6 will use prefix exclusively, and IPv4 will also optionally be
      able to use it, and the iptables functions really need a prefix
      anyway, so use the new virNetworkDefPrefix() function to send prefixes
      into iptables functions instead of netmasks.
      
      Also, in a couple places where a netmask is actually needed, use the
      new private API function for it rather than getting it directly. This
      will allow for cases where no netmask or prefix is specified (it
      returns the default for the current class of network.)
      b23d417c
    • L
      New virSocketAddr utility functions · 1ab80f32
      Laine Stump 提交于
      virSocketPrefixToNetmask: Given a 'prefix', which is the number of 1
      bits in a netmask, fill in a virSocketAddr object with a netmask as an
      IP address (IPv6 or IPv4).
      
      virSocketAddrMask: Mask off the host bits in one virSocketAddr
      according to the netmask in another virSocketAddr.
      
      virSocketAddrMaskByPrefix, Mask off the host bits in a virSocketAddr
      according to a prefix (number of 1 bits in netmask).
      
      VIR_SOCKET_FAMILY: return the family of a virSocketAddr
      1ab80f32
  13. 23 12月, 2010 1 次提交
  14. 22 12月, 2010 1 次提交
  15. 18 12月, 2010 1 次提交
  16. 14 12月, 2010 7 次提交
  17. 11 12月, 2010 2 次提交
    • E
      command: ease use with virBuffer, and fix qemu leak · e8d05c97
      Eric Blake 提交于
      * src/util/command.h (virCommandAddArgBuffer)
      (virCommandAddEnvBuffer): New prototypes.
      * src/util/command.c (virCommandAddArgBuffer)
      (virCommandAddEnvBuffer): Implement them.
      * src/libvirt_private.syms (command.h): Export them.
      * src/qemu/qemu_conf.c (qemudBuildCommandLine): Use them, plugging
      a memory leak on rbd_hosts in the process.
      e8d05c97
    • E
      virExec: avoid undefined behavior · c3568ec2
      Eric Blake 提交于
      * src/util/util.c (__virExec): Don't use FD_ISSET on out-of-bounds fd.
      c3568ec2
  18. 10 12月, 2010 3 次提交
    • E
      command: plug memory leak · f12d4169
      Eric Blake 提交于
      * src/util/command.c (virCommandFree): Free data from
      virCommandSetInputBuffer.
      f12d4169
    • H
      threadpool impl · 482380b5
      Hu Tao 提交于
      * src/util/threadpool.c, src/util/threadpool.h: Thread pool
        implementation
      * src/Makefile.am: Build thread pool
      * src/libvirt_private.syms: Export public functions
      482380b5
    • E
      command: avoid memory leak · 8e9ee30e
      Eric Blake 提交于
      * src/util/command.c (virCommandRun): Fix yesterday's regression
      on logging, and avoid leaking log-only output captures.
      Reported by Hu Tao.
      8e9ee30e
  19. 08 12月, 2010 1 次提交
    • E
      command: improve behavior on no output · cc5e2a84
      Eric Blake 提交于
      Guarantee that outbuf/errbuf are allocated on success, even if to the
      empty string.  Caller always has to free the result, and empty output
      check requires checking if *outbuf=='\0'.  Makes the API easier to use
      safely.  Failure is best effort allocation (some paths, like
      out-of-memory, cannot allocate a buffer, but most do), so caller must
      free buffer on failure.
      
      * docs/internals/command.html.in: Update documentation.
      * src/util/command.c (virCommandSetOutputBuffer)
      (virCommandSetErrorBuffer, virCommandProcessIO) Guarantee empty
      string on no output.
      * tests/commandtest.c (test17): New test.
      cc5e2a84