]> git.proxmox.com Git - qemu.git/commitdiff
qga: add guest-get-time command
authorLei Li <lilei@linux.vnet.ibm.com>
Tue, 5 Mar 2013 09:39:11 +0000 (17:39 +0800)
committerMichael Roth <mdroth@linux.vnet.ibm.com>
Mon, 11 Mar 2013 23:53:47 +0000 (18:53 -0500)
Signed-off-by: Lei Li <lilei@linux.vnet.ibm.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Michael Roth <mdroth@linux.vnet.ibm.com>
*added stub for w32

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
qga/commands-posix.c
qga/commands-win32.c
qga/qapi-schema.json

index 1c2aff356a041ec363e3c7bc666c250d245aabdc..c83d26d0a5b22c569e771e508be1af518ea4ea60 100644 (file)
@@ -119,6 +119,22 @@ void qmp_guest_shutdown(bool has_mode, const char *mode, Error **err)
     /* succeded */
 }
 
+int64_t qmp_guest_get_time(Error **errp)
+{
+   int ret;
+   qemu_timeval tq;
+   int64_t time_ns;
+
+   ret = qemu_gettimeofday(&tq);
+   if (ret < 0) {
+       error_setg_errno(errp, errno, "Failed to get time");
+       return -1;
+   }
+
+   time_ns = tq.tv_sec * 1000000000LL + tq.tv_usec * 1000;
+   return time_ns;
+}
+
 typedef struct GuestFileHandle {
     uint64_t id;
     FILE *fh;
index 7e8ecb3b40e84c95c612787181aad132b4235607..3ebb856beada1ebbf75401de6b0951ef6a995665 100644 (file)
@@ -278,6 +278,12 @@ GuestNetworkInterfaceList *qmp_guest_network_get_interfaces(Error **err)
     return NULL;
 }
 
+int64_t qmp_guest_get_time(Error **errp)
+{
+    error_set(errp, QERR_UNSUPPORTED);
+    return -1;
+}
+
 /* register init/cleanup routines for stateful command groups */
 void ga_command_state_init(GAState *s, GACommandState *cs)
 {
index d91d903256dc3465bcce639c8c4d1d114962d078..bb0f75ee5d90a509aacd5ceb5f2f7540344e00d5 100644 (file)
 ##
 { 'command': 'guest-ping' }
 
+##
+# @guest-get-time:
+#
+# Get the information about guest time relative to the Epoch
+# of 1970-01-01 in UTC.
+#
+# Returns: Time in nanoseconds.
+#
+# Since 1.5
+##
+{ 'command': 'guest-get-time',
+  'returns': 'int' }
+
 ##
 # @GuestAgentCommandInfo:
 #