[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 06/13] qdev: add no_user, alias and desc
From: |
Gerd Hoffmann |
Subject: |
[Qemu-devel] [PATCH 06/13] qdev: add no_user, alias and desc |
Date: |
Fri, 10 Jul 2009 13:26:12 +0200 |
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 <address@hidden>
---
hw/qdev.c | 26 +++++++++++++++++++++++++-
hw/qdev.h | 3 +++
2 files changed, 28 insertions(+), 1 deletions(-)
diff --git a/hw/qdev.c b/hw/qdev.c
index 3f8e456..dcca6ac 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;
}
@@ -105,7 +117,14 @@ DeviceState *qdev_device_add(const char *cmdline)
}
if (strcmp(driver, "?") == 0) {
for (info = device_info_list; info != NULL; info = info->next) {
- fprintf(stderr, "name \"%s\", bus %s\n", info->name,
info->bus_info->name);
+ fprintf(stderr, "name \"%s\", bus %s", info->name,
info->bus_info->name);
+ if (info->alias)
+ fprintf(stderr, ", alias \"%s\"", info->alias);
+ if (info->desc)
+ fprintf(stderr, ", desc \"%s\"", info->desc);
+ if (info->no_user)
+ fprintf(stderr, ", no-user");
+ fprintf(stderr, "\n");
}
return NULL;
}
@@ -125,6 +144,11 @@ DeviceState *qdev_device_add(const char *cmdline)
info->bus_info->name);
return NULL;
}
+ if (info->no_user) {
+ fprintf(stderr, "device \"%s\" can't be added via command line\n",
+ info->name);
+ return NULL;
+ }
qdev = info->bus_info->add_dev(driver, strlen(addr) ? addr : NULL);
diff --git a/hw/qdev.h b/hw/qdev.h
index 98c11a0..15c1481 100644
--- a/hw/qdev.h
+++ b/hw/qdev.h
@@ -80,8 +80,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
- [Qemu-devel] [PATCH 04/13] qdev: add generic qdev_device_add(), (continued)
- [Qemu-devel] [PATCH 04/13] qdev: add generic qdev_device_add(), Gerd Hoffmann, 2009/07/10
- Re: [Qemu-devel] [PATCH 04/13] qdev: add generic qdev_device_add(), Paul Brook, 2009/07/10
- Re: [Qemu-devel] [PATCH 04/13] qdev: add generic qdev_device_add(), Gerd Hoffmann, 2009/07/10
- Re: [Qemu-devel] [PATCH 04/13] qdev: add generic qdev_device_add(), Paul Brook, 2009/07/10
- Re: [Qemu-devel] [PATCH 04/13] qdev: add generic qdev_device_add(), Gerd Hoffmann, 2009/07/14
- Re: [Qemu-devel] [PATCH 04/13] qdev: add generic qdev_device_add(), Markus Armbruster, 2009/07/14
- Re: [Qemu-devel] [PATCH 04/13] qdev: add generic qdev_device_add(), Markus Armbruster, 2009/07/14
- Re: [Qemu-devel] [PATCH 04/13] qdev: add generic qdev_device_add(), Gerd Hoffmann, 2009/07/15
[Qemu-devel] [PATCH 02/13] qdev: factor out driver search to qdev_find_info(), Gerd Hoffmann, 2009/07/10
[Qemu-devel] [PATCH 03/13] qdev/pci: make pci_create return DeviceState instead of PCIDevice., Gerd Hoffmann, 2009/07/10
[Qemu-devel] [PATCH 06/13] qdev: add no_user, alias and desc,
Gerd Hoffmann <=
[Qemu-devel] [PATCH 07/13] qdev: es1370 description, Gerd Hoffmann, 2009/07/10
[Qemu-devel] [PATCH 08/13] qdev: convert all vga, Gerd Hoffmann, 2009/07/10
[Qemu-devel] [PATCH 13/13] qdev: print device id in "info pci"., Gerd Hoffmann, 2009/07/10
[Qemu-devel] [PATCH 09/13] qdev/pci: hook up i440fx., Gerd Hoffmann, 2009/07/10
[Qemu-devel] [PATCH 01/13] qdev: rework device properties., Gerd Hoffmann, 2009/07/10
[Qemu-devel] [PATCH 10/13] qdev: add user-specified identifier to devices., Gerd Hoffmann, 2009/07/10