[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 5/8] qdev: add no_user, alias and desc
From: |
Gerd Hoffmann |
Subject: |
[Qemu-devel] [PATCH 5/8] qdev: add no_user, alias and desc |
Date: |
Wed, 1 Jul 2009 10:57:17 +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 042c7f7..48d0fb9 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;
}
@@ -102,7 +114,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;
}
@@ -117,6 +136,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 13cafe5..f81e850 100644
--- a/hw/qdev.h
+++ b/hw/qdev.h
@@ -79,8 +79,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/8] qdev patches, batch #2, Gerd Hoffmann, 2009/07/01
- [Qemu-devel] [PATCH 3/8] qdev: add generic qdev_device_add(), Gerd Hoffmann, 2009/07/01
- [Qemu-devel] [PATCH 2/8] qdev/pci: make pci_create return DeviceState instead of PCIDevice., Gerd Hoffmann, 2009/07/01
- [Qemu-devel] [PATCH 1/8] qdev: factor out driver search to qdev_find_info(), Gerd Hoffmann, 2009/07/01
- [Qemu-devel] [PATCH 4/8] qdev: add -device command line option., Gerd Hoffmann, 2009/07/01
- [Qemu-devel] [PATCH 5/8] qdev: add no_user, alias and desc,
Gerd Hoffmann <=
- [Qemu-devel] [PATCH 8/8] qdev/pci: hook up i440fx., Gerd Hoffmann, 2009/07/01
- [Qemu-devel] [PATCH 6/8] qdev: es1370 description, Gerd Hoffmann, 2009/07/01
- [Qemu-devel] [PATCH 7/8] qdev: convert all vga, Gerd Hoffmann, 2009/07/01