36
QEMU live block copy Marcelo Tosatti KVM Forum 2011 – Vancouver, CA

QEMU live block copy - KVM

  • Upload
    others

  • View
    13

  • Download
    0

Embed Size (px)

Citation preview

Page 1: QEMU live block copy - KVM

QEMU live block copy

Marcelo TosattiKVM Forum 2011 – Vancouver, CA

Page 2: QEMU live block copy - KVM

Introduction: live copy operation

• Copies in use guest disk image to destination image.

• Switches guest disk to destination image.

ide0-hd1

/a/disk.img

ide0-hd1

/b/disk-dest.img

Page 3: QEMU live block copy - KVM

Live migration

VM

Shared storage

VM disk

Page 4: QEMU live block copy - KVM

Live migration

VM

Shared storage

VM disk

Page 5: QEMU live block copy - KVM

Storage motion

VM

Shared storage Shared storage

VM disk

Page 6: QEMU live block copy - KVM

Storage motion

VM

Shared storage Shared storage

VM disk

Page 7: QEMU live block copy - KVM

Use cases – storage motion

• Move guest image(s) from local storage to SAN storage unit and vice-versa.

• Useful for repairs, maintenance tasks (eg: move to new storage unit).

• Useful to manage guest images across storage units for speed and capacity arrangements.

Page 8: QEMU live block copy - KVM

Use cases – image format conversion.

• Convert guest disk image format.

Page 9: QEMU live block copy - KVM

Use cases – snapshot merging.

• Collapse (merge) chains formed with QCOW2 external snapshots.

Page 10: QEMU live block copy - KVM

Qcow2 backing files

• Image contains difference to base image.

• Copy-On-Write.

base.img current.img

base.img

Page 11: QEMU live block copy - KVM

Snapshots with base files

• New image is created to accomodate writes. Previous image

becomes a snapshot.

• Live snapshots: snapshot_blkdev command.

base.img sn1.img current.img

Page 12: QEMU live block copy - KVM

Qcow2 snapshot chains

• After many snapshots...

• Reading data traverses back image chain, reading and caching metadata.

base.img sn1.img current.img

...

Page 13: QEMU live block copy - KVM

Merging snapshots with live copy

base.img sn1.img current.img

...

base.img current.img

Page 14: QEMU live block copy - KVM

Live block copy interface

• Monitor command:

block_copy guest-disk-ID /path/to/new/image.img

• image.img created externally.

Page 15: QEMU live block copy - KVM

Live block copy internals

• 3 stages: bulk, dirty and mirrored writes.

Page 16: QEMU live block copy - KVM

Bulk

• Log guest writes to source block dev (dirty bitmap).

• Copy sectors from 1...LAST_SECTOR to destination block dev.

...

Page 17: QEMU live block copy - KVM

Dirty

• Copy dirty blocks (that have been modified by the guest during bulk stage), from dirty bitmap.

Page 18: QEMU live block copy - KVM

Mirrored writes

• Duplicate writes to source and destination.

• Both images are valid (crash scenario).

W

Page 19: QEMU live block copy - KVM

Mirrored writes

• Until receives switch command from management.

• Writes to destination only.

Page 20: QEMU live block copy - KVM

In the meantime...

• Requirement arises to quickly deploy guest whose base image

is on slow remote storage.

• Copying entire image takes too long.

Page 21: QEMU live block copy - KVM

Image streaming

• Copy On Read.

guest: read sector y

remote.img local.img

Page 22: QEMU live block copy - KVM

Image streaming

• Background copy. With COR that means reading entire image.

Page 23: QEMU live block copy - KVM

Image streaming: QED patches

• Implemented by IBM.

• COR logic in image format implementation.

• Generic interface for streaming entire image.

Page 24: QEMU live block copy - KVM

Streaming

• Observation: streaming and live block copy are essentially the same: copy guest disk image while its being accessed.

• Difference is that live block copy copies to an image, and

image streaming copies from and image.

• Kevin suggests one implementation to address both requirements.

Page 25: QEMU live block copy - KVM

Blkstream: unified stream/live copy

• Block driver that implements COR.

• Works with any format that supports backing files.

• Interface to sequentially read entire image.

Page 26: QEMU live block copy - KVM

Image streaming with blkstream

local.img

1) start guest with COR enabled.

ide0-hd1

remote.img local.img

Page 27: QEMU live block copy - KVM

Image streaming with blkstream

local.img

1) start guest with streaming enabled.2) once streaming is finished, remove backing file reference.

ide0-hd1

Page 28: QEMU live block copy - KVM

Storage motion with blkstream

source.img dest.img

1) create destination image with source as backing file.

ide0-hd1

Page 29: QEMU live block copy - KVM

Storage motion with blkstream

source.img dest.img

1) create destination image with source as backing file.2) switch to destination (management must update its record).3) read all clusters.

ide0-hd1

Page 30: QEMU live block copy - KVM

Storage motion with blkstream

dest.img

1) create destination image with source as backing file.2) switch to destination (management must update its record).3) read all clusters.

ide0-hd1

4) remove backing file reference.

Page 31: QEMU live block copy - KVM

Storage motion with shared base image

base.img sn1.img last.img

...

Page 32: QEMU live block copy - KVM

Storage motion with shared base image

base.img sn1.img last.img

...last+1.img

1) create new image with last as backing file.

Page 33: QEMU live block copy - KVM

Storage motion with shared base image

base.img sn1.img last.img

...last+1.img

1) create new image with last as backing file.

2) only COR if cluster allocated up the chain from shared base.

Page 34: QEMU live block copy - KVM

Shared base image

base.img last+1.img

1) create new image with last as backing file.

2) only COR if cluster allocated up the chain from shared base.

3) read all clusters, write final backing file.

Page 35: QEMU live block copy - KVM

COW emulation

• Image streaming requires backing file support.

• For formats that do not support backing files, external

support will be provided.

• Essentially on disk bitmap with allocated information.

• Robert Wang @ IBM working on it.

Page 36: QEMU live block copy - KVM

Questions? Comments?