[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 06/11] blockdev: Fix block_resize error reporting for op blockers
From: |
Michael Tokarev |
Subject: |
[PULL 06/11] blockdev: Fix block_resize error reporting for op blockers |
Date: |
Sat, 9 Mar 2024 18:57:24 +0300 |
From: Markus Armbruster <armbru@redhat.com>
When block_resize() runs into an op blocker, it creates an error like
this:
error_setg(errp, "Device '%s' is in use", device);
Trouble is @device can be null. My system formats null as "(null)",
but other systems might crash. Reproducer:
1. Create two block devices
-> {"execute": "blockdev-add", "arguments": {"driver": "file", "node-name":
"blk0", "filename": "64k.img"}}
<- {"return": {}}
-> {"execute": "blockdev-add", "arguments": {"driver": "file", "node-name":
"blk1", "filename": "m.img"}}
<- {"return": {}}
2. Put a blocker on one them
-> {"execute": "blockdev-mirror", "arguments": {"job-id": "job0", "device":
"blk0", "target": "blk1", "sync": "full"}}
{"return": {}}
-> {"execute": "job-pause", "arguments": {"id": "job0"}}
{"return": {}}
-> {"execute": "job-complete", "arguments": {"id": "job0"}}
{"return": {}}
Note: job events elided for brevity.
3. Attempt to resize
-> {"execute": "block_resize", "arguments": {"node-name": "blk1",
"size":32768}}
<- {"error": {"class": "GenericError", "desc": "Device '(null)' is in use"}}
Broken when commit 3b1dbd11a60 made @device optional. Fixed in commit
ed3d2ec98a3 (block: Add errp to b{lk,drv}_truncate()), except for this
one instance.
Fix it by using the error message provided by the op blocker instead,
so it fails like this:
<- {"error": {"class": "GenericError", "desc": "Node 'blk1' is busy: block
device is in use by block job: mirror"}}
Fixes: 3b1dbd11a60d (qmp: Allow block_resize to manipulate bs graph nodes.)
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Michael Tokarev <mjt@tls.msk.ru>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
---
blockdev.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/blockdev.c b/blockdev.c
index f8bb0932f8..d8fb3399f5 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -2252,8 +2252,7 @@ void coroutine_fn qmp_block_resize(const char *device,
const char *node_name,
}
bdrv_graph_co_rdlock();
- if (bdrv_op_is_blocked(bs, BLOCK_OP_TYPE_RESIZE, NULL)) {
- error_setg(errp, QERR_DEVICE_IN_USE, device);
+ if (bdrv_op_is_blocked(bs, BLOCK_OP_TYPE_RESIZE, errp)) {
bdrv_graph_co_rdunlock();
return;
}
--
2.39.2
- [PULL 00/11] Trivial patches for 2024-03-09, Michael Tokarev, 2024/03/09
- [PULL 01/11] replay: Improve error messages about configuration conflicts, Michael Tokarev, 2024/03/09
- [PULL 02/11] hw/vfio/pci.c: Make some structure static, Michael Tokarev, 2024/03/09
- [PULL 03/11] hw/scsi/lsi53c895a: Fix typo in comment, Michael Tokarev, 2024/03/09
- [PULL 04/11] make-release: switch to .xz format by default, Michael Tokarev, 2024/03/09
- [PULL 05/11] char: Slightly better error reporting when chardev is in use, Michael Tokarev, 2024/03/09
- [PULL 06/11] blockdev: Fix block_resize error reporting for op blockers,
Michael Tokarev <=
- [PULL 07/11] qerror: QERR_DEVICE_IN_USE is no longer used, drop, Michael Tokarev, 2024/03/09
- [PULL 08/11] hw/cxl/cxl-cdat: Fix type of buf in ct3_load_cdat(), Michael Tokarev, 2024/03/09
- [PULL 09/11] hw/pci-bridge/cxl_upstream: Fix problem with g_steal_pointer(), Michael Tokarev, 2024/03/09
- [PULL 10/11] hw/mem/cxl_type3: Fix problem with g_steal_pointer(), Michael Tokarev, 2024/03/09
- [PULL 11/11] docs/acpi/bits: add some clarity and details while also improving formating, Michael Tokarev, 2024/03/09
- Re: [PULL 00/11] Trivial patches for 2024-03-09, Peter Maydell, 2024/03/10