aboutsummaryrefslogtreecommitdiff
path: root/block
diff options
context:
space:
mode:
authorPeter Maydell <peter.maydell@linaro.org>2022-02-01 16:32:54 +0000
committerPeter Maydell <peter.maydell@linaro.org>2022-02-01 16:32:54 +0000
commit3bbe296c1c7a6ddce7a294e006b8c4a53b385292 (patch)
tree888fc407f48680d52f586fc9c3b72a4cd3df8674 /block
parent5cbe64110dbe27f82d30552001acdc5eeaade11c (diff)
parent751486c18555169ca4baf59440275d5831140822 (diff)
downloadqemu-3bbe296c1c7a6ddce7a294e006b8c4a53b385292.zip
qemu-3bbe296c1c7a6ddce7a294e006b8c4a53b385292.tar.gz
qemu-3bbe296c1c7a6ddce7a294e006b8c4a53b385292.tar.bz2
Merge remote-tracking branch 'remotes/hreitz-gitlab/tags/pull-block-2022-02-01' into staging
Block patches: - Add support to the iotests to test qcow2's zstd compression mode - Fix post-migration block node permissions - iotests fixes (051 and mirror-ready-cancel-error) - Remove an outdated comment # gpg: Signature made Tue 01 Feb 2022 13:34:54 GMT # gpg: using RSA key CB62D7A0EE3829E45F004D34A1FA40D098019CDF # gpg: issuer "hreitz@redhat.com" # gpg: Good signature from "Hanna Reitz <hreitz@redhat.com>" [marginal] # gpg: WARNING: This key is not certified with sufficiently trusted signatures! # gpg: It is not certain that the signature belongs to the owner. # Primary key fingerprint: CB62 D7A0 EE38 29E4 5F00 4D34 A1FA 40D0 9801 9CDF * remotes/hreitz-gitlab/tags/pull-block-2022-02-01: (24 commits) block.h: remove outdated comment iotests/migration-permissions: New test block-backend: Retain permissions after migration iotests: declare lack of support for compresion_type in IMGOPTS iotest 214: explicit compression type iotests 60: more accurate set dirty bit in qcow2 header iotests: bash tests: filter compression type iotest 39: use _qcow2_dump_header iotests: massive use _qcow2_dump_header iotests/common.rc: introduce _qcow2_dump_header helper qcow2: simple case support for downgrading of qcow2 images with zstd iotest 302: use img_info_log() helper iotests.py: filter compression type out iotests.py: filter out successful output of qemu-img create iotest 065: explicit compression type iotest 303: explicit compression type iotests.py: rewrite default luks support in qemu_img iotests: drop qemu_img_verbose() helper iotests.py: qemu_img*("create"): support IMGOPTS='compression_type=zstd' iotests: specify some unsupported_imgopts for python iotests ... Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'block')
-rw-r--r--block/block-backend.c11
-rw-r--r--block/qcow2.c58
2 files changed, 67 insertions, 2 deletions
diff --git a/block/block-backend.c b/block/block-backend.c
index 23e7271..4ff6b4d 100644
--- a/block/block-backend.c
+++ b/block/block-backend.c
@@ -190,6 +190,7 @@ static void blk_root_activate(BdrvChild *child, Error **errp)
{
BlockBackend *blk = child->opaque;
Error *local_err = NULL;
+ uint64_t saved_shared_perm;
if (!blk->disable_perm) {
return;
@@ -197,12 +198,22 @@ static void blk_root_activate(BdrvChild *child, Error **errp)
blk->disable_perm = false;
+ /*
+ * blk->shared_perm contains the permissions we want to share once
+ * migration is really completely done. For now, we need to share
+ * all; but we also need to retain blk->shared_perm, which is
+ * overwritten by a successful blk_set_perm() call. Save it and
+ * restore it below.
+ */
+ saved_shared_perm = blk->shared_perm;
+
blk_set_perm(blk, blk->perm, BLK_PERM_ALL, &local_err);
if (local_err) {
error_propagate(errp, local_err);
blk->disable_perm = true;
return;
}
+ blk->shared_perm = saved_shared_perm;
if (runstate_check(RUN_STATE_INMIGRATE)) {
/* Activation can happen when migration process is still active, for
diff --git a/block/qcow2.c b/block/qcow2.c
index d509016..c8115e1 100644
--- a/block/qcow2.c
+++ b/block/qcow2.c
@@ -5279,6 +5279,38 @@ static int qcow2_load_vmstate(BlockDriverState *bs, QEMUIOVector *qiov,
return bs->drv->bdrv_co_preadv_part(bs, offset, qiov->size, qiov, 0, 0);
}
+static int qcow2_has_compressed_clusters(BlockDriverState *bs)
+{
+ int64_t offset = 0;
+ int64_t bytes = bdrv_getlength(bs);
+
+ if (bytes < 0) {
+ return bytes;
+ }
+
+ while (bytes != 0) {
+ int ret;
+ QCow2SubclusterType type;
+ unsigned int cur_bytes = MIN(INT_MAX, bytes);
+ uint64_t host_offset;
+
+ ret = qcow2_get_host_offset(bs, offset, &cur_bytes, &host_offset,
+ &type);
+ if (ret < 0) {
+ return ret;
+ }
+
+ if (type == QCOW2_SUBCLUSTER_COMPRESSED) {
+ return 1;
+ }
+
+ offset += cur_bytes;
+ bytes -= cur_bytes;
+ }
+
+ return 0;
+}
+
/*
* Downgrades an image's version. To achieve this, any incompatible features
* have to be removed.
@@ -5336,9 +5368,10 @@ static int qcow2_downgrade(BlockDriverState *bs, int target_version,
* the first place; if that happens nonetheless, returning -ENOTSUP is the
* best thing to do anyway */
- if (s->incompatible_features) {
+ if (s->incompatible_features & ~QCOW2_INCOMPAT_COMPRESSION) {
error_setg(errp, "Cannot downgrade an image with incompatible features "
- "%#" PRIx64 " set", s->incompatible_features);
+ "0x%" PRIx64 " set",
+ s->incompatible_features & ~QCOW2_INCOMPAT_COMPRESSION);
return -ENOTSUP;
}
@@ -5356,6 +5389,27 @@ static int qcow2_downgrade(BlockDriverState *bs, int target_version,
return ret;
}
+ if (s->incompatible_features & QCOW2_INCOMPAT_COMPRESSION) {
+ ret = qcow2_has_compressed_clusters(bs);
+ if (ret < 0) {
+ error_setg(errp, "Failed to check block status");
+ return -EINVAL;
+ }
+ if (ret) {
+ error_setg(errp, "Cannot downgrade an image with zstd compression "
+ "type and existing compressed clusters");
+ return -ENOTSUP;
+ }
+ /*
+ * No compressed clusters for now, so just chose default zlib
+ * compression.
+ */
+ s->incompatible_features &= ~QCOW2_INCOMPAT_COMPRESSION;
+ s->compression_type = QCOW2_COMPRESSION_TYPE_ZLIB;
+ }
+
+ assert(s->incompatible_features == 0);
+
s->qcow_version = target_version;
ret = qcow2_update_header(bs);
if (ret < 0) {