* [PULL 0/8] Block layer patches
@ 2026-11-17 17:17 Kevin Wolf
2026-11-17 17:17 ` [PULL 1/8] block/bochs: validate bitmap size and compute extent_blocks after validation Kevin Wolf
` (7 more replies)
0 siblings, 8 replies; 11+ messages in thread
From: Kevin Wolf @ 2026-11-17 17:17 UTC (permalink / raw)
To: qemu-block; +Cc: kwolf, richard.henderson, qemu-devel
The following changes since commit 97c88c61d45dee6e1f9bc160a338048189846d28:
Merge tag 'docs-security-devices-pull-request' of https://gitlab.com/berrange/qemu into staging (2026-11-16 15:48:48 -0800)
are available in the Git repository at:
https://repo.or.cz/qemu/kevin.git tags/for-upstream
for you to fetch changes up to 4f5c09c6228f317eab3144ecc27e8b13b3526128:
block: notify only the replaced child in bdrv_replace_child_bs() (2026-11-17 11:46:13 +0100)
----------------------------------------------------------------
Block layer patches
- vhdx, bochs: Image validation fixes
- Fix the size change notification in bdrv_replace_child_bs()
- iotests: Minor fixes to deal more correctly with exotic environments
----------------------------------------------------------------
Daniel P. Berrangé (1):
iotests: better heuristics to find I/O tests build/source dirs
Denis V. Lunev (3):
block: read the old child length after draining in bdrv_replace_child_bs()
block: add bdrv_child_notify_resize() to notify a single parent
block: notify only the replaced child in bdrv_replace_child_bs()
John Snow (1):
iotests: fix false positive on running-outside-venv warning
Thomas Huth (2):
block/vhdx-log: Improve sanity checks to avoid OOB accesses with bad images
block/vhdx: Add alignment checks for region tables
malike (1):
block/bochs: validate bitmap size and compute extent_blocks after validation
include/block/block_int-io.h | 8 ++++++-
block.c | 7 +++---
block/bochs.c | 9 +++++++-
block/io.c | 14 +++++++++---
block/vhdx-log.c | 6 ++++-
block/vhdx.c | 10 +++++++++
tests/qemu-iotests/testenv.py | 8 +++----
meson.build | 1 +
tests/qemu-iotests/check | 52 +++++++++++++++++++++++++++++++------------
9 files changed, 88 insertions(+), 27 deletions(-)
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PULL 1/8] block/bochs: validate bitmap size and compute extent_blocks after validation
2026-11-17 17:17 [PULL 0/8] Block layer patches Kevin Wolf
@ 2026-11-17 17:17 ` Kevin Wolf
2026-11-17 17:17 ` [PULL 2/8] iotests: better heuristics to find I/O tests build/source dirs Kevin Wolf
` (6 subsequent siblings)
7 siblings, 0 replies; 11+ messages in thread
From: Kevin Wolf @ 2026-11-17 17:17 UTC (permalink / raw)
To: qemu-block; +Cc: kwolf, richard.henderson, qemu-devel
From: malike <malike@kylinos.cn>
bochs_open() computes bitmap_blocks using the formula
"1 + (le32_to_cpu(bochs.bitmap) - 1) / 512". le32_to_cpu() returns
uint32_t, so when bochs.bitmap is zero the subtraction wraps to
UINT32_MAX (0xFFFFFFFF) in unsigned arithmetic, yielding
bitmap_blocks = 8388608 instead of 1.
The bitmap field is read directly from the on-disk image header and was
never validated. The overflowed bitmap_blocks propagates into
seek_to_sector()'s bitmap_offset calculation, causing reads to target
wrong offsets and return I/O errors or incorrect data.
Add an explicit zero check for bochs.bitmap before the formula.
Also move the extent_blocks calculation to after the existing
extent_size validation. The same "1 + (x - 1) / 512" pattern applies
to extent, but extent==0 is already caught by the "extent_size <
BDRV_SECTOR_SIZE" check; the calculation is moved after that check for
clarity and robustness, and uses the already-validated s->extent_size
instead of re-reading the header field.
Cc: qemu-stable@nongnu.org
Fixes: a8753c3466dc ("Bochs disk image support")
Signed-off-by: malike <malike@kylinos.cn>
Message-ID: <20261014033419.236057-1-malike@kylinos.cn>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
block/bochs.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/block/bochs.c b/block/bochs.c
index bfda88017d9..7a8091d47d9 100644
--- a/block/bochs.c
+++ b/block/bochs.c
@@ -167,8 +167,13 @@ static int bochs_open(BlockDriverState *bs, QDict *options, int flags,
s->data_offset = le32_to_cpu(bochs.header) + (s->catalog_size * 4);
+ if (le32_to_cpu(bochs.bitmap) == 0) {
+ error_setg(errp, "Bitmap size must not be zero");
+ ret = -EINVAL;
+ goto fail;
+ }
+
s->bitmap_blocks = 1 + (le32_to_cpu(bochs.bitmap) - 1) / 512;
- s->extent_blocks = 1 + (le32_to_cpu(bochs.extent) - 1) / 512;
s->extent_size = le32_to_cpu(bochs.extent);
if (s->extent_size < BDRV_SECTOR_SIZE) {
@@ -188,6 +193,8 @@ static int bochs_open(BlockDriverState *bs, QDict *options, int flags,
goto fail;
}
+ s->extent_blocks = 1 + (s->extent_size - 1) / 512;
+
if (s->catalog_size < DIV_ROUND_UP(bs->total_sectors,
s->extent_size / BDRV_SECTOR_SIZE))
{
--
2.56.1
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PULL 2/8] iotests: better heuristics to find I/O tests build/source dirs
2026-11-17 17:17 [PULL 0/8] Block layer patches Kevin Wolf
2026-11-17 17:17 ` [PULL 1/8] block/bochs: validate bitmap size and compute extent_blocks after validation Kevin Wolf
@ 2026-11-17 17:17 ` Kevin Wolf
2026-11-17 20:06 ` Richard Henderson
2026-11-17 17:17 ` [PULL 3/8] block/vhdx-log: Improve sanity checks to avoid OOB accesses with bad images Kevin Wolf
` (5 subsequent siblings)
7 siblings, 1 reply; 11+ messages in thread
From: Kevin Wolf @ 2026-11-17 17:17 UTC (permalink / raw)
To: qemu-block; +Cc: kwolf, richard.henderson, qemu-devel
From: Daniel P. Berrangé <berrange@redhat.com>
Currently the I/O tests cannot be run if executing directly
from the source directory, even when wrapped by the 'run'
script, due to inadequate heuristics to guess the directories.
If using the 'run' script, meson can tell us exactly where the
top level build and source directories are, so we don't need
to guess. Just read MESON_BUILD_ROOT and MESON_SOURCE_ROOT
env variables if present.
If not using the 'run' script, we can do a bit better at
guessing the path from the 'check' filename. Always resolve
from sys.argv[0], even when it is not a symlink, instead of
falling back to 'cwd()' which doesn't work since we stopped
having in-tree builds. If invoked directly from the source
tree, guess that the build root is the default 'build' name
which often works.
With this change the following all work:
1. From root of build dir, with run script
cd build
./run tests/qemu-iotests/check 5
2. From root of build dir, without run script
cd build
tests/qemu-iotests/check 5
3. From I/O tests subdir of build dir, with run script
cd build/tests/qemu-iotests
../../run ./check 5
4. From I/O tests subdir of build dir, without run script
cd build/tests/qemu-iotests
./check 5
5. From root of source dir, with run script
./build/run tests/qemu-iotests/check 5
6. From root of source dir, without run script
tests/qemu-iotests/check 5
7. From I/O tests subdir of source dir, with run script
cd tests/qemu-iotests
../../build/run ./check 5
8. From I/O tests subdir of source dir, without run script
cd tests/qemu-iotests
./check 5
Before this commit, items 5-8 would always fail. Items 6 and
8 will not work if using a build directory with a name other
than the default 'build'. For those scenarios use one of the
other 6 possible variants.
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
Message-ID: <20261111091133.3527549-1-berrange@redhat.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
meson.build | 1 +
tests/qemu-iotests/check | 52 +++++++++++++++++++++++++++++-----------
2 files changed, 39 insertions(+), 14 deletions(-)
diff --git a/meson.build b/meson.build
index d7bcb581c18..9d15f2e9551 100644
--- a/meson.build
+++ b/meson.build
@@ -3502,6 +3502,7 @@ genh += config_host_h
devenv = environment()
devenv.set('MESON_BUILD_ROOT', meson.project_build_root())
+devenv.set('MESON_SOURCE_ROOT', meson.project_source_root())
devenv.set('VIRTUAL_ENV', meson.project_build_root() / 'pyvenv')
devenv.prepend('PATH', meson.project_build_root() / 'pyvenv'/ 'bin')
devenv.prepend('PYTHONPATH', meson.current_source_dir() / 'tests' / 'functional')
diff --git a/tests/qemu-iotests/check b/tests/qemu-iotests/check
index c8ba536970c..40baa2b4107 100755
--- a/tests/qemu-iotests/check
+++ b/tests/qemu-iotests/check
@@ -28,18 +28,42 @@ from findtests import TestFinder
from testenv import TestEnv
from testrunner import TestRunner
-def get_default_path(follow_link=False):
- """
- Try to automagically figure out the path we are running from.
- """
- # called from the build tree?
- if os.path.islink(sys.argv[0]):
- if follow_link:
- return os.path.dirname(os.readlink(sys.argv[0]))
+
+def get_build_dir():
+ if "MESON_BUILD_ROOT" in os.environ:
+ br = os.environ["MESON_BUILD_ROOT"]
+ return os.path.join(br, "tests", "qemu-iotests")
+ else:
+ if os.path.islink(sys.argv[0]):
+ iobr = os.path.dirname(sys.argv[0])
+ else:
+ iobr = os.path.join(os.path.dirname(sys.argv[0]),
+ "..", "..", "build", "tests", "qemu-iotests")
+ if (not os.path.exists(os.path.join(iobr, "check")) or
+ os.path.exists(os.path.join(iobr, "testenv.py"))):
+ raise Exception(f"MESON_BUILD_ROOT is not set, and guessed "
+ "I/O tests build root {iobr} does not look "
+ "valid. Please use the 'run' script to invoke "
+ "the I/O tests")
+ return os.path.abspath(iobr)
+
+
+def get_source_dir():
+ if "MESON_SOURCE_ROOT" in os.environ:
+ sr = os.environ["MESON_SOURCE_ROOT"]
+ return os.path.join(sr, "tests", "qemu-iotests")
+ else:
+ if os.path.islink(sys.argv[0]):
+ iosr = os.path.dirname(os.readlink(sys.argv[0]))
else:
- return os.path.dirname(os.path.abspath(sys.argv[0]))
- else: # or source tree?
- return os.getcwd()
+ iosr = os.path.dirname(sys.argv[0])
+ if not os.path.exists(os.path.join(iosr, "testenv.py")):
+ raise Exception(f"MESON_SOURCE_ROOT is not set, and guessed "
+ "I/O tests source root {iosr} does not look "
+ "valid. Please use the 'run' script to invoke "
+ "the I/O tests")
+ return os.path.abspath(iosr)
+
def make_argparser() -> argparse.ArgumentParser:
p = argparse.ArgumentParser(
@@ -131,11 +155,11 @@ def make_argparser() -> argparse.ArgumentParser:
'middle of the process.')
g_sel.add_argument('tests', metavar='TEST_FILES', nargs='*',
help='tests to run, or "--" followed by a command')
- g_sel.add_argument('--build-dir', default=get_default_path(),
+ g_sel.add_argument('--build-dir', default=get_build_dir(),
help='Path to iotests build directory')
g_sel.add_argument('--source-dir',
- default=get_default_path(follow_link=True),
- help='Path to iotests build directory')
+ default=get_source_dir(),
+ help='Path to iotests source directory')
return p
--
2.56.1
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PULL 3/8] block/vhdx-log: Improve sanity checks to avoid OOB accesses with bad images
2026-11-17 17:17 [PULL 0/8] Block layer patches Kevin Wolf
2026-11-17 17:17 ` [PULL 1/8] block/bochs: validate bitmap size and compute extent_blocks after validation Kevin Wolf
2026-11-17 17:17 ` [PULL 2/8] iotests: better heuristics to find I/O tests build/source dirs Kevin Wolf
@ 2026-11-17 17:17 ` Kevin Wolf
2026-11-17 17:17 ` [PULL 4/8] iotests: fix false positive on running-outside-venv warning Kevin Wolf
` (4 subsequent siblings)
7 siblings, 0 replies; 11+ messages in thread
From: Kevin Wolf @ 2026-11-17 17:17 UTC (permalink / raw)
To: qemu-block; +Cc: kwolf, richard.henderson, qemu-devel
From: Thomas Huth <thuth@redhat.com>
The multiplication "hdr->descriptor_count * sizeof(VHDXLogDescriptor)" in
vhdx_log_hdr_is_valid() can overflow on 32-bit systems, so this function
could mark bad images as valid when the truncated result is smaller than
hdr->entry_length. Switch to a division on the right hand side instead to
avoid the overflow problems.
The second problem is in vhdx_log_read_desc(): desc_sectors is a 32-bit
value, thus the multiplication "desc_sectors * VHDX_LOG_SECTOR_SIZE" is
also done with 32 bit arithmetics, and the result is used as "size_t"
parameter for qemu_try_blockalign(), i.e. the parameter here is also
only 32 bits on 32-bit systems. Let's add a sanity check here to avoid
the overflow problem that could lead to trouble later.
Cc: qemu-stable@nongnu.org
Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/3860
Signed-off-by: Thomas Huth <thuth@redhat.com>
Message-ID: <20261111150659.253918-1-thuth@redhat.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
block/vhdx-log.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/block/vhdx-log.c b/block/vhdx-log.c
index 4385a2d4f62..5c20468e1e6 100644
--- a/block/vhdx-log.c
+++ b/block/vhdx-log.c
@@ -246,7 +246,7 @@ static bool vhdx_log_hdr_is_valid(VHDXLogEntries *log, VHDXLogEntryHeader *hdr,
goto exit;
}
- if (hdr->descriptor_count * sizeof(VHDXLogDescriptor) > hdr->entry_length) {
+ if (hdr->descriptor_count > hdr->entry_length / sizeof(VHDXLogDescriptor)) {
goto exit;
}
@@ -360,6 +360,10 @@ vhdx_log_read_desc(BlockDriverState *bs, BDRVVHDXState *s, VHDXLogEntries *log,
}
desc_sectors = vhdx_compute_desc_sectors(hdr.descriptor_count);
+ if (desc_sectors > UINT32_MAX / VHDX_LOG_SECTOR_SIZE) {
+ ret = -EINVAL;
+ goto exit;
+ }
desc_entries = qemu_try_blockalign(bs->file->bs,
desc_sectors * VHDX_LOG_SECTOR_SIZE);
if (desc_entries == NULL) {
--
2.56.1
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PULL 4/8] iotests: fix false positive on running-outside-venv warning
2026-11-17 17:17 [PULL 0/8] Block layer patches Kevin Wolf
` (2 preceding siblings ...)
2026-11-17 17:17 ` [PULL 3/8] block/vhdx-log: Improve sanity checks to avoid OOB accesses with bad images Kevin Wolf
@ 2026-11-17 17:17 ` Kevin Wolf
2026-11-17 17:17 ` [PULL 5/8] block/vhdx: Add alignment checks for region tables Kevin Wolf
` (3 subsequent siblings)
7 siblings, 0 replies; 11+ messages in thread
From: Kevin Wolf @ 2026-11-17 17:17 UTC (permalink / raw)
To: qemu-block; +Cc: kwolf, richard.henderson, qemu-devel
From: John Snow <jsnow@redhat.com>
Currently, iotests checks to see if you are running with the "correct"
python interpreter by checking string equivalence between your current
python and the configure-time venv python.
Depending on exactly *how* you launch or configure your python,
however, this warning may produce false positives because it treats
"python" as different from "python3" as different from
e.g. "python3.12", even though they are all actually the same exact
interpreter.
This patch fixes this by comparing only the parent directories; we
will now be happy with any interpreter so long as it is located within
build/pyvenv/bin/.
Note that we cannot fix this by resolving symlinks, as python venv
binaries are often (but not always) just symlinks to /usr/bin/<etc>,
and full resolution would produce even more false negatives.
Reported-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: John Snow <jsnow@redhat.com>
Message-ID: <20261007183338.1899422-1-jsnow@redhat.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
tests/qemu-iotests/testenv.py | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/tests/qemu-iotests/testenv.py b/tests/qemu-iotests/testenv.py
index 86bcdf7cfad..53c9b5d1968 100644
--- a/tests/qemu-iotests/testenv.py
+++ b/tests/qemu-iotests/testenv.py
@@ -86,7 +86,7 @@ def prepare_subprocess(self, args: List[str]) -> Dict[str, str]:
with open(args[0], encoding="utf-8") as f:
try:
if f.readline().rstrip() == '#!/usr/bin/env python3':
- args.insert(0, self.python)
+ args.insert(0, str(self.python))
except UnicodeDecodeError: # binary test? for future.
pass
@@ -141,14 +141,14 @@ def init_binaries(self) -> None:
PYTHON (for bash tests)
QEMU_PROG, QEMU_IMG_PROG, QEMU_IO_PROG, QEMU_NBD_PROG, QSD_PROG
"""
- self.python = str(Path(sys.executable).absolute())
+ self.python = Path(sys.executable).absolute()
# QEMU configure-time venv python executable
venv_python = Path(
os.path.join(self.build_root, "pyvenv", "bin", "python3")
).absolute()
- if self.python != str(venv_python):
+ if str(self.python.parent) != str(venv_python.parent):
runpath = os.path.join(self.build_root, "run")
cmd = ' '.join(shlex.quote(x) for x in sys.argv)
print(
@@ -163,7 +163,7 @@ def init_binaries(self) -> None:
f"\t{runpath} {cmd}\n",
file=sys.stderr
)
- self.python = str(venv_python)
+ self.python = venv_python
def root(*names: str) -> str:
return os.path.join(self.build_root, *names)
--
2.56.1
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PULL 5/8] block/vhdx: Add alignment checks for region tables
2026-11-17 17:17 [PULL 0/8] Block layer patches Kevin Wolf
` (3 preceding siblings ...)
2026-11-17 17:17 ` [PULL 4/8] iotests: fix false positive on running-outside-venv warning Kevin Wolf
@ 2026-11-17 17:17 ` Kevin Wolf
2026-11-17 17:17 ` [PULL 6/8] block: read the old child length after draining in bdrv_replace_child_bs() Kevin Wolf
` (2 subsequent siblings)
7 siblings, 0 replies; 11+ messages in thread
From: Kevin Wolf @ 2026-11-17 17:17 UTC (permalink / raw)
To: qemu-block; +Cc: kwolf, richard.henderson, qemu-devel
From: Thomas Huth <thuth@redhat.com>
According to the VHDX specification:
"The FileOffset and Length fields specify the 64-bit byte offset and 32-bit
byte length of the object within the file. The values must be a multiple of
1 MB, and FileOffset must be at least 1 MB."
Thus let's add a sanity check to avoid that bad things could happen later.
Cc: qemu-stable@nongnu.org
Buglink: https://gitlab.com/qemu-project/qemu/-/work_items/3762
Reported-by: Daniel Wade <danjwade95@gmail.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
Message-ID: <20261113072336.46309-1-thuth@redhat.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
block/vhdx.c | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/block/vhdx.c b/block/vhdx.c
index 8013a90a1a4..e71973cf525 100644
--- a/block/vhdx.c
+++ b/block/vhdx.c
@@ -566,6 +566,16 @@ vhdx_open_region_tables(BlockDriverState *bs, BDRVVHDXState *s)
vhdx_region_entry_le_import(&rt_entry);
+ /*
+ * According to the VHDX spec, offset and length must be multiple
+ * of 1 MiB and offset must be at least 1 MiB.
+ */
+ if (!QEMU_IS_ALIGNED(rt_entry.file_offset, MiB) ||
+ !QEMU_IS_ALIGNED(rt_entry.length, MiB) || !rt_entry.file_offset) {
+ ret = -EINVAL;
+ goto fail;
+ }
+
/* check for region overlap between these entries, and any
* other memory regions in the file */
ret = vhdx_region_check(s, rt_entry.file_offset, rt_entry.length);
--
2.56.1
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PULL 6/8] block: read the old child length after draining in bdrv_replace_child_bs()
2026-11-17 17:17 [PULL 0/8] Block layer patches Kevin Wolf
` (4 preceding siblings ...)
2026-11-17 17:17 ` [PULL 5/8] block/vhdx: Add alignment checks for region tables Kevin Wolf
@ 2026-11-17 17:17 ` Kevin Wolf
2026-11-17 17:17 ` [PULL 7/8] block: add bdrv_child_notify_resize() to notify a single parent Kevin Wolf
2026-11-17 17:17 ` [PULL 8/8] block: notify only the replaced child in bdrv_replace_child_bs() Kevin Wolf
7 siblings, 0 replies; 11+ messages in thread
From: Kevin Wolf @ 2026-11-17 17:17 UTC (permalink / raw)
To: qemu-block; +Cc: kwolf, richard.henderson, qemu-devel
From: "Denis V. Lunev" <den@openvz.org>
bdrv_drained_begin() runs nested event loops, and old_bs can be resized
from there by something other than the BlockBackend being switched: an
export truncating it, or a block job completing. old_len read before
the drain is then stale, and comparing it with new_len sends a
notification the parent does not need or skips one it does.
Read it once both nodes are drained, so that the read, the comparison
and the notification see the same sizes. A resize which completes in
the drain notifies the parents of old_bs, @child included, on its own.
Fixes: 8b267376df87 ("block: notify the parent when a replaced child has a different size")
Suggested-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Denis V. Lunev <den@openvz.org>
Cc: Kevin Wolf <kwolf@redhat.com>
Cc: Hanna Reitz <hreitz@redhat.com>
Cc: Eric Blake <eblake@redhat.com>
Cc: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
Message-ID: <20261105203752.3169635-2-den@openvz.org>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
block.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/block.c b/block.c
index 006c3413406..9df1a48c06b 100644
--- a/block.c
+++ b/block.c
@@ -5566,11 +5566,12 @@ int bdrv_replace_child_bs(BdrvChild *child, BlockDriverState *new_bs,
GLOBAL_STATE_CODE();
- old_len = bdrv_getlength(old_bs);
-
bdrv_ref(old_bs);
bdrv_drained_begin(old_bs);
bdrv_drained_begin(new_bs);
+
+ old_len = bdrv_getlength(old_bs);
+
bdrv_graph_wrlock();
bdrv_replace_child_tran(child, new_bs, tran);
--
2.56.1
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PULL 7/8] block: add bdrv_child_notify_resize() to notify a single parent
2026-11-17 17:17 [PULL 0/8] Block layer patches Kevin Wolf
` (5 preceding siblings ...)
2026-11-17 17:17 ` [PULL 6/8] block: read the old child length after draining in bdrv_replace_child_bs() Kevin Wolf
@ 2026-11-17 17:17 ` Kevin Wolf
2026-11-17 17:17 ` [PULL 8/8] block: notify only the replaced child in bdrv_replace_child_bs() Kevin Wolf
7 siblings, 0 replies; 11+ messages in thread
From: Kevin Wolf @ 2026-11-17 17:17 UTC (permalink / raw)
To: qemu-block; +Cc: kwolf, richard.henderson, qemu-devel
From: "Denis V. Lunev" <den@openvz.org>
bdrv_co_parent_cb_resize() calls the resize hook of every parent of a
node. bdrv_replace_child_bs() needs to call it for one BdrvChild, and
from outside a coroutine.
Move the call into bdrv_co_child_notify_resize(), make the loop use it,
and add a co_wrapper for callers outside a coroutine.
No functional change.
Suggested-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Denis V. Lunev <den@openvz.org>
Cc: Kevin Wolf <kwolf@redhat.com>
Cc: Hanna Reitz <hreitz@redhat.com>
Cc: Eric Blake <eblake@redhat.com>
Cc: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
Message-ID: <20261105203752.3169635-3-den@openvz.org>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
include/block/block_int-io.h | 9 +++++++++
block/io.c | 14 +++++++++++---
2 files changed, 20 insertions(+), 3 deletions(-)
diff --git a/include/block/block_int-io.h b/include/block/block_int-io.h
index 95d0dd7a05f..3cb72fecd4f 100644
--- a/include/block/block_int-io.h
+++ b/include/block/block_int-io.h
@@ -197,6 +197,15 @@ void bdrv_bsc_fill(BlockDriverState *bs, int64_t offset, int64_t bytes);
void coroutine_fn GRAPH_RDLOCK
bdrv_co_parent_cb_resize(BlockDriverState *bs);
+/*
+ * Notify the parent behind @c that the size of its child changed.
+ */
+void coroutine_fn GRAPH_RDLOCK
+bdrv_co_child_notify_resize(BdrvChild *c);
+
+void co_wrapper_bdrv_rdlock
+bdrv_child_notify_resize(BdrvChild *c);
+
void co_wrapper_bdrv_rdlock
bdrv_parent_cb_resize(BlockDriverState *bs);
diff --git a/block/io.c b/block/io.c
index 0f81b7e6bb9..e4568d4d244 100644
--- a/block/io.c
+++ b/block/io.c
@@ -3636,6 +3636,16 @@ int coroutine_fn bdrv_co_copy_range(BdrvChild *src, int64_t src_offset,
bytes, read_flags, write_flags);
}
+void coroutine_fn bdrv_co_child_notify_resize(BdrvChild *c)
+{
+ IO_CODE();
+ assert_bdrv_graph_readable();
+
+ if (c->klass->resize) {
+ c->klass->resize(c);
+ }
+}
+
void coroutine_fn bdrv_co_parent_cb_resize(BlockDriverState *bs)
{
BdrvChild *c;
@@ -3644,9 +3654,7 @@ void coroutine_fn bdrv_co_parent_cb_resize(BlockDriverState *bs)
assert_bdrv_graph_readable();
QLIST_FOREACH(c, &bs->parents, next_parent) {
- if (c->klass->resize) {
- c->klass->resize(c);
- }
+ bdrv_co_child_notify_resize(c);
}
}
--
2.56.1
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PULL 8/8] block: notify only the replaced child in bdrv_replace_child_bs()
2026-11-17 17:17 [PULL 0/8] Block layer patches Kevin Wolf
` (6 preceding siblings ...)
2026-11-17 17:17 ` [PULL 7/8] block: add bdrv_child_notify_resize() to notify a single parent Kevin Wolf
@ 2026-11-17 17:17 ` Kevin Wolf
7 siblings, 0 replies; 11+ messages in thread
From: Kevin Wolf @ 2026-11-17 17:17 UTC (permalink / raw)
To: qemu-block; +Cc: kwolf, richard.henderson, qemu-devel
From: "Denis V. Lunev" <den@openvz.org>
bdrv_replace_child_bs() compares the sizes of the old and the new node
to decide whether @child has to be told, and then notifies every parent
of new_bs. The other parents already had that node and its size, so
they get a resize event for nothing: a scsi-hd sharing the new node
reports CAPACITY DATA HAS CHANGED to its guest although the capacity is
the same.
Notify @child alone. bdrv_parent_cb_resize() has no user left, so drop
it.
Fixes: 8b267376df87 ("block: notify the parent when a replaced child has a different size")
Suggested-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Denis V. Lunev <den@openvz.org>
Cc: Kevin Wolf <kwolf@redhat.com>
Cc: Hanna Reitz <hreitz@redhat.com>
Cc: Eric Blake <eblake@redhat.com>
Cc: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
Message-ID: <20261105203752.3169635-4-den@openvz.org>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
include/block/block_int-io.h | 3 ---
block.c | 2 +-
2 files changed, 1 insertion(+), 4 deletions(-)
diff --git a/include/block/block_int-io.h b/include/block/block_int-io.h
index 3cb72fecd4f..6aa7b2184e9 100644
--- a/include/block/block_int-io.h
+++ b/include/block/block_int-io.h
@@ -206,7 +206,4 @@ bdrv_co_child_notify_resize(BdrvChild *c);
void co_wrapper_bdrv_rdlock
bdrv_child_notify_resize(BdrvChild *c);
-void co_wrapper_bdrv_rdlock
-bdrv_parent_cb_resize(BlockDriverState *bs);
-
#endif /* BLOCK_INT_IO_H */
diff --git a/block.c b/block.c
index 9df1a48c06b..c3e7059556a 100644
--- a/block.c
+++ b/block.c
@@ -5590,7 +5590,7 @@ int bdrv_replace_child_bs(BdrvChild *child, BlockDriverState *new_bs,
int64_t new_len = bdrv_getlength(new_bs);
if (new_len >= 0 && new_len != old_len) {
- bdrv_parent_cb_resize(new_bs);
+ bdrv_child_notify_resize(child);
}
}
--
2.56.1
^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [PULL 2/8] iotests: better heuristics to find I/O tests build/source dirs
2026-11-17 17:17 ` [PULL 2/8] iotests: better heuristics to find I/O tests build/source dirs Kevin Wolf
@ 2026-11-17 20:06 ` Richard Henderson
2026-11-17 20:50 ` Kevin Wolf
0 siblings, 1 reply; 11+ messages in thread
From: Richard Henderson @ 2026-11-17 20:06 UTC (permalink / raw)
To: Kevin Wolf, qemu-block; +Cc: qemu-devel
On 11/17/26 09:17, Kevin Wolf wrote:
> From: Daniel P. Berrangé<berrange@redhat.com>
>
> Currently the I/O tests cannot be run if executing directly
> from the source directory, even when wrapped by the 'run'
> script, due to inadequate heuristics to guess the directories.
>
> If using the 'run' script, meson can tell us exactly where the
> top level build and source directories are, so we don't need
> to guess. Just read MESON_BUILD_ROOT and MESON_SOURCE_ROOT
> env variables if present.
>
> If not using the 'run' script, we can do a bit better at
> guessing the path from the 'check' filename. Always resolve
> from sys.argv[0], even when it is not a symlink, instead of
> falling back to 'cwd()' which doesn't work since we stopped
> having in-tree builds. If invoked directly from the source
> tree, guess that the build root is the default 'build' name
> which often works.
>
> With this change the following all work:
>
> 1. From root of build dir, with run script
>
> cd build
> ./run tests/qemu-iotests/check 5
>
> 2. From root of build dir, without run script
>
> cd build
> tests/qemu-iotests/check 5
>
> 3. From I/O tests subdir of build dir, with run script
>
> cd build/tests/qemu-iotests
> ../../run ./check 5
>
> 4. From I/O tests subdir of build dir, without run script
>
> cd build/tests/qemu-iotests
> ./check 5
>
> 5. From root of source dir, with run script
>
> ./build/run tests/qemu-iotests/check 5
>
> 6. From root of source dir, without run script
>
> tests/qemu-iotests/check 5
>
> 7. From I/O tests subdir of source dir, with run script
>
> cd tests/qemu-iotests
> ../../build/run ./check 5
>
> 8. From I/O tests subdir of source dir, without run script
>
> cd tests/qemu-iotests
> ./check 5
>
> Before this commit, items 5-8 would always fail. Items 6 and
> 8 will not work if using a build directory with a name other
> than the default 'build'. For those scenarios use one of the
> other 6 possible variants.
>
> Signed-off-by: Daniel P. Berrangé<berrange@redhat.com>
> Message-ID:<20261111091133.3527549-1-berrange@redhat.com>
> Reviewed-by: Kevin Wolf<kwolf@redhat.com>
> Signed-off-by: Kevin Wolf<kwolf@redhat.com>
> ---
> meson.build | 1 +
> tests/qemu-iotests/check | 52 +++++++++++++++++++++++++++++-----------
> 2 files changed, 39 insertions(+), 14 deletions(-)
Fails all of the block tests. E.g.
https://gitlab.com/qemu-project/qemu/-/jobs/18118947590#L135
> === pylint ===
> +************* Module check
> +check:44:12: W0719: Raising too general exception: Exception (broad-exception-raised)
> +check:44:28: W1309: Using an f-string that does not have any interpolated variables (f-string-without-interpolation)
> +check:61:12: W0719: Raising too general exception: Exception (broad-exception-raised)
> +check:61:28: W1309: Using an f-string that does not have any interpolated variables (f-string-without-interpolation)
r~
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PULL 2/8] iotests: better heuristics to find I/O tests build/source dirs
2026-11-17 20:06 ` Richard Henderson
@ 2026-11-17 20:50 ` Kevin Wolf
0 siblings, 0 replies; 11+ messages in thread
From: Kevin Wolf @ 2026-11-17 20:50 UTC (permalink / raw)
To: Richard Henderson; +Cc: qemu-block, qemu-devel, berrange
Am 17.11.2026 um 21:06 hat Richard Henderson geschrieben:
> On 11/17/26 09:17, Kevin Wolf wrote:
> > From: Daniel P. Berrangé<berrange@redhat.com>
> >
> > Currently the I/O tests cannot be run if executing directly
> > from the source directory, even when wrapped by the 'run'
> > script, due to inadequate heuristics to guess the directories.
> >
> > If using the 'run' script, meson can tell us exactly where the
> > top level build and source directories are, so we don't need
> > to guess. Just read MESON_BUILD_ROOT and MESON_SOURCE_ROOT
> > env variables if present.
> >
> > If not using the 'run' script, we can do a bit better at
> > guessing the path from the 'check' filename. Always resolve
> > from sys.argv[0], even when it is not a symlink, instead of
> > falling back to 'cwd()' which doesn't work since we stopped
> > having in-tree builds. If invoked directly from the source
> > tree, guess that the build root is the default 'build' name
> > which often works.
> >
> > With this change the following all work:
> >
> > 1. From root of build dir, with run script
> >
> > cd build
> > ./run tests/qemu-iotests/check 5
> >
> > 2. From root of build dir, without run script
> >
> > cd build
> > tests/qemu-iotests/check 5
> >
> > 3. From I/O tests subdir of build dir, with run script
> >
> > cd build/tests/qemu-iotests
> > ../../run ./check 5
> >
> > 4. From I/O tests subdir of build dir, without run script
> >
> > cd build/tests/qemu-iotests
> > ./check 5
> >
> > 5. From root of source dir, with run script
> >
> > ./build/run tests/qemu-iotests/check 5
> >
> > 6. From root of source dir, without run script
> >
> > tests/qemu-iotests/check 5
> >
> > 7. From I/O tests subdir of source dir, with run script
> >
> > cd tests/qemu-iotests
> > ../../build/run ./check 5
> >
> > 8. From I/O tests subdir of source dir, without run script
> >
> > cd tests/qemu-iotests
> > ./check 5
> >
> > Before this commit, items 5-8 would always fail. Items 6 and
> > 8 will not work if using a build directory with a name other
> > than the default 'build'. For those scenarios use one of the
> > other 6 possible variants.
> >
> > Signed-off-by: Daniel P. Berrangé<berrange@redhat.com>
> > Message-ID:<20261111091133.3527549-1-berrange@redhat.com>
> > Reviewed-by: Kevin Wolf<kwolf@redhat.com>
> > Signed-off-by: Kevin Wolf<kwolf@redhat.com>
> > ---
> > meson.build | 1 +
> > tests/qemu-iotests/check | 52 +++++++++++++++++++++++++++++-----------
> > 2 files changed, 39 insertions(+), 14 deletions(-)
>
> Fails all of the block tests. E.g.
>
> https://gitlab.com/qemu-project/qemu/-/jobs/18118947590#L135
>
> > === pylint ===
> > +************* Module check
> > +check:44:12: W0719: Raising too general exception: Exception (broad-exception-raised)
> > +check:44:28: W1309: Using an f-string that does not have any interpolated variables (f-string-without-interpolation)
> > +check:61:12: W0719: Raising too general exception: Exception (broad-exception-raised)
> > +check:61:28: W1309: Using an f-string that does not have any interpolated variables (f-string-without-interpolation)
I dropped the patch from the pull request for now and sent a v2.
Kevin
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2026-11-17 20:51 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-17 17:17 [PULL 0/8] Block layer patches Kevin Wolf
2026-11-17 17:17 ` [PULL 1/8] block/bochs: validate bitmap size and compute extent_blocks after validation Kevin Wolf
2026-11-17 17:17 ` [PULL 2/8] iotests: better heuristics to find I/O tests build/source dirs Kevin Wolf
2026-11-17 20:06 ` Richard Henderson
2026-11-17 20:50 ` Kevin Wolf
2026-11-17 17:17 ` [PULL 3/8] block/vhdx-log: Improve sanity checks to avoid OOB accesses with bad images Kevin Wolf
2026-11-17 17:17 ` [PULL 4/8] iotests: fix false positive on running-outside-venv warning Kevin Wolf
2026-11-17 17:17 ` [PULL 5/8] block/vhdx: Add alignment checks for region tables Kevin Wolf
2026-11-17 17:17 ` [PULL 6/8] block: read the old child length after draining in bdrv_replace_child_bs() Kevin Wolf
2026-11-17 17:17 ` [PULL 7/8] block: add bdrv_child_notify_resize() to notify a single parent Kevin Wolf
2026-11-17 17:17 ` [PULL 8/8] block: notify only the replaced child in bdrv_replace_child_bs() Kevin Wolf
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.