From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:42751) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UFDV2-0005Qt-QX for qemu-devel@nongnu.org; Mon, 11 Mar 2013 20:55:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UFDV1-0000ai-0B for qemu-devel@nongnu.org; Mon, 11 Mar 2013 20:55:28 -0400 Received: from mail-ob0-x233.google.com ([2607:f8b0:4003:c01::233]:47579) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UFDV0-0000aZ-RR for qemu-devel@nongnu.org; Mon, 11 Mar 2013 20:55:26 -0400 Received: by mail-ob0-f179.google.com with SMTP id un3so3994245obb.10 for ; Mon, 11 Mar 2013 17:55:26 -0700 (PDT) Sender: fluxion From: Michael Roth Date: Mon, 11 Mar 2013 19:53:16 -0500 Message-Id: <1363049600-29456-6-git-send-email-mdroth@linux.vnet.ibm.com> In-Reply-To: <1363049600-29456-1-git-send-email-mdroth@linux.vnet.ibm.com> References: <1363049600-29456-1-git-send-email-mdroth@linux.vnet.ibm.com> Subject: [Qemu-devel] [PATCH 5/9] qga: add guest-get-time command List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: aliguori@us.ibm.com, lersek@redhat.com, lilei@linux.vnet.ibm.com, stefanha@redhat.com From: Lei Li Signed-off-by: Lei Li Reviewed-by: Eric Blake Reviewed-by: Michael Roth *added stub for w32 Signed-off-by: Michael Roth --- qga/commands-posix.c | 16 ++++++++++++++++ qga/commands-win32.c | 6 ++++++ qga/qapi-schema.json | 13 +++++++++++++ 3 files changed, 35 insertions(+) diff --git a/qga/commands-posix.c b/qga/commands-posix.c index 1c2aff3..c83d26d 100644 --- a/qga/commands-posix.c +++ b/qga/commands-posix.c @@ -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; diff --git a/qga/commands-win32.c b/qga/commands-win32.c index 7e8ecb3..3ebb856 100644 --- a/qga/commands-win32.c +++ b/qga/commands-win32.c @@ -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) { diff --git a/qga/qapi-schema.json b/qga/qapi-schema.json index d91d903..bb0f75e 100644 --- a/qga/qapi-schema.json +++ b/qga/qapi-schema.json @@ -83,6 +83,19 @@ { '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: # # Information about guest agent commands. -- 1.7.9.5