Skip to contentSkip to conversation

: qemu-ga: no success response for certain commands

PATCH Superseded Luiz Capitulino 2 participants 12 messages May 4, 2012 – May 8, 2012

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover : qemu-ga: no success response for certain commands

This series changes qemu-ga to not emit a success response for commands guest-shutdown and guest-suspend-{ram,disk,hybrid}. More details and the reason for this change can be found in the following patches.

Also note that this series depends on this series sent by me previously:

    http://lists.gnu.org/archive/html/qemu-devel/2012-05/msg00584.html
 qapi-schema-guest.json   |   50 +++++++++++++++++++++++++++-------------------
 qapi/qmp-core.h          |   10 +++++++++-
 qapi/qmp-dispatch.c      |    8 ++++++--
 qapi/qmp-registry.c      |    4 +++-
 qemu-ga.c                |    2 --
 scripts/qapi-commands.py |   14 +++++++++++--
 6 files changed, 60 insertions(+), 28 deletions(-)
#1 lore raw

PATCH 1/6 qapi: add support for command options

Options allow for changes in commands behavior. This commit introduces the QCO_NO_SUCCESS_RESP option, which causes a command to not emit a success response.

This is needed by commands such as qemu-ga's guest-shutdown, which may not be able to complete before the VM vanishes. In this case, it's useful and simpler not to bother sending a success response.

---
 qapi/qmp-core.h          |   10 +++++++++-
 qapi/qmp-dispatch.c      |    8 ++++++--
 qapi/qmp-registry.c      |    4 +++-
 scripts/qapi-commands.py |   14 ++++++++++++--
 4 files changed, 30 insertions(+), 6 deletions(-)
qapi/qmp-core.h +9 -1
index 431ddbb..b0f64ba 100644
@@ -25,16 +25,24 @@ typedef enum QmpCommandType
     QCT_NORMAL,
 } QmpCommandType;
 
+typedef enum QmpCommandOptions
+{
+    QCO_NO_OPTIONS = 0x0,
+    QCO_NO_SUCCESS_RESP = 0x1,
+} QmpCommandOptions;
+
 typedef struct QmpCommand
 {
     const char *name;
     QmpCommandType type;
     QmpCommandFunc *fn;
+    QmpCommandOptions options;
     QTAILQ_ENTRY(QmpCommand) node;
     bool enabled;
 } QmpCommand;
 
-void qmp_register_command(const char *name, QmpCommandFunc *fn);
+void qmp_register_command(const char *name, QmpCommandFunc *fn,
+                          QmpCommandOptions options);
 QmpCommand *qmp_find_command(const char *name);
 QObject *qmp_dispatch(QObject *request);
 void qmp_disable_command(const char *name);
