1. 24 12月, 2010 6 次提交
    • 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
  2. 23 12月, 2010 1 次提交
  3. 22 12月, 2010 1 次提交
  4. 18 12月, 2010 1 次提交
  5. 14 12月, 2010 7 次提交
  6. 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
  7. 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
  8. 08 12月, 2010 3 次提交
    • 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
    • E
      command: enforce fd vs. buffer considerations · ee11729d
      Eric Blake 提交于
      * docs/internals/command.html.in: Better documentation of buffer
      vs. fd considerations.
      * src/util/command.c (virCommandRunAsync): Reject raw execution
      with string io.
      (virCommandRun): Reject execution with user-specified fds not
      visiting a regular file.
      ee11729d
    • E
      command: improve allocation failure reporting · c426d13b
      Eric Blake 提交于
      * src/util/command.c (virCommandAddEnvString): Remove duplicate
      code.
      (virCommandToString, virCommandRun, virCommandRunAsync)
      (virCommandWait): Report NULL command as ENOMEM, not invalid
      usage.
      Reported by Jiri Denemark.
      c426d13b
  9. 07 12月, 2010 3 次提交
    • E
      smbios: support system family · 8cad5603
      Eric Blake 提交于
      * docs/schemas/domain.rng (sysinfo-system-name): Also allow
      family.
      * src/util/sysinfo.h (struct _virSysinfoDef): Add system_family.
      * src/conf/domain_conf.c (virSysinfoParseXML)
      (virDomainSysinfoDefFormat): Support it.
      * src/util/sysinfo.c (virSysinfoDefFree, virSysinfoRead): Likewise.
      * src/qemu/qemu_conf.c (qemuBuildSmbiosSystemStr): Likewise.
      * tests/qemuxml2argvdata/qemuxml2argv-smbios.xml: Adjust test.
      * tests/qemuxml2argvdata/qemuxml2argv-smbios.args: Likewise.
      8cad5603
    • 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
    • O
      util: Fix bug which will cause libvirtd crash · 85ccf42c
      Osier Yang 提交于
      "virCommandRun": if "cmd->outbuf" or "cmd->errbuf" is NULL,
      libvirtd will be crashed when trying to start a qemu domain
      (which invokes "virCommandRun"), it caused by we try to use
      "*cmd->outbuf" and "*cmd->errbuf" regardless of cmd->outbuf
      or cmd->errbuf is NULL.
      
      * src/util/command.c (virCommandRun)
      85ccf42c
  10. 04 12月, 2010 1 次提交
  11. 03 12月, 2010 6 次提交
    • J
      Create file in virFileWriteStr() if it doesn't exist · 966a1bfe
      Jean-Baptiste Rouault 提交于
      This patch adds a mode_t parameter to virFileWriteStr().
      If mode is different from 0, virFileWriteStr() will try
      to create the file if it doesn't exist.
      
      * src/util/util.h (virFileWriteStr): Alter signature.
      * src/util/util.c (virFileWriteStr): Allow file creation.
      * src/network/bridge_driver.c (networkEnableIpForwarding)
      (networkDisableIPV6): Adjust clients.
      * src/node_device/node_device_driver.c
      (nodeDeviceVportCreateDelete): Likewise.
      * src/util/cgroup.c (virCgroupSetValueStr): Likewise.
      * src/util/pci.c (pciBindDeviceToStub, pciUnBindDeviceFromStub):
      Likewise.
      966a1bfe
    • D
      Remove bogus includes · 70256860
      Daniel P. Berrange 提交于
      70256860
    • D
      Port hooks and iptables code to new command execution APIs · 3709a386
      Daniel P. Berrange 提交于
      This proof of concept shows how two existing uses of virExec
      and virRun can be ported to the new virCommand APIs, and how
      much simpler the code becomes
      3709a386
    • D
      Introduce new APIs for spawning processes · f16ad06f
      Daniel P. Berrange 提交于
      This introduces a new set of APIs in src/util/command.h
      to use for invoking commands. This is intended to replace
      all current usage of virRun and virExec variants, with a
      more flexible and less error prone API.
      
      * src/util/command.c: New file.
      * src/util/command.h: New header.
      * src/Makefile.am (UTIL_SOURCES): Build it.
      * src/libvirt_private.syms: Export symbols internally.
      * tests/commandtest.c: New test.
      * tests/Makefile.am (check_PROGRAMS): Run it.
      * tests/commandhelper.c: Auxiliary program.
      * tests/commanddata/test2.log - test15.log: New expected outputs.
      * cfg.mk (useless_free_options): Add virCommandFree.
      (msg_gen_function): Add virCommandError.
      * po/POTFILES.in: New translation.
      * .x-sc_avoid_write: Add exemption.
      * tests/.gitignore: Ignore new built file.
      f16ad06f
    • E
      util: add virVasprintf · fce3baee
      Eric Blake 提交于
      * src/util/util.h (virVasprintf): New declaration.
      * src/util/util.c (virVasprintf): New function.
      (virAsprintf): Use it.
      * src/util/virtaudit.c (virAuditSend): Likewise.
      * src/libvirt_private.syms: Export it.
      * cfg.mk (sc_prohibit_asprintf): Also prohibit vasprintf.
      * .x-sc_prohibit_asprintf: Add exemption.
      fce3baee
    • E
      util: fix saferead type · dbab6bb5
      Eric Blake 提交于
      * src/util/util.c (saferead): Fix return type.
      (safewrite): Fix indentation.
      dbab6bb5
  12. 02 12月, 2010 4 次提交
    • D
      Fix memory leak in logging setup · c846bc9e
      Daniel P. Berrange 提交于
      The logging setup requires const char * strings, but the
      virLogSetFromEnv() strdup's the env variables, thus causing
      a memory leak
      
      * src/util/logging.c: Avoid strdup'ing env variables
      c846bc9e
    • E
      qemu: plug memory leak · 428ea3a6
      Eric Blake 提交于
      * src/qemu/qemu_driver.c (qemudShutdown): Free all strings and the
      ebtables structure.
      * src/libvirt_private.syms (ebtablesContextFree): Export missing
      symbol.
      * src/util/ebtables.c (ebtablesContextFree): Allow early exit.
      428ea3a6
    • D
      Fix flaw in thread creation APIs · 9c656092
      Daniel P. Berrange 提交于
      The arguments passed to the thread function must be allocated on
      the heap, rather than the stack, since it is possible for the
      spawning thread to continue before the new thread runs at all.
      In such a case, it is possible that the area of stack where the
      thread args were stored is overwritten.
      
      * src/util/threads-pthread.c, src/util/threads-win32.c: Allocate
        thread arguments on the heap
      9c656092
    • M
      Fix undefined symbol errors when macvtap support is disabled · 474b1c14
      Matthias Bolte 提交于
      Use macvtap specific functions depending on WITH_MACVTAP.
      
      Use #if instead of #ifdef to check for WITH_MACVTAP, because
      WITH_MACVTAP is always defined with value 0 or 1.
      
      Also export virVMOperationType{To|From}String unconditional,
      because they are used unconditional in the domain config code.
      474b1c14
  13. 01 12月, 2010 1 次提交
    • S
      802.1Qbg: use pre-associate state at beginning of inc. migr · c2b38277
      Stefan Berger 提交于
      This patch introduces the usage of the pre-associate state of the IEEE 802.1Qbg standard on incoming VM migration on the target host. It is in response to bugzilla entry 632750.
      
      https://bugzilla.redhat.com/show_bug.cgi?id=632750
      
      For being able to differentiate the exact reason as to why a macvtap device is being created, either due to a VM creation or an incoming VM migration, I needed to pass that reason as a parameter from wherever qemudStartVMDaemon is being called in order to determine whether to send an ASSOCIATE (VM creation) or a PRE-ASSOCIATE (incoming VM migration) towards lldpad.
      
      I am also fixing a problem with the virsh domainxml-to-native call on the way.
      
      Gerhard successfully tested the patch with a recent blade network 802.1Qbg-compliant switch.
      
      The patch should not have any side-effects on the 802.1Qbh support in libvirt, but Roopa (cc'ed) may want to verify this.
      c2b38277
  14. 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