migration.c (b890902c9c025b87d02e718eec3090fd3525ab18) migration.c (51b07548f7c31793adc178c7460c5f4369733c61)
1/*
2 * QEMU live migration
3 *
4 * Copyright IBM, Corp. 2008
5 *
6 * Authors:
7 * Anthony Liguori <aliguori@us.ibm.com>
8 *

--- 172 unchanged lines hidden (view full) ---

181static bool migration_object_check(MigrationState *ms, Error **errp);
182static int migration_maybe_pause(MigrationState *s,
183 int *current_active_state,
184 int new_state);
185static void migrate_fd_cancel(MigrationState *s);
186
187static bool migration_needs_multiple_sockets(void)
188{
1/*
2 * QEMU live migration
3 *
4 * Copyright IBM, Corp. 2008
5 *
6 * Authors:
7 * Anthony Liguori <aliguori@us.ibm.com>
8 *

--- 172 unchanged lines hidden (view full) ---

181static bool migration_object_check(MigrationState *ms, Error **errp);
182static int migration_maybe_pause(MigrationState *s,
183 int *current_active_state,
184 int new_state);
185static void migrate_fd_cancel(MigrationState *s);
186
187static bool migration_needs_multiple_sockets(void)
188{
189 return migrate_use_multifd() || migrate_postcopy_preempt();
189 return migrate_multifd() || migrate_postcopy_preempt();
190}
191
192static bool uri_supports_multi_channels(const char *uri)
193{
194 return strstart(uri, "tcp:", NULL) || strstart(uri, "unix:", NULL) ||
195 strstart(uri, "vsock:", NULL);
196}
197

--- 529 unchanged lines hidden (view full) ---

727
728/*
729 * Returns true when we want to start a new incoming migration process,
730 * false otherwise.
731 */
732static bool migration_should_start_incoming(bool main_channel)
733{
734 /* Multifd doesn't start unless all channels are established */
190}
191
192static bool uri_supports_multi_channels(const char *uri)
193{
194 return strstart(uri, "tcp:", NULL) || strstart(uri, "unix:", NULL) ||
195 strstart(uri, "vsock:", NULL);
196}
197

--- 529 unchanged lines hidden (view full) ---

