mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-22 04:25:18 +00:00
qemu: Add PCI-Express root to ARM virt machine
Here we assume that if qemu supports generic PCI host controller, it is a part of virt machine and can be used for adding PCI devices. In qemu this is actually a PCIe bus, so we also declare multibus capability so that 0'th bus is specified to qemu correctly as 'pcie.0' Signed-off-by: Pavel Fedin <p.fedin@samsung.com> Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
8a482abf75
commit
e8d5517254
@ -2138,6 +2138,14 @@ bool virQEMUCapsHasPCIMultiBus(virQEMUCapsPtr qemuCaps,
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (ARCH_IS_ARM(def->os.arch)) {
|
||||||
|
/* If 'virt' supports PCI, it supports multibus.
|
||||||
|
* No extra conditions here for simplicity.
|
||||||
|
*/
|
||||||
|
if (STREQ(def->os.machine, "virt"))
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -981,8 +981,10 @@ virDomainXMLNamespace virQEMUDriverDomainXMLNamespace = {
|
|||||||
static int
|
static int
|
||||||
qemuDomainDefPostParse(virDomainDefPtr def,
|
qemuDomainDefPostParse(virDomainDefPtr def,
|
||||||
virCapsPtr caps,
|
virCapsPtr caps,
|
||||||
void *opaque ATTRIBUTE_UNUSED)
|
void *opaque)
|
||||||
{
|
{
|
||||||
|
virQEMUDriverPtr driver = opaque;
|
||||||
|
virQEMUCapsPtr qemuCaps = NULL;
|
||||||
bool addDefaultUSB = true;
|
bool addDefaultUSB = true;
|
||||||
bool addImplicitSATA = false;
|
bool addImplicitSATA = false;
|
||||||
bool addPCIRoot = false;
|
bool addPCIRoot = false;
|
||||||
@ -991,17 +993,24 @@ qemuDomainDefPostParse(virDomainDefPtr def,
|
|||||||
bool addDefaultUSBKBD = false;
|
bool addDefaultUSBKBD = false;
|
||||||
bool addDefaultUSBMouse = false;
|
bool addDefaultUSBMouse = false;
|
||||||
bool addPanicDevice = false;
|
bool addPanicDevice = false;
|
||||||
|
int ret = -1;
|
||||||
|
|
||||||
if (def->os.bootloader || def->os.bootloaderArgs) {
|
if (def->os.bootloader || def->os.bootloaderArgs) {
|
||||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
||||||
_("bootloader is not supported by QEMU"));
|
_("bootloader is not supported by QEMU"));
|
||||||
return -1;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* check for emulator and create a default one if needed */
|
/* check for emulator and create a default one if needed */
|
||||||
if (!def->emulator &&
|
if (!def->emulator &&
|
||||||
!(def->emulator = virDomainDefGetDefaultEmulator(def, caps)))
|
!(def->emulator = virDomainDefGetDefaultEmulator(def, caps)))
|
||||||
return -1;
|
return ret;
|
||||||
|
|
||||||
|
|
||||||
|
/* This condition is actually a (temporary) hack for test suite which
|
||||||
|
* does not create capabilities cache */
|
||||||
|
if (driver && driver->qemuCapsCache)
|
||||||
|
qemuCaps = virQEMUCapsCacheLookup(driver->qemuCapsCache, def->emulator);
|
||||||
|
|
||||||
/* Add implicit PCI root controller if the machine has one */
|
/* Add implicit PCI root controller if the machine has one */
|
||||||
switch (def->os.arch) {
|
switch (def->os.arch) {
|
||||||
@ -1030,12 +1039,13 @@ qemuDomainDefPostParse(virDomainDefPtr def,
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case VIR_ARCH_ARMV7L:
|
case VIR_ARCH_ARMV7L:
|
||||||
addDefaultUSB = false;
|
|
||||||
addDefaultMemballoon = false;
|
|
||||||
break;
|
|
||||||
case VIR_ARCH_AARCH64:
|
case VIR_ARCH_AARCH64:
|
||||||
addDefaultUSB = false;
|
addDefaultUSB = false;
|
||||||
addDefaultMemballoon = false;
|
addDefaultMemballoon = false;
|
||||||
|
if (STREQ(def->os.machine, "virt") ||
|
||||||
|
STRPREFIX(def->os.machine, "virt-")) {
|
||||||
|
addPCIeRoot = virQEMUCapsGet(qemuCaps, QEMU_CAPS_OBJECT_GPEX);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case VIR_ARCH_PPC64:
|
case VIR_ARCH_PPC64:
|
||||||
@ -1076,18 +1086,18 @@ qemuDomainDefPostParse(virDomainDefPtr def,
|
|||||||
if (addDefaultUSB &&
|
if (addDefaultUSB &&
|
||||||
virDomainDefMaybeAddController(
|
virDomainDefMaybeAddController(
|
||||||
def, VIR_DOMAIN_CONTROLLER_TYPE_USB, 0, -1) < 0)
|
def, VIR_DOMAIN_CONTROLLER_TYPE_USB, 0, -1) < 0)
|
||||||
return -1;
|
goto cleanup;
|
||||||
|
|
||||||
if (addImplicitSATA &&
|
if (addImplicitSATA &&
|
||||||
virDomainDefMaybeAddController(
|
virDomainDefMaybeAddController(
|
||||||
def, VIR_DOMAIN_CONTROLLER_TYPE_SATA, 0, -1) < 0)
|
def, VIR_DOMAIN_CONTROLLER_TYPE_SATA, 0, -1) < 0)
|
||||||
return -1;
|
goto cleanup;
|
||||||
|
|
||||||
if (addPCIRoot &&
|
if (addPCIRoot &&
|
||||||
virDomainDefMaybeAddController(
|
virDomainDefMaybeAddController(
|
||||||
def, VIR_DOMAIN_CONTROLLER_TYPE_PCI, 0,
|
def, VIR_DOMAIN_CONTROLLER_TYPE_PCI, 0,
|
||||||
VIR_DOMAIN_CONTROLLER_MODEL_PCI_ROOT) < 0)
|
VIR_DOMAIN_CONTROLLER_MODEL_PCI_ROOT) < 0)
|
||||||
return -1;
|
goto cleanup;
|
||||||
|
|
||||||
/* When a machine has a pcie-root, make sure that there is always
|
/* When a machine has a pcie-root, make sure that there is always
|
||||||
* a dmi-to-pci-bridge controller added as bus 1, and a pci-bridge
|
* a dmi-to-pci-bridge controller added as bus 1, and a pci-bridge
|
||||||
@ -1103,14 +1113,14 @@ qemuDomainDefPostParse(virDomainDefPtr def,
|
|||||||
virDomainDefMaybeAddController(
|
virDomainDefMaybeAddController(
|
||||||
def, VIR_DOMAIN_CONTROLLER_TYPE_PCI, 2,
|
def, VIR_DOMAIN_CONTROLLER_TYPE_PCI, 2,
|
||||||
VIR_DOMAIN_CONTROLLER_MODEL_PCI_BRIDGE) < 0) {
|
VIR_DOMAIN_CONTROLLER_MODEL_PCI_BRIDGE) < 0) {
|
||||||
return -1;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (addDefaultMemballoon && !def->memballoon) {
|
if (addDefaultMemballoon && !def->memballoon) {
|
||||||
virDomainMemballoonDefPtr memballoon;
|
virDomainMemballoonDefPtr memballoon;
|
||||||
if (VIR_ALLOC(memballoon) < 0)
|
if (VIR_ALLOC(memballoon) < 0)
|
||||||
return -1;
|
goto cleanup;
|
||||||
|
|
||||||
memballoon->model = VIR_DOMAIN_MEMBALLOON_MODEL_VIRTIO;
|
memballoon->model = VIR_DOMAIN_MEMBALLOON_MODEL_VIRTIO;
|
||||||
def->memballoon = memballoon;
|
def->memballoon = memballoon;
|
||||||
@ -1121,24 +1131,27 @@ qemuDomainDefPostParse(virDomainDefPtr def,
|
|||||||
virDomainDefMaybeAddInput(def,
|
virDomainDefMaybeAddInput(def,
|
||||||
VIR_DOMAIN_INPUT_TYPE_KBD,
|
VIR_DOMAIN_INPUT_TYPE_KBD,
|
||||||
VIR_DOMAIN_INPUT_BUS_USB) < 0)
|
VIR_DOMAIN_INPUT_BUS_USB) < 0)
|
||||||
return -1;
|
goto cleanup;
|
||||||
|
|
||||||
if (addDefaultUSBMouse &&
|
if (addDefaultUSBMouse &&
|
||||||
def->ngraphics > 0 &&
|
def->ngraphics > 0 &&
|
||||||
virDomainDefMaybeAddInput(def,
|
virDomainDefMaybeAddInput(def,
|
||||||
VIR_DOMAIN_INPUT_TYPE_MOUSE,
|
VIR_DOMAIN_INPUT_TYPE_MOUSE,
|
||||||
VIR_DOMAIN_INPUT_BUS_USB) < 0)
|
VIR_DOMAIN_INPUT_BUS_USB) < 0)
|
||||||
return -1;
|
goto cleanup;
|
||||||
|
|
||||||
if (addPanicDevice && !def->panic) {
|
if (addPanicDevice && !def->panic) {
|
||||||
virDomainPanicDefPtr panic;
|
virDomainPanicDefPtr panic;
|
||||||
if (VIR_ALLOC(panic) < 0)
|
if (VIR_ALLOC(panic) < 0)
|
||||||
return -1;
|
goto cleanup;
|
||||||
|
|
||||||
def->panic = panic;
|
def->panic = panic;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
ret = 0;
|
||||||
|
cleanup:
|
||||||
|
virObjectUnref(qemuCaps);
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char *
|
static const char *
|
||||||
|
Loading…
x
Reference in New Issue
Block a user