From patchwork Thu Nov 18 10:45:16 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gerd Hoffmann X-Patchwork-Id: 72075 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 3D43FB71B1 for ; Thu, 18 Nov 2010 21:47:12 +1100 (EST) Received: from localhost ([127.0.0.1]:52813 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PJ21D-0001Lg-A8 for incoming@patchwork.ozlabs.org; Thu, 18 Nov 2010 05:47:07 -0500 Received: from [140.186.70.92] (port=34812 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PJ1ze-0001K2-5I for qemu-devel@nongnu.org; Thu, 18 Nov 2010 05:45:33 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PJ1zc-00084X-2j for qemu-devel@nongnu.org; Thu, 18 Nov 2010 05:45:30 -0500 Received: from mx1.redhat.com ([209.132.183.28]:48770) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PJ1zb-000848-RL for qemu-devel@nongnu.org; Thu, 18 Nov 2010 05:45:28 -0500 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id oAIAjRMM006743 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 18 Nov 2010 05:45:27 -0500 Received: from rincewind.home.kraxel.org (vpn2-11-75.ams2.redhat.com [10.36.11.75]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id oAIAjNWr016716; Thu, 18 Nov 2010 05:45:24 -0500 Received: by rincewind.home.kraxel.org (Postfix, from userid 500) id B98004582C; Thu, 18 Nov 2010 11:45:19 +0100 (CET) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Thu, 18 Nov 2010 11:45:16 +0100 Message-Id: <1290077118-11577-2-git-send-email-kraxel@redhat.com> In-Reply-To: <1290077118-11577-1-git-send-email-kraxel@redhat.com> References: <1290077118-11577-1-git-send-email-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. Cc: Gerd Hoffmann Subject: [Qemu-devel] [PATCH 1/3] qdev: allow devices being tagged as not hotpluggable. 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 patch adds a field to DeviceInfo to tag devices as being not hotpluggable. Any attempt to plug-in or -out such a device will throw an error. This check is done in addition to the check whenever the bus supports hotplug, i.e. there is no need to tag devices which sit on busses without hotplug support (ISA for example). Signed-off-by: Gerd Hoffmann --- hw/qdev.c | 16 +++++++++++++--- hw/qdev.h | 1 + qerror.c | 4 ++++ qerror.h | 3 +++ 4 files changed, 21 insertions(+), 3 deletions(-) diff --git a/hw/qdev.c b/hw/qdev.c index 35858cb..5ef5346 100644 --- a/hw/qdev.c +++ b/hw/qdev.c @@ -234,9 +234,15 @@ DeviceState *qdev_device_add(QemuOpts *opts) return NULL; } } - if (qdev_hotplug && !bus->allow_hotplug) { - qerror_report(QERR_BUS_NO_HOTPLUG, bus->name); - return NULL; + if (qdev_hotplug) { + if (!bus->allow_hotplug) { + qerror_report(QERR_BUS_NO_HOTPLUG, bus->name); + return NULL; + } + if (info->no_hotplug) { + qerror_report(QERR_DEVICE_NO_HOTPLUG, info->name); + return NULL; + } } /* create device, set properties */ @@ -303,6 +309,10 @@ int qdev_unplug(DeviceState *dev) qerror_report(QERR_BUS_NO_HOTPLUG, dev->parent_bus->name); return -1; } + if (dev->info->no_hotplug) { + qerror_report(QERR_DEVICE_NO_HOTPLUG, dev->info->name); + return -1; + } assert(dev->info->unplug != NULL); return dev->info->unplug(dev); diff --git a/hw/qdev.h b/hw/qdev.h index 579328a..5b57b2b 100644 --- a/hw/qdev.h +++ b/hw/qdev.h @@ -144,6 +144,7 @@ struct DeviceInfo { size_t size; Property *props; int no_user; + int no_hotplug; /* callbacks */ qdev_resetfn reset; diff --git a/qerror.c b/qerror.c index ac2cdaf..9d0cdeb 100644 --- a/qerror.c +++ b/qerror.c @@ -101,6 +101,10 @@ static const QErrorStringTable qerror_table[] = { .desc = "Device '%(device)' has no child bus", }, { + .error_fmt = QERR_DEVICE_NO_HOTPLUG, + .desc = "Device '%(device)' does not support hotplugging", + }, + { .error_fmt = QERR_DUPLICATE_ID, .desc = "Duplicate ID '%(id)' for %(object)", }, diff --git a/qerror.h b/qerror.h index 943a24b..b0f69da 100644 --- a/qerror.h +++ b/qerror.h @@ -90,6 +90,9 @@ QError *qobject_to_qerror(const QObject *obj); #define QERR_DEVICE_NO_BUS \ "{ 'class': 'DeviceNoBus', 'data': { 'device': %s } }" +#define QERR_DEVICE_NO_HOTPLUG \ + "{ 'class': 'DeviceNoHotplug', 'data': { 'device': %s } }" + #define QERR_DUPLICATE_ID \ "{ 'class': 'DuplicateId', 'data': { 'id': %s, 'object': %s } }"