1. 10 9月, 2019 3 次提交
    • L
      qemu: support unmanaged macvtap devices with <interface type='ethernet'> · 51d66b92
      Laine Stump 提交于
      Traditionally, macvtap devices are supported using <interface
      type='direct'>, but that type requires specifying a source device name
      and macvtap mode which can't be altered after the initial device
      creation (and may not even be available to the management software
      that's creating the XML config to feed to libvirt).
      
      But the attributes in the <source> are essentially describing how the
      device will be connected to the network, and if libvirt is to be
      supplied with the name of a macvtap device that has already been
      created, that device will also already be connected to the network
      (and the connection can't be changed). Thus it seems more appropriate
      to use type='ethernet', which was created explicitly for this purpose
      - for devices that have already been (or will be) connected to the
      external network by someone/something outside of libvirt. The fact
      that it is a *macv*tap rather than a contentional tap device is just a
      detail.
      
      This patch supports using an existing macvtap device with <interface
      type='ethernet'> by checking the supplied target dev name to see if it
      is a macvtap device and, when this is the case, calling
      virNetDevMacVLanTapOpen() instead of virNetDevTapCreate(). For
      consistency, this is only done when target managed='no'.
      
      Resolves: https://bugzilla.redhat.com/1723367 (partially)
      Signed-off-by: NLaine Stump <laine@redhat.com>
      Reviewed-by: NDaniel P. Berrangé <berrange@redhat.com>
      51d66b92
    • L
      qemu: support unmanaged target tap dev for <interface type='ethernet'> · 7cd0911e
      Laine Stump 提交于
      If managed='no', then the tap device must already exist, and setting
      of MAC address and online status (IFF_UP) is skipped.
      
      NB: we still set IFF_VNET_HDR and IFF_MULTI_QUEUE as appropriate,
      because those bits must be properly set in the TUNSETIFF we use to set
      the tap device name of the handle we've opened - if IFF_VNET_HDR has
      not been set and we set it the request will be honored even when
      running libvirtd unprivileged; if IFF_MULTI_QUEUE is requested to be
      different than how it was created, that will result in an error from
      the kernel. This means that you don't need to pay attention to
      IFF_VNET_HDR when creating the tap devices, but you *do* need to set
      IFF_MULTI_QUEUE if you're going to use multiple queues for your tap
      device.
      
      NB2: /dev/vhost-net normally has permissions 600, so it can't be
      opened by an unprivileged process. This would normally cause a warning
      message when using a virtio net device from an unprivileged
      libvirtd. I've found that setting the permissions for /dev/vhost-net
      permits unprivileged libvirtd to use vhost-net for virtio devices, but
      have no idea what sort of security implications that has. I haven't
      changed libvrit's code to avoid *attempting* to open /dev/vhost-net -
      if you are concerned about the security of opening up permissions of
      /dev/vhost-net (probably a good idea at least until we ask someone who
      knows about the code) then add <driver name='qemu'/> to the interface
      definition and you'll avoid the warning message.
      
      Note that virNetDevTapCreate() is the correct function to call in the
      case of an existing device, because the same ioctl() that creates a
      new tap device will also open an existing tap device.
      
      Resolves: https://bugzilla.redhat.com/1723367 (partially)
      Signed-off-by: NLaine Stump <laine@redhat.com>
      Reviewed-by: NDaniel P. Berrangé <berrange@redhat.com>
      7cd0911e
    • L
      qemu: reorganize qemuInterfaceEthernetConnect() · 3c049fad
      Laine Stump 提交于
      This just moves around a few things in qemuInterfaceConnect() with no
      functional difference (except that a few failures that would have
      previously resulted in a "success" audit log will now properly produce
      a "fail" audit). The change is so that adding support for unmanaged
      tap/macvtap devices will be more easily reviewable.
      Signed-off-by: NLaine Stump <laine@redhat.com>
      Reviewed-by: NDaniel P. Berrangé <berrange@redhat.com>
      3c049fad
  2. 06 9月, 2019 1 次提交
  3. 13 8月, 2019 1 次提交
    • L
      util: allow tap-based guest interfaces to have MAC address prefix 0xFE · a60ee914
      Laine Stump 提交于
      Back in July 2010, commit 6ea90b84 (meant to resolve
      https://bugzilla.redhat.com/571991 ) added code to set the MAC address
      of any tap device to the associated guest interface's MAC, but with
      the first byte replaced with 0xFE. This was done in order to assure
      that
      
      1) the tap MAC and guest interface MAC were different (otherwise L2
         forwarding through the tap would not work, and the kernel would
         repeatedly issue a warning stating as much).
      
      2) any bridge device that had one of these taps attached would *not*
         take on the MAC of the tap (leading to network instability as
         guests started and stopped)
      
      A couple years later, https://bugzilla.redhat.com/798467 was filed,
      complaining that a user could configure a tap-based guest interface to
      have a MAC address that itself had a first byte of 0xFE, silently
      (other than the kernel warning messages) resulting in a non-working
      configuration. This was fixed by commit 5d571045, which logged an
      error and failed the guest start / interface attach if the MAC's first
      byte was 0xFE.
      
      Although this restriction only reduces the potential pool of MAC
      addresses from 2^46 (last two bits of byte 1 must be set to 10) by
      2^32 (still 4 orders of magnitude larger than the entire IPv4 address
      space), it also means that management software that autogenerates MAC
      addresses must have special code to avoid an 0xFE prefix. Now after 7
      years, someone has noticed this restriction and requested that we
      remove it.
      
      So instead of failing when 0xFE is found as the first byte, this patch
      removes the restriction by just replacing the first byte in the tap
      device MAC with 0xFA if the first byte in the guest interface is
      0xFE. 0xFA is the next-highest value that still has 10 as the lowest
      two bits, and still
      
      2) meets the requirement of "tap MAC must be different from guest
         interface MAC", and
      
      3) is high enough that there should never be an issue of the attached
         bridge device taking on the MAC of the tap.
      
      The result is that *any* MAC can be chosen by management software
      (although it would still not work correctly if a multicast MAC (lowest
      bit of first byte set to 1) was chosen), but that's a different
      issue).
      Signed-off-by: NLaine Stump <laine@redhat.com>
      Reviewed-by: Michal Privoznik <mprivozn@redhat.com
      a60ee914
  4. 30 4月, 2019 1 次提交
  5. 18 4月, 2019 1 次提交
  6. 14 2月, 2019 1 次提交
  7. 25 1月, 2019 1 次提交
  8. 17 12月, 2018 1 次提交
    • D
      qemu: use line breaks in command line args written to log · 07c9d660
      Daniel P. Berrangé 提交于
      The QEMU command line arguments are very long and currently all written
      on a single line to /var/log/libvirt/qemu/$GUEST.log. This introduces
      logic to add line breaks after every env variable and "-" optional
      argument, and every positional argument. This will create a clearer log
      file, which will in turn present better in bug reports when people cut +
      paste from the log into a bug comment.
      
      An example log file entry now looks like this:
      
        2018-12-14 12:57:03.677+0000: starting up libvirt version: 5.0.0, qemu version: 3.0.0qemu-3.0.0-1.fc29, kernel: 4.19.5-300.fc29.x86_64, hostname: localhost.localdomain
        LC_ALL=C \
        PATH=/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin \
        HOME=/home/berrange \
        USER=berrange \
        LOGNAME=berrange \
        QEMU_AUDIO_DRV=none \
        /usr/bin/qemu-system-ppc64 \
        -name guest=guest,debug-threads=on \
        -S \
        -object secret,id=masterKey0,format=raw,file=/home/berrange/.config/libvirt/qemu/lib/domain-33-guest/master-key.aes \
        -machine pseries-2.10,accel=tcg,usb=off,dump-guest-core=off \
        -m 1024 \
        -realtime mlock=off \
        -smp 1,sockets=1,cores=1,threads=1 \
        -uuid c8a74977-ab18-41d0-ae3b-4041c7fffbcd \
        -display none \
        -no-user-config \
        -nodefaults \
        -chardev socket,id=charmonitor,fd=23,server,nowait \
        -mon chardev=charmonitor,id=monitor,mode=control \
        -rtc base=utc \
        -no-shutdown \
        -boot strict=on \
        -device qemu-xhci,id=usb,bus=pci.0,addr=0x1 \
        -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x2 \
        -sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,resourcecontrol=deny \
        -msg timestamp=on
        2018-12-14 12:57:03.730+0000: shutting down, reason=failed
      Signed-off-by: NDaniel P. Berrangé <berrange@redhat.com>
      07c9d660
  9. 14 12月, 2018 1 次提交
    • D
      Remove all Author(s): lines from source file headers · 60046283
      Daniel P. Berrangé 提交于
      In many files there are header comments that contain an Author:
      statement, supposedly reflecting who originally wrote the code.
      In a large collaborative project like libvirt, any non-trivial
      file will have been modified by a large number of different
      contributors. IOW, the Author: comments are quickly out of date,
      omitting people who have made significant contribitions.
      
      In some places Author: lines have been added despite the person
      merely being responsible for creating the file by moving existing
      code out of another file. IOW, the Author: lines give an incorrect
      record of authorship.
      
      With this all in mind, the comments are useless as a means to identify
      who to talk to about code in a particular file. Contributors will always
      be better off using 'git log' and 'git blame' if they need to  find the
      author of a particular bit of code.
      
      This commit thus deletes all Author: comments from the source and adds
      a rule to prevent them reappearing.
      
      The Copyright headers are similarly misleading and inaccurate, however,
      we cannot delete these as they have legal meaning, despite being largely
      inaccurate. In addition only the copyright holder is permitted to change
      their respective copyright statement.
      Reviewed-by: NErik Skultety <eskultet@redhat.com>
      Signed-off-by: NDaniel P. Berrangé <berrange@redhat.com>
      60046283
  10. 27 6月, 2018 1 次提交
  11. 04 5月, 2018 1 次提交
  12. 16 4月, 2018 1 次提交
  13. 12 4月, 2018 1 次提交
  14. 23 5月, 2017 1 次提交
    • L
      Revert "qemu: propagate bridge MTU into qemu "host_mtu" option" · 77780a29
      Laine Stump 提交于
      This reverts commit 2841e675.
      
      It turns out that adding the host_mtu field to the PCI capabilities in
      the guest bumps the length of PCI capabilities beyond the 32 byte
      boundary, so the virtio-net device gets 64 bytes of ioport space
      instead of 32, which offsets the address of all the other following
      devices. Migration doesn't work very well when the location and length
      of PCI capabilities of devices is changed between source and
      destination.
      
      This means that we need to make sure that the absence/presence of
      host_mtu on the qemu commandline always matches between source and
      destination, which means that we need to make setting of host_mtu an
      opt-in thing (it can't happen automatically when the bridge being used
      has a non-default MTU, which is what commit 2841e675 implemented).
      
      I do want to re-implement this feature with an <mtu auto='on'/>
      setting, but probably won't backport that to any stable branches, so
      I'm first reverting the original commit, and that revert can be pushed
      to the few releases that have been made since the original (3.1.0 -
      3.3.0)
      
      Resolves: https://bugzilla.redhat.com/1449346
      77780a29
  15. 28 4月, 2017 1 次提交
  16. 24 4月, 2017 1 次提交
  17. 21 4月, 2017 1 次提交
  18. 08 2月, 2017 2 次提交
    • L
      qemu: propagate bridge MTU into qemu "host_mtu" option · 2841e675
      Laine Stump 提交于
      libvirt was able to set the host_mtu option when an MTU was explicitly
      given in the interface config (with <mtu size='n'/>), set the MTU of a
      libvirt network in the network config (with the same named
      subelement), and would automatically set the MTU of any tap device to
      the MTU of the network.
      
      This patch ties that all together (for networks based on tap devices
      and either Linux host bridges or OVS bridges) by learning the MTU of
      the network (i.e. the bridge) during qemuInterfaceBridgeConnect(), and
      returning that value so that it can then be passed to
      qemuBuildNicDevStr(); qemuBuildNicDevStr() then sets host_mtu in the
      interface's commandline options.
      
      The result is that a higher MTU for all guests connecting to a
      particular network will be plumbed top to bottom by simply changing
      the MTU of the network (in libvirt's config for libvirt-managed
      networks, or directly on the bridge device for simple host bridges or
      OVS bridges managed outside of libvirt).
      
      One question I have about this - it occurred to me that in the case of
      migrating a guest from a host with an older libvirt to one with a
      newer libvirt, the guest may have *not* had the host_mtu option on the
      older machine, but *will* have it on the newer machine. I'm curious if
      this could lead to incompatibilities between source and destination (I
      guess it all depends on whether or not the setting of host_mtu has a
      practical effect on a guest that is already running - Maxime?)
      
      Likewise, we could run into problems when migrating from a newer
      libvirt to older libvirt - The guest would have been told of the
      higher MTU on the newer libvirt, then migrated to a host that didn't
      understand <mtu size='blah'/>. (If this really is a problem, it would
      be a problem with or without the current patch).
      2841e675
    • L
      util: add MTU arg to virNetDevTapCreateInBridgePort() · dd8ac030
      Laine Stump 提交于
      virNetDevTapCreateInBridgePort() has always set the new tap device to
      the current MTU of the bridge it's being attached to. There is one
      case where we will want to set the new tap device to a different
      (usually larger) MTU - if that's done with the very first device added
      to the bridge, the bridge's MTU will be set to the device's MTU. This
      patch allows for that possibility by adding "int mtu" to the arg list
      for virNetDevTapCreateInBridgePort(), but all callers are sending -1,
      so it doesn't yet have any effect.
      
      Since the requested MTU isn't necessarily what is used in the end (for
      example, if there is no MTU requested, the tap device will be set to
      the current MTU of the bridge), and the hypervisor may want to know
      the actual MTU used, we also return the actual MTU to the caller (if
      actualMTU is non-NULL).
      dd8ac030
  19. 26 8月, 2016 2 次提交
    • L
      qemu: set tap device online for type='ethernet' · 07262221
      Laine Stump 提交于
      When support for auto-creating tap devices was added to <interface
      type='ethernet'> in commit 9c17d6, the code assumed that
      virNetDevTapCreate() would honor the VIR_NETDEV_TAP__CREATE_IFUP flag
      that is supported by virNetDevTapCreateInBridgePort(). That isn't the
      case - the latter function performs several operations, and one of
      them is setting the tap device online. But virNetDevTapCreate() *only*
      creates the tap device, and relies on the caller to do everything
      else, so qemuInterfaceEthernetConnect() needs to call
      virNetDevSetOnline() after the device is successfully created.
      07262221
    • V
      qemu: fix ethernet network type ip/route assign · 5f243153
      Vasiliy Tolstov 提交于
      The call to virNetDevIPInfoAddToDev() that sets up tap device IP
      addresses and routes was somehow incorrectly placed in
      qemuInterfaceStopDevice() instead of qemuInterfaceStartDevice() in
      commit fe8567f6.  This fixes that error by moving the call to
      virNetDevIPInfoAddToDev() to qemuInterfaceStartDevice().
      Signed-off-by: NVasiliy Tolstov <v.tolstov@selfip.ru>
      5f243153
  20. 02 7月, 2016 1 次提交
  21. 27 6月, 2016 2 次提交
  22. 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
  23. 30 4月, 2016 1 次提交
    • L
      Revert "qemu domain allow to set ip address, peer address and route" · 9b643ae8
      Laine Stump 提交于
      This reverts commit 6e244c65, which
      added support to qemu for the "peer" attribute in domain interface <ip>
      elements.
      
      It's being removed temporarily for the release of libvirt 1.3.4
      because the feature doesn't work, and there are concerns that it may
      need to be modified in an externally visible manner which could create
      backward compatibility problems.
      
       Conflicts:
         tests/qemuxml2argvmock.c - a mock of virNetDevSetOnline() was added
         which may be assumed by other tests added since the original commit,
         so it isn't being reverted.
      9b643ae8
  24. 13 4月, 2016 1 次提交
  25. 08 4月, 2016 1 次提交
  26. 23 3月, 2016 1 次提交
  27. 17 2月, 2016 3 次提交
  28. 02 9月, 2015 1 次提交
    • J
      qemu: add udp interface support · 5c668a78
      Jonathan Toppins 提交于
      Adds a new interface type using UDP sockets, this seems only applicable
      to QEMU but have edited tree-wide to support the new interface type.
      
      The interface type required the addition of a "localaddr" (local
      address), this then maps into the following xml and qemu call.
      
      <interface type='udp'>
        <mac address='52:54:00:5c:67:56'/>
        <source address='127.0.0.1' port='11112'>
          <local address='127.0.0.1' port='22222'/>
        </source>
        <model type='virtio'/>
        <address type='pci' domain='0x0000' bus='0x00' slot='0x07' function='0x0'/>
      </interface>
      
      QEMU call:
      	-net socket,udp=127.0.0.1:11112,localaddr=127.0.0.1:22222
      
      Notice the xml "local" entry becomes the "localaddr" for the qemu call.
      
      reference:
      http://lists.gnu.org/archive/html/qemu-devel/2011-11/msg00629.htmlSigned-off-by: NJonathan Toppins <jtoppins@cumulusnetworks.com>
      Signed-off-by: NJán Tomko <jtomko@redhat.com>
      5c668a78
  29. 22 4月, 2015 1 次提交
    • L
      qemu: set macvtap physdevs online when macvtap is set online · 38172ed8
      Laine Stump 提交于
      A further fix for:
      
        https://bugzilla.redhat.com/show_bug.cgi?id=1113474
      
      Since there is no possibility that any type of macvtap will work if
      the parent physdev it's attached to is offline, we should bring the
      physdev online at the same time as the macvtap. When taking the
      macvtap offline, it's also necessary to take the physdev offline for
      macvtap passthrough mode (because the physdev has the same MAC address
      as the macvtap device, so could potentially cause problems with
      misdirected packets during migration, as outlined in commits 829770
      and 879c13). We can't set the physdev offline for other macvtap modes
      1) because there may be other macvtap devices attached to the same
      physdev (and/or the host itself may be using the device) in the other
      modes whereas passthrough mode is exclusive to one macvtap at a time,
      and 2) there's no practical reason to do so anyway.
      38172ed8
  30. 15 12月, 2014 1 次提交
    • L
      qemu: add/remove bridge fdb entries as guest CPUs are started/stopped · 44292e48
      Laine Stump 提交于
      When libvirt is managing a bridge's forwarding database (FDB)
      (macTableManager='libvirt'), if we add FDB entries for a new guest
      interface even before the qemu process is created, then in the case of
      a migration any other guest attached to the "destination" bridge will
      have its traffic immediately sent to the destination of the migration
      even while the source domain is still running (and the destination, of
      course, isn't). To make sure that traffic from other guests on the new
      host continues flowing to the old guest until the new one is ready, we
      have to wait until the new guest CPUs are started to add the FDB
      entries.
      
      Conversely, we need to remove the FDB entries from the bridge any time
      the guest CPUs are stopped; among other things, this will assure
      proper operation during a post-copy migration (which is just the
      opposite of the problem described in the previous paragraph).
      44292e48
  31. 14 12月, 2014 1 次提交
    • L
      qemu: add a qemuInterfaceStopDevices(), called when guest CPUs stop · c5a54917
      Laine Stump 提交于
      We now have a qemuInterfaceStartDevices() which does the final
      activation needed for the host-side tap/macvtap devices that are used
      for qemu network connections. It will soon make sense to have the
      converse qemuInterfaceStopDevices() which will undo whatever was done
      during qemuInterfaceStartDevices().
      
      A function to "stop" a single device has also been added, and is
      called from the appropriate place in qemuDomainDetachNetDevice(),
      although this is currently unnecessary - the device is going to
      immediately be deleted anyway, so any extra "deactivation" will be for
      naught. The call is included for completeness, though, in anticipation
      that in the future there may be some required action that *isn't*
      nullified by deleting the device.
      
      This patch is a part of a more complete fix for:
      
        https://bugzilla.redhat.com/show_bug.cgi?id=1081461
      c5a54917
  32. 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