1. 12 8月, 2017 1 次提交
    • L
      util: make virPCIGetNetName() more versatile · b3b5aa75
      Laine Stump 提交于
      A single PCI device may have multiple netdevs associated with it. Each
      of those netdevs will have a different phys_port_id entry in
      sysfs. This patch modifies virPCIGetNetName() to allow selecting one
      of the potential many netdevs in two different ways:
      
      1) by setting the "idx" argument, the caller can select the 1st (0),
      2nd (1), etc. netdev from the PCI device's net subdirectory.
      
      2) If the physPortID arg is set (to a null-terminated string) then
      virPCIGetNetName() returns the netdev that has that phys_port_id in
      the sysfs file of the same name in the netdev's directory.
      b3b5aa75
  2. 04 5月, 2017 1 次提交
    • E
      mdev: Fix daemon crash on domain shutdown after reconnect · 92e30a4d
      Erik Skultety 提交于
      The problem resides in virHostdevUpdateActiveMediatedDevices which gets
      called during qemuProcessReconnect. The issue here is that
      virMediatedDeviceListAdd takes a pointer to the item to be added to the
      list to which VIR_APPEND_ELEMENT is used, which also clears the pointer.
      However, in this case only the local copy of the pointer got cleared,
      leaving the original pointing to valid memory. To sum it up, during
      cleanup phase, the original pointer is freed and the daemon crashes
      basically any time it would access it.
      
      Backtrace:
      0x00007ffff3ccdeba in __strcmp_sse2_unaligned
      0x00007ffff72a444a in virMediatedDeviceListFindIndex
      0x00007ffff7241446 in virHostdevReAttachMediatedDevices
      0x00007fffc60215d9 in qemuHostdevReAttachMediatedDevices
      0x00007fffc60216dc in qemuHostdevReAttachDomainDevices
      0x00007fffc6046e6f in qemuProcessStop
      0x00007fffc6091596 in processMonitorEOFEvent
      0x00007fffc6091793 in qemuProcessEventHandler
      0x00007ffff7294bf5 in virThreadPoolWorker
      0x00007ffff7294184 in virThreadHelper
      0x00007ffff3fdc3c4 in start_thread () from /lib64/libpthread.so.0
      0x00007ffff3d269cf in clone () from /lib64/libc.so.6
      
      Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1446455Signed-off-by: NErik Skultety <eskultet@redhat.com>
      Reviewed-by: NLaine Stump <laine@laine.org>
      92e30a4d
  3. 27 3月, 2017 6 次提交
    • L
    • L
      util: after hostdev assignment, restore VF MAC address via setting admin MAC · d6ef331f
      Laine Stump 提交于
      It takes longer to explain this than to fix it...
      
      In the past we weren't able to save the VF's own MAC address *at all*
      when using it for hostdev assignment, because we had already unbound
      the VF from the host net driver prior to saving its config. With the
      previous patch, that problem has been solved, so we now have the VF's
      MAC address saved and can move on to the *next* problem, which is twofold:
      
      1) during teardown we restore the config before we've re-bound, so the
         VF doesn't have a net driver, and thus we can't set its MAC address
         directly.
      
      2) even if we delay restoring the config until the VF is bound to a
         net driver, the request to set its MAC address would fail, since
         (during device setup) we had set the "admin MAC" for the VF via an
         RTM_SETLINK to the PF - once you've set the admin MAC for a VF, the
         VF driver (either on host or on guest) is not allowed to change the
         VF's MAC address "forever" (well, until you reload the PF driver,
         but that requires destroying and recreating every single VF, which
         isn't something you can require).
      
      The solution is to keep the restoration of config at the same place,
      but to set the *admin MAC* to the address you want the VF to have -
      when the VF net driver is later initialized (as a part of re-binding
      to the VF net driver) its MAC will be initialized to the current value
      of the admin MAC.
      d6ef331f
    • L
      util: save hostdev network device config before unbinding from host driver · cceada57
      Laine Stump 提交于
      In order to properly restore the original state of an SRIOV VF when
      we're finished with it, we need to save the MAC address of the VF
      itself (not just the admin MAC address for the VF that is stored in
      the PF). But that can only be done when the VF is still bound to the
      host's netdev driver, and we have always done the saving of device
      config after the VF is already bound to vfio-pci. This patch prepares
      us for adding a save of the VF's MAC by calling the function that
      saves netconfig earlier in the device preparation, before we've
      unbound it from the host netdev driver.
      cceada57
    • L
      util: replace virHostdevNetConfigReplace with ...(Save|Set)NetConfig() · b684734b
      Laine Stump 提交于
      These two operations will need to be separated so that saving of the
      original config is done before detaching the host net driver, and
      setting the new config is done after attaching vfio-pci. This patch
      splits the single function into two, but for now calls them together
      (to make bisecting easier if there is a regression).
      b684734b
    • L
      util: use new virNetDev*NetConfig() functions for hostdev setup/teardown · 9c004d55
      Laine Stump 提交于
      virHostdevNetConfigReplace() and virHostdevNetConfigRestore() are
      modified to use the new virNetDev*NetConfig() functions.
      
      Note that due to the VF's original MAC addresses being saved after it
      has already been un-bound from the host net driver, the actual current
      VF MAC address won't be saved (because it no longer exists) - only the
      "admin MAC" will be saved. This reflects existing behavior that will
      be fixed in an upcoming patch.
      9c004d55
    • E
      hostdev: Maintain a driver list of active mediated devices · a4a39d90
      Erik Skultety 提交于
      Keep track of the assigned mediated devices the same way we do it for
      the rest of hostdevs. Methods like 'Prepare', 'Update', and 'ReAttach'
      are introduced by this patch.
      Signed-off-by: NErik Skultety <eskultet@redhat.com>
      a4a39d90
  4. 24 3月, 2017 2 次提交
    • L
      util: change virPCIGetNetName() to not return error if device has no net name · d6ee56d7
      Laine Stump 提交于
      ...and cleanup the callers to report it when it *is* an error.
      
      In many cases It's useful for virPCIGetNetName() to not log an error
      and simply return a NULL pointer when the given device isn't bound to
      a net driver (e.g. we're looking at a VF that is permanently bound to
      vfio-pci). The existing code would silently return an error in this
      case, which could eventually lead to the dreaded "An error occurred
      but the cause is unknown" log message.
      
      This patch changes virPCIGetNetName() to still return success if the
      device simply isn't bound to a net driver, and adjusts all the callers
      that require a non-null netname to check for that condition and log an
      error when it happens.
      d6ee56d7
    • L
      util: use cleanup label consistently in virHostdevNetConfigReplace() · 19c5db74
      Laine Stump 提交于
      This will make an upcoming functional change more straightforward.
      19c5db74
  5. 23 3月, 2017 3 次提交
  6. 24 1月, 2017 1 次提交
  7. 25 11月, 2016 1 次提交
    • E
      util: Management routines for scsi_host devices · 629544be
      Eric Farman 提交于
      For a new hostdev type='scsi_host' we have a number of
      required functions for managing, adding, and removing the
      host device to/from guests.  Provide the basic infrastructure
      for these tasks.
      
      The name "SCSIVHost" (and its variants) is chosen to avoid
      conflicts with existing code named "SCSIHost" to refer to
      a hostdev type='scsi' protcol='none'.
      Signed-off-by: NEric Farman <farman@linux.vnet.ibm.com>
      629544be
  8. 24 11月, 2016 1 次提交
  9. 22 11月, 2016 2 次提交
  10. 02 9月, 2016 1 次提交
  11. 20 5月, 2016 1 次提交
  12. 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
  13. 01 4月, 2016 1 次提交
    • A
      Revert "hostdev: Use actual device when reattaching" · fbd4db79
      Andrea Bolognani 提交于
      This reverts commit ee4cfb56.
      
      Since we're still not persisting our bookkeeping lists across
      daemon restarts, we might have lost some information
      virPCIDeviceReattach() relies on, for example whether the
      device needs to be unbound from the stub driver.
      
      As a result, if the daemon has been restarted in the meantime,
      the device might end up remaining bound to the stub driver even
      after 'virsh nodedev-reattach' or similar has been called, with
      no way of giving it back to the host short of messing with
      sysfs behind libvirt's back.
      
      Revert back to the previous behavior of always trying to bind
      the device to the host driver, regardless of its status when it
      was detached, until persistent bookkeeping lists have been
      implemented.
      fbd4db79
  14. 23 3月, 2016 5 次提交
    • A
      hostdev: Use actual device when reattaching · ee4cfb56
      Andrea Bolognani 提交于
      Instead of forcing the values for the unbind_from_stub, remove_slot
      and reprobe properties, look up the actual device and use that when
      calling virPCIDeviceReattach().
      
      This ensures the device is restored to its original state after
      reattach: for example, if it was not bound to any driver before
      detach, it will not be bound forcefully during reattach.
      ee4cfb56
    • A
      hostdev: Save netdev configuration of actual device · c3e2f6e3
      Andrea Bolognani 提交于
      We would be just fine looking up the information in pcidevs most
      of the time; however, some corner cases would not be handled
      properly, so look up the actual device instead.
      c3e2f6e3
    • A
      hostdev: Streamline device ownership tracking · 81128609
      Andrea Bolognani 提交于
      After this patch, ownership of virPCIDevice instances is very easy
      to keep track of: for each host PCI device, the only instance that
      actually matters is the one inside one of the bookkeeping list.
      
      Whenever some operation needs to be performed on a PCI device, the
      actual device is looked up first; when this is not the case, a
      comment explains the reason.
      81128609
    • A
      hostdev: Stop early if unmanaged devices have not been detached · 6da6bf2f
      Andrea Bolognani 提交于
      Unmanaged devices, as the name suggests, are not detached
      automatically from the host by libvirt before being attached to a
      guest: it's the user's responsability to detach them manually
      beforehand. If that preliminary step has not been performed, the
      attach operation can't complete successfully.
      
      Instead of relying on the lower layers to error out with cryptic
      messages such as
      
        error: Failed to attach device from /tmp/hostdev.xml
        error: Path '/dev/vfio/12' is not accessible: No such file or directory
      
      prevent the situation altogether and provide the user with a more
      useful error message.
      6da6bf2f
    • A
      hostdev: Detect untracked inactive devices · df490e7c
      Andrea Bolognani 提交于
      Unmanaged devices are attached to guests in two steps: first,
      the device is detached from the host and marked as inactive;
      subsequently, it is marked as active and attached to the guest.
      
      If the daemon is restarted between these two operations, we lose
      track of the inactive device.
      
      Steps 5 and 6 of virHostdevPreparePCIDevices() already subtly
      take care of this situation, but some planned changes will make
      it so that's no longer the case. Plus, explicit is always better
      than implicit.
      df490e7c
  15. 15 3月, 2016 3 次提交
    • A
      hostdev: Add more comments · 5fc68bd4
      Andrea Bolognani 提交于
      These comments explain the difference between a virPCIDevice
      instance used for lookups and an actual device instance; some
      information is also provided for specific uses.
      5fc68bd4
    • A
      hostdev: Use consistent variable names · 800dd16d
      Andrea Bolognani 提交于
      This is not just a cosmetic change: the name of the variable now
      gives a hint about what it is supposed to be used for.
      800dd16d
    • A
      hostdev: Remove virHostdevGetActivePCIHostDeviceList() · 4cdbff3d
      Andrea Bolognani 提交于
      virHostdevGetPCIHostDeviceList() is similar but does not filter out
      devices that are not in the active list; that said, we are looking
      up the device in the active list just a few lines after anyway, so
      we might as well just keep a single function around.
      
      This also helps stress the fact the objects contained in pcidevs are
      only for looking up the actual devices, which is something later
      commits will make even more explicit.
      4cdbff3d
  16. 14 3月, 2016 6 次提交
  17. 08 3月, 2016 4 次提交
    • A
      hostdev: Remove explicit NULL checks · 12a16314
      Andrea Bolognani 提交于
      NULL checks are performed implicitly in the rest of the module,
      including other allocations in the very same function.
      12a16314
    • A
      hostdev: Fix indentation · a54de18a
      Andrea Bolognani 提交于
      a54de18a
    • A
      hostdev: Remove inaccurate comment · a67b14a9
      Andrea Bolognani 提交于
      The comment claimed that virPCIDeviceReattach() does not reattach
      a device to the host driver; except it actually does, so the
      comment is just confusing and we're better off removing it.
      a67b14a9
    • A
      hostdev: Make comments easier to change later · be70acb7
      Andrea Bolognani 提交于
      Replace the term "loop" with the more generic "step". This allows us
      to be more flexible and eg. have a step that consists in a single
      function call.
      
      Don't include the number of steps in the first comment of the
      function, so that we can add or remove steps without having to worry
      about keeping that comment in sync.
      
      For the same reason, remove the summary contained in that comment.
      
      Clean up some weird vertical spacing while we're at it.
      be70acb7