aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKevin Wolf <kwolf@redhat.com>2019-02-27 17:25:08 +0100
committerKevin Wolf <kwolf@redhat.com>2019-03-08 12:26:46 +0100
commitaa8b34c1b21b8a977de0293cfba9fb91ed14350d (patch)
treeee6d67aeae6b5e570da8cb83cbb249e0fcdc351a
parent966b000f49c3f44d2853d691f6bbc2a4e1f2d0b0 (diff)
downloadqemu-aa8b34c1b21b8a977de0293cfba9fb91ed14350d.zip
qemu-aa8b34c1b21b8a977de0293cfba9fb91ed14350d.tar.gz
qemu-aa8b34c1b21b8a977de0293cfba9fb91ed14350d.tar.bz2
qcow2: Return error for snapshot operation with data file
Internal snapshots and an external data file are incompatible because snapshots require refcounting and non-linear mapping. Return an error for all of the snapshot operations if an external data file is in use. Signed-off-by: Kevin Wolf <kwolf@redhat.com>
-rw-r--r--block/qcow2-snapshot.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/block/qcow2-snapshot.c b/block/qcow2-snapshot.c
index 5ae3407..a6ffae8 100644
--- a/block/qcow2-snapshot.c
+++ b/block/qcow2-snapshot.c
@@ -353,6 +353,10 @@ int qcow2_snapshot_create(BlockDriverState *bs, QEMUSnapshotInfo *sn_info)
return -EFBIG;
}
+ if (has_data_file(bs)) {
+ return -ENOTSUP;
+ }
+
memset(sn, 0, sizeof(*sn));
/* Generate an ID */
@@ -466,6 +470,10 @@ int qcow2_snapshot_goto(BlockDriverState *bs, const char *snapshot_id)
int ret;
uint64_t *sn_l1_table = NULL;
+ if (has_data_file(bs)) {
+ return -ENOTSUP;
+ }
+
/* Search the snapshot */
snapshot_index = find_snapshot_by_id_or_name(bs, snapshot_id);
if (snapshot_index < 0) {
@@ -599,6 +607,10 @@ int qcow2_snapshot_delete(BlockDriverState *bs,
QCowSnapshot sn;
int snapshot_index, ret;
+ if (has_data_file(bs)) {
+ return -ENOTSUP;
+ }
+
/* Search the snapshot */
snapshot_index = find_snapshot_by_id_and_name(bs, snapshot_id, name);
if (snapshot_index < 0) {
@@ -670,6 +682,9 @@ int qcow2_snapshot_list(BlockDriverState *bs, QEMUSnapshotInfo **psn_tab)
QCowSnapshot *sn;
int i;
+ if (has_data_file(bs)) {
+ return -ENOTSUP;
+ }
if (!s->nb_snapshots) {
*psn_tab = NULL;
return s->nb_snapshots;