From f8ee9232adbe951d8f74bf9d02c07c296bcc2e3c Mon Sep 17 00:00:00 2001
From: Jeff Cody <jcody@redhat.com>
Date: Thu, 7 Nov 2013 07:33:12 +0100
Subject: [PATCH 118/212] migration: disable live block migration (-b/-i) for rhel and rhev

RH-Author: Jeff Cody <jcody@redhat.com>
Message-id: <696b8063664491b1d1799450b4498927c2ae9908.1383712781.git.jcody@redhat.com>
Patchwork-id: 55480
O-Subject: [RHEL7 qemu-kvm PATCH 3/3] migration: disable live block migration (-b/-i) for rhel and rhev
Bugzilla: 1022392
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
RH-Acked-by: Eric Blake <eblake@redhat.com>
RH-Acked-by: Kevin Wolf <kwolf@redhat.com>

This disables live block migration (both -b and -i options) for both
the RHEL and RHEV versions of qemu-kvm.  Rather than delete the options
from the QAPI/QMP commands (which would be unfriendly to libvirt), the
options return a QMP error of unsupported ("this feature or command is
not currently supported").

A configure option to enable/disable this is set, which defaults to the
command options being disabled.  Just to be safe, the rpm spec template
explicitly disables it as well.

Signed-off-by: Jeff Cody <jcody@redhat.com>
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
---
 configure                     |   12 ++++++++++++
 migration.c                   |    7 +++++++
 redhat/qemu-kvm.spec.template |    1 +
 3 files changed, 20 insertions(+), 0 deletions(-)

diff --git a/configure b/configure
index c9118b1..3309e3a 100755
--- a/configure
+++ b/configure
@@ -334,6 +334,7 @@ libssh2=""
 vhdx=""
 quorum=""
 live_block_ops="yes"
+live_block_migration="no"
 numa=""
 
 
@@ -1126,6 +1127,10 @@ for opt do
   ;;
   --enable-numa) numa="yes"
   ;;
+  --disable-live-block-migration) live_block_migration="no"
+  ;;
+  --enable-live-block-migration) live_block_migration="yes"
+  ;;
   *)
       echo "ERROR: unknown option $opt"
       echo "Try '$0 --help' for more information"
@@ -1394,6 +1399,8 @@ Advanced options (experts only):
   --enable-quorum          enable quorum block filter support
   --disable-live-block-ops disable live block operations support
   --enable-live-block-ops  enable live block operations support
+  --disable-live-block-migration disable live block migration
+  --enable-live-block-migration  enable live block migration
   --disable-numa           disable libnuma support
   --enable-numa            enable libnuma support
 
@@ -4237,6 +4244,7 @@ echo "Quorum            $quorum"
 echo "lzo support       $lzo"
 echo "snappy support    $snappy"
 echo "Live block operations $live_block_ops"
+echo "Live block migration $live_block_migration"
 echo "NUMA host support $numa"
 
 if test "$sdl_too_old" = "yes"; then
@@ -4681,6 +4689,10 @@ if test "$live_block_ops" = "yes" ; then
   echo "CONFIG_LIVE_BLOCK_OPS=y" >> $config_host_mak
 fi
 
+if test "$live_block_migration" = "yes" ; then
+  echo "CONFIG_LIVE_BLOCK_MIGRATION=y" >> $config_host_mak
+fi
+
 # USB host support
 if test "$libusb" = "yes"; then
   echo "HOST_USB=libusb legacy" >> $config_host_mak
diff --git a/migration.c b/migration.c
index 8d675b3..deeb491 100644
--- a/migration.c
+++ b/migration.c
@@ -416,6 +416,13 @@ void qmp_migrate(const char *uri, bool has_blk, bool blk,
     params.blk = has_blk && blk;
     params.shared = has_inc && inc;
 
+#ifndef CONFIG_LIVE_BLOCK_MIGRATION
+    if (params.blk || params.shared) {
+        error_set(errp, QERR_UNSUPPORTED);
+        return;
+    }
+#endif
+
     if (s->state == MIG_STATE_ACTIVE || s->state == MIG_STATE_SETUP ||
         s->state == MIG_STATE_CANCELLING) {
         error_set(errp, QERR_MIGRATION_ACTIVE);
-- 
1.7.1

