Patchwork [v2,12/45] scsi-disk: Track tray open/close state

login
register
mail settings
Submitter Markus Armbruster
Date Aug. 3, 2011, 1:07 p.m.
Message ID <1312376904-16115-13-git-send-email-armbru@redhat.com>
Download mbox | patch
Permalink /patch/108171/
State New
Headers show

Comments

Markus Armbruster - Aug. 3, 2011, 1:07 p.m.
We already track it in BlockDriverState since commit 4be9762a.  As
discussed in that commit's message, we should track it in the device
device models instead, because it's device state.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 hw/scsi-disk.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
Hannes Reinecke - Aug. 4, 2011, 6:13 a.m.
On 08/03/2011 03:07 PM, Markus Armbruster wrote:
> We already track it in BlockDriverState since commit 4be9762a.  As
> discussed in that commit's message, we should track it in the device
> device models instead, because it's device state.
>
> Signed-off-by: Markus Armbruster<armbru@redhat.com>
> ---
>   hw/scsi-disk.c |    2 ++
>   1 files changed, 2 insertions(+), 0 deletions(-)
>
> diff --git a/hw/scsi-disk.c b/hw/scsi-disk.c
> index d549cb7..2d5e157 100644
> --- a/hw/scsi-disk.c
> +++ b/hw/scsi-disk.c
> @@ -72,6 +72,7 @@ struct SCSIDiskState
>       char *version;
>       char *serial;
>       SCSISense sense;
> +    bool tray_open;
>   };
>
>   static int scsi_handle_rw_error(SCSIDiskReq *r, int error, int type);
> @@ -829,6 +830,7 @@ static void scsi_disk_emulate_start_stop(SCSIDiskReq *r)
>
>       if (s->qdev.type == TYPE_ROM&&  loej) {
>           bdrv_eject(s->bs, !start);
> +        s->tray_open = !start;
>       }
>   }
>
Acked-by: Hannes Reinecke <hare@suse.de>

Cheers,

Hannes

Patch

diff --git a/hw/scsi-disk.c b/hw/scsi-disk.c
index d549cb7..2d5e157 100644
--- a/hw/scsi-disk.c
+++ b/hw/scsi-disk.c
@@ -72,6 +72,7 @@  struct SCSIDiskState
     char *version;
     char *serial;
     SCSISense sense;
+    bool tray_open;
 };
 
 static int scsi_handle_rw_error(SCSIDiskReq *r, int error, int type);
@@ -829,6 +830,7 @@  static void scsi_disk_emulate_start_stop(SCSIDiskReq *r)
 
     if (s->qdev.type == TYPE_ROM && loej) {
         bdrv_eject(s->bs, !start);
+        s->tray_open = !start;
     }
 }