qapi/qmp-dispatch.c +6 -2
index 43f640a..122c1a2 100644
@@ -94,8 +94,12 @@ static QObject *do_qmp_dispatch(QObject *request, Error **errp)
     switch (cmd->type) {
     case QCT_NORMAL:
         cmd->fn(args, &ret, errp);
-        if (!error_is_set(errp) && ret == NULL) {
-            ret = QOBJECT(qdict_new());
+        if (!error_is_set(errp)) {
+            if (cmd->options & QCO_NO_SUCCESS_RESP) {
+                g_assert(!ret);
+            } else if (!ret) {
+                ret = QOBJECT(qdict_new());
+            }
         }
         break;
     }
qapi/qmp-registry.c +3 -1
index 43d5cde..5414613 100644
@@ -17,7 +17,8 @@
 static QTAILQ_HEAD(QmpCommandList, QmpCommand) qmp_commands =
     QTAILQ_HEAD_INITIALIZER(qmp_commands);
 
-void qmp_register_command(const char *name, QmpCommandFunc *fn)
+void qmp_register_command(const char *name, QmpCommandFunc *fn,
+                          QmpCommandOptions options)
 {
     QmpCommand *cmd = g_malloc0(sizeof(*cmd));
 
@@ -25,6 +26,7 @@ void qmp_register_command(const char *name, QmpCommandFunc *fn)
     cmd->type = QCT_NORMAL;
     cmd->fn = fn;
     cmd->enabled = true;
+    cmd->options = options;
     QTAILQ_INSERT_TAIL(&qmp_commands, cmd, node);
 }
 
scripts/qapi-commands.py +12 -2
index 0b4f0a0..e746333 100644
@@ -291,14 +291,24 @@ out:
 
     return ret
 
+def option_is_enabled(opt, val, cmd):
+    if opt in cmd and cmd[opt] == val:
+        return True
+    return False
+
 def gen_registry(commands):
     registry=""
     push_indent()
     for cmd in commands:
+        options = 'QCO_NO_OPTIONS'
+        if option_is_enabled('success-response', 'no', cmd):
+            options = 'QCO_NO_SUCCESS_RESP'
+
         registry += mcgen('''
-qmp_register_command("%(name)s", qmp_marshal_input_%(c_name)s);
+qmp_register_command("%(name)s", qmp_marshal_input_%(c_name)s, %(opts)s);
 ''',
-                     name=cmd['command'], c_name=c_fun(cmd['command']))
+                     name=cmd['command'], c_name=c_fun(cmd['command']),
+                     opts=options)
     pop_indent()
     ret = mcgen('''
 static void qmp_init_marshal(void)
Signature · 1 line
1.7.9.2.384.g4a92a
Reviewed-by on v1 1/6
#2 lore raw

Re: [Qemu-devel] [PATCH 1/6] qapi: add support for command options

Quoted 98 lines · Luiz Capitulino

Options allow for changes in commands behavior. This commit introduces the QCO_NO_SUCCESS_RESP option, which causes a command to not emit a success response.

This is needed by commands such as qemu-ga's guest-shutdown, which may not be able to complete before the VM vanishes. In this case, it's useful and simpler not to bother sending a success response.

---
 qapi/qmp-core.h          |   10 +++++++++-
 qapi/qmp-dispatch.c      |    8 ++++++--
 qapi/qmp-registry.c      |    4 +++-
 scripts/qapi-commands.py |   14 ++++++++++++--
 4 files changed, 30 insertions(+), 6 deletions(-)
qapi/qmp-core.h +9 -1
index 431ddbb..b0f64ba 100644
@@ -25,16 +25,24 @@ typedef enum QmpCommandType
     QCT_NORMAL,
 } QmpCommandType;
 
+typedef enum QmpCommandOptions
+{
+    QCO_NO_OPTIONS = 0x0,
+    QCO_NO_SUCCESS_RESP = 0x1,
+} QmpCommandOptions;
+
 typedef struct QmpCommand
 {
     const char *name;
     QmpCommandType type;
     QmpCommandFunc *fn;
+    QmpCommandOptions options;
     QTAILQ_ENTRY(QmpCommand) node;
     bool enabled;
 } QmpCommand;
 
-void qmp_register_command(const char *name, QmpCommandFunc *fn);
+void qmp_register_command(const char *name, QmpCommandFunc *fn,
+                          QmpCommandOptions options);
 QmpCommand *qmp_find_command(const char *name);
 QObject *qmp_dispatch(QObject *request);
 void qmp_disable_command(const char *name);
qapi/qmp-dispatch.c +6 -2
index 43f640a..122c1a2 100644
@@ -94,8 +94,12 @@ static QObject *do_qmp_dispatch(QObject *request, Error **errp)
     switch (cmd->type) {
     case QCT_NORMAL:
         cmd->fn(args, &ret, errp);
-        if (!error_is_set(errp) && ret == NULL) {
-            ret = QOBJECT(qdict_new());
+        if (!error_is_set(errp)) {
+            if (cmd->options & QCO_NO_SUCCESS_RESP) {
+                g_assert(!ret);
+            } else if (!ret) {
+                ret = QOBJECT(qdict_new());
+            }
         }
         break;
     }
qapi/qmp-registry.c +3 -1
index 43d5cde..5414613 100644
@@ -17,7 +17,8 @@
 static QTAILQ_HEAD(QmpCommandList, QmpCommand) qmp_commands =
     QTAILQ_HEAD_INITIALIZER(qmp_commands);
 
-void qmp_register_command(const char *name, QmpCommandFunc *fn)
+void qmp_register_command(const char *name, QmpCommandFunc *fn,
+                          QmpCommandOptions options)
 {
     QmpCommand *cmd = g_malloc0(sizeof(*cmd));
 
@@ -25,6 +26,7 @@ void qmp_register_command(const char *name, QmpCommandFunc *fn)
     cmd->type = QCT_NORMAL;
     cmd->fn = fn;
     cmd->enabled = true;
+    cmd->options = options;
     QTAILQ_INSERT_TAIL(&qmp_commands, cmd, node);
 }
 
scripts/qapi-commands.py +3 -0
index 0b4f0a0..e746333 100644
@@ -291,14 +291,24 @@ out:
 
     return ret
 
+def option_is_enabled(opt, val, cmd):
+    if opt in cmd and cmd[opt] == val:
+        return True

scripts/qapi-commands.py out: · line 306

Quoted 10 lines
scripts/qapi-commands.py +6 -0
+    return False
+
 def gen_registry(commands):
     registry=""
     push_indent()
     for cmd in commands:
+        options = 'QCO_NO_OPTIONS'
+        if option_is_enabled('success-response', 'no', cmd):
+            options = 'QCO_NO_SUCCESS_RESP'
+

Hate to hold things up for a nit, but the naming of option_is_enabled() is just plain wrong here. option_is_enabled() is returning true for a case where we're actually checking for an option being disabled. I'm guessing it looks this way because we're trying to determine if the internal QCO_NO_SUCCESS_RESP option is enabled, but option_is_enabled() only has knowledge of the QAPI directive so I think that's backwards.

option_value_matches() would indicate the purpose better, or option_is_disabled() and then moving the "no"/"false"/"disabled" matching into it.

Patch looks good otherwise.

Quoted 13 lines
scripts/qapi-commands.py +3 -2
         registry += mcgen('''
-qmp_register_command("%(name)s", qmp_marshal_input_%(c_name)s);
+qmp_register_command("%(name)s", qmp_marshal_input_%(c_name)s, %(opts)s);
 ''',
-                     name=cmd['command'], c_name=c_fun(cmd['command']))
+                     name=cmd['command'], c_name=c_fun(cmd['command']),
+                     opts=options)
     pop_indent()
     ret = mcgen('''
 static void qmp_init_marshal(void)
Signature · 1 line
1.7.9.2.384.g4a92a
#3 lore raw

Re: [Qemu-devel] [PATCH 1/6] qapi: add support for command options

Quoted 108 lines · On Mon, 7 May 2012 11:05:36 -0500 Michael Roth <[email protected]>…
Quoted 107 lines · Luiz Capitulino

Options allow for changes in commands behavior. This commit introduces the QCO_NO_SUCCESS_RESP option, which causes a command to not emit a success response.

This is needed by commands such as qemu-ga's guest-shutdown, which may not be able to complete before the VM vanishes. In this case, it's useful and simpler not to bother sending a success response.

---
 qapi/qmp-core.h          |   10 +++++++++-
 qapi/qmp-dispatch.c      |    8 ++++++--
 qapi/qmp-registry.c      |    4 +++-
 scripts/qapi-commands.py |   14 ++++++++++++--
 4 files changed, 30 insertions(+), 6 deletions(-)
qapi/qmp-core.h +9 -1
index 431ddbb..b0f64ba 100644
@@ -25,16 +25,24 @@ typedef enum QmpCommandType
     QCT_NORMAL,
 } QmpCommandType;
 
