blockdev: Fix blockdev-add not to create DriveInfo
commit26f8b3a84750546342d4397f86efb1ea7798d5dd
authorMarkus Armbruster <armbru@redhat.com>
Tue, 7 Oct 2014 11:59:22 +0000 (7 13:59 +0200)
committerKevin Wolf <kwolf@redhat.com>
Mon, 20 Oct 2014 12:03:50 +0000 (20 14:03 +0200)
tree8fd070e6bda1831dcb46333569049e0f04c5d4d7
parentd3aeb1b7dadacabd175efd515c7c52642141be87
blockdev: Fix blockdev-add not to create DriveInfo

blockdev_init() always creates a DriveInfo, but only drive_new() fills
it in.  qmp_blockdev_add() leaves it blank.  This results in a drive
with type = IF_IDE, bus = 0, unit = 0.  Screwed up in commit ee13ed1c.

Board initialization code looking for IDE drive (0,0) can pick up one
of these bogus drives.  The QMP command has to execute really early to
be visible.  Not sure how likely that is in practice.

Fix by creating DriveInfo in drive_new().  Block backends created by
blockdev-add don't get one.

Breaks the test for "has been created by qmp_blockdev_add()" in
blockdev_mark_auto_del() and do_drive_del(), because it changes the
value of dinfo && !dinfo->enable_auto_del from true to false.  Simply
test !dinfo instead.

Leaves DriveInfo member enable_auto_del unused.  Drop it.

A few places assume a block backend always has a DriveInfo.  Fix them
up.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
block/block-backend.c
blockdev.c
hw/block/block.c
hw/ide/qdev.c
hw/scsi/scsi-disk.c
include/sysemu/blockdev.h