From: Paolo Bonzini <pbonzini@redhat.com>
To: qemu-devel@nongnu.org
Cc: amit.shah@redhat.com, armbru@redhat.com
Subject: [Qemu-devel] [PATCH 2/5] raw-posix: put Linux fd fields into a union
Date: Wed, 8 Feb 2012 18:37:33 +0100 [thread overview]
Message-ID: <1328722656-22856-3-git-send-email-pbonzini@redhat.com> (raw)
In-Reply-To: <1328722656-22856-1-git-send-email-pbonzini@redhat.com>
We will add CDROM-specific fields in the next patch, reuse the space
in the struct.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
block/raw-posix.c | 38 +++++++++++++++++++++-----------------
1 files changed, 21 insertions(+), 17 deletions(-)
diff --git a/block/raw-posix.c b/block/raw-posix.c
index 2a5b6fa..d9b03a1 100644
--- a/block/raw-posix.c
+++ b/block/raw-posix.c
@@ -119,11 +119,15 @@ typedef struct BDRVRawState {
int type;
int open_flags;
#if defined(__linux__)
- /* linux floppy specific */
- int64_t fd_open_time;
- int64_t fd_error_time;
- int fd_got_error;
- int fd_media_changed;
+ union {
+ struct {
+ /* linux floppy specific */
+ int64_t open_time;
+ int64_t error_time;
+ int got_error;
+ int media_changed;
+ } fdd;
+ };
#endif
#ifdef CONFIG_LINUX_AIO
int use_aio;
@@ -779,7 +783,7 @@ static int fd_open(BlockDriverState *bs)
return 0;
last_media_present = (s->fd >= 0);
if (s->fd >= 0 &&
- (get_clock() - s->fd_open_time) >= FD_OPEN_TIMEOUT) {
+ (get_clock() - s->fdd.open_time) >= FD_OPEN_TIMEOUT) {
close(s->fd);
s->fd = -1;
#ifdef DEBUG_FLOPPY
@@ -787,8 +791,8 @@ static int fd_open(BlockDriverState *bs)
#endif
}
if (s->fd < 0) {
- if (s->fd_got_error &&
- (get_clock() - s->fd_error_time) < FD_OPEN_TIMEOUT) {
+ if (s->fdd.got_error &&
+ (get_clock() - s->fdd.error_time) < FD_OPEN_TIMEOUT) {
#ifdef DEBUG_FLOPPY
printf("No floppy (open delayed)\n");
#endif
@@ -796,10 +800,10 @@ static int fd_open(BlockDriverState *bs)
}
s->fd = open(bs->filename, s->open_flags & ~O_NONBLOCK);
if (s->fd < 0) {
- s->fd_error_time = get_clock();
- s->fd_got_error = 1;
+ s->fdd.error_time = get_clock();
+ s->fdd.got_error = 1;
if (last_media_present)
- s->fd_media_changed = 1;
+ s->fdd.media_changed = 1;
#ifdef DEBUG_FLOPPY
printf("No floppy\n");
#endif
@@ -810,9 +814,9 @@ static int fd_open(BlockDriverState *bs)
#endif
}
if (!last_media_present)
- s->fd_media_changed = 1;
- s->fd_open_time = get_clock();
- s->fd_got_error = 0;
+ s->fdd.media_changed = 1;
+ s->fdd.open_time = get_clock();
+ s->fdd.got_error = 0;
return 0;
}
@@ -931,7 +935,7 @@ static int floppy_open(BlockDriverState *bs, const char *filename, int flags)
/* close fd so that we can reopen it as needed */
close(s->fd);
s->fd = -1;
- s->fd_media_changed = 1;
+ s->fdd.media_changed = 1;
return 0;
}
@@ -980,8 +984,8 @@ static int floppy_media_changed(BlockDriverState *bs)
* It does not work if the floppy is changed without trying to read it.
*/
fd_open(bs);
- ret = s->fd_media_changed;
- s->fd_media_changed = 0;
+ ret = s->fdd.media_changed;
+ s->fdd.media_changed = 0;
#ifdef DEBUG_FLOPPY
printf("Floppy changed=%d\n", ret);
#endif
--
1.7.7.6
next prev parent reply other threads:[~2012-02-08 17:38 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-02-08 17:37 [Qemu-devel] [PATCH 0/5] Fix CD-ROM door with SCSI passthrough Paolo Bonzini
2012-02-08 17:37 ` [Qemu-devel] [PATCH 1/5] raw-posix: always prefer specific devices to hdev Paolo Bonzini
2012-02-10 12:49 ` Markus Armbruster
2012-02-08 17:37 ` Paolo Bonzini [this message]
2012-02-08 17:37 ` [Qemu-devel] [PATCH 3/5] raw-posix: keep complete control of door locking if possible Paolo Bonzini
2012-02-10 12:49 ` Markus Armbruster
2012-02-10 14:00 ` Paolo Bonzini
2012-02-10 14:56 ` Markus Armbruster
2012-02-10 15:19 ` Paolo Bonzini
2012-02-08 17:37 ` [Qemu-devel] [PATCH 4/5] configure: probe for dbus Paolo Bonzini
2012-02-08 17:37 ` [Qemu-devel] [PATCH 5/5] raw-posix: unmount CD-ROM filesystem via udisks Paolo Bonzini
2012-02-10 12:51 ` Markus Armbruster
2012-02-10 14:20 ` 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=1328722656-22856-3-git-send-email-pbonzini@redhat.com \
--to=pbonzini@redhat.com \
--cc=amit.shah@redhat.com \
--cc=armbru@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).