All of lore.kernel.org
 help / color / mirror / Atom feed
* [PULL 0/5] NBD patches for 2020-07-13
@ 2020-07-13 14:21 Eric Blake
  2020-07-13 14:21 ` [PULL 1/5] nbd: Avoid off-by-one in long export name truncation Eric Blake
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: Eric Blake @ 2020-07-13 14:21 UTC (permalink / raw)
  To: qemu-devel

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(-)

-- 
2.27.0



^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PULL 1/5] nbd: Avoid off-by-one in long export name truncation
  2020-07-13 14:21 [PULL 0/5] NBD patches for 2020-07-13 Eric Blake
@ 2020-07-13 14:21 ` Eric Blake
  2020-07-13 14:21 ` [PULL 2/5] hax: Fix setting of FD_CLOEXEC Eric Blake
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Eric Blake @ 2020-07-13 14:21 UTC (permalink / raw)
  To: qemu-devel
  Cc: Kevin Wolf, Vladimir Sementsov-Ogievskiy,
	open list:Network Block Dev...,
	Max Reitz

When 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.

Fixes: 5c86bdf12089
Reported-by: Max Reitz <mreitz@redhat.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
Message-Id: <20200622210355.414941-1-eblake@redhat.com>
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
---
 block/nbd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/block/nbd.c b/block/nbd.c
index c297336ffc5f..65a4f56924ec 100644
--- a/block/nbd.c
+++ b/block/nbd.c
@@ -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';
     }
-- 
2.27.0



^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PULL 2/5] hax: Fix setting of FD_CLOEXEC
  2020-07-13 14:21 [PULL 0/5] NBD patches for 2020-07-13 Eric Blake
  2020-07-13 14:21 ` [PULL 1/5] nbd: Avoid off-by-one in long export name truncation Eric Blake
@ 2020-07-13 14:21 ` Eric Blake
  2020-07-13 14:21 ` [PULL 3/5] iotests: QemuIoInteractive: use qemu_io_args_no_fmt Eric Blake
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Eric Blake @ 2020-07-13 14:21 UTC (permalink / raw)
  To: qemu-devel
  Cc: Eduardo Habkost, Wenchao Wang, open list:X86 HAXM CPUs, Colin Xu,
	Paolo Bonzini, Richard Henderson

Blindly 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.

Signed-off-by: Eric Blake <eblake@redhat.com>
Message-Id: <20200420175309.75894-2-eblake@redhat.com>
Reviewed-by: Colin Xu <colin.xu@intel.com>
---
 target/i386/hax-posix.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/target/i386/hax-posix.c b/target/i386/hax-posix.c
index 3bad89f13337..5f9d1b803dec 100644
--- a/target/i386/hax-posix.c
+++ b/target/i386/hax-posix.c
@@ -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;
 }

-- 
2.27.0



^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PULL 3/5] iotests: QemuIoInteractive: use qemu_io_args_no_fmt
  2020-07-13 14:21 [PULL 0/5] NBD patches for 2020-07-13 Eric Blake
  2020-07-13 14:21 ` [PULL 1/5] nbd: Avoid off-by-one in long export name truncation Eric Blake
  2020-07-13 14:21 ` [PULL 2/5] hax: Fix setting of FD_CLOEXEC Eric Blake
@ 2020-07-13 14:21 ` Eric Blake
  2020-07-13 14:21 ` [PULL 4/5] iotests.py: QemuIoInteractive: print output on failure Eric Blake
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Eric Blake @ 2020-07-13 14:21 UTC (permalink / raw)
  To: qemu-devel
  Cc: Kevin Wolf, Vladimir Sementsov-Ogievskiy,
	open list:Block layer core, Max Reitz

From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>

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.

Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Message-Id: <20200701105331.121670-2-vsementsov@virtuozzo.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
---
 tests/qemu-iotests/iotests.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py
index f1e0733dda05..109fb3884a26 100644
--- a/tests/qemu-iotests/iotests.py
+++ b/tests/qemu-iotests/iotests.py
@@ -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,
-- 
2.27.0



^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PULL 4/5] iotests.py: QemuIoInteractive: print output on failure
  2020-07-13 14:21 [PULL 0/5] NBD patches for 2020-07-13 Eric Blake
                   ` (2 preceding siblings ...)
  2020-07-13 14:21 ` [PULL 3/5] iotests: QemuIoInteractive: use qemu_io_args_no_fmt Eric Blake
