It will segfault when cleanup migration streams before they are setup, to
avoid this, use tdx_mig.nr_streams rather than nr_channels.
Opportunistically remove the unnecessary parameter "nr_channels" in
following 2 callback functions in cgs_mig:
cgs_mig.savevm_state_cleanup
cgs_mig.loadvm_state_cleanup
This fixes LFE-9211 and LFE-9481.
Signed-off-by: Lei Wang <lei4.wang@intel.com>
cgs_mig_init calls the vendor specific init function based the vm type
to initialize the cgs_mig callbacks.
Signed-off-by: Wei Wang <wei.w.wang@intel.com>
cgs_mig_loadvm_state_cleanup in invoked on the destination side when
migration is done to invoke vendor specific cleanup function to do the
cleanup work.
Signed-off-by: Wei Wang <wei.w.wang@intel.com>
The private states (memory data, vcpu states etc) are usually received
as a bundle of data, which need to be parsed by each vendor specific
implementation. cgs_mig_loadvm_state is invoked to call into the vendor
specific functions to parse and import the states.
Signed-off-by: Wei Wang <wei.w.wang@intel.com>
cgs_mig_loadvm_state_setup is invoked on the destination side at the
migration setup phase to call into the vendor specific implementation
to do the setup work. Similar to the source side setup, current
implementation doesn't support multifd.
Signed-off-by: Wei Wang <wei.w.wang@intel.com>
cgs_mig_savevm_state_cleanup is invoked after migration is done or
cancelled to invoke the vendor specific cleanup to do some house keeping
work.
Signed-off-by: Wei Wang <wei.w.wang@intel.com>
cgs_mig_savevm_state_ram_cancel in invoked to notify the vendor specific
implementation to cancel the migration process. This is required by some
vendor specific implementation to restore the states of the private pages
that have been migrated. The input parameter gfn_end tells which gfn was
last migrated, so that private pages of a gfn larger than gfn_end don't
need to be restored.
Signed-off-by: Wei Wang <wei.w.wang@intel.com>
cgs_mig_savevm_state_end is invoked after the guest is paused to save
the private non-iterable states (e.g. vCPU states) owned by each vendor
specific implementation. The states are sent following the new flage,
QEMU_VM_SECTION_CGS_END, which indicates to the destination about the
end of the private states migration.
Signed-off-by: Wei Wang <wei.w.wang@intel.com>
cgs_mig_savevm_state_downtime is invoked at the end of the precopy phase
to notify the vendor specific implementation to enter downtime.
Signed-off-by: Wei Wang <wei.w.wang@intel.com>
cgs_mig_savevm_state_ram saves one or more guest private pages. The
private pages' gfns are provided in an array of gfns with the gfn_num
to specify the size of the array. On success, the call returns the
number of bytes, including the 8-bytes header, that have been saved,
and on failures, a negative error code is returned.
Signed-off-by: Wei Wang <wei.w.wang@intel.com>
cgs_ram_save_start_epoch is invoked at the beginning of each memory save
iteration to migrate an epoch data from verndor specific implementations
if needed. For example, Intel TDX migration architecture requires such
an epoch data to be migrated to enforce each guest private page to be
migrated once during a migration epoch.
RAM_SAVE_FLAG_CGS_EPOCH is added to flag the destination side that the
migration data is cgs epoch data. Add and expose ram_save_cgs_epoch_header
to have cgs.c to send the header+epoch data.
Signed-off-by: Wei Wang <wei.w.wang@intel.com>
cgs_mig_savevm_state_start is invoked at the beginning of the migration
flow to send a kickoff message (i.e. QEMU_VM_SECTION_CGS_START flag +
vendor specific kickoff data if there is) to the destination.
The kickoff message is added, because some vendor specific implementation
(e.g. TDX live migration) requires such a kickoff message to start the
migration session and some preparation work on the destination side as
soon as possible.
Signed-off-by: Wei Wang <wei.w.wang@intel.com>
cgs_mig_savevm_state_setup is invoked on the source side at the migration
setup phase to call into the vendor specific setup function to do the
setup work. The default migration flow only have one channel to migrate
data, so cgs_mig_savevm_state_setup is called only once in the migration
thread's qemu_savevm_satate_setup. The multifd case is different and it
hasn't been supported, so skip cgs_mig_savevm_state_setup for the multifd
case.
Signed-off-by: Wei Wang <wei.w.wang@intel.com>
cgs_mig_is_ready is used to check if cgs migration is ready when required.
This is done by the framwork API calling to each vendor specific function
to check, and the check is performed at the time when user requests
migration to start. For the legacy VM migration case and the vendor
specific implementation that don't require the check, just return true
to have the migration flow continue.
cgs.c file is created to hold all the cgs migration framwork APIs,
and cgs.h exposes the APIs to the migration flow.
Signed-off-by: Wei Wang <wei.w.wang@intel.com>