1 =======================
2 Virtio device migration
3 =======================
5 Copyright 2015 IBM Corp.
7 This work is licensed under the terms of the GNU GPL, version 2 or later. See
8 the COPYING file in the top-level directory.
10 Saving and restoring the state of virtio devices is a bit of a twisty maze,
13 - state is distributed between several parts:
15 - virtio core, for common fields like features, number of queues, ...
17 - virtio transport (pci, ccw, ...), for the different proxy devices and
18 transport specific state (msix vectors, indicators, ...)
20 - virtio device (net, blk, ...), for the different device types and their
21 state (mac address, request queue, ...)
23 - most fields are saved via the stream interface; subsequently, subsections
24 have been added to make cross-version migration possible
26 This file attempts to document the current procedure and point out some
34 virtio core virtio transport virtio device
35 ----------- ---------------- -------------
37 save() function registered
38 via VMState wrapper on
40 virtio_save() <----------
43 - save transport-specific
47 - save common virtqueue
50 - save transport-specific
53 - save device-specific
71 virtio core virtio transport virtio device
72 ----------- ---------------- -------------
74 load() function registered
75 via VMState wrapper on
77 virtio_load() <----------
80 - load transport-specific
84 - load common virtqueue
87 - load transport-specific
91 - load device-specific
100 - virtqueue index sanity
102 - feature-dependent setup
104 Implications of this setup
105 ==========================
107 Devices need to be careful in their state processing during load: The
108 load_device() procedure is invoked by the core before subsections have
109 been loaded. Any code that depends on information transmitted in subsections
110 therefore has to be invoked in the device's load() function _after_
111 virtio_load() returned (like e.g. code depending on features).
113 Any extension of the state being migrated should be done in subsections
114 added to the core for compatibility reasons. If transport or device specific
115 state is added, core needs to invoke a callback from the new subsection.