Skip to contentSkip to conversation

Migration pull request

GIT PULL Applied Juan Quintela 2 participants 11 messages May 18, 2017 – May 19, 2017

lore
Share & tools
lore
#0 lore raw

Hi

This include the following series:
- Fix non-multiple of page size migraition (dave)
- Remove use of old MigrationParms (a.k.a. now block migration is a capability)
- Cleanups of headers in migration
- Make savevm.c target independent

Please, apply.

Thanks, Juan.

The following changes since commit 56821559f0ba682fe6b367815572e6f974d329ab:

Merge remote-tracking branch 'dgilbert/tags/pull-hmp-20170517' into staging (2017-05-18 13:36:15 +0100)

are available in the git repository at:

git://github.com/juanquintela/qemu.git tags/migration/20170518

for you to fetch changes up to 46d702b106d20beda2fcd0f96ddc44855ba262b3:

migration: Make savevm.c target independent (2017-05-18 19:21:00 +0200)

----------------------------------------------------------------
migration/next for 20170518

----------------------------------------------------------------
Dr. David Alan Gilbert (3):
migration: Fix non-multiple of page size migration
postcopy: Require RAMBlocks that are whole pages block migration: Allow compile time disable

Juan Quintela (15):
hmp: Use visitor api for hmp_migrate_set_parameter()
migration: Create block capability
migration: Remove use of old MigrationParams
migration: Remove old MigrationParams
migration: Create migration/xbzrle.h
migration: Split migration/channel.c for channel operations
migration: Export qemu-file-channel.c functions in its own file
migration: Remove migration.h from colo.h
migration: Move qjson.h to migration/
migration: Split vmstate-types.c from vmstate.c
migration: Remove qemu-file.h from vmstate.h
migration: Remove vmstate.h from migration.h
migration: migration.h was not needed
exec: Create include for target_page_size()
migration: Make savevm.c target independent

 Makefile.target                          |   2 +-
 block/qed.c                              |   1 -
 configure                                |  11 +
 exec.c                                   |  10 +
 hmp.c                                    |  23 +-
 hw/i386/pc_q35.c                         |   1 -
 hw/virtio/vhost-user.c                   |   1 -
 hw/virtio/vhost-vsock.c                  |   1 -
 hw/virtio/virtio.c                       |   1 -
 include/exec/target_page.h               |  21 +
 include/hw/hw.h                          |   1 +
 include/migration/block.h                |  24 ++
 include/migration/colo.h                 |   1 -
 include/migration/migration.h            |  30 +-
 include/migration/qemu-file.h            |   4 -
 include/migration/vmstate.h              |   4 -
 include/qemu/typedefs.h                  |   1 -
 include/sysemu/sysemu.h                  |   4 +-
 migration/Makefile.objs                  |   6 +-
 migration/block.c                        |  19 +-
 migration/channel.c                      |  67 ++++
 migration/channel.h                      |  27 ++
 migration/colo-comm.c                    |   4 +-
 migration/colo.c                         |   9 +-
 migration/exec.c                         |   1 +
 migration/fd.c                           |   1 +
 migration/migration.c                    | 149 ++++---
 migration/postcopy-ram.c                 |  18 +-
 migration/qemu-file-channel.c            |   1 +
 migration/qemu-file-channel.h            |  32 ++
 migration/qjson.c                        |   2 +-
 {include/migration => migration}/qjson.h |   0
 migration/ram.c                          |   8 +-
 migration/rdma.c                         |   1 +
 migration/savevm.c                       |  40 +-
 migration/socket.c                       |   1 +
 migration/tls.c                          |   1 +
 migration/vmstate-types.c                | 661 +++++++++++++++++++++++++++++++
 migration/vmstate.c                      | 656 +-----------------------------
 migration/xbzrle.c                       |   2 +-
 migration/xbzrle.h                       |  21 +
 monitor.c                                |   1 -
 qapi-schema.json                         |  28 +-
 tests/Makefile.include                   |   2 +-
 tests/test-vmstate.c                     |   2 +
 tests/test-xbzrle.c                      |   2 +-
 46 files changed, 1102 insertions(+), 801 deletions(-)
 create mode 100644 include/exec/target_page.h
 create mode 100644 migration/channel.c
 create mode 100644 migration/channel.h
 create mode 100644 migration/qemu-file-channel.h
 rename {include/migration => migration}/qjson.h (100%)
 create mode 100644 migration/vmstate-types.c
 create mode 100644 migration/xbzrle.h
#1 lore raw

[Qemu-devel] [PULL 02/18] postcopy: Require RAMBlocks that are whole pages

From: "Dr. David Alan Gilbert" <[email protected]>

It turns out that it's legal to create a VM with RAMBlocks that aren't a multiple of the pagesize in use; e.g. a 1025M main memory using 2M host pages. That breaks postcopy's atomic placement of pages, so disallow it.

---
 migration/postcopy-ram.c | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)
migration/postcopy-ram.c +13 -3
index a0489f6..63b8501 100644
@@ -96,14 +96,24 @@ static bool ufd_version_check(int ufd)
 
 /* Callback from postcopy_ram_supported_by_host block iterator.
  */
