build: move COLO under CONFIG_REPLICATION
We don't allow to use x-colo capability when replication is not configured. So, no reason to build COLO when replication is disabled, it's unusable in this case. Note also that the check in migrate_caps_check() is not the only restriction: some functions in migration/colo.c will just abort if called with not defined CONFIG_REPLICATION, for example: migration_iteration_finish() case MIGRATION_STATUS_COLO: migrate_start_colo_process() colo_process_checkpoint() abort() It could probably make sense to have possibility to enable COLO without REPLICATION, but this requires deeper audit of colo & replication code, which may be done later if needed. Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru> Acked-by: Dr. David Alan Gilbert <dave@treblig.org> Reviewed-by: Juan Quintela <quintela@redhat.com> Message-Id: <20230428194928.1426370-4-vsementsov@yandex-team.ru> Signed-off-by: Juan Quintela <quintela@redhat.com>
This commit is contained in:
parent
4332ffcd7b
commit
51e47cf860
|
@ -1052,6 +1052,7 @@ SRST
|
||||||
migration (or once already in postcopy).
|
migration (or once already in postcopy).
|
||||||
ERST
|
ERST
|
||||||
|
|
||||||
|
#ifdef CONFIG_REPLICATION
|
||||||
{
|
{
|
||||||
.name = "x_colo_lost_heartbeat",
|
.name = "x_colo_lost_heartbeat",
|
||||||
.args_type = "",
|
.args_type = "",
|
||||||
|
@ -1060,6 +1061,7 @@ ERST
|
||||||
"a failover or takeover is needed.",
|
"a failover or takeover is needed.",
|
||||||
.cmd = hmp_x_colo_lost_heartbeat,
|
.cmd = hmp_x_colo_lost_heartbeat,
|
||||||
},
|
},
|
||||||
|
#endif
|
||||||
|
|
||||||
SRST
|
SRST
|
||||||
``x_colo_lost_heartbeat``
|
``x_colo_lost_heartbeat``
|
||||||
|
|
|
@ -26,9 +26,7 @@
|
||||||
#include "qemu/rcu.h"
|
#include "qemu/rcu.h"
|
||||||
#include "migration/failover.h"
|
#include "migration/failover.h"
|
||||||
#include "migration/ram.h"
|
#include "migration/ram.h"
|
||||||
#ifdef CONFIG_REPLICATION
|
|
||||||
#include "block/replication.h"
|
#include "block/replication.h"
|
||||||
#endif
|
|
||||||
#include "net/colo-compare.h"
|
#include "net/colo-compare.h"
|
||||||
#include "net/colo.h"
|
#include "net/colo.h"
|
||||||
#include "block/block.h"
|
#include "block/block.h"
|
||||||
|
@ -86,7 +84,6 @@ void colo_checkpoint_delay_set(void)
|
||||||
static void secondary_vm_do_failover(void)
|
static void secondary_vm_do_failover(void)
|
||||||
{
|
{
|
||||||
/* COLO needs enable block-replication */
|
/* COLO needs enable block-replication */
|
||||||
#ifdef CONFIG_REPLICATION
|
|
||||||
int old_state;
|
int old_state;
|
||||||
MigrationIncomingState *mis = migration_incoming_get_current();
|
MigrationIncomingState *mis = migration_incoming_get_current();
|
||||||
Error *local_err = NULL;
|
Error *local_err = NULL;
|
||||||
|
@ -151,14 +148,10 @@ static void secondary_vm_do_failover(void)
|
||||||
if (mis->migration_incoming_co) {
|
if (mis->migration_incoming_co) {
|
||||||
qemu_coroutine_enter(mis->migration_incoming_co);
|
qemu_coroutine_enter(mis->migration_incoming_co);
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
abort();
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void primary_vm_do_failover(void)
|
static void primary_vm_do_failover(void)
|
||||||
{
|
{
|
||||||
#ifdef CONFIG_REPLICATION
|
|
||||||
MigrationState *s = migrate_get_current();
|
MigrationState *s = migrate_get_current();
|
||||||
int old_state;
|
int old_state;
|
||||||
Error *local_err = NULL;
|
Error *local_err = NULL;
|
||||||
|
@ -199,9 +192,6 @@ static void primary_vm_do_failover(void)
|
||||||
|
|
||||||
/* Notify COLO thread that failover work is finished */
|
/* Notify COLO thread that failover work is finished */
|
||||||
qemu_sem_post(&s->colo_exit_sem);
|
qemu_sem_post(&s->colo_exit_sem);
|
||||||
#else
|
|
||||||
abort();
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
COLOMode get_colo_mode(void)
|
COLOMode get_colo_mode(void)
|
||||||
|
@ -235,7 +225,6 @@ void colo_do_failover(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef CONFIG_REPLICATION
|
|
||||||
void qmp_xen_set_replication(bool enable, bool primary,
|
void qmp_xen_set_replication(bool enable, bool primary,
|
||||||
bool has_failover, bool failover,
|
bool has_failover, bool failover,
|
||||||
Error **errp)
|
Error **errp)
|
||||||
|
@ -289,7 +278,6 @@ void qmp_xen_colo_do_checkpoint(Error **errp)
|
||||||
/* Notify all filters of all NIC to do checkpoint */
|
/* Notify all filters of all NIC to do checkpoint */
|
||||||
colo_notify_filters_event(COLO_EVENT_CHECKPOINT, errp);
|
colo_notify_filters_event(COLO_EVENT_CHECKPOINT, errp);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
COLOStatus *qmp_query_colo_status(Error **errp)
|
COLOStatus *qmp_query_colo_status(Error **errp)
|
||||||
{
|
{
|
||||||
|
@ -453,15 +441,11 @@ static int colo_do_checkpoint_transaction(MigrationState *s,
|
||||||
}
|
}
|
||||||
qemu_mutex_lock_iothread();
|
qemu_mutex_lock_iothread();
|
||||||
|
|
||||||
#ifdef CONFIG_REPLICATION
|
|
||||||
replication_do_checkpoint_all(&local_err);
|
replication_do_checkpoint_all(&local_err);
|
||||||
if (local_err) {
|
if (local_err) {
|
||||||
qemu_mutex_unlock_iothread();
|
qemu_mutex_unlock_iothread();
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
abort();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
colo_send_message(s->to_dst_file, COLO_MESSAGE_VMSTATE_SEND, &local_err);
|
colo_send_message(s->to_dst_file, COLO_MESSAGE_VMSTATE_SEND, &local_err);
|
||||||
if (local_err) {
|
if (local_err) {
|
||||||
|
@ -579,15 +563,11 @@ static void colo_process_checkpoint(MigrationState *s)
|
||||||
object_unref(OBJECT(bioc));
|
object_unref(OBJECT(bioc));
|
||||||
|
|
||||||
qemu_mutex_lock_iothread();
|
qemu_mutex_lock_iothread();
|
||||||
#ifdef CONFIG_REPLICATION
|
|
||||||
replication_start_all(REPLICATION_MODE_PRIMARY, &local_err);
|
replication_start_all(REPLICATION_MODE_PRIMARY, &local_err);
|
||||||
if (local_err) {
|
if (local_err) {
|
||||||
qemu_mutex_unlock_iothread();
|
qemu_mutex_unlock_iothread();
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
abort();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
vm_start();
|
vm_start();
|
||||||
qemu_mutex_unlock_iothread();
|
qemu_mutex_unlock_iothread();
|
||||||
|
@ -755,7 +735,6 @@ static void colo_incoming_process_checkpoint(MigrationIncomingState *mis,
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef CONFIG_REPLICATION
|
|
||||||
replication_get_error_all(&local_err);
|
replication_get_error_all(&local_err);
|
||||||
if (local_err) {
|
if (local_err) {
|
||||||
error_propagate(errp, local_err);
|
error_propagate(errp, local_err);
|
||||||
|
@ -772,9 +751,6 @@ static void colo_incoming_process_checkpoint(MigrationIncomingState *mis,
|
||||||
qemu_mutex_unlock_iothread();
|
qemu_mutex_unlock_iothread();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
abort();
|
|
||||||
#endif
|
|
||||||
/* Notify all filters of all NIC to do checkpoint */
|
/* Notify all filters of all NIC to do checkpoint */
|
||||||
colo_notify_filters_event(COLO_EVENT_CHECKPOINT, &local_err);
|
colo_notify_filters_event(COLO_EVENT_CHECKPOINT, &local_err);
|
||||||
|
|
||||||
|
@ -881,15 +857,11 @@ void *colo_process_incoming_thread(void *opaque)
|
||||||
object_unref(OBJECT(bioc));
|
object_unref(OBJECT(bioc));
|
||||||
|
|
||||||
qemu_mutex_lock_iothread();
|
qemu_mutex_lock_iothread();
|
||||||
#ifdef CONFIG_REPLICATION
|
|
||||||
replication_start_all(REPLICATION_MODE_SECONDARY, &local_err);
|
replication_start_all(REPLICATION_MODE_SECONDARY, &local_err);
|
||||||
if (local_err) {
|
if (local_err) {
|
||||||
qemu_mutex_unlock_iothread();
|
qemu_mutex_unlock_iothread();
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
abort();
|
|
||||||
#endif
|
|
||||||
vm_start();
|
vm_start();
|
||||||
qemu_mutex_unlock_iothread();
|
qemu_mutex_unlock_iothread();
|
||||||
trace_colo_vm_state_change("stop", "run");
|
trace_colo_vm_state_change("stop", "run");
|
||||||
|
|
|
@ -13,8 +13,6 @@ softmmu_ss.add(files(
|
||||||
'block-dirty-bitmap.c',
|
'block-dirty-bitmap.c',
|
||||||
'channel.c',
|
'channel.c',
|
||||||
'channel-block.c',
|
'channel-block.c',
|
||||||
'colo-failover.c',
|
|
||||||
'colo.c',
|
|
||||||
'exec.c',
|
'exec.c',
|
||||||
'fd.c',
|
'fd.c',
|
||||||
'global_state.c',
|
'global_state.c',
|
||||||
|
@ -33,6 +31,10 @@ softmmu_ss.add(files(
|
||||||
'threadinfo.c',
|
'threadinfo.c',
|
||||||
), gnutls)
|
), gnutls)
|
||||||
|
|
||||||
|
if get_option('replication').allowed()
|
||||||
|
softmmu_ss.add(files('colo-failover.c', 'colo.c'))
|
||||||
|
endif
|
||||||
|
|
||||||
softmmu_ss.add(when: rdma, if_true: files('rdma.c'))
|
softmmu_ss.add(when: rdma, if_true: files('rdma.c'))
|
||||||
if get_option('live_block_migration').allowed()
|
if get_option('live_block_migration').allowed()
|
||||||
softmmu_ss.add(files('block.c'))
|
softmmu_ss.add(files('block.c'))
|
||||||
|
|
|
@ -643,6 +643,7 @@ void hmp_migrate_start_postcopy(Monitor *mon, const QDict *qdict)
|
||||||
hmp_handle_error(mon, err);
|
hmp_handle_error(mon, err);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef CONFIG_REPLICATION
|
||||||
void hmp_x_colo_lost_heartbeat(Monitor *mon, const QDict *qdict)
|
void hmp_x_colo_lost_heartbeat(Monitor *mon, const QDict *qdict)
|
||||||
{
|
{
|
||||||
Error *err = NULL;
|
Error *err = NULL;
|
||||||
|
@ -650,6 +651,7 @@ void hmp_x_colo_lost_heartbeat(Monitor *mon, const QDict *qdict)
|
||||||
qmp_x_colo_lost_heartbeat(&err);
|
qmp_x_colo_lost_heartbeat(&err);
|
||||||
hmp_handle_error(mon, err);
|
hmp_handle_error(mon, err);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
typedef struct HMPMigrationStatus {
|
typedef struct HMPMigrationStatus {
|
||||||
QEMUTimer *timer;
|
QEMUTimer *timer;
|
||||||
|
|
|
@ -392,6 +392,12 @@ void migration_incoming_disable_colo(void)
|
||||||
|
|
||||||
int migration_incoming_enable_colo(void)
|
int migration_incoming_enable_colo(void)
|
||||||
{
|
{
|
||||||
|
#ifndef CONFIG_REPLICATION
|
||||||
|
error_report("ENABLE_COLO command come in migration stream, but COLO "
|
||||||
|
"module is not built in");
|
||||||
|
return -ENOTSUP;
|
||||||
|
#endif
|
||||||
|
|
||||||
if (ram_block_discard_disable(true)) {
|
if (ram_block_discard_disable(true)) {
|
||||||
error_report("COLO: cannot disable RAM discard");
|
error_report("COLO: cannot disable RAM discard");
|
||||||
return -EBUSY;
|
return -EBUSY;
|
||||||
|
|
|
@ -1366,7 +1366,8 @@
|
||||||
# <- { "return": {} }
|
# <- { "return": {} }
|
||||||
##
|
##
|
||||||
{ 'command': 'x-colo-lost-heartbeat',
|
{ 'command': 'x-colo-lost-heartbeat',
|
||||||
'features': [ 'unstable' ] }
|
'features': [ 'unstable' ],
|
||||||
|
'if': 'CONFIG_REPLICATION' }
|
||||||
|
|
||||||
##
|
##
|
||||||
# @migrate_cancel:
|
# @migrate_cancel:
|
||||||
|
@ -1638,7 +1639,8 @@
|
||||||
##
|
##
|
||||||
{ 'struct': 'COLOStatus',
|
{ 'struct': 'COLOStatus',
|
||||||
'data': { 'mode': 'COLOMode', 'last-mode': 'COLOMode',
|
'data': { 'mode': 'COLOMode', 'last-mode': 'COLOMode',
|
||||||
'reason': 'COLOExitReason' } }
|
'reason': 'COLOExitReason' },
|
||||||
|
'if': 'CONFIG_REPLICATION' }
|
||||||
|
|
||||||
##
|
##
|
||||||
# @query-colo-status:
|
# @query-colo-status:
|
||||||
|
@ -1655,7 +1657,8 @@
|
||||||
# Since: 3.1
|
# Since: 3.1
|
||||||
##
|
##
|
||||||
{ 'command': 'query-colo-status',
|
{ 'command': 'query-colo-status',
|
||||||
'returns': 'COLOStatus' }
|
'returns': 'COLOStatus',
|
||||||
|
'if': 'CONFIG_REPLICATION' }
|
||||||
|
|
||||||
##
|
##
|
||||||
# @migrate-recover:
|
# @migrate-recover:
|
||||||
|
|
39
stubs/colo.c
Normal file
39
stubs/colo.c
Normal file
|
@ -0,0 +1,39 @@
|
||||||
|
#include "qemu/osdep.h"
|
||||||
|
#include "qemu/notify.h"
|
||||||
|
#include "net/colo-compare.h"
|
||||||
|
#include "migration/colo.h"
|
||||||
|
#include "migration/migration.h"
|
||||||
|
#include "qemu/error-report.h"
|
||||||
|
#include "qapi/qapi-commands-migration.h"
|
||||||
|
|
||||||
|
void colo_shutdown(void)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void *colo_process_incoming_thread(void *opaque)
|
||||||
|
{
|
||||||
|
error_report("Impossible happend: trying to start COLO thread when COLO "
|
||||||
|
"module is not built in");
|
||||||
|
abort();
|
||||||
|
}
|
||||||
|
|
||||||
|
void colo_checkpoint_delay_set(void)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void migrate_start_colo_process(MigrationState *s)
|
||||||
|
{
|
||||||
|
error_report("Impossible happend: trying to start COLO when COLO "
|
||||||
|
"module is not built in");
|
||||||
|
abort();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool migration_in_colo_state(void)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool migration_incoming_in_colo_state(void)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
|
@ -45,6 +45,7 @@ stub_ss.add(files('target-get-monitor-def.c'))
|
||||||
stub_ss.add(files('target-monitor-defs.c'))
|
stub_ss.add(files('target-monitor-defs.c'))
|
||||||
stub_ss.add(files('trace-control.c'))
|
stub_ss.add(files('trace-control.c'))
|
||||||
stub_ss.add(files('uuid.c'))
|
stub_ss.add(files('uuid.c'))
|
||||||
|
stub_ss.add(files('colo.c'))
|
||||||
stub_ss.add(files('vmstate.c'))
|
stub_ss.add(files('vmstate.c'))
|
||||||
stub_ss.add(files('vm-stop.c'))
|
stub_ss.add(files('vm-stop.c'))
|
||||||
stub_ss.add(files('win32-kbd-hook.c'))
|
stub_ss.add(files('win32-kbd-hook.c'))
|
||||||
|
|
Loading…
Reference in a new issue