[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 2/9] Extend <disk> element with controller informati
From: |
Wolfgang Mauerer |
Subject: |
[Qemu-devel] [PATCH 2/9] Extend <disk> element with controller information |
Date: |
Fri, 18 Sep 2009 17:26:09 +0200 |
This allows us to connect a disk with a specific controller,
which is required for disk hotadd/remove. A new XML child
element is added to the <disk> container:
<disk>
...
<controller pci_addr="<addr>" id="<identifier>" bus="<number>"
unit="<number>"/>
</disk>
Either id _or_ pci_addr can be specified. When the controller
has been brought into the system via tghe hotplug mechanism also
included in this patch series, it will typically have an ID.
In other cases, the controller can also be specified with
the PCI address.
Wrt. the data structures touched in this commit, notice
that while "bus" as subelement of target specifies
the type of bus (e.g., scsi, ide,...), it is used
to enumerate the buses on the controller here.
Signed-off-by: Wolfgang Mauerer <address@hidden>
Signed-off-by: Jan Kiszka <address@hidden>
---
src/domain_conf.c | 29 +++++++++++++++++++++++++++++
src/domain_conf.h | 5 ++++-
2 files changed, 33 insertions(+), 1 deletions(-)
diff --git a/src/domain_conf.c b/src/domain_conf.c
index 5ae0775..a6120c8 100644
--- a/src/domain_conf.c
+++ b/src/domain_conf.c
@@ -650,7 +650,12 @@ virDomainDiskDefParseXML(virConnectPtr conn,
char *driverType = NULL;
char *source = NULL;
char *target = NULL;
+ char *controller = NULL;
+ char *bus_id = NULL;
+ char *unit_id = NULL;
+ char *controller_id = NULL;
char *bus = NULL;
+ char *unit = NULL;
char *cachetag = NULL;
char *devaddr = NULL;
virStorageEncryptionPtr encryption = NULL;
@@ -694,12 +699,18 @@ virDomainDiskDefParseXML(virConnectPtr conn,
(xmlStrEqual(cur->name, BAD_CAST "target"))) {
target = virXMLPropString(cur, "dev");
bus = virXMLPropString(cur, "bus");
+ unit = virXMLPropString(cur, "unit");
/* HACK: Work around for compat with Xen
* driver in previous libvirt releases */
if (target &&
STRPREFIX(target, "ioemu:"))
memmove(target, target+6, strlen(target)-5);
+ } else if ((controller == NULL) &&
+ (xmlStrEqual(cur->name, BAD_CAST "controller"))) {
+ controller_id = virXMLPropString(cur, "id");
+ bus_id = virXMLPropString(cur, "bus");
+ unit_id = virXMLPropString(cur, "unit");
} else if ((driverName == NULL) &&
(xmlStrEqual(cur->name, BAD_CAST "driver"))) {
driverName = virXMLPropString(cur, "name");
@@ -800,6 +811,24 @@ virDomainDiskDefParseXML(virConnectPtr conn,
}
}
+ if (controller) {
+ def->controller_id = controller_id;
+
+ def->bus_id = -1;
+ if (bus_id && virStrToLong_i(bus_id, NULL, 10, &def->bus_id) < 0) {
+ virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR, "%s",
+ _("Cannot parse <controller> 'bus' attribute"));
+ goto error;
+ }
+
+ def->unit_id = -1;
+ if (unit_id && virStrToLong_i(unit_id, NULL, 10, &def->unit_id) < 0) {
+ virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR, "%s",
+ _("Cannot parse <controller> 'unit' attribute"));
+ goto error;
+ }
+ }
+
if (def->device == VIR_DOMAIN_DISK_DEVICE_FLOPPY &&
def->bus != VIR_DOMAIN_DISK_BUS_FDC) {
virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR,
diff --git a/src/domain_conf.h b/src/domain_conf.h
index 09368d9..898f6c9 100644
--- a/src/domain_conf.h
+++ b/src/domain_conf.h
@@ -105,9 +105,12 @@ typedef virDomainDiskDef *virDomainDiskDefPtr;
struct _virDomainDiskDef {
int type;
int device;
- int bus;
+ int bus; /* Bus type, e.g. scsi or ide */
+ int bus_id; /* Bus number on the controller */
+ int unit_id; /* Unit on the controller */
char *src;
char *dst;
+ char *controller_id;
char *driverName;
char *driverType;
char *serial;
--
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 <=
- [Qemu-devel] [PATCH 6/9] Allow controller selection by ID, Wolfgang Mauerer, 2009/09/19
- [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