From: Juan Quintela <quintela@redhat.com>
To: Jason Wang <jasowang@redhat.com>
Cc: kwolf@redhat.com, qemu-devel@nongnu.org
Subject: [Qemu-devel] Re: [PATCH] floppy: save and restore DIR register
Date: Fri, 25 Mar 2011 10:25:20 +0100 [thread overview]
Message-ID: <m3fwqbeem7.fsf@neno.mitica> (raw)
In-Reply-To: <20110325062741.23726.36621.stgit@dhcp-91-7.nay.redhat.com.englab.nay.redhat.com> (Jason Wang's message of "Fri, 25 Mar 2011 14:27:42 +0800")
Jason Wang <jasowang@redhat.com> wrote:
> We need to keep DIR register unchanged across migration, but currently it
> depends on the media_changed flags from block layer and we do not save/restore
> it which could let the guest driver think the floppy have changed after
> migration. To fix this, a new filed media_changed in FDrive strcutre was
> introduced in order to save and restore the it from block layer through
> pre_save/post_load callbacks.
>
> Signed-off-by: Jason Wang <jasowang@redhat.com>
> ---
> hw/fdc.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++
> 1 files changed, 46 insertions(+), 0 deletions(-)
>
> diff --git a/hw/fdc.c b/hw/fdc.c
> index 9fdbc75..8257d51 100644
> --- a/hw/fdc.c
> +++ b/hw/fdc.c
> @@ -36,6 +36,7 @@
> #include "qdev-addr.h"
> #include "blockdev.h"
> #include "sysemu.h"
> +#include "block_int.h"
>
> /********************************************************/
> /* debug Floppy devices */
> @@ -82,6 +83,7 @@ typedef struct FDrive {
> uint8_t max_track; /* Nb of tracks */
> uint16_t bps; /* Bytes per sector */
> uint8_t ro; /* Is read-only */
> + uint8_t media_changed; /* Is media changed */
> } FDrive;
>
> static void fd_init(FDrive *drv)
> @@ -533,6 +535,42 @@ static CPUWriteMemoryFunc * const fdctrl_mem_write_strict[3] = {
> NULL,
> };
>
> +static void fdrive_media_changed_pre_save(void *opaque)
> +{
> + FDrive *drive = opaque;
> +
> + drive->media_changed = drive->bs->media_changed;
> +}
> +
> +static int fdrive_media_changed_post_load(void *opaque, int version_id)
> +{
> + FDrive *drive = opaque;
> +
> + drive->bs->media_changed = drive->media_changed;
shouldn't this be something like:
if (!drive->bs)
return 1;
drive->bs->media_changed = drive->media_changed.
???
Otherwise, we can can have troubles if floppy is not opened in the other side.
Rest of code looks nice, thanks.
Later, Juan.
next prev parent reply other threads:[~2011-03-25 9:27 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-03-25 6:27 [Qemu-devel] [PATCH] floppy: save and restore DIR register Jason Wang
2011-03-25 9:25 ` Juan Quintela [this message]
2011-03-25 11:56 ` [Qemu-devel] " Paolo Bonzini
2011-03-28 2:40 ` Jason Wang
2011-03-28 7:49 ` Paolo Bonzini
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=m3fwqbeem7.fsf@neno.mitica \
--to=quintela@redhat.com \
--cc=jasowang@redhat.com \
--cc=kwolf@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).