[libvirt] [PATCH 09/13] conf: new pci controller model "pcie-switch-upstream-port"

Alex Williamson alex.williamson at redhat.com
Tue Jun 23 15:23:46 UTC 2015


On Mon, 2015-06-22 at 14:44 -0400, Laine Stump wrote:
> This controller can be connected to any PCIe port, but not to a
> standard PCI port, which is the reason for the new connect type
> VIR_PCI_CONNECT_TYPE_PCIE_ONLY. pcie-switch provides 31 ports (slot=1
> to slot=31), 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.
> ---
>  docs/formatdomain.html.in                          |  5 ++--
>  docs/schemas/domaincommon.rng                      |  1 +
>  src/conf/domain_addr.c                             | 11 +++++++-
>  src/conf/domain_addr.h                             |  6 +++-
>  src/conf/domain_conf.c                             |  3 +-
>  src/conf/domain_conf.h                             |  1 +
>  .../qemuxml2argv-pcie-switch-upstream-port.xml     | 32 ++++++++++++++++++++++
>  tests/qemuxml2xmltest.c                            |  1 +
>  8 files changed, 55 insertions(+), 5 deletions(-)
>  create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-pcie-switch-upstream-port.xml
> 
> diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
> index e6c140a..646c9ee 100644
> --- a/docs/formatdomain.html.in
> +++ b/docs/formatdomain.html.in
> @@ -2998,10 +2998,11 @@
>        PCI controllers have an optional <code>model</code> attribute with
>        possible values <code>pci-root</code>, <code>pcie-root</code>,
>        <code>pcie-root-port</code>, <code>pci-bridge</code>,
> -      or <code>dmi-to-pci-bridge</code>.
> +      <code>dmi-to-pci-bridge</code>, or <code>pcie-switch-upstream-port</code>.
>        (pci-root and pci-bridge <span class="since">since 1.0.5</span>,
>        pcie-root and dmi-to-pci-bridge <span class="since">since
> -      1.1.2</span>, pcie-root-port <span class="since">since 1.2.17</span>)
> +      1.1.2</span>, pcie-root-port and
> +      pcie-switch-upstream-port <span class="since">since 1.2.17</span>)
>        The root controllers (<code>pci-root</code> and <code>pcie-root</code>)
>        have an optional <code>pcihole64</code> element specifying how big
>        (in kilobytes, or in the unit specified by <code>pcihole64</code>'s
> diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
> index 6139dfb..3f74cfc 100644
> --- a/docs/schemas/domaincommon.rng
> +++ b/docs/schemas/domaincommon.rng
> @@ -1752,6 +1752,7 @@
>                      <value>pci-bridge</value>
>                      <value>dmi-to-pci-bridge</value>
>                      <value>pcie-root-port</value>
> +                    <value>pcie-switch-upstream-port</value>
>                    </choice>
>                  </attribute>
>                </group>
> diff --git a/src/conf/domain_addr.c b/src/conf/domain_addr.c
> index 4b5e81e..59da745 100644
> --- a/src/conf/domain_addr.c
> +++ b/src/conf/domain_addr.c
> @@ -57,6 +57,9 @@ virDomainPCIAddressFlagsCompatible(virDevicePCIAddressPtr addr,
>          if (devFlags & VIR_PCI_CONNECT_HOTPLUGGABLE)
>              busFlags |= VIR_PCI_CONNECT_HOTPLUGGABLE;
>      }
> +    /* devices with PCIE_ONLY can't connect to PCI, even if fromConfig */
> +    if (devFlags & VIR_PCI_CONNECT_TYPE_PCIE_ONLY)
> +       devFlags |= VIR_PCI_CONNECT_TYPE_PCIE;
>  
>      /* If this bus doesn't allow the type of connection (PCI
>       * vs. PCIe) required by the device, or if the device requires
> @@ -199,8 +202,14 @@ virDomainPCIAddressBusSetModel(virDomainPCIAddressBusPtr bus,
>      case VIR_DOMAIN_CONTROLLER_MODEL_PCIE_ROOT_PORT:
>          /* provides one slot which is pcie and hotpluggable */
>          bus->flags = VIR_PCI_CONNECT_TYPE_PCIE | VIR_PCI_CONNECT_HOTPLUGGABLE;
> +        bus->minSlot = 0;
> +        bus->maxSlot = 0;

Shouldn't this have belonged to a previous patch?

> +        break;
> +    case VIR_DOMAIN_CONTROLLER_MODEL_PCIE_SWITCH_UPSTREAM_PORT:
> +        /* 31 slots, can only accept pcie-switch-port, no hotplug */
> +        bus->flags = VIR_PCI_CONNECT_TYPE_PCIE_SWITCH;
>          bus->minSlot = 1;
> -        bus->maxSlot = 1;
> +        bus->maxSlot = 31;

Why exactly are we reserving slot 0?  I know we discussed on IRC that
slot 0 is reserved for the host bridge on root buses, but there are no
reserved slots downstream of an upstream switch port.  If QEMU is
limiting this, it's a bug, if libvirt wants to impose this, it should be
documented as such.  Thanks,

Alex

>          break;
>      default:
>          virReportError(VIR_ERR_INTERNAL_ERROR,
> diff --git a/src/conf/domain_addr.h b/src/conf/domain_addr.h
> index 2a0ff96..8e9ca32 100644
> --- a/src/conf/domain_addr.h
> +++ b/src/conf/domain_addr.h
> @@ -41,6 +41,10 @@ typedef enum {
>     /* PCI Express devices can connect to this bus */
>     VIR_PCI_CONNECT_TYPE_PCIE_ROOT = 1 << 4,
>     /* for devices that can only connect to pcie-root (i.e. root-port) */
> +   VIR_PCI_CONNECT_TYPE_PCIE_ONLY = 1 << 5,
> +   /* devices that can't connect to pci even if manual config */
> +   VIR_PCI_CONNECT_TYPE_PCIE_SWITCH = 1 << 6,
> +   /* devices that can only connect to a pcie-switch */
>  } virDomainPCIConnectFlags;
>  
>  typedef struct {
> @@ -73,7 +77,7 @@ typedef virDomainPCIAddressSet *virDomainPCIAddressSetPtr;
>   */
>  # define VIR_PCI_CONNECT_TYPES_MASK \
>     (VIR_PCI_CONNECT_TYPE_PCI | VIR_PCI_CONNECT_TYPE_PCIE | \
> -    VIR_PCI_CONNECT_TYPE_PCIE_ROOT)
> +    VIR_PCI_CONNECT_TYPE_PCIE_ROOT | VIR_PCI_CONNECT_TYPE_PCIE_SWITCH)
>  
>  /* combination of all bits that could be used to connect a normal
>   * endpoint device (i.e. excluding the connection possible between an
> diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
> index 0bdd51e..c0b8c92 100644
> --- a/src/conf/domain_conf.c
> +++ b/src/conf/domain_conf.c
> @@ -324,7 +324,8 @@ VIR_ENUM_IMPL(virDomainControllerModelPCI, VIR_DOMAIN_CONTROLLER_MODEL_PCI_LAST,
>                "pcie-root",
>                "pci-bridge",
>                "dmi-to-pci-bridge",
> -              "pcie-root-port")
> +              "pcie-root-port",
> +              "pcie-switch-upstream-port")
>  
>  VIR_ENUM_IMPL(virDomainControllerModelSCSI, VIR_DOMAIN_CONTROLLER_MODEL_SCSI_LAST,
>                "auto",
> diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
> index 946210e..b7ce0ce 100644
> --- a/src/conf/domain_conf.h
> +++ b/src/conf/domain_conf.h
> @@ -753,6 +753,7 @@ typedef enum {
>      VIR_DOMAIN_CONTROLLER_MODEL_PCI_BRIDGE,
>      VIR_DOMAIN_CONTROLLER_MODEL_DMI_TO_PCI_BRIDGE,
>      VIR_DOMAIN_CONTROLLER_MODEL_PCIE_ROOT_PORT,
> +    VIR_DOMAIN_CONTROLLER_MODEL_PCIE_SWITCH_UPSTREAM_PORT,
>  
>      VIR_DOMAIN_CONTROLLER_MODEL_PCI_LAST
>  } virDomainControllerModelPCI;
> diff --git a/tests/qemuxml2argvdata/qemuxml2argv-pcie-switch-upstream-port.xml b/tests/qemuxml2argvdata/qemuxml2argv-pcie-switch-upstream-port.xml
> new file mode 100644
> index 0000000..428a4ea
> --- /dev/null
> +++ b/tests/qemuxml2argvdata/qemuxml2argv-pcie-switch-upstream-port.xml
> @@ -0,0 +1,32 @@
> +<domain type='qemu'>
> +  <name>q35-test</name>
> +  <uuid>11dbdcdd-4c3b-482b-8903-9bdb8c0a2774</uuid>
> +  <memory unit='KiB'>2097152</memory>
> +  <currentMemory unit='KiB'>2097152</currentMemory>
> +  <vcpu placement='static' cpuset='0-1'>2</vcpu>
> +  <os>
> +    <type arch='x86_64' machine='q35'>hvm</type>
> +    <boot dev='hd'/>
> +  </os>
> +  <clock offset='utc'/>
> +  <on_poweroff>destroy</on_poweroff>
> +  <on_reboot>restart</on_reboot>
> +  <on_crash>destroy</on_crash>
> +  <devices>
> +    <emulator>/usr/libexec/qemu-kvm</emulator>
> +    <disk type='block' device='disk'>
> +      <source dev='/dev/HostVG/QEMUGuest1'/>
> +      <target dev='sda' bus='sata'/>
> +      <address type='drive' controller='0' bus='0' target='0' unit='0'/>
> +    </disk>
> +    <controller type='pci' index='0' model='pcie-root'/>
> +    <controller type='pci' index='1' model='dmi-to-pci-bridge'/>
> +    <controller type='pci' index='2' model='pci-bridge'/>
> +    <controller type='pci' index='3' model='pcie-switch-upstream-port'/>
> +    <controller type='sata' index='0'/>
> +    <video>
> +      <model type='qxl' ram='65536' vram='32768' vgamem='8192' heads='1'/>
> +    </video>
> +    <memballoon model='none'/>
> +  </devices>
> +</domain>
> diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c
> index 2acbae1..e5fcc5d 100644
> --- a/tests/qemuxml2xmltest.c
> +++ b/tests/qemuxml2xmltest.c
> @@ -567,6 +567,7 @@ mymain(void)
>      DO_TEST_DIFFERENT("pcie-root");
>      DO_TEST_DIFFERENT("q35");
>      DO_TEST("pcie-root-port");
> +    DO_TEST("pcie-switch-upstream-port");
>  
>      DO_TEST("hostdev-scsi-lsi");
>      DO_TEST("hostdev-scsi-virtio-scsi");






More information about the libvir-list mailing list