From: Luiz Capitulino <lcapitulino@redhat.com>
To: qemu-devel@nongnu.org
Cc: kwolf@redhat.com, aliguori@us.ibm.com, armbru@redhat.com
Subject: [Qemu-devel] [PATCH 4/5] ide: Support I/O status
Date: Wed, 3 Aug 2011 12:19:24 -0300 [thread overview]
Message-ID: <1312384765-721-5-git-send-email-lcapitulino@redhat.com> (raw)
In-Reply-To: <1312384765-721-1-git-send-email-lcapitulino@redhat.com>
TODO: migration
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
---
hw/ide/core.c | 16 ++++++++++++++++
hw/ide/internal.h | 2 ++
2 files changed, 18 insertions(+), 0 deletions(-)
diff --git a/hw/ide/core.c b/hw/ide/core.c
index ffb6500..3f075a1 100644
--- a/hw/ide/core.c
+++ b/hw/ide/core.c
@@ -58,6 +58,11 @@ static const int smart_attributes[][12] = {
static int ide_handle_rw_error(IDEState *s, int error, int op);
static void ide_dummy_transfer_stop(IDEState *s);
+static void ide_update_iostatus(IDEState *s, int error)
+{
+ s->iostatus = bdrv_iostatus_from_error(error);
+}
+
static void padstr(char *str, const char *src, int len)
{
int i, v;
@@ -474,6 +479,7 @@ void ide_sector_read(IDEState *s)
if (n > s->req_nb_sectors)
n = s->req_nb_sectors;
ret = bdrv_read(s->bs, sector_num, s->io_buffer, n);
+ ide_update_iostatus(s, ret);
if (ret != 0) {
if (ide_handle_rw_error(s, -ret,
BM_STATUS_PIO_RETRY | BM_STATUS_RETRY_READ))
@@ -544,6 +550,7 @@ void ide_dma_cb(void *opaque, int ret)
int64_t sector_num;
handle_rw_error:
+ ide_update_iostatus(s, ret);
if (ret < 0) {
int op = BM_STATUS_DMA_RETRY;
@@ -643,6 +650,7 @@ void ide_sector_write(IDEState *s)
n = s->req_nb_sectors;
ret = bdrv_write(s->bs, sector_num, s->io_buffer, n);
+ ide_update_iostatus(s, ret);
if (ret != 0) {
if (ide_handle_rw_error(s, -ret, BM_STATUS_PIO_RETRY))
return;
@@ -678,6 +686,7 @@ static void ide_flush_cb(void *opaque, int ret)
{
IDEState *s = opaque;
+ ide_update_iostatus(s, ret);
if (ret < 0) {
/* XXX: What sector number to set here? */
if (ide_handle_rw_error(s, -ret, BM_STATUS_RETRY_FLUSH)) {
@@ -1780,10 +1789,16 @@ static bool ide_cd_is_medium_locked(void *opaque)
return ((IDEState *)opaque)->tray_locked;
}
+static BlockDevIOStatus ide_iostatus(void *opaque)
+{
+ return ((IDEState *)opaque)->iostatus;
+}
+
static const BlockDevOps ide_cd_block_ops = {
.change_media_cb = ide_cd_change_cb,
.is_medium_ejected = ide_cd_medium_ejected,
.is_medium_locked = ide_cd_is_medium_locked,
+ .get_iostatus = ide_iostatus,
};
int ide_init_drive(IDEState *s, BlockDriverState *bs, IDEDriveKind kind,
@@ -1843,6 +1858,7 @@ int ide_init_drive(IDEState *s, BlockDriverState *bs, IDEDriveKind kind,
} else {
pstrcpy(s->version, sizeof(s->version), QEMU_VERSION);
}
+ s->iostatus = BDRV_IOS_INVAL;
ide_reset(s);
if (s->drive_kind == IDE_CD) {
diff --git a/hw/ide/internal.h b/hw/ide/internal.h
index 2feae25..3a9a2cf 100644
--- a/hw/ide/internal.h
+++ b/hw/ide/internal.h
@@ -480,6 +480,8 @@ struct IDEState {
uint8_t *smart_selftest_data;
/* AHCI */
int ncq_queues;
+
+ BlockDevIOStatus iostatus;
};
struct IDEDMAOps {
--
1.7.6.396.ge0613
next prev parent reply other threads:[~2011-08-03 15:20 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-08-03 15:19 [Qemu-devel] [PATCH v2 0/5]: QMP: Proper thin provisioning support Luiz Capitulino
2011-08-03 15:19 ` [Qemu-devel] [PATCH 1/5] block: Introduce get_iostatus() device model operation Luiz Capitulino
2011-08-03 15:19 ` [Qemu-devel] [PATCH 2/5] QMP/HMP: Add the 'io-status' field to query-block and info block Luiz Capitulino
2011-08-03 15:19 ` [Qemu-devel] [PATCH 3/5] virtio-blk: Support I/O status Luiz Capitulino
2011-08-03 15:19 ` Luiz Capitulino [this message]
2011-08-03 15:19 ` [Qemu-devel] [PATCH 5/5] scsi-disk: " Luiz Capitulino
2011-08-03 15:39 ` [Qemu-devel] [PATCH v2 0/5]: QMP: Proper thin provisioning support Kevin Wolf
2011-08-03 18:08 ` Luiz Capitulino
2011-08-04 8:10 ` Kevin Wolf
2011-08-04 9:19 ` Markus Armbruster
2011-08-04 13:42 ` Luiz Capitulino
2011-08-03 16:31 ` Christoph Hellwig
2011-08-03 18:11 ` Luiz Capitulino
2011-08-03 18:26 ` Christoph Hellwig
2011-08-03 18:36 ` Luiz Capitulino
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=1312384765-721-5-git-send-email-lcapitulino@redhat.com \
--to=lcapitulino@redhat.com \
--cc=aliguori@us.ibm.com \
--cc=armbru@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).