Skip to the content.

virtio 有特殊的封装

static const VMStateDescription vmstate_virtio_blk = {
    .name = "virtio-blk",
    .minimum_version_id = 2,
    .version_id = 2,
    .fields = (const VMStateField[]) {
        VMSTATE_VIRTIO_DEVICE,
        VMSTATE_END_OF_LIST()
    },
};

关于 virtio

https://qemu.readthedocs.io/en/v9.2.0/devel/migration/virtio.html 说明的比较清楚了

struct VirtioDeviceClass {
    // ....
     /* Saving and loading of a device; trying to deprecate save/load
     * use vmsd for new devices.
     */
    void (*save)(VirtIODevice *vdev, QEMUFile *f);
    int (*load)(VirtIODevice *vdev, QEMUFile *f, int version_id);
    /* Post load hook in vmsd is called early while device is processed, and
     * when VirtIODevice isn't fully initialized.  Devices should use this instead,
     * unless they specifically want to verify the migration stream as it's
     * processed, e.g. for bounds checking.
     */
    int (*post_load)(VirtIODevice *vdev);

不过,为什么 VirtioDeviceClass::save 和 virtio_net_class_init::load 只有 virtio-blk 注册

virtio-blk , virtio-scsi 和 virtio-net 全部都不一样的注册方法。

本站所有文章转发 CSDN 将按侵权追究法律责任,其它情况随意。