1. 01 9月, 2011 1 次提交
    • D
      Don't leak memory if a cgroup is mounted multiple times · c32536e7
      Daniel P. Berrange 提交于
      It is possible (expected/likely in Fedora 15) for a cgroup controller
      to be mounted in multiple locations at the same time, due to bind
      mounts. Currently we leak memory if this happens, because we overwrite
      the previous 'mountPoint' string. Instead just accept the first match
      we find.
      
      * src/util/cgroup.c: Only accept first match for a cgroup
        controller mount
      c32536e7
  2. 30 8月, 2011 1 次提交
    • E
      build: simplify use of verify · 71a0beaf
      Eric Blake 提交于
      Back in 2008 when this line of util.h was written, gnulib's verify
      module didn't allow the use of multiple verify() in one file
      in combination with our choice of gcc -W options.  But that has
      since been fixed in gnulib, and newer gnulib even maps verify()
      to the C1x feature of _Static_assert, which gives even nicer
      diagnostics with a new enough compiler, so we might as well go
      with the simpler verify().
      
      * src/util/util.h (VIR_ENUM_IMPL): Use simpler verify, now that
      gnulib module is smarter.
      71a0beaf
  3. 26 8月, 2011 3 次提交
    • M
      hyperv: Add driver skeleton · 4d6e6f4a
      Matthias Bolte 提交于
      4d6e6f4a
    • M
      virterror: Fix error message for VIR_ERR_INVALID_ARG · 6c7299d4
      Michal Privoznik 提交于
      When a detail message is presented, nobody expects prefix 'invalid
      argument in' but something more general, like 'invalid argument:'.
      6c7299d4
    • D
      Fix keymap used to talk with QEMU · ce93f64b
      Daniel P. Berrange 提交于
      The QEMU 'sendkey' command expects keys to be encoded in the same
      way as the RFB extended keycode set. Specifically it wants extended
      keys to have the high bit of the first byte set, while the Linux
      XT KBD driver codeset uses the low bit of the second byte. To deal
      with this we introduce a new keymap 'RFB' and use that in the QEMU
      driver
      
      * include/libvirt/libvirt.h.in: Add VIR_KEYCODE_SET_RFB
      * src/qemu/qemu_driver.c: Use RFB keycode set instead of XT KBD
      * src/util/virkeycode-mapgen.py: Auto-generate the RFB keycode
        set from the XT KBD set
      * src/util/virkeycode.c: Add RFB keycode entry to table. Add a
        verify check on cardinality of the codeOffset table
      ce93f64b
  4. 25 8月, 2011 1 次提交
    • L
      util: only fchown newly created files in virFileOpenAs · b1643dc1
      Laine Stump 提交于
      virFileOpenAs takes desired uid:gid as arguments, and not only uses
      them for a fork/setuid/setgid when retrying failed open operations,
      but additionally always forces the opened file to be owned by the
      given uid:gid.
      
      One example of the problems this causes is that, when restoring a
      domain from a file that is owned by the qemu user, opening the file
      chowns it to root. if dynamic_ownership=1 this is coincidentally
      expected, but if dynamic_ownership=0, no existing file should ever
      have its ownership changed.
      
      This patch adds an extra check before calling fchown() - it only does
      it if O_CREAT was passed to virFileOpenAs() in the openflags.
      b1643dc1
  5. 24 8月, 2011 1 次提交
    • E
      maint: fix comment typos · 3a52b864
      Eric Blake 提交于
      * src/qemu/qemu_driver.c (qemuDomainSaveInternal): Fix typo.
      * src/conf/domain_event.c (virDomainEventDispatchMatchCallback):
      Likewise.
      * daemon/libvirtd.c (daemonRunStateInit): Likewise.
      * src/lxc/lxc_container.c (lxcContainerChildMountSort): Likewise.
      * src/util/virterror.c (virCopyError, virRaiseErrorFull): Likewise.
      * src/xenxs/xen_sxpr.c (xenParseSxprSound): Likewise.
      3a52b864
  6. 22 8月, 2011 1 次提交
  7. 19 8月, 2011 1 次提交
    • E
      xml: add another convenience function · 751304e3
      Eric Blake 提交于
      Often, we want to use XPath functions on the just-parsed document;
      fold this into the parser function for convenience.
      
      * src/util/xml.h (virXMLParseHelper): Add argument.
      (virXMLParseStrHelper, virXMLParseFileHelper): Delete.
      (virXMLParseCtxt, virXMLParseStringCtxt, virXMLParseFileCtxt): New
      macros.
      * src/libvirt_private.syms (xml.h): Remove deleted functions.
      * src/util/xml.c (virXMLParseHelper): Add argument.
      (virXMLParseStrHelper, virXMLParseFileHelper): Delete.
      751304e3
  8. 18 8月, 2011 1 次提交
    • E
      build: fix virpidfile on mingw · c811de8f
      Eric Blake 提交于
      Regression introduced in commit b7e5ca48.
      
      Mingw lacks kill(), but we were only using it for a sanity check;
      so we can go with one less check.
      
      Also, on OOM error, this function should outright fail rather than
      claim that the pid file was successfully read.
      
      * src/util/virpidfile.c (virPidFileReadPathIfAlive): Skip kill
      call where unsupported, and report error on OOM.
      c811de8f
  9. 17 8月, 2011 2 次提交
  10. 16 8月, 2011 4 次提交
  11. 13 8月, 2011 5 次提交
    • E
      build: fix recent build failures · be427e8b
      Eric Blake 提交于
      With gcc 4.5.1:
      
      util/virpidfile.c: In function 'virPidFileAcquirePath':
      util/virpidfile.c:308:66: error: nested extern declaration of '_gl_verify_function2' [-Wnested-externs]
      
      Then in tests/commandtest.c, the new virPidFile APIs need to be used.
      
      * src/util/virpidfile.c (virPidFileAcquirePath): Move verify to
      top level.
      * tests/commandtest.c: Use new pid APIs.
      be427e8b
    • D
      Add some APIs which use locking for crashsafe pidfile handling · e1da464d
      Daniel P. Berrange 提交于
      In daemons using pidfiles to protect against concurrent
      execution there is a possibility that a crash may leave a stale
      pidfile on disk, which then prevents later restart of the daemon.
      
      To avoid this problem, introduce a pair of APIs which make
      use of virFileLock to ensure crash-safe & race condition-safe
      pidfile acquisition & releae
      
      * src/libvirt_private.syms, src/util/virpidfile.c,
        src/util/virpidfile.h: Add virPidFileAcquire and virPidFileRelease
      e1da464d
    • D
      Introduce functions for checking whether a pidfile is valid · b7e5ca48
      Daniel P. Berrange 提交于
      In some cases the caller of virPidFileRead might like extra checks
      to determine whether the pid just read is really the one they are
      expecting. This adds virPidFileReadIfAlive which will check whether
      the pid is still alive with kill(0, -1), and (on linux only) will
      look at /proc/$PID/path
      
      * libvirt_private.syms, util/virpidfile.c, util/virpidfile.h: Add
        virPidFileReadIfValid and virPidFileReadPathIfValid
      * network/bridge_driver.c: Use new APIs to check PID validity
      b7e5ca48
    • D
      Move pidfile functions into util/virpidfile.{c,h} · f80a4ed7
      Daniel P. Berrange 提交于
      The functions for manipulating pidfiles are in util/util.{c,h}.
      We will shortly be adding some further pidfile related functions.
      To avoid further growing util.c, this moves the pidfile related
      functions into a dedicated virpidfile.{c,h}. The functions are
      also all renamed to have 'virPidFile' as their name prefix
      
      * util/util.h, util/util.c: Remove all pidfile code
      * util/virpidfile.c, util/virpidfile.h: Add new APIs for pidfile
        handling.
      * lxc/lxc_controller.c, lxc/lxc_driver.c, network/bridge_driver.c,
        qemu/qemu_process.c: Add virpidfile.h include and adapt for API
        renames
      f80a4ed7
    • D
      Add virFileLock and virFileUnlock APIs · e4842705
      Daniel P. Berrange 提交于
      Add some simple wrappers around the fcntl() discretionary file
      locking capability.
      
      * src/util/util.c, src/util/util.h, src/libvirt_private.syms: Add
        virFileLock and virFileUnlock APIs
      e4842705
  12. 03 8月, 2011 3 次提交
    • E
      util: plug memory leak · c86827a2
      Eric Blake 提交于
      Leak detected by Coverity; only possible on unlikely ptsname_r
      failure.  Additionally, the man page for ptsname_r states that
      failure is merely non-zero, not necessarily -1.
      
      * src/util/util.c (virFileOpenTtyAt): Avoid leak on ptsname_r
      failure.
      c86827a2
    • E
      interface: drop dead code · d69b79ab
      Eric Blake 提交于
      Coverity detected that ifaceGetNthParent had already dereferenced
      'nth' prior to the conditional; all callers already complied with
      passing a non-NULL pointer so make this part of the contract.
      
      * src/util/interface.h (ifaceGetNthParent): Add annotations.
      * src/util/interface.c (ifaceGetNthParent): Drop useless null check.
      d69b79ab
    • E
      build: silence coverity false positives · 44ebb18e
      Eric Blake 提交于
      Coverity complained that 395 out of 409 virAsprintf calls are
      checked, and therefore assumed that the remaining cases are bugs
      waiting to happen.  But in each of these cases, a failed virAsprintf
      will properly set the target string to NULL, and pass on that
      failure to the caller, without wasting efforts to check the call.
      Adding the ignore_value silences Coverity.
      
      * src/conf/domain_audit.c (virDomainAuditGetRdev): Ignore
      virAsprintf return value, when it behaves like we need.
      * src/network/bridge_driver.c (networkDnsmasqLeaseFileNameDefault)
      (networkRadvdConfigFileName, networkBridgeDummyNicName)
      (networkRadvdPidfileBasename): Likewise.
      * src/util/storage_file.c (absolutePathFromBaseFile): Likewise.
      * src/openvz/openvz_driver.c (openvzGenerateContainerVethName):
      Likewise.
      * src/util/command.c (virCommandTranslateStatus): Likewise.
      44ebb18e
  13. 29 7月, 2011 1 次提交
  14. 27 7月, 2011 1 次提交
    • M
      bandwidth: Integrate bandwidth into portgroups · fe957f0a
      Michal Privoznik 提交于
      Every DomainNetDef has a bandwidth, as does every portgroup.
      Whenever a DomainNetDef of type NETWORK is about to be used, a call is
      made to networkAllocateActualDevice(). This function chooses the "best"
      bandwidth object and places it in the DomainActualNetDef.
      From that point on, whenever some code needs to use the bandwidth data
      for the interface, it's retrieved with virDomainNetGetActualBandwidth(),
      which will always return the "best" info as determined in the
      previous step.
      fe957f0a
  15. 26 7月, 2011 1 次提交
    • L
      util: change virFile*Pid functions to return < 0 on failure · d6354c16
      Laine Stump 提交于
      Although most functions in libvirt return 0 on success and < 0 on
      failure, there are a few functions lingering around that return errno
      (a positive value) on failure, and sometimes code calling those
      functions incorrectly assumes the <0 standard. I noticed one of these
      the other day when auditing networkStartDhcpDaemon after Guido Gunther
      found a place where success was improperly returned on failure (that
      patch has been acked and is pending a push). The problem was that it
      expected the return value from virFileReadPid to be < 0 on failure,
      but it was actually positive (it was also neglected to set the return
      code in this case, similar to the bug found by Guido).
      
      This all led to the fact that *all* of the virFile*Pid functions in
      util.c are returning errno on failure. This patch remedies that
      problem by changing them all to return -errno on failure, and makes
      any necessary changes to callers of the functions. (In the meantime, I
      also properly set the return code on failure of virFileReadPid in
      networkStartDhcpDaemon).
      d6354c16
  16. 25 7月, 2011 5 次提交
  17. 22 7月, 2011 8 次提交
    • M
      build: Use $(PYTHON) instead of python for the keycode map generator · 1a80a4e0
      Matthias Bolte 提交于
      Also prepend $(AM_V_GEN) to the command line, mark virkeycode-mapgen.py
      as executable and switch the shebang line from /bin/python to the
      commonly use /usr/bin/python.
      1a80a4e0
    • L
      util: make interface.c functions consistently return < 0 on error · f7e18208
      Laine Stump 提交于
      All of the functions in util/interface.c were returning 0 on success,
      but some returned -1 on error, and some returned a positive value
      (usually the value of errno, but sometimes just 1). Libvirt's standard
      is to return < 0 on error (in the case of functions that need to
      return errno, -errno is returned.
      
      This patch modifies all functions in interface.c to consistently
      return < 0 on error, and makes changes to callers of those functions
      where necessary.
      f7e18208
    • E
      save: add virFileDirectFd wrapper type · 519a1c43
      Eric Blake 提交于
      O_DIRECT has stringent requirements.  Rather than make lots of changes
      at each site that wants to use O_DIRECT, it is easier to offload
      the work through a helper process that mirrors the I/O between a
      pipe and the actual direct fd, so that the other end of the pipe
      no longer has to worry about constraints.
      
      Plus, if the kernel ever gains better posix_fadvise support, then we
      only have to touch a single file to let all callers benefit from a
      more efficient way to avoid file system caching.
      
      * src/util/virfile.h (virFileDirectFdFlag, virFileDirectFdNew)
      (virFileDirectFdClose, virFileDirectFdFree): New prototypes.
      * src/util/virdirect.c: Implement new wrapper object.
      * src/libvirt_private.syms (virfile.h): Export new symbols.
      * cfg.mk (useless_free_options): Add to list.
      * po/POTFILES.in: Add new translations.
      519a1c43
    • E
      save: let iohelper work on O_DIRECT fds · 12291656
      Eric Blake 提交于
      Required for a coming patch where iohelper will operate on O_DIRECT
      fds.  There, the user-space memory must be aligned to file system
      boundaries (at least 512, but using page-aligned works better, and
      some file systems prefer 64k).  Made tougher by the fact that
      VIR_ALLOC won't work on void *, but posix_memalign won't work on
      char * and isn't available everywhere.
      
      This patch makes some simplifying assumptions - namely, output
      to an O_DIRECT fd will only be attempted on an empty seekable
      file (hence, no need to worry about preserving existing data
      on a partial block, and ftruncate will work to undo the effects
      of having to round up the size of the last block written), and
      input from an O_DIRECT fd will only be attempted on a complete
      seekable file with the only possible short read at EOF.
      
      * configure.ac (AC_CHECK_FUNCS_ONCE): Check for posix_memalign.
      * src/util/iohelper.c (runIO): Use aligned memory, and handle
      quirks of O_DIRECT on last write.
      12291656
    • E
      save: let iohelper handle inherited fd · 1eb66479
      Eric Blake 提交于
      Rather than making the iohelper subject to a race in reopening
      the file, it is nicer to pass an already-open fd by inheritance.
      
      The old synopsis form must continue to work - if someone updates
      their libvirt package and installs a new libvirt_iohelper but
      without restarting the old libvirtd daemon, then the daemon can
      still make calls using the old syntax but the new iohelper.
      
      * src/util/iohelper.c (runIO): Split code for open...
      (prepare): ...to new function.
      (usage): Update synopsis.
      (main): Allow alternate calling form.
      * src/fdstream.c (virFDStreamOpenFileInternal): Use alternate form.
      1eb66479
    • E
      error: add new error type for reflecting partial API support · 17003457
      Eric Blake 提交于
      VIR_ERR_INVALID_ARG implies that an argument cannot possibly
      be correct, given the current state of the API.
      VIR_ERR_CONFIG_UNSUPPORTED implies that a configuration is
      wrong, but arguments aren't configuration.
      VIR_ERR_NO_SUPPORT implies that a function is completely
      unimplemented.
      
      But in the case of a function that is partially implemented,
      yet the full power of the API is not available for that
      driver, none of the above messages make sense.  Hence a new
      error message, implying that the argument is known to comply
      with the current state of the API, and that while the driver
      supports aspects of the function, it does not support that
      particular use of the argument.
      
      A good use case for this is a driver that supports
      virDomainSaveFlags, but not the dxml argument of that API.
      
      It might be feasible to also use this new error for all functions
      that check flags, and which accept fewer flags than what is possible
      in the public API.  But doing so would get complicated, since
      neither libvirt.c nor the remote driver may do flag filtering,
      and every other driver would have to do a two-part check, first
      using virCheckFlags on all public flags (which gives
      VIR_ERR_INVALID_ARG for an impossible flag), followed by a
      particular mask check for VIR_ERR_ARGUMENT_UNSUPPORTED (for a
      possible public flag but unsupported by this driver).
      
      * include/libvirt/virterror.h (VIR_ERR_ARGUMENT_UNSUPPORTED): New
      error.
      * src/util/virterror.c (virErrorMsg): Give it a message.
      Suggested by Daniel P. Berrange.
      17003457
    • L
      conf: virDomainNetDef points to (rather than contains) virtPortProfile · 524655ee
      Laine Stump 提交于
      The virtPortProfile in the domain interface struct is now a separately
      allocated object *pointed to by* (rather than contained in) the main
      virDomainNetDef object. This is done to make it easier to figure out
      when a virtualPortProfile has/hasn't been specified in a particular
      config.
      524655ee
    • L
      conf: put virtPortProfile struct / functions in a common location · a3d95b55
      Laine Stump 提交于
      virtPortProfiles are currently only used in the domain XML, but will
      soon also be used in the network XML. To prepare for that change, this
      patch moves the structure definition into util/network.h and the parse
      and format functions into util/network.c (I decided that this was a
      better choice than macvtap.h/c for something that needed to always be
      available on all platforms).
      a3d95b55