From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MR2tq-0002mW-4w for qemu-devel@nongnu.org; Wed, 15 Jul 2009 07:43:50 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MR2tl-0002jT-6J for qemu-devel@nongnu.org; Wed, 15 Jul 2009 07:43:49 -0400 Received: from [199.232.76.173] (port=56677 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MR2tl-0002jG-12 for qemu-devel@nongnu.org; Wed, 15 Jul 2009 07:43:45 -0400 Received: from mx2.redhat.com ([66.187.237.31]:36369) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1MR2tk-00039e-EY for qemu-devel@nongnu.org; Wed, 15 Jul 2009 07:43:44 -0400 Received: from int-mx2.corp.redhat.com (int-mx2.corp.redhat.com [172.16.27.26]) by mx2.redhat.com (8.13.8/8.13.8) with ESMTP id n6FBhhb7013580 for ; Wed, 15 Jul 2009 07:43:43 -0400 From: Gerd Hoffmann Date: Wed, 15 Jul 2009 13:43:33 +0200 Message-Id: <1247658216-511-4-git-send-email-kraxel@redhat.com> In-Reply-To: <1247658216-511-1-git-send-email-kraxel@redhat.com> References: <1247658216-511-1-git-send-email-kraxel@redhat.com> Subject: [Qemu-devel] [PATCH 3/6] qdev: add no_user, alias and desc List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Gerd Hoffmann no_user: prevent users from adding certain devices. desc: description of the device. alias: to allow user friendly shortcuts on the command line, i.e. -device usbmouse instead of -device "QEMU USB Mouse" or -device lsi instead of -device lsi53c895a Signed-off-by: Gerd Hoffmann --- hw/qdev.c | 12 ++++++++++++ hw/qdev.h | 3 +++ 2 files changed, 15 insertions(+), 0 deletions(-) diff --git a/hw/qdev.c b/hw/qdev.c index 644a5be..53e9b00 100644 --- a/hw/qdev.c +++ b/hw/qdev.c @@ -51,6 +51,7 @@ static DeviceInfo *qdev_find_info(BusInfo *bus_info, const char *name) { DeviceInfo *info; + /* first check device names */ for (info = device_info_list; info != NULL; info = info->next) { if (bus_info && info->bus_info != bus_info) continue; @@ -58,6 +59,17 @@ static DeviceInfo *qdev_find_info(BusInfo *bus_info, const char *name) continue; return info; } + + /* failing that check the aliases */ + for (info = device_info_list; info != NULL; info = info->next) { + if (bus_info && info->bus_info != bus_info) + continue; + if (!info->alias) + continue; + if (strcmp(info->alias, name) != 0) + continue; + return info; + } return NULL; } diff --git a/hw/qdev.h b/hw/qdev.h index 9ecc9ec..115c2d0 100644 --- a/hw/qdev.h +++ b/hw/qdev.h @@ -87,8 +87,11 @@ typedef void (*SCSIAttachFn)(DeviceState *host, BlockDriverState *bdrv, struct DeviceInfo { const char *name; + const char *alias; + const char *desc; size_t size; Property *props; + int no_user; /* Private to qdev / bus. */ qdev_initfn init; -- 1.6.2.5