qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Wenchao Xia <xiawenc@linux.vnet.ibm.com>
To: Dietmar Maurer <dietmar@proxmox.com>
Cc: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH v2 6/6] add vm state to backups
Date: Mon, 03 Dec 2012 18:13:48 +0800	[thread overview]
Message-ID: <50BC7B5C.6020308@linux.vnet.ibm.com> (raw)
In-Reply-To: <1354267354-1028712-6-git-send-email-dietmar@proxmox.com>

> +static void coroutine_fn backup_start_savevm(void *opaque)
> +{
> +    assert(backup_state.driver);
> +    assert(backup_state.writer);
> +    int ret;
> +    char *err = NULL;
> +    uint64_t remaining;
> +    int64_t maxlen;
> +    MigrationParams params = {
> +        .blk = 0,
> +        .shared = 0
> +    };
> +
> +    int restart = 0;
> +
> +    QEMUFile *file = qemu_fopen_ops(NULL, &backup_file_ops);
> +
> +    ret = qemu_savevm_state_begin(file, &params);
> +    if (ret < 0) {
> +        qemu_fclose(file);
> +        err = g_strdup("qemu_savevm_state_begin failed");
> +        goto abort;
> +    }
> +
> +    while (1) {
> +        ret = qemu_savevm_state_iterate(file);
> +        remaining = ram_bytes_remaining();
> +
> +        if (ret < 0) {
> +            qemu_fclose(file);
> +            err = g_strdup_printf("qemu_savevm_state_iterate error %d", ret);
> +            goto abort;
> +        }
> +
> +        /* stop the VM if we use too much space,
> +         * or if remaining is just a few MB
> +         */
> +        maxlen = ram_bytes_total();
> +        size_t cpos = backup_state.buf_cluster_num * BACKUP_CLUSTER_SIZE;
> +        if ((remaining < 100000) || ((cpos + remaining) >= maxlen)) {
> +            if (runstate_is_running()) {
> +                restart = 1;
> +                vm_stop(RUN_STATE_SAVE_VM);
> +           }
> +        }
> +
> +        if (ret == 1) { /* finished */
> +            if (runstate_is_running()) {
> +                restart = 1;
> +                vm_stop(RUN_STATE_SAVE_VM);
> +            }
> +
> +            ret = qemu_savevm_state_complete(file);
> +            if (ret < 0) {
> +                qemu_fclose(file);
> +                err = g_strdup("qemu_savevm_state_complete error");
> +                goto abort;
> +
> +            } else {
> +                if (qemu_fclose(file) < 0) {
> +                    error_setg(&backup_state.error,
> +                               "backup_start_savevm: qemu_fclose failed");
> +                    goto abort;
> +                }
> +                if (backup_state.driver->complete_cb(backup_state.writer,
> +                    backup_state.vmstate_dev_id, 0) < 0) {
> +                    err = g_strdup("backup_start_savevm: complete_cb failed");
> +                    goto abort;
> +                }
> +                backup_start_jobs();

  backup_start_jobs() was called after qemu_savevm_state_complete(),
and then VM got resumed with block backup jobs alone, would this cause
saved vm state not sync with the saved block contents, if there is
vmstate changing after backup_start_jobs()?


> +                goto out;
> +            }
> +        }
> +    }



-- 
Best Regards

Wenchao Xia

      reply	other threads:[~2012-12-03 10:15 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-11-30  9:22 [Qemu-devel] [PATCH v2 1/6] RFC: Efficient VM backup for qemu Dietmar Maurer
2012-11-30  9:22 ` [Qemu-devel] [PATCH v2 2/6] add basic backup support to block driver Dietmar Maurer
2012-11-30  9:22 ` [Qemu-devel] [PATCH v2 3/6] add backup related monitor commands Dietmar Maurer
2012-12-12 17:47   ` Eric Blake
2012-12-12 19:33     ` Dietmar Maurer
2012-11-30  9:22 ` [Qemu-devel] [PATCH v2 4/6] introduce new vma archive format Dietmar Maurer
2012-11-30  9:22 ` [Qemu-devel] [PATCH v2 5/6] add regression tests for backup Dietmar Maurer
2012-11-30  9:22 ` [Qemu-devel] [PATCH v2 6/6] add vm state to backups Dietmar Maurer
2012-12-03 10:13   ` Wenchao Xia [this message]

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=50BC7B5C.6020308@linux.vnet.ibm.com \
    --to=xiawenc@linux.vnet.ibm.com \
    --cc=dietmar@proxmox.com \
    --cc=qemu-devel@nongnu.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).