1. 01 12月, 2012 2 次提交
  2. 30 11月, 2012 4 次提交
    • L
      util: new virSocketAddrIsPrivate function · bf402e77
      Laine Stump 提交于
      This new function returns true if the given address is in the range of
      any "private" or "local" networks as defined in RFC1918 (IPv4) or
      RFC3484/RFC4193 (IPv6), otherwise they return false.
      
      These ranges are:
      
         192.168.0.0/16
         172.16.0.0/16
         10.0.0.0/24
         FC00::/7
         FEC0::/10
      bf402e77
    • L
      util: capabilities detection for dnsmasq · 719c2c76
      Laine Stump 提交于
      In order to optionally take advantage of new features in dnsmasq when
      the host's version of dnsmasq supports them, but still be able to run
      on hosts that don't support the new features, we need to be able to
      detect the version of dnsmasq running on the host, and possibly
      determine from the help output what options are in this dnsmasq.
      
      This patch implements a greatly simplified version of the capabilities
      code we already have for qemu. A dnsmasqCaps device can be created and
      populated either from running a program on disk, reading a file with
      the concatenated output of "dnsmasq --version; dnsmasq --help", or
      examining a buffer in memory that contains the concatenated output of
      those two commands. Simple functions to retrieve capabilities flags,
      the version number, and the path of the binary are also included.
      
      bridge_driver.c creates a single dnsmasqCaps object at driver startup,
      and disposes of it at driver shutdown. Any time it must be used, the
      dnsmasqCapsRefresh method is called - it checks the mtime of the
      binary, and re-runs the checks if the binary has changed.
      
      networkxml2argvtest.c creates 2 "artificial" dnsmasqCaps objects at
      startup - one "restricted" (doesn't support --bind-dynamic) and one
      "full" (does support --bind-dynamic). Some of the test cases use one
      and some the other, to make sure both code pathes are tested.
      719c2c76
    • J
      util: fix virBitmap allocation in virProcessInfoGetAffinity · 7730257d
      Ján Tomko 提交于
      Found by coverity:
      Error: REVERSE_INULL (CWE-476):
          libvirt-0.10.2/src/util/processinfo.c:141: deref_ptr: Directly
          dereferencing pointer "map".
          libvirt-0.10.2/src/util/processinfo.c:142: check_after_deref:
          Null-checking "map" suggests that it may be null, but it has already
          been dereferenced on all paths leading to the check.
      7730257d
    • D
      Turn some dual-state int parameters into booleans · f4ea67f5
      Daniel P. Berrange 提交于
      The virStateInitialize method and several cgroups methods were
      using an 'int privileged' parameter or similar for dual-state
      values. These are better represented with the bool type.
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      f4ea67f5
  3. 29 11月, 2012 2 次提交
  4. 28 11月, 2012 6 次提交
  5. 26 11月, 2012 1 次提交
  6. 25 11月, 2012 1 次提交
  7. 23 11月, 2012 3 次提交
  8. 22 11月, 2012 2 次提交
  9. 15 11月, 2012 4 次提交
    • M
      Use helper functions to format the journal iov array · 39c814ff
      Miloslav Trmač 提交于
      This simplifies the top-level code, at the cost of using a little more
      stack space.  The primary benefit is being able to send more fields
      without knowing in advance how many of them, and of which types, these
      fields will be, and without having to individually add buffer variables.
      
      The code imposes an upper limit on the total number of iovs/buffers
      used, and fields that wouldn't fit are silently dropped.  This is not
      significant in this patch, but will affect the following one.
      Signed-off-by: NMiloslav Trmač <mitr@redhat.com>
      39c814ff
    • M
      Add metadata to virLogOutputFunc · 37f7a1fa
      Miloslav Trmač 提交于
      ... and update all users.  No change in functionality, the parameter
      will be used in the next patch.
      Signed-off-by: NMiloslav Trmač <mitr@redhat.com>
      37f7a1fa
    • M
      Add a metadata parameter to virLog{, V}Message · c780e9b8
      Miloslav Trmač 提交于
      ... and update all users.  No change in functionality, the parameter
      will be used later.
      
      The metadata representation is as minimal as possible, but requires
      the caller to allocate an array on stack explicitly.
      
      The alternative of using varargs in the virLogMessage() callers:
      * Would not allow the caller to optionally omit some metadata elements,
        except by having two calls to virLogMessage.
      * Would not be as type-safe (e.g. using int vs. size_t), and the compiler
        wouldn't be able to do type checking
      * Depending on parameter order:
        a) virLogMessage(..., message format, message params...,
                         metadata..., NULL)
           can not be portably implemented (parse_printf_format() is a glibc
           function)
        b) virLogMessage(..., metadata..., NULL,
                         message format, message params...)
           would prevent usage of ATTRIBUTE_FMT_PRINTF and the associated
           compiler checking.
      Signed-off-by: NMiloslav Trmač <mitr@redhat.com>
      c780e9b8
    • L
      util: fix index when building lock owners array · bc4b4330
      Laine Stump 提交于
      The "restart" function for locks allocates a new array according to
      and pre-sets its length, then reads the owner pids from a JSON
      document in a loop. Rather than adding each owner at a different
      index, though, it repeatedly overwrites the last element of the array
      with all the owners.
      bc4b4330
  10. 09 11月, 2012 1 次提交
    • P
      storage: fix broken backing chain · e0c469e5
      Philipp Hahn 提交于
      82507838 refactored the code to keep both the raw and canonicalized form
      of the backingStore, which breaks badly when the storage pool contains a
      storage volume, which is missing its backing store file:
       # ./daemon/libvirtd -l
       2012-11-07 12:43:33.279+0000: 22175: info : libvirt version: 1.0.0
       2012-11-07 12:43:33.279+0000: 22175: error : absolutePathFromBaseFile:542 : Can't canonicalize path '/var/lib/libvirt/images/base.qcow2': No such file or directory
       2012-11-07 12:43:33.280+0000: 22175: error : storageDriverAutostart:115 : Failed to autostart storage pool 'default': Can't canonicalize path '/var/lib/libvirt/images/base.qcow2': No such file or directory
      
      This is because virStorageFileGetMetadataFromBuf() aborts with -1 if the
      filename of the backingStore can not be canonicalized:
       #0  absolutePathFromBaseFile () at util/storage_file.c:541
       #1  virStorageFileGetMetadataFromBuf () at util/storage_file.c:728
       #2  virStorageFileGetMetadataFromFD () at util/storage_file.c:932
       #3  virStorageBackendProbeTarget () at storage/storage_backend_fs.c:94
       #4  virStorageBackendFileSystemRefresh () at storage/storage_backend_fs.c:849
       #5  storagePoolStart () at storage/storage_driver.c:700
       #6  virStoragePoolCreate () at libvirt.c:12471
       ...
      
      Treat files which miss their backing file as standalone files.
      Signed-off-by: NPhilipp Hahn <hahn@univention.de>
      e0c469e5
  11. 05 11月, 2012 1 次提交
  12. 02 11月, 2012 4 次提交
  13. 01 11月, 2012 2 次提交
    • M
      iohelper: fdatasync() at the end · f32e3a2d
      Michal Privoznik 提交于
      Currently, when we are doing (managed) save, we insert the
      iohelper between the qemu and OS. The pipe is created, the
      writing end is passed to qemu and the reading end to the
      iohelper. It reads data and write them into given file. However,
      with write() being asynchronous data may still be in OS
      caches and hence in some (corner) cases, all migration data
      may have been read and written (not physically though). So
      qemu will report success, as well as iohelper. However, with
      some non local filesystems, where ENOSPACE is polled every X
      time units, we may get into situation where all operations
      succeeded but data hasn't reached the disk. And in fact will
      never do. Therefore we ought sync caches to make sure data
      has reached the block device on remote host.
      f32e3a2d
    • D
      Don't assume pid_t is the same size as an int · 6bf55a97
      Daniel P. Berrange 提交于
      virPidFileReadPathIfAlive passed in an 'int *' where a 'pid_t *'
      was expected, which breaks on Mingw64 targets. Also a few places
      were using '%d' for formatting pid_t, change them to '%lld' and
      force a cast to the longer type as done elsewhere in the same
      file.
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      6bf55a97
  14. 31 10月, 2012 2 次提交
    • P
      util: Improve error reporting from absolutePathFromBaseFile helper · ca043b8c
      Peter Krempa 提交于
      There are multiple reasons canonicalize_file_name() used in
      absolutePathFromBaseFile helper can fail. This patch enhances error
      reporting from that helper.
      ca043b8c
    • L
      util: do a better job of matching up pids with their binaries · 7bafe009
      Laine Stump 提交于
      This patch resolves: https://bugzilla.redhat.com/show_bug.cgi?id=871201
      
      If libvirt is restarted after updating the dnsmasq or radvd packages,
      a subsequent "virsh net-destroy" will fail to kill the dnsmasq/radvd
      process.
      
      The problem is that when libvirtd restarts, it re-reads the dnsmasq
      and radvd pidfiles, then does a sanity check on each pid it finds,
      including checking that the symbolic link in /proc/$pid/exe actually
      points to the same file as the path used by libvirt to execute the
      binary in the first place. If this fails, libvirt assumes that the
      process is no longer alive.
      
      But if the original binary has been replaced, the link in /proc is set
      to "$binarypath (deleted)" (it literally has the string " (deleted)"
      appended to the link text stored in the filesystem), so even if a new
      binary exists in the same location, attempts to resolve the link will
      fail.
      
      In the end, not only is the old dnsmasq/radvd not terminated when the
      network is stopped, but a new dnsmasq can't be started when the
      network is later restarted (because the original process is still
      listening on the ports that the new process wants).
      
      The solution is, when the initial "use stat to check for identical
      inodes" check for identity between /proc/$pid/exe and $binpath fails,
      to check /proc/$pid/exe for a link ending with " (deleted)" and if so,
      truncate that part of the link and compare what's left with the
      original binarypath.
      
      A twist to this problem is that on systems with "merged" /sbin and
      /usr/sbin (i.e. /sbin is really just a symlink to /usr/sbin; Fedora
      17+ is an example of this), libvirt may have started the process using
      one path, but /proc/$pid/exe lists a different path (indeed, on F17
      this is the case - libvirtd uses /sbin/dnsmasq, but /proc/$pid/exe
      shows "/usr/sbin/dnsmasq"). The further bit of code to resolve this is
      to call virFileResolveAllLinks() on both the original binarypath and
      on the truncated link we read from /proc/$pid/exe, and compare the
      results.
      
      The resulting code still succeeds in all the same cases it did before,
      but also succeeds if the binary was deleted or replaced after it was
      started.
      7bafe009
  15. 30 10月, 2012 1 次提交
    • M
      qemu: Report errors from iohelper · 34e8f63a
      Michal Privoznik 提交于
      Currently, we use iohelper when saving/restoring a domain.
      However, if there's some kind of error (like I/O) it is not
      propagated to libvirt. Since it is not qemu who is doing
      the actual write() it will not get error. The iohelper does.
      Therefore we should check for iohelper errors as it makes
      libvirt more user friendly.
      34e8f63a
  16. 29 10月, 2012 2 次提交
    • P
      util: Re-format literal strings in virXMLEmitWarning · cbd10126
      Peter Krempa 提交于
      And drop a stray space at the end of the first line of the warning.
      cbd10126
    • J
      xml: print uuids in the warning · 0b121614
      Ján Tomko 提交于
      In the XML warning, we print a virsh command line that can be used to
      edit that XML. This patch prints UUIDs if the entity name contains
      special characters (like shell metacharacters, or "--" that would break
      parsing of the XML comment). If the entity doesn't have a UUID, just
      print the virsh command that can be used to edit it.
      0b121614
  17. 26 10月, 2012 2 次提交
    • C
      daemon: Fix LIBVIRT_DEBUG=1 default output · eba36a38
      Cole Robinson 提交于
      This commit changes the behavior of LIBVIRT_DEBUG=1 libvirtd:
      
      $ git show 7022b091
      commit 7022b091
      Author: Daniel P. Berrange <berrange@redhat.com>
      Date:   Thu Sep 27 13:13:09 2012 +0100
      
          Automatically enable systemd journal logging
      
          Probe to see if the systemd journal is accessible, and if
          so enable logging to the journal by default, rather than
          stderr (current default under systemd).
      
      Previously  'LIBVIRT_DEBUG=1 /usr/sbin/libvirtd' would show all debug
      output to stderr, now it send debug output to the journal.
      
      Only use the journal by default if running in daemon mode, or
      if stdin is _not_ a tty. This should make libvirtd launched from
      systemd use the journal, but preserve the old behavior in most
      situations.
      eba36a38
    • E
      bitmap: add virBitmapCountBits · 0711c4b7
      Eric Blake 提交于
      Sometimes it's handy to know how many bits are set.
      
      * src/util/bitmap.h (virBitmapCountBits): New prototype.
      (virBitmapNextSetBit): Use correct type.
      * src/util/bitmap.c (virBitmapNextSetBit): Likewise.
      (virBitmapSetAll): Maintain invariant of clear tail bits.
      (virBitmapCountBits): New function.
      * src/libvirt_private.syms (bitmap.h): Export it.
      * tests/virbitmaptest.c (test2): Test it.
      0711c4b7