rdma: core logic
v3 cover rdma: core logic
From: "Michael R. Hines" <[email protected]>
Changes since v2:
- trivial bugfix
- re-ran checkpatch
Michael R. Hines (8):
rdma: update documentation to reflect new unpin support
rdma: bugfix: ram_control_save_page()
rdma: introduce ram_handle_compressed()
rdma: core logic
rdma: send pc.ram
rdma: allow state transitions between other states besides ACTIVE
rdma: introduce MIG_STATE_NONE and change MIG_STATE_SETUP state
transition
rdma: account for the time spent in MIG_STATE_SETUP through QMP
Makefile.objs | 1 + arch_init.c | 62 +- configure | 40 + docs/rdma.txt | 51 +- hmp.c | 4 + include/migration/migration.h | 7 + migration-rdma.c | 3249 +++++++++++++++++++++++++++++++++++++++++ migration.c | 48 +- qapi-schema.json | 9 +- savevm.c | 2 +- 10 files changed, 3427 insertions(+), 46 deletions(-) create mode 100644 migration-rdma.c
Signature · 1 line
1.7.10.4
PATCH RESEND v3 1/8 rdma: update documentation to reflect new unpin support
From: "Michael R. Hines" <[email protected]>
As requested, the protocol now includes memory unpinning support. This has been implemented in a non-optimized manner, in such a way that one could devise an LRU or other workload-specific information on top of the basic mechanism to influence the way unpinning happens during runtime.
The feature is not yet user-facing, and is thus can only be enabled at compile-time.
--- docs/rdma.txt | 51 ++++++++++++++++++++++++++++++--------------------- 1 file changed, 30 insertions(+), 21 deletions(-)
docs/rdma.txt +30 -21
@@ -35,7 +35,7 @@ memory tracked during each live migration iteration round cannot keep pace with the rate of dirty memory produced by the workload. RDMA currently comes in two flavors: both Ethernet based (RoCE, or RDMA -over Convered Ethernet) as well as Infiniband-based. This implementation of +over Converged Ethernet) as well as Infiniband-based. This implementation of migration using RDMA is capable of using both technologies because of the use of the OpenFabrics OFED software stack that abstracts out the programming model irrespective of the underlying hardware.
@@ -188,9 +188,9 @@ header portion and a data portion (but together are transmitted as a single SEND message). Header: - * Length (of the data portion, uint32, network byte order) - * Type (what command to perform, uint32, network byte order) - * Repeat (Number of commands in data portion, same type only) + * Length (of the data portion, uint32, network byte order) + * Type (what command to perform, uint32, network byte order) + * Repeat (Number of commands in data portion, same type only) The 'Repeat' field is here to support future multiple page registrations in a single message without any need to change the protocol itself
@@ -202,17 +202,19 @@ The maximum number of repeats is hard-coded to 4096. This is a conservative limit based on the maximum size of a SEND message along with emperical observations on the maximum future benefit of simultaneous page registrations. -The 'type' field has 10 different command values: - 1. Unused - 2. Error (sent to the source during bad things) - 3. Ready (control-channel is available) - 4. QEMU File (for sending non-live device state) - 5. RAM Blocks request (used right after connection setup) - 6. RAM Blocks result (used right after connection setup) - 7. Compress page (zap zero page and skip registration) - 8. Register request (dynamic chunk registration) - 9. Register result ('rkey' to be used by sender) - 10. Register finished (registration for current iteration finished) +The 'type' field has 12 different command values: + 1. Unused + 2. Error (sent to the source during bad things) + 3. Ready (control-channel is available) + 4. QEMU File (for sending non-live device state) + 5. RAM Blocks request (used right after connection setup) + 6. RAM Blocks result (used right after connection setup) + 7. Compress page (zap zero page and skip registration) + 8. Register request (dynamic chunk registration) + 9. Register result ('rkey' to be used by sender) + 10. Register finished (registration for current iteration finished) + 11. Unregister request (unpin previously registered memory) + 12. Unregister finished (confirmation that unpin completed) A single control message, as hinted above, can contain within the data portion an array of many commands of the same type. If there is more than
@@ -243,7 +245,7 @@ qemu_rdma_exchange_send(header, data, optional response header & data): from the receiver to tell us that the receiver is *ready* for us to transmit some new bytes. 2. Optionally: if we are expecting a response from the command - (that we have no yet transmitted), let's post an RQ + (that we have not yet transmitted), let's post an RQ work request to receive that data a few moments later. 3. When the READY arrives, librdmacm will unblock us and we immediately post a RQ work request
@@ -293,8 +295,10 @@ librdmacm provides the user with a 'private data' area to be exchanged at connection-setup time before any infiniband traffic is generated. Header: - * Version (protocol version validated before send/recv occurs), uint32, network byte order - * Flags (bitwise OR of each capability), uint32, network byte order + * Version (protocol version validated before send/recv occurs), + uint32, network byte order + * Flags (bitwise OR of each capability), + uint32, network byte order There is no data portion of this header right now, so there is no length field. The maximum size of the 'private data' section
@@ -313,7 +317,7 @@ If the version is invalid, we throw an error. If the version is new, we only negotiate the capabilities that the requested version is able to perform and ignore the rest. -Currently there is only *one* capability in Version #1: dynamic page registration +Currently there is only one capability in Version #1: dynamic page registration Finally: Negotiation happens with the Flags field: If the primary-VM sets a flag, but the destination does not support this capability, it
@@ -326,8 +330,8 @@ QEMUFileRDMA Interface: QEMUFileRDMA introduces a couple of new functions: -1. qemu_rdma_get_buffer() (QEMUFileOps rdma_read_ops) -2. qemu_rdma_put_buffer() (QEMUFileOps rdma_write_ops) +1. qemu_rdma_get_buffer() (QEMUFileOps rdma_read_ops) +2. qemu_rdma_put_buffer() (QEMUFileOps rdma_write_ops) These two functions are very short and simply use the protocol describe above to deliver bytes without changing the upper-level
@@ -413,3 +417,8 @@ TODO: the use of KSM and ballooning while using RDMA. 4. Also, some form of balloon-device usage tracking would also help alleviate some issues. +5. Move UNREGISTER requests to a separate thread. +6. Use LRU to provide more fine-grained direction of UNREGISTER + requests for unpinning memory in an overcommitted environment. +7. Expose UNREGISTER support to the user by way of workload-specific + hints about application behavior.
Signature · 1 line
1.7.10.4
PATCH RESEND v3 2/8 rdma: bugfix: ram_control_save_page()
In reply to [email protected]From: "Michael R. Hines" <[email protected]>
We were not checking for a valid 'bytes_sent' pointer before accessing it.
--- savevm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
savevm.c +1 -1
@@ -662,7 +662,7 @@ size_t ram_control_save_page(QEMUFile *f, ram_addr_t block_offset, offset, size, bytes_sent);if (ret !=RAM_SAVE_CONTROL_DELAYED ) { -if (*bytes_sent >0 ) { +if (bytes_sent && *bytes_sent >0 ) {qemu_update_position (f, *bytes_sent); }else if (ret <0 ) {qemu_file_set_error (f, ret);
Signature · 1 line
1.7.10.4
PATCH RESEND v3 3/8 rdma: introduce ram_handle_compressed()
In reply to [email protected]From: "Michael R. Hines" <[email protected]>
This gives RDMA shared access to madvise() on the destination side when an entire chunk is found to be zero.
--- arch_init.c | 29 +++++++++++++++++++---------- include/migration/migration.h | 2 ++ 2 files changed, 21 insertions(+), 10 deletions(-)
arch_init.c +19 -10
@@ -777,6 +777,24 @@ static inline void *host_from_stream_offset(QEMUFile *f,return NULL ; } +/* +* If a page (or a whole RDMA chunk) has been +* determined to be zero, then zap it. +*/ +void ram_handle_compressed (void *host,uint8_t ch,uint64_t size) +{ +if (ch !=0 || !is_zero_page (host)) { +memset (host, ch, size); +#ifndef _WIN32 +if (ch ==0 && + (!kvm_enabled () ||kvm_has_sync_mmu ()) && +getpagesize () <=TARGET_PAGE_SIZE ) { +qemu_madvise (host,TARGET_PAGE_SIZE ,QEMU_MADV_DONTNEED ); + } +#endif + } +} +static int ram_load (QEMUFile *f,void *opaque,int version_id) {ram_addr_t addr;
@@ -848,16 +866,7 @@ static int ram_load(QEMUFile *f, void *opaque, int version_id) } ch =qemu_get_byte (f); -if (ch !=0 || !is_zero_page (host)) { -memset (host, ch,TARGET_PAGE_SIZE ); -#ifndef _WIN32 -if (ch ==0 && - (!kvm_enabled () ||kvm_has_sync_mmu ()) && -getpagesize () <=TARGET_PAGE_SIZE ) { -qemu_madvise (host,TARGET_PAGE_SIZE ,QEMU_MADV_DONTNEED ); - } -#endif - } +ram_handle_compressed (host, ch,TARGET_PAGE_SIZE ); }else if (flags &RAM_SAVE_FLAG_PAGE ) {void *host;
include/migration/migration.h +2 -0
@@ -109,6 +109,8 @@ uint64_t xbzrle_mig_pages_transferred(void);uint64_t xbzrle_mig_pages_overflow (void );uint64_t xbzrle_mig_pages_cache_miss (void ); +void ram_handle_compressed (void *host,uint8_t ch,uint64_t size); +/** * @migrate_add_blocker - prevent migration from proceeding *
Signature · 1 line
1.7.10.4
PATCH RESEND v3 4/8 rdma: core logic
In reply to [email protected]From: "Michael R. Hines" <[email protected]>
Code that does need to be visible is kept well contained inside this file and this is the only new additional file to the entire patch.
This file includes the entire protocol and interfaces required to perform RDMA migration.
Also, the configure and Makefile modifications to link this file are included.
Full documentation is in docs/rdma.txt
--- Makefile.objs | 1 + configure | 40 + include/migration/migration.h | 4 + migration-rdma.c | 3249 +++++++++++++++++++++++++++++++++++++++++ migration.c | 8 + 5 files changed, 3302 insertions(+) create mode 100644 migration-rdma.c
Makefile.objs +1 -0
@@ -51,6 +51,7 @@ common-obj-$(CONFIG_POSIX) += os-posix.o common-obj-$(CONFIG_LINUX) += fsdev/ common-obj-y += migration.o migration-tcp.o +common-obj-$(CONFIG_RDMA) += migration-rdma.o common-obj-y += qemu-char.o #aio.o common-obj-y += block-migration.o common-obj-y += page_cache.o xbzrle.o
configure +40 -0
@@ -180,6 +180,7 @@ xfs="" vhost_net="no" vhost_scsi="no" kvm="no" +rdma="" gprof="no" debug_tcg="no" debug="no"
@@ -936,6 +937,10 @@ for opt do ;; --enable-gtk) gtk="yes" ;; + --enable-rdma) rdma="yes" + ;; + --disable-rdma) rdma="no" + ;; --with-gtkabi=*) gtkabi="$optarg" ;; --enable-tpm) tpm="yes"
@@ -1094,6 +1099,8 @@ echo " --enable-bluez enable bluez stack connectivity" echo " --disable-slirp disable SLIRP userspace network connectivity" echo " --disable-kvm disable KVM acceleration support" echo " --enable-kvm enable KVM acceleration support" +echo " --disable-rdma disable RDMA-based migration support" +echo " --enable-rdma enable RDMA-based migration support" echo " --enable-tcg-interpreter enable TCG with bytecode interpreter (TCI)" echo " --disable-nptl disable usermode NPTL support" echo " --enable-nptl enable usermode NPTL support"
@@ -1797,6 +1804,30 @@ EOF fi ########################################## +# RDMA needs OpenFabrics libraries +if test "$rdma" != "no" ; then + cat > $TMPC <<EOF +#include <rdma/rdma_cma.h> +int main(void) { return 0; } +EOF + rdma_libs="-lrdmacm -libverbs" + if compile_prog "" "$rdma_libs" ; then + rdma="yes" + libs_softmmu="$libs_softmmu $rdma_libs" + else + if test "$rdma" = "yes" ; then + error_exit \ + " OpenFabrics librdmacm/libibverbs not present." \ + " Your options:" \ + " (1) Fast: Install infiniband packages from your distro." \ + " (2) Cleanest: Install libraries from www.openfabrics.org" \ + " (3) Also: Install softiwarp if you don't have RDMA hardware" + fi + rdma="no" + fi +fi + +########################################## # VNC TLS/WS detection if test "$vnc" = "yes" -a \( "$vnc_tls" != "no" -o "$vnc_ws" != "no" \) ; then cat > $TMPC <<EOF
@@ -3555,6 +3586,7 @@ echo "Linux AIO support $linux_aio" echo "ATTR/XATTR support $attr" echo "Install blobs $blobs" echo "KVM support $kvm" +echo "RDMA support $rdma" echo "TCG interpreter $tcg_interpreter" echo "fdt support $fdt" echo "preadv support $preadv"
@@ -4039,6 +4071,10 @@ if test "$trace_default" = "yes"; then echo "CONFIG_TRACE_DEFAULT=y" >> $config_host_mak fi +if test "$rdma" = "yes" ; then + echo "CONFIG_RDMA=y" >> $config_host_mak +fi + if test "$tcg_interpreter" = "yes"; then QEMU_INCLUDES="-I\$(SRC_PATH)/tcg/tci $QEMU_INCLUDES" elif test "$ARCH" = "sparc64" ; then
@@ -4478,6 +4514,10 @@ if [ "$pixman" = "internal" ]; then echo "config-host.h: subdir-pixman" >> $config_host_mak fi +if test "$rdma" = "yes" ; then +echo "CONFIG_RDMA=y" >> $config_host_mak +fi + if [ "$dtc_internal" = "yes" ]; then echo "config-host.h: subdir-dtc" >> $config_host_mak fi
include/migration/migration.h +4 -0
@@ -77,6 +77,10 @@ void fd_start_incoming_migration(const char *path, Error **errp);void fd_start_outgoing_migration (MigrationState *s,const char *fdname,Error **errp); +void rdma_start_outgoing_migration (void *opaque,const char *host_port,Error **errp); + +void rdma_start_incoming_migration (const char *host_port,Error **errp); +void migrate_fd_error (MigrationState *s);void migrate_fd_connect (MigrationState *s);
migration-rdma.c new file +3249 -0
2,901 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
1.7.10.4
Part of the diff is not shown here. View the raw message.
PATCH RESEND v3 5/8 rdma: send pc.ram
In reply to [email protected]From: "Michael R. Hines" <[email protected]>
This takes advantages of the previous patches:
1. use the new QEMUFileOps hook 'save_page'
2. call out to the right accessor methods to invoke the iteration hooks defined in QEMUFileOps
--- arch_init.c | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-)
arch_init.c +32 -1
@@ -115,6 +115,7 @@ const uint32_t arch_type = QEMU_ARCH;#define RAM_SAVE_FLAG_EOS 0x10#define RAM_SAVE_FLAG_CONTINUE 0x20#define RAM_SAVE_FLAG_XBZRLE 0x40 +/* 0x80 is reserved in migration.h start with 0x100 next */ static struct defconfig_file {
@@ -447,6 +448,7 @@ static int ram_save_block(QEMUFile *f, bool last_stage) ram_bulk_stage = false; } }else { +int ret;uint8_t *p;int cont = (block == last_sent_block) ?RAM_SAVE_FLAG_CONTINUE :0 ;
@@ -455,7 +457,18 @@ static int ram_save_block(QEMUFile *f, bool last_stage)/* In doubt sent page as normal */ bytes_sent =-1 ; -if (is_zero_page (p)) { + ret =ram_control_save_page (f, block->offset, + offset,TARGET_PAGE_SIZE , &bytes_sent); + +if (ret !=RAM_SAVE_CONTROL_NOT_SUPP ) { +if (ret !=RAM_SAVE_CONTROL_DELAYED ) { +if (bytes_sent >0 ) { + acct_info.norm_pages++; + }else if (bytes_sent ==0 ) { + acct_info.dup_pages++; + } + } + }else if (is_zero_page (p)) { acct_info.dup_pages++; bytes_sent =save_block_hdr (f, block, offset, cont,RAM_SAVE_FLAG_COMPRESS );
@@ -605,6 +618,10 @@ static int ram_save_setup(QEMUFile *f, void *opaque) }qemu_mutex_unlock_ramlist (); + +ram_control_before_iterate (f,RAM_CONTROL_SETUP ); +ram_control_after_iterate (f,RAM_CONTROL_SETUP ); +qemu_put_be64 (f,RAM_SAVE_FLAG_EOS );return 0 ;
@@ -623,6 +640,8 @@ static int ram_save_iterate(QEMUFile *f, void *opaque)reset_ram_globals (); } +ram_control_before_iterate (f,RAM_CONTROL_ROUND ); + t0 =qemu_get_clock_ns (rt_clock); i =0 ;while ((ret =qemu_file_rate_limit (f)) ==0 ) {
@@ -653,6 +672,12 @@ static int ram_save_iterate(QEMUFile *f, void *opaque)qemu_mutex_unlock_ramlist (); +/* +* Must occur before EOS (or any QEMUFile operation) +* because of RDMA protocol. +*/ +ram_control_after_iterate (f,RAM_CONTROL_ROUND ); +if (ret <0 ) { bytes_transferred += total_sent;return ret;
@@ -670,6 +695,8 @@ static int ram_save_complete(QEMUFile *f, void *opaque)qemu_mutex_lock_ramlist ();migration_bitmap_sync (); +ram_control_before_iterate (f,RAM_CONTROL_FINISH ); +/* try transferring iterative blocks of memory */ /* flush all remaining blocks regardless of rate limiting */
@@ -683,6 +710,8 @@ static int ram_save_complete(QEMUFile *f, void *opaque) } bytes_transferred += bytes_sent; } + +ram_control_after_iterate (f,RAM_CONTROL_FINISH );migration_end ();qemu_mutex_unlock_ramlist ();
@@ -886,6 +915,8 @@ static int ram_load(QEMUFile *f, void *opaque, int version_id) ret = -EINVAL ; goto done; } + }else if (flags &RAM_SAVE_FLAG_HOOK ) { +ram_control_load_hook (f, flags); } error =qemu_file_get_error (f);if (error) {
Signature · 1 line
1.7.10.4
PATCH RESEND v3 6/8 rdma: allow state transitions between other states besides ACTIVE
In reply to [email protected]From: "Michael R. Hines" <[email protected]>
This patch is in preparation for the next ones: Until now the MIG_STATE_SETUP state was not really a 'formal' state. It has been used as a 'zero' state and QEMU has been unconditionally transitioning into this state when the QMP migrate command was called. In preparation for timing this state, we have to make this state a a 'real' state which actually gets transitioned from later in the migration_thread() from SETUP => ACTIVE, rather than just automatically dropping into this state at the beginninig of the migration.
This means that the state transition function (migration_finish_set_state()) needs to be capable of transitioning from valid states _other_ than just MIG_STATE_ACTIVE.
The function is in fact already capable of doing that, but was not allowing the old state to be a parameter specified as an input.
This patch fixes that and only makes the transition if the current state matches the old state that the caller intended to transition from.
--- migration.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
migration.c +5 -5
@@ -295,9 +295,9 @@ static void migrate_fd_cleanup(void *opaque)notifier_list_notify (&migration_state_notifiers, s); } -static void migrate_finish_set_state (MigrationState *s,int new_state) +static void migrate_set_state (MigrationState *s,int old_state,int new_state) { -if (atomic_cmpxchg (&s->state,MIG_STATE_ACTIVE , new_state) == new_state) { +if (atomic_cmpxchg (&s->state, old_state, new_state) == new_state) {trace_migrate_set_state (new_state); } }
@@ -315,7 +315,7 @@ static void migrate_fd_cancel(MigrationState *s) {DPRINTF ("cancelling migration\n" ); -migrate_finish_set_state (s,MIG_STATE_CANCELLED ); +migrate_set_state (s, s->state,MIG_STATE_CANCELLED ); }void add_migration_state_change_notifier (Notifier *notify)
@@ -545,14 +545,14 @@ static void *migration_thread(void *opaque)qemu_savevm_state_complete (s->file);qemu_mutex_unlock_iothread ();if (!qemu_file_get_error (s->file)) { -migrate_finish_set_state (s,MIG_STATE_COMPLETED ); +migrate_set_state (s,MIG_STATE_ACTIVE ,MIG_STATE_COMPLETED );break ; } } }if (qemu_file_get_error (s->file)) { -migrate_finish_set_state (s,MIG_STATE_ERROR ); +migrate_set_state (s,MIG_STATE_ACTIVE ,MIG_STATE_ERROR );break ; } current_time =qemu_get_clock_ms (rt_clock);
Signature · 1 line
1.7.10.4
PATCH RESEND v3 7/8 rdma: introduce MIG_STATE_NONE and change MIG_STATE_SETUP state transition
In reply to [email protected]From: "Michael R. Hines" <[email protected]>
As described in the previous patch, until now, the MIG_STATE_SETUP state was not really a 'formal' state. It has been used as a 'zero' state (what we're calling 'NONE' here) and QEMU has been unconditionally transitioning into this state when the QMP migration command was called. Instead we want to introduce MIG_STATE_NONE, which is our starting state in the state machine, and then immediately transition into the MIG_STATE_SETUP state when the QMP migrate command is issued.
In order to do this, we must delay the transition into MIG_STATE_ACTIVE until later in the migration_thread(). This is done to be able to timestamp the amount of time spent in the SETUP state for proper accounting to the user during an RDMA migration.
Furthermore, the management software, until now, has never been aware of the existence of the SETUP state whatsoever. This must change, because, timing of this state implies that the state actually exists.
These two patches cannot be separated because the 'query_migrate' QMP switch statement needs to know how to handle this new state transition.
--- migration.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-)
migration.c +14 -7
@@ -36,7 +36,8 @@#endif enum { -MIG_STATE_ERROR , +MIG_STATE_ERROR =-1 , +MIG_STATE_NONE ,MIG_STATE_SETUP ,MIG_STATE_CANCELLED ,MIG_STATE_ACTIVE ,
@@ -63,7 +64,7 @@ static NotifierList migration_state_notifiers =MigrationState *migrate_get_current (void ) {static MigrationState current_migration = { - .state =MIG_STATE_SETUP , + .state =MIG_STATE_NONE , .bandwidth_limit =MAX_THROTTLE , .xbzrle_cache_size =DEFAULT_MIGRATE_CACHE_SIZE , .mbps =-1 ,
@@ -184,9 +185,13 @@ MigrationInfo *qmp_query_migrate(Error **errp)MigrationState *s =migrate_get_current ();switch (s->state) { -case MIG_STATE_SETUP : +case MIG_STATE_NONE :/* no migration has happened ever */ break ; +case MIG_STATE_SETUP : + info->has_status = true; + info->status =g_strdup ("setup" ); +break ;case MIG_STATE_ACTIVE : info->has_status = true; info->status =g_strdup ("active" );
@@ -257,7 +262,7 @@ void qmp_migrate_set_capabilities(MigrationCapabilityStatusList *params,MigrationState *s =migrate_get_current ();MigrationCapabilityStatusList *cap; -if (s->state ==MIG_STATE_ACTIVE ) { +if (s->state ==MIG_STATE_ACTIVE || s->state ==MIG_STATE_SETUP ) {error_set (errp,QERR_MIGRATION_ACTIVE );return ; }
@@ -392,7 +397,7 @@ void qmp_migrate(const char *uri, bool has_blk, bool blk, params.blk = blk; params.shared = inc; -if (s->state ==MIG_STATE_ACTIVE ) { +if (s->state ==MIG_STATE_ACTIVE || s->state ==MIG_STATE_SETUP ) {error_set (errp,QERR_MIGRATION_ACTIVE );return ; }
@@ -524,6 +529,8 @@ static void *migration_thread(void *opaque)DPRINTF ("beginning savevm\n" );qemu_savevm_state_begin (s->file, &s->params); +migrate_set_state (s,MIG_STATE_SETUP ,MIG_STATE_ACTIVE ); +while (s->state ==MIG_STATE_ACTIVE ) {int64_t current_time;uint64_t pending_size;
@@ -603,8 +610,8 @@ static void *migration_thread(void *opaque)void migrate_fd_connect (MigrationState *s) { - s->state =MIG_STATE_ACTIVE ; -trace_migrate_set_state (MIG_STATE_ACTIVE ); + s->state =MIG_STATE_SETUP ; +trace_migrate_set_state (MIG_STATE_SETUP );/* This is a best 1st approximation. ns to ms */ s->expected_downtime = max_downtime/1000000 ;
Signature · 1 line
1.7.10.4
Re: [Qemu-devel] [PATCH v3 resend 7/8] rdma: introduce MIG_STATE_NONE and change MIG_STATE_SETUP state transition
Quoted 15 lines · On 07/22/2013 08:01 AM, [email protected] wrote:
From: "Michael R. Hines" <[email protected]>
As described in the previous patch, until now, the
MIG_STATE_SETUPstate was not really a 'formal' state. It has been used as a 'zero' state (what we're calling 'NONE' here) and QEMU has been unconditionally transitioning into this state when the QMP migration command was called. Instead we want to introduceMIG_STATE_NONE, which is our starting state in the state machine, and then immediately transition into theMIG_STATE_SETUPstate when the QMP migrate command is issued.In order to do this, we must delay the transition into
MIG_STATE_ACTIVEuntil later in themigration_thread(). This is done to be able to timestamp the amount of time spent in the SETUP state for proper accounting to the user during an RDMA migration.
Quoted 6 lines
Furthermore, the management software, until now, has never been aware of the existence of the SETUP state whatsoever. This must change, because, timing of this state implies that the state actually exists.
These two patches cannot be separated because the '
query_migrate' QMP switch statement needs to know how to handle this new state transition.
This patch causes an issue with libvirt migration:
https://bugzilla.redhat.com/show_bug.cgi?id=1015636
migration.c MigrationInfo *qmp_query_migrate(Error **errp) · line 194
Quoted 4 lines
migration.c +4
-0+case MIG_STATE_SETUP : + info->has_status = true; + info->status =g_strdup ("setup" ); +break ;
You are now returning a state that older libvirt versions are not expecting. Obviously, we can patch newer libvirt to make migration work again, but should we be thinking about damage control by stating that an older management app should still be able to drive migration on a new qemu? Or is it acceptable to state that newer qemu requires newer management tools?
If we try to support this working under older management tools, maybe the approach is that we have to add some new migration capability; newer management tools set the capability to true and are therefore allowed to see the new state name; older management tools do not set the capability and when that is the case we guarantee that we do not return a state string that the older tool is not expecting. Thoughts on whether we should pursue this?
Signature · 2 lines
Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
Re: [Qemu-devel] [PATCH v3 resend 7/8] rdma: introduce MIG_STATE_NONE and change MIG_STATE_SETUP state transition
Il 08/10/2013 16:49, Eric Blake ha scritto:
Quoted 6 lines
You are now returning a state that older libvirt versions are not expecting. Obviously, we can patch newer libvirt to make migration work again, but should we be thinking about damage control by stating that an older management app should still be able to drive migration on a new qemu? Or is it acceptable to state that newer qemu requires newer management tools?
We strive for that, but sometimes we break because we do not really know what management expects from QEMU.
In this case, in particular, I think a capability is a bit overkill. Libvirt needs to be somewhat liberal in what it accepts; in this case it can treat any unknown state as "active".
Paolo
Quoted 8 lines
If we try to support this working under older management tools, maybe the approach is that we have to add some new migration capability; newer management tools set the capability to true and are therefore allowed to see the new state name; older management tools do not set the capability and when that is the case we guarantee that we do not return a state string that the older tool is not expecting. Thoughts on whether we should pursue this?
Re: [Qemu-devel] [PATCH v3 resend 7/8] rdma: introduce MIG_STATE_NONE and change MIG_STATE_SETUP state transition
Quoted 7 lines · Paolo Bonzini
Il 08/10/2013 16:49, Eric Blake ha scritto:
Quoted 6 lines
You are now returning a state that older libvirt versions are not expecting. Obviously, we can patch newer libvirt to make migration work again, but should we be thinking about damage control by stating that an older management app should still be able to drive migration on a new qemu? Or is it acceptable to state that newer qemu requires newer management tools?
Quoted 8 lines
We strive for that, but sometimes we break because we do not really know what management expects from QEMU.
In this case, in particular, I think a capability is a bit overkill. Libvirt needs to be somewhat liberal in what it accepts; in this case it can treat any unknown state as "active".
Paolo
That makes sense to me too - the setup state is "effectively" the same as active and can be safely treated as such.
There's a similar issue MigrationInfo statistics - what's the backwards/forwards-compatible procedure for not breaking libvirt when new statics appear? - such as "setup-time", which timestamps the new state that was introduced?
- Michael
for adding new statistics
- Michael
Re: [Qemu-devel] [PATCH v3 resend 7/8] rdma: introduce MIG_STATE_NONE and change MIG_STATE_SETUP state transition
Quoted 7 lines · Michael R. Hines
Quoted 6 lines
In this case, in particular, I think a capability is a bit overkill. Libvirt needs to be somewhat liberal in what it accepts; in this case it can treat any unknown state as "active".
Paolo
Quoted 7 lines
That makes sense to me too - the setup state is "effectively" the same as active and can be safely treated as such.
There's a similar issue MigrationInfo statistics - what's the backwards/forwards-compatible procedure for not breaking libvirt when new statics appear? - such as "setup-time", which timestamps the new state that was introduced?
Libvirt ignores fields it does not expect. But for fields it expects, it was not ignoring new enum values within those fields that it was not expecting. The 'setup-time' change is not a problem (new field); only the new state ('setup') - and even then, Paolo is right that newer libvirt will be taught to be tolerant of unknown states, and that it is okay to require newer libvirt when using newer qemu (for example, when qemu 1.0 first came out, you had to upgrade to a new-enough libvirt that knew what to do with the different version number).
So sounds like nothing further to worry about in qemu.
Signature · 2 lines
Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
Re: [Qemu-devel] [PATCH v3 resend 7/8] rdma: introduce MIG_STATE_NONE and change MIG_STATE_SETUP state transition
In reply to Paolo BonziniQuoted 26 lines · Paolo Bonzini
Il 08/10/2013 16:49, Eric Blake ha scritto:
Quoted 6 lines
You are now returning a state that older libvirt versions are not expecting. Obviously, we can patch newer libvirt to make migration work again, but should we be thinking about damage control by stating that an older management app should still be able to drive migration on a new qemu? Or is it acceptable to state that newer qemu requires newer management tools?
We strive for that, but sometimes we break because we do not really know what management expects from QEMU.
In this case, in particular, I think a capability is a bit overkill. Libvirt needs to be somewhat liberal in what it accepts; in this case it can treat any unknown state as "active".
Paolo
Quoted 7 lines
If we try to support this working under older management tools, maybe the approach is that we have to add some new migration capability; newer management tools set the capability to true and are therefore allowed to see the new state name; older management tools do not set the capability and when that is the case we guarantee that we do not return a state string that the older tool is not expecting. Thoughts on whether we should pursue this?
PATCH RESEND v3 8/8 rdma: account for the time spent in MIG_STATE_SETUP through QMP
In reply to [email protected]From: "Michael R. Hines" <[email protected]>
Using the previous patches, we're now able to timestamp the SETUP state. Once we have this time, let the user know about it in the schema.
--- hmp.c | 4 ++++ include/migration/migration.h | 1 + migration.c | 9 +++++++++ qapi-schema.json | 9 ++++++++- 4 files changed, 22 insertions(+), 1 deletion(-)
hmp.c +4 -0
@@ -164,6 +164,10 @@ void hmp_info_migrate(Monitor *mon, const QDict *qdict)monitor_printf (mon,"downtime: %" PRIu64" milliseconds\n" , info->downtime); } +if (info->has_setup_time) { +monitor_printf (mon,"setup: %" PRIu64" milliseconds\n" , + info->setup_time); + } }if (info->has_ram) {
include/migration/migration.h +1 -0
@@ -49,6 +49,7 @@ struct MigrationStateint64_t dirty_bytes_rate;bool enabled_capabilities[MIGRATION_CAPABILITY_MAX ];int64_t xbzrle_cache_size; +int64_t setup_time; };void process_incoming_migration (QEMUFile *f);
migration.c +9 -0
@@ -191,6 +191,7 @@ MigrationInfo *qmp_query_migrate(Error **errp)case MIG_STATE_SETUP : info->has_status = true; info->status =g_strdup ("setup" ); + info->has_total_time = false;break ;case MIG_STATE_ACTIVE : info->has_status = true;
@@ -200,6 +201,8 @@ MigrationInfo *qmp_query_migrate(Error **errp) - s->total_time; info->has_expected_downtime = true; info->expected_downtime = s->expected_downtime; + info->has_setup_time = true; + info->setup_time = s->setup_time; info->has_ram = true; info->ram =g_malloc0 (sizeof (*info->ram));
@@ -231,6 +234,8 @@ MigrationInfo *qmp_query_migrate(Error **errp) info->total_time = s->total_time; info->has_downtime = true; info->downtime = s->downtime; + info->has_setup_time = true; + info->setup_time = s->setup_time; info->has_ram = true; info->ram =g_malloc0 (sizeof (*info->ram));
@@ -521,6 +526,7 @@ static void *migration_thread(void *opaque) {MigrationState *s = opaque;int64_t initial_time =qemu_get_clock_ms (rt_clock); +int64_t setup_start =qemu_get_clock_ms (host_clock);int64_t initial_bytes =0 ;int64_t max_size =0 ;int64_t start_time = initial_time;
@@ -529,8 +535,11 @@ static void *migration_thread(void *opaque)DPRINTF ("beginning savevm\n" );qemu_savevm_state_begin (s->file, &s->params); + s->setup_time =qemu_get_clock_ms (host_clock) - setup_start;migrate_set_state (s,MIG_STATE_SETUP ,MIG_STATE_ACTIVE ); +DPRINTF ("setup complete\n" ); +while (s->state ==MIG_STATE_ACTIVE ) {int64_t current_time;uint64_t pending_size;
qapi-schema.json +8 -1
@@ -578,6 +578,12 @@ # expected downtime in milliseconds for the guest in last walk # of the dirty bitmap. (since 1.3) # +# @setup-time: #optional amount of setup time in milliseconds _before_ the +# iterations begin but _after_ the QMP command is issued. This is designed +# to provide an accounting of any activities (such as RDMA pinning) which +# may be expensive, but do not actually occur during the iterative +# migration rounds themselves. (since 1.6) +# # Since: 0.14.0 ## { 'type': 'MigrationInfo',
@@ -586,7 +592,8 @@ '*xbzrle-cache': 'XBZRLECacheStats', '*total-time': 'int', '*expected-downtime': 'int', - '*downtime': 'int'} } + '*downtime': 'int', + '*setup-time': 'int'} } ## # @query-migrate
Signature · 1 line
1.7.10.4