From: Eric Blake <eblake@redhat.com>
To: Sanidhya Kashyap <sanidhya.iiith@gmail.com>,
qemu list <qemu-devel@nongnu.org>
Cc: Juan Quintela <quintela@redhat.com>
Subject: Re: [Qemu-devel] [PATCH 2/6] bitmap dump code via QAPI framework
Date: Tue, 20 May 2014 13:03:00 -0600 [thread overview]
Message-ID: <537BA6E4.1060307@redhat.com> (raw)
In-Reply-To: <1400608075-19917-3-git-send-email-sanidhya.iiith@gmail.com>
[-- Attachment #1: Type: text/plain, Size: 6155 bytes --]
On 05/20/2014 11:47 AM, Sanidhya Kashyap wrote:
> This patch introduces the mechanism of dumping the dirty bitmap either
> in an ascii format or binary format. The implementation is almost
> similar to the migration one. A separate thread is created for the
> dumping process.
>
> The bitmap is obtained with the help of ramlist blocks. I have used almost
> similar functions that have been used in the migration mechanism (in
> arch_init.c file). The mechanism to save the dirty bitmap is based on
> RamBlock rather than MemoryRegion. After having a discussion with Juan, there
> are still some issues with MemoryRegion like
> * memory regions can overlap as well as
> * no port of TCG to MemoryRegion.
>
>
> +++ b/include/qapi/qmp/qerror.h
> @@ -118,6 +118,9 @@ void qerror_report_err(Error *err);
> #define QERR_MIGRATION_ACTIVE \
> ERROR_CLASS_GENERIC_ERROR, "There's a migration process in progress"
>
> +#define QERR_LOG_DIRTY_BITMAP_ACTIVE \
> + ERROR_CLASS_GENERIC_ERROR, "Dirty bitmap dump already in progress"
> +
Please don't add new ERROR_CLASS macros. Instead, just use error_setg()
and directly output the error message at the call site that produces the
error.
> +++ b/qapi-schema.json
> @@ -4700,3 +4700,13 @@
> 'btn' : 'InputBtnEvent',
> 'rel' : 'InputMoveEvent',
> 'abs' : 'InputMoveEvent' } }
> +##
> +# @log-dirty-bitmap
> +#
> +# provides the dirty bitmap for time t if specified.
Too light on the specification. You should document all 4 parameters,
and the default value for when the parameters are omitted.
'time t' isn't mentioned in any of the parameter names, so I'm assuming
the docs should mention its significance.
Missing a 'Since: 2.1' designation.
> +##
> +{ 'command' : 'log-dirty-bitmap',
> + 'data' : { 'filename' : 'str',
> + '*epochs' : 'int',
> + '*frequency' : 'int',
> + '*readable' : 'bool' } }
Seems okay. As long as you use qemu_open(), it should also allow
management to pass in an fd with the add-fd mechanism.
> +
> +Arguments:
> +
> +- "filename": name of the file, in which the bitmap will be saved
> +- "epochs": number of times, the memory will be logged
s/times,/times/
> +- "frequency": time difference in milliseconds between each epoch
> +- "readable": dumps the bitmap in hex format (non-binary)
Possibly a poor choice of naming (binary output IS machine-readable; in
fact, programs prefer parsing binary output over decoding human-readable
text); maybe 'pretty' or 'text' would have been better; or even invert
the sense and have it be 'binary' and default to true. I also wonder if
we even need it - I'd rather have the QMP command always output raw
binary, and then rely on post-processing to turn it into whatever format
the user wants to see (od works wonders), than to bloat qemu with having
to generate a human-readable variant.
> +
> +Examples:
> +-> { "execute" : "log-dirty-bitmap",
> + "arguments" : {
> + "filename" : "/tmp/fileXXX",
> + "epochs" : 100,
> + "frequency" : 100 } }
> +
> +<- { "return": {} }
> +
> +Note: The epochs, frequency and readable are optional. epochs default
> +value is 3 while that of frequency is 40 and readable defaults to false.
Mention the defaults alongside the description of each parameter, not in
a footnote.
> +static inline void check_epochs_value(int64_t *epochs, Error **errp)
> +{
> + if (*epochs <= 0) {
> + error_setg(errp, "epoch size must be greater than 0, setting"
> + " a value of 3\n");
> + *epochs = 3;
This error reporting won't work. Since this function returns void, if
errp is set at all, the caller must assume failure, rather than hoping
that you replaced the user's bad input with a saner default value. If
it was worth reporting the error, then it is not worth trying to fix up
the value.
> +/*
> + * copied from arch_init.c file (below function)
> + */
> +
> +static void dirty_bitmap_logging_sync_range(ram_addr_t start,
> + ram_addr_t length)
> +{
Rather than copying a function, can you make the original non-static and
share it between both callers? Otherwise, the two will get out of sync
if a bug is fixed in one.
> +void qmp_log_dirty_bitmap(const char *filename, bool has_epochs,
> + int64_t epochs, bool has_frequency,
> + int64_t frequency, bool has_readable,
> + bool readable, Error **errp)
> +{
> + FILE *f;
> + BitmapLogState *b = logging_current_state();
> +
> + if (b->state == LOG_BITMAP_STATE_ACTIVE ||
> + b->state == LOG_BITMAP_STATE_SETUP ||
> + b->state == LOG_BITMAP_STATE_CANCELING) {
> + error_set(errp, QERR_LOG_DIRTY_BITMAP_ACTIVE);
> + return;
> + }
> +
> + if (b->state == LOG_BITMAP_STATE_COMPLETED) {
> + logging_state_set_status(b, LOG_BITMAP_STATE_COMPLETED,
> + LOG_BITMAP_STATE_NONE);
> + } else if (b->state == LOG_BITMAP_STATE_CANCELLED) {
> + logging_state_set_status(b, LOG_BITMAP_STATE_CANCELLED,
> + LOG_BITMAP_STATE_NONE);
> + }
> +
> + if (readable) {
readable is undefined if has_readable is false. You are missing
something like:
if (!has_readable) {
readable = false;
}
> + f = fopen(filename, "w");
> + } else {
> + f = fopen(filename, "wb");
Ouch. You should be using qemu_open, not fopen, so that you can
automatically support things like /dev/fdset/NNN when coupled with the
'add-fd' command for passing open file descriptors.
> + if (!has_epochs) {
> + epochs = 3;
> + }
> + if (!has_frequency) {
> + frequency = 40;
Magic numbers; use a named constant.
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 604 bytes --]
next prev parent reply other threads:[~2014-05-20 19:03 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-05-20 17:47 [Qemu-devel] [PATCH 0/6] Obtain dirty bitmap via VM logging Sanidhya Kashyap
2014-05-20 17:47 ` [Qemu-devel] [PATCH 1/6] split dirty bitmap into four for dumping the bitmaps Sanidhya Kashyap
2014-05-20 17:47 ` [Qemu-devel] [PATCH 2/6] bitmap dump code via QAPI framework Sanidhya Kashyap
2014-05-20 19:03 ` Eric Blake [this message]
2014-05-20 19:25 ` Sanidhya Kashyap
2014-05-20 17:47 ` [Qemu-devel] [PATCH 3/6] hmp interface for dirty bitmap dump Sanidhya Kashyap
2014-05-20 17:47 ` [Qemu-devel] [PATCH 4/6] cancel mechanism for an already running dump bitmap process Sanidhya Kashyap
2014-05-20 19:34 ` Eric Blake
2014-05-20 17:47 ` [Qemu-devel] [PATCH 5/6] set the frequency of the " Sanidhya Kashyap
2014-05-20 19:36 ` Eric Blake
2014-05-20 17:47 ` [Qemu-devel] [PATCH 6/6] python script for extracting bitmap from a binary file Sanidhya Kashyap
2014-05-20 19:38 ` Eric Blake
2014-05-20 19:39 ` Eric Blake
2014-05-21 0:43 ` Sanidhya Kashyap
2014-05-21 4:13 ` [Qemu-devel] [PATCH 0/6] Obtain dirty bitmap via VM logging ChenLiang
2014-05-21 4:56 ` Sanidhya Kashyap
2014-05-21 6:45 ` ChenLiang
2014-05-21 6:55 ` Sanidhya Kashyap
2014-05-22 11:21 ` Sanidhya Kashyap
2014-05-22 12:57 ` ChenLiang
2014-05-23 2:30 ` Sanidhya Kashyap
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=537BA6E4.1060307@redhat.com \
--to=eblake@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=quintela@redhat.com \
--cc=sanidhya.iiith@gmail.com \
/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).