[libvirt] [PATCH] Bypass caching in saving VM memory upon external memory snapshot.

Daniel P. Berrange berrange at redhat.com
Thu Aug 25 12:43:12 UTC 2016


On Thu, Aug 25, 2016 at 07:46:01AM +0000, fuweiwei wrote:
> From: Fuweiwei <fuweiwei2 at huawei.com>
> 
> Currently in qemu-kvm platform, the process of making an external memory 
> snapshot is based on the "migration-to-file" sheme. It will use the system 
> cache to speed up dumping. However, it will make external disk snapshots
> afterwards, which must wait for the completion of flushing the dirty pages 
> to the snapshot file. i.e. In virFileWrapperFdClose() after qemuMigrationToFile(),
> it should wait until the libvirt_iohelper thread finishes fdatasync and exits.
> During this time, the VM is paused (since it is suspended from the last iteration
> of migration-to-file, to the completion of disk snapshots).
> 
> Assuming saving 4GB dirty memory at 200MB/s fdatasync speed, the VM will pause
> for up to 20s, which is unfriendly to guests.
> 
> So I propose that it may be better to bypass caching upon external memory 
> snapshot, via the VIR_DOMAIN_SAVE_BYPASS_CACHE flag. As a result, it may avoid
> long-term fdatasync in libvirt_iohelper thread and achieve seemless VM suspend.
> 
> Signed-off-by: Fuweiwei <fuweiwei2 at huawei.com>
> ---
>  src/qemu/qemu_driver.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
> index 2089359..f954c23 100644
> --- a/src/qemu/qemu_driver.c
> +++ b/src/qemu/qemu_driver.c
> @@ -14117,7 +14117,8 @@ qemuDomainSnapshotCreateActiveExternal(virConnectPtr conn,
>              goto cleanup;
>  
>          if ((ret = qemuDomainSaveMemory(driver, vm, snap->def->file,
> -                                        xml, compressed, resume, 0,
> +                                        xml, compressed, resume,
> +                                        VIR_DOMAIN_SAVE_BYPASS_CACHE,
>                                          QEMU_ASYNC_JOB_SNAPSHOT)) < 0)
>              goto cleanup;

We should not hardcode this - some filesystems won't support this mode.
We need to wire this upto the API, so when the user invokes the snapshot
they can request the VIR_DOMAIN_SAVE_BYPASS_CACHE flag explicitly.


Regards,
Daniel
-- 
|: http://berrange.com      -o-    http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org              -o-             http://virt-manager.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org       -o-       http://live.gnome.org/gtk-vnc :|




More information about the libvir-list mailing list