From patchwork Fri Sep 18 15:26:09 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wolfgang Mauerer X-Patchwork-Id: 33932 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 2B764B7B75 for ; Sat, 19 Sep 2009 16:32:19 +1000 (EST) Received: from localhost ([127.0.0.1]:33904 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MotUV-0000bs-Ud for incoming@patchwork.ozlabs.org; Sat, 19 Sep 2009 02:32:15 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MofLs-0005Lg-Vz for qemu-devel@nongnu.org; Fri, 18 Sep 2009 11:26:25 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MofLn-0005GE-UP for qemu-devel@nongnu.org; Fri, 18 Sep 2009 11:26:24 -0400 Received: from [199.232.76.173] (port=49814 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MofLn-0005Fy-MT for qemu-devel@nongnu.org; Fri, 18 Sep 2009 11:26:19 -0400 Received: from gecko.sbs.de ([194.138.37.40]:19596) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1MofLn-0003LN-1C for qemu-devel@nongnu.org; Fri, 18 Sep 2009 11:26:19 -0400 Received: from mail1.sbs.de (localhost [127.0.0.1]) by gecko.sbs.de (8.12.11.20060308/8.12.11) with ESMTP id n8IFODD1025872; Fri, 18 Sep 2009 17:24:13 +0200 Received: from localhost.localdomain (mchn315c.mchp.siemens.de [139.25.109.82]) by mail1.sbs.de (8.12.11.20060308/8.12.11) with ESMTP id n8IFODD0015178; Fri, 18 Sep 2009 17:24:13 +0200 From: Wolfgang Mauerer To: libvir-list@redhat.com Date: Fri, 18 Sep 2009 17:26:09 +0200 Message-Id: <1253287576-12875-3-git-send-email-wolfgang.mauerer@siemens.com> X-Mailer: git-send-email 1.6.4 In-Reply-To: <1253287576-12875-1-git-send-email-wolfgang.mauerer@siemens.com> References: <1253287576-12875-1-git-send-email-wolfgang.mauerer@siemens.com> X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.4-2.6 X-Mailman-Approved-At: Sat, 19 Sep 2009 02:10:30 -0400 Cc: jan.kiszka@siemens.com, qemu-devel@nongnu.org, wlm.libvirt@googlemail.com Subject: [Qemu-devel] [PATCH 2/9] Extend element with controller information X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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 container: ... 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 Signed-off-by: Jan Kiszka --- 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 '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 '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;