提交 aa8b34c1 编写于 作者: K Kevin Wolf

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: NKevin Wolf <kwolf@redhat.com>
上级 966b000f
...@@ -353,6 +353,10 @@ int qcow2_snapshot_create(BlockDriverState *bs, QEMUSnapshotInfo *sn_info) ...@@ -353,6 +353,10 @@ int qcow2_snapshot_create(BlockDriverState *bs, QEMUSnapshotInfo *sn_info)
return -EFBIG; return -EFBIG;
} }
if (has_data_file(bs)) {
return -ENOTSUP;
}
memset(sn, 0, sizeof(*sn)); memset(sn, 0, sizeof(*sn));
/* Generate an ID */ /* Generate an ID */
...@@ -466,6 +470,10 @@ int qcow2_snapshot_goto(BlockDriverState *bs, const char *snapshot_id) ...@@ -466,6 +470,10 @@ int qcow2_snapshot_goto(BlockDriverState *bs, const char *snapshot_id)
int ret; int ret;
uint64_t *sn_l1_table = NULL; uint64_t *sn_l1_table = NULL;
if (has_data_file(bs)) {
return -ENOTSUP;
}
/* Search the snapshot */ /* Search the snapshot */
snapshot_index = find_snapshot_by_id_or_name(bs, snapshot_id); snapshot_index = find_snapshot_by_id_or_name(bs, snapshot_id);
if (snapshot_index < 0) { if (snapshot_index < 0) {
...@@ -599,6 +607,10 @@ int qcow2_snapshot_delete(BlockDriverState *bs, ...@@ -599,6 +607,10 @@ int qcow2_snapshot_delete(BlockDriverState *bs,
QCowSnapshot sn; QCowSnapshot sn;
int snapshot_index, ret; int snapshot_index, ret;
if (has_data_file(bs)) {
return -ENOTSUP;
}
/* Search the snapshot */ /* Search the snapshot */
snapshot_index = find_snapshot_by_id_and_name(bs, snapshot_id, name); snapshot_index = find_snapshot_by_id_and_name(bs, snapshot_id, name);
if (snapshot_index < 0) { if (snapshot_index < 0) {
...@@ -670,6 +682,9 @@ int qcow2_snapshot_list(BlockDriverState *bs, QEMUSnapshotInfo **psn_tab) ...@@ -670,6 +682,9 @@ int qcow2_snapshot_list(BlockDriverState *bs, QEMUSnapshotInfo **psn_tab)
QCowSnapshot *sn; QCowSnapshot *sn;
int i; int i;
if (has_data_file(bs)) {
return -ENOTSUP;
}
if (!s->nb_snapshots) { if (!s->nb_snapshots) {
*psn_tab = NULL; *psn_tab = NULL;
return s->nb_snapshots; return s->nb_snapshots;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册