block: fail live snapshot if disk has no medium

Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
This commit is contained in:
Paolo Bonzini 2012-04-12 14:00:59 +02:00 committed by Kevin Wolf
parent 31155b9b3c
commit e86fe18ac9

View File

@ -756,14 +756,17 @@ void qmp_transaction(BlockdevActionList *dev_list, Error **errp)
goto delete_and_fail; goto delete_and_fail;
} }
if (!bdrv_is_inserted(states->old_bs)) {
error_set(errp, QERR_DEVICE_HAS_NO_MEDIUM, device);
goto delete_and_fail;
}
if (bdrv_in_use(states->old_bs)) { if (bdrv_in_use(states->old_bs)) {
error_set(errp, QERR_DEVICE_IN_USE, device); error_set(errp, QERR_DEVICE_IN_USE, device);
goto delete_and_fail; goto delete_and_fail;
} }
if (!bdrv_is_read_only(states->old_bs) && if (!bdrv_is_read_only(states->old_bs)) {
bdrv_is_inserted(states->old_bs)) {
if (bdrv_flush(states->old_bs)) { if (bdrv_flush(states->old_bs)) {
error_set(errp, QERR_IO_ERROR); error_set(errp, QERR_IO_ERROR);
goto delete_and_fail; goto delete_and_fail;