diff mbox series

[3/4] python: raise OSError from send_fd_scm

Message ID 20210928135309.199796-4-pbonzini@redhat.com (mailing list archive)
State New, archived
Headers show
Series python: remove socket_scm_helper | expand

Commit Message

Paolo Bonzini Sept. 28, 2021, 1:53 p.m. UTC
The previous weird calling convention was a consequence of using
socket_scm_helper.  Just use exceptions now that it is gone.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 python/qemu/machine/machine.py | 11 ++---------
 tests/qemu-iotests/045         |  3 +--
 tests/qemu-iotests/147         |  3 +--
 3 files changed, 4 insertions(+), 13 deletions(-)
diff mbox series

Patch

diff --git a/python/qemu/machine/machine.py b/python/qemu/machine/machine.py
index d230915fbf..813ccb17c2 100644
--- a/python/qemu/machine/machine.py
+++ b/python/qemu/machine/machine.py
@@ -208,7 +208,7 @@  def add_fd(self: _T, fd: int, fdset: int,
         return self
 
     def send_fd_scm(self, fd: Optional[int] = None,
-                    file_path: Optional[str] = None) -> int:
+                    file_path: Optional[str] = None) -> None:
         """
         Send an fd or file_path via QMP.
 
@@ -225,19 +225,12 @@  def send_fd_scm(self, fd: Optional[int] = None,
             try:
                 fd = os.open(file_path, os.O_RDONLY)
                 self._qmp.send_fd(fd)
-            except OSError:
-                return 1
             finally:
                 if fd != -1:
                     os.close(fd)
         else:
             assert fd is not None
-            try:
-                self._qmp.send_fd(fd)
-            except OSError:
-                return 1
-
-        return 0
+            self._qmp.send_fd(fd)
 
     @staticmethod
     def _remove_if_exists(path: str) -> None:
diff --git a/tests/qemu-iotests/045 b/tests/qemu-iotests/045
index 45eb239baa..3e6d42010e 100755
--- a/tests/qemu-iotests/045
+++ b/tests/qemu-iotests/045
@@ -141,8 +141,7 @@  class TestSCMFd(iotests.QMPTestCase):
         os.remove(image0)
 
     def _send_fd_by_SCM(self):
-        ret = self.vm.send_fd_scm(file_path=image0)
-        self.assertEqual(ret, 0, 'Failed to send fd with UNIX SCM')
+        self.vm.send_fd_scm(file_path=image0)
 
     def test_add_fd(self):
         self._send_fd_by_SCM()
diff --git a/tests/qemu-iotests/147 b/tests/qemu-iotests/147
index 47dfa62e6b..58de6db52e 100755
--- a/tests/qemu-iotests/147
+++ b/tests/qemu-iotests/147
@@ -269,8 +269,7 @@  class BuiltinNBD(NBDBlockdevAddBase):
         sockfd = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
         sockfd.connect(unix_socket)
 
-        result = self.vm.send_fd_scm(fd=sockfd.fileno())
-        self.assertEqual(result, 0, 'Failed to send socket FD')
+        self.vm.send_fd_scm(fd=sockfd.fileno())
 
         result = self.vm.qmp('getfd', fdname='nbd-fifo')
         self.assert_qmp(result, 'return', {})