Commit 3320e56e54021acab2d6eeb4797ddac30c2411ef
Committed by
Anthony Liguori
1 parent
b6b61144
qdev: add no_user, alias and desc
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 <kraxel@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Showing
2 changed files
with
15 additions
and
0 deletions
hw/qdev.c
| ... | ... | @@ -50,6 +50,7 @@ static DeviceInfo *qdev_find_info(BusInfo *bus_info, const char *name) |
| 50 | 50 | { |
| 51 | 51 | DeviceInfo *info; |
| 52 | 52 | |
| 53 | + /* first check device names */ | |
| 53 | 54 | for (info = device_info_list; info != NULL; info = info->next) { |
| 54 | 55 | if (bus_info && info->bus_info != bus_info) |
| 55 | 56 | continue; |
| ... | ... | @@ -57,6 +58,17 @@ static DeviceInfo *qdev_find_info(BusInfo *bus_info, const char *name) |
| 57 | 58 | continue; |
| 58 | 59 | return info; |
| 59 | 60 | } |
| 61 | + | |
| 62 | + /* failing that check the aliases */ | |
| 63 | + for (info = device_info_list; info != NULL; info = info->next) { | |
| 64 | + if (bus_info && info->bus_info != bus_info) | |
| 65 | + continue; | |
| 66 | + if (!info->alias) | |
| 67 | + continue; | |
| 68 | + if (strcmp(info->alias, name) != 0) | |
| 69 | + continue; | |
| 70 | + return info; | |
| 71 | + } | |
| 60 | 72 | return NULL; |
| 61 | 73 | } |
| 62 | 74 | ... | ... |
hw/qdev.h
| ... | ... | @@ -95,8 +95,11 @@ typedef void (*SCSIAttachFn)(DeviceState *host, BlockDriverState *bdrv, |
| 95 | 95 | |
| 96 | 96 | struct DeviceInfo { |
| 97 | 97 | const char *name; |
| 98 | + const char *alias; | |
| 99 | + const char *desc; | |
| 98 | 100 | size_t size; |
| 99 | 101 | Property *props; |
| 102 | + int no_user; | |
| 100 | 103 | |
| 101 | 104 | /* Private to qdev / bus. */ |
| 102 | 105 | qdev_initfn init; | ... | ... |