1. 21 12月, 2012 5 次提交
    • D
      Rename buf.{c,h} to virbuffer.{c,h} · 2005f7b5
      Daniel P. Berrange 提交于
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      2005f7b5
    • D
      Rename bitmap.{c,h} to virbitmap.{c,h} · a27e4fbb
      Daniel P. Berrange 提交于
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      a27e4fbb
    • D
      Rename cgroup.{h,c} to vircgroup.{h,c} · f9c7020c
      Daniel P. Berrange 提交于
      To bring in line with new naming practice, rename the=
      src/util/cgroup.{h,c} files to vircgroup.{h,c}
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      f9c7020c
    • L
      util: fix functions that retrieve SRIOV VF info · ac2797cf
      Laine Stump 提交于
      This patch resolves:
      
        https://bugzilla.redhat.com/show_bug.cgi?id=889319
      
      When assigning an SRIOV virtual function to a guest using "intelligent
      PCI passthrough" (<interface type='hostdev'>, which sets the MAC
      address and vlan tag of the VF before passing its info to qemu),
      libvirt first learns the current MAC address and vlan tag by sending
      an NLM_F_REQUEST message for the VF's PF (physical function) to the
      kernel via a NETLINK_ROUTE socket (see virNetDevLinkDump()); the
      response message's IFLA_VFINFO_LIST section is examined to extract the
      info for the particular VF being assigned.
      
      This worked fine with kernels up until kernel commit
      115c9b81928360d769a76c632bae62d15206a94a (first appearing in upstream
      kernel 3.3) which changed the ABI to not return IFLA_VFINFO_LIST in
      the response until a newly introduced IFLA_EXT_MASK field was included
      in the request, with the (newly introduced, of course) RTEXT_FILTER_VF
      flag set.
      
      The justification for this ABI change was that new fields had been
      added to the VFINFO, causing NLM_F_REQUEST messages to fail on systems
      with large numbers of VFs if the requesting application didn't have a
      large enough buffer for all the info. The idea is that most
      applications doing an NLM_F_REQUEST don't care about VFINFO anyway, so
      eliminating it from the response would lower the requirements on
      buffer size. Apparently, the people who pushed this patch made the
      mistaken assumption that iproute2 (the "ip" command) was the only
      package that used IFLA_VFINFO_LIST, so it wouldn't break anything else
      (and they made sure that iproute2 was fixed.
      
      The logic of this "fix" is debatable at best (one could claim that the
      proper fix would be for the applications in question to be fixed so
      that they properly sized the buffer, which is what libvirt does
      (purely by virtue of using libnl), but it is what it is and we have to
      deal with it.
      
      In order for <interface type='hostdev'> to work properly on systems
      with a kernel 3.3 or later, libvirt needs to add the afore-mentioned
      IFLA_EXT_MASK field with RTEXT_FILTER_VF set.
      
      Of course we also need to continue working on systems with older
      kernels, so that one bit of code is compiled conditionally. The one
      time this could cause problems is if the libvirt binary was built on a
      system without IFLA_EXT_MASK which was subsequently updated to a
      kernel that *did* have it. That could be solved by manually providing
      the values of IFLA_EXT_MASK and RTEXT_FILTER_VF and adding it to the
      message anyway, but I'm uncertain what that might actually do on a
      system that didn't support the message, so for the time being we'll
      just fail in that case (which will very likely never happen anyway).
      ac2797cf
    • L
      util: add missing error log messages when failing to get netlink VFINFO · 846770e5
      Laine Stump 提交于
      This patch fixes the lack of error messages when libvirt fails to find
      VFINFO in a returned netlinke response message.
      
      https://bugzilla.redhat.com/show_bug.cgi?id=827519#c10 is an example
      of the error message that was previously logged when the
      IFLA_VFINFO_LIST object was missing from the netlink response. The
      reason for this failure is detailed in
      
         https://bugzilla.redhat.com/show_bug.cgi?id=889319
      
      Even though that root problem has been fixed, the experience of
      finding the root cause shows us how important it is to properly log an
      error message in these cases. This patch *seems* to replace the entire
      function, but really most of the changes are due to moving code that
      was previously inside an if() statement out to the top level of the
      function (the original if() was reversed and made to log an error and
      return).
      846770e5
  2. 20 12月, 2012 2 次提交
  3. 19 12月, 2012 3 次提交
  4. 18 12月, 2012 4 次提交
    • L
      network: don't require private addresses if dnsmasq uses SO_BINDTODEVICE · 4b31da34
      Laine Stump 提交于
      This is yet another refinement to the fix for CVE-2012-3411:
      
         https://bugzilla.redhat.com/show_bug.cgi?id=833033
      
      It turns out that it would be very intrusive to correctly backport the
      entire --bind-dynamic option to older dnsmasq versions
      (e.g. dnsmasq-2.48 that is used on RHEL6.x and CentOS 6.x), but very
      simple to patch those versions to just use SO_BINDTODEVICE on all
      their listening sockets (SO_BINDTODEVICE also has the desired effect
      of permitting only traffic that was received on the interface(s) where
      dnsmasq was set to listen.)
      
      This patch modifies the dnsmasq capabilities detection to detect the
      string:
      
          --bind-interfaces with SO_BINDTODEVICE
      
      in the output of "dnsmasq --version", and in that case realize that
      using the old --bind-interfaces option is just as safe as
      --bind-dynamic (and therefore *not* forbid creation of networks that
      use public IP address ranges).
      
      If -bind-dynamic is available, it is still preferred over
      --bind-interfaces.
      
      Note that this patch does no harm in upstream, or in any distro's
      downstream if it happens to end up there, but builds for distros that
      have a new enough dnsmasq to support --bind-dynamic do *NOT* need to
      specifically backport this patch; it's only required for distro
      releases that have dnsmasq too old to have --bind-dynamic (and those
      distros will need to add the SO_BINDTODEVICE patch to dnsmasq,
      *including the extra string in the --version output*, as well.
      4b31da34
    • C
      2628ad83
    • D
      Allow passing a vroot into security manager hostdev labelling · df5928ea
      Daniel P. Berrange 提交于
      When LXC labels USB devices during hotplug, it is running in
      host context, so it needs to pass in a vroot path to the
      container root.
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      df5928ea
    • V
      S390: Fix virSysinfoRead memory corruption · cab938c9
      Viktor Mihajlovski 提交于
      There was a double free issue caused by virSysinfoRead on s390,
      as the same manufacturer string instance was assigned to more
      than one processor record.
      Cleaned up other potential memory issues and restructured the sysinfo
      parsing code by moving repeating patterns into a helper function.
      
      The restructuring made it necessary to conditionally disable
      -Wlogical-op for some older GCC versions, using pragma GCC diagnostic.
      This is a GCC specific pragma, which is acceptable, since we're
      using it to work around a GCC specific bug.
      
      Finally, added a function virSysinfoSetup to configure the sysinfo
      data source files/script during run time, to facilitate writing test
      programs. This function is not published in sysinfo.h and only
      there for testing.
      Signed-off-by: NViktor Mihajlovski <mihajlov@linux.vnet.ibm.com>
      cab938c9
  5. 13 12月, 2012 6 次提交
  6. 12 12月, 2012 8 次提交
    • P
      util: Fix warning message in previous patch · ab8d3233
      Peter Krempa 提交于
      I didn't notice the extra "does" in the previous patch. Remove it.
      ab8d3233
    • P
      util: rework error reporting in virGet(User|Group)IDByName · 96460a19
      Peter Krempa 提交于
      This patch gets rid of the undeterministic error reporting code done on
      return values of get(pw|gr)nam_r. With this patch, if the group record
      is not returned by the corresponding function this error is not
      considered fatal even if errno != 0. The error is logged in such case.
      96460a19
    • D
      Remove bogus const return values in storage file APIs · 3f0010a6
      Daniel P. Berrange 提交于
      virStorageFileGetLVMKey and virStorageFileGetSCSIKey
      both return heap allocated strings, so the return value
      should not be marked const.
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      3f0010a6
    • M
      bandwidth: Create rate update function · b697411c
      Michal Privoznik 提交于
      This will be used whenever a NIC with guaranteed throughput is to
      be plugged into a bridge. It will adjust the average throughput of
      non guaranteed NICs (classid 1:2) to meet new requirements.
      b697411c
    • M
      bandwidth: Create (un)plug functions · 7cdbacb4
      Michal Privoznik 提交于
      These set bridge part of QoS when bringing domain's interface up.
      Long story short, if there's a 'floor' set, a new QoS class is created.
      ClassID MUST be unique within the bridge and should be kept for
      unplug phase.
      7cdbacb4
    • M
      bandwidth: Create hierarchical shaping classes · 67159f1c
      Michal Privoznik 提交于
      These classes can borrow unused bandwidth. Basically,
      only egress qdsics can have classes, therefore we can
      do this kind of traffic shaping only on host's outgoing,
      that is domain's incoming traffic.
      67159f1c
    • M
      bandwidth: add new 'floor' attribute · ec6474b2
      Michal Privoznik 提交于
      This is however supported only on domain interfaces with
      type='network'. Moreover, target network needs to have at least
      inbound QoS set. This is required by hierarchical traffic shaping.
      
      From now on, the required attribute for <inbound/> is either 'average'
      (old) or 'floor' (new). This new attribute can be used just for
      interfaces type of network (<interface type='network'/>) currently.
      ec6474b2
    • M
      bandwidth: Attach sfq to leaf node · 7e5040bd
      Michal Privoznik 提交于
      Stochastic Fairness Queuing (SFQ) is queuing discipline
      (qdisc) which doesn't really shape any traffic but 'just'
      re-arrange packets in sending buffer so no stream starve.
      The goal is to ensure fairness. There is basically only one
      configuration parameter (perturb) which is set to advised
      value of 10.
      7e5040bd
  7. 11 12月, 2012 2 次提交
    • G
      network: add support for DHCPv6 · 2d5cd1d7
      Gene Czarcinski 提交于
      The DHCPv6 support includes IPV6 dhcp-range and dhcp-host for one
      IPv6 subnetwork on one interface.  This support will only work
      if dnsmasq version >= 2.64; otherwise an error occurs if
      dhcp-range or dhcp-host is specified for an IPv6 address.
      
      Essentially, this change provides the same DHCP support for IPv6
      that has been available for IPv4.
      
      With dnsmasq >= 2.64, support for the RA service is also now provided
      by dnsmasq (radvd is no longer used/started). (Although at least one
      version of dnsmasq prior to 2.64 "supported" IPv6 Router
      Advertisement, there were bugs (fixed in 2.64) that rendered it
      unusable.)
      
      Documentation and the network schema has been updated
      to reflect the new support.
      2d5cd1d7
    • L
      util: add VIR_(APPEND|INSERT|DELETE)_ELEMENT · 85b22f52
      Laine Stump 提交于
      I noticed when writing the backend functions for virNetworkUpdate that
      I was repeating the same sequence of memmove, VIR_REALLOC, nXXX-- (and
      messed up the args to memmove at least once), and had seen the same
      sequence in a lot of other places, so I decided to write a few
      utility functions/macros - see the .h file for full documentation.
      
      The intent is to reduce the number of lines of code, but more
      importantly to eliminate the need to check the element size and
      element count arithmetic every time we need to do this (I *always*
      make at least one mistake.)
      
      VIR_INSERT_ELEMENT: insert one element at an arbitrary index within an
        array of objects. The size of each object is determined
        automatically by the macro using sizeof(*array). The new element's
        contents are copied into the inserted space, then the original copy
        of contents are 0'ed out (if everything else was
        successful). Compile-time assignment and size compatibility between
        the array and the new element is guaranteed (see explanation below
        [*])
      
      VIR_INSERT_ELEMENT_COPY: identical to VIR_INSERT_ELEMENT, except that
        the original contents of newelem are not cleared to 0 (i.e. a copy
        is made).
      
      VIR_APPEND_ELEMENT: This is just a special case of VIR_INSERT_ELEMENT
        that "inserts" one past the current last element.
      
      VIR_APPEND_ELEMENT_COPY: identical to VIR_APPEND_ELEMENT, except that
        the original contents of newelem are not cleared to 0 (i.e. a copy
        is made).
      
      VIR_DELETE_ELEMENT: delete one element at an arbitrary index within an
        array of objects. It's assumed that the element being deleted is
        already saved elsewhere (or cleared, if that's what is appropriate).
      
      All five of these macros have an _INPLACE variant, which skips the
      memory re-allocation of the array, assuming that the caller has
      already done it (when inserting) or will do it later (when deleting).
      
      Note that VIR_DELETE_ELEMENT* can return a failure, but only if an
      invalid index is given (index + amount to delete is > current array
      size), so in most cases you can safely ignore the return (that's why
      the helper function virDeleteElementsN isn't declared with
      ATTRIBUTE_RETURN_CHECK). A warning is logged if this ever happens,
      since it is surely a coding error.
      
      [*] One initial problem with the INSERT and APPEND macros was that,
      due to both the array pointer and newelem pointer being cast to void*
      when passing to virInsertElementsN(), any chance of type-checking was
      lost. If we were going to move in newelem with a memmove anyway, we
      would be no worse off for this. However, most current open-coded
      insert/append operations use direct struct assignment to move the new
      element into place (or just populate the new element directly) - thus
      use of the new macros would open a possibility for new usage errors
      that didn't exist before (e.g. accidentally sending &newelemptr rather
      than newelemptr - I actually did this quite a lot in my test
      conversions of existing code).
      
      But thanks to Eric Blake's clever thinking, I was able to modify the
      INSERT and APPEND macros so that they *do* check for both assignment
      and size compatibility of *ptr (an element in the array) and newelem
      (the element being copied into the new position of the array). This is
      done via clever use of the C89-guaranteed fact that the sizeof()
      operator must have *no* side effects (so an assignment inside sizeof()
      is checked for validity, but not actually evaluated), and the fact
      that virInsertElementsN has a "# of new elements" argument that we
      want to always be 1.
      85b22f52
  8. 10 12月, 2012 1 次提交
  9. 07 12月, 2012 3 次提交
    • O
      qemu: Allow the user to specify vendor and product for disk · b718ded3
      Osier Yang 提交于
      QEMU supports setting vendor and product strings for disk since
      1.2.0 (only scsi-disk, scsi-hd, scsi-cd support it), this patch
      exposes it with new XML elements <vendor> and <product> of disk
      device.
      b718ded3
    • C
      util: Don't fail virGetGroupIDByName when group not found · a33f4eae
      Christophe Fergeau 提交于
      virGetGroupIDByName is documented as returning 1 if the groupname
      cannot be found. getgrnam_r is documented as returning:
      « 0 or ENOENT or ESRCH or EBADF or EPERM or ...  The given name
      or gid was not found. »
       and that:
      « The formulation given above under "RETURN VALUE" is from POSIX.1-2001.
      It  does  not  call  "not  found"  an error, hence does not specify what
      value errno might have in this situation.  But that makes it impossible to
      recognize errors.  One might argue that according to POSIX errno should be
      left unchanged if an entry is not found.  Experiments on various UNIX-like
      systems shows that lots of different values occur in this situation: 0,
      ENOENT, EBADF, ESRCH, EWOULDBLOCK, EPERM and probably others. »
      
      virGetGroupIDByName returns an error when the return value of getgrnam_r
      is non-0. However on my RHEL system, getgrnam_r returns ENOENT when the
      requested user cannot be found, which then causes virGetGroupID not
      to behave as documented (it returns an error instead of falling back
      to parsing the passed-in value as an gid).
      
      This commit makes virGetGroupIDByName only report an error when errno
      is set to one of the values in the posix description of getgrnam_r
      (which are the same as the ones described in the manpage on my system).
      a33f4eae
    • C
      util: Don't fail virGetUserIDByName when user not found · 6c6c03dc
      Christophe Fergeau 提交于
      virGetUserIDByName is documented as returning 1 if the username
      cannot be found. getpwnam_r is documented as returning:
      « 0 or ENOENT or ESRCH or EBADF or EPERM or ...  The given name
      or uid was not found. »
       and that:
      « The formulation given above under "RETURN VALUE" is from POSIX.1-2001.
      It  does  not  call  "not  found"  an error, hence does not specify what
      value errno might have in this situation.  But that makes it impossible to
      recognize errors.  One might argue that according to POSIX errno should be
      left unchanged if an entry is not found.  Experiments on various UNIX-like
      systems shows that lots of different values occur in this situation: 0,
      ENOENT, EBADF, ESRCH, EWOULDBLOCK, EPERM and probably others. »
      
      virGetUserIDByName returns an error when the return value of getpwnam_r
      is non-0. However on my RHEL system, getpwnam_r returns ENOENT when the
      requested user cannot be found, which then causes virGetUserID not
      to behave as documented (it returns an error instead of falling back
      to parsing the passed-in value as an uid).
      
      This commit makes virGetUserIDByName only report an error when errno
      is set to one of the values in the posix description of getpwnam_r
      (which are the same as the ones described in the manpage on my system).
      6c6c03dc
  10. 06 12月, 2012 2 次提交
    • M
      dnsmasq: Fix parsing of the version number · ff33f807
      Michal Privoznik 提交于
      If debugging is enabled, the debug messages are sent to stderr.
      Moreover, if a command has catching of stderr set, the messages
      gets mixed with stdout output (assuming both outputs are stored
      in the same variable). The resulting string then doesn't
      necessarily have to start with desired prefix then. This bug
      exposes itself when parsing dnsmasq output:
      
      2012-12-06 11:18:11.445+0000: 18491: error :
      dnsmasqCapsSetFromBuffer:664 : internal error cannot parse
      /usr/sbin/dnsmasq version number in '2012-12-06
      11:11:02.232+0000: 18492: debug : virFileClose:72 : Closed fd 22'
      
      We can clearly see that the output of dnsmasq --version doesn't
      start with expected "Dnsmasq version " string but a libvirt debug
      output.
      ff33f807
    • M
      dnsmasq: Fix parsing of the version number · 51144313
      Michal Privoznik 提交于
      If the debugging is enabled, the virCommand subsystem catches debug
      messages in the command output as well. In that case, we can't assume
      the string corresponding to command's stdout will start with specific
      prefix. But the prefix can be moved deeper in the string. This bug
      shows itself when parsing dnsmasq output:
      
      2012-12-06 11:18:11.445+0000: 18491: error :
      dnsmasqCapsSetFromBuffer:664 : internal error cannot parse
      /usr/sbin/dnsmasq version number in '2012-12-06 11:11:02.232+0000:
      18492: debug : virFileClose:72 : Closed fd 22'
      
      We can clearly see that the output of dnsmasq --version
      doesn't start with expected "Dnsmasq version " string but a libvirt
      debug output.
      51144313
  11. 05 12月, 2012 3 次提交
  12. 03 12月, 2012 1 次提交