[libvirt PATCH 6/7] qemu: turn qemuDomainObjExitMonitor into void

Ján Tomko posted 7 patches 4 years, 2 months ago
[libvirt PATCH 6/7] qemu: turn qemuDomainObjExitMonitor into void
Posted by Ján Tomko 4 years, 2 months ago
This reverts my
    commit dc2fd51fd727bbb6de172e0ca4b7dd307bb99180
    Check for domain liveness in qemuDomainObjExitMonitor
which fixed the symptoms of the bug later fixed by
    commit 81f50cb92d16643bcd749e3ab5b404b8b7cec643
    qemu: Avoid calling qemuProcessStop without a job

Signed-off-by: Ján Tomko <jtomko@redhat.com>
---
 src/qemu/THREADS.txt   |  5 -----
 src/qemu/qemu_domain.c | 15 +--------------
 src/qemu/qemu_domain.h |  4 ++--
 3 files changed, 3 insertions(+), 21 deletions(-)

diff --git a/src/qemu/THREADS.txt b/src/qemu/THREADS.txt
index ff10bef9a0..98aa3165e3 100644
--- a/src/qemu/THREADS.txt
+++ b/src/qemu/THREADS.txt
@@ -170,11 +170,6 @@ To acquire the QEMU monitor lock
     - Acquires the virDomainObj *lock
 
   These functions must not be used by an asynchronous job.
-  Note that the virDomainObj is unlocked during the time in
-  monitor and it can be changed, e.g. if QEMU dies, qemuProcessStop
-  may free the live domain definition and put the persistent
-  definition back in vm->def. The callers should check the return
-  value of ExitMonitor to see if the domain is still alive.
 
 
 To acquire the QEMU monitor lock as part of an asynchronous job
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index 94b4081da6..dea7dae4b3 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -5893,24 +5893,11 @@ void qemuDomainObjEnterMonitor(virQEMUDriver *driver,
 /* obj must NOT be locked before calling
  *
  * Should be paired with an earlier qemuDomainObjEnterMonitor() call
- *
- * Returns -1 if the domain is no longer alive after exiting the monitor.
- * In that case, the caller should be careful when using obj's data,
- * e.g. the live definition in vm->def has been freed by qemuProcessStop
- * and replaced by the persistent definition, so pointers stolen
- * from the live definition could no longer be valid.
  */
-int qemuDomainObjExitMonitor(virQEMUDriver *driver,
+void qemuDomainObjExitMonitor(virQEMUDriver *driver,
                              virDomainObj *obj)
 {
     qemuDomainObjExitMonitorInternal(driver, obj);
-    if (!virDomainObjIsActive(obj)) {
-        if (virGetLastErrorCode() == VIR_ERR_OK)
-            virReportError(VIR_ERR_OPERATION_FAILED, "%s",
-                           _("domain is no longer running"));
-        return -1;
-    }
-    return 0;
 }
 
 /*
diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h
index 596add616d..8173c39cdb 100644
--- a/src/qemu/qemu_domain.h
+++ b/src/qemu/qemu_domain.h
@@ -487,8 +487,8 @@ qemuMonitor *qemuDomainGetMonitor(virDomainObj *vm)
 void qemuDomainObjEnterMonitor(virQEMUDriver *driver,
                                virDomainObj *obj)
     ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
-int qemuDomainObjExitMonitor(virQEMUDriver *driver,
-                             virDomainObj *obj)
+void qemuDomainObjExitMonitor(virQEMUDriver *driver,
+                              virDomainObj *obj)
     ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
 int qemuDomainObjEnterMonitorAsync(virQEMUDriver *driver,
                                    virDomainObj *obj,
-- 
2.31.1

Re: [libvirt PATCH 6/7] qemu: turn qemuDomainObjExitMonitor into void
Posted by Michal Prívozník 4 years, 2 months ago
On 11/24/21 14:28, Ján Tomko wrote:
> This reverts my
>     commit dc2fd51fd727bbb6de172e0ca4b7dd307bb99180
>     Check for domain liveness in qemuDomainObjExitMonitor
> which fixed the symptoms of the bug later fixed by
>     commit 81f50cb92d16643bcd749e3ab5b404b8b7cec643
>     qemu: Avoid calling qemuProcessStop without a job
> 
> Signed-off-by: Ján Tomko <jtomko@redhat.com>
> ---
>  src/qemu/THREADS.txt   |  5 -----
>  src/qemu/qemu_domain.c | 15 +--------------
>  src/qemu/qemu_domain.h |  4 ++--
>  3 files changed, 3 insertions(+), 21 deletions(-)
> 
> diff --git a/src/qemu/THREADS.txt b/src/qemu/THREADS.txt
> index ff10bef9a0..98aa3165e3 100644
> --- a/src/qemu/THREADS.txt
> +++ b/src/qemu/THREADS.txt
> @@ -170,11 +170,6 @@ To acquire the QEMU monitor lock
>      - Acquires the virDomainObj *lock
>  
>    These functions must not be used by an asynchronous job.
> -  Note that the virDomainObj is unlocked during the time in
> -  monitor and it can be changed, e.g. if QEMU dies, qemuProcessStop
> -  may free the live domain definition and put the persistent
> -  definition back in vm->def. The callers should check the return
> -  value of ExitMonitor to see if the domain is still alive.
>  
>  
>  To acquire the QEMU monitor lock as part of an asynchronous job
> diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
> index 94b4081da6..dea7dae4b3 100644
> --- a/src/qemu/qemu_domain.c
> +++ b/src/qemu/qemu_domain.c
> @@ -5893,24 +5893,11 @@ void qemuDomainObjEnterMonitor(virQEMUDriver *driver,
>  /* obj must NOT be locked before calling
>   *
>   * Should be paired with an earlier qemuDomainObjEnterMonitor() call
> - *
> - * Returns -1 if the domain is no longer alive after exiting the monitor.
> - * In that case, the caller should be careful when using obj's data,
> - * e.g. the live definition in vm->def has been freed by qemuProcessStop
> - * and replaced by the persistent definition, so pointers stolen
> - * from the live definition could no longer be valid.
>   */
> -int qemuDomainObjExitMonitor(virQEMUDriver *driver,
> +void qemuDomainObjExitMonitor(virQEMUDriver *driver,
>                               virDomainObj *obj)

  Alignment.

Michal