From patchwork Tue Jul 24 17:20:52 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 172983 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 7A38A2C007A for ; Wed, 25 Jul 2012 03:38:47 +1000 (EST) Received: from localhost ([::1]:39712 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Stioq-0005YV-B6 for incoming@patchwork.ozlabs.org; Tue, 24 Jul 2012 13:22:48 -0400 Received: from eggs.gnu.org ([208.118.235.92]:49811) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1StioO-00058H-C5 for qemu-devel@nongnu.org; Tue, 24 Jul 2012 13:22:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1StioN-0000b7-5m for qemu-devel@nongnu.org; Tue, 24 Jul 2012 13:22:20 -0400 Received: from mail-pb0-f45.google.com ([209.85.160.45]:53639) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1StioM-0000Fl-W1 for qemu-devel@nongnu.org; Tue, 24 Jul 2012 13:22:19 -0400 Received: by mail-pb0-f45.google.com with SMTP id ro12so12773613pbb.4 for ; Tue, 24 Jul 2012 10:22:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references; bh=fJbHlGLd37hqpYEFbb/9gXoFAGgebESx67qgPkPXMkQ=; b=k383buuASMEOE8fn+BIO4yELHgtKBIN7LX8TnhympYaEe2SaO48SX6+lwHM3NSdQ+Y q2/gEynNMfALR0F/DuhNEJHtcSHpAqQLeuwBBbdtwKXOW7vsWeVALZMP2y9zE/QEMuVn yBR0B+hQXeFVp0XiAXQ6rOxQgQ2BlUf9ZY0j8fsNjR8AK6K2CFJXQ2FbF9ufS0gNUIvp J+cSih11XqW5c24NbocU13Qxyyj+bqujfnqmUJmzt4+HswuvHyXByZ/MVQ6/bSExgKmG JfkLl5esqCyQYAp/vEIBM3jsLKG01nosff5iO0d+kppl9vnrgI1PL1+N67ZaMc6QXleK cfkg== Received: by 10.68.231.132 with SMTP id tg4mr46869326pbc.159.1343150538690; Tue, 24 Jul 2012 10:22:18 -0700 (PDT) Received: from loki.morrigu.org (cpe-72-179-62-111.austin.res.rr.com. [72.179.62.111]) by mx.google.com with ESMTPS id nh8sm12522083pbc.60.2012.07.24.10.22.15 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 24 Jul 2012 10:22:17 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Tue, 24 Jul 2012 12:20:52 -0500 Message-Id: <1343150454-4677-21-git-send-email-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1343150454-4677-1-git-send-email-mdroth@linux.vnet.ibm.com> References: <1343150454-4677-1-git-send-email-mdroth@linux.vnet.ibm.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.85.160.45 Cc: aliguori@us.ibm.com, quintela@redhat.com, owasserm@redhat.com, yamahata@valinux.co.jp, pbonzini@redhat.com, akong@redhat.com, afaerber@suse.de Subject: [Qemu-devel] [PATCH 20/22] qemu-timer: add visit_type_QEMUTimer 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 Signed-off-by: Michael Roth --- Makefile | 3 ++- qemu-timer.c | 25 +++++++++++++++++++++++++ qemu-timer.h | 4 ++++ 3 files changed, 31 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 0711f14..c545ebd 100644 --- a/Makefile +++ b/Makefile @@ -157,7 +157,8 @@ qemu-img.o: qemu-img-cmds.h tools-obj-y = $(oslib-obj-y) $(trace-obj-y) qemu-tool.o qemu-timer.o \ qemu-timer-common.o main-loop.o notify.o \ - iohandler.o cutils.o iov.o async.o + iohandler.o cutils.o iov.o async.o \ + $(qapi-obj-y) $(qobject-obj-y) tools-obj-$(CONFIG_POSIX) += compatfd.o qemu-img$(EXESUF): qemu-img.o $(tools-obj-y) $(block-obj-y) diff --git a/qemu-timer.c b/qemu-timer.c index de98977..8a67620 100644 --- a/qemu-timer.c +++ b/qemu-timer.c @@ -30,6 +30,7 @@ #include "hw/hw.h" #include "qemu-timer.h" +#include "qapi/qapi-visit-core.h" #ifdef _WIN32 #include @@ -61,6 +62,30 @@ struct QEMUTimer { int scale; }; +void visit_type_QEMUTimer(Visitor *v, QEMUTimer **obj, const char *name, + Error **errp) +{ + int64_t expire_time, expire_time_cpy; + if (!obj || !*obj) { + error_set(errp, QERR_INVALID_PARAMETER_VALUE, name ? name : NULL, + "non-NULL QEMUTimer"); + return; + } + expire_time = expire_time_cpy = qemu_timer_expire_time_ns(*obj); + visit_start_struct(v, NULL, "QEMUTimer", name, 0, errp); + visit_type_int64(v, &expire_time, "expire_time", errp); + visit_end_struct(v, errp); + + /* if we're modifying a QEMUTimer, re-arm/delete accordingly */ + if (expire_time != expire_time_cpy) { + if (expire_time != -1) { + qemu_mod_timer_ns(*obj, expire_time); + } else { + qemu_del_timer(*obj); + } + } +} + struct qemu_alarm_timer { char const *name; int (*start)(struct qemu_alarm_timer *t); diff --git a/qemu-timer.h b/qemu-timer.h index f8af595..1feabd7 100644 --- a/qemu-timer.h +++ b/qemu-timer.h @@ -4,6 +4,7 @@ #include "qemu-common.h" #include "main-loop.h" #include "notify.h" +#include "qapi/qapi-visit-core.h" #ifdef __FreeBSD__ #include @@ -67,6 +68,9 @@ int64_t cpu_get_ticks(void); void cpu_enable_ticks(void); void cpu_disable_ticks(void); +void visit_type_QEMUTimer(Visitor *v, QEMUTimer **obj, const char *name, + Error **errp); + static inline QEMUTimer *qemu_new_timer_ns(QEMUClock *clock, QEMUTimerCB *cb, void *opaque) {