diff mbox series

[V9,41/46] python/machine: QEMUMachine reopen_qmp_connection

Message ID 1658851843-236870-42-git-send-email-steven.sistare@oracle.com (mailing list archive)
State New, archived
Headers show
Series Live Update | expand

Commit Message

Steven Sistare July 26, 2022, 4:10 p.m. UTC
Provide reopen_qmp_connection() to reopen a closed monitor connection.
This is needed by cpr, because qemu exec closes the monitor socket.

Signed-off-by: Steve Sistare <steven.sistare@oracle.com>
---
 python/qemu/machine/machine.py | 9 +++++++++
 1 file changed, 9 insertions(+)

Comments

John Snow July 26, 2022, 6:04 p.m. UTC | #1
On Tue, Jul 26, 2022 at 12:12 PM Steve Sistare
<steven.sistare@oracle.com> wrote:
>
> Provide reopen_qmp_connection() to reopen a closed monitor connection.
> This is needed by cpr, because qemu exec closes the monitor socket.
>
> Signed-off-by: Steve Sistare <steven.sistare@oracle.com>
> ---
>  python/qemu/machine/machine.py | 9 +++++++++
>  1 file changed, 9 insertions(+)
>
> diff --git a/python/qemu/machine/machine.py b/python/qemu/machine/machine.py
> index d05950e..60b934d 100644
> --- a/python/qemu/machine/machine.py
> +++ b/python/qemu/machine/machine.py
> @@ -491,6 +491,15 @@ def _close_qmp_connection(self) -> None:
>          finally:
>              self._qmp_connection = None
>
> +    def reopen_qmp_connection(self):

def reopen_qmp_connection(self) -> None:
    """Close and re-open the QMP connection."""
    ...

> +        self._close_qmp_connection()
> +        self._qmp_connection = QEMUMonitorProtocol(
> +            self._monitor_address,
> +            server=True,
> +            nickname=self._name
> +        )
> +        self._qmp.accept(self._qmp_timer)
> +
>      def _early_cleanup(self) -> None:
>          """
>          Perform any cleanup that needs to happen before the VM exits.
> --
> 1.8.3.1
>

With applied fixup:

Reviewed-by: John Snow <jsnow@redhat.com>
Steven Sistare July 27, 2022, 12:06 p.m. UTC | #2
On 7/26/2022 2:04 PM, John Snow wrote:
> On Tue, Jul 26, 2022 at 12:12 PM Steve Sistare
> <steven.sistare@oracle.com> wrote:
>>
>> Provide reopen_qmp_connection() to reopen a closed monitor connection.
>> This is needed by cpr, because qemu exec closes the monitor socket.
>>
>> Signed-off-by: Steve Sistare <steven.sistare@oracle.com>
>> ---
>>  python/qemu/machine/machine.py | 9 +++++++++
>>  1 file changed, 9 insertions(+)
>>
>> diff --git a/python/qemu/machine/machine.py b/python/qemu/machine/machine.py
>> index d05950e..60b934d 100644
>> --- a/python/qemu/machine/machine.py
>> +++ b/python/qemu/machine/machine.py
>> @@ -491,6 +491,15 @@ def _close_qmp_connection(self) -> None:
>>          finally:
>>              self._qmp_connection = None
>>
>> +    def reopen_qmp_connection(self):
> 
> def reopen_qmp_connection(self) -> None:
>     """Close and re-open the QMP connection."""

Will do.  Thanks very much John for the fast review.

- Steve

>     ...
> 
>> +        self._close_qmp_connection()
>> +        self._qmp_connection = QEMUMonitorProtocol(
>> +            self._monitor_address,
>> +            server=True,
>> +            nickname=self._name
>> +        )
>> +        self._qmp.accept(self._qmp_timer)
>> +
>>      def _early_cleanup(self) -> None:
>>          """
>>          Perform any cleanup that needs to happen before the VM exits.
>> --
>> 1.8.3.1
>>
> 
> With applied fixup:
> 
> Reviewed-by: John Snow <jsnow@redhat.com>
>
diff mbox series

Patch

diff --git a/python/qemu/machine/machine.py b/python/qemu/machine/machine.py
index d05950e..60b934d 100644
--- a/python/qemu/machine/machine.py
+++ b/python/qemu/machine/machine.py
@@ -491,6 +491,15 @@  def _close_qmp_connection(self) -> None:
         finally:
             self._qmp_connection = None
 
+    def reopen_qmp_connection(self):
+        self._close_qmp_connection()
+        self._qmp_connection = QEMUMonitorProtocol(
+            self._monitor_address,
+            server=True,
+            nickname=self._name
+        )
+        self._qmp.accept(self._qmp_timer)
+
     def _early_cleanup(self) -> None:
         """
         Perform any cleanup that needs to happen before the VM exits.