mirror of https://github.com/xemu-project/xemu.git
Migration pull for 9.1
- Het's new test cases for "channels" - Het's fix for a typo for vsock parsing - Cedric's VFIO error report series - Cedric's one more patch for dirty-bitmap error reports - Zhijian's rdma deprecation patch - Yuan's zeropage optimization to fix double faults on anon mem - Zhijian's COLO fix on a crash -----BEGIN PGP SIGNATURE----- iIgEABYKADAWIQS5GE3CDMRX2s990ak7X8zN86vXBgUCZig4HxIccGV0ZXJ4QHJl ZGhhdC5jb20ACgkQO1/MzfOr1wbQiwD/V5nSJzSuAG4Ra1Fjo+LRG2TT6qk8eNCi fIytehSw6cYA/0wqarxOF0tr7ikeyhtG3w4xFf44kk6KcPkoVSl1tqoL =pJmQ -----END PGP SIGNATURE----- Merge tag 'migration-20240423-pull-request' of https://gitlab.com/peterx/qemu into staging Migration pull for 9.1 - Het's new test cases for "channels" - Het's fix for a typo for vsock parsing - Cedric's VFIO error report series - Cedric's one more patch for dirty-bitmap error reports - Zhijian's rdma deprecation patch - Yuan's zeropage optimization to fix double faults on anon mem - Zhijian's COLO fix on a crash # -----BEGIN PGP SIGNATURE----- # # iIgEABYKADAWIQS5GE3CDMRX2s990ak7X8zN86vXBgUCZig4HxIccGV0ZXJ4QHJl # ZGhhdC5jb20ACgkQO1/MzfOr1wbQiwD/V5nSJzSuAG4Ra1Fjo+LRG2TT6qk8eNCi # fIytehSw6cYA/0wqarxOF0tr7ikeyhtG3w4xFf44kk6KcPkoVSl1tqoL # =pJmQ # -----END PGP SIGNATURE----- # gpg: Signature made Tue 23 Apr 2024 03:37:19 PM PDT # gpg: using EDDSA key B9184DC20CC457DACF7DD1A93B5FCCCDF3ABD706 # gpg: issuer "peterx@redhat.com" # gpg: Good signature from "Peter Xu <xzpeter@gmail.com>" [unknown] # gpg: aka "Peter Xu <peterx@redhat.com>" [unknown] # gpg: WARNING: This key is not certified with a trusted signature! # gpg: There is no indication that the signature belongs to the owner. # Primary key fingerprint: B918 4DC2 0CC4 57DA CF7D D1A9 3B5F CCCD F3AB D706 * tag 'migration-20240423-pull-request' of https://gitlab.com/peterx/qemu: (26 commits) migration/colo: Fix bdrv_graph_rdlock_main_loop: Assertion `!qemu_in_coroutine()' failed. migration/multifd: solve zero page causing multiple page faults migration: Add Error** argument to add_bitmaps_to_list() migration: Modify ram_init_bitmaps() to report dirty tracking errors migration: Add Error** argument to xbzrle_init() migration: Add Error** argument to ram_state_init() memory: Add Error** argument to the global_dirty_log routines migration: Introduce ram_bitmaps_destroy() memory: Add Error** argument to .log_global_start() handler migration: Add Error** argument to .load_setup() handler migration: Add Error** argument to .save_setup() handler migration: Add Error** argument to qemu_savevm_state_setup() migration: Add Error** argument to vmstate_save() migration: Always report an error in ram_save_setup() migration: Always report an error in block_save_setup() vfio: Always report an error in vfio_save_setup() s390/stattrib: Add Error** argument to set_migrationmode() handler tests/qtest/migration: Fix typo for vsock in SocketAddress_to_str tests/qtest/migration: Add negative tests to validate migration QAPIs tests/qtest/migration: Add multifd_tcp_plain test using list of channels instead of uri ... Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
This commit is contained in:
commit
88daa112d4
|
@ -457,11 +457,12 @@ static void xen_log_sync(MemoryListener *listener, MemoryRegionSection *section)
|
||||||
int128_get64(section->size));
|
int128_get64(section->size));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void xen_log_global_start(MemoryListener *listener)
|
static bool xen_log_global_start(MemoryListener *listener, Error **errp)
|
||||||
{
|
{
|
||||||
if (xen_enabled()) {
|
if (xen_enabled()) {
|
||||||
xen_in_migration = true;
|
xen_in_migration = true;
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void xen_log_global_stop(MemoryListener *listener)
|
static void xen_log_global_stop(MemoryListener *listener)
|
||||||
|
@ -668,7 +669,7 @@ void xen_hvm_modified_memory(ram_addr_t start, ram_addr_t length)
|
||||||
void qmp_xen_set_global_dirty_log(bool enable, Error **errp)
|
void qmp_xen_set_global_dirty_log(bool enable, Error **errp)
|
||||||
{
|
{
|
||||||
if (enable) {
|
if (enable) {
|
||||||
memory_global_dirty_log_start(GLOBAL_DIRTY_MIGRATION);
|
memory_global_dirty_log_start(GLOBAL_DIRTY_MIGRATION, errp);
|
||||||
} else {
|
} else {
|
||||||
memory_global_dirty_log_stop(GLOBAL_DIRTY_MIGRATION);
|
memory_global_dirty_log_stop(GLOBAL_DIRTY_MIGRATION);
|
||||||
}
|
}
|
||||||
|
|
|
@ -2174,7 +2174,7 @@ static const VMStateDescription vmstate_spapr = {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
static int htab_save_setup(QEMUFile *f, void *opaque)
|
static int htab_save_setup(QEMUFile *f, void *opaque, Error **errp)
|
||||||
{
|
{
|
||||||
SpaprMachineState *spapr = opaque;
|
SpaprMachineState *spapr = opaque;
|
||||||
|
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
#include "sysemu/kvm.h"
|
#include "sysemu/kvm.h"
|
||||||
#include "exec/ram_addr.h"
|
#include "exec/ram_addr.h"
|
||||||
#include "kvm/kvm_s390x.h"
|
#include "kvm/kvm_s390x.h"
|
||||||
|
#include "qapi/error.h"
|
||||||
|
|
||||||
Object *kvm_s390_stattrib_create(void)
|
Object *kvm_s390_stattrib_create(void)
|
||||||
{
|
{
|
||||||
|
@ -137,14 +138,21 @@ static void kvm_s390_stattrib_synchronize(S390StAttribState *sa)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int kvm_s390_stattrib_set_migrationmode(S390StAttribState *sa, bool val)
|
static int kvm_s390_stattrib_set_migrationmode(S390StAttribState *sa, bool val,
|
||||||
|
Error **errp)
|
||||||
{
|
{
|
||||||
struct kvm_device_attr attr = {
|
struct kvm_device_attr attr = {
|
||||||
.group = KVM_S390_VM_MIGRATION,
|
.group = KVM_S390_VM_MIGRATION,
|
||||||
.attr = val,
|
.attr = val,
|
||||||
.addr = 0,
|
.addr = 0,
|
||||||
};
|
};
|
||||||
return kvm_vm_ioctl(kvm_state, KVM_SET_DEVICE_ATTR, &attr);
|
int r;
|
||||||
|
|
||||||
|
r = kvm_vm_ioctl(kvm_state, KVM_SET_DEVICE_ATTR, &attr);
|
||||||
|
if (r) {
|
||||||
|
error_setg_errno(errp, -r, "setting KVM_S390_VM_MIGRATION failed");
|
||||||
|
}
|
||||||
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
static long long kvm_s390_stattrib_get_dirtycount(S390StAttribState *sa)
|
static long long kvm_s390_stattrib_get_dirtycount(S390StAttribState *sa)
|
||||||
|
|
|
@ -60,11 +60,13 @@ void hmp_migrationmode(Monitor *mon, const QDict *qdict)
|
||||||
S390StAttribState *sas = s390_get_stattrib_device();
|
S390StAttribState *sas = s390_get_stattrib_device();
|
||||||
S390StAttribClass *sac = S390_STATTRIB_GET_CLASS(sas);
|
S390StAttribClass *sac = S390_STATTRIB_GET_CLASS(sas);
|
||||||
uint64_t what = qdict_get_int(qdict, "mode");
|
uint64_t what = qdict_get_int(qdict, "mode");
|
||||||
|
Error *local_err = NULL;
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
r = sac->set_migrationmode(sas, what);
|
r = sac->set_migrationmode(sas, what, &local_err);
|
||||||
if (r < 0) {
|
if (r < 0) {
|
||||||
monitor_printf(mon, "Error: %s", strerror(-r));
|
monitor_printf(mon, "Error: %s", error_get_pretty(local_err));
|
||||||
|
error_free(local_err);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -166,7 +168,7 @@ static int cmma_load(QEMUFile *f, void *opaque, int version_id)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int cmma_save_setup(QEMUFile *f, void *opaque)
|
static int cmma_save_setup(QEMUFile *f, void *opaque, Error **errp)
|
||||||
{
|
{
|
||||||
S390StAttribState *sas = S390_STATTRIB(opaque);
|
S390StAttribState *sas = S390_STATTRIB(opaque);
|
||||||
S390StAttribClass *sac = S390_STATTRIB_GET_CLASS(sas);
|
S390StAttribClass *sac = S390_STATTRIB_GET_CLASS(sas);
|
||||||
|
@ -175,7 +177,7 @@ static int cmma_save_setup(QEMUFile *f, void *opaque)
|
||||||
* Signal that we want to start a migration, thus needing PGSTE dirty
|
* Signal that we want to start a migration, thus needing PGSTE dirty
|
||||||
* tracking.
|
* tracking.
|
||||||
*/
|
*/
|
||||||
res = sac->set_migrationmode(sas, 1);
|
res = sac->set_migrationmode(sas, true, errp);
|
||||||
if (res) {
|
if (res) {
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
@ -260,7 +262,7 @@ static void cmma_save_cleanup(void *opaque)
|
||||||
{
|
{
|
||||||
S390StAttribState *sas = S390_STATTRIB(opaque);
|
S390StAttribState *sas = S390_STATTRIB(opaque);
|
||||||
S390StAttribClass *sac = S390_STATTRIB_GET_CLASS(sas);
|
S390StAttribClass *sac = S390_STATTRIB_GET_CLASS(sas);
|
||||||
sac->set_migrationmode(sas, 0);
|
sac->set_migrationmode(sas, false, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool cmma_active(void *opaque)
|
static bool cmma_active(void *opaque)
|
||||||
|
@ -293,7 +295,8 @@ static long long qemu_s390_get_dirtycount_stub(S390StAttribState *sa)
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
static int qemu_s390_set_migrationmode_stub(S390StAttribState *sa, bool value)
|
static int qemu_s390_set_migrationmode_stub(S390StAttribState *sa, bool value,
|
||||||
|
Error **errp)
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1066,7 +1066,8 @@ out:
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void vfio_listener_log_global_start(MemoryListener *listener)
|
static bool vfio_listener_log_global_start(MemoryListener *listener,
|
||||||
|
Error **errp)
|
||||||
{
|
{
|
||||||
VFIOContainerBase *bcontainer = container_of(listener, VFIOContainerBase,
|
VFIOContainerBase *bcontainer = container_of(listener, VFIOContainerBase,
|
||||||
listener);
|
listener);
|
||||||
|
@ -1083,6 +1084,7 @@ static void vfio_listener_log_global_start(MemoryListener *listener)
|
||||||
ret, strerror(-ret));
|
ret, strerror(-ret));
|
||||||
vfio_set_migration_error(ret);
|
vfio_set_migration_error(ret);
|
||||||
}
|
}
|
||||||
|
return !ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void vfio_listener_log_global_stop(MemoryListener *listener)
|
static void vfio_listener_log_global_stop(MemoryListener *listener)
|
||||||
|
|
|
@ -376,11 +376,12 @@ static int vfio_save_prepare(void *opaque, Error **errp)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int vfio_save_setup(QEMUFile *f, void *opaque)
|
static int vfio_save_setup(QEMUFile *f, void *opaque, Error **errp)
|
||||||
{
|
{
|
||||||
VFIODevice *vbasedev = opaque;
|
VFIODevice *vbasedev = opaque;
|
||||||
VFIOMigration *migration = vbasedev->migration;
|
VFIOMigration *migration = vbasedev->migration;
|
||||||
uint64_t stop_copy_size = VFIO_MIG_DEFAULT_DATA_BUFFER_SIZE;
|
uint64_t stop_copy_size = VFIO_MIG_DEFAULT_DATA_BUFFER_SIZE;
|
||||||
|
int ret;
|
||||||
|
|
||||||
qemu_put_be64(f, VFIO_MIG_FLAG_DEV_SETUP_STATE);
|
qemu_put_be64(f, VFIO_MIG_FLAG_DEV_SETUP_STATE);
|
||||||
|
|
||||||
|
@ -389,19 +390,19 @@ static int vfio_save_setup(QEMUFile *f, void *opaque)
|
||||||
stop_copy_size);
|
stop_copy_size);
|
||||||
migration->data_buffer = g_try_malloc0(migration->data_buffer_size);
|
migration->data_buffer = g_try_malloc0(migration->data_buffer_size);
|
||||||
if (!migration->data_buffer) {
|
if (!migration->data_buffer) {
|
||||||
error_report("%s: Failed to allocate migration data buffer",
|
error_setg(errp, "%s: Failed to allocate migration data buffer",
|
||||||
vbasedev->name);
|
vbasedev->name);
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (vfio_precopy_supported(vbasedev)) {
|
if (vfio_precopy_supported(vbasedev)) {
|
||||||
int ret;
|
|
||||||
|
|
||||||
switch (migration->device_state) {
|
switch (migration->device_state) {
|
||||||
case VFIO_DEVICE_STATE_RUNNING:
|
case VFIO_DEVICE_STATE_RUNNING:
|
||||||
ret = vfio_migration_set_state(vbasedev, VFIO_DEVICE_STATE_PRE_COPY,
|
ret = vfio_migration_set_state(vbasedev, VFIO_DEVICE_STATE_PRE_COPY,
|
||||||
VFIO_DEVICE_STATE_RUNNING);
|
VFIO_DEVICE_STATE_RUNNING);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
|
error_setg(errp, "%s: Failed to set new PRE_COPY state",
|
||||||
|
vbasedev->name);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -412,6 +413,8 @@ static int vfio_save_setup(QEMUFile *f, void *opaque)
|
||||||
/* vfio_save_complete_precopy() will go to STOP_COPY */
|
/* vfio_save_complete_precopy() will go to STOP_COPY */
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
error_setg(errp, "%s: Invalid device state %d", vbasedev->name,
|
||||||
|
migration->device_state);
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -420,7 +423,12 @@ static int vfio_save_setup(QEMUFile *f, void *opaque)
|
||||||
|
|
||||||
qemu_put_be64(f, VFIO_MIG_FLAG_END_OF_STATE);
|
qemu_put_be64(f, VFIO_MIG_FLAG_END_OF_STATE);
|
||||||
|
|
||||||
return qemu_file_get_error(f);
|
ret = qemu_file_get_error(f);
|
||||||
|
if (ret < 0) {
|
||||||
|
error_setg_errno(errp, -ret, "%s: save setup failed", vbasedev->name);
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void vfio_save_cleanup(void *opaque)
|
static void vfio_save_cleanup(void *opaque)
|
||||||
|
@ -580,12 +588,17 @@ static void vfio_save_state(QEMUFile *f, void *opaque)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int vfio_load_setup(QEMUFile *f, void *opaque)
|
static int vfio_load_setup(QEMUFile *f, void *opaque, Error **errp)
|
||||||
{
|
{
|
||||||
VFIODevice *vbasedev = opaque;
|
VFIODevice *vbasedev = opaque;
|
||||||
|
int ret;
|
||||||
|
|
||||||
return vfio_migration_set_state(vbasedev, VFIO_DEVICE_STATE_RESUMING,
|
ret = vfio_migration_set_state(vbasedev, VFIO_DEVICE_STATE_RESUMING,
|
||||||
vbasedev->migration->device_state);
|
vbasedev->migration->device_state);
|
||||||
|
if (ret) {
|
||||||
|
error_setg(errp, "%s: Failed to set RESUMING state", vbasedev->name);
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int vfio_load_cleanup(void *opaque)
|
static int vfio_load_cleanup(void *opaque)
|
||||||
|
|
|
@ -1044,7 +1044,7 @@ check_dev_state:
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void vhost_log_global_start(MemoryListener *listener)
|
static bool vhost_log_global_start(MemoryListener *listener, Error **errp)
|
||||||
{
|
{
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
|
@ -1052,6 +1052,7 @@ static void vhost_log_global_start(MemoryListener *listener)
|
||||||
if (r < 0) {
|
if (r < 0) {
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void vhost_log_global_stop(MemoryListener *listener)
|
static void vhost_log_global_stop(MemoryListener *listener)
|
||||||
|
|
|
@ -1001,8 +1001,11 @@ struct MemoryListener {
|
||||||
* active at that time.
|
* active at that time.
|
||||||
*
|
*
|
||||||
* @listener: The #MemoryListener.
|
* @listener: The #MemoryListener.
|
||||||
|
* @errp: pointer to Error*, to store an error if it happens.
|
||||||
|
*
|
||||||
|
* Return: true on success, else false setting @errp with error.
|
||||||
*/
|
*/
|
||||||
void (*log_global_start)(MemoryListener *listener);
|
bool (*log_global_start)(MemoryListener *listener, Error **errp);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @log_global_stop:
|
* @log_global_stop:
|
||||||
|
@ -2581,8 +2584,11 @@ void memory_listener_unregister(MemoryListener *listener);
|
||||||
* memory_global_dirty_log_start: begin dirty logging for all regions
|
* memory_global_dirty_log_start: begin dirty logging for all regions
|
||||||
*
|
*
|
||||||
* @flags: purpose of starting dirty log, migration or dirty rate
|
* @flags: purpose of starting dirty log, migration or dirty rate
|
||||||
|
* @errp: pointer to Error*, to store an error if it happens.
|
||||||
|
*
|
||||||
|
* Return: true on success, else false setting @errp with error.
|
||||||
*/
|
*/
|
||||||
void memory_global_dirty_log_start(unsigned int flags);
|
bool memory_global_dirty_log_start(unsigned int flags, Error **errp);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* memory_global_dirty_log_stop: end dirty logging for all regions
|
* memory_global_dirty_log_stop: end dirty logging for all regions
|
||||||
|
|
|
@ -58,7 +58,7 @@ struct RAMBlock {
|
||||||
off_t bitmap_offset;
|
off_t bitmap_offset;
|
||||||
uint64_t pages_offset;
|
uint64_t pages_offset;
|
||||||
|
|
||||||
/* bitmap of already received pages in postcopy */
|
/* Bitmap of already received pages. Only used on destination side. */
|
||||||
unsigned long *receivedmap;
|
unsigned long *receivedmap;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -39,7 +39,7 @@ struct S390StAttribClass {
|
||||||
int (*set_stattr)(S390StAttribState *sa, uint64_t start_gfn,
|
int (*set_stattr)(S390StAttribState *sa, uint64_t start_gfn,
|
||||||
uint32_t count, uint8_t *values);
|
uint32_t count, uint8_t *values);
|
||||||
void (*synchronize)(S390StAttribState *sa);
|
void (*synchronize)(S390StAttribState *sa);
|
||||||
int (*set_migrationmode)(S390StAttribState *sa, bool value);
|
int (*set_migrationmode)(S390StAttribState *sa, bool value, Error **errp);
|
||||||
int (*get_active)(S390StAttribState *sa);
|
int (*get_active)(S390StAttribState *sa);
|
||||||
long long (*get_dirtycount)(S390StAttribState *sa);
|
long long (*get_dirtycount)(S390StAttribState *sa);
|
||||||
};
|
};
|
||||||
|
|
|
@ -60,10 +60,11 @@ typedef struct SaveVMHandlers {
|
||||||
*
|
*
|
||||||
* @f: QEMUFile where to send the data
|
* @f: QEMUFile where to send the data
|
||||||
* @opaque: data pointer passed to register_savevm_live()
|
* @opaque: data pointer passed to register_savevm_live()
|
||||||
|
* @errp: pointer to Error*, to store an error if it happens.
|
||||||
*
|
*
|
||||||
* Returns zero to indicate success and negative for error
|
* Returns zero to indicate success and negative for error
|
||||||
*/
|
*/
|
||||||
int (*save_setup)(QEMUFile *f, void *opaque);
|
int (*save_setup)(QEMUFile *f, void *opaque, Error **errp);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @save_cleanup
|
* @save_cleanup
|
||||||
|
@ -233,10 +234,11 @@ typedef struct SaveVMHandlers {
|
||||||
*
|
*
|
||||||
* @f: QEMUFile where to receive the data
|
* @f: QEMUFile where to receive the data
|
||||||
* @opaque: data pointer passed to register_savevm_live()
|
* @opaque: data pointer passed to register_savevm_live()
|
||||||
|
* @errp: pointer to Error*, to store an error if it happens.
|
||||||
*
|
*
|
||||||
* Returns zero to indicate success and negative for error
|
* Returns zero to indicate success and negative for error
|
||||||
*/
|
*/
|
||||||
int (*load_setup)(QEMUFile *f, void *opaque);
|
int (*load_setup)(QEMUFile *f, void *opaque, Error **errp);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @load_cleanup
|
* @load_cleanup
|
||||||
|
|
|
@ -481,13 +481,13 @@ static void dirty_bitmap_do_save_cleanup(DBMSaveState *s)
|
||||||
|
|
||||||
/* Called with the BQL taken. */
|
/* Called with the BQL taken. */
|
||||||
static int add_bitmaps_to_list(DBMSaveState *s, BlockDriverState *bs,
|
static int add_bitmaps_to_list(DBMSaveState *s, BlockDriverState *bs,
|
||||||
const char *bs_name, GHashTable *alias_map)
|
const char *bs_name, GHashTable *alias_map,
|
||||||
|
Error **errp)
|
||||||
{
|
{
|
||||||
BdrvDirtyBitmap *bitmap;
|
BdrvDirtyBitmap *bitmap;
|
||||||
SaveBitmapState *dbms;
|
SaveBitmapState *dbms;
|
||||||
GHashTable *bitmap_aliases;
|
GHashTable *bitmap_aliases;
|
||||||
const char *node_alias, *bitmap_name, *bitmap_alias;
|
const char *node_alias, *bitmap_name, *bitmap_alias;
|
||||||
Error *local_err = NULL;
|
|
||||||
|
|
||||||
/* When an alias map is given, @bs_name must be @bs's node name */
|
/* When an alias map is given, @bs_name must be @bs's node name */
|
||||||
assert(!alias_map || !strcmp(bs_name, bdrv_get_node_name(bs)));
|
assert(!alias_map || !strcmp(bs_name, bdrv_get_node_name(bs)));
|
||||||
|
@ -504,8 +504,8 @@ static int add_bitmaps_to_list(DBMSaveState *s, BlockDriverState *bs,
|
||||||
bitmap_name = bdrv_dirty_bitmap_name(bitmap);
|
bitmap_name = bdrv_dirty_bitmap_name(bitmap);
|
||||||
|
|
||||||
if (!bs_name || strcmp(bs_name, "") == 0) {
|
if (!bs_name || strcmp(bs_name, "") == 0) {
|
||||||
error_report("Bitmap '%s' in unnamed node can't be migrated",
|
error_setg(errp, "Bitmap '%s' in unnamed node can't be migrated",
|
||||||
bitmap_name);
|
bitmap_name);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -525,9 +525,9 @@ static int add_bitmaps_to_list(DBMSaveState *s, BlockDriverState *bs,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (node_alias[0] == '#') {
|
if (node_alias[0] == '#') {
|
||||||
error_report("Bitmap '%s' in a node with auto-generated "
|
error_setg(errp, "Bitmap '%s' in a node with auto-generated "
|
||||||
"name '%s' can't be migrated",
|
"name '%s' can't be migrated",
|
||||||
bitmap_name, node_alias);
|
bitmap_name, node_alias);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -538,8 +538,7 @@ static int add_bitmaps_to_list(DBMSaveState *s, BlockDriverState *bs,
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bdrv_dirty_bitmap_check(bitmap, BDRV_BITMAP_DEFAULT, &local_err)) {
|
if (bdrv_dirty_bitmap_check(bitmap, BDRV_BITMAP_DEFAULT, errp)) {
|
||||||
error_report_err(local_err);
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -558,9 +557,9 @@ static int add_bitmaps_to_list(DBMSaveState *s, BlockDriverState *bs,
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (strlen(bitmap_name) > UINT8_MAX) {
|
if (strlen(bitmap_name) > UINT8_MAX) {
|
||||||
error_report("Cannot migrate bitmap '%s' on node '%s': "
|
error_setg(errp, "Cannot migrate bitmap '%s' on node '%s': "
|
||||||
"Name is longer than %u bytes",
|
"Name is longer than %u bytes",
|
||||||
bitmap_name, bs_name, UINT8_MAX);
|
bitmap_name, bs_name, UINT8_MAX);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
bitmap_alias = bitmap_name;
|
bitmap_alias = bitmap_name;
|
||||||
|
@ -599,7 +598,7 @@ static int add_bitmaps_to_list(DBMSaveState *s, BlockDriverState *bs,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Called with the BQL taken. */
|
/* Called with the BQL taken. */
|
||||||
static int init_dirty_bitmap_migration(DBMSaveState *s)
|
static int init_dirty_bitmap_migration(DBMSaveState *s, Error **errp)
|
||||||
{
|
{
|
||||||
BlockDriverState *bs;
|
BlockDriverState *bs;
|
||||||
SaveBitmapState *dbms;
|
SaveBitmapState *dbms;
|
||||||
|
@ -643,7 +642,7 @@ static int init_dirty_bitmap_migration(DBMSaveState *s)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bs && bs->drv && !bs->drv->is_filter) {
|
if (bs && bs->drv && !bs->drv->is_filter) {
|
||||||
if (add_bitmaps_to_list(s, bs, name, NULL)) {
|
if (add_bitmaps_to_list(s, bs, name, NULL, errp)) {
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
g_hash_table_add(handled_by_blk, bs);
|
g_hash_table_add(handled_by_blk, bs);
|
||||||
|
@ -656,7 +655,8 @@ static int init_dirty_bitmap_migration(DBMSaveState *s)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (add_bitmaps_to_list(s, bs, bdrv_get_node_name(bs), alias_map)) {
|
if (add_bitmaps_to_list(s, bs, bdrv_get_node_name(bs), alias_map,
|
||||||
|
errp)) {
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1213,12 +1213,12 @@ fail:
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int dirty_bitmap_save_setup(QEMUFile *f, void *opaque)
|
static int dirty_bitmap_save_setup(QEMUFile *f, void *opaque, Error **errp)
|
||||||
{
|
{
|
||||||
DBMSaveState *s = &((DBMState *)opaque)->save;
|
DBMSaveState *s = &((DBMState *)opaque)->save;
|
||||||
SaveBitmapState *dbms = NULL;
|
SaveBitmapState *dbms = NULL;
|
||||||
|
|
||||||
if (init_dirty_bitmap_migration(s) < 0) {
|
if (init_dirty_bitmap_migration(s, errp) < 0) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -367,7 +367,7 @@ static void unset_dirty_tracking(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int init_blk_migration(QEMUFile *f)
|
static int init_blk_migration(QEMUFile *f, Error **errp)
|
||||||
{
|
{
|
||||||
BlockDriverState *bs;
|
BlockDriverState *bs;
|
||||||
BlkMigDevState *bmds;
|
BlkMigDevState *bmds;
|
||||||
|
@ -378,7 +378,6 @@ static int init_blk_migration(QEMUFile *f)
|
||||||
BlkMigDevState *bmds;
|
BlkMigDevState *bmds;
|
||||||
BlockDriverState *bs;
|
BlockDriverState *bs;
|
||||||
} *bmds_bs;
|
} *bmds_bs;
|
||||||
Error *local_err = NULL;
|
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
GRAPH_RDLOCK_GUARD_MAINLOOP();
|
GRAPH_RDLOCK_GUARD_MAINLOOP();
|
||||||
|
@ -406,6 +405,8 @@ static int init_blk_migration(QEMUFile *f)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (sectors < 0) {
|
if (sectors < 0) {
|
||||||
|
error_setg(errp, "Error getting length of block device %s",
|
||||||
|
bdrv_get_device_name(bs));
|
||||||
ret = sectors;
|
ret = sectors;
|
||||||
bdrv_next_cleanup(&it);
|
bdrv_next_cleanup(&it);
|
||||||
goto out;
|
goto out;
|
||||||
|
@ -442,9 +443,8 @@ static int init_blk_migration(QEMUFile *f)
|
||||||
bs = bmds_bs[i].bs;
|
bs = bmds_bs[i].bs;
|
||||||
|
|
||||||
if (bmds) {
|
if (bmds) {
|
||||||
ret = blk_insert_bs(bmds->blk, bs, &local_err);
|
ret = blk_insert_bs(bmds->blk, bs, errp);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
error_report_err(local_err);
|
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -711,7 +711,7 @@ static void block_migration_cleanup(void *opaque)
|
||||||
blk_mig_unlock();
|
blk_mig_unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
static int block_save_setup(QEMUFile *f, void *opaque)
|
static int block_save_setup(QEMUFile *f, void *opaque, Error **errp)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
|
@ -721,7 +721,7 @@ static int block_save_setup(QEMUFile *f, void *opaque)
|
||||||
warn_report("block migration is deprecated;"
|
warn_report("block migration is deprecated;"
|
||||||
" use blockdev-mirror with NBD instead");
|
" use blockdev-mirror with NBD instead");
|
||||||
|
|
||||||
ret = init_blk_migration(f);
|
ret = init_blk_migration(f, errp);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -729,10 +729,15 @@ static int block_save_setup(QEMUFile *f, void *opaque)
|
||||||
/* start track dirty blocks */
|
/* start track dirty blocks */
|
||||||
ret = set_dirty_tracking();
|
ret = set_dirty_tracking();
|
||||||
if (ret) {
|
if (ret) {
|
||||||
|
error_setg_errno(errp, -ret, "Failed to start block dirty tracking");
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = flush_blks(f);
|
ret = flush_blks(f);
|
||||||
|
if (ret) {
|
||||||
|
error_setg_errno(errp, -ret, "Flushing block failed");
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
blk_mig_reset_dirty_cursor();
|
blk_mig_reset_dirty_cursor();
|
||||||
qemu_put_be64(f, BLK_MIG_FLAG_EOS);
|
qemu_put_be64(f, BLK_MIG_FLAG_EOS);
|
||||||
|
|
||||||
|
|
|
@ -835,6 +835,16 @@ static void *colo_process_incoming_thread(void *opaque)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Make sure all file formats throw away their mutable metadata */
|
||||||
|
bql_lock();
|
||||||
|
bdrv_activate_all(&local_err);
|
||||||
|
if (local_err) {
|
||||||
|
bql_unlock();
|
||||||
|
error_report_err(local_err);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
bql_unlock();
|
||||||
|
|
||||||
failover_init_state();
|
failover_init_state();
|
||||||
|
|
||||||
mis->to_src_file = qemu_file_get_return_path(mis->from_src_file);
|
mis->to_src_file = qemu_file_get_return_path(mis->from_src_file);
|
||||||
|
@ -922,7 +932,6 @@ out:
|
||||||
int coroutine_fn colo_incoming_co(void)
|
int coroutine_fn colo_incoming_co(void)
|
||||||
{
|
{
|
||||||
MigrationIncomingState *mis = migration_incoming_get_current();
|
MigrationIncomingState *mis = migration_incoming_get_current();
|
||||||
Error *local_err = NULL;
|
|
||||||
QemuThread th;
|
QemuThread th;
|
||||||
|
|
||||||
assert(bql_locked());
|
assert(bql_locked());
|
||||||
|
@ -931,13 +940,6 @@ int coroutine_fn colo_incoming_co(void)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Make sure all file formats throw away their mutable metadata */
|
|
||||||
bdrv_activate_all(&local_err);
|
|
||||||
if (local_err) {
|
|
||||||
error_report_err(local_err);
|
|
||||||
return -EINVAL;
|
|
||||||
}
|
|
||||||
|
|
||||||
qemu_thread_create(&th, "COLO incoming", colo_process_incoming_thread,
|
qemu_thread_create(&th, "COLO incoming", colo_process_incoming_thread,
|
||||||
mis, QEMU_THREAD_JOINABLE);
|
mis, QEMU_THREAD_JOINABLE);
|
||||||
|
|
||||||
|
|
|
@ -90,9 +90,15 @@ static int64_t do_calculate_dirtyrate(DirtyPageRecord dirty_pages,
|
||||||
|
|
||||||
void global_dirty_log_change(unsigned int flag, bool start)
|
void global_dirty_log_change(unsigned int flag, bool start)
|
||||||
{
|
{
|
||||||
|
Error *local_err = NULL;
|
||||||
|
bool ret;
|
||||||
|
|
||||||
bql_lock();
|
bql_lock();
|
||||||
if (start) {
|
if (start) {
|
||||||
memory_global_dirty_log_start(flag);
|
ret = memory_global_dirty_log_start(flag, &local_err);
|
||||||
|
if (!ret) {
|
||||||
|
error_report_err(local_err);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
memory_global_dirty_log_stop(flag);
|
memory_global_dirty_log_stop(flag);
|
||||||
}
|
}
|
||||||
|
@ -608,9 +614,12 @@ static void calculate_dirtyrate_dirty_bitmap(struct DirtyRateConfig config)
|
||||||
{
|
{
|
||||||
int64_t start_time;
|
int64_t start_time;
|
||||||
DirtyPageRecord dirty_pages;
|
DirtyPageRecord dirty_pages;
|
||||||
|
Error *local_err = NULL;
|
||||||
|
|
||||||
bql_lock();
|
bql_lock();
|
||||||
memory_global_dirty_log_start(GLOBAL_DIRTY_DIRTY_RATE);
|
if (!memory_global_dirty_log_start(GLOBAL_DIRTY_DIRTY_RATE, &local_err)) {
|
||||||
|
error_report_err(local_err);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* 1'round of log sync may return all 1 bits with
|
* 1'round of log sync may return all 1 bits with
|
||||||
|
|
|
@ -3431,6 +3431,8 @@ static void *migration_thread(void *opaque)
|
||||||
int64_t setup_start = qemu_clock_get_ms(QEMU_CLOCK_HOST);
|
int64_t setup_start = qemu_clock_get_ms(QEMU_CLOCK_HOST);
|
||||||
MigThrError thr_error;
|
MigThrError thr_error;
|
||||||
bool urgent = false;
|
bool urgent = false;
|
||||||
|
Error *local_err = NULL;
|
||||||
|
int ret;
|
||||||
|
|
||||||
thread = migration_threads_add("live_migration", qemu_get_thread_id());
|
thread = migration_threads_add("live_migration", qemu_get_thread_id());
|
||||||
|
|
||||||
|
@ -3474,12 +3476,24 @@ static void *migration_thread(void *opaque)
|
||||||
}
|
}
|
||||||
|
|
||||||
bql_lock();
|
bql_lock();
|
||||||
qemu_savevm_state_setup(s->to_dst_file);
|
ret = qemu_savevm_state_setup(s->to_dst_file, &local_err);
|
||||||
bql_unlock();
|
bql_unlock();
|
||||||
|
|
||||||
qemu_savevm_wait_unplug(s, MIGRATION_STATUS_SETUP,
|
qemu_savevm_wait_unplug(s, MIGRATION_STATUS_SETUP,
|
||||||
MIGRATION_STATUS_ACTIVE);
|
MIGRATION_STATUS_ACTIVE);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Handle SETUP failures after waiting for virtio-net-failover
|
||||||
|
* devices to unplug. This to preserve migration state transitions.
|
||||||
|
*/
|
||||||
|
if (ret) {
|
||||||
|
migrate_set_error(s, local_err);
|
||||||
|
error_free(local_err);
|
||||||
|
migrate_set_state(&s->state, MIGRATION_STATUS_ACTIVE,
|
||||||
|
MIGRATION_STATUS_FAILED);
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
s->setup_time = qemu_clock_get_ms(QEMU_CLOCK_HOST) - setup_start;
|
s->setup_time = qemu_clock_get_ms(QEMU_CLOCK_HOST) - setup_start;
|
||||||
|
|
||||||
trace_migration_thread_setup_complete();
|
trace_migration_thread_setup_complete();
|
||||||
|
@ -3553,6 +3567,8 @@ static void *bg_migration_thread(void *opaque)
|
||||||
MigThrError thr_error;
|
MigThrError thr_error;
|
||||||
QEMUFile *fb;
|
QEMUFile *fb;
|
||||||
bool early_fail = true;
|
bool early_fail = true;
|
||||||
|
Error *local_err = NULL;
|
||||||
|
int ret;
|
||||||
|
|
||||||
rcu_register_thread();
|
rcu_register_thread();
|
||||||
object_ref(OBJECT(s));
|
object_ref(OBJECT(s));
|
||||||
|
@ -3586,12 +3602,24 @@ static void *bg_migration_thread(void *opaque)
|
||||||
|
|
||||||
bql_lock();
|
bql_lock();
|
||||||
qemu_savevm_state_header(s->to_dst_file);
|
qemu_savevm_state_header(s->to_dst_file);
|
||||||
qemu_savevm_state_setup(s->to_dst_file);
|
ret = qemu_savevm_state_setup(s->to_dst_file, &local_err);
|
||||||
bql_unlock();
|
bql_unlock();
|
||||||
|
|
||||||
qemu_savevm_wait_unplug(s, MIGRATION_STATUS_SETUP,
|
qemu_savevm_wait_unplug(s, MIGRATION_STATUS_SETUP,
|
||||||
MIGRATION_STATUS_ACTIVE);
|
MIGRATION_STATUS_ACTIVE);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Handle SETUP failures after waiting for virtio-net-failover
|
||||||
|
* devices to unplug. This to preserve migration state transitions.
|
||||||
|
*/
|
||||||
|
if (ret) {
|
||||||
|
migrate_set_error(s, local_err);
|
||||||
|
error_free(local_err);
|
||||||
|
migrate_set_state(&s->state, MIGRATION_STATUS_ACTIVE,
|
||||||
|
MIGRATION_STATUS_FAILED);
|
||||||
|
goto fail_setup;
|
||||||
|
}
|
||||||
|
|
||||||
s->setup_time = qemu_clock_get_ms(QEMU_CLOCK_HOST) - setup_start;
|
s->setup_time = qemu_clock_get_ms(QEMU_CLOCK_HOST) - setup_start;
|
||||||
|
|
||||||
trace_migration_thread_setup_complete();
|
trace_migration_thread_setup_complete();
|
||||||
|
@ -3660,6 +3688,7 @@ fail:
|
||||||
bql_unlock();
|
bql_unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fail_setup:
|
||||||
bg_migration_iteration_finish(s);
|
bg_migration_iteration_finish(s);
|
||||||
|
|
||||||
qemu_fclose(fb);
|
qemu_fclose(fb);
|
||||||
|
|
|
@ -80,8 +80,10 @@ void multifd_recv_zero_page_process(MultiFDRecvParams *p)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < p->zero_num; i++) {
|
for (int i = 0; i < p->zero_num; i++) {
|
||||||
void *page = p->host + p->zero[i];
|
void *page = p->host + p->zero[i];
|
||||||
if (!buffer_is_zero(page, p->page_size)) {
|
if (ramblock_recv_bitmap_test_byte_offset(p->block, p->zero[i])) {
|
||||||
memset(page, 0, p->page_size);
|
memset(page, 0, p->page_size);
|
||||||
|
} else {
|
||||||
|
ramblock_recv_bitmap_set_offset(p->block, p->zero[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -284,6 +284,7 @@ static int zlib_recv(MultiFDRecvParams *p, Error **errp)
|
||||||
int flush = Z_NO_FLUSH;
|
int flush = Z_NO_FLUSH;
|
||||||
unsigned long start = zs->total_out;
|
unsigned long start = zs->total_out;
|
||||||
|
|
||||||
|
ramblock_recv_bitmap_set_offset(p->block, p->normal[i]);
|
||||||
if (i == p->normal_num - 1) {
|
if (i == p->normal_num - 1) {
|
||||||
flush = Z_SYNC_FLUSH;
|
flush = Z_SYNC_FLUSH;
|
||||||
}
|
}
|
||||||
|
|
|
@ -278,6 +278,7 @@ static int zstd_recv(MultiFDRecvParams *p, Error **errp)
|
||||||
z->in.pos = 0;
|
z->in.pos = 0;
|
||||||
|
|
||||||
for (i = 0; i < p->normal_num; i++) {
|
for (i = 0; i < p->normal_num; i++) {
|
||||||
|
ramblock_recv_bitmap_set_offset(p->block, p->normal[i]);
|
||||||
z->out.dst = p->host + p->normal[i];
|
z->out.dst = p->host + p->normal[i];
|
||||||
z->out.size = p->page_size;
|
z->out.size = p->page_size;
|
||||||
z->out.pos = 0;
|
z->out.pos = 0;
|
||||||
|
|
|
@ -277,6 +277,7 @@ static int nocomp_recv(MultiFDRecvParams *p, Error **errp)
|
||||||
for (int i = 0; i < p->normal_num; i++) {
|
for (int i = 0; i < p->normal_num; i++) {
|
||||||
p->iov[i].iov_base = p->host + p->normal[i];
|
p->iov[i].iov_base = p->host + p->normal[i];
|
||||||
p->iov[i].iov_len = p->page_size;
|
p->iov[i].iov_len = p->page_size;
|
||||||
|
ramblock_recv_bitmap_set_offset(p->block, p->normal[i]);
|
||||||
}
|
}
|
||||||
return qio_channel_readv_all(p->c, p->iov, p->normal_num, errp);
|
return qio_channel_readv_all(p->c, p->iov, p->normal_num, errp);
|
||||||
}
|
}
|
||||||
|
|
110
migration/ram.c
110
migration/ram.c
|
@ -275,6 +275,10 @@ void ramblock_recv_bitmap_set_range(RAMBlock *rb, void *host_addr,
|
||||||
nr);
|
nr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ramblock_recv_bitmap_set_offset(RAMBlock *rb, uint64_t byte_offset)
|
||||||
|
{
|
||||||
|
set_bit_atomic(byte_offset >> TARGET_PAGE_BITS, rb->receivedmap);
|
||||||
|
}
|
||||||
#define RAMBLOCK_RECV_BITMAP_ENDING (0x0123456789abcdefULL)
|
#define RAMBLOCK_RECV_BITMAP_ENDING (0x0123456789abcdefULL)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -2438,10 +2442,23 @@ static void xbzrle_cleanup(void)
|
||||||
XBZRLE_cache_unlock();
|
XBZRLE_cache_unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void ram_bitmaps_destroy(void)
|
||||||
|
{
|
||||||
|
RAMBlock *block;
|
||||||
|
|
||||||
|
RAMBLOCK_FOREACH_NOT_IGNORED(block) {
|
||||||
|
g_free(block->clear_bmap);
|
||||||
|
block->clear_bmap = NULL;
|
||||||
|
g_free(block->bmap);
|
||||||
|
block->bmap = NULL;
|
||||||
|
g_free(block->file_bmap);
|
||||||
|
block->file_bmap = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void ram_save_cleanup(void *opaque)
|
static void ram_save_cleanup(void *opaque)
|
||||||
{
|
{
|
||||||
RAMState **rsp = opaque;
|
RAMState **rsp = opaque;
|
||||||
RAMBlock *block;
|
|
||||||
|
|
||||||
/* We don't use dirty log with background snapshots */
|
/* We don't use dirty log with background snapshots */
|
||||||
if (!migrate_background_snapshot()) {
|
if (!migrate_background_snapshot()) {
|
||||||
|
@ -2458,12 +2475,7 @@ static void ram_save_cleanup(void *opaque)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
RAMBLOCK_FOREACH_NOT_IGNORED(block) {
|
ram_bitmaps_destroy();
|
||||||
g_free(block->clear_bmap);
|
|
||||||
block->clear_bmap = NULL;
|
|
||||||
g_free(block->bmap);
|
|
||||||
block->bmap = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
xbzrle_cleanup();
|
xbzrle_cleanup();
|
||||||
compress_threads_save_cleanup();
|
compress_threads_save_cleanup();
|
||||||
|
@ -2719,44 +2731,41 @@ int ram_discard_range(const char *rbname, uint64_t start, size_t length)
|
||||||
* For every allocation, we will try not to crash the VM if the
|
* For every allocation, we will try not to crash the VM if the
|
||||||
* allocation failed.
|
* allocation failed.
|
||||||
*/
|
*/
|
||||||
static int xbzrle_init(void)
|
static bool xbzrle_init(Error **errp)
|
||||||
{
|
{
|
||||||
Error *local_err = NULL;
|
|
||||||
|
|
||||||
if (!migrate_xbzrle()) {
|
if (!migrate_xbzrle()) {
|
||||||
return 0;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
XBZRLE_cache_lock();
|
XBZRLE_cache_lock();
|
||||||
|
|
||||||
XBZRLE.zero_target_page = g_try_malloc0(TARGET_PAGE_SIZE);
|
XBZRLE.zero_target_page = g_try_malloc0(TARGET_PAGE_SIZE);
|
||||||
if (!XBZRLE.zero_target_page) {
|
if (!XBZRLE.zero_target_page) {
|
||||||
error_report("%s: Error allocating zero page", __func__);
|
error_setg(errp, "%s: Error allocating zero page", __func__);
|
||||||
goto err_out;
|
goto err_out;
|
||||||
}
|
}
|
||||||
|
|
||||||
XBZRLE.cache = cache_init(migrate_xbzrle_cache_size(),
|
XBZRLE.cache = cache_init(migrate_xbzrle_cache_size(),
|
||||||
TARGET_PAGE_SIZE, &local_err);
|
TARGET_PAGE_SIZE, errp);
|
||||||
if (!XBZRLE.cache) {
|
if (!XBZRLE.cache) {
|
||||||
error_report_err(local_err);
|
|
||||||
goto free_zero_page;
|
goto free_zero_page;
|
||||||
}
|
}
|
||||||
|
|
||||||
XBZRLE.encoded_buf = g_try_malloc0(TARGET_PAGE_SIZE);
|
XBZRLE.encoded_buf = g_try_malloc0(TARGET_PAGE_SIZE);
|
||||||
if (!XBZRLE.encoded_buf) {
|
if (!XBZRLE.encoded_buf) {
|
||||||
error_report("%s: Error allocating encoded_buf", __func__);
|
error_setg(errp, "%s: Error allocating encoded_buf", __func__);
|
||||||
goto free_cache;
|
goto free_cache;
|
||||||
}
|
}
|
||||||
|
|
||||||
XBZRLE.current_buf = g_try_malloc(TARGET_PAGE_SIZE);
|
XBZRLE.current_buf = g_try_malloc(TARGET_PAGE_SIZE);
|
||||||
if (!XBZRLE.current_buf) {
|
if (!XBZRLE.current_buf) {
|
||||||
error_report("%s: Error allocating current_buf", __func__);
|
error_setg(errp, "%s: Error allocating current_buf", __func__);
|
||||||
goto free_encoded_buf;
|
goto free_encoded_buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* We are all good */
|
/* We are all good */
|
||||||
XBZRLE_cache_unlock();
|
XBZRLE_cache_unlock();
|
||||||
return 0;
|
return true;
|
||||||
|
|
||||||
free_encoded_buf:
|
free_encoded_buf:
|
||||||
g_free(XBZRLE.encoded_buf);
|
g_free(XBZRLE.encoded_buf);
|
||||||
|
@ -2769,16 +2778,16 @@ free_zero_page:
|
||||||
XBZRLE.zero_target_page = NULL;
|
XBZRLE.zero_target_page = NULL;
|
||||||
err_out:
|
err_out:
|
||||||
XBZRLE_cache_unlock();
|
XBZRLE_cache_unlock();
|
||||||
return -ENOMEM;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int ram_state_init(RAMState **rsp)
|
static bool ram_state_init(RAMState **rsp, Error **errp)
|
||||||
{
|
{
|
||||||
*rsp = g_try_new0(RAMState, 1);
|
*rsp = g_try_new0(RAMState, 1);
|
||||||
|
|
||||||
if (!*rsp) {
|
if (!*rsp) {
|
||||||
error_report("%s: Init ramstate fail", __func__);
|
error_setg(errp, "%s: Init ramstate fail", __func__);
|
||||||
return -1;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
qemu_mutex_init(&(*rsp)->bitmap_mutex);
|
qemu_mutex_init(&(*rsp)->bitmap_mutex);
|
||||||
|
@ -2794,7 +2803,7 @@ static int ram_state_init(RAMState **rsp)
|
||||||
(*rsp)->migration_dirty_pages = (*rsp)->ram_bytes_total >> TARGET_PAGE_BITS;
|
(*rsp)->migration_dirty_pages = (*rsp)->ram_bytes_total >> TARGET_PAGE_BITS;
|
||||||
ram_state_reset(*rsp);
|
ram_state_reset(*rsp);
|
||||||
|
|
||||||
return 0;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ram_list_init_bitmaps(void)
|
static void ram_list_init_bitmaps(void)
|
||||||
|
@ -2852,39 +2861,53 @@ static void migration_bitmap_clear_discarded_pages(RAMState *rs)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ram_init_bitmaps(RAMState *rs)
|
static bool ram_init_bitmaps(RAMState *rs, Error **errp)
|
||||||
{
|
{
|
||||||
|
bool ret = true;
|
||||||
|
|
||||||
qemu_mutex_lock_ramlist();
|
qemu_mutex_lock_ramlist();
|
||||||
|
|
||||||
WITH_RCU_READ_LOCK_GUARD() {
|
WITH_RCU_READ_LOCK_GUARD() {
|
||||||
ram_list_init_bitmaps();
|
ram_list_init_bitmaps();
|
||||||
/* We don't use dirty log with background snapshots */
|
/* We don't use dirty log with background snapshots */
|
||||||
if (!migrate_background_snapshot()) {
|
if (!migrate_background_snapshot()) {
|
||||||
memory_global_dirty_log_start(GLOBAL_DIRTY_MIGRATION);
|
ret = memory_global_dirty_log_start(GLOBAL_DIRTY_MIGRATION, errp);
|
||||||
|
if (!ret) {
|
||||||
|
goto out_unlock;
|
||||||
|
}
|
||||||
migration_bitmap_sync_precopy(rs, false);
|
migration_bitmap_sync_precopy(rs, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
out_unlock:
|
||||||
qemu_mutex_unlock_ramlist();
|
qemu_mutex_unlock_ramlist();
|
||||||
|
|
||||||
|
if (!ret) {
|
||||||
|
ram_bitmaps_destroy();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* After an eventual first bitmap sync, fixup the initial bitmap
|
* After an eventual first bitmap sync, fixup the initial bitmap
|
||||||
* containing all 1s to exclude any discarded pages from migration.
|
* containing all 1s to exclude any discarded pages from migration.
|
||||||
*/
|
*/
|
||||||
migration_bitmap_clear_discarded_pages(rs);
|
migration_bitmap_clear_discarded_pages(rs);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int ram_init_all(RAMState **rsp)
|
static int ram_init_all(RAMState **rsp, Error **errp)
|
||||||
{
|
{
|
||||||
if (ram_state_init(rsp)) {
|
if (!ram_state_init(rsp, errp)) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (xbzrle_init()) {
|
if (!xbzrle_init(errp)) {
|
||||||
ram_state_cleanup(rsp);
|
ram_state_cleanup(rsp);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
ram_init_bitmaps(*rsp);
|
if (!ram_init_bitmaps(*rsp, errp)) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -3066,20 +3089,22 @@ static bool mapped_ram_read_header(QEMUFile *file, MappedRamHeader *header,
|
||||||
*
|
*
|
||||||
* @f: QEMUFile where to send the data
|
* @f: QEMUFile where to send the data
|
||||||
* @opaque: RAMState pointer
|
* @opaque: RAMState pointer
|
||||||
|
* @errp: pointer to Error*, to store an error if it happens.
|
||||||
*/
|
*/
|
||||||
static int ram_save_setup(QEMUFile *f, void *opaque)
|
static int ram_save_setup(QEMUFile *f, void *opaque, Error **errp)
|
||||||
{
|
{
|
||||||
RAMState **rsp = opaque;
|
RAMState **rsp = opaque;
|
||||||
RAMBlock *block;
|
RAMBlock *block;
|
||||||
int ret, max_hg_page_size;
|
int ret, max_hg_page_size;
|
||||||
|
|
||||||
if (compress_threads_save_setup()) {
|
if (compress_threads_save_setup()) {
|
||||||
|
error_setg(errp, "%s: failed to start compress threads", __func__);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* migration has already setup the bitmap, reuse it. */
|
/* migration has already setup the bitmap, reuse it. */
|
||||||
if (!migration_in_colo_state()) {
|
if (!migration_in_colo_state()) {
|
||||||
if (ram_init_all(rsp) != 0) {
|
if (ram_init_all(rsp, errp) != 0) {
|
||||||
compress_threads_save_cleanup();
|
compress_threads_save_cleanup();
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -3116,12 +3141,14 @@ static int ram_save_setup(QEMUFile *f, void *opaque)
|
||||||
|
|
||||||
ret = rdma_registration_start(f, RAM_CONTROL_SETUP);
|
ret = rdma_registration_start(f, RAM_CONTROL_SETUP);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
|
error_setg(errp, "%s: failed to start RDMA registration", __func__);
|
||||||
qemu_file_set_error(f, ret);
|
qemu_file_set_error(f, ret);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = rdma_registration_stop(f, RAM_CONTROL_SETUP);
|
ret = rdma_registration_stop(f, RAM_CONTROL_SETUP);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
|
error_setg(errp, "%s: failed to stop RDMA registration", __func__);
|
||||||
qemu_file_set_error(f, ret);
|
qemu_file_set_error(f, ret);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -3138,6 +3165,7 @@ static int ram_save_setup(QEMUFile *f, void *opaque)
|
||||||
ret = multifd_send_sync_main();
|
ret = multifd_send_sync_main();
|
||||||
bql_lock();
|
bql_lock();
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
|
error_setg(errp, "%s: multifd synchronization failed", __func__);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3147,7 +3175,11 @@ static int ram_save_setup(QEMUFile *f, void *opaque)
|
||||||
}
|
}
|
||||||
|
|
||||||
qemu_put_be64(f, RAM_SAVE_FLAG_EOS);
|
qemu_put_be64(f, RAM_SAVE_FLAG_EOS);
|
||||||
return qemu_fflush(f);
|
ret = qemu_fflush(f);
|
||||||
|
if (ret < 0) {
|
||||||
|
error_setg_errno(errp, -ret, "%s failed", __func__);
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ram_save_file_bmap(QEMUFile *f)
|
static void ram_save_file_bmap(QEMUFile *f)
|
||||||
|
@ -3592,7 +3624,11 @@ void ram_handle_zero(void *host, uint64_t size)
|
||||||
|
|
||||||
static void colo_init_ram_state(void)
|
static void colo_init_ram_state(void)
|
||||||
{
|
{
|
||||||
ram_state_init(&ram_state);
|
Error *local_err = NULL;
|
||||||
|
|
||||||
|
if (!ram_state_init(&ram_state, &local_err)) {
|
||||||
|
error_report_err(local_err);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -3647,6 +3683,8 @@ int colo_init_ram_cache(void)
|
||||||
void colo_incoming_start_dirty_log(void)
|
void colo_incoming_start_dirty_log(void)
|
||||||
{
|
{
|
||||||
RAMBlock *block = NULL;
|
RAMBlock *block = NULL;
|
||||||
|
Error *local_err = NULL;
|
||||||
|
|
||||||
/* For memory_global_dirty_log_start below. */
|
/* For memory_global_dirty_log_start below. */
|
||||||
bql_lock();
|
bql_lock();
|
||||||
qemu_mutex_lock_ramlist();
|
qemu_mutex_lock_ramlist();
|
||||||
|
@ -3658,7 +3696,10 @@ void colo_incoming_start_dirty_log(void)
|
||||||
/* Discard this dirty bitmap record */
|
/* Discard this dirty bitmap record */
|
||||||
bitmap_zero(block->bmap, block->max_length >> TARGET_PAGE_BITS);
|
bitmap_zero(block->bmap, block->max_length >> TARGET_PAGE_BITS);
|
||||||
}
|
}
|
||||||
memory_global_dirty_log_start(GLOBAL_DIRTY_MIGRATION);
|
if (!memory_global_dirty_log_start(GLOBAL_DIRTY_MIGRATION,
|
||||||
|
&local_err)) {
|
||||||
|
error_report_err(local_err);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
ram_state->migration_dirty_pages = 0;
|
ram_state->migration_dirty_pages = 0;
|
||||||
qemu_mutex_unlock_ramlist();
|
qemu_mutex_unlock_ramlist();
|
||||||
|
@ -3694,8 +3735,9 @@ void colo_release_ram_cache(void)
|
||||||
*
|
*
|
||||||
* @f: QEMUFile where to receive the data
|
* @f: QEMUFile where to receive the data
|
||||||
* @opaque: RAMState pointer
|
* @opaque: RAMState pointer
|
||||||
|
* @errp: pointer to Error*, to store an error if it happens.
|
||||||
*/
|
*/
|
||||||
static int ram_load_setup(QEMUFile *f, void *opaque)
|
static int ram_load_setup(QEMUFile *f, void *opaque, Error **errp)
|
||||||
{
|
{
|
||||||
xbzrle_load_setup();
|
xbzrle_load_setup();
|
||||||
ramblock_recv_map_init();
|
ramblock_recv_map_init();
|
||||||
|
|
|
@ -69,6 +69,7 @@ int ramblock_recv_bitmap_test(RAMBlock *rb, void *host_addr);
|
||||||
bool ramblock_recv_bitmap_test_byte_offset(RAMBlock *rb, uint64_t byte_offset);
|
bool ramblock_recv_bitmap_test_byte_offset(RAMBlock *rb, uint64_t byte_offset);
|
||||||
void ramblock_recv_bitmap_set(RAMBlock *rb, void *host_addr);
|
void ramblock_recv_bitmap_set(RAMBlock *rb, void *host_addr);
|
||||||
void ramblock_recv_bitmap_set_range(RAMBlock *rb, void *host_addr, size_t nr);
|
void ramblock_recv_bitmap_set_range(RAMBlock *rb, void *host_addr, size_t nr);
|
||||||
|
void ramblock_recv_bitmap_set_offset(RAMBlock *rb, uint64_t byte_offset);
|
||||||
int64_t ramblock_recv_bitmap_send(QEMUFile *file,
|
int64_t ramblock_recv_bitmap_send(QEMUFile *file,
|
||||||
const char *block_name);
|
const char *block_name);
|
||||||
bool ram_dirty_bitmap_reload(MigrationState *s, RAMBlock *rb, Error **errp);
|
bool ram_dirty_bitmap_reload(MigrationState *s, RAMBlock *rb, Error **errp);
|
||||||
|
|
|
@ -1009,11 +1009,10 @@ static void save_section_footer(QEMUFile *f, SaveStateEntry *se)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int vmstate_save(QEMUFile *f, SaveStateEntry *se, JSONWriter *vmdesc)
|
static int vmstate_save(QEMUFile *f, SaveStateEntry *se, JSONWriter *vmdesc,
|
||||||
|
Error **errp)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
Error *local_err = NULL;
|
|
||||||
MigrationState *s = migrate_get_current();
|
|
||||||
|
|
||||||
if ((!se->ops || !se->ops->save_state) && !se->vmsd) {
|
if ((!se->ops || !se->ops->save_state) && !se->vmsd) {
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -1035,10 +1034,9 @@ static int vmstate_save(QEMUFile *f, SaveStateEntry *se, JSONWriter *vmdesc)
|
||||||
if (!se->vmsd) {
|
if (!se->vmsd) {
|
||||||
vmstate_save_old_style(f, se, vmdesc);
|
vmstate_save_old_style(f, se, vmdesc);
|
||||||
} else {
|
} else {
|
||||||
ret = vmstate_save_state_with_err(f, se->vmsd, se->opaque, vmdesc, &local_err);
|
ret = vmstate_save_state_with_err(f, se->vmsd, se->opaque, vmdesc,
|
||||||
|
errp);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
migrate_set_error(s, local_err);
|
|
||||||
error_report_err(local_err);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1312,11 +1310,11 @@ int qemu_savevm_state_prepare(Error **errp)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void qemu_savevm_state_setup(QEMUFile *f)
|
int qemu_savevm_state_setup(QEMUFile *f, Error **errp)
|
||||||
{
|
{
|
||||||
|
ERRP_GUARD();
|
||||||
MigrationState *ms = migrate_get_current();
|
MigrationState *ms = migrate_get_current();
|
||||||
SaveStateEntry *se;
|
SaveStateEntry *se;
|
||||||
Error *local_err = NULL;
|
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
json_writer_int64(ms->vmdesc, "page_size", qemu_target_page_size());
|
json_writer_int64(ms->vmdesc, "page_size", qemu_target_page_size());
|
||||||
|
@ -1325,8 +1323,9 @@ void qemu_savevm_state_setup(QEMUFile *f)
|
||||||
trace_savevm_state_setup();
|
trace_savevm_state_setup();
|
||||||
QTAILQ_FOREACH(se, &savevm_state.handlers, entry) {
|
QTAILQ_FOREACH(se, &savevm_state.handlers, entry) {
|
||||||
if (se->vmsd && se->vmsd->early_setup) {
|
if (se->vmsd && se->vmsd->early_setup) {
|
||||||
ret = vmstate_save(f, se, ms->vmdesc);
|
ret = vmstate_save(f, se, ms->vmdesc, errp);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
|
migrate_set_error(ms, *errp);
|
||||||
qemu_file_set_error(f, ret);
|
qemu_file_set_error(f, ret);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1343,7 +1342,7 @@ void qemu_savevm_state_setup(QEMUFile *f)
|
||||||
}
|
}
|
||||||
save_section_header(f, se, QEMU_VM_SECTION_START);
|
save_section_header(f, se, QEMU_VM_SECTION_START);
|
||||||
|
|
||||||
ret = se->ops->save_setup(f, se->opaque);
|
ret = se->ops->save_setup(f, se->opaque, errp);
|
||||||
save_section_footer(f, se);
|
save_section_footer(f, se);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
qemu_file_set_error(f, ret);
|
qemu_file_set_error(f, ret);
|
||||||
|
@ -1352,12 +1351,11 @@ void qemu_savevm_state_setup(QEMUFile *f)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ret) {
|
if (ret) {
|
||||||
return;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (precopy_notify(PRECOPY_NOTIFY_SETUP, &local_err)) {
|
/* TODO: Should we check that errp is set in case of failure ? */
|
||||||
error_report_err(local_err);
|
return precopy_notify(PRECOPY_NOTIFY_SETUP, errp);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int qemu_savevm_state_resume_prepare(MigrationState *s)
|
int qemu_savevm_state_resume_prepare(MigrationState *s)
|
||||||
|
@ -1542,6 +1540,7 @@ int qemu_savevm_state_complete_precopy_non_iterable(QEMUFile *f,
|
||||||
JSONWriter *vmdesc = ms->vmdesc;
|
JSONWriter *vmdesc = ms->vmdesc;
|
||||||
int vmdesc_len;
|
int vmdesc_len;
|
||||||
SaveStateEntry *se;
|
SaveStateEntry *se;
|
||||||
|
Error *local_err = NULL;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
QTAILQ_FOREACH(se, &savevm_state.handlers, entry) {
|
QTAILQ_FOREACH(se, &savevm_state.handlers, entry) {
|
||||||
|
@ -1552,8 +1551,10 @@ int qemu_savevm_state_complete_precopy_non_iterable(QEMUFile *f,
|
||||||
|
|
||||||
start_ts_each = qemu_clock_get_us(QEMU_CLOCK_REALTIME);
|
start_ts_each = qemu_clock_get_us(QEMU_CLOCK_REALTIME);
|
||||||
|
|
||||||
ret = vmstate_save(f, se, vmdesc);
|
ret = vmstate_save(f, se, vmdesc, &local_err);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
|
migrate_set_error(ms, local_err);
|
||||||
|
error_report_err(local_err);
|
||||||
qemu_file_set_error(f, ret);
|
qemu_file_set_error(f, ret);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -1568,7 +1569,6 @@ int qemu_savevm_state_complete_precopy_non_iterable(QEMUFile *f,
|
||||||
* bdrv_activate_all() on the other end won't fail. */
|
* bdrv_activate_all() on the other end won't fail. */
|
||||||
ret = bdrv_inactivate_all();
|
ret = bdrv_inactivate_all();
|
||||||
if (ret) {
|
if (ret) {
|
||||||
Error *local_err = NULL;
|
|
||||||
error_setg(&local_err, "%s: bdrv_inactivate_all() failed (%d)",
|
error_setg(&local_err, "%s: bdrv_inactivate_all() failed (%d)",
|
||||||
__func__, ret);
|
__func__, ret);
|
||||||
migrate_set_error(ms, local_err);
|
migrate_set_error(ms, local_err);
|
||||||
|
@ -1723,7 +1723,10 @@ static int qemu_savevm_state(QEMUFile *f, Error **errp)
|
||||||
ms->to_dst_file = f;
|
ms->to_dst_file = f;
|
||||||
|
|
||||||
qemu_savevm_state_header(f);
|
qemu_savevm_state_header(f);
|
||||||
qemu_savevm_state_setup(f);
|
ret = qemu_savevm_state_setup(f, errp);
|
||||||
|
if (ret) {
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
|
||||||
while (qemu_file_get_error(f) == 0) {
|
while (qemu_file_get_error(f) == 0) {
|
||||||
if (qemu_savevm_state_iterate(f, false) > 0) {
|
if (qemu_savevm_state_iterate(f, false) > 0) {
|
||||||
|
@ -1736,10 +1739,11 @@ static int qemu_savevm_state(QEMUFile *f, Error **errp)
|
||||||
qemu_savevm_state_complete_precopy(f, false, false);
|
qemu_savevm_state_complete_precopy(f, false, false);
|
||||||
ret = qemu_file_get_error(f);
|
ret = qemu_file_get_error(f);
|
||||||
}
|
}
|
||||||
qemu_savevm_state_cleanup();
|
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
error_setg_errno(errp, -ret, "Error while writing VM state");
|
error_setg_errno(errp, -ret, "Error while writing VM state");
|
||||||
}
|
}
|
||||||
|
cleanup:
|
||||||
|
qemu_savevm_state_cleanup();
|
||||||
|
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
status = MIGRATION_STATUS_FAILED;
|
status = MIGRATION_STATUS_FAILED;
|
||||||
|
@ -1764,6 +1768,8 @@ void qemu_savevm_live_state(QEMUFile *f)
|
||||||
|
|
||||||
int qemu_save_device_state(QEMUFile *f)
|
int qemu_save_device_state(QEMUFile *f)
|
||||||
{
|
{
|
||||||
|
MigrationState *ms = migrate_get_current();
|
||||||
|
Error *local_err = NULL;
|
||||||
SaveStateEntry *se;
|
SaveStateEntry *se;
|
||||||
|
|
||||||
if (!migration_in_colo_state()) {
|
if (!migration_in_colo_state()) {
|
||||||
|
@ -1778,8 +1784,10 @@ int qemu_save_device_state(QEMUFile *f)
|
||||||
if (se->is_ram) {
|
if (se->is_ram) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
ret = vmstate_save(f, se, NULL);
|
ret = vmstate_save(f, se, NULL, &local_err);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
|
migrate_set_error(ms, local_err);
|
||||||
|
error_report_err(local_err);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2760,8 +2768,9 @@ static void qemu_loadvm_state_switchover_ack_needed(MigrationIncomingState *mis)
|
||||||
trace_loadvm_state_switchover_ack_needed(mis->switchover_ack_pending_num);
|
trace_loadvm_state_switchover_ack_needed(mis->switchover_ack_pending_num);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int qemu_loadvm_state_setup(QEMUFile *f)
|
static int qemu_loadvm_state_setup(QEMUFile *f, Error **errp)
|
||||||
{
|
{
|
||||||
|
ERRP_GUARD();
|
||||||
SaveStateEntry *se;
|
SaveStateEntry *se;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
|
@ -2776,10 +2785,11 @@ static int qemu_loadvm_state_setup(QEMUFile *f)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = se->ops->load_setup(f, se->opaque);
|
ret = se->ops->load_setup(f, se->opaque, errp);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
|
error_prepend(errp, "Load state of device %s failed: ",
|
||||||
|
se->idstr);
|
||||||
qemu_file_set_error(f, ret);
|
qemu_file_set_error(f, ret);
|
||||||
error_report("Load state of device %s failed", se->idstr);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2960,7 +2970,8 @@ int qemu_loadvm_state(QEMUFile *f)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (qemu_loadvm_state_setup(f) != 0) {
|
if (qemu_loadvm_state_setup(f, &local_err) != 0) {
|
||||||
|
error_report_err(local_err);
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -32,7 +32,7 @@
|
||||||
bool qemu_savevm_state_blocked(Error **errp);
|
bool qemu_savevm_state_blocked(Error **errp);
|
||||||
void qemu_savevm_non_migratable_list(strList **reasons);
|
void qemu_savevm_non_migratable_list(strList **reasons);
|
||||||
int qemu_savevm_state_prepare(Error **errp);
|
int qemu_savevm_state_prepare(Error **errp);
|
||||||
void qemu_savevm_state_setup(QEMUFile *f);
|
int qemu_savevm_state_setup(QEMUFile *f, Error **errp);
|
||||||
bool qemu_savevm_state_guest_unplug_pending(void);
|
bool qemu_savevm_state_guest_unplug_pending(void);
|
||||||
int qemu_savevm_state_resume_prepare(MigrationState *s);
|
int qemu_savevm_state_resume_prepare(MigrationState *s);
|
||||||
void qemu_savevm_state_header(QEMUFile *f);
|
void qemu_savevm_state_header(QEMUFile *f);
|
||||||
|
|
|
@ -2919,7 +2919,30 @@ static unsigned int postponed_stop_flags;
|
||||||
static VMChangeStateEntry *vmstate_change;
|
static VMChangeStateEntry *vmstate_change;
|
||||||
static void memory_global_dirty_log_stop_postponed_run(void);
|
static void memory_global_dirty_log_stop_postponed_run(void);
|
||||||
|
|
||||||
void memory_global_dirty_log_start(unsigned int flags)
|
static bool memory_global_dirty_log_do_start(Error **errp)
|
||||||
|
{
|
||||||
|
MemoryListener *listener;
|
||||||
|
|
||||||
|
QTAILQ_FOREACH(listener, &memory_listeners, link) {
|
||||||
|
if (listener->log_global_start) {
|
||||||
|
if (!listener->log_global_start(listener, errp)) {
|
||||||
|
goto err;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
|
||||||
|
err:
|
||||||
|
while ((listener = QTAILQ_PREV(listener, link)) != NULL) {
|
||||||
|
if (listener->log_global_stop) {
|
||||||
|
listener->log_global_stop(listener);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool memory_global_dirty_log_start(unsigned int flags, Error **errp)
|
||||||
{
|
{
|
||||||
unsigned int old_flags;
|
unsigned int old_flags;
|
||||||
|
|
||||||
|
@ -2933,7 +2956,7 @@ void memory_global_dirty_log_start(unsigned int flags)
|
||||||
|
|
||||||
flags &= ~global_dirty_tracking;
|
flags &= ~global_dirty_tracking;
|
||||||
if (!flags) {
|
if (!flags) {
|
||||||
return;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
old_flags = global_dirty_tracking;
|
old_flags = global_dirty_tracking;
|
||||||
|
@ -2941,11 +2964,17 @@ void memory_global_dirty_log_start(unsigned int flags)
|
||||||
trace_global_dirty_changed(global_dirty_tracking);
|
trace_global_dirty_changed(global_dirty_tracking);
|
||||||
|
|
||||||
if (!old_flags) {
|
if (!old_flags) {
|
||||||
MEMORY_LISTENER_CALL_GLOBAL(log_global_start, Forward);
|
if (!memory_global_dirty_log_do_start(errp)) {
|
||||||
|
global_dirty_tracking &= ~flags;
|
||||||
|
trace_global_dirty_changed(global_dirty_tracking);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
memory_region_transaction_begin();
|
memory_region_transaction_begin();
|
||||||
memory_region_update_pending = true;
|
memory_region_update_pending = true;
|
||||||
memory_region_transaction_commit();
|
memory_region_transaction_commit();
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void memory_global_dirty_log_do_stop(unsigned int flags)
|
static void memory_global_dirty_log_do_stop(unsigned int flags)
|
||||||
|
@ -3019,8 +3048,15 @@ static void listener_add_address_space(MemoryListener *listener,
|
||||||
listener->begin(listener);
|
listener->begin(listener);
|
||||||
}
|
}
|
||||||
if (global_dirty_tracking) {
|
if (global_dirty_tracking) {
|
||||||
|
/*
|
||||||
|
* Currently only VFIO can fail log_global_start(), and it's not
|
||||||
|
* yet allowed to hotplug any PCI device during migration. So this
|
||||||
|
* should never fail when invoked, guard it with error_abort. If
|
||||||
|
* it can start to fail in the future, we need to be able to fail
|
||||||
|
* the whole listener_add_address_space() and its callers.
|
||||||
|
*/
|
||||||
if (listener->log_global_start) {
|
if (listener->log_global_start) {
|
||||||
listener->log_global_start(listener);
|
listener->log_global_start(listener, &error_abort);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -13,6 +13,11 @@
|
||||||
#include "qemu/osdep.h"
|
#include "qemu/osdep.h"
|
||||||
#include "qemu/ctype.h"
|
#include "qemu/ctype.h"
|
||||||
#include "qapi/qmp/qjson.h"
|
#include "qapi/qmp/qjson.h"
|
||||||
|
#include "qapi/qapi-visit-sockets.h"
|
||||||
|
#include "qapi/qobject-input-visitor.h"
|
||||||
|
#include "qapi/error.h"
|
||||||
|
#include "qapi/qmp/qlist.h"
|
||||||
|
#include "qemu/cutils.h"
|
||||||
|
|
||||||
#include "migration-helpers.h"
|
#include "migration-helpers.h"
|
||||||
|
|
||||||
|
@ -24,6 +29,127 @@
|
||||||
*/
|
*/
|
||||||
#define MIGRATION_STATUS_WAIT_TIMEOUT 120
|
#define MIGRATION_STATUS_WAIT_TIMEOUT 120
|
||||||
|
|
||||||
|
static char *SocketAddress_to_str(SocketAddress *addr)
|
||||||
|
{
|
||||||
|
switch (addr->type) {
|
||||||
|
case SOCKET_ADDRESS_TYPE_INET:
|
||||||
|
return g_strdup_printf("tcp:%s:%s",
|
||||||
|
addr->u.inet.host,
|
||||||
|
addr->u.inet.port);
|
||||||
|
case SOCKET_ADDRESS_TYPE_UNIX:
|
||||||
|
return g_strdup_printf("unix:%s",
|
||||||
|
addr->u.q_unix.path);
|
||||||
|
case SOCKET_ADDRESS_TYPE_FD:
|
||||||
|
return g_strdup_printf("fd:%s", addr->u.fd.str);
|
||||||
|
case SOCKET_ADDRESS_TYPE_VSOCK:
|
||||||
|
return g_strdup_printf("vsock:%s:%s",
|
||||||
|
addr->u.vsock.cid,
|
||||||
|
addr->u.vsock.port);
|
||||||
|
default:
|
||||||
|
return g_strdup("unknown address type");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static QDict *SocketAddress_to_qdict(SocketAddress *addr)
|
||||||
|
{
|
||||||
|
QDict *dict = qdict_new();
|
||||||
|
|
||||||
|
switch (addr->type) {
|
||||||
|
case SOCKET_ADDRESS_TYPE_INET:
|
||||||
|
qdict_put_str(dict, "type", "inet");
|
||||||
|
qdict_put_str(dict, "host", addr->u.inet.host);
|
||||||
|
qdict_put_str(dict, "port", addr->u.inet.port);
|
||||||
|
break;
|
||||||
|
case SOCKET_ADDRESS_TYPE_UNIX:
|
||||||
|
qdict_put_str(dict, "type", "unix");
|
||||||
|
qdict_put_str(dict, "path", addr->u.q_unix.path);
|
||||||
|
break;
|
||||||
|
case SOCKET_ADDRESS_TYPE_FD:
|
||||||
|
qdict_put_str(dict, "type", "fd");
|
||||||
|
qdict_put_str(dict, "str", addr->u.fd.str);
|
||||||
|
break;
|
||||||
|
case SOCKET_ADDRESS_TYPE_VSOCK:
|
||||||
|
qdict_put_str(dict, "type", "vsock");
|
||||||
|
qdict_put_str(dict, "cid", addr->u.vsock.cid);
|
||||||
|
qdict_put_str(dict, "port", addr->u.vsock.port);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
g_assert_not_reached();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return dict;
|
||||||
|
}
|
||||||
|
|
||||||
|
static SocketAddress *migrate_get_socket_address(QTestState *who)
|
||||||
|
{
|
||||||
|
QDict *rsp;
|
||||||
|
SocketAddressList *addrs;
|
||||||
|
SocketAddress *addr;
|
||||||
|
Visitor *iv = NULL;
|
||||||
|
QObject *object;
|
||||||
|
|
||||||
|
rsp = migrate_query(who);
|
||||||
|
object = qdict_get(rsp, "socket-address");
|
||||||
|
|
||||||
|
iv = qobject_input_visitor_new(object);
|
||||||
|
visit_type_SocketAddressList(iv, NULL, &addrs, &error_abort);
|
||||||
|
addr = addrs->value;
|
||||||
|
visit_free(iv);
|
||||||
|
|
||||||
|
qobject_unref(rsp);
|
||||||
|
return addr;
|
||||||
|
}
|
||||||
|
|
||||||
|
static char *
|
||||||
|
migrate_get_connect_uri(QTestState *who)
|
||||||
|
{
|
||||||
|
SocketAddress *addrs;
|
||||||
|
char *connect_uri;
|
||||||
|
|
||||||
|
addrs = migrate_get_socket_address(who);
|
||||||
|
connect_uri = SocketAddress_to_str(addrs);
|
||||||
|
|
||||||
|
qapi_free_SocketAddress(addrs);
|
||||||
|
return connect_uri;
|
||||||
|
}
|
||||||
|
|
||||||
|
static QDict *
|
||||||
|
migrate_get_connect_qdict(QTestState *who)
|
||||||
|
{
|
||||||
|
SocketAddress *addrs;
|
||||||
|
QDict *connect_qdict;
|
||||||
|
|
||||||
|
addrs = migrate_get_socket_address(who);
|
||||||
|
connect_qdict = SocketAddress_to_qdict(addrs);
|
||||||
|
|
||||||
|
qapi_free_SocketAddress(addrs);
|
||||||
|
return connect_qdict;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void migrate_set_ports(QTestState *to, QList *channel_list)
|
||||||
|
{
|
||||||
|
QDict *addr;
|
||||||
|
QListEntry *entry;
|
||||||
|
const char *addr_port = NULL;
|
||||||
|
|
||||||
|
addr = migrate_get_connect_qdict(to);
|
||||||
|
|
||||||
|
QLIST_FOREACH_ENTRY(channel_list, entry) {
|
||||||
|
QDict *channel = qobject_to(QDict, qlist_entry_obj(entry));
|
||||||
|
QDict *addrdict = qdict_get_qdict(channel, "addr");
|
||||||
|
|
||||||
|
if (qdict_haskey(addrdict, "port") &&
|
||||||
|
qdict_haskey(addr, "port") &&
|
||||||
|
(strcmp(qdict_get_str(addrdict, "port"), "0") == 0)) {
|
||||||
|
addr_port = qdict_get_str(addr, "port");
|
||||||
|
qdict_put_str(addrdict, "port", g_strdup(addr_port));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
qobject_unref(addr);
|
||||||
|
}
|
||||||
|
|
||||||
bool migrate_watch_for_events(QTestState *who, const char *name,
|
bool migrate_watch_for_events(QTestState *who, const char *name,
|
||||||
QDict *event, void *opaque)
|
QDict *event, void *opaque)
|
||||||
{
|
{
|
||||||
|
@ -43,7 +169,8 @@ bool migrate_watch_for_events(QTestState *who, const char *name,
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void migrate_qmp_fail(QTestState *who, const char *uri, const char *fmt, ...)
|
void migrate_qmp_fail(QTestState *who, const char *uri,
|
||||||
|
const char *channels, const char *fmt, ...)
|
||||||
{
|
{
|
||||||
va_list ap;
|
va_list ap;
|
||||||
QDict *args, *err;
|
QDict *args, *err;
|
||||||
|
@ -53,7 +180,15 @@ void migrate_qmp_fail(QTestState *who, const char *uri, const char *fmt, ...)
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
|
|
||||||
g_assert(!qdict_haskey(args, "uri"));
|
g_assert(!qdict_haskey(args, "uri"));
|
||||||
qdict_put_str(args, "uri", uri);
|
if (uri) {
|
||||||
|
qdict_put_str(args, "uri", uri);
|
||||||
|
}
|
||||||
|
|
||||||
|
g_assert(!qdict_haskey(args, "channels"));
|
||||||
|
if (channels) {
|
||||||
|
QObject *channels_obj = qobject_from_json(channels, &error_abort);
|
||||||
|
qdict_put_obj(args, "channels", channels_obj);
|
||||||
|
}
|
||||||
|
|
||||||
err = qtest_qmp_assert_failure_ref(
|
err = qtest_qmp_assert_failure_ref(
|
||||||
who, "{ 'execute': 'migrate', 'arguments': %p}", args);
|
who, "{ 'execute': 'migrate', 'arguments': %p}", args);
|
||||||
|
@ -68,17 +203,32 @@ void migrate_qmp_fail(QTestState *who, const char *uri, const char *fmt, ...)
|
||||||
* Arguments are built from @fmt... (formatted like
|
* Arguments are built from @fmt... (formatted like
|
||||||
* qobject_from_jsonf_nofail()) with "uri": @uri spliced in.
|
* qobject_from_jsonf_nofail()) with "uri": @uri spliced in.
|
||||||
*/
|
*/
|
||||||
void migrate_qmp(QTestState *who, const char *uri, const char *fmt, ...)
|
void migrate_qmp(QTestState *who, QTestState *to, const char *uri,
|
||||||
|
const char *channels, const char *fmt, ...)
|
||||||
{
|
{
|
||||||
va_list ap;
|
va_list ap;
|
||||||
QDict *args;
|
QDict *args;
|
||||||
|
g_autofree char *connect_uri = NULL;
|
||||||
|
|
||||||
va_start(ap, fmt);
|
va_start(ap, fmt);
|
||||||
args = qdict_from_vjsonf_nofail(fmt, ap);
|
args = qdict_from_vjsonf_nofail(fmt, ap);
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
|
|
||||||
g_assert(!qdict_haskey(args, "uri"));
|
g_assert(!qdict_haskey(args, "uri"));
|
||||||
qdict_put_str(args, "uri", uri);
|
if (uri) {
|
||||||
|
qdict_put_str(args, "uri", uri);
|
||||||
|
} else if (!channels) {
|
||||||
|
connect_uri = migrate_get_connect_uri(to);
|
||||||
|
qdict_put_str(args, "uri", connect_uri);
|
||||||
|
}
|
||||||
|
|
||||||
|
g_assert(!qdict_haskey(args, "channels"));
|
||||||
|
if (channels) {
|
||||||
|
QObject *channels_obj = qobject_from_json(channels, &error_abort);
|
||||||
|
QList *channel_list = qobject_to(QList, channels_obj);
|
||||||
|
migrate_set_ports(to, channel_list);
|
||||||
|
qdict_put_obj(args, "channels", channels_obj);
|
||||||
|
}
|
||||||
|
|
||||||
qtest_qmp_assert_success(who,
|
qtest_qmp_assert_success(who,
|
||||||
"{ 'execute': 'migrate', 'arguments': %p}", args);
|
"{ 'execute': 'migrate', 'arguments': %p}", args);
|
||||||
|
|
|
@ -25,15 +25,17 @@ typedef struct QTestMigrationState {
|
||||||
bool migrate_watch_for_events(QTestState *who, const char *name,
|
bool migrate_watch_for_events(QTestState *who, const char *name,
|
||||||
QDict *event, void *opaque);
|
QDict *event, void *opaque);
|
||||||
|
|
||||||
G_GNUC_PRINTF(3, 4)
|
G_GNUC_PRINTF(5, 6)
|
||||||
void migrate_qmp(QTestState *who, const char *uri, const char *fmt, ...);
|
void migrate_qmp(QTestState *who, QTestState *to, const char *uri,
|
||||||
|
const char *channels, const char *fmt, ...);
|
||||||
|
|
||||||
G_GNUC_PRINTF(3, 4)
|
G_GNUC_PRINTF(3, 4)
|
||||||
void migrate_incoming_qmp(QTestState *who, const char *uri,
|
void migrate_incoming_qmp(QTestState *who, const char *uri,
|
||||||
const char *fmt, ...);
|
const char *fmt, ...);
|
||||||
|
|
||||||
G_GNUC_PRINTF(3, 4)
|
G_GNUC_PRINTF(4, 5)
|
||||||
void migrate_qmp_fail(QTestState *who, const char *uri, const char *fmt, ...);
|
void migrate_qmp_fail(QTestState *who, const char *uri,
|
||||||
|
const char *channels, const char *fmt, ...);
|
||||||
|
|
||||||
void migrate_set_capability(QTestState *who, const char *capability,
|
void migrate_set_capability(QTestState *who, const char *capability,
|
||||||
bool value);
|
bool value);
|
||||||
|
|
|
@ -13,16 +13,12 @@
|
||||||
#include "qemu/osdep.h"
|
#include "qemu/osdep.h"
|
||||||
|
|
||||||
#include "libqtest.h"
|
#include "libqtest.h"
|
||||||
#include "qapi/error.h"
|
|
||||||
#include "qapi/qmp/qdict.h"
|
#include "qapi/qmp/qdict.h"
|
||||||
#include "qemu/module.h"
|
#include "qemu/module.h"
|
||||||
#include "qemu/option.h"
|
#include "qemu/option.h"
|
||||||
#include "qemu/range.h"
|
#include "qemu/range.h"
|
||||||
#include "qemu/sockets.h"
|
#include "qemu/sockets.h"
|
||||||
#include "chardev/char.h"
|
#include "chardev/char.h"
|
||||||
#include "qapi/qapi-visit-sockets.h"
|
|
||||||
#include "qapi/qobject-input-visitor.h"
|
|
||||||
#include "qapi/qobject-output-visitor.h"
|
|
||||||
#include "crypto/tlscredspsk.h"
|
#include "crypto/tlscredspsk.h"
|
||||||
#include "qapi/qmp/qlist.h"
|
#include "qapi/qmp/qlist.h"
|
||||||
|
|
||||||
|
@ -369,50 +365,6 @@ static void cleanup(const char *filename)
|
||||||
unlink(path);
|
unlink(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
static char *SocketAddress_to_str(SocketAddress *addr)
|
|
||||||
{
|
|
||||||
switch (addr->type) {
|
|
||||||
case SOCKET_ADDRESS_TYPE_INET:
|
|
||||||
return g_strdup_printf("tcp:%s:%s",
|
|
||||||
addr->u.inet.host,
|
|
||||||
addr->u.inet.port);
|
|
||||||
case SOCKET_ADDRESS_TYPE_UNIX:
|
|
||||||
return g_strdup_printf("unix:%s",
|
|
||||||
addr->u.q_unix.path);
|
|
||||||
case SOCKET_ADDRESS_TYPE_FD:
|
|
||||||
return g_strdup_printf("fd:%s", addr->u.fd.str);
|
|
||||||
case SOCKET_ADDRESS_TYPE_VSOCK:
|
|
||||||
return g_strdup_printf("tcp:%s:%s",
|
|
||||||
addr->u.vsock.cid,
|
|
||||||
addr->u.vsock.port);
|
|
||||||
default:
|
|
||||||
return g_strdup("unknown address type");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static char *migrate_get_socket_address(QTestState *who, const char *parameter)
|
|
||||||
{
|
|
||||||
QDict *rsp;
|
|
||||||
char *result;
|
|
||||||
SocketAddressList *addrs;
|
|
||||||
Visitor *iv = NULL;
|
|
||||||
QObject *object;
|
|
||||||
|
|
||||||
rsp = migrate_query(who);
|
|
||||||
object = qdict_get(rsp, parameter);
|
|
||||||
|
|
||||||
iv = qobject_input_visitor_new(object);
|
|
||||||
visit_type_SocketAddressList(iv, NULL, &addrs, &error_abort);
|
|
||||||
visit_free(iv);
|
|
||||||
|
|
||||||
/* we are only using a single address */
|
|
||||||
result = SocketAddress_to_str(addrs->value);
|
|
||||||
|
|
||||||
qapi_free_SocketAddressList(addrs);
|
|
||||||
qobject_unref(rsp);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
static long long migrate_get_parameter_int(QTestState *who,
|
static long long migrate_get_parameter_int(QTestState *who,
|
||||||
const char *parameter)
|
const char *parameter)
|
||||||
{
|
{
|
||||||
|
@ -703,6 +655,13 @@ typedef struct {
|
||||||
*/
|
*/
|
||||||
const char *connect_uri;
|
const char *connect_uri;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Optional: JSON-formatted list of src QEMU URIs. If a port is
|
||||||
|
* defined as '0' in any QDict key a value of '0' will be
|
||||||
|
* automatically converted to the correct destination port.
|
||||||
|
*/
|
||||||
|
const char *connect_channels;
|
||||||
|
|
||||||
/* Optional: callback to run at start to set migration parameters */
|
/* Optional: callback to run at start to set migration parameters */
|
||||||
TestMigrateStartHook start_hook;
|
TestMigrateStartHook start_hook;
|
||||||
/* Optional: callback to run at finish to cleanup */
|
/* Optional: callback to run at finish to cleanup */
|
||||||
|
@ -1349,8 +1308,7 @@ static int migrate_postcopy_prepare(QTestState **from_ptr,
|
||||||
wait_for_serial("src_serial");
|
wait_for_serial("src_serial");
|
||||||
wait_for_suspend(from, &src_state);
|
wait_for_suspend(from, &src_state);
|
||||||
|
|
||||||
g_autofree char *uri = migrate_get_socket_address(to, "socket-address");
|
migrate_qmp(from, to, NULL, NULL, "{}");
|
||||||
migrate_qmp(from, uri, "{}");
|
|
||||||
|
|
||||||
migrate_wait_for_dirty_mem(from, to);
|
migrate_wait_for_dirty_mem(from, to);
|
||||||
|
|
||||||
|
@ -1500,7 +1458,7 @@ static void postcopy_recover_fail(QTestState *from, QTestState *to)
|
||||||
g_assert_cmpint(ret, ==, 1);
|
g_assert_cmpint(ret, ==, 1);
|
||||||
|
|
||||||
migrate_recover(to, "fd:fd-mig");
|
migrate_recover(to, "fd:fd-mig");
|
||||||
migrate_qmp(from, "fd:fd-mig", "{'resume': true}");
|
migrate_qmp(from, to, "fd:fd-mig", NULL, "{'resume': true}");
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Make sure both QEMU instances will go into RECOVER stage, then test
|
* Make sure both QEMU instances will go into RECOVER stage, then test
|
||||||
|
@ -1588,7 +1546,7 @@ static void test_postcopy_recovery_common(MigrateCommon *args)
|
||||||
* Try to rebuild the migration channel using the resume flag and
|
* Try to rebuild the migration channel using the resume flag and
|
||||||
* the newly created channel
|
* the newly created channel
|
||||||
*/
|
*/
|
||||||
migrate_qmp(from, uri, "{'resume': true}");
|
migrate_qmp(from, to, uri, NULL, "{'resume': true}");
|
||||||
|
|
||||||
/* Restore the postcopy bandwidth to unlimited */
|
/* Restore the postcopy bandwidth to unlimited */
|
||||||
migrate_set_parameter_int(from, "max-postcopy-bandwidth", 0);
|
migrate_set_parameter_int(from, "max-postcopy-bandwidth", 0);
|
||||||
|
@ -1669,7 +1627,7 @@ static void test_baddest(void)
|
||||||
if (test_migrate_start(&from, &to, "tcp:127.0.0.1:0", &args)) {
|
if (test_migrate_start(&from, &to, "tcp:127.0.0.1:0", &args)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
migrate_qmp(from, "tcp:127.0.0.1:0", "{}");
|
migrate_qmp(from, to, "tcp:127.0.0.1:0", NULL, "{}");
|
||||||
wait_for_migration_fail(from, false);
|
wait_for_migration_fail(from, false);
|
||||||
test_migrate_end(from, to, false);
|
test_migrate_end(from, to, false);
|
||||||
}
|
}
|
||||||
|
@ -1708,7 +1666,7 @@ static void test_analyze_script(void)
|
||||||
uri = g_strdup_printf("exec:cat > %s", file);
|
uri = g_strdup_printf("exec:cat > %s", file);
|
||||||
|
|
||||||
migrate_ensure_converge(from);
|
migrate_ensure_converge(from);
|
||||||
migrate_qmp(from, uri, "{}");
|
migrate_qmp(from, to, uri, NULL, "{}");
|
||||||
wait_for_migration_complete(from);
|
wait_for_migration_complete(from);
|
||||||
|
|
||||||
pid = fork();
|
pid = fork();
|
||||||
|
@ -1733,7 +1691,6 @@ static void test_precopy_common(MigrateCommon *args)
|
||||||
{
|
{
|
||||||
QTestState *from, *to;
|
QTestState *from, *to;
|
||||||
void *data_hook = NULL;
|
void *data_hook = NULL;
|
||||||
g_autofree char *connect_uri = NULL;
|
|
||||||
|
|
||||||
if (test_migrate_start(&from, &to, args->listen_uri, &args->start)) {
|
if (test_migrate_start(&from, &to, args->listen_uri, &args->start)) {
|
||||||
return;
|
return;
|
||||||
|
@ -1766,18 +1723,12 @@ static void test_precopy_common(MigrateCommon *args)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!args->connect_uri) {
|
|
||||||
connect_uri = migrate_get_socket_address(to, "socket-address");
|
|
||||||
} else {
|
|
||||||
connect_uri = g_strdup(args->connect_uri);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (args->result == MIG_TEST_QMP_ERROR) {
|
if (args->result == MIG_TEST_QMP_ERROR) {
|
||||||
migrate_qmp_fail(from, connect_uri, "{}");
|
migrate_qmp_fail(from, args->connect_uri, args->connect_channels, "{}");
|
||||||
goto finish;
|
goto finish;
|
||||||
}
|
}
|
||||||
|
|
||||||
migrate_qmp(from, connect_uri, "{}");
|
migrate_qmp(from, to, args->connect_uri, args->connect_channels, "{}");
|
||||||
|
|
||||||
if (args->result != MIG_TEST_SUCCEED) {
|
if (args->result != MIG_TEST_SUCCEED) {
|
||||||
bool allow_active = args->result == MIG_TEST_FAIL;
|
bool allow_active = args->result == MIG_TEST_FAIL;
|
||||||
|
@ -1843,7 +1794,6 @@ static void test_file_common(MigrateCommon *args, bool stop_src)
|
||||||
{
|
{
|
||||||
QTestState *from, *to;
|
QTestState *from, *to;
|
||||||
void *data_hook = NULL;
|
void *data_hook = NULL;
|
||||||
g_autofree char *connect_uri = g_strdup(args->connect_uri);
|
|
||||||
|
|
||||||
if (test_migrate_start(&from, &to, args->listen_uri, &args->start)) {
|
if (test_migrate_start(&from, &to, args->listen_uri, &args->start)) {
|
||||||
return;
|
return;
|
||||||
|
@ -1869,18 +1819,18 @@ static void test_file_common(MigrateCommon *args, bool stop_src)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args->result == MIG_TEST_QMP_ERROR) {
|
if (args->result == MIG_TEST_QMP_ERROR) {
|
||||||
migrate_qmp_fail(from, connect_uri, "{}");
|
migrate_qmp_fail(from, args->connect_uri, NULL, "{}");
|
||||||
goto finish;
|
goto finish;
|
||||||
}
|
}
|
||||||
|
|
||||||
migrate_qmp(from, connect_uri, "{}");
|
migrate_qmp(from, to, args->connect_uri, NULL, "{}");
|
||||||
wait_for_migration_complete(from);
|
wait_for_migration_complete(from);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* We need to wait for the source to finish before starting the
|
* We need to wait for the source to finish before starting the
|
||||||
* destination.
|
* destination.
|
||||||
*/
|
*/
|
||||||
migrate_incoming_qmp(to, connect_uri, "{}");
|
migrate_incoming_qmp(to, args->connect_uri, "{}");
|
||||||
wait_for_migration_complete(to);
|
wait_for_migration_complete(to);
|
||||||
|
|
||||||
if (stop_src) {
|
if (stop_src) {
|
||||||
|
@ -2029,7 +1979,7 @@ static void test_ignore_shared(void)
|
||||||
/* Wait for the first serial output from the source */
|
/* Wait for the first serial output from the source */
|
||||||
wait_for_serial("src_serial");
|
wait_for_serial("src_serial");
|
||||||
|
|
||||||
migrate_qmp(from, uri, "{}");
|
migrate_qmp(from, to, uri, NULL, "{}");
|
||||||
|
|
||||||
migrate_wait_for_dirty_mem(from, to);
|
migrate_wait_for_dirty_mem(from, to);
|
||||||
|
|
||||||
|
@ -2568,7 +2518,7 @@ static void do_test_validate_uuid(MigrateStart *args, bool should_fail)
|
||||||
/* Wait for the first serial output from the source */
|
/* Wait for the first serial output from the source */
|
||||||
wait_for_serial("src_serial");
|
wait_for_serial("src_serial");
|
||||||
|
|
||||||
migrate_qmp(from, uri, "{}");
|
migrate_qmp(from, to, uri, NULL, "{}");
|
||||||
|
|
||||||
if (should_fail) {
|
if (should_fail) {
|
||||||
qtest_set_expected_status(to, EXIT_FAILURE);
|
qtest_set_expected_status(to, EXIT_FAILURE);
|
||||||
|
@ -2621,6 +2571,55 @@ static void test_validate_uuid_dst_not_set(void)
|
||||||
do_test_validate_uuid(&args, false);
|
do_test_validate_uuid(&args, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void do_test_validate_uri_channel(MigrateCommon *args)
|
||||||
|
{
|
||||||
|
QTestState *from, *to;
|
||||||
|
|
||||||
|
if (test_migrate_start(&from, &to, args->listen_uri, &args->start)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Wait for the first serial output from the source */
|
||||||
|
wait_for_serial("src_serial");
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 'uri' and 'channels' validation is checked even before the migration
|
||||||
|
* starts.
|
||||||
|
*/
|
||||||
|
migrate_qmp_fail(from, args->connect_uri, args->connect_channels, "{}");
|
||||||
|
test_migrate_end(from, to, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void test_validate_uri_channels_both_set(void)
|
||||||
|
{
|
||||||
|
MigrateCommon args = {
|
||||||
|
.start = {
|
||||||
|
.hide_stderr = true,
|
||||||
|
},
|
||||||
|
.listen_uri = "defer",
|
||||||
|
.connect_uri = "tcp:127.0.0.1:0",
|
||||||
|
.connect_channels = "[ { 'channel-type': 'main',"
|
||||||
|
" 'addr': { 'transport': 'socket',"
|
||||||
|
" 'type': 'inet',"
|
||||||
|
" 'host': '127.0.0.1',"
|
||||||
|
" 'port': '0' } } ]",
|
||||||
|
};
|
||||||
|
|
||||||
|
do_test_validate_uri_channel(&args);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void test_validate_uri_channels_none_set(void)
|
||||||
|
{
|
||||||
|
MigrateCommon args = {
|
||||||
|
.start = {
|
||||||
|
.hide_stderr = true,
|
||||||
|
},
|
||||||
|
.listen_uri = "defer",
|
||||||
|
};
|
||||||
|
|
||||||
|
do_test_validate_uri_channel(&args);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The way auto_converge works, we need to do too many passes to
|
* The way auto_converge works, we need to do too many passes to
|
||||||
* run this test. Auto_converge logic is only run once every
|
* run this test. Auto_converge logic is only run once every
|
||||||
|
@ -2671,7 +2670,7 @@ static void test_migrate_auto_converge(void)
|
||||||
/* Wait for the first serial output from the source */
|
/* Wait for the first serial output from the source */
|
||||||
wait_for_serial("src_serial");
|
wait_for_serial("src_serial");
|
||||||
|
|
||||||
migrate_qmp(from, uri, "{}");
|
migrate_qmp(from, to, uri, NULL, "{}");
|
||||||
|
|
||||||
/* Wait for throttling begins */
|
/* Wait for throttling begins */
|
||||||
percentage = 0;
|
percentage = 0;
|
||||||
|
@ -2778,7 +2777,7 @@ test_migrate_precopy_tcp_multifd_zstd_start(QTestState *from,
|
||||||
}
|
}
|
||||||
#endif /* CONFIG_ZSTD */
|
#endif /* CONFIG_ZSTD */
|
||||||
|
|
||||||
static void test_multifd_tcp_none(void)
|
static void test_multifd_tcp_uri_none(void)
|
||||||
{
|
{
|
||||||
MigrateCommon args = {
|
MigrateCommon args = {
|
||||||
.listen_uri = "defer",
|
.listen_uri = "defer",
|
||||||
|
@ -2823,6 +2822,21 @@ static void test_multifd_tcp_no_zero_page(void)
|
||||||
test_precopy_common(&args);
|
test_precopy_common(&args);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void test_multifd_tcp_channels_none(void)
|
||||||
|
{
|
||||||
|
MigrateCommon args = {
|
||||||
|
.listen_uri = "defer",
|
||||||
|
.start_hook = test_migrate_precopy_tcp_multifd_start,
|
||||||
|
.live = true,
|
||||||
|
.connect_channels = "[ { 'channel-type': 'main',"
|
||||||
|
" 'addr': { 'transport': 'socket',"
|
||||||
|
" 'type': 'inet',"
|
||||||
|
" 'host': '127.0.0.1',"
|
||||||
|
" 'port': '0' } } ]",
|
||||||
|
};
|
||||||
|
test_precopy_common(&args);
|
||||||
|
}
|
||||||
|
|
||||||
static void test_multifd_tcp_zlib(void)
|
static void test_multifd_tcp_zlib(void)
|
||||||
{
|
{
|
||||||
MigrateCommon args = {
|
MigrateCommon args = {
|
||||||
|
@ -3017,7 +3031,6 @@ static void test_multifd_tcp_cancel(void)
|
||||||
.hide_stderr = true,
|
.hide_stderr = true,
|
||||||
};
|
};
|
||||||
QTestState *from, *to, *to2;
|
QTestState *from, *to, *to2;
|
||||||
g_autofree char *uri = NULL;
|
|
||||||
|
|
||||||
if (test_migrate_start(&from, &to, "defer", &args)) {
|
if (test_migrate_start(&from, &to, "defer", &args)) {
|
||||||
return;
|
return;
|
||||||
|
@ -3038,9 +3051,7 @@ static void test_multifd_tcp_cancel(void)
|
||||||
/* Wait for the first serial output from the source */
|
/* Wait for the first serial output from the source */
|
||||||
wait_for_serial("src_serial");
|
wait_for_serial("src_serial");
|
||||||
|
|
||||||
uri = migrate_get_socket_address(to, "socket-address");
|
migrate_qmp(from, to, NULL, NULL, "{}");
|
||||||
|
|
||||||
migrate_qmp(from, uri, "{}");
|
|
||||||
|
|
||||||
migrate_wait_for_dirty_mem(from, to);
|
migrate_wait_for_dirty_mem(from, to);
|
||||||
|
|
||||||
|
@ -3065,14 +3076,11 @@ static void test_multifd_tcp_cancel(void)
|
||||||
/* Start incoming migration from the 1st socket */
|
/* Start incoming migration from the 1st socket */
|
||||||
migrate_incoming_qmp(to2, "tcp:127.0.0.1:0", "{}");
|
migrate_incoming_qmp(to2, "tcp:127.0.0.1:0", "{}");
|
||||||
|
|
||||||
g_free(uri);
|
|
||||||
uri = migrate_get_socket_address(to2, "socket-address");
|
|
||||||
|
|
||||||
wait_for_migration_status(from, "cancelled", NULL);
|
wait_for_migration_status(from, "cancelled", NULL);
|
||||||
|
|
||||||
migrate_ensure_non_converge(from);
|
migrate_ensure_non_converge(from);
|
||||||
|
|
||||||
migrate_qmp(from, uri, "{}");
|
migrate_qmp(from, to2, NULL, NULL, "{}");
|
||||||
|
|
||||||
migrate_wait_for_dirty_mem(from, to2);
|
migrate_wait_for_dirty_mem(from, to2);
|
||||||
|
|
||||||
|
@ -3405,7 +3413,7 @@ static void test_migrate_dirty_limit(void)
|
||||||
migrate_dirty_limit_wait_showup(from, dirtylimit_period, dirtylimit_value);
|
migrate_dirty_limit_wait_showup(from, dirtylimit_period, dirtylimit_value);
|
||||||
|
|
||||||
/* Start migrate */
|
/* Start migrate */
|
||||||
migrate_qmp(from, uri, "{}");
|
migrate_qmp(from, to, args.connect_uri, NULL, "{}");
|
||||||
|
|
||||||
/* Wait for dirty limit throttle begin */
|
/* Wait for dirty limit throttle begin */
|
||||||
throttle_us_per_full = 0;
|
throttle_us_per_full = 0;
|
||||||
|
@ -3446,7 +3454,7 @@ static void test_migrate_dirty_limit(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Start migrate */
|
/* Start migrate */
|
||||||
migrate_qmp(from, uri, "{}");
|
migrate_qmp(from, to, args.connect_uri, NULL, "{}");
|
||||||
|
|
||||||
/* Wait for dirty limit throttle begin */
|
/* Wait for dirty limit throttle begin */
|
||||||
throttle_us_per_full = 0;
|
throttle_us_per_full = 0;
|
||||||
|
@ -3720,6 +3728,10 @@ int main(int argc, char **argv)
|
||||||
test_validate_uuid_src_not_set);
|
test_validate_uuid_src_not_set);
|
||||||
migration_test_add("/migration/validate_uuid_dst_not_set",
|
migration_test_add("/migration/validate_uuid_dst_not_set",
|
||||||
test_validate_uuid_dst_not_set);
|
test_validate_uuid_dst_not_set);
|
||||||
|
migration_test_add("/migration/validate_uri/channels/both_set",
|
||||||
|
test_validate_uri_channels_both_set);
|
||||||
|
migration_test_add("/migration/validate_uri/channels/none_set",
|
||||||
|
test_validate_uri_channels_none_set);
|
||||||
/*
|
/*
|
||||||
* See explanation why this test is slow on function definition
|
* See explanation why this test is slow on function definition
|
||||||
*/
|
*/
|
||||||
|
@ -3732,8 +3744,10 @@ int main(int argc, char **argv)
|
||||||
test_migrate_dirty_limit);
|
test_migrate_dirty_limit);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
migration_test_add("/migration/multifd/tcp/plain/none",
|
migration_test_add("/migration/multifd/tcp/uri/plain/none",
|
||||||
test_multifd_tcp_none);
|
test_multifd_tcp_uri_none);
|
||||||
|
migration_test_add("/migration/multifd/tcp/channels/plain/none",
|
||||||
|
test_multifd_tcp_channels_none);
|
||||||
migration_test_add("/migration/multifd/tcp/plain/zero-page/legacy",
|
migration_test_add("/migration/multifd/tcp/plain/zero-page/legacy",
|
||||||
test_multifd_tcp_zero_page_legacy);
|
test_multifd_tcp_zero_page_legacy);
|
||||||
migration_test_add("/migration/multifd/tcp/plain/zero-page/none",
|
migration_test_add("/migration/multifd/tcp/plain/zero-page/none",
|
||||||
|
|
Loading…
Reference in New Issue