From 10c8640afe73580b29585bfd80a7d21cc3323b09 Mon Sep 17 00:00:00 2001
Message-Id: <10c8640afe73580b29585bfd80a7d21cc3323b09.1380723420.git.minovotn@redhat.com>
In-Reply-To: <68de4f1434a46df7d1b6e59cb348f11c92dbf17c.1380723420.git.minovotn@redhat.com>
References: <68de4f1434a46df7d1b6e59cb348f11c92dbf17c.1380723420.git.minovotn@redhat.com>
From: Fam Zheng <famz@redhat.com>
Date: Thu, 26 Sep 2013 03:23:32 +0200
Subject: [PATCH 04/13] vmdk: Add migration blocker

RH-Author: Fam Zheng <famz@redhat.com>
Message-id: <1380165812-10833-1-git-send-email-famz@redhat.com>
Patchwork-id: 54540
O-Subject: [RHEL-6.5 qemu-kvm PATCH] vmdk: Add migration blocker
Bugzilla: 999358
RH-Acked-by: Markus Armbruster <armbru@redhat.com>
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
RH-Acked-by: Kevin Wolf <kwolf@redhat.com>
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>

From: Kevin Wolf <kwolf@redhat.com>

Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=999358
Brew:     http://brewweb.devel.redhat.com/brew/taskinfo?taskID=6330555
Upstream: merged

VMDK caches L2 tables. For migration to work, they would have to be
invalidated. Block migration for now.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
(cherry picked from commit 2bc3166c22aeeb5cd7b8f21104f4744f08c7a288)
Signed-off-by: Fam Zheng <famz@redhat.com>
---
 block/vmdk.c | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

Signed-off-by: Michal Novotny <minovotn@redhat.com>
---
 block/vmdk.c | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/block/vmdk.c b/block/vmdk.c
index bf21515..6f5b415 100644
--- a/block/vmdk.c
+++ b/block/vmdk.c
@@ -26,6 +26,7 @@
 #include "qemu-common.h"
 #include "block_int.h"
 #include "module.h"
+#include "migration.h"
 #include <zlib.h>
 #include "qerror.h"
 
@@ -116,6 +117,7 @@ typedef struct BDRVVmdkState {
     int num_extents;
     /* Extent array with num_extents entries, ascend ordered by address */
     VmdkExtent *extents;
+    Error *migration_blocker;
 } BDRVVmdkState;
 
 typedef struct VmdkMetaData {
@@ -824,7 +826,14 @@ static int vmdk_open(BlockDriverState *bs, int flags)
     }
     s->parent_cid = vmdk_read_cid(bs, 1);
     qemu_co_mutex_init(&s->lock);
-    return ret;
+
+    /* Disable migration when VMDK images are used */
+    error_set(&s->migration_blocker,
+              QERR_BLOCK_FORMAT_FEATURE_NOT_SUPPORTED,
+              "vmdk", bs->device_name, "live migration");
+    migrate_add_blocker(s->migration_blocker);
+
+    return 0;
 
 fail:
     vmdk_free_extents(bs);
@@ -1735,7 +1744,12 @@ exit:
 
 static void vmdk_close(BlockDriverState *bs)
 {
+    BDRVVmdkState *s = bs->opaque;
+
     vmdk_free_extents(bs);
+
+    migrate_del_blocker(s->migration_blocker);
+    error_free(s->migration_blocker);
 }
 
 static coroutine_fn int vmdk_co_flush(BlockDriverState *bs)
-- 
1.7.11.7

