qemu: support new pci controller model "pcie-root-port"

This is backed by the qemu device ioh3420.

chassis and port from the <target> subelement are used to store/set the
respective qemu device options for the ioh3420. Currently, chassis is
set to be the index of the controller, and port is set to
"(slot << 3) + function" (per suggestion from Alex Williamson).
This commit is contained in:
Laine Stump 2015-06-17 13:27:57 -04:00
parent dce3b8beb3
commit 16328520f6
5 changed files with 136 additions and 0 deletions

View File

@ -1607,6 +1607,12 @@ qemuCollectPCIAddress(virDomainDefPtr def ATTRIBUTE_UNUSED,
*/
flags = VIR_PCI_CONNECT_TYPE_PCIE;
break;
case VIR_DOMAIN_CONTROLLER_MODEL_PCIE_ROOT_PORT:
/* pcie-root-port can only connect to pcie-root, isn't
* hot-pluggable
*/
flags = VIR_PCI_CONNECT_TYPE_PCIE_ROOT;
break;
default:
break;
}
@ -2284,6 +2290,13 @@ qemuDomainAssignPCIAddresses(virDomainDefPtr def,
options->modelName = VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_I82801B11_BRIDGE;
break;
case VIR_DOMAIN_CONTROLLER_MODEL_PCIE_ROOT_PORT:
if (options->modelName == VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_NONE)
options->modelName = VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_IOH3420;
if (options->chassis == -1)
options->chassis = cont->idx;
if (options->port == -1)
options->port = (addr->slot << 3) + addr->function;
break;
case VIR_DOMAIN_CONTROLLER_MODEL_PCI_ROOT:
case VIR_DOMAIN_CONTROLLER_MODEL_PCIE_ROOT:
case VIR_DOMAIN_CONTROLLER_MODEL_PCI_LAST:
@ -2395,6 +2408,10 @@ qemuAssignDevicePCISlots(virDomainDefPtr def,
*/
flags = VIR_PCI_CONNECT_TYPE_PCIE;
break;
case VIR_DOMAIN_CONTROLLER_MODEL_PCIE_ROOT_PORT:
/* pcie-root-port can only plug into pcie-root */
flags = VIR_PCI_CONNECT_TYPE_PCIE_ROOT;
break;
default:
flags = VIR_PCI_CONNECT_HOTPLUGGABLE | VIR_PCI_CONNECT_TYPE_PCI;
break;
@ -4722,6 +4739,39 @@ qemuBuildControllerDevStr(virDomainDefPtr domainDef,
}
virBufferAsprintf(&buf, "%s,id=%s", modelName, def->info.alias);
break;
case VIR_DOMAIN_CONTROLLER_MODEL_PCIE_ROOT_PORT:
if (def->opts.pciopts.modelName
== VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_NONE) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("autogenerated pcie-root-port options not set"));
goto error;
}
modelName = virDomainControllerPCIModelNameTypeToString(def->opts.pciopts.modelName);
if (!modelName) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("unknown pcie-root-port model name value %d"),
def->opts.pciopts.modelName);
goto error;
}
if (def->opts.pciopts.modelName
!= VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_IOH3420) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("PCI controller model name '%s' "
"is not valid for a pcie-root-port"),
modelName);
goto error;
}
if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_IOH3420)) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("the pcie-root-port (ioh3420) "
"controller is not supported in this QEMU binary"));
goto error;
}
virBufferAsprintf(&buf, "%s,port=0x%x,chassis=%d,id=%s",
modelName, def->opts.pciopts.port,
def->opts.pciopts.chassis, def->info.alias);
break;
}
break;

View File

