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:
John Snow 2014-10-01 14:19:24 -04:00 committed by Stefan Hajnoczi
parent cf77b2d25e
commit a66c9dc734
3 changed files with 32 additions and 1 deletions

10
vl.c
View file

@ -1169,6 +1169,7 @@ static void default_drive(int enable, int snapshot, BlockInterfaceType type,
int index, const char *optstr)
{
QemuOpts *opts;
DriveInfo *dinfo;
if (!enable || drive_get_by_index(type, index)) {
return;
@ -1178,9 +1179,13 @@ static void default_drive(int enable, int snapshot, BlockInterfaceType type,
if (snapshot) {
drive_enable_snapshot(opts, NULL);
}
if (!drive_new(opts, type)) {
dinfo = drive_new(opts, type);
if (!dinfo) {
exit(1);
}
dinfo->is_default = true;
}
void qemu_register_boot_set(QEMUBootSetHandler *func, void *opaque)
@ -4457,6 +4462,9 @@ int main(int argc, char **argv, char **envp)
if (qemu_opts_foreach(qemu_find_opts("device"), device_init_func, NULL, 1) != 0)
exit(1);
/* Did we create any drives that we failed to create a device for? */
drive_check_orphaned();
net_check_clients();
ds = init_displaystate();