aboutsummaryrefslogtreecommitdiff
path: root/qemu-char.c
diff options
context:
space:
mode:
authorStefan Hajnoczi <stefanha@redhat.com>2014-06-22 10:38:36 +0800
committerMichael S. Tsirkin <mst@redhat.com>2014-06-23 17:38:00 +0300
commit4f8586144161d5e680fdef3e09b7e8e9111c2929 (patch)
tree124dff54d53f5eba6a6f0493c7eafffcccf1750f /qemu-char.c
parent684531ad1f69feb1288b9813c3eb47fba992ea96 (diff)
downloadqemu-4f8586144161d5e680fdef3e09b7e8e9111c2929.zip
qemu-4f8586144161d5e680fdef3e09b7e8e9111c2929.tar.gz
qemu-4f8586144161d5e680fdef3e09b7e8e9111c2929.tar.bz2
qemu-char: fix qemu_chr_fe_get_msgfd()
Commit c76bf6bb8fbbb233a7d3641e09229d23747d5ee3 ("Add chardev API qemu_chr_fe_get_msgfds") broke qemu_chr_fe_get_msgfd() because it changed the return value. Callers expect -1 if no fd is available. The commit changed the return value to 0 (which is a valid file descriptor number) so callers always detected a file descriptor even if none was available. This patch fixes qemu-iotests 045: $ cd tests/qemu-iotests && ./check 045 [...] +FAIL: test_add_fd_invalid_fd (__main__.TestFdSets) +---------------------------------------------------------------------- +Traceback (most recent call last): + File "./045", line 123, in test_add_fd_invalid_fd + self.assert_qmp(result, 'error/class', 'GenericError') + File "/home/stefanha/qemu/tests/qemu-iotests/iotests.py", line 232, in assert_qmp + result = self.dictpath(d, path) + File "/home/stefanha/qemu/tests/qemu-iotests/iotests.py", line 211, in dictpath + self.fail('failed path traversal for "%s" in "%s"' % (path, str(d))) +AssertionError: failed path traversal for "error/class" in "{u'return': {u'fdset-id': 2, u'fd': 0}}" Cc: Nikolay Nikolaev <n.nikolaev@virtualopensystems.com> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Diffstat (limited to 'qemu-char.c')
-rw-r--r--qemu-char.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/qemu-char.c b/qemu-char.c
index e4eb985..d9100a2 100644
--- a/qemu-char.c
+++ b/qemu-char.c
@@ -204,7 +204,7 @@ void qemu_chr_be_write(CharDriverState *s, uint8_t *buf, int len)
int qemu_chr_fe_get_msgfd(CharDriverState *s)
{
int fd;
- return (qemu_chr_fe_get_msgfds(s, &fd, 1) >= 0) ? fd : -1;
+ return (qemu_chr_fe_get_msgfds(s, &fd, 1) == 1) ? fd : -1;
}
int qemu_chr_fe_get_msgfds(CharDriverState *s, int *fds, int len)