migration.c (67ff703c97d63348e169619249144d0add092b70) | migration.c (f3bff6c44304a21ea99eeed336672bd46ca102d5) |
---|---|
1/* 2 * Migration support for VFIO devices 3 * 4 * Copyright NVIDIA, Inc. 2020 5 * 6 * This work is licensed under the terms of the GNU GPL, version 2. See 7 * the COPYING file in the top-level directory. 8 */ --- 4 unchanged lines hidden (view full) --- 13#include "qemu/units.h" 14#include "qemu/error-report.h" 15#include <linux/vfio.h> 16#include <sys/ioctl.h> 17 18#include "sysemu/runstate.h" 19#include "hw/vfio/vfio-common.h" 20#include "migration/migration.h" | 1/* 2 * Migration support for VFIO devices 3 * 4 * Copyright NVIDIA, Inc. 2020 5 * 6 * This work is licensed under the terms of the GNU GPL, version 2. See 7 * the COPYING file in the top-level directory. 8 */ --- 4 unchanged lines hidden (view full) --- 13#include "qemu/units.h" 14#include "qemu/error-report.h" 15#include <linux/vfio.h> 16#include <sys/ioctl.h> 17 18#include "sysemu/runstate.h" 19#include "hw/vfio/vfio-common.h" 20#include "migration/migration.h" |
21#include "migration/options.h" | |
22#include "migration/savevm.h" 23#include "migration/vmstate.h" 24#include "migration/qemu-file.h" 25#include "migration/register.h" 26#include "migration/blocker.h" 27#include "migration/misc.h" 28#include "qapi/error.h" 29#include "exec/ramlist.h" --- 470 unchanged lines hidden (view full) --- 500 501static bool vfio_is_active_iterate(void *opaque) 502{ 503 VFIODevice *vbasedev = opaque; 504 505 return vfio_device_state_is_precopy(vbasedev); 506} 507 | 21#include "migration/savevm.h" 22#include "migration/vmstate.h" 23#include "migration/qemu-file.h" 24#include "migration/register.h" 25#include "migration/blocker.h" 26#include "migration/misc.h" 27#include "qapi/error.h" 28#include "exec/ramlist.h" --- 470 unchanged lines hidden (view full) --- 499 500static bool vfio_is_active_iterate(void *opaque) 501{ 502 VFIODevice *vbasedev = opaque; 503 504 return vfio_device_state_is_precopy(vbasedev); 505} 506 |
507/* 508 * Note about migration rate limiting: VFIO migration buffer size is currently 509 * limited to 1MB, so there is no need to check if migration rate exceeded (as 510 * in the worst case it will exceed by 1MB). However, if the buffer size is 511 * later changed to a bigger value, migration rate should be enforced here. 512 */ |
|
508static int vfio_save_iterate(QEMUFile *f, void *opaque) 509{ 510 VFIODevice *vbasedev = opaque; 511 VFIOMigration *migration = vbasedev->migration; 512 ssize_t data_size; 513 514 data_size = vfio_save_block(f, migration); 515 if (data_size < 0) { --- 8 unchanged lines hidden (view full) --- 524 migration->initial_data_sent = true; 525 } else { 526 qemu_put_be64(f, VFIO_MIG_FLAG_END_OF_STATE); 527 } 528 529 trace_vfio_save_iterate(vbasedev->name, migration->precopy_init_size, 530 migration->precopy_dirty_size); 531 | 513static int vfio_save_iterate(QEMUFile *f, void *opaque) 514{ 515 VFIODevice *vbasedev = opaque; 516 VFIOMigration *migration = vbasedev->migration; 517 ssize_t data_size; 518 519 data_size = vfio_save_block(f, migration); 520 if (data_size < 0) { --- 8 unchanged lines hidden (view full) --- 529 migration->initial_data_sent = true; 530 } else { 531 qemu_put_be64(f, VFIO_MIG_FLAG_END_OF_STATE); 532 } 533 534 trace_vfio_save_iterate(vbasedev->name, migration->precopy_init_size, 535 migration->precopy_dirty_size); 536 |
532 /* 533 * A VFIO device's pre-copy dirty_bytes is not guaranteed to reach zero. 534 * Return 1 so following handlers will not be potentially blocked. 535 */ 536 return 1; | 537 return !migration->precopy_init_size && !migration->precopy_dirty_size; |
537} 538 539static int vfio_save_complete_precopy(QEMUFile *f, void *opaque) 540{ 541 VFIODevice *vbasedev = opaque; 542 ssize_t data_size; 543 int ret; 544 --- 339 unchanged lines hidden (view full) --- 884 if (vbasedev->enable_migration == ON_OFF_AUTO_ON) { 885 error_propagate(errp, err); 886 return -EINVAL; 887 } 888 889 vbasedev->migration_blocker = error_copy(err); 890 error_free(err); 891 | 538} 539 540static int vfio_save_complete_precopy(QEMUFile *f, void *opaque) 541{ 542 VFIODevice *vbasedev = opaque; 543 ssize_t data_size; 544 int ret; 545 --- 339 unchanged lines hidden (view full) --- 885 if (vbasedev->enable_migration == ON_OFF_AUTO_ON) { 886 error_propagate(errp, err); 887 return -EINVAL; 888 } 889 890 vbasedev->migration_blocker = error_copy(err); 891 error_free(err); 892 |
892 return migrate_add_blocker_normal(&vbasedev->migration_blocker, errp); | 893 return migrate_add_blocker(&vbasedev->migration_blocker, errp); |
893} 894 895/* ---------------------------------------------------------------------- */ 896 897int64_t vfio_mig_bytes_transferred(void) 898{ 899 return bytes_transferred; 900} --- 80 unchanged lines hidden --- | 894} 895 896/* ---------------------------------------------------------------------- */ 897 898int64_t vfio_mig_bytes_transferred(void) 899{ 900 return bytes_transferred; 901} --- 80 unchanged lines hidden --- |