From: Joshua Otto <jtotto@uwaterloo.ca>
To: xen-devel@lists.xenproject.org
Cc: wei.liu2@citrix.com, andrew.cooper3@citrix.com,
ian.jackson@eu.citrix.com, czylin@uwaterloo.ca,
Joshua Otto <jtotto@uwaterloo.ca>,
imhy.yang@gmail.com, hjarmstr@uwaterloo.ca
Subject: [PATCH RFC 04/20] libxc/xc_sr_save.c: add WRITE_TRIVIAL_RECORD_FN()
Date: Mon, 27 Mar 2017 05:06:16 -0400 [thread overview]
Message-ID: <1490605592-12189-5-git-send-email-jtotto@uwaterloo.ca> (raw)
In-Reply-To: <1490605592-12189-1-git-send-email-jtotto@uwaterloo.ca>
Writing the libxc save stream requires writing a few 'trivial' records,
consisting only of a header with a particular type. As a readability
aid, it's nice to have obviously-named functions that write these sorts
of records into the stream - for example, the first such function was
write_end_record(), which reads much more pleasantly at its call-site
than write_generic_record(REC_TYPE_END) would. However, it's tedious
and error-prone to copy-paste the generic body of such a function for
each new trivial record type.
Add a helper macro that takes a name base and a record type and declares
the corresponding trivial record write function. Use this to re-define
the two existing trivial record functions, write_end_record() and
write_checkpoint_record().
No functional change.
Signed-off-by: Joshua Otto <jtotto@uwaterloo.ca>
---
tools/libxc/xc_sr_save.c | 26 ++++++++++----------------
1 file changed, 10 insertions(+), 16 deletions(-)
diff --git a/tools/libxc/xc_sr_save.c b/tools/libxc/xc_sr_save.c
index 61fc4a4..86f6903 100644
--- a/tools/libxc/xc_sr_save.c
+++ b/tools/libxc/xc_sr_save.c
@@ -47,24 +47,18 @@ static int write_headers(struct xc_sr_context *ctx, uint16_t guest_type)
}
/*
- * Writes an END record into the stream.
+ * Declares a helper function to write an empty record of a particular type.
*/
-static int write_end_record(struct xc_sr_context *ctx)
-{
- struct xc_sr_record end = { REC_TYPE_END, 0, NULL };
-
- return write_record(ctx, ctx->fd, &end);
-}
-
-/*
- * Writes a CHECKPOINT record into the stream.
- */
-static int write_checkpoint_record(struct xc_sr_context *ctx)
-{
- struct xc_sr_record checkpoint = { REC_TYPE_CHECKPOINT, 0, NULL };
+#define WRITE_TRIVIAL_RECORD_FN(name, type) \
+ static int write_ ## name ## _record(struct xc_sr_context *ctx) \
+ { \
+ struct xc_sr_record name = { (type), 0, NULL }; \
+ \
+ return write_record(ctx, ctx->fd, &name); \
+ }
- return write_record(ctx, ctx->fd, &checkpoint);
-}
+WRITE_TRIVIAL_RECORD_FN(end, REC_TYPE_END);
+WRITE_TRIVIAL_RECORD_FN(checkpoint, REC_TYPE_CHECKPOINT);
/*
* Writes a batch of memory as a PAGE_DATA record into the stream. The batch
--
2.7.4
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel
next prev parent reply other threads:[~2017-03-27 9:07 UTC|newest]
Thread overview: 53+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-03-27 9:06 [PATCH RFC 00/20] Add postcopy live migration support Joshua Otto
2017-03-27 9:06 ` [PATCH RFC 01/20] tools: rename COLO 'postcopy' to 'aftercopy' Joshua Otto
2017-03-28 16:34 ` Wei Liu
2017-04-11 6:19 ` Zhang Chen
2017-03-27 9:06 ` [PATCH RFC 02/20] libxc/xc_sr: parameterise write_record() on fd Joshua Otto
2017-03-28 18:53 ` Andrew Cooper
2017-03-31 14:19 ` Wei Liu
2017-03-27 9:06 ` [PATCH RFC 03/20] libxc/xc_sr_restore.c: use write_record() in send_checkpoint_dirty_pfn_list() Joshua Otto
2017-03-28 18:56 ` Andrew Cooper
2017-03-31 14:19 ` Wei Liu
2017-03-27 9:06 ` Joshua Otto [this message]
2017-03-28 19:03 ` [PATCH RFC 04/20] libxc/xc_sr_save.c: add WRITE_TRIVIAL_RECORD_FN() Andrew Cooper
2017-03-30 4:28 ` Joshua Otto
2017-03-27 9:06 ` [PATCH RFC 05/20] libxc/xc_sr: factor out filter_pages() Joshua Otto
2017-03-28 19:27 ` Andrew Cooper
2017-03-30 4:42 ` Joshua Otto
2017-03-27 9:06 ` [PATCH RFC 06/20] libxc/xc_sr: factor helpers out of handle_page_data() Joshua Otto
2017-03-28 19:52 ` Andrew Cooper
2017-03-30 4:49 ` Joshua Otto
2017-04-12 15:16 ` Wei Liu
2017-03-27 9:06 ` [PATCH RFC 07/20] migration: defer precopy policy to libxl Joshua Otto
2017-03-29 18:54 ` Jennifer Herbert
2017-03-30 5:28 ` Joshua Otto
2017-03-29 20:18 ` Andrew Cooper
2017-03-30 5:19 ` Joshua Otto
2017-04-12 15:16 ` Wei Liu
2017-04-18 17:56 ` Ian Jackson
2017-03-27 9:06 ` [PATCH RFC 08/20] libxl/migration: add precopy tuning parameters Joshua Otto
2017-03-29 21:08 ` Andrew Cooper
2017-03-30 6:03 ` Joshua Otto
2017-04-12 15:37 ` Wei Liu
2017-04-27 22:51 ` Joshua Otto
2017-03-27 9:06 ` [PATCH RFC 09/20] libxc/xc_sr_save: introduce save batch types Joshua Otto
2017-03-27 9:06 ` [PATCH RFC 10/20] libxc/xc_sr_save.c: initialise rec.data before free() Joshua Otto
2017-03-28 19:59 ` Andrew Cooper
2017-03-29 17:47 ` Wei Liu
2017-03-27 9:06 ` [PATCH RFC 11/20] libxc/migration: correct hvm record ordering specification Joshua Otto
2017-03-27 9:06 ` [PATCH RFC 12/20] libxc/migration: specify postcopy live migration Joshua Otto
2017-03-27 9:06 ` [PATCH RFC 13/20] libxc/migration: add try_read_record() Joshua Otto
2017-04-12 15:16 ` Wei Liu
2017-03-27 9:06 ` [PATCH RFC 14/20] libxc/migration: implement the sender side of postcopy live migration Joshua Otto
2017-03-27 9:06 ` [PATCH RFC 15/20] libxc/migration: implement the receiver " Joshua Otto
2017-03-27 9:06 ` [PATCH RFC 16/20] libxl/libxl_stream_write.c: track callback chains with an explicit phase Joshua Otto
2017-03-27 9:06 ` [PATCH RFC 17/20] libxl/libxl_stream_read.c: " Joshua Otto
2017-03-27 9:06 ` [PATCH RFC 18/20] libxl/migration: implement the sender side of postcopy live migration Joshua Otto
2017-03-27 9:06 ` [PATCH RFC 19/20] libxl/migration: implement the receiver " Joshua Otto
2017-03-27 9:06 ` [PATCH RFC 20/20] tools: expose postcopy live migration support in libxl and xl Joshua Otto
2017-03-28 14:41 ` [PATCH RFC 00/20] Add postcopy live migration support Wei Liu
2017-03-30 4:13 ` Joshua Otto
2017-03-31 14:19 ` Wei Liu
2017-03-29 22:50 ` Andrew Cooper
2017-03-31 4:51 ` Joshua Otto
2017-04-12 15:38 ` Wei Liu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1490605592-12189-5-git-send-email-jtotto@uwaterloo.ca \
--to=jtotto@uwaterloo.ca \
--cc=andrew.cooper3@citrix.com \
--cc=czylin@uwaterloo.ca \
--cc=hjarmstr@uwaterloo.ca \
--cc=ian.jackson@eu.citrix.com \
--cc=imhy.yang@gmail.com \
--cc=wei.liu2@citrix.com \
--cc=xen-devel@lists.xenproject.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).