From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:33200) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RHEwP-0001Kr-BZ for qemu-devel@nongnu.org; Fri, 21 Oct 2011 09:15:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RHEwN-0005A0-PV for qemu-devel@nongnu.org; Fri, 21 Oct 2011 09:15:17 -0400 Received: from mx1.redhat.com ([209.132.183.28]:16836) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RHEkn-0002Q7-VS for qemu-devel@nongnu.org; Fri, 21 Oct 2011 09:03:21 -0400 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p9LD3G0N001284 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 21 Oct 2011 09:03:16 -0400 Message-ID: <4EA16D91.4070308@redhat.com> Date: Fri, 21 Oct 2011 15:03:13 +0200 From: Paolo Bonzini MIME-Version: 1.0 References: <1318503845-11473-1-git-send-email-pbonzini@redhat.com> <1318503845-11473-16-git-send-email-pbonzini@redhat.com> <4EA16636.7000807@redhat.com> In-Reply-To: <4EA16636.7000807@redhat.com> Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH 15/35] scsi: remove devs array from SCSIBus List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Kevin Wolf Cc: qemu-devel@nongnu.org On 10/21/2011 02:31 PM, Kevin Wolf wrote: >> > diff --git a/hw/esp.c b/hw/esp.c >> > index d3fb1c6..8e17005 100644 >> > --- a/hw/esp.c >> > +++ b/hw/esp.c >> > @@ -217,7 +217,8 @@ static uint32_t get_cmd(ESPState *s, uint8_t *buf) >> > s->async_len = 0; >> > } >> > >> > - if (target>= ESP_MAX_DEVS || !s->bus.devs[target]) { >> > + s->current_dev = scsi_device_find(&s->bus, target, 0); >> > + if (!s->current_dev) { >> > // No such drive >> > s->rregs[ESP_RSTAT] = 0; >> > s->rregs[ESP_RINTR] = INTR_DC; >> > @@ -225,7 +226,6 @@ static uint32_t get_cmd(ESPState *s, uint8_t *buf) >> > esp_raise_irq(s); >> > return 0; >> > } >> > - s->current_dev = s->bus.devs[target]; >> > return dmalen; >> > } >> > >> > @@ -236,6 +236,7 @@ static void do_busid_cmd(ESPState *s, uint8_t *buf, uint8_t busid) >> > >> > trace_esp_do_busid_cmd(busid); >> > lun = busid& 7; >> > + s->current_dev = scsi_device_find(&s->bus, s->current_dev->id, lun); > This is new, and I can't see an explanation in the commit log. It isn't really new; up until now the lun was hard-coded to zero and so s->current_dev could be set in get_cmd. Now we have to delay it until do_busid_cmd because we actually have a place to pass the LUN. That said, s->current_dev is never really used outside do_busid_cmd, so I can instead do something like: - s->current_req = scsi_req_new(s->current_dev, 0, lun, buf, NULL); + SCSIDevice *current_lun; + + current_lun = scsi_device_find(&s->bus, 0, s->current_dev->id, lun); + s->current_req = scsi_req_new(current_lun, 0, lun, buf, NULL); That would be the same as the code I have above. Paolo