From: Wolfgang Mauerer <wolfgang.maue...@siemens.com> ... by simply traversing the list of controllers to find the associated PCI address.
Signed-off-by: Wolfgang Mauerer <wolfgang.maue...@siemens.com> Signed-off-by: Jan Kiszka <jan.kis...@siemens.com> --- src/qemu/qemu_driver.c | 37 +++++++++++++++++++++++++++++-------- 1 files changed, 29 insertions(+), 8 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 1b20937..d3395a7 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -4407,19 +4407,40 @@ try_command: } if (controller_specified) { - /* NOTE: Proper check for the controller will be implemented - in a later commit */ - domain = dev->data.disk->controller_pci_addr.domain; - bus = dev->data.disk->controller_pci_addr.bus; - slot = dev->data.disk->controller_pci_addr.slot; - if (dev->data.disk->controller_name) { - /* TODO: Obtain the PCI address of the controller - from the data structures using the ID */ + for (i = 0 ; i < vm->def->ncontrollers ; i++) { + if (STREQ(dev->data.disk->controller_name, + vm->def->controllers[i]->name)) { + break; + } + } + + if (i == vm->def->ncontrollers) { + qemudReportError(conn, dom, NULL, VIR_ERR_OPERATION_FAILED, + _("Controller does not exist")); + return -1; + } + + domain = vm->def->controllers[i]->address->data.pci.domain; + bus = vm->def->controllers[i]->address->data.pci.bus; + slot = vm->def->controllers[i]->address->data.pci.slot; } else { domain = dev->data.disk->controller_pci_addr.domain; bus = dev->data.disk->controller_pci_addr.bus; slot = dev->data.disk->controller_pci_addr.slot; + + for (i = 0 ; i < vm->def->ncontrollers ; i++) { + if (domain == vm->def->controllers[i]->address->data.pci.domain && + bus == vm->def->controllers[i]->address->data.pci.bus && + slot == vm->def->controllers[i]->address->data.pci.slot) + break; + } + + if (i == vm->def->ncontrollers) { + qemudReportError(conn, dom, NULL, VIR_ERR_OPERATION_FAILED, + _("Controller does not exist")); + return -1; + } } if (dev->data.disk->bus_id != -1) { -- 1.6.4 -- Libvir-list mailing list Libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list