From patchwork Tue Jun 5 01:00:08 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 162988 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 92B27B6F86 for ; Tue, 5 Jun 2012 13:53:50 +1000 (EST) Received: from localhost ([::1]:47687 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Sbi9Y-0003Hj-8b for incoming@patchwork.ozlabs.org; Mon, 04 Jun 2012 21:01:44 -0400 Received: from eggs.gnu.org ([208.118.235.92]:48307) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Sbi8h-0001KL-Md for qemu-devel@nongnu.org; Mon, 04 Jun 2012 21:00:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Sbi8d-0002rb-Ql for qemu-devel@nongnu.org; Mon, 04 Jun 2012 21:00:50 -0400 Received: from mail-pz0-f45.google.com ([209.85.210.45]:34174) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Sbi8d-0002oi-7e for qemu-devel@nongnu.org; Mon, 04 Jun 2012 21:00:47 -0400 Received: by mail-pz0-f45.google.com with SMTP id v2so7118187dad.4 for ; Mon, 04 Jun 2012 18:00:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references; bh=ZzilEeXszd49ksy3rwNysXVR8YGlU2tBRenP2XAgODU=; b=s752Li4T4X6vQWj4olM59Sj6UZgxf7oLuuWdQ3Y+UDZfoVWeE8mqU/+Kfc+A+zz9ki Cl2vyhAWswoWvMi0Vz7w1DLheZRsayrvM9GRihR1NQ6Q6UhAOVevR+tfEINIMtm+w5jd +fd5NcsW1ibw8N9Y4R36PzbaDYMGE0j8M5YqR4u9+ikTlCq3O4Q8O4OYgzEr4p1PJDd6 0tM5FxLtqZp7hiMPgv1YS5z0y5xc9Xby8GUCH4ujX1NPR06WiN8rblHx0yiCGXqLUqI3 mwgkd3xdH4tSSq9+xm4MZv4KQwwTSIWXpkEm2UIxaLRJtWzpeeiQ/vJhTc1apKN9D+ez fwOw== Received: by 10.68.203.66 with SMTP id ko2mr44757278pbc.84.1338858046255; Mon, 04 Jun 2012 18:00:46 -0700 (PDT) Received: from localhost.localdomain ([32.97.110.59]) by mx.google.com with ESMTPS id np8sm408059pbc.71.2012.06.04.18.00.44 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 04 Jun 2012 18:00:45 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 4 Jun 2012 20:00:08 -0500 Message-Id: <1338858018-17189-8-git-send-email-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1338858018-17189-1-git-send-email-mdroth@linux.vnet.ibm.com> References: <1338858018-17189-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.210.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 07/17] qapi: add open-coded visitors for QEMUTimer/struct tm types 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 These are common types that don't lend themselves to script-generated visitors and require special handling. These will be useful for device state serialization. Signed-off-by: Michael Roth --- qapi/misc-qapi-visit.c | 35 +++++++++++++++++++++++++++++++++++ qapi/qc.h | 7 +++++++ 2 files changed, 42 insertions(+), 0 deletions(-) create mode 100644 qapi/misc-qapi-visit.c diff --git a/qapi/misc-qapi-visit.c b/qapi/misc-qapi-visit.c new file mode 100644 index 0000000..fedc063 --- /dev/null +++ b/qapi/misc-qapi-visit.c @@ -0,0 +1,35 @@ +#include +#include "qapi-visit-core.h" +#include "qc.h" +#include "qemu-timer.h" + +void visit_type_tm(Visitor *v, struct tm *obj, const char *name, Error **errp) +{ + visit_start_struct(v, NULL, "struct tm", name, 0, errp); + visit_type_int32(v, &obj->tm_year, "tm_year", errp); + visit_type_int32(v, &obj->tm_mon, "tm_mon", errp); + visit_type_int32(v, &obj->tm_mday, "tm_mday", errp); + visit_type_int32(v, &obj->tm_hour, "tm_hour", errp); + visit_type_int32(v, &obj->tm_min, "tm_min", errp); + visit_type_int32(v, &obj->tm_sec, "tm_sec", errp); + visit_end_struct(v, errp); +} + +void visit_type_QEMUTimer(Visitor *v, QEMUTimer **obj, const char *name, + Error **errp) +{ + int64_t expire_time, expire_time_cpy; + 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); + } + } +} diff --git a/qapi/qc.h b/qapi/qc.h index 3b3a8b9..cf12c07 100644 --- a/qapi/qc.h +++ b/qapi/qc.h @@ -1,6 +1,8 @@ #ifndef QC_H #define QC_H +#include "qemu-timer.h" + #define qc_declaration #define _immutable #define _derived @@ -8,4 +10,9 @@ #define _version(x) #define _size_is(x) +/* misc. visitors */ +void visit_type_tm(Visitor *m, struct tm *obj, const char *name, Error **errp); +void visit_type_QEMUTimer(Visitor *v, QEMUTimer **obj, const char *name, + Error **errp); + #endif