]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemu: implement <target chassisNr='n'/> subelement/attribute of <controller>
authorLaine Stump <laine@laine.org>
Wed, 15 Jul 2015 19:16:14 +0000 (15:16 -0400)
committerLaine Stump <laine@laine.org>
Mon, 10 Aug 2015 01:40:40 +0000 (21:40 -0400)
This uses the new subelement/attribute in two ways:

1) If a "pci-bridge" pci controller has no chassisNr attribute, it
will automatically be set to the controller's index as soon as the
controller's PCI address is known (during
qemuDomainAssignPCIAddresses()).

2) when creating the commandline for a pci-bridge device, chassisNr
will be used to set qemu's chassis_nr option (rather than the previous
practice of hard-coding it to the controller's index).

src/qemu/qemu_command.c
tests/qemuxml2argvdata/qemuxml2argv-q35.args

index d84ef8ec1f3151d67062451f63de3c06dbdc9a5c..49397c1a938acc21745012db618c14de515ec532 100644 (file)
@@ -2276,6 +2276,8 @@ qemuDomainAssignPCIAddresses(virDomainDefPtr def,
                 case VIR_DOMAIN_CONTROLLER_MODEL_PCI_BRIDGE:
                     if (options->modelName == VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_NONE)
                         options->modelName = VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_PCI_BRIDGE;
+                    if (options->chassisNr == -1)
+                        options->chassisNr = cont->idx;
                     break;
                 case VIR_DOMAIN_CONTROLLER_MODEL_DMI_TO_PCI_BRIDGE:
                     if (options->modelName == VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_NONE)
@@ -4656,7 +4658,8 @@ qemuBuildControllerDevStr(virDomainDefPtr domainDef,
         switch (def->model) {
         case VIR_DOMAIN_CONTROLLER_MODEL_PCI_BRIDGE:
             if (def->opts.pciopts.modelName
-                == VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_NONE) {
+                == VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_NONE ||
+                def->opts.pciopts.chassisNr == -1) {
                 virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
                                _("autogenerated pci-bridge options not set"));
                 goto error;
@@ -4684,7 +4687,8 @@ qemuBuildControllerDevStr(virDomainDefPtr domainDef,
                 goto error;
             }
             virBufferAsprintf(&buf, "%s,chassis_nr=%d,id=%s",
-                              modelName, def->idx, def->info.alias);
+                              modelName, def->opts.pciopts.chassisNr,
+                              def->info.alias);
             break;
         case VIR_DOMAIN_CONTROLLER_MODEL_DMI_TO_PCI_BRIDGE:
             if (def->opts.pciopts.modelName
index 888aa6bf5292d6d42a52ac0ebccf4a36c375d1f8..e42022d4dfdd0112d0cf0254acb7f83106efcb99 100644 (file)
@@ -2,7 +2,7 @@ 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 pci-bridge,chassis_nr=56,id=pci.2,bus=pci.1,addr=0x1 \
 -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