@ 2020-07-13 14:21 ` Eric Blake
  2020-07-13 14:21 ` [PULL 5/5] iotests.py: filter_testfiles(): filter SOCK_DIR too Eric Blake
  2020-07-14 13:38 ` [PULL 0/5] NBD patches for 2020-07-13 Peter Maydell
  5 siblings, 0 replies; 7+ messages in thread
From: Eric Blake @ 2020-07-13 14:21 UTC (permalink / raw)
  To: qemu-devel
  Cc: Kevin Wolf, Vladimir Sementsov-Ogievskiy,
	open list:Block layer core, Max Reitz

From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>

Make it simpler to debug when qemu-io fails due to wrong arguments or
environment.

Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Message-Id: <20200701105331.121670-3-vsementsov@virtuozzo.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
---
 tests/qemu-iotests/iotests.py | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py
index 109fb3884a26..2a08fea3c9ec 100644
--- a/tests/qemu-iotests/iotests.py
+++ b/tests/qemu-iotests/iotests.py
@@ -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')
-- 
2.27.0



^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PULL 5/5] iotests.py: filter_testfiles(): filter SOCK_DIR too
  2020-07-13 14:21 [PULL 0/5] NBD patches for 2020-07-13 Eric Blake
                   ` (3 preceding siblings ...)
  2020-07-13 14:21 ` [PULL 4/5] iotests.py: QemuIoInteractive: print output on failure Eric Blake
@ 2020-07-13 14:21 ` Eric Blake
  2020-07-14 13:38 ` [PULL 0/5] NBD patches for 2020-07-13 Peter Maydell
  5 siblings, 0 replies; 7+ messages in thread
From: Eric Blake @ 2020-07-13 14:21 UTC (permalink / raw)
  To: qemu-devel
  Cc: Kevin Wolf, Vladimir Sementsov-Ogievskiy,
	open list:Block layer core, Max Reitz

From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>

Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Message-Id: <20200701105331.121670-5-vsementsov@virtuozzo.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
---
 tests/qemu-iotests/iotests.py | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py
index 2a08fea3c9ec..8b760405ee72 100644
--- a/tests/qemu-iotests/iotests.py
+++ b/tests/qemu-iotests/iotests.py
@@ -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):
-- 
2.27.0



^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PULL 0/5] NBD patches for 2020-07-13
  2020-07-13 14:21 [PULL 0/5] NBD patches for 2020-07-13 Eric Blake
                   ` (4 preceding siblings ...)
  2020-07-13 14:21 ` [PULL 5/5] iotests.py: filter_testfiles(): filter SOCK_DIR too Eric Blake
@ 2020-07-14 13:38 ` Peter Maydell
  5 siblings, 0 replies; 7+ messages in thread
From: Peter Maydell @ 2020-07-14 13:38 UTC (permalink / raw)
  To: Eric Blake; +Cc: QEMU Developers

On Mon, 13 Jul 2020 at 15:34, Eric Blake <eblake@redhat.com> wrote:
>
> 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
>
> ----------------------------------------------------------------


Applied, thanks.

Please update the changelog at https://wiki.qemu.org/ChangeLog/5.1
for any user-visible changes.

-- PMM


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2020-07-14 13:40 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-13 14:21 [PULL 0/5] NBD patches for 2020-07-13 Eric Blake
2020-07-13 14:21 ` [PULL 1/5] nbd: Avoid off-by-one in long export name truncation Eric Blake
2020-07-13 14:21 ` [PULL 2/5] hax: Fix setting of FD_CLOEXEC Eric Blake
2020-07-13 14:21 ` [PULL 3/5] iotests: QemuIoInteractive: use qemu_io_args_no_fmt Eric Blake
2020-07-13 14:21 ` [PULL 4/5] iotests.py: QemuIoInteractive: print output on failure Eric Blake
2020-07-13 14:21 ` [PULL 5/5] iotests.py: filter_testfiles(): filter SOCK_DIR too Eric Blake
2020-07-14 13:38 ` [PULL 0/5] NBD patches for 2020-07-13 Peter Maydell

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.