qemu-devel
[Top][All Lists]
Advanced

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

[Qemu-devel] [PATCH 4/5] ide: Support I/O status


From: Luiz Capitulino
Subject: [Qemu-devel] [PATCH 4/5] ide: Support I/O status
Date: Wed, 3 Aug 2011 12:19:24 -0300

TODO: migration

Signed-off-by: Luiz Capitulino <address@hidden>
---
 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




reply via email to

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