[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 18/97] mirror: Fail gracefully for source == target
From: |
Michael Roth |
Subject: |
[Qemu-devel] [PATCH 18/97] mirror: Fail gracefully for source == target |
Date: |
Mon, 1 Apr 2019 15:58:52 -0500 |
From: Kevin Wolf <address@hidden>
blockdev-mirror with the same node for source and target segfaults
today: A node is in its own backing chain, so mirror_start_job() decides
that this is an active commit. When adding the intermediate nodes with
block_job_add_bdrv(), it starts the iteration through the subchain with
the backing file of source, though, so it never reaches target and
instead runs into NULL at the base.
While we could fix that by starting with source itself, there is no
point in allowing mirroring a node into itself and I wouldn't be
surprised if this caused more problems later.
So just check for this scenario and error out.
Cc: address@hidden
Signed-off-by: Kevin Wolf <address@hidden>
Reviewed-by: Eric Blake <address@hidden>
(cherry picked from commit 86fae10c64d642256cf019e6829929fa0d259c7a)
Signed-off-by: Michael Roth <address@hidden>
---
block/mirror.c | 5 +++++
tests/qemu-iotests/041 | 6 ++++++
tests/qemu-iotests/041.out | 4 ++--
3 files changed, 13 insertions(+), 2 deletions(-)
diff --git a/block/mirror.c b/block/mirror.c
index b48c3f8cf5..dd5ca02b09 100644
--- a/block/mirror.c
+++ b/block/mirror.c
@@ -1499,6 +1499,11 @@ static void mirror_start_job(const char *job_id,
BlockDriverState *bs,
buf_size = DEFAULT_MIRROR_BUF_SIZE;
}
+ if (bs == target) {
+ error_setg(errp, "Can't mirror node into itself");
+ return;
+ }
+
/* In the case of active commit, add dummy driver to provide consistent
* reads on the top, while disabling it in the intermediate nodes, and make
* the backing chain writable. */
diff --git a/tests/qemu-iotests/041 b/tests/qemu-iotests/041
index c20ac7da87..9336ab6ff5 100755
--- a/tests/qemu-iotests/041
+++ b/tests/qemu-iotests/041
@@ -234,6 +234,12 @@ class TestSingleBlockdev(TestSingleDrive):
result = self.vm.qmp("blockdev-add", **args)
self.assert_qmp(result, 'return', {})
+ def test_mirror_to_self(self):
+ result = self.vm.qmp(self.qmp_cmd, job_id='job0',
+ device=self.qmp_target, sync='full',
+ target=self.qmp_target)
+ self.assert_qmp(result, 'error/class', 'GenericError')
+
test_large_cluster = None
test_image_not_found = None
test_small_buffer2 = None
diff --git a/tests/qemu-iotests/041.out b/tests/qemu-iotests/041.out
index c28b392b87..e071d0b261 100644
--- a/tests/qemu-iotests/041.out
+++ b/tests/qemu-iotests/041.out
@@ -1,5 +1,5 @@
-.....................................................................................
+........................................................................................
----------------------------------------------------------------------
-Ran 85 tests
+Ran 88 tests
OK
--
2.17.1
- [Qemu-devel] [PATCH 16/97] target/arm: Use FZ not FZ16 for SVE FCVT single-half and double-half, (continued)
- [Qemu-devel] [PATCH 16/97] target/arm: Use FZ not FZ16 for SVE FCVT single-half and double-half, Michael Roth, 2019/04/01
- [Qemu-devel] [PATCH 19/97] qemu-img: fix regression copying secrets during convert, Michael Roth, 2019/04/01
- [Qemu-devel] [PATCH 20/97] nvme: Fix nvme_init error handling, Michael Roth, 2019/04/01
- [Qemu-devel] [PATCH 27/97] block: iotest to catch abort on forced blockjob cancel, Michael Roth, 2019/04/01
- [Qemu-devel] [PATCH 24/97] vnc: fix memleak of the "vnc-worker-output" name, Michael Roth, 2019/04/01
- [Qemu-devel] [PATCH 26/97] block: for jobs, do not clear user_paused until after the resume, Michael Roth, 2019/04/01
- [Qemu-devel] [PATCH 28/97] virtio: update MemoryRegionCaches when guest negotiates features, Michael Roth, 2019/04/01
- [Qemu-devel] [PATCH 31/97] slirp: Add sanity check for str option length, Michael Roth, 2019/04/01
- [Qemu-devel] [PATCH 25/97] i386: Disable TOPOEXT by default on "-cpu host", Michael Roth, 2019/04/01
- [Qemu-devel] [PATCH 36/97] job: Fix nested aio_poll() hanging in job_txn_apply, Michael Roth, 2019/04/01
- [Qemu-devel] [PATCH 18/97] mirror: Fail gracefully for source == target,
Michael Roth <=
- [Qemu-devel] [PATCH 37/97] target/xtensa: fix s32c1i TCGMemOp flags, Michael Roth, 2019/04/01
- [Qemu-devel] [PATCH 38/97] nbd/server: fix bitmap export, Michael Roth, 2019/04/01
- [Qemu-devel] [PATCH 39/97] clean up callback when del virtqueue, Michael Roth, 2019/04/01
- [Qemu-devel] [PATCH 43/97] block/rbd: add deprecation documentation for filename keyvalue pairs, Michael Roth, 2019/04/01
- [Qemu-devel] [PATCH 42/97] block/rbd: add iotest for rbd legacy keyvalue filename parsing, Michael Roth, 2019/04/01
- [Qemu-devel] [PATCH 45/97] ne2000: fix possible out of bound access in ne2000_receive, Michael Roth, 2019/04/01
- [Qemu-devel] [PATCH 47/97] pcnet: fix possible buffer overflow, Michael Roth, 2019/04/01
- [Qemu-devel] [PATCH 52/97] target/arm: Correct condition for v8M callee stack push, Michael Roth, 2019/04/01
- [Qemu-devel] [PATCH 46/97] rtl8139: fix possible out of bound access, Michael Roth, 2019/04/01
- [Qemu-devel] [PATCH 53/97] nbd/server: fix NBD_CMD_CACHE, Michael Roth, 2019/04/01