1. 28 5月, 2015 1 次提交
    • M
      Cleanup "/sys/class/net" usage · 5040f00b
      Michal Privoznik 提交于
      Throughout the code, we have several places need to construct a path
      somewhere in /sys/class/net/... They are not consistent and nearly
      each code piece invents its own way how to do it. So unify this by:
      
      1) use virNetDevSysfsFile() wherever possible
      
      2) At least use common macro SYSFS_NET_DIR declared in virnetdev.h at
         the rest of places which can't go with 1)
      Signed-off-by: NMichal Privoznik <mprivozn@redhat.com>
      (cherry picked from commit 96a21e97)
      5040f00b
  2. 28 4月, 2015 2 次提交
    • L
      util: set MAC address for VF via netlink message to PF+VF# when possible · d336362c
      Laine Stump 提交于
      Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1113474
      
      When we set the MAC address of a network device as a part of setting
      up macvtap "passthrough" mode (where the domain has an emulated netdev
      connected to a host macvtap device that has exclusive use of the
      physical device, and sets the device MAC address to match its own,
      i.e. "<interface type='direct'> <source mode='passthrough' .../>"), we
      use ioctl(SIOCSIFHWADDR) giving it the name of that device. This is
      true even if it is an SRIOV Virtual Function (VF).
      
      But, when we are setting the MAC address / vlan ID of a VF in
      preparation for "hostdev network" passthrough (this is where we set
      the MAC address and vlan id of the VF after detaching the host net
      driver and before assigning the device to the domain with PCI
      passthrough, i.e. "<interface type='hostdev'>", we do the setting via
      a netlink RTM_SETLINK message for that VF's Physical Function (PF),
      telling it the VF# we want to change. This sets an "administratively
      changed MAC" flag for that VF in the PF's driver, and from that point
      on (until the PF driver is reloaded, *not* merely the VF driver) that
      VF's MAC address can't be changed using ioctl(SIOCSIFHWADDR) - the
      only way to change it is via the PF with RTM_SETLINK.
      
      This means that if a VF is used for hostdev passthrough, it will have
      the admin flag set, and future attempts to use that VF for macvtap
      passthrough will fail.
      
      The solution to this problem is to check if the device being used for
      macvtap passthrough is actually a VF; if so, we use the netlink
      RTM_SETLINK message to the PF to set the VF's mac address instead of
      ioctl(SIOCSIFHWADDR) directly to the VF; if not, behavior does not
      change from previously.
      
      There are three pieces to making this work:
      
      1) virNetDevMacVLan(Create|Delete)WithVPortProfile() now call
         virNetDev(Replace|Restore)NetConfig() rather than
         virNetDev(Replace|Restore)MacAddress() (simply passing -1 for VF#
         and vlanid).
      
      2) virNetDev(Replace|Restore)NetConfig() check to see if the device is
         a VF. If so, they find the PF's name and VF#, allowing them to call
         virNetDev(Replace|Restore)VfConfig().
      
      3) To prevent mixups when detaching a macvtap passthrough device that
         had been attached while running an older version of libvirt,
         virNetDevRestoreVfConfig() is potentially given the preserved name
         of the VF, and if the proper statefile for a VF can't be found in
         the stateDir (${stateDir}/${pfname}_vf${vfid}),
         virNetDevRestoreMacAddress() is called instead (which will look in
         the file named ${stateDir}/${vfname}).
      
      This problem has existed in every version of libvirt that has both
      macvtap passthrough and interface type='hostdev'. Fortunately people
      seem to use one or the other though, so it hasn't caused any real
      world problem reports.
      
      (cherry picked from commit cb3fe38c)
      d336362c
    • L
      util: more verbose error when failing to create macvtap device · b10e27ad
      Laine Stump 提交于
      Investigation of a problem with creating passthrough macvtap devices
      (https://bugzilla.redhat.com/show_bug.cgi?id=1185501) has shown that
      this slightly more verbose failure message is useful. In particular,
      the mac address can be used to determine the domain. You could also
      figure this out by looking at preceding messages in a debug log, but
      this gets it in a single place.
      
      (cherry picked from commit 72423df9)
      b10e27ad
  3. 29 1月, 2015 2 次提交
  4. 11 12月, 2014 1 次提交
    • M
      network: Bring netdevs online later · 82977058
      Matthew Rosato 提交于
      Currently, MAC registration occurs during device creation, which is
      early enough that, during live migration, you end up with duplicate
      MAC addresses on still-running source and target devices, even though
      the target device isn't actually being used yet.
      This patch proposes to defer MAC registration until right before
      the guest can actually use the device -- In other words, right
      before starting guest CPUs.
      Signed-off-by: NMatthew Rosato <mjrosato@linux.vnet.ibm.com>
      Signed-off-by: NLaine Stump <laine@laine.org>
      82977058
  5. 19 11月, 2014 1 次提交
  6. 15 11月, 2014 1 次提交
  7. 05 9月, 2014 1 次提交
    • E
      maint: use hanging curly braces · 625e04a8
      Eric Blake 提交于
      Our style overwhelmingly uses hanging braces (the open brace
      hangs at the end of the compound condition, rather than on
      its own line), with the primary exception of the top level function
      body.  Fix the few remaining outliers, before adding a syntax
      check in a later patch.
      
      * src/interface/interface_backend_netcf.c (netcfStateReload)
      (netcfInterfaceClose, netcf_to_vir_err): Correct use of { in
      compound statement.
      * src/conf/domain_conf.c (virDomainHostdevDefFormatSubsys)
      (virDomainHostdevDefFormatCaps): Likewise.
      * src/network/bridge_driver.c (networkAllocateActualDevice):
      Likewise.
      * src/util/virfile.c (virBuildPathInternal): Likewise.
      * src/util/virnetdev.c (virNetDevGetVirtualFunctions): Likewise.
      * src/util/virnetdevmacvlan.c
      (virNetDevMacVLanVPortProfileCallback): Likewise.
      * src/util/virtypedparam.c (virTypedParameterAssign): Likewise.
      * src/util/virutil.c (virGetWin32DirectoryRoot)
      (virFileWaitForDevices): Likewise.
      * src/vbox/vbox_common.c (vboxDumpNetwork): Likewise.
      * tests/seclabeltest.c (main): Likewise.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      625e04a8
  8. 02 9月, 2014 1 次提交
  9. 04 8月, 2014 1 次提交
    • J
      Don't overwrite errors from virNetDevBandwidthSet · 6dac5d06
      Ján Tomko 提交于
      Otherwise this beautiful error would be overwritten when
      the function is called with a really high rate number:
      
      2014-07-28 12:51:47.920+0000: 2304: error : virCommandWait:2399 :
      internal error: Child process (/sbin/tc class add dev vnet0 parent 1:
      classid 1:1 htb rate 4294968kbps) unexpected exit status 1: Illegal "rate"
      Usage: ... qdisc add ... htb [default N] [r2q N]
       default  minor id of class to which unclassified packets are sent {0}
       r2q      DRR quantums are computed as rate in Bps/r2q {10}
       debug    string of 16 numbers each 0-3 {0}
      
      ... class add ... htb rate R1 [burst B1] [mpu B] [overhead O]
                            [prio P] [slot S] [pslot PS]
                            [ceil R2] [cburst B2] [mtu MTU] [quantum Q]
       rate     rate allocated to this class (class can still borrow)
       burst    max bytes burst which can be accumulated during idle period {computed}
       mpu      minimum packet size used in rate computations
       overhead per-packet size overhead used in rate computations
       linklay  adapting to a linklayer e.g. atm
       ceil     definite upper class rate (no borrows) {rate}
       cburst   burst but for ceil {computed}
       mtu      max packet size we create rate map for {1600}
       prio     priority of leaf; lowe
      
      https://bugzilla.redhat.com/show_bug.cgi?id=1043735
      6dac5d06
  10. 06 5月, 2014 2 次提交
  11. 08 4月, 2014 1 次提交
  12. 25 3月, 2014 1 次提交
  13. 18 3月, 2014 1 次提交
  14. 21 11月, 2013 1 次提交
    • E
      maint: fix comma style issues: util · c7c84fa5
      Eric Blake 提交于
      Most of our code base uses space after comma but not before;
      fix the remaining uses before adding a syntax check.
      
      * src/util/vircommand.c: Consistently use commas.
      * src/util/virlog.c: Likewise.
      * src/util/virnetdevbandwidth.c: Likewise.
      * src/util/virnetdevmacvlan.c: Likewise.
      * src/util/virnetdevvportprofile.c: Likewise.
      * src/util/virnetlink.c: Likewise.
      * src/util/virpci.c: Likewise.
      * src/util/virsysinfo.c: Likewise.
      * src/util/virusb.c: Likewise.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      c7c84fa5
  15. 15 10月, 2013 1 次提交
    • E
      maint: avoid 'const fooPtr' in virnet files · 955af4d4
      Eric Blake 提交于
      'const fooPtr' is the same as 'foo * const' (the pointer won't
      change, but it's contents can).  But in general, if an interface
      is trying to be const-correct, it should be using 'const foo *'
      (the pointer is to data that can't be changed).
      
      Fix up remaining offenders in src/util.
      
      * src/util/virnetdev.h (virNetDevSetMAC)
      (virNetDevReplaceMacAddress, virNetDevValidateConfig)
      (virNetDevReplaceNetConfig): Use intended type.
      * src/util/virnetdevbandwidth.h (virNetDevBandwidthCopy)
      (virNetDevBandwidthPlug): Likewise.
      * src/util/virnetdevmacvlan.h (virNetDevMacVLanCreate)
      (virNetDevMacVLanCreateWithVPortProfile)
      (virNetDevMacVLanDeleteWithVPortProfile)
      (virNetDevMacVLanRestartWithVPortProfile)
      (virNetDevMacVLanVPortProfileRegisterCallback): Likewise.
      * src/util/virnetdevopenvswitch.h (virNetDevOpenvswitchAddPort):
      Likewise.
      * src/util/virnetdevtap.h (virNetDevTapCreateInBridgePort):
      Likewise.
      * src/util/virnetdevvlan.h (virNetDevVlanEqual)
      (virNetDevVlanCopy): Likewise.
      * src/util/virnetdevvportprofile.h
      (virNetDevVPortProfileAssociate)
      (virNetDevVPortProfileDisassociate): Likewise.
      * src/util/virnetlink.h (virNetlinkEventRemoveCallback)
      (virNetlinkEventAddClient, virNetlinkEventRemoveClient):
      Likewise.
      * src/util/virnetdev.c (virNetDevSetMAC)
      (virNetDevReplaceMacAddress, virNetDevValidateConfig)
      (virNetDevReplaceNetConfig): Fix fallout.
      * src/util/virnetdevbandwidth.c (virNetDevBandwidthCopy)
      (virNetDevBandwidthPlug): Likewise.
      * src/util/virnetdevmacvlan.c (virNetDevMacVLanCreate)
      (virNetDevMacVLanCreateWithVPortProfile)
      (virNetDevMacVLanDeleteWithVPortProfile)
      (virNetDevMacVLanRestartWithVPortProfile)
      (virNetDevMacVLanVPortProfileRegisterCallback): Likewise.
      * src/util/virnetdevopenvswitch.c (virNetDevOpenvswitchAddPort):
      Likewise.
      * src/util/virnetdevtap.c (virNetDevTapCreateInBridgePort):
      Likewise.
      * src/util/virnetdevvlan.c (virNetDevVlanEqual)
      (virNetDevVlanCopy): Likewise.
      * src/util/virnetdevvportprofile.c
      (virNetDevVPortProfileAssociate)
      (virNetDevVPortProfileDisassociate)
      (virNetDevVPortProfileOpSetLink, virNetDevVPortProfileOpCommon)
      (virNetDevVPortProfileOp8021Qbg, virNetDevVPortProfileOp8021Qbh):
      Likewise.
      * src/util/virnetlink.c (virNetlinkEventRemoveCallback)
      (virNetlinkEventAddClient, virNetlinkEventRemoveClient):
      Likewise.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      955af4d4
  16. 11 7月, 2013 1 次提交
  17. 10 7月, 2013 1 次提交
  18. 14 6月, 2013 1 次提交
  19. 24 5月, 2013 1 次提交
  20. 14 5月, 2013 1 次提交
  21. 02 5月, 2013 1 次提交
    • M
      virutil: Move string related functions to virstring.c · 7c9a2d88
      Michal Privoznik 提交于
      The source code base needs to be adapted as well. Some files
      include virutil.h just for the string related functions (here,
      the include is substituted to match the new file), some include
      virutil.h without any need (here, the include is removed), and
      some require both.
      7c9a2d88
  22. 08 4月, 2013 1 次提交
    • D
      Avoid casts between unsigned char * and struct nlmsghdr · e95de74d
      Daniel P. Berrange 提交于
      The virNetlinkCommand() method takes an 'unsigned char **'
      parameter to be filled with the received netlink message.
      The callers then immediately cast this to 'struct nlmsghdr',
      triggering (bogus) warnings about increasing alignment
      requirements
      
      util/virnetdev.c: In function 'virNetDevLinkDump':
      util/virnetdev.c:1300:12: warning: cast increases required alignment of target type [-Wcast-align]
           resp = (struct nlmsghdr *)*recvbuf;
                  ^
      util/virnetdev.c: In function 'virNetDevSetVfConfig':
      util/virnetdev.c:1429:12: warning: cast increases required alignment of target type [-Wcast-align]
           resp = (struct nlmsghdr *)recvbuf;
      
      Since all callers cast to 'struct nlmsghdr' we can avoid
      the warning problem entirely by simply changing the
      signature of virNetlinkCommand to return a 'struct nlmsghdr **'
      instead of 'unsigned char **'. The way we do the cast inside
      virNetlinkCommand does not have any alignment issues.
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      e95de74d
  23. 02 4月, 2013 1 次提交
  24. 01 3月, 2013 1 次提交
    • M
      virnetdevmacvlan.c: Introduce mutex for macvlan creation · 1cf97c87
      Michal Privoznik 提交于
      Currently, after we removed the qemu driver lock, it may happen
      that two or more threads will start up a machine with macvlan and
      race over virNetDevMacVLanCreateWithVPortProfile(). However,
      there's a racy section in which we are generating a sequence of
      possible device names and detecting if they exits. If we found
      one which doesn't we try to create a device with that name.
      However, the other thread is doing just the same. Assume it will
      succeed and we must therefore fail. If this happens more than 5
      times (which in massive parallel startup surely will) we return
      -1 without any error reported. This patch is a simple hack to
      both of these problems. It introduces a mutex, so only one thread
      will enter the section, and if it runs out of possibilities,
      error is reported. Moreover, the number of retries is raised to 20.
      1cf97c87
  25. 21 12月, 2012 5 次提交
  26. 12 12月, 2012 1 次提交
    • 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
  27. 28 11月, 2012 1 次提交
  28. 02 11月, 2012 1 次提交
  29. 21 9月, 2012 1 次提交
  30. 22 8月, 2012 1 次提交
  31. 23 7月, 2012 1 次提交
    • O
      Desert the FSF address in copyright · f9ce7dad
      Osier Yang 提交于
      Per the FSF address could be changed from time to time, and GNU
      recommends the following now: (http://www.gnu.org/licenses/gpl-howto.html)
      
        You should have received a copy of the GNU General Public License
        along with Foobar.  If not, see <http://www.gnu.org/licenses/>.
      
      This patch removes the explicit FSF address, and uses above instead
      (of course, with inserting 'Lesser' before 'General').
      
      Except a bunch of files for security driver, all others are changed
      automatically, the copyright for securify files are not complete,
      that's why to do it manually:
      
        src/security/security_selinux.h
        src/security/security_driver.h
        src/security/security_selinux.c
        src/security/security_apparmor.h
        src/security/security_apparmor.c
        src/security/security_driver.c
      f9ce7dad
  32. 18 7月, 2012 1 次提交
  33. 17 7月, 2012 1 次提交
    • S
      Convert 'raw MAC address' usages to use virMacAddr · 387117ad
      Stefan Berger 提交于
      Introduce new members in the virMacAddr 'class'
      - virMacAddrSet: set virMacAddr from a virMacAddr
      - virMacAddrSetRaw: setting virMacAddr from raw 6 byte MAC address buffer
      - virMacAddrGetRaw: writing virMacAddr into raw 6 byte MAC address buffer
      - virMacAddrCmp: comparing two virMacAddr
      - virMacAddrCmpRaw: comparing a virMacAddr with a raw 6 byte MAC address buffer
      
      then replace raw MAC addresses by replacing
      
      - 'unsigned char *' with virMacAddrPtr
      - 'unsigned char ... [VIR_MAC_BUFLEN]' with virMacAddr
      
      and introduce usage of above functions where necessary.
      387117ad