1. 25 10月, 2016 1 次提交
    • 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
  2. 17 10月, 2016 1 次提交
    • A
      conf: Explain some code in more detail · 61e10143
      Andrea Bolognani 提交于
      The code is entirely correct, but it still managed to trip me
      up when I first ran into it because I did not realize right away
      that VIR_PCI_CONNECT_TYPES_ENDPOINT was not a single flag, but
      rather a mask including both VIR_PCI_CONNECT_TYPE_PCI_DEVICE and
      VIR_PCI_CONNECT_TYPE_PCIE_DEVICE.
      
      In order to save the next distracted traveler in PCI Address Land
      some time, document this fact with a comment. Add a test case for
      the behavior as well.
      61e10143
  3. 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
  4. 06 10月, 2016 1 次提交
    • L
      qemu: allow 32 slots on pcie-expander-bus, not just 1 · 22afd441
      Laine Stump 提交于
      When I added support for the pcie-expander-bus controller in commit
      bc07251f, I incorrectly thought that it only had a single slot
      available. Actually it has 32 slots, just like the root complex aka
      pcie-root (the part that I *did* get correct is that unlike pcie-root
      a pcie-expander-bus doesn't allow any integrated endpoint devices -
      only pcie-root-ports and dmi-to-pci-controllers are allowed).
      22afd441
  5. 13 9月, 2016 1 次提交
    • L
      conf: allow hotplugging "legacy PCI" device to manually addressed PCIe slot · b87703cf
      Laine Stump 提交于
      In a full domain config, libvirt allows overriding the normal PCI
      vs. PCI Express rules when a device address is explicitly provided
      (so, e.g., you can force a legacy PCI device to plug into a PCIe port,
      although libvirt would never do that on its own). However, due to a
      bug libvirt doesn't give this same leeway when hotplugging devices. On
      top of that, current libvirt assumes that *all* devices are legacy
      PCI. The result of all this is that it's impossible to hotplug a
      device into a PCIe port, even if you manually add the PCI address.
      
      This can all be traced to the function
      virDomainPCIAddressEnsureAddr(), and the fact that it calls
      virDomainPCIaddressReserveSlot() for manually set addresses, and that
      function hardcodes the argument "fromConfig" to false (meaning "this
      address was auto-assigned, so it should be subject to stricter
      validation").
      
      Since virDomainPCIAddressReserveSlot() is just a one line simple
      wrapper around virDomainPCIAddressReserveAddr() (adding in a hardcoded
      reserveEntireSlot = true and fromConfig = false), all that's needed to
      solve the problem with no unwanted side effects is to replace that
      call for virDomainPCIAddressReserveSlot() with a direct call to
      virDomainPCIAddressReserveAddr(), but with reserveEntireSlot = true,
      fromConfig = true. That's what this patch does.
      
      Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1337490
      b87703cf
  6. 02 9月, 2016 1 次提交
    • X
      conf: Fix initialization value of 'multi' in PCI address · f7658da6
      Xian Han Yu 提交于
      The 'multi' element in PCI address struct used as 'virTristateSwitch',
      and its default value is 'VIR_TRISTATE_SWITCH_ABSENT'. Current PCI
      process use 'false' to initialization 'multi', which is ambiguously
      for assignment or comparison. This patch use '{0}' to initialize
      the whole PCI address struct, which fix the 'multi' initialization
      and makes code more simplify and explicitly.
      Signed-off-by: NXian Han Yu <xhyubj@linux.vnet.ibm.com>
      f7658da6
  7. 16 8月, 2016 2 次提交
  8. 10 8月, 2016 4 次提交
  9. 02 8月, 2016 1 次提交
    • C
      extend usb controller model to support xen pvusb · be146b34
      Chunyan Liu 提交于
      According to libxl implementation, it supports pvusb
      controller of version 1.1 and version 2.0, and it
      supports two types of backend, 'pvusb' (dom0 backend)
      and 'qusb' (qemu backend). But currently pvusb backend
      is not checked in yet.
      
      To match libxl support, extend usb controller schema
      to support two more models: qusb1 (qusb, version 1.1)
      and 'qusb2' (qusb version 2.0).
      Signed-off-by: NChunyan Liu <cyliu@suse.com>
      be146b34
  10. 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
  11. 21 7月, 2016 7 次提交
    • 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 hubs to addrs · 2f081351
      Ján Tomko 提交于
      Walk through all the usb hubs in the domain definition
      that have a USB address specified, create the
      corresponding structures in the virDomainUSBAddressSet
      and mark the port it occupies as used.
      2f081351
    • 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
  12. 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
  13. 21 5月, 2016 1 次提交
    • L
      qemu: auto-assign addresses when <address type='pci'/> is specified · c026f8f1
      Laine Stump 提交于
      Rather than only assigning a PCI address when no address is given at
      all, also do it when the config says that the address type is 'pci',
      but it gives no address (virDeviceInfoPCIAddressWanted()).
      
      There are also several places after parsing but prior to address
      assignment where code previously expected that any info with address
      type='pci' would have a *valid* PCI address, which isn't always the
      case - now we check not only for type='pci', but also for a valid
      address (virDeviceInfoPCIAddressPresent()).
      
      The test case added in this patch was directly copied from Cole's patch titled:
      
          qemu: Wire up address type=pci auto_allocate
      c026f8f1
  14. 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
  15. 15 4月, 2016 6 次提交
    • L
      conf: new pci controller model pcie-expander-bus · bc07251f
      Laine Stump 提交于
      This controller provides a single PCIe port on a new root. It is
      similar to pci-expander-bus, intended to provide a bus that can be
      associated with a guest-identifiable NUMA node, but is for
      machinetypes with PCIe rather than PCI (e.g. q35-based machinetypes).
      
      Aside from PCIe vs. PCI, the other main difference is that a
      pci-expander-bus has a companion pci-bridge that is automatically
      attached along with it, but pcie-expander-bus has only a single port,
      and that port will only connect to a pcie-root-port, or to a
      pcie-switch-upstream-port. In order for the bus to be of any use in
      the guest, it must have either a pcie-root-port or a
      pcie-switch-upstream-port attached (and one or more
      pcie-switch-downstream-ports attached to the
      pcie-switch-upstream-port).
      bc07251f
    • L
      conf: new pci controller model pci-expander-bus · 52f3d0a4
      Laine Stump 提交于
      This is a standard PCI root bus (not a bridge) that can be added to a
      440fx-based domain. Although it uses a PCI slot, this is *not* how it
      is connected into the PCI bus hierarchy, but is only used for
      control. Each pci-expander-bus provides 32 slots (0-31) that can
      accept hotplug of standard PCI devices.
      
      The usefulness of pci-expander-bus relative to a pci-bridge is that
      the NUMA node of the bus can be specified with the <node> subelement
      of <target>. This gives guest-side visibility to the NUMA node of
      attached devices (presuming that management apps only assign a device
      to a bus that has a NUMA node number matching the node number of the
      device on the host).
      
      Each pci-expander-bus also has a "busNr" attribute. The expander-bus
      itself will take the busNr specified, and all buses that are connected
      to this bus (including the pci-bridge that is automatically added to
      any expander bus of model "pxb" (see the next commit)) will use
      busNr+1, busNr+2, etc, and the pci-root (or the expander-bus with next
      lower busNr) will use bus numbers lower than busNr.
      52f3d0a4
    • 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
    • L
      conf: allow use of slot 0 in a dmi-to-pci-bridge · 0d668434
      Laine Stump 提交于
      When support for dmi-to-pci-bridge was added, it was assumed that,
      just as with the pci-root bus, slot 0 was reserved. This is not the
      case - it can be used to connect a device just like any other slot, so
      remove the restriction and update the test cases that auto-assign an
      address on a dmi-to-pci-bridge.
      0d668434
    • L
      conf: use #define instead of literal for highest slot in upstream port · 6d0902a5
      Laine Stump 提交于
      Every other maxSlot was either set to 0 or to
      VIR_PCI_ADDRESS_SLOT_LAST, but this one was for some reason set to the
      literal value 31 (which is the same as VIR_PCI_ADDRESS_SLOT_LAST).
      This makes them all consistent.
      6d0902a5
  16. 17 12月, 2015 2 次提交
  17. 10 8月, 2015 3 次提交
    • L
      conf: new pcie-controller model "pcie-switch-downstream-port" · 76379a6e
      Laine Stump 提交于
      This controller can be connected only to a port on a
      pcie-switch-upstream-port. It provides a single hotpluggable port that
      will accept any PCI or PCIe device, as well as any device requiring a
      pcie-*-port (the only current example of such a device is the
      pcie-switch-upstream-port).
      76379a6e
    • 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
  18. 25 7月, 2015 1 次提交
    • L
      conf: pay attention to bus minSlot/maxSlot when autoassigning PCI addresses · d4cf72af
      Laine Stump 提交于
      The function that auto-assigns PCI addresses was written with the
      hardcoded assumptions that any PCI bus would have slots available
      starting at 1 and ending at 31. This isn't true for many types of
      controllers (some have a single slot/port at 0, some have slots/ports
      from 0 to 31). This patch updates that function to remove the
      hardcoded assumptions. It will properly find/assign addresses for
      devices that can only connect to pcie-(root|downstream)-port (which
      have minSlot/maxSlot of 0/0) or a pcie-switch-upstream-port (0/31).
      
      It still will not auto-create a new bus of the proper kind for these
      connections when one doesn't exist, that task is for another day.
      d4cf72af
  19. 27 6月, 2015 2 次提交
    • L
      qemu: ignore assumptions about hotplug requirement when address is from config · 9a12b6cd
      Laine Stump 提交于
      Certain PCI buses don't support hotplug, and when automatically
      assigning PCI addresses for devices, libvirt is very conservative in
      its assumptions about whether or not a device will need to be
      hotplugged/unplugged in the future. But if the user manually assigns
      an address, they likely are aware of any hotplug requirements of the
      device (or at least they should be).
      
      In short, after this patch, automatically PCI address assignment will
      assume that the device must be plugged in to a hot-pluggable slot, but
      manually assignment can place the device in any bus that is
      compatible, regardless of whether or not it supports hotplug. If the
      user makes a mistake and plugs the device into a bus that doesn't
      support hotplug, then later tries to do a hot-unplug, qemu will give
      an appropriate error.
      
      (in the future we may want to add a "hotpluggable" attribute to all
      devices, with default being "yes" for autoassign, and "no" for manual
      assign).
      9a12b6cd
    • 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
  20. 08 4月, 2015 1 次提交
    • M
      virDomainVirtioSerialAddrSetFree: Fix memleak · 8d971cec
      Michal Privoznik 提交于
      ==19015== 8 bytes in 1 blocks are definitely lost in loss record 34 of 1,049
      ==19015==    at 0x4C29F80: malloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
      ==19015==    by 0x4C2C32F: realloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
      ==19015==    by 0x52AD888: virReallocN (viralloc.c:245)
      ==19015==    by 0x52AD97E: virExpandN (viralloc.c:294)
      ==19015==    by 0x52ADC51: virInsertElementsN (viralloc.c:436)
      ==19015==    by 0x5335864: virDomainVirtioSerialAddrSetAddController (domain_addr.c:816)
      ==19015==    by 0x53358E0: virDomainVirtioSerialAddrSetAddControllers (domain_addr.c:839)
      ==19015==    by 0x1DD5513B: qemuDomainAssignVirtioSerialAddresses (qemu_command.c:1422)
      ==19015==    by 0x1DD55A6E: qemuDomainAssignAddresses (qemu_command.c:1711)
      ==19015==    by 0x1DDA5818: qemuProcessStart (qemu_process.c:4616)
      ==19015==    by 0x1DDF1807: qemuDomainObjStart (qemu_driver.c:7265)
      ==19015==    by 0x1DDF1A66: qemuDomainCreateWithFlags (qemu_driver.c:7320)
      Signed-off-by: NMichal Privoznik <mprivozn@redhat.com>
      8d971cec
  21. 02 4月, 2015 1 次提交