qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH v2 27/45] scsi-disk: Preserve tray state on migr


From: Paolo Bonzini
Subject: Re: [Qemu-devel] [PATCH v2 27/45] scsi-disk: Preserve tray state on migration
Date: Thu, 04 Aug 2011 08:45:48 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:5.0) Gecko/20110707 Thunderbird/5.0

On 08/04/2011 08:23 AM, Hannes Reinecke wrote:
On 08/03/2011 03:08 PM, Markus Armbruster wrote:
Breaks migration of qdevs "scsi-cd" and legacy "scsi-disk" to older
versions. We normally use subsections to avoid that. Not possible
here, because we don't have a section to begin with. Too bad.

Signed-off-by: Markus Armbruster<address@hidden>
---
hw/scsi-disk.c | 35 +++++++++++++++++++++++++++++++++++
1 files changed, 35 insertions(+), 0 deletions(-)

diff --git a/hw/scsi-disk.c b/hw/scsi-disk.c
index f223de6..04e0a77 100644
--- a/hw/scsi-disk.c
+++ b/hw/scsi-disk.c
@@ -1301,6 +1301,39 @@ static int scsi_disk_initfn(SCSIDevice *dev)
return scsi_initfn(dev, scsi_type);
}

+static int scsi_cd_post_load(void *opaque, int version_id)
+{
+ SCSIDiskState *s = opaque;
+
+ bdrv_eject(s->bs, s->tray_open);
+ bdrv_lock_medium(s->bs, s->tray_locked);
+ return 0;
+}
+
+static const VMStateDescription vmstate_scsi_cd = {
+ .name = "scsi-cd",
+ .version_id = 0,
+ .minimum_version_id = 0,
+ .post_load = scsi_cd_post_load,
+ .fields = (VMStateField[]) {
+ VMSTATE_BOOL(tray_open, SCSIDiskState),
+ VMSTATE_BOOL(tray_locked, SCSIDiskState),
+ VMSTATE_END_OF_LIST()
+ }
+};
+
+static const VMStateDescription vmstate_scsi_disk = {
+ .name = "scsi-disk",
+ .version_id = 0,
+ .minimum_version_id = 0,
+ .post_load = scsi_cd_post_load,
+ .fields = (VMStateField[]) {
+ VMSTATE_BOOL(tray_open, SCSIDiskState),
+ VMSTATE_BOOL(tray_locked, SCSIDiskState),
+ VMSTATE_END_OF_LIST()
+ }
+};
+
And again; if we had just one 'flags' value we would have to save only
one variable. And wouldn't need to touch this one for future states.

Agreed, but we have time until 0.16 to fix this. I plan to migrate more stuff (unit attention state, for one), I'll take care of this too.

Paolo




reply via email to

[Prev in Thread] Current Thread [Next in Thread]