+typedef enum QmpCommandOptions
+{
+    QCO_NO_OPTIONS = 0x0,
+    QCO_NO_SUCCESS_RESP = 0x1,
+} QmpCommandOptions;
+
 typedef struct QmpCommand
 {
     const char *name;
     QmpCommandType type;
     QmpCommandFunc *fn;
+    QmpCommandOptions options;
     QTAILQ_ENTRY(QmpCommand) node;
     bool enabled;
 } QmpCommand;
 
-void qmp_register_command(const char *name, QmpCommandFunc *fn);
+void qmp_register_command(const char *name, QmpCommandFunc *fn,
+                          QmpCommandOptions options);
 QmpCommand *qmp_find_command(const char *name);
 QObject *qmp_dispatch(QObject *request);
 void qmp_disable_command(const char *name);
qapi/qmp-dispatch.c +6 -2
index 43f640a..122c1a2 100644
@@ -94,8 +94,12 @@ static QObject *do_qmp_dispatch(QObject *request, Error **errp)
     switch (cmd->type) {
     case QCT_NORMAL:
         cmd->fn(args, &ret, errp);
-        if (!error_is_set(errp) && ret == NULL) {
-            ret = QOBJECT(qdict_new());
+        if (!error_is_set(errp)) {
+            if (cmd->options & QCO_NO_SUCCESS_RESP) {
+                g_assert(!ret);
+            } else if (!ret) {
+                ret = QOBJECT(qdict_new());
+            }
         }
         break;
     }
qapi/qmp-registry.c +3 -1
index 43d5cde..5414613 100644
@@ -17,7 +17,8 @@
 static QTAILQ_HEAD(QmpCommandList, QmpCommand) qmp_commands =
     QTAILQ_HEAD_INITIALIZER(qmp_commands);
 
-void qmp_register_command(const char *name, QmpCommandFunc *fn)
+void qmp_register_command(const char *name, QmpCommandFunc *fn,
+                          QmpCommandOptions options)
 {
     QmpCommand *cmd = g_malloc0(sizeof(*cmd));
 
@@ -25,6 +26,7 @@ void qmp_register_command(const char *name, QmpCommandFunc *fn)
     cmd->type = QCT_NORMAL;
     cmd->fn = fn;
     cmd->enabled = true;
+    cmd->options = options;
     QTAILQ_INSERT_TAIL(&qmp_commands, cmd, node);
 }
 
scripts/qapi-commands.py +8 -0
index 0b4f0a0..e746333 100644
@@ -291,14 +291,24 @@ out:
 
     return ret
 
+def option_is_enabled(opt, val, cmd):
+    if opt in cmd and cmd[opt] == val:
+        return True
+    return False
+
 def gen_registry(commands):
     registry=""
     push_indent()
     for cmd in commands:
+        options = 'QCO_NO_OPTIONS'
+        if option_is_enabled('success-response', 'no', cmd):
+            options = 'QCO_NO_SUCCESS_RESP'
Quoted 8 lines

scripts/qapi-commands.py out: · line 306

Quoted 1 line
scripts/qapi-commands.py +1 -0
+

Hate to hold things up for a nit, but the naming of option_is_enabled() is just plain wrong here. option_is_enabled() is returning true for a case where we're actually checking for an option being disabled. I'm guessing it looks this way because we're trying to determine if the internal QCO_NO_SUCCESS_RESP option is enabled, but option_is_enabled() only has knowledge of the QAPI directive so I think that's backwards.

Agreed.

Quoted 3 lines

option_value_matches() would indicate the purpose better, or option_is_disabled() and then moving the "no"/"false"/"disabled" matching into it.

I like option_value_matches(), will address this and the other comments and resend.

Btw, I expect this series and my next one (which makes guest-shutdown and guest-suspend-* synchronous) to go through your tree. Also note that they're 1.1 material.

#4 lore raw

PATCH 2/6 qemu-ga: don't warn on no command return

In reply to Luiz Capitulino

This is a valid condition when a command chooses to not emit a success response.

---
 qemu-ga.c |    2 --
 1 file changed, 2 deletions(-)
qemu-ga.c +0 -2
index 216be39..3547119 100644
@@ -488,8 +488,6 @@ static void process_command(GAState *s, QDict *req)
             g_warning("error sending response: %s", strerror(ret));
         }
         qobject_decref(rsp);
