Skip to content
  • Markus Armbruster's avatar
    blockdev: Fix blockdev-add not to create DriveInfo · 26f8b3a8
    Markus Armbruster authored
    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: default avatarMarkus Armbruster <armbru@redhat.com>
    Reviewed-by: default avatarMax Reitz <mreitz@redhat.com>
    Signed-off-by: default avatarKevin Wolf <kwolf@redhat.com>
    26f8b3a8