NBD patches for 2020-07-13
[PULL 1/5] nbd: Avoid off-by-one in long export name truncation
In reply to Eric BlakeWhen snprintf returns the same value as the buffer size, the final byte was truncated to ensure a NUL terminator. Fortunately, such long export names are unusual enough, with no real impact other than what is displayed to the user.
Message-Id: <[email protected]>
--- block/nbd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
block/nbd.c +1 -1
@@ -2002,7 +2002,7 @@ static void nbd_refresh_filename(BlockDriverState *bs) len =snprintf (bs->exact_filename,sizeof (bs->exact_filename),"nbd://%s:%s" , host, port); } -if (len >sizeof (bs->exact_filename)) { +if (len >=sizeof (bs->exact_filename)) {/* Name is too long to represent exactly, so leave it empty. */ bs->exact_filename[0 ] ='\0' ; }
Signature · 1 line
2.27.0
[PULL 5/5] iotests.py: filter_testfiles(): filter SOCK_DIR too
In reply to Eric BlakeFrom: Vladimir Sementsov-Ogievskiy <[email protected]>
Message-Id: <[email protected]>
--- tests/qemu-iotests/iotests.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
tests/qemu-iotests/iotests.py +3 -2
@@ -345,8 +345,9 @@ def filter_qmp(qmsg, filter_fn): return qmsg def filter_testfiles(msg): - prefix = os.path.join(test_dir, "%s-" % (os.getpid())) - return msg.replace(prefix, 'TEST_DIR/PID-') + pref1 = os.path.join(test_dir, "%s-" % (os.getpid())) + pref2 = os.path.join(sock_dir, "%s-" % (os.getpid())) + return msg.replace(pref1, 'TEST_DIR/PID-').replace(pref2, 'SOCK_DIR/PID-') def filter_qmp_testfiles(qmsg): def _filter(_key, value):
Signature · 1 line
2.27.0
[PULL 4/5] iotests.py: QemuIoInteractive: print output on failure
In reply to Eric BlakeFrom: Vladimir Sementsov-Ogievskiy <[email protected]>
Make it simpler to debug when qemu-io fails due to wrong arguments or environment.
Message-Id: <[email protected]>
--- tests/qemu-iotests/iotests.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
tests/qemu-iotests/iotests.py +7 -1
@@ -217,7 +217,13 @@ class QemuIoInteractive: stdout=subprocess.PIPE, stderr=subprocess.STDOUT, universal_newlines=True) - assert self._p.stdout.read(9) == 'qemu-io> ' + out = self._p.stdout.read(9) + if out != 'qemu-io> ': + # Most probably qemu-io just failed to start. + # Let's collect the whole output and exit. + out += self._p.stdout.read() + self._p.wait(timeout=1) + raise ValueError(out) def close(self): self._p.communicate('q\n')
Signature · 1 line
2.27.0
[PULL 3/5] iotests: QemuIoInteractive: use qemu_io_args_no_fmt
In reply to Eric BlakeFrom: Vladimir Sementsov-Ogievskiy <[email protected]>
The only user (iotest 205) of QemuIoInteractive provides -f argument, so it's a bit inefficient to use qemu_io_args, which contains -f too. And we are going to add one more test, which wants to specify -f by hand. Let's use qemu_io_args_no_fmt.
Message-Id: <[email protected]>
--- tests/qemu-iotests/iotests.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tests/qemu-iotests/iotests.py +1 -1
@@ -212,7 +212,7 @@ def get_virtio_scsi_device(): class QemuIoInteractive: def __init__(self, *args): - self.args = qemu_io_args + list(args) + self.args = qemu_io_args_no_fmt + list(args) self._p = subprocess.Popen(self.args, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.STDOUT,
Signature · 1 line
2.27.0
[PULL 2/5] hax: Fix setting of FD_CLOEXEC
In reply to Eric BlakeBlindly setting FD_CLOEXEC without a read-modify-write will inadvertently clear any other intentionally-set bits, such as a proposed new bit for designating a fd that must behave in 32-bit mode. Use our wrapper function instead of an incorrect hand-rolled version.
Message-Id: <[email protected]>
--- target/i386/hax-posix.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
target/i386/hax-posix.c +3 -3
@@ -23,7 +23,7 @@ hax_fd hax_mod_open(void)fprintf (stderr,"Failed to open the hax module\n" ); } -fcntl (fd,F_SETFD ,FD_CLOEXEC ); +qemu_set_cloexec (fd);return fd; }
@@ -147,7 +147,7 @@ hax_fd hax_host_open_vm(struct hax_state *hax, int vm_id) fd =open (vm_name,O_RDWR );g_free (vm_name); -fcntl (fd,F_SETFD ,FD_CLOEXEC ); +qemu_set_cloexec (fd);return fd; }
@@ -200,7 +200,7 @@ hax_fd hax_host_open_vcpu(int vmid, int vcpuid)if (fd <0 ) {fprintf (stderr,"Failed to open the vcpu devfs\n" ); } -fcntl (fd,F_SETFD ,FD_CLOEXEC ); +qemu_set_cloexec (fd);return fd; }
Signature · 1 line
2.27.0
The following changes since commit 00ce6c36b35e0eb8cc5d68a28f288a6335848813:
Merge remote-tracking branch 'remotes/huth-gitlab/tags/pull-request-2020-07-13' into staging (2020-07-13 13:01:30 +0100)
are available in the Git repository at:
https://repo.or.cz/qemu/ericb.git tags/pull-nbd-2020-07-13
for you to fetch changes up to df0e032b6196934b2b12180a6a05aa8b7e6553fc:
iotests.py: filter_testfiles(): filter SOCK_DIR too (2020-07-13 09:01:01 -0500)
Patch 2 is a trivial patch that isn't really NBD-related, but which has been overlooked for too long now, so I just included it.
----------------------------------------------------------------
NBD patches for 2020-07-13
- fix off-by-one truncation in corner-case name display
- use fcntl correctly
- iotest cleanups that enable testing an upcoming fix for NBD close
----------------------------------------------------------------
Eric Blake (2):
nbd: Avoid off-by-one in long export name truncation
hax: Fix setting of FD_CLOEXEC
Vladimir Sementsov-Ogievskiy (3):
iotests: QemuIoInteractive: use qemu_io_args_no_fmt iotests.py: QemuIoInteractive: print output on failure iotests.py: filter_testfiles(): filter SOCK_DIR too
block/nbd.c | 2 +- target/i386/hax-posix.c | 6 +++--- tests/qemu-iotests/iotests.py | 15 +++++++++++---- 3 files changed, 15 insertions(+), 8 deletions(-)
Signature · 1 line
2.27.0
Peter Maydell
AppliedQuoted 16 lines · Eric Blake
The following changes since commit
00ce6c36b35e0eb8cc5d68a28f288a6335848813:Merge remote-tracking branch 'remotes/huth-gitlab/tags/pull-request-2020-07-13' into staging (2020-07-13 13:01:30 +0100)
are available in the Git repository at:
https://repo.or.cz/qemu/ericb.git tags/pull-nbd-2020-07-13
for you to fetch changes up to
df0e032b6196934b2b12180a6a05aa8b7e6553fc:
iotests.py:filter_testfiles(): filterSOCK_DIRtoo (2020-07-13 09:01:01 -0500)Patch 2 is a trivial patch that isn't really NBD-related, but which has been overlooked for too long now, so I just included it.
Quoted 8 lines
----------------------------------------------------------------
NBD patches for 2020-07-13- fix off-by-one truncation in corner-case name display
- use fcntl correctly
- iotest cleanups that enable testing an upcoming fix for NBD close----------------------------------------------------------------
Applied, thanks.
Please update the changelog at https://wiki.qemu.org/ChangeLog/5.1
for any user-visible changes.
-- PMM