[libvirt] [PATCHv2 08/17] qemu: implement <target chassisNr='n'/> subelement/attribute of <controller>

Laine Stump laine at laine.org
Fri Jul 17 18:43:35 UTC 2015


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 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.
---

new in V2 (previously was a part of the patch to add pcie-root-port,
but adding the attributes under <model> instead of <target>)

 src/qemu/qemu_command.c                      | 6 ++++--
 tests/qemuxml2argvdata/qemuxml2argv-q35.args | 2 +-
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 8868e18..9f15eb6 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -2260,6 +2260,8 @@ qemuDomainAssignPCIAddresses(virDomainDefPtr def,
                 case VIR_DOMAIN_CONTROLLER_MODEL_PCI_BRIDGE:
                     if (!options->type)
                         deviceName = "pci-bridge";
+                    if (options->chassisNr == -1)
+                        options->chassisNr = cont->idx;
                     break;
                 case VIR_DOMAIN_CONTROLLER_MODEL_DMI_TO_PCI_BRIDGE:
                     if (!options->type)
@@ -4640,7 +4642,7 @@ qemuBuildControllerDevStr(virDomainDefPtr domainDef,
         }
         switch (def->model) {
         case VIR_DOMAIN_CONTROLLER_MODEL_PCI_BRIDGE:
-            if (!def->opts.pciopts.type) {
+            if (!def->opts.pciopts.type || def->opts.pciopts.chassisNr == -1) {
                 virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
                                _("autogenerated pci-bridge options not set"));
                 goto error;
@@ -4660,7 +4662,7 @@ qemuBuildControllerDevStr(virDomainDefPtr domainDef,
             }
             virBufferAsprintf(&buf, "%s,chassis_nr=%d,id=%s",
                               def->opts.pciopts.type,
-                              def->idx, def->info.alias);
+                              def->opts.pciopts.chassisNr, def->info.alias);
             break;
         case VIR_DOMAIN_CONTROLLER_MODEL_DMI_TO_PCI_BRIDGE:
             if (!def->opts.pciopts.type) {
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-q35.args b/tests/qemuxml2argvdata/qemuxml2argv-q35.args
index 888aa6b..e42022d 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-q35.args
+++ b/tests/qemuxml2argvdata/qemuxml2argv-q35.args
@@ -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
-- 
2.1.0




More information about the libvir-list mailing list