qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH v2 11/45] scsi-disk: Factor out scsi_disk_emulat


From: Hannes Reinecke
Subject: Re: [Qemu-devel] [PATCH v2 11/45] scsi-disk: Factor out scsi_disk_emulate_start_stop()
Date: Thu, 04 Aug 2011 08:12:33 +0200
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.14) Gecko/20110221 SUSE/3.1.8 Thunderbird/3.1.8

On 08/03/2011 03:07 PM, Markus Armbruster wrote:
Signed-off-by: Markus Armbruster<address@hidden>
---
  hw/scsi-disk.c |   17 +++++++++++++----
  1 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/hw/scsi-disk.c b/hw/scsi-disk.c
index fa198f9..d549cb7 100644
--- a/hw/scsi-disk.c
+++ b/hw/scsi-disk.c
@@ -820,6 +820,18 @@ static int scsi_disk_emulate_read_toc(SCSIRequest *req, 
uint8_t *outbuf)
      return toclen;
  }

+static void scsi_disk_emulate_start_stop(SCSIDiskReq *r)
+{
+    SCSIRequest *req =&r->req;
+    SCSIDiskState *s = DO_UPCAST(SCSIDiskState, qdev, req->dev);
+    bool start = req->cmd.buf[4]&  1;
+    bool loej = req->cmd.buf[4]&  2;
+
+    if (s->qdev.type == TYPE_ROM&&  loej) {
+        bdrv_eject(s->bs, !start);
+    }
+}
+
  static int scsi_disk_emulate_command(SCSIDiskReq *r, uint8_t *outbuf)
  {
      SCSIRequest *req =&r->req;
@@ -873,10 +885,7 @@ static int scsi_disk_emulate_command(SCSIDiskReq *r, 
uint8_t *outbuf)
              goto illegal_request;
          break;
      case START_STOP:
-        if (s->qdev.type == TYPE_ROM&&  (req->cmd.buf[4]&  2)) {
-            /* load/eject medium */
-            bdrv_eject(s->bs, !(req->cmd.buf[4]&  1));
-        }
+        scsi_disk_emulate_start_stop(r);
          break;
      case ALLOW_MEDIUM_REMOVAL:
          bdrv_set_locked(s->bs, req->cmd.buf[4]&  1);

Acked-by: Hannes Reinecke <address@hidden>

Cheers,

Hannes
--
Dr. Hannes Reinecke                   zSeries & Storage
address@hidden                        +49 911 74053 688
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: J. Hawn, J. Guild, F. Imendörffer, HRB 16746 (AG Nürnberg)



reply via email to

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