Skip to content
  • Stefan Hajnoczi's avatar
    qemu-char: fix qemu_chr_fe_get_msgfd() · 4f858614
    Stefan Hajnoczi authored
    Commit c76bf6bb
    
     ("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: default avatarStefan Hajnoczi <stefanha@redhat.com>
    Reviewed-by: default avatarMichael S. Tsirkin <mst@redhat.com>
    Signed-off-by: default avatarMichael S. Tsirkin <mst@redhat.com>
    
    4f858614