Skip to contentSkip to conversation

qga: fix assert regression on guest-shutdown

PATCH In review Marc-André Lureau 3 participants 5 messages Jun 4, 2020 – Jun 15, 2020

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 qga: fix assert regression on guest-shutdown

Since commit 781f2b3d1e ("qga: process_event() simplification"), send_response() is called unconditionally, but will assert when "rsp" is NULL. This may happen with QCO_NO_SUCCESS_RESP commands, such as "guest-shutdown".

Fixes 781f2b3d1e5ef389b44016a897fd55e7a780bf35
Cc Michael Roth <[email protected]>
---
 qga/main.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
qga/main.c +5 -1
index f0e454f28d3..3febf3b0fdf 100644
@@ -531,7 +531,11 @@ static int send_response(GAState *s, const QDict *rsp)
     QString *payload_qstr, *response_qstr;
     GIOStatus status;
 
-    g_assert(rsp && s->channel);
+    g_assert(s->channel);
+
+    if (!rsp) {
+        return 0;
+    }
 
     payload_qstr = qobject_to_json(QOBJECT(rsp));
     if (!payload_qstr) {
Signature · 1 line
2.26.2.561.g07d8ea56f2
Reviewed-by on v1 1/1
#1 lore raw
Quoted 18 lines · Marc-André Lureau

Since commit 781f2b3d1e ("qga: process_event() simplification"), send_response() is called unconditionally, but will assert when "rsp" is NULL. This may happen with QCO_NO_SUCCESS_RESP commands, such as "guest-shutdown".

Fixes 781f2b3d1e5ef389b44016a897fd55e7a780bf35
Cc Michael Roth <[email protected]>
---
 qga/main.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
qga/main.c +0 -0
index f0e454f28d3..3febf3b0fdf 100644

qga/main.c static int send_response(GAState *s, const QDict *rsp) · line 538

Quoted 9 lines
qga/main.c +5 -1
@@ -531,7 +531,11 @@ static int send_response(GAState *s, const QDict *rsp)
     QString *payload_qstr, *response_qstr;
     GIOStatus status;
 
-    g_assert(rsp && s->channel);
+    g_assert(s->channel);
+
+    if (!rsp) {
+        return 0;
+    }

Why not assert after the check?

Anyway:

Quoted 4 lines
qga/main.c +0 -0
     payload_qstr = qobject_to_json(QOBJECT(rsp));
     if (!payload_qstr) {
 
Reviewed-by on v1 1/1
#2 lore raw
In reply to Marc-André Lureau
Quoted 20 lines · Marc-André Lureau

Since commit 781f2b3d1e ("qga: process_event() simplification"), send_response() is called unconditionally, but will assert when "rsp" is NULL. This may happen with QCO_NO_SUCCESS_RESP commands, such as "guest-shutdown".

Fixes 781f2b3d1e5ef389b44016a897fd55e7a780bf35
Cc Michael Roth <[email protected]>
---
 qga/main.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
qga/main.c +0 -0
index f0e454f28d3..3febf3b0fdf 100644
@@ -531,7 +531,11 @@ static int send_response(GAState *s, const QDict *rsp)
     QString *payload_qstr, *response_qstr;
     GIOStatus status;

qga/main.c static int send_response(GAState *s, const QDict *rsp) · line 541

Quoted 10 lines
qga/main.c +5 -1
 
-    g_assert(rsp && s->channel);
+    g_assert(s->channel);
+
+    if (!rsp) {
+        return 0;
+    }
 
 
 

Thanks Marc-André,
LGTM and should fix the issues I was seeing.

Signature · 3 lines
Christian Ehrhardt
Staff Engineer, Ubuntu Server
Canonical Ltd
#3 lore raw
Quoted 39 lines · Christian Ehrhardt
Quoted 21 lines · Marc-André Lureau

Since commit 781f2b3d1e ("qga: process_event() simplification"), send_response() is called unconditionally, but will assert when "rsp" is NULL. This may happen with QCO_NO_SUCCESS_RESP commands, such as "guest-shutdown".

Fixes 781f2b3d1e5ef389b44016a897fd55e7a780bf35
Cc Michael Roth <[email protected]>
---
 qga/main.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
qga/main.c +0 -0
index f0e454f28d3..3febf3b0fdf 100644
@@ -531,7 +531,11 @@ static int send_response(GAState *s, const QDict
 *rsp)
     QString *payload_qstr, *response_qstr;

qga/main.c static int send_response(GAState *s, const QDict · line 541

Quoted 10 lines
qga/main.c +5 -1
     GIOStatus status;
 
-    g_assert(rsp && s->channel);
+    g_assert(s->channel);
+
+    if (!rsp) {
+        return 0;
+    }
 
 

Thanks Marc-André,
LGTM and should fix the issues I was seeing.

Quoted 2 lines

In the meantime I also got to test this against the initially reported issue, LGTM as well (ran as no-change backport onto 4.2).

#4 lore raw
Quoted 44 lines · Christian Ehrhardt
Quoted 39 lines · Christian Ehrhardt
Quoted 21 lines · Marc-André Lureau

Since commit 781f2b3d1e ("qga: process_event() simplification"), send_response() is called unconditionally, but will assert when "rsp" is NULL. This may happen with QCO_NO_SUCCESS_RESP commands, such as "guest-shutdown".

Fixes 781f2b3d1e5ef389b44016a897fd55e7a780bf35
Cc Michael Roth <[email protected]>
---
 qga/main.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
qga/main.c +0 -0
index f0e454f28d3..3febf3b0fdf 100644
@@ -531,7 +531,11 @@ static int send_response(GAState *s, const QDict
 *rsp)
     QString *payload_qstr, *response_qstr;

qga/main.c static int send_response(GAState *s, const QDict · line 541

Quoted 10 lines
qga/main.c +5 -1
     GIOStatus status;
 
-    g_assert(rsp && s->channel);
+    g_assert(s->channel);
+
+    if (!rsp) {
+        return 0;
+    }
 
 

Thanks Marc-André,
LGTM and should fix the issues I was seeing.

Quoted 8 lines
Quoted 2 lines

In the meantime I also got to test this against the initially reported issue, LGTM as well (ran as no-change backport onto 4.2).

This LGTM with 2*reviews 1*tested and 11 days on the list without any negative feedback.
I just wanted to re-check if there is anything else left for this to be committed?