diff mbox series

[v2,1/6] python/machine: move socket setup out of _base_args property

Message ID 20230725180337.2937292-2-jsnow@redhat.com (mailing list archive)
State New, archived
Headers show
Series python/machine: use socketpair() for console socket | expand

Commit Message

John Snow July 25, 2023, 6:03 p.m. UTC
This property isn't meant to do much else besides return a list of
strings, so move this setup back out into _pre_launch().

Signed-off-by: John Snow <jsnow@redhat.com>
---
 python/qemu/machine/machine.py | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

Comments

Daniel P. Berrangé July 25, 2023, 6:16 p.m. UTC | #1
On Tue, Jul 25, 2023 at 02:03:32PM -0400, John Snow wrote:
> This property isn't meant to do much else besides return a list of
> strings, so move this setup back out into _pre_launch().
> 
> Signed-off-by: John Snow <jsnow@redhat.com>
> ---
>  python/qemu/machine/machine.py | 5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>


With regards,
Daniel
Ani Sinha July 26, 2023, 7:10 a.m. UTC | #2
> On 25-Jul-2023, at 11:33 PM, John Snow <jsnow@redhat.com> wrote:
> 
> This property isn't meant to do much else besides return a list of
> strings, so move this setup back out into _pre_launch().
> 
> Signed-off-by: John Snow <jsnow@redhat.com>

Reviewed-by: Ani Sinha <anisinha@redhat.com>

> ---
> python/qemu/machine/machine.py | 5 ++---
> 1 file changed, 2 insertions(+), 3 deletions(-)
> 
> diff --git a/python/qemu/machine/machine.py b/python/qemu/machine/machine.py
> index c16a0b6fed..8be0f684fe 100644
> --- a/python/qemu/machine/machine.py
> +++ b/python/qemu/machine/machine.py
> @@ -300,9 +300,7 @@ def _base_args(self) -> List[str]:
> 
>         if self._qmp_set:
>             if self._sock_pair:
> -                fd = self._sock_pair[0].fileno()
> -                os.set_inheritable(fd, True)
> -                moncdev = f"socket,id=mon,fd={fd}"
> +                moncdev = f"socket,id=mon,fd={self._sock_pair[0].fileno()}"
>             elif isinstance(self._monitor_address, tuple):
>                 moncdev = "socket,id=mon,host={},port={}".format(
>                     *self._monitor_address
> @@ -339,6 +337,7 @@ def _pre_launch(self) -> None:
>         if self._qmp_set:
>             if self._monitor_address is None:
>                 self._sock_pair = socket.socketpair()
> +                os.set_inheritable(self._sock_pair[0].fileno(), True)
>                 sock = self._sock_pair[1]
>             if isinstance(self._monitor_address, str):
>                 self._remove_files.append(self._monitor_address)
> -- 
> 2.41.0
>
diff mbox series

Patch

diff --git a/python/qemu/machine/machine.py b/python/qemu/machine/machine.py
index c16a0b6fed..8be0f684fe 100644
--- a/python/qemu/machine/machine.py
+++ b/python/qemu/machine/machine.py
@@ -300,9 +300,7 @@  def _base_args(self) -> List[str]:
 
         if self._qmp_set:
             if self._sock_pair:
-                fd = self._sock_pair[0].fileno()
-                os.set_inheritable(fd, True)
-                moncdev = f"socket,id=mon,fd={fd}"
+                moncdev = f"socket,id=mon,fd={self._sock_pair[0].fileno()}"
             elif isinstance(self._monitor_address, tuple):
                 moncdev = "socket,id=mon,host={},port={}".format(
                     *self._monitor_address
@@ -339,6 +337,7 @@  def _pre_launch(self) -> None:
         if self._qmp_set:
             if self._monitor_address is None:
                 self._sock_pair = socket.socketpair()
+                os.set_inheritable(self._sock_pair[0].fileno(), True)
                 sock = self._sock_pair[1]
             if isinstance(self._monitor_address, str):
                 self._remove_files.append(self._monitor_address)