1. 26 1月, 2012 7 次提交
    • D
      Rename hash.h and hash.c to virhash.h and virhash.c · 1d5c7a9f
      Daniel P. Berrange 提交于
      In preparation for the patch to include Murmurhash3, which
      introduces a virhashcode.h and virhashcode.c files, rename
      the existing hash.h and hash.c to virhash.h and virhash.c
      respectively.
      1d5c7a9f
    • D
      Convert various virHash functions to use size_t / uint32 · 9f2bf8fd
      Daniel P. Berrange 提交于
      In preparation for conversion over to use the Murmurhash3
      algorithm, convert various virHash APIs to use size_t or
      uint32 for their return values/parameters, instead of the
      variable size 'unsigned long' or 'int' types
      9f2bf8fd
    • D
      Introduce new API for generating random numbers · e95ef67b
      Daniel P. Berrange 提交于
      The old virRandom() API was not generating good random numbers.
      Replace it with a new API virRandomBits which instead of being
      told the upper limit, gets told the number of bits of randomness
      required.
      
      * src/util/virrandom.c, src/util/virrandom.h: Add virRandomBits,
        and move virRandomInitialize
      * src/util/util.h, src/util/util.c: Delete virRandom and
        virRandomInitialize
      * src/libvirt.c, src/security/security_selinux.c,
        src/test/test_driver.c, src/util/iohelper.c: Update for
        changes from virRandom to virRandomBits
      * src/storage/storage_backend_iscsi.c: Remove bogus call
        to virRandomInitialize & convert to virRandomBits
      e95ef67b
    • M
      Cast pointer to int using intptr_t · d553554b
      Marc-André Lureau 提交于
      Fix a few warnings with mingw64 x86_64.
      d553554b
    • E
      build: fix header order on mingw · 3d5c139c
      Eric Blake 提交于
      In file included from ../gnulib/lib/unistd.h:51:0,
                       from ../src/util/util.h:30,
                       from rpc/virkeepalive.c:29:
      /usr/x86_64-w64-mingw32/sys-root/mingw/include/winsock2.h:15:2: warning: #warning Please include winsock2.h before windows.h [-Wcpp]
      
      Reported by Marc-André Lureau.
      
      * src/util/threads-win32.h (includes): Pick up winsock2.h before
      windows.h, as required by mingw64.
      3d5c139c
    • M
      errcode is typedef by mingw, rename an argument name · 75d3612e
      Marc-André Lureau 提交于
      Fixes the following warning:
      util/virterror.c:1242:31: warning: declaration of 'errcode' shadows a global declaration [-Wshadow]
      75d3612e
    • M
      Add missing virGetGroupName() · 5f1767e8
      Marc-André Lureau 提交于
      Add missing function if !HAVE_GETPWUID_R.
      5f1767e8
  2. 25 1月, 2012 2 次提交
    • D
      Add virFileTouch for creating empty files · ef7efbc6
      Daniel P. Berrange 提交于
      Add a virFileTouch API which ensures that a file will always
      exist, even if zero length
      
      * src/util/virfile.c, src/util/virfile.h,
        src/libvirt_private.syms: Introduce virFileTouch
      ef7efbc6
    • L
      virCommandProcessIO(): make poll() usage more robust · d19149dd
      Laszlo Ersek 提交于
      POLLIN and POLLHUP are not mutually exclusive. Currently the following
      seems possible: the child writes 3K to its stdout or stderr pipe, and
      immediately closes it. We get POLLIN|POLLHUP (I'm not sure that's possible
      on Linux, but SUSv4 seems to allow it). We read 1K and throw away the
      rest.
      
      When poll() returns and we're about to check the /revents/ member in a
      given array element, let's map all the revents bits to two (independent)
      ideas: "let's attempt to read()", and "let's attempt to write()". This
      should cover all errors, EOFs, and normal conditions; the read()/write()
      call should report any pending error.
      
      Under this approach, both POLLHUP and POLLERR are mapped to "needs read()"
      if we're otherwise prepared for POLLIN. POLLERR also maps to "needs
      write()" if we're otherwise prepared for POLLOUT. The rest of the mappings
      (POLLPRI etc.) would be easy, but probably useless for pipes.
      
      Additionally, SUSv4 doesn't appear to forbid POLLIN|POLLERR (or
      POLLOUT|POLLERR) set simultaneously. One could argue that the read() or
      write() call would return without blocking in these cases (with an error),
      so POLLIN / POLLOUT would be justified beside POLLERR.
      
      The code now penalizes POLLIN|POLLERR differently from plain POLLERR. The
      former (ie. read() returning -1) is terminal and we jump to cleanup, while
      plain POLLERR masks only the affected file descriptor for the future.
      Let's unify those.
      Signed-off-by: NLaszlo Ersek <lersek@redhat.com>
      d19149dd
  3. 24 1月, 2012 1 次提交
  4. 21 1月, 2012 1 次提交
    • E
      maint: enforce use of _LAST marker · bb69630b
      Eric Blake 提交于
      When converting a linear enum to a string, we have checks in
      place in the VIR_ENUM_IMPL macro to ensure that there is one
      string for every value, which lets us quickly flag if a user
      added a value but forgot to add a counterpart string.  However,
      this only works if we use the _LAST marker.
      
      * cfg.mk (sc_require_enum_last_marker): New syntax check.
      * src/conf/domain_conf.h (virDomainSnapshotState): Add new marker.
      * src/conf/domain_conf.c (virDomainSnapshotState): Fix offender.
      * src/qemu/qemu_monitor_json.c (qemuMonitorWatchdogAction)
      (qemuMonitorIOErrorAction, qemuMonitorGraphicsAddressFamily):
      Likewise.
      * src/util/virtypedparam.c (virTypedParameter): Likewise.
      bb69630b
  5. 20 1月, 2012 3 次提交
    • E
      error: drop old-style error reporting · c2551bea
      Eric Blake 提交于
      While we still don't want to enable gcc's new -Wformat-literal
      warning, I found a rather easy case where the warning could be
      reduced, by getting rid of obsolete error-reporting practices.
      This is the last place where we were passing the (unused) net
      and conn arguments for constructing an error.
      
      * src/util/virterror_internal.h (virErrorMsg): Delete prototype.
      (virReportError): Delete macro.
      * src/util/virterror.c (virErrorMsg): Make static.
      * src/libvirt_private.syms (virterror_internal.h): Drop export.
      * src/util/conf.c (virConfError): Convert to macro.
      (virConfErrorHelper): New function, and adjust error calls.
      * src/xen/xen_hypervisor.c (virXenErrorFunc): Delete.
      (xenHypervisorGetSchedulerType)
      (xenHypervisorGetSchedulerParameters)
      (xenHypervisorSetSchedulerParameters)
      (xenHypervisorDomainBlockStats)
      (xenHypervisorDomainInterfaceStats)
      (xenHypervisorDomainGetOSType)
      (xenHypervisorNodeGetCellsFreeMemory, xenHypervisorGetVcpus):
      Update callers.
      c2551bea
    • E
      util: add new file for virTypedParameter utils · 61ca98b0
      Eric Blake 提交于
      Preparation for another patch that refactors common patterns
      into the new file for fewer lines of code overall.
      
      * src/util/util.h (virTypedParameterArrayClear): Move...
      * src/util/virtypedparam.h: ...to new file.
      (virTypedParameterArrayValidate, virTypedParameterAssign): New
      prototypes.
      * src/util/util.c (virTypedParameterArrayClear): Likewise.
      * src/util/virtypedparam.c: New file.
      * po/POTFILES.in: Mark file for translation.
      * src/Makefile.am (UTIL_SOURCES): Build it.
      * src/libvirt_private.syms (util.h): Split...
      (virtypedparam.h): to new section.
      (virkeycode.h): Sort.
      * daemon/remote.c: Adjust callers.
      * tools/virsh.c: Likewise.
      61ca98b0
    • E
      threads: check for failure to set thread-local value · 927cfaf4
      Eric Blake 提交于
      We had a memory leak on a very arcane OOM situation (unlikely to ever
      hit in practice, but who knows if libvirt.so would ever be linked
      into some other program that exhausts all thread-local storage keys?).
      I found it by code inspection, while analyzing a valgrind report
      generated by Alex Jia.
      
      * src/util/threads.h (virThreadLocalSet): Alter signature.
      * src/util/threads-pthread.c (virThreadHelper): Reduce allocation
      lifetime.
      (virThreadLocalSet): Detect failure.
      * src/util/threads-win32.c (virThreadLocalSet): Likewise.
      (virCondWait): Fix caller.
      * src/util/virterror.c (virLastErrorObject): Likewise.
      927cfaf4
  6. 19 1月, 2012 1 次提交
  7. 18 1月, 2012 2 次提交
    • D
      Fix startup of LXC containers with filesystems containing symlinks · c53ba61b
      Daniel P. Berrange 提交于
      Given an LXC guest with a root filesystem path of
      
        /export/lxc/roots/helloworld/root
      
      During startup, we will pivot the root filesystem to end up
      at
      
        /.oldroot/export/lxc/roots/helloworld/root
      
      We then try to open
      
        /.oldroot/export/lxc/roots/helloworld/root/dev/pts
      
      Now consider if '/export/lxc' is an absolute symlink pointing
      to '/media/lxc'. The kernel will try to open
      
        /media/lxc/roots/helloworld/root/dev/pts
      
      whereas it should be trying to open
      
        /.oldroot//media/lxc/roots/helloworld/root/dev/pts
      
      To deal with the fact that the root filesystem can be moved,
      we need to resolve symlinks in *any* part of the filesystem
      source path.
      
      * src/libvirt_private.syms, src/util/util.c,
        src/util/util.h: Add virFileResolveAllLinks to resolve
        all symlinks in a path
      * src/lxc/lxc_container.c: Resolve all symlinks in filesystem
        paths during startup
      c53ba61b
    • O
      qemu: Introduce inactive PCI device list · 6be610bf
      Osier Yang 提交于
      pciTrySecondaryBusReset checks if there is active device on the
      same bus, however, qemu driver doesn't maintain an effective
      list for the inactive devices, and it passes meaningless argument
      for parameter "inactiveDevs". e.g. (qemuPrepareHostdevPCIDevices)
      
      if (!(pcidevs = qemuGetPciHostDeviceList(hostdevs, nhostdevs)))
          return -1;
      
      ..skipped...
      
      if (pciResetDevice(dev, driver->activePciHostdevs, pcidevs) < 0)
          goto reattachdevs;
      
      NB, the "pcidevs" used above are extracted from domain def, and
      thus one won't be able to attach a device of which bus has other
      device even detached from host (nodedev-detach). To see more
      details of the problem:
      
      RHBZ: https://bugzilla.redhat.com/show_bug.cgi?id=773667
      
      This patch is to resolve the problem by introducing an inactive
      PCI device list (just like qemu_driver->activePciHostdevs), and
      the whole logic is:
      
        * Add the device to inactive list during nodedev-dettach
        * Remove the device from inactive list during nodedev-reattach
        * Remove the device from inactive list during attach-device
          (for non-managed device)
        * Add the device to inactive list after detach-device, only
          if the device is not managed
      
      With the above, we have a sufficient inactive PCI device list, and thus
      we can use it for pciResetDevice. e.g.(qemuPrepareHostdevPCIDevices)
      
      if (pciResetDevice(dev, driver->activePciHostdevs,
                         driver->inactivePciHostdevs) < 0)
          goto reattachdevs;
      6be610bf
  8. 13 1月, 2012 2 次提交
    • E
      uuid: fix off-by-one · 0327ff07
      Eric Blake 提交于
      Detected by Coverity.  Although unlikely, if we are ever started
      with stdin closed, we could reach a situation where we open a
      uuid file but then fail to close it, making that file the new
      stdin for the rest of the process.
      
      * src/util/uuid.c (getDMISystemUUID): Allow for stdin.
      0327ff07
    • D
      Rsync keymaps.csv file with GTK-VNC · 08272dc8
      Daniel P. Berrange 提交于
      08272dc8
  9. 12 1月, 2012 2 次提交
  10. 07 1月, 2012 1 次提交
    • E
      build: fix mingw virCommand build · 03ea5673
      Eric Blake 提交于
      Commit db371a21 mistakenly added new functions inside a #ifndef WIN32
      guard, even though they are needed on all platforms.
      
      * src/util/command.c (virCommandFDSet): Move outside WIN32
      conditional.
      03ea5673
  11. 05 1月, 2012 1 次提交
  12. 04 1月, 2012 2 次提交
  13. 25 12月, 2011 1 次提交
  14. 21 12月, 2011 1 次提交
  15. 16 12月, 2011 1 次提交
    • P
      migration: Add more specific error code/message on migration abort · 8fb2aeb6
      Peter Krempa 提交于
      A generic error code was returned, if the user aborted a migration job.
      This made it hard to distinguish between a user requested abort and an
      error that might have occured. This patch introduces a new error code,
      which is returned in the specific case of a user abort, while leaving
      all other failures with their existing code. This makes it easier to
      distinguish between failure while mirgrating and an user requested
      abort.
      
       * include/libvirt/virterror.h: - add new error code
       * src/util/virterror.c: - add message for the new error code
       * src/qemu/qemu_migration.h: - Emit operation aborted error instead of
                                      operation failed, on migration abort
      8fb2aeb6
  16. 10 12月, 2011 2 次提交
  17. 09 12月, 2011 2 次提交
  18. 08 12月, 2011 1 次提交
    • E
      build: fix build with older libxml2 · f59a9417
      Eric Blake 提交于
      On RHEL 5, with libxml2-2.6.26, the build failed with:
      virsh.c: In function 'vshNodeIsSuperset':
      virsh.c:11951: warning: implicit declaration of function 'xmlChildElementCount'
      
      (or if warnings aren't errors, a link failure later on).
      
      * src/util/xml.h (virXMLChildElementCount): New prototype.
      * src/util/xml.c (virXMLChildElementCount): New function.
      * src/libvirt_private.syms (xml.h): Export it.
      * tools/virsh.c (vshNodeIsSuperset): Use it.
      f59a9417
  19. 04 12月, 2011 3 次提交
    • 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
      command: handle empty buffer argument correctly · 2b045d39
      Eric Blake 提交于
      virBufferContentAndReset (intentionally) returns NULL for a buffer
      with no content, but it is feasible to invoke a command with an
      explicit empty string.
      
      * src/util/command.c (virCommandAddEnvBuffer): Reject empty string.
      (virCommandAddArgBuffer): Allow explicit empty argument.
      * tests/commandtest.c (test9): Test it.
      * tests/commanddata/test9.log: Adjust.
      2b045d39
    • 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
  20. 02 12月, 2011 2 次提交
    • E
      maint: typo fixes · a6997934
      Eric Blake 提交于
      Many of these were mentioned by Yuri Chornoivan in:
      https://bugzilla.redhat.com/show_bug.cgi?id=669506
      
      * src/esx/esx_vi.c (esxVI_WaitForTaskCompletion): Fix spelling.
      * src/conf/netdev_vport_profile_conf.c
      (virNetDevVPortProfileParse): Likewise.
      * src/xen/xend_internal.c (xenDaemonDomainSetVcpusFlags):
      Likewise.
      * src/xen/xm_internal.c (xenXMDomainSetVcpusFlags): Likewise.
      * src/esx/esx_util.c (esxUtil_ResolveHostname): Likewise.
      * src/storage/storage_backend_fs.c
      (virStorageBackendFileSystemBuild): Likewise.
      * daemon/libvirtd.conf: Likewise.
      * src/util/logging.c (virLogMessage): Likewise.
      * src/uml/uml_conf.c (umlBuildCommandLineNet): Likewise.
      * src/vmx/vmx.c (virVMXFormatEthernet): Likewise.
      a6997934
    • D
      Fix build for platforms lacking struct ifreq · 949e1091
      Daniel P. Berrange 提交于
      This ought to fix the build if you have net/if.h but do
      not have struct ifreq
      
      * configure.ac: Check for struct ifreq in net/if.h
      * src/util/virnetdev.c: Conditionalize to avoid use of
        struct ifreq if it does not exist
      949e1091
  21. 01 12月, 2011 2 次提交