[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 6/9] Allow controller selection by ID
From: |
Wolfgang Mauerer |
Subject: |
[Qemu-devel] [PATCH 6/9] Allow controller selection by ID |
Date: |
Fri, 18 Sep 2009 17:26:13 +0200 |
... by simply traversing the list of controllers
to find the associated PCI address.
Signed-off-by: Wolfgang Mauerer <address@hidden>
Signed-off-by: Jan Kiszka <address@hidden>
---
src/qemu_driver.c | 41 +++++++++++++++++++++++++++++++----------
1 files changed, 31 insertions(+), 10 deletions(-)
diff --git a/src/qemu_driver.c b/src/qemu_driver.c
index 3bdd2d7..990f05a 100644
--- a/src/qemu_driver.c
+++ b/src/qemu_driver.c
@@ -5418,19 +5418,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_id) {
- /* 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_id,
+ vm->def->controllers[i]->id)) {
+ 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]->pci_addr.domain;
+ bus = vm->def->controllers[i]->pci_addr.bus;
+ slot = vm->def->controllers[i]->pci_addr.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]->pci_addr.domain &&
+ bus == vm->def->controllers[i]->pci_addr.bus &&
+ slot == vm->def->controllers[i]->pci_addr.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) {
@@ -5457,13 +5478,13 @@ try_command:
ret = virAsprintf(&cmd, "pci_add %s storage file=%s,if=%s",
(tryOldSyntax ? "0": "pci_addr=auto"), safe_path, type);
}
-
+
VIR_FREE(safe_path);
if (ret == -1) {
virReportOOMError(conn);
return ret;
}
-
+
if (qemudMonitorCommand(vm, cmd, &reply) < 0) {
qemudReportError(conn, dom, NULL, VIR_ERR_OPERATION_FAILED,
_("cannot attach %s disk"), type);
--
1.6.4
- [Qemu-devel] [PATCH 0/9] Support disk-hotremove and controller hotplugging, Wolfgang Mauerer, 2009/09/19
- [Qemu-devel] [PATCH 7/9] Remove surprises in the semantics of disk-hotadd, Wolfgang Mauerer, 2009/09/19
- [Qemu-devel] [PATCH 4/9] Add disk-based hotplugging for the qemu backend, Wolfgang Mauerer, 2009/09/19
- [Qemu-devel] [PATCH 3/9] Add new domain device: "controller", Wolfgang Mauerer, 2009/09/19
- [Qemu-devel] [PATCH 9/9] Implement disk- and controller hotremove, Wolfgang Mauerer, 2009/09/19
- [Qemu-devel] [PATCH 5/9] Implement controller hotplugging, Wolfgang Mauerer, 2009/09/19
- [Qemu-devel] [PATCH 2/9] Extend <disk> element with controller information, Wolfgang Mauerer, 2009/09/19
- [Qemu-devel] [PATCH 6/9] Allow controller selection by ID,
Wolfgang Mauerer <=
- [Qemu-devel] [PATCH 1/9] Clarify documentation for private symbols, Wolfgang Mauerer, 2009/09/19
- [Qemu-devel] [PATCH 8/9] Factor out the method to get the PCI address of a controller for a given disk, Wolfgang Mauerer, 2009/09/19