From f37bc03623cd22f3934264f50af926b9b63f6598 Mon Sep 17 00:00:00 2001 From: Peter Xu Date: Fri, 6 Jan 2017 12:06:12 +0800 Subject: migration: allow to prioritize save state entries During migration, save state entries are saved/loaded without a specific order - we just traverse the savevm_state.handlers list and do it one by one. This might not be enough. There are requirements that we need to load specific device's vmstate first before others. For example, VT-d IOMMU contains DMA address remapping information, which is required by all the PCI devices to do address translations. We need to make sure IOMMU's device state is loaded before the rest of the PCI devices, so that DMA address translation can work properly. This patch provide a VMStateDescription.priority value to allow specify the priority of the saved states. The loadvm operation will be done with those devices with higher vmsd priority. Before this patch, we are possibly achieving the ordering requirement by an assumption that the ordering will be the same with the ordering that objects are created. A better way is to mark it out explicitly in the VMStateDescription table, like what this patch does. Current ordering logic is still naive and slow, but after all that's not a critical path so IMO it's a workable solution for now. Signed-off-by: Peter Xu Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Reviewed-by: Dr. David Alan Gilbert --- include/migration/vmstate.h | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'include') diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h index 1638ee5..1a22887 100644 --- a/include/migration/vmstate.h +++ b/include/migration/vmstate.h @@ -186,6 +186,11 @@ enum VMStateFlags { VMS_MULTIPLY_ELEMENTS = 0x4000, }; +typedef enum { + MIG_PRI_DEFAULT = 0, + MIG_PRI_MAX, +} MigrationPriority; + typedef struct { const char *name; size_t offset; @@ -207,6 +212,7 @@ struct VMStateDescription { int version_id; int minimum_version_id; int minimum_version_id_old; + MigrationPriority priority; LoadStateHandler *load_state_old; int (*pre_load)(void *opaque); int (*post_load)(void *opaque, int version_id); -- cgit v1.1