From 96944399224dcd29b232839fcc4d56aefa4492fa Mon Sep 17 00:00:00 2001
From: Jeffrey Cody <jcody@redhat.com>
Date: Tue, 10 Jan 2012 14:39:07 +0100
Subject: [PATCH 1/3] QMP: configure script enable/disable for live snapshot
 commands

RH-Author: Jeffrey Cody <jcody@redhat.com>
Message-id: <1326206347.13202.17.camel@jefflaptop>
Patchwork-id: 36325
O-Subject: [RHEL6.3 qemu-kvm PATCH v2 2/2] QMP: configure script enable/disable for live snapshot commands
Bugzilla: 769111
RH-Acked-by: Alex Williamson <alex.williamson@redhat.com>
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
RH-Acked-by: Luiz Capitulino <lcapitulino@redhat.com>

Provide the ability to disable/enable the live snapshot commands
during compile.  The default has been set to 'enabled'.

BZ 769111
Signed-off-by: Jeff Cody <jcody@redhat.com>
---
 blockdev.c      |    2 ++
 configure       |   12 ++++++++++++
 qemu-monitor.hx |    4 ++++
 3 files changed, 18 insertions(+), 0 deletions(-)

Signed-off-by: Michal Novotny <minovotn@redhat.com>
---
 blockdev.c      |    2 ++
 configure       |   12 ++++++++++++
 qemu-monitor.hx |    4 ++++
 3 files changed, 18 insertions(+), 0 deletions(-)

diff --git a/blockdev.c b/blockdev.c
index 067bbee..c3a8159 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -832,6 +832,7 @@ void do_commit(Monitor *mon, const QDict *qdict)
     }
 }
 
+#ifdef CONFIG_LIVE_SNAPSHOTS
 int do_snapshot_blkdev(Monitor *mon, const QDict *qdict, QObject **ret_data)
 {
     const char *device = qdict_get_str(qdict, "device");
@@ -910,6 +911,7 @@ out:
 
     return ret;
 }
+#endif 
 
 static void monitor_print_block_stream(Monitor *mon, const QObject *data)
 {
diff --git a/configure b/configure
index fc25e87..1732bb6 100755
--- a/configure
+++ b/configure
@@ -281,6 +281,7 @@ fake_machine="no"
 spice=""
 smartcard=""
 smartcard_nss=""
+live_snapshots="yes"
 
 # OS specific
 if check_define __linux__ ; then
@@ -675,6 +676,10 @@ for opt do
   ;;
   --enable-smartcard-nss) smartcard_nss="yes"
   ;;
+  --disable-live-snapshots) live_snapshots="no"
+  ;;
+  --enable-live-snapshots) live_snapshots="yes"
+  ;;
   *) echo "ERROR: unknown option $opt"; show_help="yes"
   ;;
   esac
@@ -846,6 +851,8 @@ echo "  --disable-smartcard      disable smartcard support"
 echo "  --enable-smartcard       enable smartcard support"
 echo "  --disable-smartcard-nss  disable smartcard nss support"
 echo "  --enable-smartcard-nss   enable smartcard nss support"
+echo "  --disable-live-snapshots disable live block device snapshot support"
+echo "  --enable-live-snapshots  enable live block device snapshot support"
 echo ""
 echo "NOTE: The object files are built at the place where configure is launched"
 exit 1
@@ -2231,6 +2238,7 @@ echo "-fake-machine     $fake_machine"
 echo "Trace backend     $trace_backend"
 echo "spice support     $spice"
 echo "nss used          $smartcard_nss"
+echo "Live snapshots    $live_snapshots"
 
 if test $sdl_too_old = "yes"; then
 echo "-> Your SDL version is too old - please upgrade to have SDL support"
@@ -2476,6 +2484,10 @@ if test "$smartcard_nss" = "yes" ; then
   echo "CONFIG_SMARTCARD_NSS=y" >> $config_host_mak
 fi
 
+if test "$live_snapshots" = "yes" ; then
+  echo "CONFIG_LIVE_SNAPSHOTS=y" >> $config_host_mak
+fi
+
 # XXX: suppress that
 if [ "$bsd" = "yes" ] ; then
   echo "CONFIG_BSD=y" >> $config_host_mak
diff --git a/qemu-monitor.hx b/qemu-monitor.hx
index 149c3a0..98cc55c 100644
--- a/qemu-monitor.hx
+++ b/qemu-monitor.hx
@@ -1384,6 +1384,7 @@ Example:
 
 EQMP
 
+#ifdef CONFIG_LIVE_SNAPSHOTS
     {
         .name       = "snapshot_blkdev",
         .args_type  = "device:B,snapshot-file:s?,format:s?",
@@ -1396,6 +1397,7 @@ EQMP
                       "snapshot will be internal! (currently unsupported)",
         .mhandler.cmd_new = do_snapshot_blkdev,
     },
+#endif
 
 STEXI
 @item snapshot_blkdev
@@ -1621,6 +1623,7 @@ STEXI
 Remove host-to-guest TCP or UDP redirection.
 ETEXI
 
+#ifdef CONFIG_LIVE_SNAPSHOTS
     {
         .name       = "blockdev-snapshot-sync",
         .args_type  = "device:B,snapshot-file:s?,format:s?",
@@ -1628,6 +1631,7 @@ ETEXI
         .user_print = monitor_user_noop,
         .mhandler.cmd_new = do_snapshot_blkdev,
     },
+#endif
 
 SQMP
 blockdev-snapshot-sync
-- 
1.7.7.5

