From: Anthony Liguori <anthony@codemonkey.ws>
To: lirans@il.ibm.com
Cc: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH 2/3 v4] Block live migration
Date: Wed, 21 Oct 2009 13:30:22 -0500 [thread overview]
Message-ID: <4ADF533E.30808@codemonkey.ws> (raw)
In-Reply-To: <12553645922863-git-send-email-lirans@il.ibm.com>
lirans@il.ibm.com wrote:
> This patch introduces block migration called during live migration. Block
> are being copied to the destination in an async way. First the code will
> transfer the whole disk and then transfer all dirty blocks accumulted during
> the migration.
> Still need to improve transition from the iterative phase of migration to the
> end phase. For now transition will take place when all blocks transfered once,
> all the dirty blocks will be transfered during the end phase (guest is
> suspended).
>
>
> diff --git a/Makefile b/Makefile
> index 7d4d75c..3f34459 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -125,6 +125,7 @@ obj-y += qemu-char.o aio.o net-checksum.o savevm.o
> obj-y += msmouse.o ps2.o
> obj-y += qdev.o qdev-properties.o
> obj-y += qint.o qstring.o qdict.o qlist.o qemu-config.o
> +obj-y += block-migration.o
>
> obj-$(CONFIG_BRLAPI) += baum.o
> obj-$(CONFIG_WIN32) += tap-win32.o
> diff --git a/block-migration.c b/block-migration.c
> new file mode 100644
> index 0000000..7ca9d85
> --- /dev/null
> +++ b/block-migration.c
> @@ -0,0 +1,624 @@
> +/*
> + * QEMU live block migration
> + *
> + * Copyright IBM, Corp. 2009
> + *
> + * Authors:
> + * Liran Schour <lirans@il.ibm.com>
> + *
> + * This work is licensed under the terms of the GNU GPL, version 2. See
> + * the COPYING file in the top-level directory.
> + *
> + */
> +
> +#include "qemu-common.h"
> +#include "block_int.h"
> +#include "hw/hw.h"
> +#include "qemu-timer.h"
> +#include "block-migration.h"
> +#include <assert.h>
> +#include <pthread.h>
> +
> +#define SECTOR_BITS 9
> +#define SECTOR_SIZE (1 << SECTOR_BITS)
> +#define SECTOR_MASK ~(SECTOR_SIZE - 1);
> +
> +#define SECTORS_PER_BLOCK 8
> +#define BLOCK_SIZE (SECTORS_PER_BLOCK << SECTOR_BITS)
> +
> +#define BLK_MIG_FLAG_DEVICE_BLOCK 0x01
> +#define BLK_MIG_FLAG_EOS 0x02
> +
> +#define MAX_IS_ALLOCATED_SEARCH 65536
> +#define MAX_BLOCKS_READ 10000
> +#define BLOCKS_READ_CHANGE 100
> +#define INITIAL_BLOCKS_READ 100
> +
> +//#define DEBUG_BLK_MIGRATION
> +
> +#ifdef DEBUG_BLK_MIGRATION
> +#define dprintf(fmt, ...) \
> + do { printf("blk_migration: " fmt, ## __VA_ARGS__); } while (0)
> +#else
> +#define dprintf(fmt, ...) \
> + do { } while (0)
> +#endif
> +
> +typedef struct BlkMigBlock {
> + uint8_t buf[BLOCK_SIZE];
> + BlkMigDevState *bmds;
> + int64_t sector;
> + struct iovec iov;
> + QEMUIOVector qiov;
> + BlockDriverAIOCB *aiocb;
> + int ret;
> + struct BlkMigBlock *next;
> +} BlkMigBlock;
> +
> +typedef struct BlkMigState {
> + int bulk_completed;
> + int blk_enable;
> + int shared_base;
> + int no_dirty;
> + QEMUFile *load_file;
> + BlkMigDevState *bmds_first;
> + QEMUTimer *timer;
> +} BlkMigState;
> +
> +static BlkMigState block_mig_state;
> +
> +static BlkMigBlock *first_blk = NULL;
> +static BlkMigBlock *last_blk = NULL;
> +
> +static int submitted = 0;
> +static int read_done = 0;
> +static int transferred = 0;
>
It seems to me that this could all get moved to a global state (that's
dynamically allocated).
> +
> +static int64_t print_completion = 0;
> +static void mark_clean(BlkMigDevState *bmds, int64_t sector,
> + int sector_num);
> +static int is_dirty(BlkMigDevState *bmds, int64_t sector);
> +
> +static void blk_mig_read_cb(void *opaque, int ret)
> +{
> + BlkMigBlock *blk = opaque;
> +
> + blk->ret = ret;
> +
> + /* insert at the end */
> + if(last_blk == NULL) {
> + first_blk = last_blk = blk;
> + } else {
> + last_blk->next = blk;
> + last_blk = blk;
> + }
>
CodingStyle is off.
> + /* Device name */
> + qemu_put_be64(f,(cur_sector << SECTOR_BITS) | BLK_MIG_FLAG_DEVICE_BLOCK);
> +
> + len = strlen(bs->device_name);
> + qemu_put_byte(f, len);
> + qemu_put_buffer(f, (uint8_t *)bs->device_name, len);
> +
> + qemu_put_buffer(f, tmp_buf, BLOCK_SIZE);
>
Would be good to do a simple check for an all zero block. That would
help the initial transfer.
Regards,
Anthony Liguori
next prev parent reply other threads:[~2009-10-21 18:30 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-10-12 16:23 [Qemu-devel] [PATCH 2/3 v4] Block live migration lirans
2009-10-21 18:30 ` Anthony Liguori [this message]
-- strict thread matches above, loose matches on Subject: below --
2009-10-12 15:07 lirans
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=4ADF533E.30808@codemonkey.ws \
--to=anthony@codemonkey.ws \
--cc=lirans@il.ibm.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).