[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 07/17] qapi: add open-coded visitors for QEMUTimer/s
From: |
Michael Roth |
Subject: |
[Qemu-devel] [PATCH 07/17] qapi: add open-coded visitors for QEMUTimer/struct tm types |
Date: |
Mon, 4 Jun 2012 20:00:08 -0500 |
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 <address@hidden>
---
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 <time.h>
+#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
--
1.7.4.1
- Re: [Qemu-devel] [PATCH 01/17] qidl: add QEMU IDL processor, (continued)
- Re: [Qemu-devel] [PATCH 01/17] qidl: add QEMU IDL processor, Avi Kivity, 2012/06/06
- Re: [Qemu-devel] [PATCH 01/17] qidl: add QEMU IDL processor, Anthony Liguori, 2012/06/06
- Re: [Qemu-devel] [PATCH 01/17] qidl: add QEMU IDL processor, Avi Kivity, 2012/06/06
- Re: [Qemu-devel] [PATCH 01/17] qidl: add QEMU IDL processor, Anthony Liguori, 2012/06/06
- Re: [Qemu-devel] [PATCH 01/17] qidl: add QEMU IDL processor, Avi Kivity, 2012/06/06
- Re: [Qemu-devel] [PATCH 01/17] qidl: add QEMU IDL processor, Anthony Liguori, 2012/06/06
- Re: [Qemu-devel] [PATCH 01/17] qidl: add QEMU IDL processor, Avi Kivity, 2012/06/06
- Re: [Qemu-devel] [PATCH 01/17] qidl: add QEMU IDL processor, Anthony Liguori, 2012/06/06
[Qemu-devel] [PATCH 06/17] qapi: qapi-visit.py, add gen support for existing types, Michael Roth, 2012/06/04
[Qemu-devel] [PATCH 05/17] qapi: qapi-visit.py, support arrays and complex qapi definitions, Michael Roth, 2012/06/04
[Qemu-devel] [PATCH 07/17] qapi: add open-coded visitors for QEMUTimer/struct tm types,
Michael Roth <=
[Qemu-devel] [PATCH 08/17] rtc: move RTCState declaration to header, Michael Roth, 2012/06/04
[Qemu-devel] [PATCH 09/17] rtc: add qc annotations, Michael Roth, 2012/06/04
[Qemu-devel] [PATCH 10/17] Makefile: add infrastructure to incorporate qidl-generated files, Michael Roth, 2012/06/04
[Qemu-devel] [PATCH 15/17] Makefile: add qidl-generation of vmstate field descriptions, Michael Roth, 2012/06/04
[Qemu-devel] [PATCH 14/17] qidl: add qidl-based generation of vmstate field bindings, Michael Roth, 2012/06/04
[Qemu-devel] [PATCH 11/17] qapi: add qidl-generated qapi schema for rtc, Michael Roth, 2012/06/04