[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, 3 Jul 2009 12:22:51 +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 82bcd04..d72a8ef 100644
--- a/hw/qdev.c
+++ b/hw/qdev.c
@@ -50,6 +50,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;
@@ -57,6 +58,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;
}
@@ -104,7 +116,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;
}
@@ -119,6 +138,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(driver, strlen(addr) ? addr : NULL);
diff --git a/hw/qdev.h b/hw/qdev.h
index a856576..03413b1 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 0/13] qdev patches: properties, -device switch, id=<tag> & more., Gerd Hoffmann, 2009/07/03
- [Qemu-devel] [PATCH 02/13] qdev: factor out driver search to qdev_find_info(), Gerd Hoffmann, 2009/07/03
- [Qemu-devel] [PATCH 03/13] qdev/pci: make pci_create return DeviceState instead of PCIDevice., Gerd Hoffmann, 2009/07/03
- [Qemu-devel] [PATCH 04/13] qdev: add generic qdev_device_add(), Gerd Hoffmann, 2009/07/03
- [Qemu-devel] [PATCH 07/13] qdev: es1370 description, Gerd Hoffmann, 2009/07/03
- [Qemu-devel] [PATCH 06/13] qdev: add no_user, alias and desc,
Gerd Hoffmann <=
- [Qemu-devel] [PATCH 05/13] qdev: add -device command line option., Gerd Hoffmann, 2009/07/03
- [Qemu-devel] [PATCH 10/13] qdev: add user-specified identifier to devices., Gerd Hoffmann, 2009/07/03
- [Qemu-devel] [PATCH 08/13] qdev: convert all vga, Gerd Hoffmann, 2009/07/03
- [Qemu-devel] [PATCH 13/13] qdev: print device id in "info pci"., Gerd Hoffmann, 2009/07/03
- [Qemu-devel] [PATCH 09/13] qdev/pci: hook up i440fx., Gerd Hoffmann, 2009/07/03
- [Qemu-devel] [PATCH 01/13] qdev: rework device properties., Gerd Hoffmann, 2009/07/03
- [Qemu-devel] [PATCH 11/13] switch balloon initialization to -device., Gerd Hoffmann, 2009/07/03
- [Qemu-devel] [PATCH 12/13] qdev: add id= support for pci nics., Gerd Hoffmann, 2009/07/03