727
728/*
729 * Returns true when we want to start a new incoming migration process,
730 * false otherwise.
731 */
732static bool migration_should_start_incoming(bool main_channel)
733{
734 /* Multifd doesn't start unless all channels are established */
735 if (migrate_use_multifd()) {
735 if (migrate_multifd()) {
736 return migration_has_all_channels();
737 }
738
739 /* Preempt channel only starts when the main channel is created */
740 if (migrate_postcopy_preempt()) {
741 return main_channel;
742 }
743

--- 10 unchanged lines hidden (view full) ---

754{
755 MigrationIncomingState *mis = migration_incoming_get_current();
756 Error *local_err = NULL;
757 QEMUFile *f;
758 bool default_channel = true;
759 uint32_t channel_magic = 0;
760 int ret = 0;
761
736 return migration_has_all_channels();
737 }
738
739 /* Preempt channel only starts when the main channel is created */
740 if (migrate_postcopy_preempt()) {
741 return main_channel;
742 }
743

--- 10 unchanged lines hidden (view full) ---

754{
755 MigrationIncomingState *mis = migration_incoming_get_current();
756 Error *local_err = NULL;
757 QEMUFile *f;
758 bool default_channel = true;
759 uint32_t channel_magic = 0;
760 int ret = 0;
761
762 if (migrate_use_multifd() && !migrate_postcopy_ram() &&
762 if (migrate_multifd() && !migrate_postcopy_ram() &&
763 qio_channel_has_feature(ioc, QIO_CHANNEL_FEATURE_READ_MSG_PEEK)) {
764 /*
765 * With multiple channels, it is possible that we receive channels
766 * out of order on destination side, causing incorrect mapping of
767 * source channels on destination side. Check channel MAGIC to
768 * decide type of channel. Please note this is best effort, postcopy
769 * preempt channel does not send any magic number so avoid it for
770 * postcopy live migration. Also tls live migration already does

--- 22 unchanged lines hidden (view full) ---

793 f = qemu_file_new_input(ioc);
794
795 if (!migration_incoming_setup(f, errp)) {
796 return;
797 }
798 } else {
799 /* Multiple connections */
800 assert(migration_needs_multiple_sockets());
763 qio_channel_has_feature(ioc, QIO_CHANNEL_FEATURE_READ_MSG_PEEK)) {
764 /*
765 * With multiple channels, it is possible that we receive channels
766 * out of order on destination side, causing incorrect mapping of
767 * source channels on destination side. Check channel MAGIC to
768 * decide type of channel. Please note this is best effort, postcopy
769 * preempt channel does not send any magic number so avoid it for
770 * postcopy live migration. Also tls live migration already does

--- 22 unchanged lines hidden (view full) ---

793 f = qemu_file_new_input(ioc);
794
795 if (!migration_incoming_setup(f, errp)) {
796 return;
797 }
798 } else {
799 /* Multiple connections */
800 assert(migration_needs_multiple_sockets());
801 if (migrate_use_multifd()) {
801 if (migrate_multifd()) {
802 multifd_recv_new_channel(ioc, &local_err);
803 } else {
804 assert(migrate_postcopy_preempt());
805 f = qemu_file_new_input(ioc);
806 postcopy_preempt_new_channel(mis, f);
807 }
808 if (local_err) {
809 error_propagate(errp, local_err);

--- 19 unchanged lines hidden (view full) ---

829bool migration_has_all_channels(void)
830{
831 MigrationIncomingState *mis = migration_incoming_get_current();
832
833 if (!mis->from_src_file) {
834 return false;
835 }
836
802 multifd_recv_new_channel(ioc, &local_err);
803 } else {
804 assert(migrate_postcopy_preempt());
805 f = qemu_file_new_input(ioc);
806 postcopy_preempt_new_channel(mis, f);
807 }
808 if (local_err) {
809 error_propagate(errp, local_err);

--- 19 unchanged lines hidden (view full) ---

829bool migration_has_all_channels(void)
830{
831 MigrationIncomingState *mis = migration_incoming_get_current();
832
833 if (!mis->from_src_file) {
834 return false;
835 }
836
837 if (migrate_use_multifd()) {
837 if (migrate_multifd()) {
838 return multifd_recv_all_channels_created();
839 }
840
841 if (migrate_postcopy_preempt()) {
842 return mis->postcopy_qemufile_dst != NULL;
843 }
844
845 return true;

--- 1707 unchanged lines hidden (view full) ---

2553{
2554 MigrationState *s;
2555
2556 s = migrate_get_current();
2557
2558 return s->parameters.decompress_threads;
2559}
2560
838 return multifd_recv_all_channels_created();
839 }
840
841 if (migrate_postcopy_preempt()) {
842 return mis->postcopy_qemufile_dst != NULL;
843 }
844
845 return true;

--- 1707 unchanged lines hidden (view full) ---

2553{
2554 MigrationState *s;
2555
2556 s = migrate_get_current();
2557
2558 return s->parameters.decompress_threads;
2559}
2560
2561bool migrate_use_multifd(void)
2562{
2563 MigrationState *s;
2564
2565 s = migrate_get_current();
2566
2567 return s->capabilities[MIGRATION_CAPABILITY_MULTIFD];
2568}
2569
2570int migrate_multifd_channels(void)
2571{
2572 MigrationState *s;
2573
2574 s = migrate_get_current();
2575
2576 return s->parameters.multifd_channels;
2577}

--- 1902 unchanged lines hidden ---
2561int migrate_multifd_channels(void)
2562{
2563 MigrationState *s;
2564
2565 s = migrate_get_current();
2566
2567 return s->parameters.multifd_channels;
2568}

--- 1902 unchanged lines hidden ---