Changeset 21773 in vbox
- Timestamp:
- Jul 23, 2009 9:14:20 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/VMM/SSM.cpp
r20153 r21773 24 24 * 25 25 * The Saved State Manager (SSM) implements facilities for saving and loading a 26 * VM state in a structural manner using callbacks for each collection of data 27 * which needs saving. 26 * VM state in a structural manner using callbacks for named data units. 28 27 * 29 28 * At init time each of the VMM components, Devices, Drivers and one or two 30 * other things will register data entities which they need to save and restore. 31 * Each entity have a unique name (ascii), instance number, and a set of 32 * callbacks associated with it. The name will be used to identify the entity 33 * during restore. The callbacks are for the two operations, save and restore. 34 * There are three callbacks for each of the two - a prepare, a execute and a 35 * complete - giving each component ample opportunity to perform actions both 36 * before and afterwards. 37 * 38 * The SSM provides a number of APIs for encoding and decoding the data. 39 * 40 * @see grp_ssm 41 * 42 * 43 * @section sec_ssm_future Future Changes 29 * other things will register data units which they need to save and restore. 30 * Each unit have a unique name (ascii), instance number, and a set of callbacks 31 * associated with it. The name will be used to identify the unit during 32 * restore. The callbacks are for the two operations, save and restore. There 33 * are three callbacks for each of the two - a prepare, a execute and a complete 34 * - giving each component ample opportunity to perform actions both before and 35 * afterwards. 36 * 37 * The SSM provides a number of APIs for encoding and decoding the data: @see 38 * grp_ssm 39 * 40 * 41 * 42 * @section sec_ssm_live_snapshots Live Snapshots 43 * 44 * The live snapshots feature (LS) is similar to live migration (LM) and was a 45 * natural first step when implementing LM. The main differences between LS and 46 * LM are that after a live snapshot we will have a saved state file, disk image 47 * snapshots, and the VM will still be running. 48 * 49 * Compared to normal saved stated and snapshots, the difference is in that the 50 * VM is running while we do most of the saving. Prior to LS, there was only 51 * round of callback during saving, after LS there are 1 or more while the VM is 52 * still running and a final one after it has been paused. The runtime stages 53 * is executed on a dedicated thread running at at the same priority as the EMTs 54 * so that the saving doesn't starve or lose in scheduling questions. The final 55 * phase is done on EMT(0). 56 * 57 * There are a couple of common reasons why LS and LM will fail: 58 * - Memory configuration changed (PCI memory mappings). 59 * - Takes too long (LM) / Too much output (LS). 60 * 61 * FIGURE THIS: It is currently unclear who will resume the VM after it has been 62 * paused. The most efficient way to do this is by doing it before returning 63 * from the VMR3Save call and use a callback for reconfiguring the disk images. 64 * (It is more efficient because of fewer thread switches.) The more convenient 65 * way is to have main do it after calling VMR3Save. 66 * 67 * 68 * @section sec_ssm_live_migration Live Migration 69 * 70 * As mentioned in the previous section, the main differences between this and 71 * live snapshots are in where the saved state is written and what state the 72 * local VM is in afterwards - at least from the VMM point of view. The 73 * necessary administrative work - establishing the connection to the remote 74 * machine, cloning the VM config on it and doing lowlevel saved state data 75 * transfer - is taken care of by layer above the VMM (i.e. Main). 76 * 77 * The SSM data format was made streamable for the purpose of live migration 78 * (v1.2 was the last non-streamable version). 79 * 80 * 81 * @section sec_ssm_format Saved State Format 82 * 83 * The stream format starts with a header (SSMFILEHDR) that indicates the 84 * version and such things, it is followed by zero or more saved state units 85 * (name + instance + phase), and the stream concludes with a footer 86 * (SSMFILEFTR) that contains unit counts and optionally a checksum for the 87 * entire file. (In version 1.2 and earlier, the checksum was in the header and 88 * there was no footer. This meant that the header was updated after the entire 89 * file was written.) 90 * 91 * The saved state units each starts with a variable sized header 92 * (SSMFILEUNITHDR) that contains the name, instance and phase. The data 93 * follows the header and is encoded as records with a 2-8 byte record header 94 * indicating the type, flags and size. The first byte in the record header 95 * indicates the type and flags: 96 * 97 * - bits 0..3: Record type: 98 * - type 0: Invalid. 99 * - type 1: Terminator with CRC32 and unit size. 100 * - type 2: Terminator without any integrity checks. 101 * - type 3: Raw data record. 102 * - type 4: Named data - length prefixed name followed by the data. 103 * - types 5 thru 15 are current undefined. 104 * - bit 4: Important (set), can be skipped (clear). 105 * - bit 5: Undefined flag, must be zero. 106 * - bit 6: Undefined flag, must be zero. 107 * - bit 7: "magic" bit, always set. 108 * 109 * Record header byte 2 (optionally thru 7) is the size of the following data 110 * encoded in UTF-8 style. 111 * 112 * The data part of the unit is compressed using LZF (via RTZip). 113 * 114 * (In version 1.2 and earlier the unit header also contained the compressed 115 * size of the data, i.e. it was updated after the data was written, and the 116 * data was not record based.) 117 * 118 * 119 * @section sec_ssm_future Future Changes 44 120 * 45 121 * There are plans to extend SSM to make it easier to be both backwards and 46 122 * (somewhat) forwards compatible. One of the new features will be being able 47 * to classify units and data items as unimportant. Another potentailfeature123 * to classify units and data items as unimportant. Another suggested feature 48 124 * is naming data items, perhaps by extending the SSMR3PutStruct API. 49 125 *
Note:
See TracChangeset
for help on using the changeset viewer.