diff options
Diffstat (limited to 'blockdev.c')
-rw-r--r-- | blockdev.c | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/blockdev.c b/blockdev.c index 0621390ea6..f7f591fe78 100644 --- a/blockdev.c +++ b/blockdev.c @@ -687,13 +687,15 @@ int do_drive_del(Monitor *mon, const QDict *qdict, QObject **ret_data) /* clean up guest state from pointing to host resource by * finding and removing DeviceState "drive" property */ - 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; + 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; + } } } } |