From 26f8b3a84750546342d4397f86efb1ea7798d5dd Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Tue, 7 Oct 2014 13:59:22 +0200 Subject: 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 Reviewed-by: Max Reitz Signed-off-by: Kevin Wolf --- block/block-backend.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'block/block-backend.c') diff --git a/block/block-backend.c b/block/block-backend.c index a3e613b383..ae30873df1 100644 --- a/block/block-backend.c +++ b/block/block-backend.c @@ -18,7 +18,7 @@ struct BlockBackend { char *name; int refcnt; BlockDriverState *bs; - DriveInfo *legacy_dinfo; + DriveInfo *legacy_dinfo; /* null unless created by drive_new() */ QTAILQ_ENTRY(BlockBackend) link; /* for blk_backends */ }; -- cgit v1.2.3