-static int test_range_shared(const char *block_name, void *host_addr,
+static int test_ramblock_postcopiable(const char *block_name, void *host_addr,
                              ram_addr_t offset, ram_addr_t length, void *opaque)
 {
-    if (qemu_ram_is_shared(qemu_ram_block_by_name(block_name))) {
+    RAMBlock *rb = qemu_ram_block_by_name(block_name);
+    size_t pagesize = qemu_ram_pagesize(rb);
+
+    if (qemu_ram_is_shared(rb)) {
         error_report("Postcopy on shared RAM (%s) is not yet supported",
                      block_name);
         return 1;
     }
+
+    if (length % pagesize) {
+        error_report("Postcopy requires RAM blocks to be a page size multiple,"
+                     " block %s is 0x" RAM_ADDR_FMT " bytes with a "
+                     "page size of 0x%zx", block_name, length, pagesize);
+        return 1;
+    }
     return 0;
 }
 
@@ -140,7 +150,7 @@ bool postcopy_ram_supported_by_host(void)
     }
 
     /* We don't support postcopy with shared RAM yet */
-    if (qemu_ram_foreach_block(test_range_shared, NULL)) {
+    if (qemu_ram_foreach_block(test_ramblock_postcopiable, NULL)) {
         goto out;
     }
 
Signature · 1 line
2.9.3
#2 lore raw

[Qemu-devel] [PULL 01/18] migration: Fix non-multiple of page size migration

In reply to Juan Quintela

From: "Dr. David Alan Gilbert" <[email protected]>

Unfortunately it's legal to create a VM with a RAM size that's not a multiple of the underlying host page or huge page size. Recently I'd changed things to always send host sized pages, and that breaks if we have say a 1025MB guest on 2MB hugepages.

Unfortunately we can't just make that illegal since it would break migration from/to existing oddly configured VMs.

Symptom: qemu-system-x86_64: Illegal RAM offset 40100000
as it transmits the fraction of the hugepage after the end of the RAMBlock (may also cause a crash on the source
- possibly due to clearing bits after the bitmap)

Red Hat bug: https://bugzilla.redhat.com/show_bug.cgi?id=1449037

---
 migration/ram.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
migration/ram.c +4 -1
index f59fdd4..59459ef 100644
@@ -1312,6 +1312,8 @@ static int ram_save_target_page(RAMState *rs, PageSearchStatus *pss,
  * a host page in which case the remainder of the hostpage is sent.
  * Only dirty target pages are sent. Note that the host page size may
  * be a huge page for this block.
+ * The saving stops at the boundary of the used_length of the block
+ * if the RAMBlock isn't a multiple of the host page size.
  *
  * Returns the number of pages written or negative on error
  *
@@ -1335,7 +1337,8 @@ static int ram_save_host_page(RAMState *rs, PageSearchStatus *pss,
 
         pages += tmppages;
         pss->page++;
-    } while (pss->page & (pagesize_bits - 1));
+    } while ((pss->page & (pagesize_bits - 1)) &&
+             offset_in_ramblock(pss->block, pss->page << TARGET_PAGE_BITS));
 
     /* The offset we leave with is the last one we looked at */
     pss->page--;
Signature · 1 line
2.9.3
#3 lore raw

[Qemu-devel] [PULL 03/18] hmp: Use visitor api for hmp_migrate_set_parameter()

In reply to Juan Quintela

We only use it for int64 at this point, I am not able to find a way to parse an int with MiB units.

---
 hmp.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
hmp.c +6 -4
index 3dceaf8..83e45c8 100644
@@ -29,6 +29,7 @@
 #include "monitor/qdev.h"
 #include "qapi/opts-visitor.h"
 #include "qapi/qmp/qerror.h"
+#include "qapi/string-input-visitor.h"
 #include "qapi/string-output-visitor.h"
 #include "qapi/util.h"
 #include "qapi-visit.h"
@@ -1524,8 +1525,9 @@ void hmp_migrate_set_parameter(Monitor *mon, const QDict *qdict)
 {
     const char *param = qdict_get_str(qdict, "parameter");
     const char *valuestr = qdict_get_str(qdict, "value");
+    Visitor *v = string_input_visitor_new(valuestr);
     uint64_t valuebw = 0;
-    long valueint = 0;
+    int64_t valueint = 0;
     Error *err = NULL;
     bool use_int_value = false;
     int i, ret;
@@ -1583,9 +1585,8 @@ void hmp_migrate_set_parameter(Monitor *mon, const QDict *qdict)
             }
 
             if (use_int_value) {
-                if (qemu_strtol(valuestr, NULL, 10, &valueint) < 0) {
-                    error_setg(&err, "Unable to parse '%s' as an int",
-                               valuestr);
+                visit_type_int(v, param, &valueint, &err);
+                if (err) {
                     goto cleanup;
                 }
                 /* Set all integers; only one has_FOO will be set, and
@@ -1609,6 +1610,7 @@ void hmp_migrate_set_parameter(Monitor *mon, const QDict *qdict)
     }
 
  cleanup:
+    visit_free(v);
     if (err) {
         error_report_err(err);
     }
Signature · 1 line
2.9.3
#4 lore raw

[Qemu-devel] [PULL 04/18] migration: Create block capability

In reply to Juan Quintela

Create one capability for block migration and one parameter for incremental block migration.

---

- address all Markus comments
- use Markus and Eric text descriptions
- change logic another time
- improve text messages

---
 hmp.c                         | 13 ++++++++
 include/migration/block.h     |  2 ++
 include/migration/migration.h |  6 ++++
 migration/migration.c         | 71 +++++++++++++++++++++++++++++++++++++++++++
 qapi-schema.json              | 28 +++++++++++++++--
 5 files changed, 117 insertions(+), 3 deletions(-)
hmp.c +13 -0
index 83e45c8..20f5dab 100644
@@ -327,6 +327,10 @@ void hmp_info_migrate_parameters(Monitor *mon, const QDict *qdict)
         monitor_printf(mon, "%s: %" PRId64 "\n",
             MigrationParameter_lookup[MIGRATION_PARAMETER_X_CHECKPOINT_DELAY],
             params->x_checkpoint_delay);
+        assert(params->has_block_incremental);
+        monitor_printf(mon, "%s: %s\n",
+            MigrationParameter_lookup[MIGRATION_PARAMETER_BLOCK_INCREMENTAL],
+                       params->block_incremental ? "on" : "off");
     }
 
     qapi_free_MigrationParameters(params);
@@ -1528,6 +1532,7 @@ void hmp_migrate_set_parameter(Monitor *mon, const QDict *qdict)
     Visitor *v = string_input_visitor_new(valuestr);
     uint64_t valuebw = 0;
     int64_t valueint = 0;
+    bool valuebool = false;
     Error *err = NULL;
     bool use_int_value = false;
     int i, ret;
@@ -1582,6 +1587,14 @@ void hmp_migrate_set_parameter(Monitor *mon, const QDict *qdict)
                 p.has_x_checkpoint_delay = true;
                 use_int_value = true;
                 break;
+            case MIGRATION_PARAMETER_BLOCK_INCREMENTAL:
+                p.has_block_incremental = true;
+                visit_type_bool(v, param, &valuebool, &err);
+                if (err) {
+                    goto cleanup;
+                }
+                p.block_incremental = valuebool;
+                break;
             }
 
             if (use_int_value) {
include/migration/block.h +2 -0
index 41a1ac8..5225af9 100644
@@ -20,4 +20,6 @@ uint64_t blk_mig_bytes_transferred(void);
 uint64_t blk_mig_bytes_remaining(void);
 uint64_t blk_mig_bytes_total(void);
 
+void migrate_set_block_enabled(bool value, Error **errp);
+
 #endif /* MIGRATION_BLOCK_H */
include/migration/migration.h +6 -0
index 49ec501..024a048 100644
@@ -153,6 +153,9 @@ struct MigrationState
 
     /* The last error that occurred */
     Error *error;
+    /* Do we have to clean up -b/-i from old migrate parameters */
+    /* This feature is deprecated and will be removed */
+    bool must_remove_block_options;
 };
 
 void migrate_set_state(int *state, int old_state, int new_state);
@@ -265,6 +268,9 @@ bool migrate_colo_enabled(void);
 
 int64_t xbzrle_cache_resize(int64_t new_size);
 
+bool migrate_use_block(void);
+bool migrate_use_block_incremental(void);
+
 bool migrate_use_compression(void);
 int migrate_compress_level(void);
 int migrate_compress_threads(void);
migration/migration.c +71 -0

119 lines not on this page · raw message

qapi-schema.json +25 -3
index 80603cf..e38c5f0 100644
@@ -894,11 +894,18 @@
 # @release-ram: if enabled, qemu will free the migrated ram pages on the source
 #        during postcopy-ram migration. (since 2.9)
 #
+# @block: If enabled, QEMU will also migrate the contents of all block
+#          devices.  Default is disabled.  A possible alternative uses
+#          mirror jobs to a builtin NBD server on the destination, which
+#          offers more flexibility.
+#          (Since 2.10)
+#
 # Since: 1.2
 ##
 { 'enum': 'MigrationCapability',
   'data': ['xbzrle', 'rdma-pin-all', 'auto-converge', 'zero-blocks',
-           'compress', 'events', 'postcopy-ram', 'x-colo', 'release-ram'] }
+           'compress', 'events', 'postcopy-ram', 'x-colo', 'release-ram',
+           'block' ] }
 
 ##
 # @MigrationCapabilityStatus:
@@ -1009,13 +1016,20 @@
 # @x-checkpoint-delay: The delay time (in ms) between two COLO checkpoints in
 #          periodic mode. (Since 2.8)
 #
+# @block-incremental: Affects how much storage is migrated when the
+# 	block migration capability is enabled.  When false, the entire
+# 	storage backing chain is migrated into a flattened image at
+# 	the destination; when true, only the active qcow2 layer is
+# 	migrated and the destination must already have access to the
+# 	same backing chain as was used on the source.  (since 2.10)
+#
 # Since: 2.4
 ##
 { 'enum': 'MigrationParameter',
   'data': ['compress-level', 'compress-threads', 'decompress-threads',
            'cpu-throttle-initial', 'cpu-throttle-increment',
            'tls-creds', 'tls-hostname', 'max-bandwidth',
-           'downtime-limit', 'x-checkpoint-delay' ] }
+           'downtime-limit', 'x-checkpoint-delay', 'block-incremental' ] }
 
 ##
 # @migrate-set-parameters:
