Signed-off-by: liguang <lig.fnst(a)cn.fujitsu.com>
---
src/qemu/qemu_command.c | 25 ++++++++++++++++++++-----
1 files changed, 20 insertions(+), 5 deletions(-)
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 04a9512..0da32e0 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -966,10 +966,15 @@ static char *qemuPCIAddressAsString(virDomainDeviceInfoPtr dev)
{
char *addr;
- if (dev->addr.pci.domain != 0 ||
- dev->addr.pci.bus != 0) {
+ if (dev->addr.pci.domain != 0) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
- _("Only PCI domain 0 and bus 0 are available"));
+ _("Only PCI domain 0 is available"));
+ return NULL;
+ }
+ if (dev->addr.pci.bridge < 0 && dev->addr.pci.bus != 0) {
+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("Only PCI bus 0 is available "
+ "without pci-bridge support"));
return NULL;
}
@@ -1768,7 +1773,7 @@ qemuBuildDeviceAddressStr(virBufferPtr buf,
_("Only PCI device addresses with domain=0 are
supported"));
return -1;
}
- if (info->addr.pci.bus != 0) {
+ if (info->addr.pci.bus != 0 && info->addr.pci.bridge < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Only PCI device addresses with bus=0 are
supported"));
return -1;
@@ -1801,7 +1806,9 @@ qemuBuildDeviceAddressStr(virBufferPtr buf,
* When QEMU grows support for > 1 PCI domain, then pci.0 change
* to pciNN.0 where NN is the domain number
*/
- if (qemuCapsGet(caps, QEMU_CAPS_PCI_MULTIBUS))
+ if (info->addr.pci.bridge >= 0)
+ virBufferAsprintf(buf, ",bus=pci.%d", info->addr.pci.bus);
+ else if (qemuCapsGet(caps, QEMU_CAPS_PCI_MULTIBUS))
virBufferAsprintf(buf, ",bus=pci.0");
else
virBufferAsprintf(buf, ",bus=pci");
@@ -3064,6 +3071,12 @@ qemuBuildControllerDevStr(virDomainDefPtr domainDef,
int model;
switch (def->type) {
+ case VIR_DOMAIN_CONTROLLER_TYPE_PCIBRIDGE:
+ virBufferAsprintf(&buf, "pci-bridge,chassis_nr=%d",
def->idx+1);
+ virBufferAsprintf(&buf, ",id=pci.%d", def->idx);
+ if (def->idx == 0)
+ goto out;
+ break;
case VIR_DOMAIN_CONTROLLER_TYPE_SCSI:
model = def->model;
if ((qemuSetScsiControllerModel(domainDef, caps, &model)) < 0)
@@ -3137,6 +3150,7 @@ qemuBuildControllerDevStr(virDomainDefPtr domainDef,
if (qemuBuildDeviceAddressStr(&buf, &def->info, caps) < 0)
goto error;
+out:
if (virBufferError(&buf)) {
virReportOOMError();
goto error;
@@ -5033,6 +5047,7 @@ qemuBuildCommandLine(virConnectPtr conn,
/* We don't add an explicit IDE or FD controller because the
* provided PIIX4 device already includes one. It isn't possible to
* remove the PIIX4. */
+ VIR_DOMAIN_CONTROLLER_TYPE_PCIBRIDGE,
VIR_DOMAIN_CONTROLLER_TYPE_USB,
VIR_DOMAIN_CONTROLLER_TYPE_SCSI,
VIR_DOMAIN_CONTROLLER_TYPE_SATA,
--
1.7.2.5