diff mbox series

[04/43] migration: create options.c

Message ID 20230302163410.11399-5-quintela@redhat.com
State New
Headers show
Series Migration: Create options.c for capabilities/params/properties | expand

Commit Message

Juan Quintela March 2, 2023, 4:33 p.m. UTC
We move there all capabilities helpers from migration.c.

Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 migration/migration.h          |  12 ----
 migration/options.h            |  34 +++++++++
 hw/virtio/virtio-balloon.c     |   1 +
 migration/block-dirty-bitmap.c |   1 +
 migration/block.c              |   1 +
 migration/colo.c               |   1 +
 migration/migration.c          | 109 +---------------------------
 migration/options.c            | 126 +++++++++++++++++++++++++++++++++
 migration/postcopy-ram.c       |   1 +
 migration/ram.c                |   1 +
 migration/savevm.c             |   1 +
 migration/socket.c             |   1 +
 migration/meson.build          |   1 +
 13 files changed, 170 insertions(+), 120 deletions(-)
 create mode 100644 migration/options.h
 create mode 100644 migration/options.c

Comments

Dr. David Alan Gilbert March 8, 2023, 9:46 a.m. UTC | #1
* Juan Quintela (quintela@redhat.com) wrote:
> We move there all capabilities helpers from migration.c.
> 
> Signed-off-by: Juan Quintela <quintela@redhat.com>
> ---
>  migration/migration.h          |  12 ----
>  migration/options.h            |  34 +++++++++
>  hw/virtio/virtio-balloon.c     |   1 +
>  migration/block-dirty-bitmap.c |   1 +
>  migration/block.c              |   1 +
>  migration/colo.c               |   1 +
>  migration/migration.c          | 109 +---------------------------
>  migration/options.c            | 126 +++++++++++++++++++++++++++++++++
>  migration/postcopy-ram.c       |   1 +
>  migration/ram.c                |   1 +
>  migration/savevm.c             |   1 +
>  migration/socket.c             |   1 +
>  migration/meson.build          |   1 +
>  13 files changed, 170 insertions(+), 120 deletions(-)
>  create mode 100644 migration/options.h
>  create mode 100644 migration/options.c
> 
> diff --git a/migration/migration.h b/migration/migration.h
> index b07efaf259..68851e485d 100644
> --- a/migration/migration.h
> +++ b/migration/migration.h
> @@ -410,16 +410,7 @@ MigrationState *migrate_get_current(void);
>  
>  bool migrate_postcopy(void);
>  
> -bool migrate_release_ram(void);
> -bool migrate_postcopy_ram(void);
> -bool migrate_zero_blocks(void);
> -bool migrate_dirty_bitmaps(void);
> -bool migrate_ignore_shared(void);
> -bool migrate_validate_uuid(void);
> -
> -bool migrate_auto_converge(void);
>  bool migrate_use_multifd(void);
> -bool migrate_pause_before_switchover(void);
>  int migrate_multifd_channels(void);
>  MultiFDCompression migrate_multifd_compression(void);
>  int migrate_multifd_zlib_level(void);
> @@ -448,9 +439,6 @@ int migrate_compress_threads(void);
>  int migrate_compress_wait_thread(void);
>  int migrate_decompress_threads(void);
>  bool migrate_use_events(void);
> -bool migrate_postcopy_blocktime(void);
> -bool migrate_background_snapshot(void);
> -bool migrate_postcopy_preempt(void);
>  
>  /* Sending on the return path - generic and then for each message type */
>  void migrate_send_rp_shut(MigrationIncomingState *mis,
> diff --git a/migration/options.h b/migration/options.h
> new file mode 100644
> index 0000000000..bae032375a
> --- /dev/null
> +++ b/migration/options.h
> @@ -0,0 +1,34 @@
> +/*
> + * QEMU migration options
> + *
> + * Copyright IBM, Corp. 2008
> + *
> + * Authors:
> + *  Anthony Liguori   <aliguori@us.ibm.com>
> + *
> + * This work is licensed under the terms of the GNU GPL, version 2.  See
> + * the COPYING file in the top-level directory.
> + *
> + * Contributions after 2012-01-13 are licensed under the terms of the
> + * GNU GPL, version 2 or (at your option) any later version.

I don't think any of these functions were written by Anthony, and I
think they're all after 2012 aren't they?  If so we can update to a more
modern header.

Other than that,


Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>

Dave
> + */
> +
> +#ifndef QEMU_MIGRATION_OPTIONS_H
> +#define QEMU_MIGRATION_OPTIONS_H
> +
> +/* capabilities */
> +
> +bool migrate_auto_converge(void);
> +bool migrate_background_snapshot(void);
> +bool migrate_dirty_bitmaps(void);
> +bool migrate_ignore_shared(void);
> +bool migrate_late_block_activate(void);
> +bool migrate_pause_before_switchover(void);
> +bool migrate_postcopy_blocktime(void);
> +bool migrate_postcopy_preempt(void);
> +bool migrate_postcopy_ram(void);
> +bool migrate_release_ram(void);
> +bool migrate_validate_uuid(void);
> +bool migrate_zero_blocks(void);
> +
> +#endif
> diff --git a/hw/virtio/virtio-balloon.c b/hw/virtio/virtio-balloon.c
> index 746f07c4d2..43092aa634 100644
> --- a/hw/virtio/virtio-balloon.c
> +++ b/hw/virtio/virtio-balloon.c
> @@ -32,6 +32,7 @@
>  #include "qemu/error-report.h"
>  #include "migration/misc.h"
>  #include "migration/migration.h"
> +#include "migration/options.h"
>  
>  #include "hw/virtio/virtio-bus.h"
>  #include "hw/virtio/virtio-access.h"
> diff --git a/migration/block-dirty-bitmap.c b/migration/block-dirty-bitmap.c
> index fe73aa94b1..a6ffae0002 100644
> --- a/migration/block-dirty-bitmap.c
> +++ b/migration/block-dirty-bitmap.c
> @@ -79,6 +79,7 @@
>  #include "qapi/qapi-visit-migration.h"
>  #include "qapi/clone-visitor.h"
>  #include "trace.h"
> +#include "options.h"
>  
>  #define CHUNK_SIZE     (1 << 10)
>  
> diff --git a/migration/block.c b/migration/block.c
> index 426a25bb19..c4fe9fea56 100644
> --- a/migration/block.c
> +++ b/migration/block.c
> @@ -28,6 +28,7 @@
>  #include "migration/vmstate.h"
>  #include "sysemu/block-backend.h"
>  #include "trace.h"
> +#include "options.h"
>  
>  #define BLK_MIG_BLOCK_SIZE           (1ULL << 20)
>  #define BDRV_SECTORS_PER_DIRTY_CHUNK (BLK_MIG_BLOCK_SIZE >> BDRV_SECTOR_BITS)
> diff --git a/migration/colo.c b/migration/colo.c
> index 0716e64689..93b78c9270 100644
> --- a/migration/colo.c
> +++ b/migration/colo.c
> @@ -36,6 +36,7 @@
>  #include "sysemu/cpus.h"
>  #include "sysemu/runstate.h"
>  #include "net/filter.h"
> +#include "options.h"
>  
>  static bool vmstate_loading;
>  static Notifier packets_compare_notifier;
> diff --git a/migration/migration.c b/migration/migration.c
> index e3062530f0..790848ef1c 100644
> --- a/migration/migration.c
> +++ b/migration/migration.c
> @@ -63,6 +63,7 @@
>  #include "sysemu/cpus.h"
>  #include "yank_functions.h"
>  #include "sysemu/qtest.h"
> +#include "options.h"
>  
>  #define MAX_THROTTLE  (128 << 20)      /* Migration transfer speed throttling */
>  
> @@ -357,15 +358,6 @@ static void migrate_generate_event(int new_state)
>      }
>  }
>  
> -static bool migrate_late_block_activate(void)
> -{
> -    MigrationState *s;
> -
> -    s = migrate_get_current();
> -
> -    return s->capabilities[MIGRATION_CAPABILITY_LATE_BLOCK_ACTIVATE];
> -}
> -
>  /*
>   * Send a message on the return channel back to the source
>   * of the migration.
> @@ -2523,56 +2515,11 @@ void qmp_migrate_continue(MigrationStatus state, Error **errp)
>      qemu_sem_post(&s->pause_sem);
>  }
>  
> -bool migrate_release_ram(void)
> -{
> -    MigrationState *s;
> -
> -    s = migrate_get_current();
> -
> -    return s->capabilities[MIGRATION_CAPABILITY_RELEASE_RAM];
> -}
> -
> -bool migrate_postcopy_ram(void)
> -{
> -    MigrationState *s;
> -
> -    s = migrate_get_current();
> -
> -    return s->capabilities[MIGRATION_CAPABILITY_POSTCOPY_RAM];
> -}
> -
>  bool migrate_postcopy(void)
>  {
>      return migrate_postcopy_ram() || migrate_dirty_bitmaps();
>  }
>  
> -bool migrate_auto_converge(void)
> -{
> -    MigrationState *s;
> -
> -    s = migrate_get_current();
> -
> -    return s->capabilities[MIGRATION_CAPABILITY_AUTO_CONVERGE];
> -}
> -
> -bool migrate_zero_blocks(void)
> -{
> -    MigrationState *s;
> -
> -    s = migrate_get_current();
> -
> -    return s->capabilities[MIGRATION_CAPABILITY_ZERO_BLOCKS];
> -}
> -
> -bool migrate_postcopy_blocktime(void)
> -{
> -    MigrationState *s;
> -
> -    s = migrate_get_current();
> -
> -    return s->capabilities[MIGRATION_CAPABILITY_POSTCOPY_BLOCKTIME];
> -}
> -
>  bool migrate_use_compression(void)
>  {
>      MigrationState *s;
> @@ -2618,33 +2565,6 @@ int migrate_decompress_threads(void)
>      return s->parameters.decompress_threads;
>  }
>  
> -bool migrate_dirty_bitmaps(void)
> -{
> -    MigrationState *s;
> -
> -    s = migrate_get_current();
> -
> -    return s->capabilities[MIGRATION_CAPABILITY_DIRTY_BITMAPS];
> -}
> -
> -bool migrate_ignore_shared(void)
> -{
> -    MigrationState *s;
> -
> -    s = migrate_get_current();
> -
> -    return s->capabilities[MIGRATION_CAPABILITY_X_IGNORE_SHARED];
> -}
> -
> -bool migrate_validate_uuid(void)
> -{
> -    MigrationState *s;
> -
> -    s = migrate_get_current();
> -
> -    return s->capabilities[MIGRATION_CAPABILITY_VALIDATE_UUID];
> -}
> -
>  bool migrate_use_events(void)
>  {
>      MigrationState *s;
> @@ -2663,15 +2583,6 @@ bool migrate_use_multifd(void)
>      return s->capabilities[MIGRATION_CAPABILITY_MULTIFD];
>  }
>  
> -bool migrate_pause_before_switchover(void)
> -{
> -    MigrationState *s;
> -
> -    s = migrate_get_current();
> -
> -    return s->capabilities[MIGRATION_CAPABILITY_PAUSE_BEFORE_SWITCHOVER];
> -}
> -
>  int migrate_multifd_channels(void)
>  {
>      MigrationState *s;
> @@ -2783,24 +2694,6 @@ bool migrate_use_block_incremental(void)
>      return s->parameters.block_incremental;
>  }
>  
> -bool migrate_background_snapshot(void)
> -{
> -    MigrationState *s;
> -
> -    s = migrate_get_current();
> -
> -    return s->capabilities[MIGRATION_CAPABILITY_BACKGROUND_SNAPSHOT];
> -}
> -
> -bool migrate_postcopy_preempt(void)
> -{
> -    MigrationState *s;
> -
> -    s = migrate_get_current();
> -
> -    return s->capabilities[MIGRATION_CAPABILITY_POSTCOPY_PREEMPT];
> -}
> -
>  /* migration thread support */
>  /*
>   * Something bad happened to the RP stream, mark an error
> diff --git a/migration/options.c b/migration/options.c
> new file mode 100644
> index 0000000000..47337a9a29
> --- /dev/null
> +++ b/migration/options.c
> @@ -0,0 +1,126 @@
> +/*
> + * QEMU migration capabilities
> + *
> + * Copyright IBM, Corp. 2008
> + *
> + * Authors:
> + *  Anthony Liguori   <aliguori@us.ibm.com>
> + *
> + * This work is licensed under the terms of the GNU GPL, version 2.  See
> + * the COPYING file in the top-level directory.
> + *
> + * Contributions after 2012-01-13 are licensed under the terms of the
> + * GNU GPL, version 2 or (at your option) any later version.
> + */
> +
> +#include "qemu/osdep.h"
> +#include "migration.h"
> +#include "options.h"
> +
> +bool migrate_auto_converge(void)
> +{
> +    MigrationState *s;
> +
> +    s = migrate_get_current();
> +
> +    return s->capabilities[MIGRATION_CAPABILITY_AUTO_CONVERGE];
> +}
> +
> +bool migrate_background_snapshot(void)
> +{
> +    MigrationState *s;
> +
> +    s = migrate_get_current();
> +
> +    return s->capabilities[MIGRATION_CAPABILITY_BACKGROUND_SNAPSHOT];
> +}
> +
> +bool migrate_dirty_bitmaps(void)
> +{
> +    MigrationState *s;
> +
> +    s = migrate_get_current();
> +
> +    return s->capabilities[MIGRATION_CAPABILITY_DIRTY_BITMAPS];
> +}
> +
> +bool migrate_ignore_shared(void)
> +{
> +    MigrationState *s;
> +
> +    s = migrate_get_current();
> +
> +    return s->capabilities[MIGRATION_CAPABILITY_X_IGNORE_SHARED];
> +}
> +
> +bool migrate_late_block_activate(void)
> +{
> +    MigrationState *s;
> +
> +    s = migrate_get_current();
> +
> +    return s->capabilities[MIGRATION_CAPABILITY_LATE_BLOCK_ACTIVATE];
> +}
> +
> +bool migrate_pause_before_switchover(void)
> +{
> +    MigrationState *s;
> +
> +    s = migrate_get_current();
> +
> +    return s->capabilities[MIGRATION_CAPABILITY_PAUSE_BEFORE_SWITCHOVER];
> +}
> +
> +bool migrate_postcopy_blocktime(void)
> +{
> +    MigrationState *s;
> +
> +    s = migrate_get_current();
> +
> +    return s->capabilities[MIGRATION_CAPABILITY_POSTCOPY_BLOCKTIME];
> +}
> +
> +bool migrate_postcopy_preempt(void)
> +{
> +    MigrationState *s;
> +
> +    s = migrate_get_current();
> +
> +    return s->capabilities[MIGRATION_CAPABILITY_POSTCOPY_PREEMPT];
> +}
> +
> +bool migrate_postcopy_ram(void)
> +{
> +    MigrationState *s;
> +
> +    s = migrate_get_current();
> +
> +    return s->capabilities[MIGRATION_CAPABILITY_POSTCOPY_RAM];
> +}
> +
> +bool migrate_release_ram(void)
> +{
> +    MigrationState *s;
> +
> +    s = migrate_get_current();
> +
> +    return s->capabilities[MIGRATION_CAPABILITY_RELEASE_RAM];
> +}
> +
> +bool migrate_validate_uuid(void)
> +{
> +    MigrationState *s;
> +
> +    s = migrate_get_current();
> +
> +    return s->capabilities[MIGRATION_CAPABILITY_VALIDATE_UUID];
> +}
> +
> +bool migrate_zero_blocks(void)
> +{
> +    MigrationState *s;
> +
> +    s = migrate_get_current();
> +
> +    return s->capabilities[MIGRATION_CAPABILITY_ZERO_BLOCKS];
> +}
> diff --git a/migration/postcopy-ram.c b/migration/postcopy-ram.c
> index f54f44d899..ce41670466 100644
> --- a/migration/postcopy-ram.c
> +++ b/migration/postcopy-ram.c
> @@ -36,6 +36,7 @@
>  #include "yank_functions.h"
>  #include "tls.h"
>  #include "qemu/userfaultfd.h"
> +#include "options.h"
>  
>  /* Arbitrary limit on size of each discard command,
>   * keeps them around ~200 bytes
> diff --git a/migration/ram.c b/migration/ram.c
> index af749b369b..1c786eb8f4 100644
> --- a/migration/ram.c
> +++ b/migration/ram.c
> @@ -57,6 +57,7 @@
>  #include "qemu/iov.h"
>  #include "multifd.h"
>  #include "sysemu/runstate.h"
> +#include "options.h"
>  
>  #include "hw/boards.h" /* for machine_dump_guest_core() */
>  
> diff --git a/migration/savevm.c b/migration/savevm.c
> index 589ef926ab..ebcf571e37 100644
> --- a/migration/savevm.c
> +++ b/migration/savevm.c
> @@ -67,6 +67,7 @@
>  #include "qemu/yank.h"
>  #include "yank_functions.h"
>  #include "sysemu/qtest.h"
> +#include "options.h"
>  
>  const unsigned int postcopy_ram_discard_version;
>  
> diff --git a/migration/socket.c b/migration/socket.c
> index e6fdf3c5e1..ebf9ac41af 100644
> --- a/migration/socket.c
> +++ b/migration/socket.c
> @@ -27,6 +27,7 @@
>  #include "io/net-listener.h"
>  #include "trace.h"
>  #include "postcopy-ram.h"
> +#include "options.h"
>  
>  struct SocketOutgoingArgs {
>      SocketAddress *saddr;
> diff --git a/migration/meson.build b/migration/meson.build
> index 0d1bb9f96e..480ff6854a 100644
> --- a/migration/meson.build
> +++ b/migration/meson.build
> @@ -22,6 +22,7 @@ softmmu_ss.add(files(
>    'migration.c',
>    'multifd.c',
>    'multifd-zlib.c',
> +  'options.c',
>    'postcopy-ram.c',
>    'savevm.c',
>    'socket.c',
> -- 
> 2.39.2
>
Juan Quintela April 20, 2023, 1:02 p.m. UTC | #2
"Dr. David Alan Gilbert" <dgilbert@redhat.com> wrote:
> * Juan Quintela (quintela@redhat.com) wrote:
>> We move there all capabilities helpers from migration.c.
>> 
>> Signed-off-by: Juan Quintela <quintela@redhat.com>

>> --- /dev/null
>> +++ b/migration/options.h
>> @@ -0,0 +1,34 @@
>> +/*
>> + * QEMU migration options
>> + *
>> + * Copyright IBM, Corp. 2008
>> + *
>> + * Authors:
>> + *  Anthony Liguori   <aliguori@us.ibm.com>
>> + *
>> + * This work is licensed under the terms of the GNU GPL, version 2.  See
>> + * the COPYING file in the top-level directory.
>> + *
>> + * Contributions after 2012-01-13 are licensed under the terms of the
>> + * GNU GPL, version 2 or (at your option) any later version.
>
> I don't think any of these functions were written by Anthony, and I

I investigated, and the creator of enabled_capabilities is:

commit bbf6da32b5bd32018069e4eaeda59a02855903f2
Author: Orit Wasserman <owasserm@redhat.com>
Date:   Mon Aug 6 21:42:47 2012 +0300

    Add migration capabilities


> think they're all after 2012 aren't they?

We are ... by 8 months O:-)

> If so we can update to a more modern header.

/*
 * QEMU migration capabilities
 *
 * Copyright (c) 2012-2023 Red Hat Inc
 *
 * Authors:
 *   Orit Wasserman <owasserm@redhat.com>
 *   Juan Quintela <quintela@redhat.com>
 *
 * This work is licensed under the terms of the GNU GPL, version 2 or later.
 * See the COPYING file in the top-level directory.
 */

I put Orit and myself. Peter Xu has also done quite a bit of work here.
Rest of people have just added capabilities for its stuff.

But if anyone feel that they need/want to be added, just ask.

> Other than that,

Thanks, Juan.

>
> Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
diff mbox series

Patch

diff --git a/migration/migration.h b/migration/migration.h
index b07efaf259..68851e485d 100644
--- a/migration/migration.h
+++ b/migration/migration.h
@@ -410,16 +410,7 @@  MigrationState *migrate_get_current(void);
 
 bool migrate_postcopy(void);
 
-bool migrate_release_ram(void);
-bool migrate_postcopy_ram(void);
-bool migrate_zero_blocks(void);
-bool migrate_dirty_bitmaps(void);
-bool migrate_ignore_shared(void);
-bool migrate_validate_uuid(void);
-
-bool migrate_auto_converge(void);
 bool migrate_use_multifd(void);
-bool migrate_pause_before_switchover(void);
 int migrate_multifd_channels(void);
 MultiFDCompression migrate_multifd_compression(void);
 int migrate_multifd_zlib_level(void);
@@ -448,9 +439,6 @@  int migrate_compress_threads(void);
 int migrate_compress_wait_thread(void);
 int migrate_decompress_threads(void);
 bool migrate_use_events(void);
-bool migrate_postcopy_blocktime(void);
-bool migrate_background_snapshot(void);
-bool migrate_postcopy_preempt(void);
 
 /* Sending on the return path - generic and then for each message type */
 void migrate_send_rp_shut(MigrationIncomingState *mis,
diff --git a/migration/options.h b/migration/options.h
new file mode 100644
index 0000000000..bae032375a
--- /dev/null
+++ b/migration/options.h
@@ -0,0 +1,34 @@ 
+/*
+ * QEMU migration options
+ *
+ * Copyright IBM, Corp. 2008
+ *
+ * Authors:
+ *  Anthony Liguori   <aliguori@us.ibm.com>
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2.  See
+ * the COPYING file in the top-level directory.
+ *
+ * Contributions after 2012-01-13 are licensed under the terms of the
+ * GNU GPL, version 2 or (at your option) any later version.
+ */
+
+#ifndef QEMU_MIGRATION_OPTIONS_H
+#define QEMU_MIGRATION_OPTIONS_H
+
+/* capabilities */
+
+bool migrate_auto_converge(void);
+bool migrate_background_snapshot(void);
+bool migrate_dirty_bitmaps(void);
+bool migrate_ignore_shared(void);
+bool migrate_late_block_activate(void);
+bool migrate_pause_before_switchover(void);
+bool migrate_postcopy_blocktime(void);
+bool migrate_postcopy_preempt(void);
+bool migrate_postcopy_ram(void);
+bool migrate_release_ram(void);
+bool migrate_validate_uuid(void);
+bool migrate_zero_blocks(void);
+
+#endif
diff --git a/hw/virtio/virtio-balloon.c b/hw/virtio/virtio-balloon.c
index 746f07c4d2..43092aa634 100644
--- a/hw/virtio/virtio-balloon.c
+++ b/hw/virtio/virtio-balloon.c
@@ -32,6 +32,7 @@ 
 #include "qemu/error-report.h"
 #include "migration/misc.h"
 #include "migration/migration.h"
+#include "migration/options.h"
 
 #include "hw/virtio/virtio-bus.h"
 #include "hw/virtio/virtio-access.h"
diff --git a/migration/block-dirty-bitmap.c b/migration/block-dirty-bitmap.c
index fe73aa94b1..a6ffae0002 100644
--- a/migration/block-dirty-bitmap.c
+++ b/migration/block-dirty-bitmap.c
@@ -79,6 +79,7 @@ 
 #include "qapi/qapi-visit-migration.h"
 #include "qapi/clone-visitor.h"
 #include "trace.h"
+#include "options.h"
 
 #define CHUNK_SIZE     (1 << 10)
 
diff --git a/migration/block.c b/migration/block.c
index 426a25bb19..c4fe9fea56 100644
--- a/migration/block.c
+++ b/migration/block.c
@@ -28,6 +28,7 @@ 
 #include "migration/vmstate.h"
 #include "sysemu/block-backend.h"
 #include "trace.h"
+#include "options.h"
 
 #define BLK_MIG_BLOCK_SIZE           (1ULL << 20)
 #define BDRV_SECTORS_PER_DIRTY_CHUNK (BLK_MIG_BLOCK_SIZE >> BDRV_SECTOR_BITS)
diff --git a/migration/colo.c b/migration/colo.c
index 0716e64689..93b78c9270 100644
--- a/migration/colo.c
+++ b/migration/colo.c
@@ -36,6 +36,7 @@ 
 #include "sysemu/cpus.h"
 #include "sysemu/runstate.h"
 #include "net/filter.h"
+#include "options.h"
 
 static bool vmstate_loading;
 static Notifier packets_compare_notifier;
diff --git a/migration/migration.c b/migration/migration.c
index e3062530f0..790848ef1c 100644
--- a/migration/migration.c
+++ b/migration/migration.c
@@ -63,6 +63,7 @@ 
 #include "sysemu/cpus.h"
 #include "yank_functions.h"
 #include "sysemu/qtest.h"
+#include "options.h"
 
 #define MAX_THROTTLE  (128 << 20)      /* Migration transfer speed throttling */
 
@@ -357,15 +358,6 @@  static void migrate_generate_event(int new_state)
     }
 }
 
-static bool migrate_late_block_activate(void)
-{
-    MigrationState *s;
-
-    s = migrate_get_current();
-
-    return s->capabilities[MIGRATION_CAPABILITY_LATE_BLOCK_ACTIVATE];
-}
-
 /*
  * Send a message on the return channel back to the source
  * of the migration.
@@ -2523,56 +2515,11 @@  void qmp_migrate_continue(MigrationStatus state, Error **errp)
     qemu_sem_post(&s->pause_sem);
 }
 
-bool migrate_release_ram(void)
-{
-    MigrationState *s;
-
-    s = migrate_get_current();
-
-    return s->capabilities[MIGRATION_CAPABILITY_RELEASE_RAM];
-}
-
-bool migrate_postcopy_ram(void)
-{
-    MigrationState *s;
-
-    s = migrate_get_current();
-
-    return s->capabilities[MIGRATION_CAPABILITY_POSTCOPY_RAM];
-}
-
 bool migrate_postcopy(void)
 {
     return migrate_postcopy_ram() || migrate_dirty_bitmaps();
 }
 
-bool migrate_auto_converge(void)
-{
-    MigrationState *s;
-
-    s = migrate_get_current();
-
-    return s->capabilities[MIGRATION_CAPABILITY_AUTO_CONVERGE];
-}
-
-bool migrate_zero_blocks(void)
-{
-    MigrationState *s;
-
-    s = migrate_get_current();
-
-    return s->capabilities[MIGRATION_CAPABILITY_ZERO_BLOCKS];
-}
-
-bool migrate_postcopy_blocktime(void)
-{
-    MigrationState *s;
-
-    s = migrate_get_current();
-
-    return s->capabilities[MIGRATION_CAPABILITY_POSTCOPY_BLOCKTIME];
-}
-
 bool migrate_use_compression(void)
 {
     MigrationState *s;
@@ -2618,33 +2565,6 @@  int migrate_decompress_threads(void)
     return s->parameters.decompress_threads;
 }
 
-bool migrate_dirty_bitmaps(void)
-{
-    MigrationState *s;
-
-    s = migrate_get_current();
-
-    return s->capabilities[MIGRATION_CAPABILITY_DIRTY_BITMAPS];
-}
-
-bool migrate_ignore_shared(void)
-{
-    MigrationState *s;
-
-    s = migrate_get_current();
-
-    return s->capabilities[MIGRATION_CAPABILITY_X_IGNORE_SHARED];
-}
-
-bool migrate_validate_uuid(void)
-{
-    MigrationState *s;
-
-    s = migrate_get_current();
-
-    return s->capabilities[MIGRATION_CAPABILITY_VALIDATE_UUID];
-}
-
 bool migrate_use_events(void)
 {
     MigrationState *s;
@@ -2663,15 +2583,6 @@  bool migrate_use_multifd(void)
     return s->capabilities[MIGRATION_CAPABILITY_MULTIFD];
 }
 
-bool migrate_pause_before_switchover(void)
-{
-    MigrationState *s;
-
-    s = migrate_get_current();
-
-    return s->capabilities[MIGRATION_CAPABILITY_PAUSE_BEFORE_SWITCHOVER];
-}
-
 int migrate_multifd_channels(void)
 {
     MigrationState *s;
@@ -2783,24 +2694,6 @@  bool migrate_use_block_incremental(void)
     return s->parameters.block_incremental;
 }
 
-bool migrate_background_snapshot(void)
-{
-    MigrationState *s;
-
-    s = migrate_get_current();
-
-    return s->capabilities[MIGRATION_CAPABILITY_BACKGROUND_SNAPSHOT];
-}
-
-bool migrate_postcopy_preempt(void)
-{
-    MigrationState *s;
-
-    s = migrate_get_current();
-
-    return s->capabilities[MIGRATION_CAPABILITY_POSTCOPY_PREEMPT];
-}
-
 /* migration thread support */
 /*
  * Something bad happened to the RP stream, mark an error
diff --git a/migration/options.c b/migration/options.c
new file mode 100644
index 0000000000..47337a9a29
--- /dev/null
+++ b/migration/options.c
@@ -0,0 +1,126 @@ 
+/*
+ * QEMU migration capabilities
+ *
+ * Copyright IBM, Corp. 2008
+ *
+ * Authors:
+ *  Anthony Liguori   <aliguori@us.ibm.com>
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2.  See
+ * the COPYING file in the top-level directory.
+ *
+ * Contributions after 2012-01-13 are licensed under the terms of the
+ * GNU GPL, version 2 or (at your option) any later version.
+ */
+
+#include "qemu/osdep.h"
+#include "migration.h"
+#include "options.h"
+
+bool migrate_auto_converge(void)
+{
+    MigrationState *s;
+
+    s = migrate_get_current();
+
+    return s->capabilities[MIGRATION_CAPABILITY_AUTO_CONVERGE];
+}
+
+bool migrate_background_snapshot(void)
+{
+    MigrationState *s;
+
+    s = migrate_get_current();
+
+    return s->capabilities[MIGRATION_CAPABILITY_BACKGROUND_SNAPSHOT];
+}
+
+bool migrate_dirty_bitmaps(void)
+{
+    MigrationState *s;
+
+    s = migrate_get_current();
+
+    return s->capabilities[MIGRATION_CAPABILITY_DIRTY_BITMAPS];
+}
+
+bool migrate_ignore_shared(void)
+{
+    MigrationState *s;
+
+    s = migrate_get_current();
+
+    return s->capabilities[MIGRATION_CAPABILITY_X_IGNORE_SHARED];
+}
+
+bool migrate_late_block_activate(void)
+{
+    MigrationState *s;
+
+    s = migrate_get_current();
+
+    return s->capabilities[MIGRATION_CAPABILITY_LATE_BLOCK_ACTIVATE];
+}
+
+bool migrate_pause_before_switchover(void)
+{
+    MigrationState *s;
+
+    s = migrate_get_current();
+
+    return s->capabilities[MIGRATION_CAPABILITY_PAUSE_BEFORE_SWITCHOVER];
+}
+
+bool migrate_postcopy_blocktime(void)
+{
+    MigrationState *s;
+
+    s = migrate_get_current();
+
+    return s->capabilities[MIGRATION_CAPABILITY_POSTCOPY_BLOCKTIME];
+}
+
+bool migrate_postcopy_preempt(void)
+{
+    MigrationState *s;
+
+    s = migrate_get_current();
+
+    return s->capabilities[MIGRATION_CAPABILITY_POSTCOPY_PREEMPT];
+}
+
+bool migrate_postcopy_ram(void)
+{
+    MigrationState *s;
+
+    s = migrate_get_current();
+
+    return s->capabilities[MIGRATION_CAPABILITY_POSTCOPY_RAM];
+}
+
+bool migrate_release_ram(void)
+{
+    MigrationState *s;
+
+    s = migrate_get_current();
+
+    return s->capabilities[MIGRATION_CAPABILITY_RELEASE_RAM];
+}
+
+bool migrate_validate_uuid(void)
+{
+    MigrationState *s;
+
+    s = migrate_get_current();
+
+    return s->capabilities[MIGRATION_CAPABILITY_VALIDATE_UUID];
+}
+
+bool migrate_zero_blocks(void)
+{
+    MigrationState *s;
+
+    s = migrate_get_current();
+
+    return s->capabilities[MIGRATION_CAPABILITY_ZERO_BLOCKS];
+}
diff --git a/migration/postcopy-ram.c b/migration/postcopy-ram.c
index f54f44d899..ce41670466 100644
--- a/migration/postcopy-ram.c
+++ b/migration/postcopy-ram.c
@@ -36,6 +36,7 @@ 
 #include "yank_functions.h"
 #include "tls.h"
 #include "qemu/userfaultfd.h"
+#include "options.h"
 
 /* Arbitrary limit on size of each discard command,
  * keeps them around ~200 bytes
diff --git a/migration/ram.c b/migration/ram.c
index af749b369b..1c786eb8f4 100644
--- a/migration/ram.c
+++ b/migration/ram.c
@@ -57,6 +57,7 @@ 
 #include "qemu/iov.h"
 #include "multifd.h"
 #include "sysemu/runstate.h"
+#include "options.h"
 
 #include "hw/boards.h" /* for machine_dump_guest_core() */
 
diff --git a/migration/savevm.c b/migration/savevm.c
index 589ef926ab..ebcf571e37 100644
--- a/migration/savevm.c
+++ b/migration/savevm.c
@@ -67,6 +67,7 @@ 
 #include "qemu/yank.h"
 #include "yank_functions.h"
 #include "sysemu/qtest.h"
+#include "options.h"
 
 const unsigned int postcopy_ram_discard_version;
 
diff --git a/migration/socket.c b/migration/socket.c
index e6fdf3c5e1..ebf9ac41af 100644
--- a/migration/socket.c
+++ b/migration/socket.c
@@ -27,6 +27,7 @@ 
 #include "io/net-listener.h"
 #include "trace.h"
 #include "postcopy-ram.h"
+#include "options.h"
 
 struct SocketOutgoingArgs {
     SocketAddress *saddr;
diff --git a/migration/meson.build b/migration/meson.build
index 0d1bb9f96e..480ff6854a 100644
--- a/migration/meson.build
+++ b/migration/meson.build
@@ -22,6 +22,7 @@  softmmu_ss.add(files(
   'migration.c',
   'multifd.c',
   'multifd-zlib.c',
+  'options.c',
   'postcopy-ram.c',
   'savevm.c',
   'socket.c',