提交 db118fe7 编写于 作者: M Markus Armbruster 提交者: Kevin Wolf

ide/atapi: Preserve tray state on migration

Use a subsection, so that migration to older version still works,
provided the tray is closed and unlocked.
Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
Signed-off-by: NKevin Wolf <kwolf@redhat.com>
上级 68bb01f3
......@@ -2058,6 +2058,22 @@ static bool ide_drive_pio_state_needed(void *opaque)
|| (s->bus->error_status & BM_STATUS_PIO_RETRY);
}
static int ide_tray_state_post_load(void *opaque, int version_id)
{
IDEState *s = opaque;
bdrv_eject(s->bs, s->tray_open);
bdrv_lock_medium(s->bs, s->tray_locked);
return 0;
}
static bool ide_tray_state_needed(void *opaque)
{
IDEState *s = opaque;
return s->tray_open || s->tray_locked;
}
static bool ide_atapi_gesn_needed(void *opaque)
{
IDEState *s = opaque;
......@@ -2085,6 +2101,19 @@ static const VMStateDescription vmstate_ide_atapi_gesn_state = {
}
};
static const VMStateDescription vmstate_ide_tray_state = {
.name = "ide_drive/tray_state",
.version_id = 1,
.minimum_version_id = 1,
.minimum_version_id_old = 1,
.post_load = ide_tray_state_post_load,
.fields = (VMStateField[]) {
VMSTATE_BOOL(tray_open, IDEState),
VMSTATE_BOOL(tray_locked, IDEState),
VMSTATE_END_OF_LIST()
}
};
static const VMStateDescription vmstate_ide_drive_pio_state = {
.name = "ide_drive/pio_state",
.version_id = 1,
......@@ -2138,6 +2167,9 @@ const VMStateDescription vmstate_ide_drive = {
{
.vmsd = &vmstate_ide_drive_pio_state,
.needed = ide_drive_pio_state_needed,
}, {
.vmsd = &vmstate_ide_tray_state,
.needed = ide_tray_state_needed,
}, {
.vmsd = &vmstate_ide_atapi_gesn_state,
.needed = ide_atapi_gesn_needed,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册