@@ -1082,6 +1096,13 @@
 #
 # @x-checkpoint-delay: the delay time between two COLO checkpoints. (Since 2.8)
 #
+# @block-incremental: Affects how much storage is migrated when the
+# 	block migration capability is enabled.  When false, the entire
+# 	storage backing chain is migrated into a flattened image at
+# 	the destination; when true, only the active qcow2 layer is
+# 	migrated and the destination must already have access to the
+# 	same backing chain as was used on the source.  (since 2.10)
+#
 # Since: 2.4
 ##
 { 'struct': 'MigrationParameters',
@@ -1094,7 +1115,8 @@
             '*tls-hostname': 'str',
             '*max-bandwidth': 'int',
             '*downtime-limit': 'int',
-            '*x-checkpoint-delay': 'int'} }
+            '*x-checkpoint-delay': 'int',
+            '*block-incremental': 'bool' } }
 
 ##
 # @query-migrate-parameters:
Signature · 1 line
2.9.3
#5 lore raw

[Qemu-devel] [PULL 05/18] migration: Remove use of old MigrationParams

In reply to Juan Quintela

We have change in the previous patch to use migration capabilities for it. Notice that we continue using the old command line flags from migrate command from the time being. Remove the set_params method as now it is empty.

For savevm, one can't do a:

savevm -b/-i foo

but now one can do:

migrate_set_capability block on
savevm foo

And we can't use block migration. We could disable block capability unconditionally, but it would not be much better.

---
- Maintain shared/enabled dependency (Xu suggestion)
- Now we maintain the dependency on the setter functions
- improve error messages

