From dbce67620187edbb6155a2eba9e199ab6ea7f906 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?C=C3=A9dric=20de=20Saint=20Martin?= <cedric.dsm@tiolive.com>
Date: Mon, 14 Oct 2013 10:54:50 +0000
Subject: [PATCH] KVM SR: new way of exporting disk image.

Using new built-in feature of qemu 1.6.
---
 software/kvm/common.cfg                |  2 +-
 software/kvm/template/kvm-export.sh.in | 15 +--------------
 2 files changed, 2 insertions(+), 15 deletions(-)

diff --git a/software/kvm/common.cfg b/software/kvm/common.cfg
index 5de1e9dd5..cae25e336 100644
--- a/software/kvm/common.cfg
+++ b/software/kvm/common.cfg
@@ -133,7 +133,7 @@ mode = 0644
 recipe = hexagonit.recipe.download
 url = ${:_profile_base_location_}/template/kvm-export.sh.in
 filename = kvm-export.sh.in
-md5sum = 844ffe5e01dedbf0a261edf52e067cbe
+md5sum = 95fde96f35cbf90d677c44d18b60fafb 
 download-only = true
 mode = 0755
 
diff --git a/software/kvm/template/kvm-export.sh.in b/software/kvm/template/kvm-export.sh.in
index b62754727..1cba2ccb4 100644
--- a/software/kvm/template/kvm-export.sh.in
+++ b/software/kvm/template/kvm-export.sh.in
@@ -1,8 +1,5 @@
 #!/bin/bash
 # Create a backup of the disk image of the virtual machine
-QEMU_IMG=${kvm-instance:qemu-img-path}
-SNAPSHOT_NAME=$(date +%s)
-DISK_PATH=${kvm-instance:disk-path}
 BACKUP_PATH=${:backup-disk-path}
 QMP_CLIENT=${buildout:directory}/software_release/bin/qemu-qmp-client
 
@@ -11,15 +8,5 @@ if [ ! -f $DISK_PATH ]; then
   exit 0;
 fi
 
-$QMP_CLIENT ${kvm-instance:socket-path} suspend && \
-$QEMU_IMG snapshot -c $SNAPSHOT_NAME $DISK_PATH
-$QMP_CLIENT ${kvm-instance:socket-path} resume
+$QMP_CLIENT --socket ${kvm-instance:socket-path} --drive-backup $BACKUP_PATH
 
-if [ -f $BACKUP_PATH ]; then
-  rm $BACKUP_PATH
-fi
-$QEMU_IMG convert -f qcow2 -O qcow2 -s $SNAPSHOT_NAME $DISK_PATH $BACKUP_PATH
-
-$QMP_CLIENT ${kvm-instance:socket-path} suspend && \
-$QEMU_IMG snapshot -d $SNAPSHOT_NAME $DISK_PATH
-$QMP_CLIENT ${kvm-instance:socket-path} resume
-- 
2.30.9