From patchwork Tue Mar 12 00:53:16 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 226732 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 266942C02B4 for ; Tue, 12 Mar 2013 11:56:16 +1100 (EST) Received: from localhost ([::1]:34600 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UFDVm-0005YK-8d for incoming@patchwork.ozlabs.org; Mon, 11 Mar 2013 20:56:14 -0400 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) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:sender:from:to:cc:subject:date:message-id:x-mailer :in-reply-to:references; bh=aJGOzrCHbuMMXYM2vk0H2SmmCngDWOx0hKIy20YiPd4=; b=bwZBpN+KMfQMJIxlnhyePk8CPZFQv2Say9ybkHXdG3+99Cjscbmd/unUNmc6z/mKL4 c/QXztyU6Iv1xwwQ9GN9jYSce0EE4YpCQYUqmIQJL4DnSsTa9vNOX3ZRWK6vKghCaHj0 ukL2HK7Y/jFO5vWhV9ef1Rqc7wulHlPv9uV92pYLm6JaaX7D5V1pJaN6oucYKTsFxQjn JQwXowSoyYtCzJ8W0U8V2jsjYRqTVo0cV+ogIxjMaY830MUQH71+TYLc+j8NmHzegiKT UgRaJmhOTPDBPcJ645Sf3kaK1IewLFuUVAamX5z77rGYKERgu77NJl7eI2vih/+FmOsf 9oOw== X-Received: by 10.182.93.193 with SMTP id cw1mr10656049obb.93.1363049726223; Mon, 11 Mar 2013 17:55:26 -0700 (PDT) Received: from localhost ([32.97.110.51]) by mx.google.com with ESMTPS id x5sm20106039oeb.6.2013.03.11.17.55.25 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Mon, 11 Mar 2013 17:55:25 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 11 Mar 2013 19:53:16 -0500 Message-Id: <1363049600-29456-6-git-send-email-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 1.7.9.5 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> X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2607:f8b0:4003:c01::233 Cc: aliguori@us.ibm.com, lersek@redhat.com, lilei@linux.vnet.ibm.com, stefanha@redhat.com Subject: [Qemu-devel] [PATCH 5/9] qga: add guest-get-time command X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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.