]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemu_monitor: Introduce handler for 'query-current-machine' command
authorMichal Privoznik <mprivozn@redhat.com>
Wed, 24 Apr 2019 21:16:28 +0000 (18:16 -0300)
committerMichal Privoznik <mprivozn@redhat.com>
Thu, 25 Apr 2019 09:43:53 +0000 (11:43 +0200)
So far, this command returns a structure with only one member:
'wakeup-suspend-support'. But that's okay. It's what we are after
anyway.

Based-on-work-of: Daniel Henrique Barboza <danielhb413@gmail.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
src/qemu/qemu_monitor.c
src/qemu/qemu_monitor.h
src/qemu/qemu_monitor_json.c
src/qemu/qemu_monitor_json.h

index babcbde8783e4d4e08149b93cafc0101e27cfa4e..e1fcbac13fe77997e68ab9e836219919aeb73cd7 100644 (file)
@@ -4472,3 +4472,13 @@ qemuMonitorGetPRManagerInfo(qemuMonitorPtr mon,
     virHashFree(info);
     return ret;
 }
+
+
+int
+qemuMonitorGetCurrentMachineInfo(qemuMonitorPtr mon,
+                                 qemuMonitorCurrentMachineInfoPtr info)
+{
+    QEMU_CHECK_MONITOR(mon);
+
+    return qemuMonitorJSONGetCurrentMachineInfo(mon, info);
+}
index caf62af5e282d2606e8c40a66dc8988af92e88e4..9242d3740785487e93cadb038cfe73cf0d19a9a1 100644 (file)
@@ -1221,4 +1221,13 @@ struct _qemuMonitorPRManagerInfo {
 int qemuMonitorGetPRManagerInfo(qemuMonitorPtr mon,
                                 virHashTablePtr *retinfo);
 
+typedef struct  _qemuMonitorCurrentMachineInfo qemuMonitorCurrentMachineInfo;
+typedef qemuMonitorCurrentMachineInfo *qemuMonitorCurrentMachineInfoPtr;
+struct _qemuMonitorCurrentMachineInfo {
+    bool wakeupSuspendSupport;
+};
+
+int qemuMonitorGetCurrentMachineInfo(qemuMonitorPtr mon,
+                                     qemuMonitorCurrentMachineInfoPtr info);
+
 #endif /* LIBVIRT_QEMU_MONITOR_H */
index e7d063a5a85072cc0d5a83feb85b301b125ed0e3..908967f46c64dad3d3c69a9e39f2e2aaf7059566 100644 (file)
@@ -8459,3 +8459,53 @@ qemuMonitorJSONGetPRManagerInfo(qemuMonitorPtr mon,
     return ret;
 
 }
+
+
+static int
+qemuMonitorJSONExtractCurrentMachineInfo(virJSONValuePtr reply,
+                                         qemuMonitorCurrentMachineInfoPtr info)
+{
+    virJSONValuePtr data;
+
+    data = virJSONValueObjectGetObject(reply, "return");
+    if (!data)
+        goto malformed;
+
+    if (virJSONValueObjectGetBoolean(data, "wakeup-suspend-support",
+                                     &info->wakeupSuspendSupport) < 0)
+        goto malformed;
+
+    return 0;
+
+ malformed:
+    virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+                   _("malformed qemu-current-machine reply"));
+    return -1;
+}
+
+
+int
+qemuMonitorJSONGetCurrentMachineInfo(qemuMonitorPtr mon,
+                                     qemuMonitorCurrentMachineInfoPtr info)
+{
+    int ret = -1;
+    virJSONValuePtr cmd;
+    virJSONValuePtr reply = NULL;
+
+    if (!(cmd = qemuMonitorJSONMakeCommand("query-current-machine",
+                                           NULL)))
+        return -1;
+
+    if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
+        goto cleanup;
+
+    if (qemuMonitorJSONCheckReply(cmd, reply, VIR_JSON_TYPE_OBJECT) < 0)
+        goto cleanup;
+
+    ret = qemuMonitorJSONExtractCurrentMachineInfo(reply, info);
+
+ cleanup:
+    virJSONValueFree(cmd);
+    virJSONValueFree(reply);
+    return ret;
+}
index c10513da152535df8cf5ad0476b131af5f6e9401..746b7072ca87c96e40360d26d63d5e8ddd5fb1a2 100644 (file)
@@ -576,4 +576,9 @@ int qemuMonitorJSONGetPRManagerInfo(qemuMonitorPtr mon,
                                     virHashTablePtr info)
     ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
 
+int
+qemuMonitorJSONGetCurrentMachineInfo(qemuMonitorPtr mon,
+                                     qemuMonitorCurrentMachineInfoPtr info)
+    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
+
 #endif /* LIBVIRT_QEMU_MONITOR_JSON_H */