-    } else {
-        g_warning("error getting response");
     }
 }
 
Signature · 1 line
1.7.9.2.384.g4a92a
Reviewed-by on v1 2/6
#5 lore raw

Re: [Qemu-devel] [PATCH 2/6] qemu-ga: don't warn on no command return

Quoted 4 lines · Luiz Capitulino

This is a valid condition when a command chooses to not emit a success response.

Quoted 20 lines
---
 qemu-ga.c |    2 --
 1 file changed, 2 deletions(-)
qemu-ga.c +0 -2
index 216be39..3547119 100644
@@ -488,8 +488,6 @@ static void process_command(GAState *s, QDict *req)
             g_warning("error sending response: %s", strerror(ret));
         }
         qobject_decref(rsp);
-    } else {
-        g_warning("error getting response");
     }
 }
 
Signature · 1 line
1.7.9.2.384.g4a92a
#6 lore raw

PATCH 3/6 qemu-ga: guest-shutdown: don't emit a success response

In reply to Luiz Capitulino

Today, qemu-ga may not be able to emit a success response when guest-shutdown completes. This happens because the VM may vanish before qemu-ga is able to emit a response.

This semantic is a bit confusing, as it's not clear for clients if they should wait for a response or how they should check for success.

This commit solves that problem by changing guest-shutdown to never emit a success response and suggests in the documentation what clients could do to check for success.

---
 qapi-schema-guest.json |    6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
qapi-schema-guest.json +4 -2
index d7a073e..0aa9f91 100644
@@ -131,11 +131,13 @@
 #
 # @mode: #optional "halt", "powerdown" (default), or "reboot"
 #
-# Returns: Nothing on success
+# Returns: This command does NOT return a response on success. Success
+# condition is indicated by the VM exiting with a zero exit status.
 #
 # Since: 0.15.0
 ##
