From 9c9f9fb9d6691c7e554a6bc837beba023e2619ad Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?C=C3=A9dric=20de=20Saint=20Martin?= <cedric.dsm@tiolive.com>
Date: Tue, 15 Oct 2013 12:22:43 +0000
Subject: [PATCH] KVM SR: add promise to look for disk image non-corruption.

---
 software/kvm/common.cfg                 |  4 ++--
 software/kvm/instance-kvm-export.cfg.in |  3 ++-
 software/kvm/instance-kvm.cfg.in        | 13 +++++++++++--
 3 files changed, 15 insertions(+), 5 deletions(-)

diff --git a/software/kvm/common.cfg b/software/kvm/common.cfg
index 344f3c541..45f402212 100644
--- a/software/kvm/common.cfg
+++ b/software/kvm/common.cfg
@@ -87,7 +87,7 @@ mode = 0644
 [template-kvm]
 recipe = slapos.recipe.template
 url = ${:_profile_base_location_}/instance-kvm.cfg.in
-md5sum = 9d1764289f2e705dc8209b99cfcaab46
+md5sum = c06bb498593aabc9c76eb7dc892da15a 
 output = ${buildout:directory}/template-kvm.cfg
 mode = 0644
 
@@ -125,7 +125,7 @@ mode = 0755
 [template-kvm-export]
 recipe = slapos.recipe.template
 url = ${:_profile_base_location_}/instance-kvm-export.cfg.in
-md5sum = 64a1a505aff9fde52afac46240811047
+md5sum = 2f5fdf1e88e6e3454f877b80074bed05 
 output = ${buildout:directory}/template-kvm-export.cfg
 mode = 0644
 
diff --git a/software/kvm/instance-kvm-export.cfg.in b/software/kvm/instance-kvm-export.cfg.in
index eab6f3d55..22dfc871c 100644
--- a/software/kvm/instance-kvm-export.cfg.in
+++ b/software/kvm/instance-kvm-export.cfg.in
@@ -7,7 +7,8 @@ parts +=
 
   certificate-authority
   publish-connection-information
-  kvm-promise
+  kvm-vnc-promise
+  kvm-disk-image-corruption-promise
   websockify-sighandler
   novnc-promise
   cron
diff --git a/software/kvm/instance-kvm.cfg.in b/software/kvm/instance-kvm.cfg.in
index 48581fa89..4545830d4 100644
--- a/software/kvm/instance-kvm.cfg.in
+++ b/software/kvm/instance-kvm.cfg.in
@@ -7,7 +7,8 @@
 parts =
   certificate-authority
   publish-connection-information
-  kvm-promise
+  kvm-vnc-promise
+  kvm-disk-image-corruption-promise
   websockify-sighandler
   novnc-promise
 #  kvm-monitor
@@ -96,12 +97,20 @@ qemu-img-path = ${kvm:location}/bin/qemu-img
 6tunnel-path = ${6tunnel:location}/bin/6tunnel
 
 
-[kvm-promise]
+[kvm-vnc-promise]
 recipe = slapos.cookbook:check_port_listening
 path = $${directory:promises}/vnc_promise
 hostname = $${kvm-instance:vnc-ip}
 port = $${kvm-instance:vnc-port}
 
+[kvm-disk-image-corruption-promise]
+# Check that disk image is not corrupted
+recipe = collective.recipe.template
+input = inline:#!/bin/sh
+  $${kvm-instance:qemu-img-path} check $${kvm-instance:disk-path}
+output = $${directory:promises}/kvm-disk-image-corruption
+mode = 700
+
 
 [novnc-instance]
 recipe = slapos.cookbook:novnc
-- 
2.30.9