From mboxrd@z Thu Jan 1 00:00:00 1970 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 From: Gerd Hoffmann 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> Subject: [Qemu-devel] [PATCH 1/3] qdev: allow devices being tagged as not hotpluggable. List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Gerd Hoffmann 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 } }" -- 1.7.1