-{ 'command': 'guest-shutdown', 'data': { '*mode': 'str' } }
+{ 'command': 'guest-shutdown', 'data': { '*mode': 'str' },
+  'success-response': 'no' }
 
 ##
 # @guest-file-open:
Signature · 1 line
1.7.9.2.384.g4a92a
Reviewed-by on v1 3/6
#7 lore raw

Re: [Qemu-devel] [PATCH 3/6] qemu-ga: guest-shutdown: don't emit a success response

Quoted 21 lines · Luiz Capitulino

Today, qemu-ga may not be able to emit a success response when guest-shutdown completes. This happens because the VM may vanish before qemu-ga is able to emit a response.

This semantic is a bit confusing, as it's not clear for clients if they should wait for a response or how they should check for success.

This commit solves that problem by changing guest-shutdown to never emit a success response and suggests in the documentation what clients could do to check for success.

---
 qapi-schema-guest.json |    6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
qapi-schema-guest.json +0 -0
index d7a073e..0aa9f91 100644

qapi-schema-guest.json line 135

Quoted 6 lines
qapi-schema-guest.json +2 -1
@@ -131,11 +131,13 @@
 #
 # @mode: #optional "halt", "powerdown" (default), or "reboot"
 #
-# Returns: Nothing on success
+# Returns: This command does NOT return a response on success. Success
+# condition is indicated by the VM exiting with a zero exit status.

Would also include something like:

'or, when running with --no-shutdown, by running the query-status QMP command to confirm the status/RunState is "shutdown"'

Quoted 12 lines
qapi-schema-guest.json +2 -1
 #
 # Since: 0.15.0
 ##
-{ 'command': 'guest-shutdown', 'data': { '*mode': 'str' } }
+{ 'command': 'guest-shutdown', 'data': { '*mode': 'str' },
+  'success-response': 'no' }
 
 ##
 # @guest-file-open:
Signature · 1 line
1.7.9.2.384.g4a92a
#8 lore raw

PATCH 4/6 qemu-ga: guest-suspend-disk: don't emit a success response

In reply to Luiz Capitulino

Today, qemu-ga may not be able to emit a success response when guest-suspend-disk completes. This happens because the VM may vanish before qemu-ga is able to emit a response.

This semantic is a bit confusing, as it's not clear for clients if they should wait for a response or how they should check for success.

This commit solves that problem by changing guest-suspend-disk to never emit a success response and suggests in the documentation what clients could do to check for success.

---
 qapi-schema-guest.json |   14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)
qapi-schema-guest.json +8 -6
index 0aa9f91..8ea7805 100644
@@ -361,17 +361,19 @@
 # For the best results it's strongly recommended to have the pm-utils
 # package installed in the guest.
 #
-# Returns: nothing on success
+# Returns: This command does NOT return a response on success. There's a
+# high chance the command succeeded if the VM exits with a zero exit status,
+# but the VM could also exit due to other reasons.
+#
+# The following errors may be returned:
 #          If suspend to disk is not supported, Unsupported
 #
-# Notes: o This is an asynchronous request. There's no guarantee a response
-#          will be sent
-#        o It's strongly recommended to issue the guest-sync command before
-#          sending commands when the guest resumes
+# Notes: It's strongly recommended to issue the guest-sync command before
+#        sending commands when the guest resumes
 #
 # Since: 1.1
 ##
-{ 'command': 'guest-suspend-disk' }
+{ 'command': 'guest-suspend-disk', 'success-response': 'no' }
 
 ##
 # @guest-suspend-ram
Signature · 1 line
1.7.9.2.384.g4a92a
#9 lore raw

Re: [Qemu-devel] [PATCH 4/6] qemu-ga: guest-suspend-disk: don't emit a success response

Quoted 21 lines · Luiz Capitulino

Today, qemu-ga may not be able to emit a success response when guest-suspend-disk completes. This happens because the VM may vanish before qemu-ga is able to emit a response.

This semantic is a bit confusing, as it's not clear for clients if they should wait for a response or how they should check for success.

This commit solves that problem by changing guest-suspend-disk to never emit a success response and suggests in the documentation what clients could do to check for success.

---
 qapi-schema-guest.json |   14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)
qapi-schema-guest.json +0 -0
index 0aa9f91..8ea7805 100644

qapi-schema-guest.json line 366

Quoted 7 lines
qapi-schema-guest.json +3 -1
@@ -361,17 +361,19 @@
 # For the best results it's strongly recommended to have the pm-utils
 # package installed in the guest.
 #
