qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
To: Sanidhya Kashyap <sanidhya.iiith@gmail.com>
Cc: qemu list <qemu-devel@nongnu.org>, Juan Quintela <quintela@redhat.com>
Subject: Re: [Qemu-devel] [PATCH v2 2/8] bitmap dump code via QAPI framework
Date: Wed, 4 Jun 2014 11:12:53 +0100	[thread overview]
Message-ID: <20140604101253.GE2618@work-vm> (raw)
In-Reply-To: <1401863911-5947-3-git-send-email-sanidhya.iiith@gmail.com>

* Sanidhya Kashyap (sanidhya.iiith@gmail.com) wrote:
> Following are the changes made with respect to the previous version:
> Chen's advice

> +    if (qemu_write_full(fd, &ram_bitmap_pages, sizeof(int64_t)) < 0) {
> +        b->state = LOG_BITMAP_STATE_ERROR;
> +        goto log_thread_end;
> +    }
> +
> +    /*
> +     * sync the dirty bitmap along with saving it
> +     * using the FILE pointer f.
> +     */
> +    while (epoch_count < total_epochs) {
> +        if (!runstate_is_running() || b->state != LOG_BITMAP_STATE_ACTIVE) {
> +            goto log_thread_end;
> +        }
> +        bitmap_zero(logging_bitmap, ram_bitmap_pages);
> +        logging_lock();
> +        dirty_bitmap_sync();
> +        logging_unlock();
> +        if (qemu_write_full(fd, logging_bitmap, bitmap_size) < 0) {
> +            b->state = LOG_BITMAP_STATE_ERROR;
> +            goto log_thread_end;
> +        }
> +        g_usleep(b->current_frequency * 1000);
> +        epoch_count++;
> +    }

I wonder about adding two extra things to the file format:
  1) The block names/length/offset information - so that you can tell
that bitmap entry 'n' is from main ram or from video ram.
  2) A marker word between/after each bitmap with a known value - it would
help spot any error where the wrong length is being read in the scripts;
otherwise it would be easy to get misaligned bitmaps without really noticing.

Dave

> +
> +    /*
> +     * stop the logging period.
> +     */
> + log_thread_end:
> +    logging_bitmap_close(b);
> +    if (b->state == LOG_BITMAP_STATE_ACTIVE) {
> +        logging_state_set_status(b, LOG_BITMAP_STATE_ACTIVE,
> +                                    LOG_BITMAP_STATE_COMPLETED);
> +    } else if (b->state == LOG_BITMAP_STATE_CANCELING) {
> +        logging_state_set_status(b, LOG_BITMAP_STATE_CANCELING,
> +                                    LOG_BITMAP_STATE_COMPLETED);
> +    } else if (b->state == LOG_BITMAP_STATE_ERROR) {
> +        logging_state_set_status(b, LOG_BITMAP_STATE_ERROR,
> +                                    LOG_BITMAP_STATE_COMPLETED);
> +    }
> +    return NULL;
> +}
> +
> +void qmp_log_dirty_bitmap(const char *filename, bool has_epochs,
> +                          int64_t epochs, bool has_frequency,
> +                          int64_t frequency, Error **errp)
> +{
> +    int fd = -1;
> +    BitmapLogState *b = logging_current_state();
> +    Error *local_err = NULL;
> +    if (b->state == LOG_BITMAP_STATE_ACTIVE ||
> +            b->state == LOG_BITMAP_STATE_SETUP ||
> +            b->state == LOG_BITMAP_STATE_CANCELING) {
> +        b = NULL;
> +        error_setg(errp, "dirty bitmap dump in progress");
> +        return;
> +    }
> +
> +    if (b->state == LOG_BITMAP_STATE_COMPLETED) {
> +        b->state = LOG_BITMAP_STATE_NONE;
> +    }
> +
> +    if (!has_epochs) {
> +        epochs = MIN_EPOCH_VALUE;
> +    }
> +    if (!has_frequency) {
> +        frequency = MIN_FREQUENCY_VALUE;
> +    }
> +
> +    if (!check_value(epochs, MIN_EPOCH_VALUE, "epoch", &local_err) ||
> +        !check_value(frequency, MIN_FREQUENCY_VALUE, "frequency", &local_err)) {
> +        if (local_err) {
> +            b = NULL;
> +            error_propagate(errp, local_err);
> +            return;
> +        }
> +    }
> +
> +    fd = qemu_open(filename, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, S_IRUSR);
> +    if (fd < 0) {
> +        error_setg_file_open(errp, errno, filename);
> +        b = NULL;
> +        return;
> +    }
> +
> +    b->total_epochs = epochs;
> +    b->current_frequency = frequency;
> +    b->fd = fd;
> +    qemu_thread_create(&b->thread, "dirty-bitmap-dump",
> +                       bitmap_logging_thread, b,
> +                       QEMU_THREAD_JOINABLE);
> +
> +    return;
> +}
> +
>  void qmp_xen_save_devices_state(const char *filename, Error **errp)
>  {
>      QEMUFile *f;
> -- 
> 1.8.3.1
> 
> 
--
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK

  reply	other threads:[~2014-06-04 10:13 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-04  6:38 [Qemu-devel] [PATCH v2 0/8] Obtain dirty bitmap via VM logging Sanidhya Kashyap
2014-06-04  6:38 ` [Qemu-devel] [PATCH v2 1/8] enable sharing of the function between migration and bitmap dump Sanidhya Kashyap
2014-06-04 10:07   ` Juan Quintela
2014-06-04 10:16     ` Sanidhya Kashyap
2014-06-04 11:29       ` Juan Quintela
2014-06-04 11:43         ` Sanidhya Kashyap
2014-06-04  6:38 ` [Qemu-devel] [PATCH v2 2/8] bitmap dump code via QAPI framework Sanidhya Kashyap
2014-06-04 10:12   ` Dr. David Alan Gilbert [this message]
2014-06-04 10:18   ` Juan Quintela
2014-06-04  6:38 ` [Qemu-devel] [PATCH v2 3/8] RunState: added two new flags for bitmap dump and migration process Sanidhya Kashyap
2014-06-04 10:08   ` Dr. David Alan Gilbert
2014-06-04  6:38 ` [Qemu-devel] [PATCH v2 4/8] bitmap dump process with runstates Sanidhya Kashyap
2014-06-04  6:38 ` [Qemu-devel] [PATCH v2 5/8] hmp interface for dirty bitmap dump Sanidhya Kashyap
2014-06-04  6:38 ` [Qemu-devel] [PATCH v2 6/8] cancel mechanism for an already running dump bitmap process Sanidhya Kashyap
2014-06-04  6:38 ` [Qemu-devel] [PATCH v2 7/8] set the frequency of the " Sanidhya Kashyap
2014-06-04  6:38 ` [Qemu-devel] [PATCH v2 8/8] python script for extracting bitmap from a binary file 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=20140604101253.GE2618@work-vm \
    --to=dgilbert@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).