---
 include/migration/migration.h |  3 +--
 migration/block.c             | 17 ++---------------
 migration/colo.c              |  4 ++--
 migration/migration.c         |  3 ---
 migration/savevm.c            |  8 ++++++--
 5 files changed, 11 insertions(+), 24 deletions(-)
include/migration/migration.h +1 -2
index 024a048..4dedc66 100644
@@ -39,8 +39,7 @@
 #define QEMU_VM_SECTION_FOOTER       0x7e
 
 struct MigrationParams {
-    bool blk;
-    bool shared;
+    bool unused; /* C doesn't allow empty structs */
 };
 
 /* Messages sent on the return path from destination to source */
migration/block.c +2 -15
index 060087f..5d22926 100644
@@ -94,9 +94,6 @@ typedef struct BlkMigBlock {
 } BlkMigBlock;
 
 typedef struct BlkMigState {
-    /* Written during setup phase.  Can be read without a lock.  */
-    int blk_enable;
-    int shared_base;
     QSIMPLEQ_HEAD(bmds_list, BlkMigDevState) bmds_list;
     int64_t total_sector_sum;
     bool zero_blocks;
@@ -425,7 +422,7 @@ static int init_blk_migration(QEMUFile *f)
         bmds->bulk_completed = 0;
         bmds->total_sectors = sectors;
         bmds->completed_sectors = 0;
-        bmds->shared_base = block_mig_state.shared_base;
+        bmds->shared_base = migrate_use_block_incremental();
 
         assert(i < num_bs);
         bmds_bs[i].bmds = bmds;
@@ -994,22 +991,12 @@ static int block_load(QEMUFile *f, void *opaque, int version_id)
     return 0;
 }
 
