1. 05 12月, 2017 1 次提交
  2. 11 4月, 2017 1 次提交
  3. 11 1月, 2017 2 次提交
    • L
      conf: aggregate multiple pcie-root-ports onto a single slot · 147ebe6d
      Laine Stump 提交于
      Set the VIR_PCI_CONNECT_AGGREGATE_SLOT flag for pcie-root-ports so
      that they will be assigned to all the functions on a slot.
      
      Some qemu test case outputs had to be adjusted due to the
      pcie-root-ports now being put on multiple functions.
      147ebe6d
    • L
      qemu: use virDomainPCIAddressSetAllMulti() to set multi when needed · 8f400871
      Laine Stump 提交于
      If there are multiple devices assigned to the different functions of a
      single PCI slot, they will not work properly if the device at function
      0 doesn't have its "multi" attribute turned on, so it makes sense for
      libvirt to turn it on during PCI address assignment. Setting multi
      then assures that the new setting is stored in the config (so it will
      be used next time the domain is started), preventing any potential
      problems in the case that a future change in the configuration
      eliminates the devices on all non-0 functions (multi will still be set
      for function 0 even though it is the only function in use on the slot,
      which has no useful purpose, but also doesn't cause any problems).
      
      (NB: If we were to instead just decide on the setting for
      multifunction at runtime, a later removal of the non-0 functions of a
      slot would result in a silent change in the guest ABI for the
      remaining device on function 0 (although it may seem like an
      inconsequential guest ABI change, it *is* a guest ABI change to turn
      off the multi bit).)
      8f400871
  4. 15 11月, 2016 6 次提交
    • L
      qemu: initially reserve one open pcie-root-port for hotplug · 70d15c9a
      Laine Stump 提交于
      For machinetypes with a pci-root bus (all legacy PCI), libvirt will
      make a "fake" reservation for one extra slot prior to assigning
      addresses to unaddressed PCI endpoint devices in the domain. This will
      trigger auto-adding of a pci-bridge for the final device to be
      assigned an address *if that device would have otherwise instead been
      the last device on the last available pci-bridge*; thus it assures
      that there will always be at least one slot left open in the domain's
      bus topology for expansion (which is important both for hotplug (since
      a new pci-bridge can't be added while the guest is running) as well as
      for offline additions to the config (since adding a new device might
      otherwise in some cases require re-addressing existing devices, which
      we want to avoid)).
      
      It's important to note that for the above case (legacy PCI), we must
      check for the special case of all slots on all buses being occupied
      *prior to assigning any addresses*, and avoid attempting to reserve
      the extra address in that case, because there is no free address in
      the existing topology, so no place to auto-add a pci-bridge for
      expansion (i.e. it would always fail anyway). Since that condition can
      only be reached by manual intervention, this is acceptable.
      
      For machinetypes with pcie-root (Q35, aarch64 virt), libvirt's
      methodology for automatically expanding the bus topology is different
      - pcie-root-ports are plugged into slots (soon to be functions) of
      pcie-root as needed, and the new endpoint devices are assigned to the
      single slot in each pcie-root-port. This is done so that the devices
      are, by default, hotpluggable (the slots of pcie-root don't support
      hotplug, but the single slot of the pcie-root-port does). Since
      pcie-root-ports can only be plugged into pcie-root, and we don't
      auto-assign endpoint devices to the pcie-root slots, this means
      topology expansion doesn't compete with endpoint devices for slots, so
      we don't need to worry about checking for all "useful" slots being
      free *prior* to assigning addresses to new endpoint devices - as a
      matter of fact, if we attempt to reserve the open slots before the
      used slots, it can lead to errors.
      
      Instead this patch just reserves one slot for a "future potential"
      PCIe device after doing the assignment for actual devices, but only
      if the only PCI controller defined prior to starting address
      assignment was pcie-root, and only if we auto-added at least one PCI
      controller during address assignment. This assures two things:
      
      1) that reserving the open slots will only be done when the domain is
         initially defined, never at any time after, and
      
      2) that if the user understands enough about PCI controllers that they
         are adding them manually, that we don't mess up their plan by
         adding extras - if they know enough to add one pcie-root-port, or
         to manually assign addresses such that no pcie-root-ports are
         needed, they know enough to add extra pcie-root-ports if they want
         them (this could be called the "libguestfs clause", since
         libguestfs needs to be able to create domains with as few
         devices/controllers as possible).
      
      This is set to reserve a single free port for now, but could be
      increased in the future if public sentiment goes in that direction
      (it's easy to increase later, but essentially impossible to decrease)
      70d15c9a
    • L
      qemu: don't force-add a dmi-to-pci-bridge just on principle · 80723220
      Laine Stump 提交于
      Now the a dmi-to-pci-bridge is automatically added just as it's needed
      (when a pci-bridge is being added), we no longer have any need to
      force-add one to every single Q35 domain.
      80723220
    • L
      qemu: auto-add pcie-root-port/dmi-to-pci-bridge controllers as needed · 0702f48e
      Laine Stump 提交于
      Previously libvirt would only add pci-bridge devices automatically
      when an address was requested for a device that required a legacy PCI
      slot and none was available. This patch expands that support to
      dmi-to-pci-bridge (which is needed in order to add a pci-bridge on a
      machine with a pcie-root), and pcie-root-port (which is needed to add
      a hotpluggable PCIe device). It does *not* automatically add
      pcie-switch-upstream-ports or pcie-switch-downstream-ports (and
      currently there are no plans for that).
      
      Given the existing code to auto-add pci-bridge devices, automatically
      adding pcie-root-ports is fairly straightforward. The
      dmi-to-pci-bridge support is a bit tricky though, for a few reasons:
      
      1) Although the only reason to add a dmi-to-pci-bridge is so that
         there is a reasonable place to plug in a pci-bridge controller,
         most of the time it's not the presence of a pci-bridge *in the
         config* that triggers the requirement to add a dmi-to-pci-bridge.
         Rather, it is the presence of a legacy-PCI device in the config,
         which triggers auto-add of a pci-bridge, which triggers auto-add of
         a dmi-to-pci-bridge (this is handled in
         virDomainPCIAddressSetGrow() - if there's a request to add a
         pci-bridge we'll check if there is a suitable bus to plug it into;
         if not, we first add a dmi-to-pci-bridge).
      
      2) Once there is already a single dmi-to-pci-bridge on the system,
         there won't be a need for any more, even if it's full, as long as
         there is a pci-bridge with an open slot - you can also plug
         pci-bridges into existing pci-bridges. So we have to make sure we
         don't add a dmi-to-pci-bridge unless there aren't any
         dmi-to-pci-bridges *or* any pci-bridges.
      
      3) Although it is strongly discouraged, it is legal for a pci-bridge
         to be directly plugged into pcie-root, and we don't want to
         auto-add a dmi-to-pci-bridge if there is already a pci-bridge
         that's been forced directly into pcie-root.
      
      Although libvirt will now automatically create a dmi-to-pci-bridge
      when it's needed, the code still remains for now that forces a
      dmi-to-pci-bridge on all domains with pcie-root (in
      qemuDomainDefAddDefaultDevices()). That will be removed in a future
      patch.
      
      For now, the pcie-root-ports are added one to a slot, which is a bit
      wasteful and means it will fail after 31 total PCIe devices (30 if
      there are also some PCI devices), but helps keep the changeset down
      for this patch. A future patch will have 8 pcie-root-ports sharing the
      functions on a single slot.
      0702f48e
    • L
      qemu: assign nec-xhci (USB3) controller to a PCIe address when appropriate · 5266426b
      Laine Stump 提交于
      The nec-usb-xhci device (which is a USB3 controller) has always
      presented itself as a PCI device when plugged into a legacy PCI slot,
      and a PCIe device when plugged into a PCIe slot, but libvirt has
      always auto-assigned it to a legacy PCI slot.
      
      This patch changes that behavior to auto-assign to a PCIe slot on
      systems that have pcie-root (e.g. Q35 and aarch64/virt).
      
      Since we don't yet auto-create pcie-*-port controllers on demand, this
      means a config with an nec-xhci USB controller that has no PCI address
      assigned will also need to have an otherwise-unused pcie-*-port
      controller specified:
      
         <controller type='pci' model='pcie-root-port'/>
         <controller type='usb' model='nec-xhci'/>
      
      (this assumes there is an otherwise-unused slot on pcie-root to accept
      the pcie-root-port)
      5266426b
    • L
      qemu: assign e1000e network devices to PCIe slots when appropriate · 9dfe733e
      Laine Stump 提交于
      The e1000e is an emulated network device based on the Intel 82574,
      present in qemu 2.7.0 and later. Among other differences from the
      e1000, it presents itself as a PCIe device rather than legacy PCI. In
      order to get it assigned to a PCIe controller, this patch updates the
      flags setting for network devices when the model name is "e1000e".
      
      (Note that for some reason libvirt has never validated the network
      device model names other than to check that there are no dangerous
      characters in them. That should probably change, but is the subject of
      another patch.)
      
      Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1343094
      9dfe733e
    • L
      qemu: assign virtio devices to PCIe slot when appropriate · c7fc151e
      Laine Stump 提交于
      libvirt previously assigned nearly all devices to a "hotpluggable"
      legacy PCI slot even on machines with a PCIe root bus (and even though
      most such machines don't even support hotplug on legacy PCI slots!)
      Forcing all devices onto legacy PCI slots means that the domain will
      need a dmi-to-pci-bridge (to convert from PCIe to legacy PCI) and a
      pci-bridge (to provide hotpluggable legacy PCI slots which, again,
      usually aren't hotpluggable anyway).
      
      To help reduce the need for these legacy controllers, this patch tries
      to assign virtio-1.0-capable devices to PCIe slots whenever possible,
      by setting appropriate connectFlags in
      virDomainCalculateDevicePCIConnectFlags(). Happily, when that function
      was written (just a few commits ago) it was created with a
      "virtioFlags" argument, set by both of its callers, which is the
      proper connectFlags to set for any virtio-*-pci device - depending on
      the arch/machinetype of the domain, and whether or not the qemu binary
      supports virtio-1.0, that flag will have either been set to PCI or
      PCIe. This patch merely enables the functionality by setting the flags
      for the device to whatever is in virtioFlags if the device is a
      virtio-*-pci device.
      
      NB: the first virtio video device will be placed directly on bus 0
      slot 1 rather than on a pcie-root-port due to the override for primary
      video devices in qemuDomainValidateDevicePCISlotsQ35(). Whether or not
      to change that is a topic of discussion, but this patch doesn't change
      that particular behavior.
      
      NB2: since the slot must be hotpluggable, and pcie-root (the PCIe root
      complex) does *not* support hotplug, this means that suitable
      controllers must also be in the config (i.e. either pcie-root-port, or
      pcie-downstream-port). For now, libvirt doesn't add those
      automatically, so if you put virtio devices in a config for a qemu
      that has PCIe-capable virtio devices, you'll need to add extra
      pcie-root-ports yourself. That requirement will be eliminated in a
      future patch, but for now, it's simple to do this:
      
         <controller type='pci' model='pcie-root-port'/>
         <controller type='pci' model='pcie-root-port'/>
         <controller type='pci' model='pcie-root-port'/>
         ...
      
      Partially Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1330024
      c7fc151e