[libvirt] [PATCH v3] qemu: agent: Avoid agentError when closing the QEMU agent

Wang Yechao posted 1 patch 5 years, 6 months ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/1539310768-30445-1-git-send-email-wang.yechao255@zte.com.cn
Test syntax-check passed
src/qemu/qemu_agent.c | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
[libvirt] [PATCH v3] qemu: agent: Avoid agentError when closing the QEMU agent
Posted by Wang Yechao 5 years, 6 months ago
The commit 89563efc0209b854d2b2e554423423d7602acdbd fix the
monitor error when closing the QEMU monitor. The QEMU agent
has a problem similar to QEMU monitor. So fix the QEMU agent
with the same method.

Signed-off-by: Wang Yechao <wang.yechao255@zte.com.cn>
---
Changes in v3:
 - change the commit messages
---
 src/qemu/qemu_agent.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/src/qemu/qemu_agent.c b/src/qemu/qemu_agent.c
index 97ad0e7..d842b0e 100644
--- a/src/qemu/qemu_agent.c
+++ b/src/qemu/qemu_agent.c
@@ -530,6 +530,9 @@ static void qemuAgentUpdateWatch(qemuAgentPtr mon)
         VIR_EVENT_HANDLE_HANGUP |
         VIR_EVENT_HANDLE_ERROR;
 
+    if (!mon->watch)
+        return;
+
     if (mon->lastError.code == VIR_ERR_OK) {
         events |= VIR_EVENT_HANDLE_READABLE;
 
@@ -555,6 +558,12 @@ qemuAgentIO(int watch, int fd, int events, void *opaque)
     VIR_DEBUG("Agent %p I/O on watch %d fd %d events %d", mon, watch, fd, events);
 #endif
 
+    if (mon->fd == -1 || mon->watch == 0) {
+        virObjectUnlock(mon);
+        virObjectUnref(mon);
+        return;
+    }
+
     if (mon->fd != fd || mon->watch != watch) {
         if (events & (VIR_EVENT_HANDLE_HANGUP | VIR_EVENT_HANDLE_ERROR))
             eof = true;
@@ -788,8 +797,10 @@ void qemuAgentClose(qemuAgentPtr mon)
     virObjectLock(mon);
 
     if (mon->fd >= 0) {
-        if (mon->watch)
+        if (mon->watch) {
             virEventRemoveHandle(mon->watch);
+            mon->watch = 0;
+        }
         VIR_FORCE_CLOSE(mon->fd);
     }
 
-- 
1.8.3.1

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH v3] qemu: agent: Avoid agentError when closing the QEMU agent
Posted by John Ferlan 5 years, 5 months ago

On 10/11/18 10:19 PM, Wang Yechao wrote:
> The commit 89563efc0209b854d2b2e554423423d7602acdbd fix the
> monitor error when closing the QEMU monitor. The QEMU agent
> has a problem similar to QEMU monitor. So fix the QEMU agent
> with the same method.
> 
> Signed-off-by: Wang Yechao <wang.yechao255@zte.com.cn>
> ---
> Changes in v3:
>  - change the commit messages
> ---
>  src/qemu/qemu_agent.c | 13 ++++++++++++-
>  1 file changed, 12 insertions(+), 1 deletion(-)
> 

Strange somehow this patch got lost and marked as read in my pile of
patches to review so I have essentially forgotten about it until I was
looking back through my email list and wondered why I had an unanswered
entry unmarked... Oh well - in the future if you think your patch is
"forgotten" - after a week or so of inactivity, feel free to "ping" on
it...

Reviewed-by: John Ferlan <jferlan@redhat.com>
(and pushed)

John

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list