From patchwork Mon Dec 6 13:54:42 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gleb Natapov X-Patchwork-Id: 74354 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id F279CB70AF for ; Tue, 7 Dec 2010 01:06:20 +1100 (EST) Received: from localhost ([127.0.0.1]:45066 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PPbhp-0008GU-Vh for incoming@patchwork.ozlabs.org; Mon, 06 Dec 2010 09:06:18 -0500 Received: from [140.186.70.92] (port=46132 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PPbWu-0002uS-1V for qemu-devel@nongnu.org; Mon, 06 Dec 2010 08:55:06 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PPbWp-00023L-Vs for qemu-devel@nongnu.org; Mon, 06 Dec 2010 08:54:59 -0500 Received: from mx1.redhat.com ([209.132.183.28]:52426) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PPbWp-00022F-Om for qemu-devel@nongnu.org; Mon, 06 Dec 2010 08:54:55 -0500 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id oB6Dso19031694 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 6 Dec 2010 08:54:51 -0500 Received: from dhcp-1-237.tlv.redhat.com (dhcp-1-237.tlv.redhat.com [10.35.1.237]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id oB6DsoiO002400; Mon, 6 Dec 2010 08:54:50 -0500 Received: by dhcp-1-237.tlv.redhat.com (Postfix, from userid 13519) id 3C21218D3A7; Mon, 6 Dec 2010 15:54:48 +0200 (IST) From: Gleb Natapov To: qemu-devel@nongnu.org Date: Mon, 6 Dec 2010 15:54:42 +0200 Message-Id: <1291643687-32232-12-git-send-email-gleb@redhat.com> In-Reply-To: <1291643687-32232-1-git-send-email-gleb@redhat.com> References: <1291643687-32232-1-git-send-email-gleb@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. Cc: blauwirbel@gmail.com, kevin@koconnor.net, kvm@vger.kernel.org Subject: [Qemu-devel] [PATCHv7 11/16] Add get_fw_dev_path callback to scsi bus. X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Signed-off-by: Gleb Natapov --- hw/scsi-bus.c | 23 +++++++++++++++++++++++ 1 files changed, 23 insertions(+), 0 deletions(-) diff --git a/hw/scsi-bus.c b/hw/scsi-bus.c index 93f0e9a..7febb86 100644 --- a/hw/scsi-bus.c +++ b/hw/scsi-bus.c @@ -5,9 +5,12 @@ #include "qdev.h" #include "blockdev.h" +static char *scsibus_get_fw_dev_path(DeviceState *dev); + static struct BusInfo scsi_bus_info = { .name = "SCSI", .size = sizeof(SCSIBus), + .get_fw_dev_path = scsibus_get_fw_dev_path, .props = (Property[]) { DEFINE_PROP_UINT32("scsi-id", SCSIDevice, id, -1), DEFINE_PROP_END_OF_LIST(), @@ -518,3 +521,23 @@ void scsi_req_complete(SCSIRequest *req) req->tag, req->status); } + +static char *scsibus_get_fw_dev_path(DeviceState *dev) +{ + SCSIDevice *d = (SCSIDevice*)dev; + SCSIBus *bus = scsi_bus_from_device(d); + char path[100]; + int i; + + for (i = 0; i < bus->ndev; i++) { + if (bus->devs[i] == d) { + break; + } + } + + assert(i != bus->ndev); + + snprintf(path, sizeof(path), "%s@%x", qdev_fw_name(dev), i); + + return strdup(path); +}