diff options
author | Anthony Liguori <aliguori@us.ibm.com> | 2011-04-07 09:56:09 -0500 |
---|---|---|
committer | Anthony Liguori <aliguori@us.ibm.com> | 2011-04-07 09:56:09 -0500 |
commit | f124a410ea12a644c3577c5303846c37baa5e819 (patch) | |
tree | b1deb798b7ff6dc9ea95968f4aa5a96c8358ec61 /blockdev.c | |
parent | e54f17713f638189e79dac5ba0aa0ce606788777 (diff) | |
parent | 52c050236eaa4f0b5e1d160cd66dc18106445c4d (diff) | |
download | qemu-f124a410ea12a644c3577c5303846c37baa5e819.zip qemu-f124a410ea12a644c3577c5303846c37baa5e819.tar.gz qemu-f124a410ea12a644c3577c5303846c37baa5e819.tar.bz2 |
Merge remote branch 'kwolf/for-anthony' into staging
Diffstat (limited to 'blockdev.c')
-rw-r--r-- | blockdev.c | 25 |
1 files changed, 8 insertions, 17 deletions
@@ -737,8 +737,6 @@ int do_drive_del(Monitor *mon, const QDict *qdict, QObject **ret_data) { const char *id = qdict_get_str(qdict, "id"); BlockDriverState *bs; - BlockDriverState **ptr; - Property *prop; bs = bdrv_find(id); if (!bs) { @@ -755,24 +753,17 @@ int do_drive_del(Monitor *mon, const QDict *qdict, QObject **ret_data) bdrv_flush(bs); bdrv_close(bs); - /* clean up guest state from pointing to host resource by - * finding and removing DeviceState "drive" property */ + /* if we have a device associated with this BlockDriverState (bs->peer) + * then we need to make the drive anonymous until the device + * can be removed. If this is a drive with no device backing + * then we can just get rid of the block driver state right here. + */ if (bs->peer) { - for (prop = bs->peer->info->props; prop && prop->name; prop++) { - if (prop->info->type == PROP_TYPE_DRIVE) { - ptr = qdev_get_prop_ptr(bs->peer, prop); - if (*ptr == bs) { - bdrv_detach(bs, bs->peer); - *ptr = NULL; - break; - } - } - } + bdrv_make_anon(bs); + } else { + drive_uninit(drive_get_by_blockdev(bs)); } - /* clean up host side */ - drive_uninit(drive_get_by_blockdev(bs)); - return 0; } |