aboutsummaryrefslogtreecommitdiff
path: root/block
diff options
context:
space:
mode:
Diffstat (limited to 'block')
-rw-r--r--block/backup-top.c14
-rw-r--r--block/backup.c14
2 files changed, 22 insertions, 6 deletions
diff --git a/block/backup-top.c b/block/backup-top.c
index 3b50c06e2c..79b268e6dc 100644
--- a/block/backup-top.c
+++ b/block/backup-top.c
@@ -148,8 +148,10 @@ static void backup_top_child_perm(BlockDriverState *bs, BdrvChild *c,
*
* Share write to target (child_file), to not interfere
* with guest writes to its disk which may be in target backing chain.
+ * Can't resize during a backup block job because we check the size
+ * only upfront.
*/
- *nshared = BLK_PERM_ALL;
+ *nshared = BLK_PERM_ALL & ~BLK_PERM_RESIZE;
*nperm = BLK_PERM_WRITE;
} else {
/* Source child */
@@ -159,7 +161,7 @@ static void backup_top_child_perm(BlockDriverState *bs, BdrvChild *c,
if (perm & BLK_PERM_WRITE) {
*nperm = *nperm | BLK_PERM_CONSISTENT_READ;
}
- *nshared &= ~BLK_PERM_WRITE;
+ *nshared &= ~(BLK_PERM_WRITE | BLK_PERM_RESIZE);
}
}
@@ -192,11 +194,13 @@ BlockDriverState *bdrv_backup_top_append(BlockDriverState *source,
{
Error *local_err = NULL;
BDRVBackupTopState *state;
- BlockDriverState *top = bdrv_new_open_driver(&bdrv_backup_top_filter,
- filter_node_name,
- BDRV_O_RDWR, errp);
+ BlockDriverState *top;
bool appended = false;
+ assert(source->total_sectors == target->total_sectors);
+
+ top = bdrv_new_open_driver(&bdrv_backup_top_filter, filter_node_name,
+ BDRV_O_RDWR, errp);
if (!top) {
return NULL;
}
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;