-static void block_set_params(const MigrationParams *params, void *opaque)
-{
-    block_mig_state.blk_enable = params->blk;
-    block_mig_state.shared_base = params->shared;
-
-    /* shared base means that blk_enable = 1 */
-    block_mig_state.blk_enable |= params->shared;
-}
-
 static bool block_is_active(void *opaque)
 {
-    return block_mig_state.blk_enable == 1;
+    return migrate_use_block();
 }
 
 static SaveVMHandlers savevm_block_handlers = {
-    .set_params = block_set_params,
     .save_live_setup = block_save_setup,
     .save_live_iterate = block_save_iterate,
     .save_live_complete_precopy = block_save_complete,
migration/colo.c +2 -2
index 963c802..8c86892 100644
@@ -14,6 +14,7 @@
 #include "qemu/timer.h"
 #include "sysemu/sysemu.h"
 #include "migration/colo.h"
+#include "migration/block.h"
 #include "io/channel-buffer.h"
 #include "trace.h"
 #include "qemu/error-report.h"
@@ -345,8 +346,7 @@ static int colo_do_checkpoint_transaction(MigrationState *s,
     }
 
     /* Disable block migration */
-    s->params.blk = 0;
-    s->params.shared = 0;
+    migrate_set_block_enabled(false, &local_err);
     qemu_savevm_state_header(fb);
     qemu_savevm_state_begin(fb, &s->params);
     qemu_mutex_lock_iothread();
migration/migration.c +0 -3
index c13c0a2..b3d300d 100644
@@ -1224,9 +1224,6 @@ void qmp_migrate(const char *uri, bool has_blk, bool blk,
     MigrationParams params;
     const char *p;
 
-    params.blk = has_blk && blk;
-    params.shared = has_inc && inc;
-
     if (migration_is_setup_or_active(s->state) ||
         s->state == MIGRATION_STATUS_CANCELLING ||
         s->state == MIGRATION_STATUS_COLO) {
migration/savevm.c +6 -2
index f5e8194..2f1f4eb 100644
@@ -1233,8 +1233,6 @@ static int qemu_savevm_state(QEMUFile *f, Error **errp)
 {
     int ret;
     MigrationParams params = {
-        .blk = 0,
-        .shared = 0
     };
     MigrationState *ms = migrate_init(&params);
     MigrationStatus status;
@@ -1245,6 +1243,12 @@ static int qemu_savevm_state(QEMUFile *f, Error **errp)
         goto done;
     }
 
+    if (migrate_use_block()) {
+        error_setg(errp, "Block migration and snapshots are incompatible");
+        ret = -EINVAL;
+        goto done;
+    }
+
     qemu_mutex_unlock_iothread();
     qemu_savevm_state_header(f);
     qemu_savevm_state_begin(f, &params);
Signature · 1 line
2.9.3
#6 lore raw

[Qemu-devel] [PULL 06/18] migration: Remove old MigrationParams

In reply to Juan Quintela

Not used anymore after moving block migration to use capabilities.

---
 include/migration/migration.h | 10 ++--------
 include/migration/vmstate.h   |  1 -
 include/qemu/typedefs.h       |  1 -
 include/sysemu/sysemu.h       |  3 +--
 migration/colo.c              |  2 +-
 migration/migration.c         |  8 +++-----
 migration/savevm.c            | 16 +++-------------
 7 files changed, 10 insertions(+), 31 deletions(-)
include/migration/migration.h +2 -8
index 4dedc66..b80a6ed 100644
@@ -38,10 +38,6 @@
 #define QEMU_VM_COMMAND              0x08
 #define QEMU_VM_SECTION_FOOTER       0x7e
 
-struct MigrationParams {
-    bool unused; /* C doesn't allow empty structs */
-};
-
 /* Messages sent on the return path from destination to source */
 enum mig_rp_message_type {
     MIG_RP_MSG_INVALID = 0,  /* Must be 0 */
@@ -109,12 +105,10 @@ struct MigrationState
     QEMUBH *cleanup_bh;
     QEMUFile *to_dst_file;
 
-    /* New style params from 'migrate-set-parameters' */
+    /* params from 'migrate-set-parameters' */
     MigrationParameters parameters;
 
     int state;
-    /* Old style params from 'migrate' command */
-    MigrationParams params;
 
     /* State related to return path */
     struct {
@@ -207,7 +201,7 @@ void migrate_fd_connect(MigrationState *s);
 
 void add_migration_state_change_notifier(Notifier *notify);
 void remove_migration_state_change_notifier(Notifier *notify);
-MigrationState *migrate_init(const MigrationParams *params);
+MigrationState *migrate_init(void);
 bool migration_is_blocked(Error **errp);
 bool migration_in_setup(MigrationState *);
 bool migration_is_idle(void);
include/migration/vmstate.h +0 -1
index 8489659..dacb052 100644
@@ -37,7 +37,6 @@ typedef int LoadStateHandler(QEMUFile *f, void *opaque, int version_id);
 
 typedef struct SaveVMHandlers {
     /* This runs inside the iothread lock.  */
-    void (*set_params)(const MigrationParams *params, void * opaque);
     SaveStateHandler *save_state;
 
     void (*cleanup)(void *opaque);
include/qemu/typedefs.h +0 -1
index 7d85057..33a6aa1 100644
@@ -49,7 +49,6 @@ typedef struct MemoryRegion MemoryRegion;
 typedef struct MemoryRegionCache MemoryRegionCache;
 typedef struct MemoryRegionSection MemoryRegionSection;
 typedef struct MigrationIncomingState MigrationIncomingState;
-typedef struct MigrationParams MigrationParams;
 typedef struct MigrationState MigrationState;
 typedef struct Monitor Monitor;
 typedef struct MonitorDef MonitorDef;
include/sysemu/sysemu.h +1 -2
index 83c1ceb..765358e 100644
@@ -102,8 +102,7 @@ enum qemu_vm_cmd {
 #define MAX_VM_CMD_PACKAGED_SIZE (1ul << 24)
 
 bool qemu_savevm_state_blocked(Error **errp);
-void qemu_savevm_state_begin(QEMUFile *f,
-                             const MigrationParams *params);
+void qemu_savevm_state_begin(QEMUFile *f);
 void qemu_savevm_state_header(QEMUFile *f);
 int qemu_savevm_state_iterate(QEMUFile *f, bool postcopy);
 void qemu_savevm_state_cleanup(void);
migration/colo.c +1 -1
index 8c86892..dd38fed 100644
@@ -348,7 +348,7 @@ static int colo_do_checkpoint_transaction(MigrationState *s,
     /* Disable block migration */
     migrate_set_block_enabled(false, &local_err);
     qemu_savevm_state_header(fb);
-    qemu_savevm_state_begin(fb, &s->params);
+    qemu_savevm_state_begin(fb);
     qemu_mutex_lock_iothread();
     qemu_savevm_state_complete_precopy(fb, false);
     qemu_mutex_unlock_iothread();
migration/migration.c +3 -5
index b3d300d..ed66158 100644
@@ -1118,7 +1118,7 @@ bool migration_is_idle(void)
     return false;
 }
 
-MigrationState *migrate_init(const MigrationParams *params)
+MigrationState *migrate_init(void)
 {
     MigrationState *s = migrate_get_current();
 
@@ -1132,7 +1132,6 @@ MigrationState *migrate_init(const MigrationParams *params)
     s->cleanup_bh = 0;
     s->to_dst_file = NULL;
     s->state = MIGRATION_STATUS_NONE;
-    s->params = *params;
     s->rp_state.from_dst_file = NULL;
     s->rp_state.error = false;
     s->mbps = 0.0;
@@ -1221,7 +1220,6 @@ void qmp_migrate(const char *uri, bool has_blk, bool blk,
 {
     Error *local_err = NULL;
     MigrationState *s = migrate_get_current();
-    MigrationParams params;
     const char *p;
 
     if (migration_is_setup_or_active(s->state) ||
@@ -1257,7 +1255,7 @@ void qmp_migrate(const char *uri, bool has_blk, bool blk,
         migrate_set_block_incremental(s, true);
     }
 
-    s = migrate_init(&params);
+    s = migrate_init();
 
     if (strstart(uri, "tcp:", &p)) {
         tcp_start_outgoing_migration(s, p, &local_err);
@@ -1981,7 +1979,7 @@ static void *migration_thread(void *opaque)
         qemu_savevm_send_postcopy_advise(s->to_dst_file);
     }
 
-    qemu_savevm_state_begin(s->to_dst_file, &s->params);
+    qemu_savevm_state_begin(s->to_dst_file);
 
     s->setup_time = qemu_clock_get_ms(QEMU_CLOCK_HOST) - setup_start;
     migrate_set_state(&s->state, MIGRATION_STATUS_SETUP,
migration/savevm.c +3 -13
index 2f1f4eb..a728414 100644
@@ -966,21 +966,13 @@ void qemu_savevm_state_header(QEMUFile *f)
 
 }
 
-void qemu_savevm_state_begin(QEMUFile *f,
-                             const MigrationParams *params)
+void qemu_savevm_state_begin(QEMUFile *f)
 {
     SaveStateEntry *se;
     int ret;
 
     trace_savevm_state_begin();
     QTAILQ_FOREACH(se, &savevm_state.handlers, entry) {
-        if (!se->ops || !se->ops->set_params) {
-            continue;
-        }
-        se->ops->set_params(params, se->opaque);
-    }
-
-    QTAILQ_FOREACH(se, &savevm_state.handlers, entry) {
         if (!se->ops || !se->ops->save_live_setup) {
             continue;
         }
@@ -1232,9 +1224,7 @@ void qemu_savevm_state_cleanup(void)
 static int qemu_savevm_state(QEMUFile *f, Error **errp)
 {
     int ret;
-    MigrationParams params = {
-    };
-    MigrationState *ms = migrate_init(&params);
+    MigrationState *ms = migrate_init();
     MigrationStatus status;
     ms->to_dst_file = f;
 
@@ -1251,7 +1241,7 @@ static int qemu_savevm_state(QEMUFile *f, Error **errp)
 
     qemu_mutex_unlock_iothread();
     qemu_savevm_state_header(f);
-    qemu_savevm_state_begin(f, &params);
+    qemu_savevm_state_begin(f);
     qemu_mutex_lock_iothread();
 
     while (qemu_file_get_error(f) == 0) {
Signature · 1 line
2.9.3
#7 lore raw

[Qemu-devel] [PULL 07/18] block migration: Allow compile time disable

In reply to Juan Quintela

From: "Dr. David Alan Gilbert" <[email protected]>

Many users now prefer to use drive_mirror over NBD as an alternative to the older migrate -b option; drive_mirror is more complex to setup but gives you more options (e.g. only migrating some of the disks if some of them are shared).

Allow the large chunk of block migration code to be compiled out for those who don't use it.

Based on a downstream-patch we've had for a while by Jeff Cody.

--

- When compiled out, allow seting block only with false value (eric)

---
 configure                 | 11 +++++++++++
 include/migration/block.h | 24 +++++++++++++++++++++++-
 migration/Makefile.objs   |  2 +-
 migration/migration.c     | 14 ++++++++++++++
 4 files changed, 49 insertions(+), 2 deletions(-)
configure +11 -0
index 139638e..1a5ee4b 100755
@@ -316,6 +316,7 @@ vte=""
 virglrenderer=""
 tpm="yes"
 libssh2=""
+live_block_migration="yes"
 numa=""
 tcmalloc="no"
 jemalloc="no"
@@ -1169,6 +1170,10 @@ for opt do
   ;;
   --enable-libssh2) libssh2="yes"
   ;;
+  --disable-live-block-migration) live_block_migration="no"
+  ;;
+  --enable-live-block-migration) live_block_migration="yes"
+  ;;
   --disable-numa) numa="no"
   ;;
   --enable-numa) numa="yes"
@@ -1401,6 +1406,7 @@ disabled with --disable-FEATURE, default is enabled if available:
   libnfs          nfs support
   smartcard       smartcard support (libcacard)
   libusb          libusb (for usb passthrough)
+  live-block-migration   Block migration in the main migration stream
   usb-redir       usb network redirection support
   lzo             support of lzo compression library
   snappy          support of snappy compression library
@@ -5216,6 +5222,7 @@ echo "TPM support       $tpm"
 echo "libssh2 support   $libssh2"
 echo "TPM passthrough   $tpm_passthrough"
 echo "QOM debugging     $qom_cast_debug"
+echo "Live block migration $live_block_migration"
 echo "lzo support       $lzo"
 echo "snappy support    $snappy"
 echo "bzip2 support     $bzip2"
@@ -5782,6 +5789,10 @@ if test "$libssh2" = "yes" ; then
   echo "LIBSSH2_LIBS=$libssh2_libs" >> $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
include/migration/block.h +23 -1
index 5225af9..28cff53 100644
@@ -14,12 +14,34 @@
 #ifndef MIGRATION_BLOCK_H
 #define MIGRATION_BLOCK_H
 
+#ifdef CONFIG_LIVE_BLOCK_MIGRATION
 void blk_mig_init(void);
 int blk_mig_active(void);
 uint64_t blk_mig_bytes_transferred(void);
 uint64_t blk_mig_bytes_remaining(void);
 uint64_t blk_mig_bytes_total(void);
 
+#else
+static inline void blk_mig_init(void) { }
+static inline int blk_mig_active(void)
+{
+    return false;
+}
+static inline uint64_t blk_mig_bytes_transferred(void)
+{
+    return 0;
+}
+
+static inline uint64_t blk_mig_bytes_remaining(void)
+{
+    return 0;
+}
+
+static inline uint64_t blk_mig_bytes_total(void)
+{
+    return 0;
+}
+#endif /* CONFIG_LIVE_BLOCK_MIGRATION */
+
 void migrate_set_block_enabled(bool value, Error **errp);
-
 #endif /* MIGRATION_BLOCK_H */
migration/Makefile.objs +1 -1
index c1920b6..00a3f4a 100644
@@ -9,5 +9,5 @@ common-obj-y += qjson.o
 
 common-obj-$(CONFIG_RDMA) += rdma.o
 
-common-obj-y += block.o
+common-obj-$(CONFIG_LIVE_BLOCK_MIGRATION) += block.o
 
migration/migration.c +14 -0
index ed66158..2feeee8 100644
@@ -547,6 +547,11 @@ MigrationCapabilityStatusList *qmp_query_migrate_capabilities(Error **errp)
 
     caps = NULL; /* silence compiler warning */
     for (i = 0; i < MIGRATION_CAPABILITY__MAX; i++) {
+#ifndef CONFIG_LIVE_BLOCK_MIGRATION
+        if (i == MIGRATION_CAPABILITY_BLOCK) {
+            continue;
+        }
+#endif
         if (i == MIGRATION_CAPABILITY_X_COLO && !colo_supported()) {
             continue;
         }
@@ -763,6 +768,15 @@ void qmp_migrate_set_capabilities(MigrationCapabilityStatusList *params,
     }
 
     for (cap = params; cap; cap = cap->next) {
+#ifndef CONFIG_LIVE_BLOCK_MIGRATION
+        if (cap->value->capability == MIGRATION_CAPABILITY_BLOCK
+            && cap->value->state) {
+            error_setg(errp, "QEMU compiled without old-style (blk/-b, inc/-i) "
+                       "block migration");
+            error_append_hint(errp, "Use drive_mirror+NBD instead.\n");
+            continue;
+        }
+#endif
         if (cap->value->capability == MIGRATION_CAPABILITY_X_COLO) {
             if (!colo_supported()) {
                 error_setg(errp, "COLO is not currently supported, please"
Signature · 1 line
2.9.3
#8 lore raw

[Qemu-devel] [PULL 08/18] migration: Create migration/xbzrle.h

In reply to Juan Quintela
---
 include/migration/migration.h |  4 ----
 migration/ram.c               |  1 +
 migration/xbzrle.c            |  2 +-
 migration/xbzrle.h            | 21 +++++++++++++++++++++
 tests/test-xbzrle.c           |  2 +-
 5 files changed, 24 insertions(+), 6 deletions(-)
 create mode 100644 migration/xbzrle.h
include/migration/migration.h +0 -4
index b80a6ed..7d1eef7 100644
@@ -251,10 +251,6 @@ bool migrate_zero_blocks(void);
 
 bool migrate_auto_converge(void);
 
-int xbzrle_encode_buffer(uint8_t *old_buf, uint8_t *new_buf, int slen,
-                         uint8_t *dst, int dlen);
-int xbzrle_decode_buffer(uint8_t *src, int slen, uint8_t *dst, int dlen);
-
 int migrate_use_xbzrle(void);
 int64_t migrate_xbzrle_cache_size(void);
 bool migrate_colo_enabled(void);
migration/ram.c +1 -0
index 59459ef..c14269f 100644
@@ -35,6 +35,7 @@
 #include "qemu/bitmap.h"
 #include "qemu/timer.h"
 #include "qemu/main-loop.h"
+#include "xbzrle.h"
 #include "migration/migration.h"
 #include "postcopy-ram.h"
 #include "exec/address-spaces.h"
migration/xbzrle.c +1 -1
index c858339..1ba482d 100644
@@ -12,7 +12,7 @@
  */
 #include "qemu/osdep.h"
 #include "qemu/cutils.h"
-#include "include/migration/migration.h"
+#include "xbzrle.h"
 
 /*
   page = zrun nzrun
migration/xbzrle.h new file +21 -0
new file mode 100644
index 0000000..a0db507
@@ -0,0 +1,21 @@
+/*
+ * QEMU live migration
+ *
+ * Copyright IBM, Corp. 2008
+ *
+ * Authors:
+ *  Anthony Liguori   <[email protected]>
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2.  See
+ * the COPYING file in the top-level directory.
+ *
+ */
+
+#ifndef QEMU_MIGRATION_XBZRLE_H
+#define QEMU_MIGRATION_XBZRLE_H
+
+int xbzrle_encode_buffer(uint8_t *old_buf, uint8_t *new_buf, int slen,
+                         uint8_t *dst, int dlen);
+
+int xbzrle_decode_buffer(uint8_t *src, int slen, uint8_t *dst, int dlen);
+#endif
tests/test-xbzrle.c +1 -1
index 49f6419..f5e08de 100644
@@ -13,7 +13,7 @@
 #include "qemu/osdep.h"
 #include "qemu-common.h"
 #include "qemu/cutils.h"
-#include "include/migration/migration.h"
+#include "../migration/xbzrle.h"
 
 #define PAGE_SIZE 4096
 
Signature · 1 line
2.9.3
#9 lore raw

[Qemu-devel] [PULL 09/18] migration: Split migration/channel.c for channel operations

In reply to Juan Quintela

Create an include for its exported functions.

---
Add proper header

---
 include/migration/migration.h |  7 -----
 migration/Makefile.objs       |  2 +-
 migration/channel.c           | 66 +++++++++++++++++++++++++++++++++++++++++++
 migration/channel.h           | 27 ++++++++++++++++++
 migration/exec.c              |  1 +
 migration/fd.c                |  1 +
 migration/migration.c         | 50 --------------------------------
 migration/socket.c            |  1 +
 migration/tls.c               |  1 +
 9 files changed, 98 insertions(+), 58 deletions(-)
 create mode 100644 migration/channel.c
 create mode 100644 migration/channel.h
include/migration/migration.h +0 -7
index 7d1eef7..e831259 100644
@@ -157,17 +157,10 @@ void migration_fd_process_incoming(QEMUFile *f);
 
 void qemu_start_incoming_migration(const char *uri, Error **errp);
 
-void migration_channel_process_incoming(MigrationState *s,
-                                        QIOChannel *ioc);
-
 void migration_tls_channel_process_incoming(MigrationState *s,
                                             QIOChannel *ioc,
                                             Error **errp);
 
-void migration_channel_connect(MigrationState *s,
-                               QIOChannel *ioc,
-                               const char *hostname);
-
 void migration_tls_channel_connect(MigrationState *s,
                                    QIOChannel *ioc,
                                    const char *hostname,
migration/Makefile.objs +1 -1
index 00a3f4a..4e8ab0a 100644
@@ -1,5 +1,5 @@
 common-obj-y += migration.o socket.o fd.o exec.o
-common-obj-y += tls.o
+common-obj-y += tls.o channel.o
 common-obj-y += colo-comm.o colo.o colo-failover.o
 common-obj-y += vmstate.o page_cache.o
 common-obj-y += qemu-file.o
migration/channel.c new file +66 -0

66 lines not on this page · raw message

migration/channel.h new file +27 -0
new file mode 100644
index 0000000..2e0a7e3
@@ -0,0 +1,27 @@
+/*
+ * QEMU live migration channel operations
+ *
+ * Copyright Red Hat, Inc. 2016
+ *
+ * Authors:
+ *  Daniel P. Berrange <[email protected]>
+ *
+ * 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_CHANNEL_H
+#define QEMU_MIGRATION_CHANNEL_H
+
+#include "io/channel.h"
+
+void migration_channel_process_incoming(MigrationState *s,
+                                        QIOChannel *ioc);
+
+void migration_channel_connect(MigrationState *s,
+                               QIOChannel *ioc,
+                               const char *hostname);
+#endif
migration/exec.c +1 -0
index aba9089..57a9335 100644
@@ -20,6 +20,7 @@
 #include "qemu/osdep.h"
 #include "qapi/error.h"
 #include "qemu-common.h"
+#include "channel.h"
 #include "migration/migration.h"
 #include "io/channel-command.h"
 #include "trace.h"
migration/fd.c +1 -0
index 58cb51a..05e0a5c 100644
@@ -17,6 +17,7 @@
 #include "qemu/osdep.h"
 #include "qapi/error.h"
 #include "qemu-common.h"
+#include "channel.h"
 #include "migration/migration.h"
 #include "monitor/monitor.h"
 #include "io/channel-util.h"
migration/migration.c +0 -50

56 lines not on this page · raw message

migration/socket.c +1 -0
index 1cfbe81..53f9d61 100644
@@ -19,6 +19,7 @@
 #include "qemu-common.h"
 #include "qemu/error-report.h"
 #include "qapi/error.h"
+#include "channel.h"
 #include "migration/migration.h"
 #include "migration/qemu-file.h"
 #include "io/channel-socket.h"
migration/tls.c +1 -0
index a33ecb7..34ad121 100644
@@ -19,6 +19,7 @@
  */
 
 #include "qemu/osdep.h"
+#include "channel.h"
 #include "migration/migration.h"
 #include "io/channel-tls.h"
 #include "crypto/tlscreds.h"
Signature · 1 line
2.9.3
#10 lore raw
In reply to Juan Quintela
Quoted 96 lines · Juan Quintela

Hi

This include the following series:
- Fix non-multiple of page size migraition (dave)
- Remove use of old MigrationParms (a.k.a. now block migration is a capability)
- Cleanups of headers in migration
- Make savevm.c target independent

Please, apply.

Thanks, Juan.

The following changes since commit 56821559f0ba682fe6b367815572e6f974d329ab:

Merge remote-tracking branch 'dgilbert/tags/pull-hmp-20170517' into staging (2017-05-18 13:36:15 +0100)

are available in the git repository at:

git://github.com/juanquintela/qemu.git tags/migration/20170518

for you to fetch changes up to 46d702b106d20beda2fcd0f96ddc44855ba262b3:

migration: Make savevm.c target independent (2017-05-18 19:21:00 +0200)

----------------------------------------------------------------
migration/next for 20170518

----------------------------------------------------------------
Dr. David Alan Gilbert (3):
migration: Fix non-multiple of page size migration
postcopy: Require RAMBlocks that are whole pages block migration: Allow compile time disable

Juan Quintela (15):
hmp: Use visitor api for hmp_migrate_set_parameter()
migration: Create block capability
migration: Remove use of old MigrationParams
migration: Remove old MigrationParams
migration: Create migration/xbzrle.h
migration: Split migration/channel.c for channel operations
migration: Export qemu-file-channel.c functions in its own file
migration: Remove migration.h from colo.h
migration: Move qjson.h to migration/
migration: Split vmstate-types.c from vmstate.c
migration: Remove qemu-file.h from vmstate.h
migration: Remove vmstate.h from migration.h
migration: migration.h was not needed
exec: Create include for target_page_size()
migration: Make savevm.c target independent

 Makefile.target                          |   2 +-
 block/qed.c                              |   1 -
 configure                                |  11 +
 exec.c                                   |  10 +
 hmp.c                                    |  23 +-
 hw/i386/pc_q35.c                         |   1 -
 hw/virtio/vhost-user.c                   |   1 -
 hw/virtio/vhost-vsock.c                  |   1 -
 hw/virtio/virtio.c                       |   1 -
 include/exec/target_page.h               |  21 +
 include/hw/hw.h                          |   1 +
 include/migration/block.h                |  24 ++
 include/migration/colo.h                 |   1 -
 include/migration/migration.h            |  30 +-
 include/migration/qemu-file.h            |   4 -
 include/migration/vmstate.h              |   4 -
 include/qemu/typedefs.h                  |   1 -
 include/sysemu/sysemu.h                  |   4 +-
 migration/Makefile.objs                  |   6 +-
 migration/block.c                        |  19 +-
 migration/channel.c                      |  67 ++++
 migration/channel.h                      |  27 ++
 migration/colo-comm.c                    |   4 +-
 migration/colo.c                         |   9 +-
 migration/exec.c                         |   1 +
 migration/fd.c                           |   1 +
 migration/migration.c                    | 149 ++++---
 migration/postcopy-ram.c                 |  18 +-
 migration/qemu-file-channel.c            |   1 +
 migration/qemu-file-channel.h            |  32 ++
 migration/qjson.c                        |   2 +-
 {include/migration => migration}/qjson.h |   0
 migration/ram.c                          |   8 +-
 migration/rdma.c                         |   1 +
 migration/savevm.c                       |  40 +-
 migration/socket.c                       |   1 +
 migration/tls.c                          |   1 +
 migration/vmstate-types.c                | 661 +++++++++++++++++++++++++++++++
 migration/vmstate.c                      | 656 +-----------------------------
 migration/xbzrle.c                       |   2 +-
 migration/xbzrle.h                       |  21 +
 monitor.c                                |   1 -
 qapi-schema.json                         |  28 +-
 tests/Makefile.include                   |   2 +-
 tests/test-vmstate.c                     |   2 +
 tests/test-xbzrle.c                      |   2 +-
Quoted 9 lines
 46 files changed, 1102 insertions(+), 801 deletions(-)
 create mode 100644 include/exec/target_page.h
 create mode 100644 migration/channel.c
 create mode 100644 migration/channel.h
 create mode 100644 migration/qemu-file-channel.h
 rename {include/migration => migration}/qjson.h (100%)
 create mode 100644 migration/vmstate-types.c
 create mode 100644 migration/xbzrle.h

Thanks, applied to my staging tree:
https://github.com/stefanha/qemu/commits/staging

Stefan