-# Returns: nothing on success
+# Returns: This command does NOT return a response on success. There's a
+# high chance the command succeeded if the VM exits with a zero exit status,
+# but the VM could also exit due to other reasons.

Similar suggestion as previous patch (adding a note about query-status)

Quoted 21 lines
qapi-schema-guest.json +5 -5
+#
+# The following errors may be returned:
 #          If suspend to disk is not supported, Unsupported
 #
-# Notes: o This is an asynchronous request. There's no guarantee a response
-#          will be sent
-#        o It's strongly recommended to issue the guest-sync command before
-#          sending commands when the guest resumes
+# Notes: It's strongly recommended to issue the guest-sync command before
+#        sending commands when the guest resumes
 #
 # Since: 1.1
 ##
-{ 'command': 'guest-suspend-disk' }
+{ 'command': 'guest-suspend-disk', 'success-response': 'no' }
 
 ##
 # @guest-suspend-ram
Signature · 1 line
1.7.9.2.384.g4a92a
#10 lore raw

PATCH 5/6 qemu-ga: guest-suspend-ram: don't emit a success response

In reply to Luiz Capitulino

Today, qemu-ga may not be able to emit a success response when guest-suspend-ram completes. This happens because the VM may suspend before qemu-ga is able to emit a response.

This semantic is a bit confusing, as it's not clear for clients if they should wait for a response or how they should check for success.

This commit solves that problem by changing guest-suspend-ram to never emit a success response and suggests in the documentation what clients should do to check for success.

---
 qapi-schema-guest.json |   15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)
qapi-schema-guest.json +9 -6
index 8ea7805..f5f6f26 100644
@@ -391,17 +391,20 @@
 # command.  Thus, it's *required* to query QEMU for the presence of the
 # 'system_wakeup' command before issuing guest-suspend-ram.
 #
-# Returns: nothing on success
+# Returns: This command does NOT return a response on success. There are
+# two options to check for success:
+#   1. Wait for the SUSPEND QMP event from QEMU
+#   2. Check for the suspended RunState in QEMU, by issuing query-status
+#
+# The following errors may be returned:
 #          If suspend to ram is not supported, Unsupported
 #
-# Notes: o This is an asynchronous request. There's no guarantee a response
-#          will be sent
-#        o It's strongly recommended to issue the guest-sync command before
-#          sending commands when the guest resumes
+# Notes: It's strongly recommended to issue the guest-sync command before
+#        sending commands when the guest resumes
 #
 # Since: 1.1
 ##
-{ 'command': 'guest-suspend-ram' }
+{ 'command': 'guest-suspend-ram', 'success-response': 'no' }
 
 ##
 # @guest-suspend-hybrid
Signature · 1 line
1.7.9.2.384.g4a92a
#11 lore raw

PATCH 6/6 qemu-ga: guest-suspend-hybrid: don't emit a success response

In reply to Luiz Capitulino

Today, qemu-ga may not be able to emit a success response when guest-suspend-hybrid completes. This happens because the VM may suspend before qemu-ga is able to emit a response.

This semantic is a bit confusing, as it's not clear for clients if they should wait for a response or how they should check for success.

This commit solves that problem by changing guest-suspend-hybrid to never emit a success response and suggests in the documentation what clients should do to check for success.

---
 qapi-schema-guest.json |   15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)
qapi-schema-guest.json +9 -6
index f5f6f26..b3ccd66 100644
@@ -417,17 +417,20 @@
 # command.  Thus, it's *required* to query QEMU for the presence of the
 # 'system_wakeup' command before issuing guest-suspend-hybrid.
 #
-# Returns: nothing on success
+# Returns: This command does NOT return a response on success. There are
+# two options to check for success:
+#   1. Wait for the SUSPEND QMP event from QEMU
+#   2. Check for the suspended RunState in QEMU, by issuing query-status
+#
+# The following errors may be returned:
 #          If hybrid suspend is not supported, Unsupported
 #
-# Notes: o This is an asynchronous request. There's no guarantee a response
-#          will be sent
-#        o It's strongly recommended to issue the guest-sync command before
-#          sending commands when the guest resumes
+# Notes: It's strongly recommended to issue the guest-sync command before
+#        sending commands when the guest resumes
 #
 # Since: 1.1
 ##
-{ 'command': 'guest-suspend-hybrid' }
+{ 'command': 'guest-suspend-hybrid', 'success-response': 'no' }
 
 ##
 # @GuestIpAddressType:
Signature · 1 line
1.7.9.2.384.g4a92a