1. 23 3月, 2017 3 次提交
    • L
      util: new function virNetDevGetMaster() · e75f5bfb
      Laine Stump 提交于
      This function provides the bridge/bond device that the given network
      device is attached to. The return value is 0 or -1, and the master
      device is a char** argument to the function - this is needed in order
      to allow for a "success" return from a device that has no master.
      e75f5bfb
    • L
      util: allow retrieving ethtool features when unprivileged · 549fe5a8
      Laine Stump 提交于
      The only reason that the ethtool features weren't being retrieved in
      an unprivileged libvirtd was because they required ioctl(), and the
      ioctl was using an AF_PACKET socket, which requires root. Now that we
      are using AF_UNIX for ioctl(), this restriction can be removed.
      549fe5a8
    • L
      util: use AF_UNIX family (not AF_PACKET) for ioctl sockets · 1c9a8746
      Laine Stump 提交于
      The exact family of the socket created for the fd used by ioctl(7)
      doesn't matter, it just needs to be a socket and not a file. But for
      some reason when macvtap support was added, it used
      AF_PACKET/SOCK_DGRAM sockets for its ioctls; we later used the same
      AF_PACKET/SOCK_DGRAM socket for new ioctls we added, and eventually
      modified the other pre-existing ioctl sockets (for creating/deleting
      bridges) to also use AF_PACKET/SOCK_DGRAM (that code originally used
      AF_UNIX/SOCK_STREAM).
      
      The problem with using AF_PACKET (intended for sending/receiving "raw"
      packets, i.e. packets that can be some protocol other than TCP or UDP)
      is that it requires root privileges. This meant that none of the
      ioctls in virnetdev.c or virnetdevip.c would work when running
      libvirtd unprivileged.
      
      This packet solves that problem by changing the family to AF_UNIX when
      creating the socket used for any ioctl().
      1c9a8746
  2. 22 3月, 2017 4 次提交
  3. 16 3月, 2017 2 次提交
    • M
      virTimeBackOffWait: Avoid long periods of sleep · 67dcb797
      Michal Privoznik 提交于
      While connecting to qemu monitor, the first thing we do is wait
      for it to show up. However, we are doing it with some timeout to
      avoid indefinite waits (e.g. when qemu doesn't create the monitor
      socket at all). After beaa447a we are using exponential back
      off timeout meaning, after the first connection attempt we wait
      1ms, then 2ms, then 4 and so on.  This allows us to bring down
      wait time for small domains where qemu initializes quickly.
      However, on the other end of this scale are some domains with
      huge amounts of guest memory. Now imagine that we've gotten up to
      wait time of 15 seconds. The next one is going to be 30 seconds,
      and the one after that whole minute. Well, okay - with current
      code we are not going to wait longer than 30 seconds in total,
      but this is going to change in the next commit.
      
      The exponential back off is usable only for first few iterations.
      Then it needs to be caped (one second was chosen as the limit)
      and switch to constant wait time.
      Signed-off-by: NMichal Privoznik <mprivozn@redhat.com>
      67dcb797
    • J
      util: Rename virFileWaitForDevices · 97e0d3c3
      John Ferlan 提交于
      The function is actually in virutil.c, but prototyped in virfile.h.
      This patch fixes that by renaming the function to virWaitForDevices,
      adding the prototype in virutil.h and libvirt_private.syms, and then
      changing the callers to use the new name.
      Signed-off-by: NJohn Ferlan <jferlan@redhat.com>
      97e0d3c3
  4. 08 3月, 2017 11 次提交
  5. 07 3月, 2017 3 次提交
    • P
      tests: sysinfo: Export virSysinfoSetup via the private header · c58d95b7
      Peter Krempa 提交于
      virSysinfoSetup should be used only in tests so it can be moved to the
      new header file rather than using an extern declaration.
      c58d95b7
    • P
      util: sysinfo: Reduce amount of conditionally compiled code · b38c6b6a
      Peter Krempa 提交于
      Whole implementations along with helper totalling screens of code were
      conditionally compiled. That made the code totally unreadable and
      untestable. Rename functions to have the architecture in the name so
      that all can be compiled at the same time and introduce header to allow
      testing them all.
      b38c6b6a
    • L
      make all struct typedefs comply with proposed coding conventions · 38985269
      Laine Stump 提交于
      Proposed formal coding conventions encourage defining typedefs for
      vir[Blah] and vir[Blah]Ptr separately from the associated struct named
      _vir[Blah]:
      
          typedef struct _virBlah virBlah;
          typedef virBlah *virBlahPtr;
          struct _virBlah {
          ...
          };
      
      At some point in the past, I had submitted several patches using a
      more compact style that I prefer, and they were accepted:
      
          typedef struct _virBlah {
              ...
          } virBlah, *virBlahPtr;
      
      Since these are by far a minority among all struct definitions, this
      patch changes all those definitions to reflect the style prefered by
      the proposal so that there is 100% consistency.
      38985269
  6. 06 3月, 2017 2 次提交
    • J
      Cache the presence of machine1 service · f10bd740
      Ján Tomko 提交于
      After the system has been booted, it should not change.
      
      Cache the return value of virSystemdHasMachined.
      Allow starting and terminating machines with just one
      DBus call, instead of three, reducing the chance of
      the call timing out.
      
      Also introduce a small function for resetting the cache
      to be used in tests.
      f10bd740
    • J
      Unify checking for machine1 systemd service · 18c145a0
      Ján Tomko 提交于
      Both virSystemdTerminateMachine and virSystemdCreateMachine
      propagate the error to tell between a non-systemd system
      and a hard error.
      
      In virSystemdGetMachineNameByPID both are treated the same,
      but an error is ignored by the callers.
      
      Split out the checks into a separate function.
      18c145a0
  7. 24 2月, 2017 3 次提交
  8. 23 2月, 2017 1 次提交
    • D
      Use explicit boolean comparison in OOM check · 09db97d3
      Daniel P. Berrange 提交于
      GCC 7 gets upset by
      
         if (!tmp && (size * count))
      
      warning
      
        util/viralloc.c: In function 'virReallocN':
        util/viralloc.c:246:23: error: '*' in boolean context, suggest '&&' instead [-Werror=int-in-bool-context]
           if (!tmp && (size * count)) {
                       ~~~~~~^~~~~~~~
      
      Keep it happy by adding != 0 to the right hand expression
      so it realizes we really are wanting to treat the result
      of the arithmetic expression as a boolean
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      09db97d3
  9. 22 2月, 2017 2 次提交
  10. 20 2月, 2017 1 次提交
    • P
      Disallow inclusion of files from src/conf into src/utils · b4c73106
      Peter Krempa 提交于
      The utils code should stay separated from other code (except for very
      well justified cases). Unfortunately commit 272769be
      made it trivial to break the separation (and not get slapped by the
      syntax-check rule) by adding -I src/conf to the CFLAGS for utils.
      
      Remove this shortcut and except the two offenders from the syntax check
      so that the codebase can be kept separated.
      b4c73106
  11. 19 2月, 2017 3 次提交
  12. 17 2月, 2017 1 次提交
    • M
      qemu: Allow empty script path to <interface/> · 1d9ab0f0
      Michal Privoznik 提交于
      Before 9c17d665 (v1.3.2 - I know, right?) it was possible to
      have the following interface configuration:
      
        <interface type='ethernet'/>
          <script path=''/>
        </interface>
      
      This resulted in -netdev tap,script=,.. Fortunately, qemu helped
      us to get away with this as it just ignored the empty script
      path. However, after the commit mentioned above it's libvirtd
      who is executing the script. Unfortunately without special
      case-ing empty script path.
      Signed-off-by: NMichal Privoznik <mprivozn@redhat.com>
      1d9ab0f0
  13. 16 2月, 2017 1 次提交
  14. 14 2月, 2017 1 次提交
    • J
      util: fix off-by-one when expanding a bitmap · 4a41cf18
      Ján Tomko 提交于
      To make sure bit 'b' fits into the bitmap, we need to allocate b+1
      bits, since we number from 0.
      
      Adjust the bitmap test to set a bit at a multiple of 16.
      That way the test fails without this fix, because the VIR_REALLOC
      call clears the newly added memory even if the original pointer
      has not changed.
      4a41cf18
  15. 11 2月, 2017 2 次提交