aboutsummaryrefslogtreecommitdiff
path: root/block/backup.c
diff options
context:
space:
mode:
Diffstat (limited to 'block/backup.c')
-rw-r--r--block/backup.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/block/backup.c b/block/backup.c
index c4c3b8cd46..4f13bb20a5 100644
--- a/block/backup.c
+++ b/block/backup.c
@@ -340,7 +340,7 @@ BlockJob *backup_job_create(const char *job_id, BlockDriverState *bs,
BlockCompletionFunc *cb, void *opaque,
JobTxn *txn, Error **errp)
{
- int64_t len;
+ int64_t len, target_len;
BackupBlockJob *job = NULL;
int64_t cluster_size;
BdrvRequestFlags write_flags;
@@ -405,6 +405,18 @@ BlockJob *backup_job_create(const char *job_id, BlockDriverState *bs,
goto error;
}
+ target_len = bdrv_getlength(target);
+ if (target_len < 0) {
+ error_setg_errno(errp, -target_len, "Unable to get length for '%s'",
+ bdrv_get_device_or_node_name(bs));
+ goto error;
+ }
+
+ if (target_len != len) {
+ error_setg(errp, "Source and target image have different sizes");
+ goto error;
+ }
+
cluster_size = backup_calculate_cluster_size(target, errp);
if (cluster_size < 0) {
goto error;