]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemu: Introduce qemuMonitorGetRTCTime
authorMichal Privoznik <mprivozn@redhat.com>
Fri, 29 Apr 2016 14:01:47 +0000 (16:01 +0200)
committerMichal Privoznik <mprivozn@redhat.com>
Tue, 3 May 2016 09:44:13 +0000 (11:44 +0200)
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 0170850c89eb59e0e8913c24f1778866db077c8b..1f402eeb571f706cac28aa6ad3780d38a6df8c57 100644 (file)
@@ -3726,3 +3726,14 @@ qemuMonitorMigrateStartPostCopy(qemuMonitorPtr mon)
 
     return qemuMonitorJSONMigrateStartPostCopy(mon);
 }
+
+int
+qemuMonitorGetRTCTime(qemuMonitorPtr mon,
+                      struct tm *tm)
+{
+    VIR_DEBUG("mon=%p", mon);
+
+    QEMU_CHECK_MONITOR_JSON(mon);
+
+    return qemuMonitorJSONGetRTCTime(mon, tm);
+}
index 871ebe0bb429a24390e394b9e4f279a9c020ec9b..4d8f21fc0bac4f6cbe17c69c9e5f6468188f6d9f 100644 (file)
@@ -933,4 +933,7 @@ int qemuMonitorMigrateIncoming(qemuMonitorPtr mon,
 
 int qemuMonitorMigrateStartPostCopy(qemuMonitorPtr mon);
 
+int qemuMonitorGetRTCTime(qemuMonitorPtr mon,
+                          struct tm *tm);
+
 #endif /* QEMU_MONITOR_H */
index e0dbda12a10af8437b07d3ed95eed2acab00a338..a48a2639652331967ced93b3e871fff09ca771ab 100644 (file)
@@ -6905,3 +6905,44 @@ qemuMonitorJSONMigrateStartPostCopy(qemuMonitorPtr mon)
     virJSONValueFree(reply);
     return ret;
 }
+
+int
+qemuMonitorJSONGetRTCTime(qemuMonitorPtr mon,
+                          struct tm *tm)
+{
+    int ret = -1;
+    virJSONValuePtr cmd;
+    virJSONValuePtr reply = NULL;
+    virJSONValuePtr data;
+
+    if (!(cmd = qemuMonitorJSONMakeCommand("qom-get",
+                                           "s:path", "/machine",
+                                           "s:property", "rtc-time",
+                                           NULL)))
+        return -1;
+
+    if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
+        goto cleanup;
+
+    if (qemuMonitorJSONCheckError(cmd, reply) < 0)
+        goto cleanup;
+
+    data = virJSONValueObjectGet(reply, "return");
+
+    if (virJSONValueObjectGetNumberInt(data, "tm_year", &tm->tm_year) < 0 ||
+        virJSONValueObjectGetNumberInt(data, "tm_mon", &tm->tm_mon) < 0 ||
+        virJSONValueObjectGetNumberInt(data, "tm_mday", &tm->tm_mday) < 0 ||
+        virJSONValueObjectGetNumberInt(data, "tm_hour", &tm->tm_hour) < 0 ||
+        virJSONValueObjectGetNumberInt(data, "tm_min", &tm->tm_min) < 0 ||
+        virJSONValueObjectGetNumberInt(data, "tm_sec", &tm->tm_sec) < 0) {
+        virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+                       _("qemu returned malformed time"));
+        goto cleanup;
+    }
+
+    ret = 0;
+ cleanup:
+    virJSONValueFree(cmd);
+    virJSONValueFree(reply);
+    return ret;
+}
index 1587a036f629955fab84d00249299c41c6064186..b7aff73eb319d9edc41669a512292827ec9878d8 100644 (file)
@@ -483,4 +483,7 @@ int qemuMonitorJSONMigrateIncoming(qemuMonitorPtr mon,
 int qemuMonitorJSONMigrateStartPostCopy(qemuMonitorPtr mon)
     ATTRIBUTE_NONNULL(1);
 
+int qemuMonitorJSONGetRTCTime(qemuMonitorPtr mon,
+                              struct tm *tm)
+    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
 #endif /* QEMU_MONITOR_JSON_H */