1. 11 1月, 2017 2 次提交
    • L
      conf: eliminate concept of "reserveEntireSlot" · 9ff9d9f5
      Laine Stump 提交于
      setting reserveEntireSlot really accomplishes nothing - instead of
      going to the trouble of computing the value for reserveEntireSlot and
      then possibly setting *all* functions of the slot as in-use, we can
      just set the in-use bit only for the specific function being used by a
      device.  Later we will know from the context (the PCI connect flags,
      and whether we are reserving a specific address or asking for "the
      next available") whether or not it is okay to allocate other functions
      on the same slot.
      
      Although it's not used yet, we allow specifying "-1" for the function
      number when looking for the "next available slot" - this is going to
      end up meaning "return the lowest available function in the slot, but
      since we currently only provide a function from an otherwise unused
      slot, "-1" ends up meaning "0".
      9ff9d9f5
    • L
      conf: use struct instead of int for each slot in virDomainPCIAddressBus · 9838cad9
      Laine Stump 提交于
      When keeping track of which functions of which slots are allocated, we
      will need to have more information than just the current bitmap with a
      bit for each function that is currently stored for each slot in a
      virDomainPCIAddressBus. To prepare for adding more per-slot info, this
      patch changes "uint8_t slots" into "virDomainPCIAddressSlot slot", which
      currently has a single member named "functions" that serves the same
      purpose previously served directly by "slots".
      9838cad9
  2. 15 11月, 2016 1 次提交
    • L
      qemu: set/use proper pciConnectFlags during hotplug · abb7a4bd
      Laine Stump 提交于
      Before now, all the qemu hotplug functions assumed that all devices to
      be hotplugged were legacy PCI endpoint devices
      (VIR_PCI_CONNECT_TYPE_PCI_DEVICE). This worked out "okay", because all
      devices *are* legacy PCI endpoint devices on x86/440fx machinetypes,
      and hotplug didn't work properly on machinetypes using PCIe anyway
      (hotplugging onto a legacy PCI slot doesn't work, and until commit
      b87703cf any attempt to manually specify a PCIe address for a
      hotplugged device would be erroneously rejected).
      
      This patch makes all qemu hotplug operations honor the pciConnectFlags
      set by the single all-knowing function
      qemuDomainDeviceCalculatePCIConnectFlags(). This is done in 3 steps,
      but in a single commit since we would have to touch the other points
      at each step anyway:
      
      1) add a flags argument to the hypervisor-agnostic
      virDomainPCIAddressEnsureAddr() (previously it hardcoded
      ..._PCI_DEVICE)
      
      2) add a new qemu-specific function qemuDomainEnsurePCIAddress() which
      gets the correct pciConnectFlags for the device from
      qemuDomainDeviceConnectFlags(), then calls
      virDomainPCIAddressEnsureAddr().
      
      3) in qemu_hotplug.c replace all calls to
      virDomainPCIAddressEnsureAddr() with calls to
      qemuDomainEnsurePCIAddress()
      
      So in effect, we're putting a "shim" on top of all calls to
      virDomainPCIAddressEnsureAddr() that sets the right pciConnectFlags.
      abb7a4bd
  3. 27 10月, 2016 3 次提交
  4. 25 10月, 2016 2 次提交
    • L
      conf: make virDomainPCIAddressGetNextSlot() a local static function · 696929e6
      Laine Stump 提交于
      This function is no longer needed outside of domain_addr.c.
      696929e6
    • L
      conf: new function virDomainPCIAddressReserveNextAddr() · 848e7ff2
      Laine Stump 提交于
      There is an existing virDomainPCIAddressReserveNextSlot() which will
      reserve all functions of the next available PCI slot. One place in the
      qemu PCI address assignment code requires reserving a *single*
      function of the next available PCI slot. This patch modifies and
      renames virDomainPCIAddressReserveNextSlot() so that it can fulfill
      both the original purpose and the need to reserve a single function.
      
      (This is being done so that the abovementioned code in qemu can have
      its "kind of open coded" solution replaced with a call to this new
      function).
      848e7ff2
  5. 15 10月, 2016 1 次提交
    • L
      conf: restrict what type of buses will accept a pci-bridge · 538220c3
      Laine Stump 提交于
      A pci-bridge has *almost* the same rules as a legacy PCI endpoint
      device for where it can be automatically connected, and until now both
      had been considered identical. There is one pairing that is okay when
      specifically requested by the user (i.e. manual assignment), but we
      want to avoid it when auto-assigning addresses - plugging a pci-bridge
      directly into pcie-root (it is cleaner to plug in a dmi-to-pci-bridge,
      then plug the pci-bridge into that).
      
      In order to allow that difference, this patch makes a separate
      CONNECT_TYPE for pci-bridge, and uses it to restrict auto-assigned
      addresses for pci-bridges to be only on pci-root, pci-expander-bus,
      dmi-to-pci-bridge, or on another pci-bridge.
      
      NB: As with other discouraged-but-seem-to-work configurations
      (e.g. plugging a legacy PCI device into a pcie-root-port) if someone
      *really* wants to, they can still force a pci-bridge to be plugged
      into pcie-root (by manually specifying its PCI address.)
      538220c3
  6. 10 8月, 2016 2 次提交
  7. 26 7月, 2016 1 次提交
    • T
      add virDomainVirtioSerialAddrSetCreateFromDomain · 40c284f0
      Tomasz Flendrich 提交于
      The address sets (pci, ccw, virtio serial) are currently cached
      in qemu private data, but all the information required to recreate
      these sets is in the domain definition. Therefore I am removing
      the redundant data and adding a way to recalculate these sets.
      
      Add a function that calculates the virtio serial address set
      from the domain definition.
      
      Credit goes to Cole Robinson.
      40c284f0
  8. 21 7月, 2016 6 次提交
    • J
      Auto-add one hub if there are too many USB devices · 815d98ac
      Ján Tomko 提交于
      When parsing a command line with USB devices that have
      no address specified, QEMU automatically adds a USB hub
      if the device would fill up all the available USB ports.
      
      To help most of the users, add one hub if there are more
      USB devices than available ports. For wilder configurations,
      expect the user to provide us with more hubs and/or controllers.
      815d98ac
    • J
      Assign addresses on USB device hotplug · f2a781ce
      Ján Tomko 提交于
      USB disks, redirected devices, host devices and serial devices
      are supported.
      f2a781ce
    • J
      Assign addresses to USB devices · bf182078
      Ján Tomko 提交于
      Automatically assign addresses to USB devices.
      
      Just like reserving, this is only done for newly defined domains.
      
      https://bugzilla.redhat.com/show_bug.cgi?id=1215968
      bf182078
    • J
      Reserve existing USB addresses · ddd31fd7
      Ján Tomko 提交于
      Check if they fit on the USB controllers the domain has,
      and error out if two devices try to use the same address.
      ddd31fd7
    • J
      Add functions for adding USB controllers to addrs · 6b3e4e2b
      Ján Tomko 提交于
      Walk through all the usb controllers in the domain definition
      and create the corresponding structures in the virDomainUSBAddressSet.
      6b3e4e2b
    • J
      Introduce virDomainUSBAddressSet · 82c142b3
      Ján Tomko 提交于
      A new type to track USB addresses.
      
      Every <controller type='usb' index='i'/> is represented by an
      object of type virDomainUSBAddressHub located at buses[i].
      
      Each of these hubs has up to 'nports' ports.
      If a port is occupied, it has the corresponding bit set in
      the 'ports' bitmap, e.g. port 1 would have the 0th bit set.
      If there is a hub on this port, then hubs[i] will point
      to this hub.
      82c142b3
  9. 18 7月, 2016 1 次提交
    • J
      Store USB port path as an array of integers · f820d5bf
      Ján Tomko 提交于
      In preparation to tracking which USB addresses are occupied.
      Introduce two helper functions for printing the port path
      as a string and appending it to a virBuffer.
      f820d5bf
  10. 02 5月, 2016 1 次提交
    • M
      Change virDevicePCIAddress to virPCIDeviceAddress · c36b1f7b
      Martin Kletzander 提交于
      We had both and the only difference was that the latter also included
      information about multifunction setting.  The problem with that was that
      we couldn't use functions made for only one of the structs (e.g.
      parsing).  To consolidate those two structs, use the one in virpci.h,
      include that in domain_conf.h and add the multifunction member in it.
      Signed-off-by: NMartin Kletzander <mkletzan@redhat.com>
      c36b1f7b
  11. 15 4月, 2016 2 次提交
    • L
      conf: utility function to convert PCI controller model into connect type · a0616ee8
      Laine Stump 提交于
      There are two places in qemu_domain_address.c where we have a switch
      statement to convert PCI controller models
      (VIR_DOMAIN_CONTROLLER_MODEL_PCI*) into the connection type flag that
      is matched when looking for an upstream connection for that model of
      controller (VIR_PCI_CONNECT_TYPE_*). This patch makes a utility
      function in conf/domain_addr.c to do that, so that when a new PCI
      controller is added, we only need to add the new model-->connect-type
      in a single place.
      a0616ee8
    • L
      conf/qemu: change the way VIR_PCI_CONNECT_TYPE_* flags work · d1cc4605
      Laine Stump 提交于
      The flags used to determine which devices could be plugged into which
      controllers were quite confusing, as they tried to create classes of
      connections, then put particular devices into possibly multiple
      classes, while sometimes setting multiple flags for the controllers
      themselves. The attempt to have a single flag indicate, e.g. that a
      root-port or a switch-downstream-port could connect was not only
      confusing, it was leading to a situation where it would be impossible
      to specify exactly the right combinations for a new controller.
      
      The solution is for the VIR_PCI_CONNECT_TYPE_* flags to have a 1:1
      correspondence with each type of PCI controller, plus a flag for a PCI
      endpoint device and another for a PCIe endpoint device (the only
      exception to this is that pci-bridge and pcie-expander-bus controllers
      have their upstream connection classified as
      VIR_PCI_CONNECT_TYPE_PCI_DEVICE since they can be plugged into
      *exactly* the same ports as any endpoint device).  Each device then
      has a single flag for connect type (plus the HOTPLUG flag if that
      device can e hotplugged), and each controller sets the CONNECT bits
      for all controllers that can be plugged into it, as well as for either
      type of endpoint device that can be plugged in (and the HOTPLUG flag
      if it can accept hotplugged devices).
      
      With this change, it is *slightly* easier to understand the matching
      of connections (as long as you remember that the flag for a
      device/upstream-facing connection of a controller is the same as that
      device's type, while the flags for a controller's downstream
      connections is the OR of all device types that can be plugged into
      that controller). More importantly, it will be possible to correctly
      specify what can be plugged into a pcie-switch-expander-bus, when
      support for it is added.
      d1cc4605
  12. 17 12月, 2015 2 次提交
  13. 10 8月, 2015 2 次提交
    • L
      conf: new pci controller model "pcie-switch-upstream-port" · 38ea9515
      Laine Stump 提交于
      This controller can be connected only to a pcie-root-port or a
      pcie-switch-downstream-port (which will be added in a later patch),
      which is the reason for the new connect type
      VIR_PCI_CONNECT_TYPE_PCIE_PORT. A pcie-switch-upstream-port provides
      32 ports (slot=0 to slot=31) on the downstream side, which can only
      have pci controllers of model "pcie-switch-downstream-port" plugged
      into them, which is the reason for the other new connect type
      VIR_PCI_CONNECT_TYPE_PCIE_SWITCH.
      38ea9515
    • L
      conf: new pci controller model "pcie-root-port" · dce3b8be
      Laine Stump 提交于
      This controller can be connected (at domain startup time only - not
      hotpluggable) only to a port on the pcie root complex ("pcie-root" in
      libvirt config), hence the new connect type
      VIR_PCI_CONNECT_TYPE_PCIE_ROOT. It provides a hotpluggable port that
      will accept any PCI or PCIe device.
      
      New attributes must be added to the controller <target> subelement for
      this - chassis and port are guest-visible option values that will be
      set by libvirt with values derived from the controller's index and pci
      address information.
      dce3b8be
  14. 27 6月, 2015 1 次提交
    • L
      qemu: always permit PCI devices to be manually assigned to a PCIe bus · 1e15be1b
      Laine Stump 提交于
      When support for the pcie-root and dmi-to-pci-bridge buses on a Q35
      machinetype was added, I was concerned that even though qemu at the
      time allowed plugging a PCI device into a PCIe port, that it might not
      be supported in the future. To prevent painful backtracking in the
      possible future where this happened, I disallowed such connections
      except in a few specific cases requested by qemu developers (indicated
      in the code with the flag VIR_PCI_CONNECT_TYPE_EITHER_IF_CONFIG).
      
      Now that a couple years have passed, there is a clear message from
      qemu that there is no danger in allowing PCI devices to be plugged
      into PCIe ports. This patch eliminates
      VIR_PCI_CONNECT_TYPE_EITHER_IF_CONFIG and changes the code to always
      allow PCI->PCIe or PCIe->PCI connection *when the PCI address is
      specified in the config. (For newly added devices that haven't yet
      been given a PCI address, the auto-placement still prefers using the
      correct type of bus).
      1e15be1b
  15. 02 4月, 2015 2 次提交
  16. 21 6月, 2014 1 次提交
  17. 14 5月, 2014 2 次提交
    • R
      qemu: extract common PCI handling functions · 353cf370
      Roman Bogorodskiy 提交于
      Move sharable PCI handling functions to domain_addr.[ch], and
      change theirs prefix from 'qemu' to 'vir':
      
       - virDomainPCIAddressAsString;
       - virDomainPCIAddressBusSetModel;
       - virDomainPCIAddressEnsureAddr;
       - virDomainPCIAddressFlagsCompatible;
       - virDomainPCIAddressGetNextSlot;
       - virDomainPCIAddressReleaseSlot;
       - virDomainPCIAddressReserveAddr;
       - virDomainPCIAddressReserveNextSlot;
       - virDomainPCIAddressReserveSlot;
       - virDomainPCIAddressSetFree;
       - virDomainPCIAddressSetGrow;
       - virDomainPCIAddressSlotInUse;
       - virDomainPCIAddressValidate;
      
      The only change here is function names, the implementation itself
      stays untouched.
      
      Extract common allocation code from DomainPCIAddressSetCreate
      into virDomainPCIAddressSetAlloc.
      353cf370
    • R
      qemu: extract PCI handling structs · c453f2d0
      Roman Bogorodskiy 提交于
      Introduce new files (domain_addr.[ch]) to provide
      an API for domain device handling that could be
      shared across the drivers.
      
      A list of data types were extracted and moved there:
      
       qemuDomainPCIAddressBus -> virDomainPCIAddressBus
       qemuDomainPCIAddressBusPtr -> virDomainPCIAddressBusPtr
       _qemuDomainPCIAddressSet -> virDomainPCIAddressSet
       qemuDomainPCIAddressSetPtr -> virDomainPCIAddressSetPtr
       qemuDomainPCIConnectFlags -> virDomainPCIConnectFlags
      
      Also, move the related definitions and macros.
      c453f2d0