Skip to content

Commit 1a53dfe

Browse files
committed
Merge remote-tracking branch 'remotes/ericb/tags/pull-nbd-2020-07-13' into staging
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 # gpg: Signature made Mon 13 Jul 2020 15:11:35 BST # gpg: using RSA key 71C2CC22B1C4602927D2F3AAA7A16B4A2527436A # gpg: Good signature from "Eric Blake <[email protected]>" [full] # gpg: aka "Eric Blake (Free Software Programmer) <[email protected]>" [full] # gpg: aka "[jpeg image of size 6874]" [full] # Primary key fingerprint: 71C2 CC22 B1C4 6029 27D2 F3AA A7A1 6B4A 2527 436A * remotes/ericb/tags/pull-nbd-2020-07-13: iotests.py: filter_testfiles(): filter SOCK_DIR too iotests.py: QemuIoInteractive: print output on failure iotests: QemuIoInteractive: use qemu_io_args_no_fmt hax: Fix setting of FD_CLOEXEC nbd: Avoid off-by-one in long export name truncation Signed-off-by: Peter Maydell <[email protected]>
2 parents 20c1df5 + df0e032 commit 1a53dfe

File tree

3 files changed

+15
-8
lines changed

3 files changed

+15
-8
lines changed

block/nbd.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2002,7 +2002,7 @@ static void nbd_refresh_filename(BlockDriverState *bs)
20022002
len = snprintf(bs->exact_filename, sizeof(bs->exact_filename),
20032003
"nbd://%s:%s", host, port);
20042004
}
2005-
if (len > sizeof(bs->exact_filename)) {
2005+
if (len >= sizeof(bs->exact_filename)) {
20062006
/* Name is too long to represent exactly, so leave it empty. */
20072007
bs->exact_filename[0] = '\0';
20082008
}

target/i386/hax-posix.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ hax_fd hax_mod_open(void)
2323
fprintf(stderr, "Failed to open the hax module\n");
2424
}
2525

26-
fcntl(fd, F_SETFD, FD_CLOEXEC);
26+
qemu_set_cloexec(fd);
2727

2828
return fd;
2929
}
@@ -147,7 +147,7 @@ hax_fd hax_host_open_vm(struct hax_state *hax, int vm_id)
147147
fd = open(vm_name, O_RDWR);
148148
g_free(vm_name);
149149

150-
fcntl(fd, F_SETFD, FD_CLOEXEC);
150+
qemu_set_cloexec(fd);
151151

152152
return fd;
153153
}
@@ -200,7 +200,7 @@ hax_fd hax_host_open_vcpu(int vmid, int vcpuid)
200200
if (fd < 0) {
201201
fprintf(stderr, "Failed to open the vcpu devfs\n");
202202
}
203-
fcntl(fd, F_SETFD, FD_CLOEXEC);
203+
qemu_set_cloexec(fd);
204204
return fd;
205205
}
206206

tests/qemu-iotests/iotests.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -212,12 +212,18 @@ def get_virtio_scsi_device():
212212

213213
class QemuIoInteractive:
214214
def __init__(self, *args):
215-
self.args = qemu_io_args + list(args)
215+
self.args = qemu_io_args_no_fmt + list(args)
216216
self._p = subprocess.Popen(self.args, stdin=subprocess.PIPE,
217217
stdout=subprocess.PIPE,
218218
stderr=subprocess.STDOUT,
219219
universal_newlines=True)
220-
assert self._p.stdout.read(9) == 'qemu-io> '
220+
out = self._p.stdout.read(9)
221+
if out != 'qemu-io> ':
222+
# Most probably qemu-io just failed to start.
223+
# Let's collect the whole output and exit.
224+
out += self._p.stdout.read()
225+
self._p.wait(timeout=1)
226+
raise ValueError(out)
221227

222228
def close(self):
223229
self._p.communicate('q\n')
@@ -339,8 +345,9 @@ def filter_qmp(qmsg, filter_fn):
339345
return qmsg
340346

341347
def filter_testfiles(msg):
342-
prefix = os.path.join(test_dir, "%s-" % (os.getpid()))
343-
return msg.replace(prefix, 'TEST_DIR/PID-')
348+
pref1 = os.path.join(test_dir, "%s-" % (os.getpid()))
349+
pref2 = os.path.join(sock_dir, "%s-" % (os.getpid()))
350+
return msg.replace(pref1, 'TEST_DIR/PID-').replace(pref2, 'SOCK_DIR/PID-')
344351

345352
def filter_qmp_testfiles(qmsg):
346353
def _filter(_key, value):

0 commit comments

Comments
 (0)