mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-01 14:53:54 -06:00
blockdev: Orphaned drive search
When users use command line options like -hda, -cdrom, or even -drive if=ide, it is up to the board initialization routines to pick up these drives and create backing devices for them. Some boards, like Q35, have not been doing this. However, there is no warning explaining why certain drive specifications are just silently ignored, so this function adds a check to print some warnings to assist users in debugging these sorts of issues in the future. This patch will not warn about drives added with if_none, for which it is not possible to tell in advance if the omission of a backing device is an issue. A warning in these cases is considered appropriate. Signed-off-by: John Snow <jsnow@redhat.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> Message-id: 1412187569-23452-2-git-send-email-jsnow@redhat.com Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
This commit is contained in:
parent
cf77b2d25e
commit
a66c9dc734
3 changed files with 32 additions and 1 deletions
21
blockdev.c
21
blockdev.c
|
@ -166,6 +166,27 @@ DriveInfo *drive_get(BlockInterfaceType type, int bus, int unit)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
bool drive_check_orphaned(void)
|
||||
{
|
||||
DriveInfo *dinfo;
|
||||
bool rs = false;
|
||||
|
||||
QTAILQ_FOREACH(dinfo, &drives, next) {
|
||||
/* If dinfo->bdrv->dev is NULL, it has no device attached. */
|
||||
/* Unless this is a default drive, this may be an oversight. */
|
||||
if (!dinfo->bdrv->dev && !dinfo->is_default &&
|
||||
dinfo->type != IF_NONE) {
|
||||
fprintf(stderr, "Warning: Orphaned drive without device: "
|
||||
"id=%s,file=%s,if=%s,bus=%d,unit=%d\n",
|
||||
dinfo->id, dinfo->bdrv->filename, if_name[dinfo->type],
|
||||
dinfo->bus, dinfo->unit);
|
||||
rs = true;
|
||||
}
|
||||
}
|
||||
|
||||
return rs;
|
||||
}
|
||||
|
||||
DriveInfo *drive_get_by_index(BlockInterfaceType type, int index)
|
||||
{
|
||||
return drive_get(type,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue