blockdev-backup: Use bdrv_lookup_bs on target
This allows backing up to a BDS that has not been attached to any BB. Signed-off-by: Fam Zheng <famz@redhat.com> Message-id: 1463969978-24970-2-git-send-email-famz@redhat.com Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
This commit is contained in:
parent
271b385e7e
commit
0d97891312
13
blockdev.c
13
blockdev.c
@ -3335,7 +3335,7 @@ void do_blockdev_backup(const char *device, const char *target,
|
||||
BlockdevOnError on_target_error,
|
||||
BlockJobTxn *txn, Error **errp)
|
||||
{
|
||||
BlockBackend *blk, *target_blk;
|
||||
BlockBackend *blk;
|
||||
BlockDriverState *bs;
|
||||
BlockDriverState *target_bs;
|
||||
Error *local_err = NULL;
|
||||
@ -3366,18 +3366,11 @@ void do_blockdev_backup(const char *device, const char *target,
|
||||
}
|
||||
bs = blk_bs(blk);
|
||||
|
||||
target_blk = blk_by_name(target);
|
||||
if (!target_blk) {
|
||||
error_setg(errp, "Device '%s' not found", target);
|
||||
target_bs = bdrv_lookup_bs(target, target, errp);
|
||||
if (!target_bs) {
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (!blk_is_available(target_blk)) {
|
||||
error_setg(errp, "Device '%s' has no medium", target);
|
||||
goto out;
|
||||
}
|
||||
target_bs = blk_bs(target_blk);
|
||||
|
||||
bdrv_set_aio_context(target_bs, aio_context);
|
||||
backup_start(bs, target_bs, speed, sync, NULL, on_source_error,
|
||||
on_target_error, block_job_cb, bs, txn, &local_err);
|
||||
|
Loading…
Reference in New Issue
Block a user