@ -0,0 +1,60 @@
<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-root-port'/>
<controller type='pci' index='4' model='pcie-root-port'/>
<controller type='pci' index='5' model='pcie-root-port'/>
<controller type='pci' index='6' model='pcie-root-port'/>
<controller type='pci' index='7' model='pcie-root-port'/>
<controller type='pci' index='8' model='pcie-root-port'/>
<controller type='pci' index='9' model='pcie-root-port'/>
<controller type='pci' index='10' model='pcie-root-port'/>
<controller type='pci' index='11' model='pcie-root-port'/>
<controller type='pci' index='12' model='pcie-root-port'/>
<controller type='pci' index='13' model='pcie-root-port'/>
<controller type='pci' index='14' model='pcie-root-port'/>
<controller type='pci' index='15' model='pcie-root-port'/>
<controller type='pci' index='16' model='pcie-root-port'/>
<controller type='pci' index='17' model='pcie-root-port'/>
<controller type='pci' index='18' model='pcie-root-port'/>
<controller type='pci' index='19' model='pcie-root-port'/>
<controller type='pci' index='20' model='pcie-root-port'/>
<controller type='pci' index='21' model='pcie-root-port'/>
<controller type='pci' index='22' model='pcie-root-port'/>
<controller type='pci' index='23' model='pcie-root-port'/>
<controller type='pci' index='24' model='pcie-root-port'/>
<controller type='pci' index='25' model='pcie-root-port'/>
<controller type='pci' index='26' model='pcie-root-port'/>
<controller type='pci' index='27' model='pcie-root-port'/>
<controller type='pci' index='28' model='pcie-root-port'/>
<controller type='pci' index='29' model='pcie-root-port'/>
<controller type='pci' index='30' model='pcie-root-port'/>
<controller type='pci' index='31' model='pcie-root-port'/>
<controller type='sata' index='0'/>
<video>
<model type='qxl' ram='65536' vram='32768' vgamem='8192' heads='1'/>
</video>
<memballoon model='none'/>
</devices>
</domain>

View File

@ -0,0 +1,10 @@
LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test QEMU_AUDIO_DRV=none \
/usr/libexec/qemu-kvm -S -M q35 -m 2048 -smp 2 -nographic -nodefaults \
-monitor unix:/tmp/test-monitor,server,nowait -no-acpi -boot c \
-device i82801b11-bridge,id=pci.1,bus=pcie.0,addr=0x1e \
-device pci-bridge,chassis_nr=2,id=pci.2,bus=pci.1,addr=0x1 \
-device ioh3420,port=0x10,chassis=3,id=pci.3,bus=pcie.0,addr=0x2 \
-device ioh3420,port=0x1a,chassis=40,id=pci.4,bus=pcie.0,addr=0x3 \
-drive file=/dev/HostVG/QEMUGuest1,if=none,id=drive-sata0-0-0 \
-device ide-drive,bus=ide.0,drive=drive-sata0-0-0,id=sata0-0-0 \
-vga qxl -global qxl-vga.ram_size=67108864 -global qxl-vga.vram_size=33554432

View File

@ -1507,6 +1507,21 @@ mymain(void)
QEMU_CAPS_DRIVE, QEMU_CAPS_ICH9_AHCI,
QEMU_CAPS_VGA, QEMU_CAPS_DEVICE_VIDEO_PRIMARY,
QEMU_CAPS_VGA, QEMU_CAPS_VGA_QXL, QEMU_CAPS_DEVICE_QXL);
DO_TEST("pcie-root-port",
QEMU_CAPS_DEVICE, QEMU_CAPS_DEVICE_PCI_BRIDGE,
QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE,
QEMU_CAPS_DEVICE_IOH3420,
QEMU_CAPS_DRIVE, QEMU_CAPS_ICH9_AHCI,
QEMU_CAPS_VGA, QEMU_CAPS_DEVICE_VIDEO_PRIMARY,
QEMU_CAPS_VGA, QEMU_CAPS_VGA_QXL, QEMU_CAPS_DEVICE_QXL);
DO_TEST_ERROR("pcie-root-port-too-many",
QEMU_CAPS_DEVICE, QEMU_CAPS_DEVICE_PCI_BRIDGE,
QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE,
QEMU_CAPS_DEVICE_IOH3420,
QEMU_CAPS_DRIVE, QEMU_CAPS_ICH9_AHCI,
QEMU_CAPS_VGA, QEMU_CAPS_DEVICE_VIDEO_PRIMARY,
QEMU_CAPS_VGA, QEMU_CAPS_VGA_QXL, QEMU_CAPS_DEVICE_QXL);
DO_TEST("hostdev-scsi-lsi", QEMU_CAPS_DRIVE,
QEMU_CAPS_DEVICE, QEMU_CAPS_DRIVE,

View File

@ -568,6 +568,7 @@ mymain(void)
DO_TEST_DIFFERENT("pcie-root");
DO_TEST_DIFFERENT("q35");
DO_TEST("pcie-root-port");
DO_TEST("pcie-root-port-too-many");
DO_TEST("hostdev-scsi-lsi");
DO_TEST("hostdev-scsi-virtio-scsi");