From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:48583) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S0FlY-0003WO-BA for qemu-devel@nongnu.org; Wed, 22 Feb 2012 12:14:14 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1S0FlR-0008Mg-Ta for qemu-devel@nongnu.org; Wed, 22 Feb 2012 12:14:08 -0500 Received: from mx1.redhat.com ([209.132.183.28]:24424) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S0FlR-0008MY-Mg for qemu-devel@nongnu.org; Wed, 22 Feb 2012 12:14:01 -0500 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q1MHE0VA013223 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 22 Feb 2012 12:14:00 -0500 From: Federico Simoncelli Date: Wed, 22 Feb 2012 17:13:32 +0000 Message-Id: <1329930815-7995-1-git-send-email-fsimonce@redhat.com> Subject: [Qemu-devel] Live Block Migration using Mirroring List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: kwolf@redhat.com, mtosatti@redhat.com Hi, recently I've been working on live block migration combining the live snapshots and the blkmirror patch sent by Marcelo Tosatti few months ago. The design is summarized at this url as "Mirrored-Snapshot": http://www.ovirt.org/wiki/Features/Design/StorageLiveMigration The design assumes that the qemu process can reach both the source and destination storages and no real VM migration between hosts is involved. The principal problem that it tries to solve is moving a VM to a new reachable storage (more space, faster) without temporarily disrupting its services. The following set of patches are implementing the required changes in QEMU. Here it is a quick example of the use case (for consistency with the design at the url above I will use the same step numbers): Preparation =========== $ mkdir /tmp/{src/dst} $ qemu-img create -f qcow2 /tmp/src/hd0base.qcow2 20G Formatting '/tmp/src/hd0base.qcow2', fmt=qcow2 size=21474836480 encryption=off cluster_size=65536 Step 1 - Initital Scenario ========================== VM1 is running on the src/hd0base. (Where "<=" stands for "uses") [src/hd0base] <= VM1(read-write) $ qemu-system-x86_64 -hda /tmp/src/hd0base.qcow2 -monitor stdio QEMU 1.0.50 monitor - type 'help' for more information (qemu) Step 3 - Mirrored Live Snapshot =============================== A mirrored live snapshot is issued using src/hd0snap1 and dst/hd0snap1 as image files. (Where "<-" stands for "has backing file") [src/hd0base] <- [src/hd0snap1] <= VM1(read-write) ... <- [dst/hd0snap1] <= VM1(write-only) $ qemu-img create -f qcow2 \ -b /tmp/src/hd0base.qcow2 /tmp/src/hd0snap1.qcow2 20G Formatting '/tmp/src/hd0snap1.qcow2', fmt=qcow2 size=21474836480 backing_file='/tmp/src/hd0base.qcow2' encryption=off cluster_size=65536 $ qemu-img create -f qcow2 \ -b /tmp/dst/hd0base.qcow2 /tmp/dst/hd0snap1.qcow2 20G Formatting '/tmp/dst/hd0snap1.qcow2', fmt=qcow2 size=21474836480 backing_file='/tmp/src/hd0base.qcow2' encryption=off cluster_size=65536 (qemu) snapshot_blkdev -n ide0-hd0 \ blkmirror:/tmp/src/hd0snap1.qcow2:/tmp/dst/hd0snap1.qcow2 blkmirror Step 4 - Backing File Copy ========================== An external manager copies src/hd0base to the destination dst/hd0base. [src/hd0base] <- [src/hd0snap1] <= VM1(read-write) [dst/hd0base] <- [dst/hd0snap1] <= VM1(write-only) $ cp -a /tmp/src/hd0base.qcow2 /tmp/dst/hd0base.qcow2 Step 5 - Final Switch to Destination ==================================== VM1 is now able to switch to the destination for both read and write operations. [src/hd0base] <- [src/hd0snap1] <= VM1(read-write) (qemu) snapshot_blkdev -n ide0-hd0 /tmp/dst/hd0snap1.qcow2 -- Federico