[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 10/18] block/qed: Keep auto_backing_file if possible
From: |
Kevin Wolf |
Subject: |
[PULL 10/18] block/qed: Keep auto_backing_file if possible |
Date: |
Fri, 30 Sep 2022 18:52:14 +0200 |
From: Hanna Reitz <hreitz@redhat.com>
Just like qcow2, qed invokes its open function in its
.bdrv_co_invalidate_cache() implementation. Therefore, just like done
for qcow2 in HEAD^, update auto_backing_file only if the backing file
string in the image header differs from the one we have read before.
Signed-off-by: Hanna Reitz <hreitz@redhat.com>
Message-Id: <20220803144446.20723-3-hreitz@redhat.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
block/qed.c | 15 +++++++++++----
1 file changed, 11 insertions(+), 4 deletions(-)
diff --git a/block/qed.c b/block/qed.c
index 40943e679b..324ca0e95a 100644
--- a/block/qed.c
+++ b/block/qed.c
@@ -445,6 +445,8 @@ static int coroutine_fn bdrv_qed_do_open(BlockDriverState
*bs, QDict *options,
}
if ((s->header.features & QED_F_BACKING_FILE)) {
+ g_autofree char *backing_file_str = NULL;
+
if ((uint64_t)s->header.backing_filename_offset +
s->header.backing_filename_size >
s->header.cluster_size * s->header.header_size) {
@@ -452,16 +454,21 @@ static int coroutine_fn bdrv_qed_do_open(BlockDriverState
*bs, QDict *options,
return -EINVAL;
}
+ backing_file_str = g_malloc(sizeof(bs->backing_file));
ret = qed_read_string(bs->file, s->header.backing_filename_offset,
s->header.backing_filename_size,
- bs->auto_backing_file,
- sizeof(bs->auto_backing_file));
+ backing_file_str, sizeof(bs->backing_file));
if (ret < 0) {
error_setg(errp, "Failed to read backing filename");
return ret;
}
- pstrcpy(bs->backing_file, sizeof(bs->backing_file),
- bs->auto_backing_file);
+
+ if (!g_str_equal(backing_file_str, bs->backing_file)) {
+ pstrcpy(bs->backing_file, sizeof(bs->backing_file),
+ backing_file_str);
+ pstrcpy(bs->auto_backing_file, sizeof(bs->auto_backing_file),
+ backing_file_str);
+ }
if (s->header.features & QED_F_BACKING_FORMAT_NO_PROBE) {
pstrcpy(bs->backing_format, sizeof(bs->backing_format), "raw");
--
2.37.3
- [PULL 01/18] qcow2: fix memory leak in qcow2_read_extensions, (continued)
- [PULL 01/18] qcow2: fix memory leak in qcow2_read_extensions, Kevin Wolf, 2022/09/30
- [PULL 04/18] block: pass OnOffAuto instead of bool to block_acct_setup(), Kevin Wolf, 2022/09/30
- [PULL 05/18] block: add missed block_acct_setup with new block device init procedure, Kevin Wolf, 2022/09/30
- [PULL 06/18] block: use bdrv_is_sg() helper instead of raw bs->sg reading, Kevin Wolf, 2022/09/30
- [PULL 08/18] gluster: stop using .bdrv_needs_filename, Kevin Wolf, 2022/09/30
- [PULL 07/18] block: make serializing requests functions 'void', Kevin Wolf, 2022/09/30
- [PULL 09/18] block/qcow2: Keep auto_backing_file if possible, Kevin Wolf, 2022/09/30
- [PULL 11/18] iotests/backing-file-invalidation: Add new test, Kevin Wolf, 2022/09/30
- [PULL 13/18] block: use the request length for iov alignment, Kevin Wolf, 2022/09/30
- [PULL 12/18] block: move bdrv_qiov_is_aligned to file-posix, Kevin Wolf, 2022/09/30
- [PULL 10/18] block/qed: Keep auto_backing_file if possible,
Kevin Wolf <=
- [PULL 14/18] piix_ide_reset: Use pci_set_* functions instead of direct access, Kevin Wolf, 2022/09/30
- [PULL 17/18] tests/qtest/ide-test: Verify that DIAGNOSTIC clears DEV to zero, Kevin Wolf, 2022/09/30
- [PULL 16/18] hw/ide/core: Clear LBA and drive bits for EXECUTE DEVICE DIAGNOSTIC, Kevin Wolf, 2022/09/30
- [PULL 15/18] tests/qtest/ide-test.c: Create disk image for use as a secondary, Kevin Wolf, 2022/09/30
- [PULL 18/18] hw/ide/core.c: Implement ATA INITIALIZE_DEVICE_PARAMETERS command, Kevin Wolf, 2022/09/30