1. 24 3月, 2017 1 次提交
    • L
      util: permit querying a VF MAC address or VLAN tag by itself · 176229dd
      Laine Stump 提交于
      virNetDevParseVfConfig() assumed that both the MAC address and VLAN
      tag pointers were valid, so even if you only wanted one or the other,
      you would need a variable to hold the returned value for both. This
      patch checks each for a NULL pointer before filling it in.
      176229dd
  2. 23 3月, 2017 4 次提交
    • R
      util: fix build on non-Linux · 80958284
      Roman Bogorodskiy 提交于
      Decorate unused arguments of the virNetDevGetMaster() stub
      with ATTRIBUTE_UNUSED to fix build on systems where this
      stub is used.
      80958284
    • 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
  3. 22 3月, 2017 1 次提交
  4. 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
  5. 27 6月, 2016 3 次提交
    • L
      util: new files virnetdevip.[ch] for IP-related netdev functions · cf0568b0
      Laine Stump 提交于
      This patch splits virnetdev.[ch] into multiple files, with the new
      virnetdevip.[ch] containing all the functions related to setting and
      retrieving IP-related info for a device (both addresses and routes).
      cf0568b0
    • L
      util: move virInterface(State|Link)/virNetDevFeature from conf to util · 638c6e5b
      Laine Stump 提交于
      These had been declared in conf/device_conf.h, but then used in
      util/virnetdev.c, meaning that we had to #include conf/device_conf.h
      in virnetdev.c (which we have for a long time said shouldn't be done.
      
      This caused a bigger problem when I tried to #include util/virnetdev.h
      in a file in src/conf (which is allowed) - for some reason the
      "device_conf.h: File not found" error.
      
      The solution is to move the data types and functions used in util
      sources from conf to util. Some names were adjusted during the move
      ("virInterface" --> "virNetDevIf", and "VIR_INTERFACE" -->
      "VIR_NETDEV_IF")
      638c6e5b
    • L
      util: move virNetDevLinkDump to virnetlink.c · 943a400c
      Laine Stump 提交于
      virNetDevLinkDump should have been in virnetlink.c, but that file
      didn't exist yet when the function was created. It didn't really
      matter until now - I found that having virnetlink.h included by
      virnetdev.h caused build problems when trying to #include virnetdev.h
      in a .c file in src/conf (due to missing directory in -I). Rather than
      fix that to further institutionalize the incorrect placement of this
      one function, this patch moves the function.
      943a400c
  6. 24 6月, 2016 3 次提交
    • J
      Use virDirOpen · e81de04c
      Ján Tomko 提交于
      Switch from opendir to virDirOpen everywhere we need to report an error.
      e81de04c
    • J
      Do not ignore hidden files in /sys and /proc · 70a033ab
      Ján Tomko 提交于
      The directories we iterate over are unlikely to contain any entries
      starting with a dot, other than '.' and '..' which is already skipped
      by virDirRead.
      70a033ab
    • J
      Introduce VIR_DIR_CLOSE · a4e6f1eb
      Ján Tomko 提交于
      Introduce a helper that only calls closedir if DIR* is non-NULL
      and sets it to NULL afterwards.
      a4e6f1eb
  7. 17 6月, 2016 1 次提交
    • L
      util: fix missing broadcast address in bridge and tap device IP addresses · bf913385
      Laine Stump 提交于
      Commit b3d06987 added peer address setting to the low level
      virNetDevSetIPAddress() function, but ended up causing a segfault in
      cases where the caller passed NULL for peer address.
      
      Commit a3510e33 fixed the segfault, but managed to cause us to
      skip setting the broadcast address when setting an interface's IP
      address. The result is that the broadcast address is 0.0.0.0 for all
      libvirt-created bridges (and interfaces in lxc containers with IP
      addresses set by libvirt).
      
      This was reported on the mailing list:
      
        https://www.redhat.com/archives/libvir-list/2016-June/msg00027.html
      
      but I was too busy to investigate at the time. I found it by accident
      today while refactoring virNetDevSetIPAddress(). Since this regression
      is present in the 1.3.5 release, I'm sending the bugfix as a separate
      patch from my larger refactoring patchset.
      bf913385
  8. 09 6月, 2016 1 次提交
  9. 07 6月, 2016 7 次提交
  10. 11 5月, 2016 1 次提交
    • L
      util: set vlan tag for macvtap passthrough mode on SRIOV VFs · 75db9997
      Laine Stump 提交于
      SRIOV VFs used in macvtap passthrough mode can take advantage of the
      SRIOV card's transparent vlan tagging. All the code was there to set
      the vlan tag, and it has been used for SRIOV VFs used for hostdev
      interfaces for several years, but for some reason, the vlan tag for
      macvtap passthrough devices was stubbed out with a -1.
      
      This patch moves a bit of common validation down to a lower level
      (virNetDevReplaceNetConfig()) so it is shared by hostdev and macvtap
      modes, and updates the macvtap caller to actually send the vlan config
      instead of -1.
      75db9997
  11. 13 4月, 2016 1 次提交
  12. 08 4月, 2016 3 次提交
  13. 26 2月, 2016 1 次提交
    • A
      netdev: Use virNetDevIsVirtualFunction() properly · dec3a4a1
      Andrea Bolognani 提交于
      virNetDevIsVirtualFunction() returns 1 if the interface is a
      virtual function, 0 if it isn't and -1 on error. This means that,
      despite the name suggesting otherwise, using it as a predicate is
      not correct.
      
      Fix two callers that were doing so adding an explicit check on
      the return value.
      dec3a4a1
  14. 25 2月, 2016 1 次提交
  15. 05 1月, 2016 1 次提交
    • L
      util: report the MAC address that couldn't be set · 5ffa236b
      Laine Stump 提交于
      I noticed in a log file that we had failed to set a MAC address. The
      log said which interface we were trying to set, but didn't give the
      offending MAC address, which could have been useful in determining the
      source of the problem. This patch modifies all three places in the
      code that set MAC addresses to report the failed MAC as well as
      interface.
      5ffa236b
  16. 02 12月, 2015 1 次提交
    • I
      network: selectively disable -Wcast-align in virNetDevParseDadStatus · af2954ae
      Ian Campbell 提交于
      Commit 0f7436ca "network: wait for DAD to finish for bridge IPv6 addresses"
      results in:
      
       CC     util/libvirt_util_la-virnetdevmacvlan.lo
      util/virnetdev.c: In function 'virNetDevParseDadStatus':
      util/virnetdev.c:1319:188: error: cast increases required alignment of target type [-Werror=cast-align]
      util/virnetdev.c:1332:41: error: cast increases required alignment of target type [-Werror=cast-align]
      util/virnetdev.c:1334:92: error: cast increases required alignment of target type [-Werror=cast-align]
      cc1: all warnings being treated as errors
      
      on at least ARM platforms.
      
      The three macros involved (NLMSG_NEXT, IFA_RTA and RTA_NEXT) all appear to
      correctly take care of alignment, therefore suppress Wcast-align around their
      uses.
      Signed-off-by: NIan Campbell <ian.campbell@citrix.com>
      Cc: Maxim Perevedentsev <mperevedentsev@virtuozzo.com>
      Cc: Laine Stump <laine@laine.org>
      Cc: Dario Faggioli <dario.faggioli@citrix.com>
      Cc: Jim Fehlig <jfehlig@suse.com>
      af2954ae
  17. 25 11月, 2015 1 次提交
    • L
      nodedev: report maxCount for virtual_functions capability · f391889f
      Laine Stump 提交于
      A PCI device may have the capability to setup virtual functions (VFs)
      but have them currently all disabled. Prior to this patch, if that was
      the case the the node device XML for the device wouldn't report any
      virtual_functions capability.
      
      With this patch, if a file called "sriov_totalvfs" is found in the
      device's sysfs directory, its contents will be interpreted as a
      decimal number, and that value will be reported as "maxCount" in a
      capability element of the device's XML, e.g.:
      
         <capability type='virtual_functions' maxCount='7'/>
      
      This will be reported regardless of whether or not any VFs are
      currently enabled for the device.
      
      NB: sriov_numvfs (the number of VFs currently active) is also
      available in sysfs, but that value is implied by the number of items
      in the list that is inside the capability element, so there is no
      reason to explicitly provide it as an attribute.
      
      sriov_totalvfs and sriov_numvfs are available in kernels at least as far
      back as the 2.6.32 that is in RHEL6.7, but in the case that they
      simply aren't there, libvirt will behave as it did prior to this patch
      - no maxCount will be displayed, and the virtual_functions capability
      will be absent from the device's XML when 0 VFs are enabled.
      f391889f
  18. 07 11月, 2015 2 次提交
    • J
      virnetdev: Use virNetDevSetupControl in virNetDevSendEthtoolIoctl · edc88e20
      John Ferlan 提交于
      Use virNetDevSetupControl instead of open coding using socket(AF_LOCAL...)
      and clearing virIfreq.
      
      By using virNetDevSetupControl, the socket is then opened using
      AF_PACKET which requires being privileged (effectively root) in
      order to complete successfully.  Since that's now a requirement,
      then the ioctl(SIOCETHTOOL) should not fail with EPERM, thus it
      is removed from the filtered listed of failure codes.
      Signed-off-by: NJohn Ferlan <jferlan@redhat.com>
      edc88e20
    • J
      virnetdev: Check for root in virNetDevGetFeatures · d0a3a1ff
      John Ferlan 提交于
      Since the SIOCETHTOOL ioctl only works for privileged daemons, if called
      when not root, then virNetDevGetFeatures will VIR_DEBUG a message and
      return 0 as if the functions were not available for the architecture.
      This effectively returns an empty bitmap indicating no features available.
      
      Introduced by commit id 'c9027d8f'
      Signed-off-by: NJohn Ferlan <jferlan@redhat.com>
      d0a3a1ff
  19. 06 11月, 2015 3 次提交
    • J
      virnetdev: Fix function comments for virNetDevGetFeatures · 9efab5da
      John Ferlan 提交于
      In commit id 'c9027d8f' when updating the posted patch to generate
      a bitmap instead of an array of named feature bits, adjustment of
      the args was missed
      9efab5da
    • J
      virnetdev: Document reasons for ignoring some SIOCETHTOOL errno values · 301bd801
      John Ferlan 提交于
      Recently reverted commit id '6f2a0198' showed a need to add extra
      comments when dealing with filtering of potential "non-issues".
      
      Scanning through upstream patch postings indicates early on the
      reasons for the filtering of specific ioctl failures were provided;
      however, when converted from causing an error to VIR_DEBUG's the
      reasons were missing. A future read/change of the code incorrectly
      assumed they could or should be removed.
      301bd801
    • D
      Revert "utils: Remove the logging of errors from virNetDevSendEthtoolIoctl" · a3f63b85
      Daniel P. Berrange 提交于
      This reverts commit 6f2a0198.
      
      This commit removed error reporting from virNetDevSendEthtoolIoctl
      pushing responsibility onto the callers. This is wrong, however,
      since virNetDevSendEthtoolIoctl calls virNetDevSetupControl
      which can still report errors. So as a result virNetDevSendEthtoolIoctl
      may or may not report errors depending on which bit of it fails, and as
      a result callers now overwrite some errors.
      
      It also introduced a regression causing unprivileged libvirtd to
      spew error messages to the console due to inability to query the
      NIC features, an error which was previously ignored.
      
      virNetDevSetupControlFull:148 : Cannot open network interface control socket: Operation not permitted
      virNetDevFeatureAvailable:3062 : Cannot get device wlp3s0 flags: Operation not permitted
      virNetDevSetupControlFull:148 : Cannot open network interface control socket: Operation not permitted
      virNetDevFeatureAvailable:3062 : Cannot get device wlp3s0 flags: Operation not permitted
      virNetDevSetupControlFull:148 : Cannot open network interface control socket: Operation not permitted
      virNetDevFeatureAvailable:3062 : Cannot get device wlp3s0 flags: Operation not permitted
      virNetDevSetupControlFull:148 : Cannot open network interface control socket: Operation not permitted
      virNetDevFeatureAvailable:3062 : Cannot get device wlp3s0 flags: Operation not permitted
      
      Looking back at the original posting I see no explanation of why
      thsi refactoring was needed, so reverting the clearly broken
      error reporting logic looks like the best option.
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      a3f63b85
  20. 05 11月, 2015 1 次提交
  21. 30 10月, 2015 2 次提交
    • L
      util: set max wait for IPv6 DAD to 20 seconds · ac339206
      Laine Stump 提交于
      This was originally set to 5 seconds, but times of 5.5 to 7 seconds
      were experienced. Since it's an arbitrary number intended to prevent
      an infinite hang, having it a bit too high won't hurt anything, and 20
      seconds looks to be adequate (i.e. I think/hope we don't need to make
      it tunable in libvirtd.conf)
      ac339206
    • L
      util: set error if DAD is not finished · d41a64a1
      Luyao Huang 提交于
      If DAD not finished in 5 seconds, user will get an
      unknown error like this:
      
       # virsh net-start ipv6
       error: Failed to start network ipv6
       error: An error occurred, but the cause is unknown
      
      Call virReportError to set an error.
      Signed-off-by: NLuyao Huang <lhuang@redhat.com>
      d41a64a1