From patchwork Wed Nov 17 16:43:58 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gleb Natapov X-Patchwork-Id: 333311 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id oAHGiMA8020576 for ; Wed, 17 Nov 2010 16:44:23 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935030Ab0KQQoP (ORCPT ); Wed, 17 Nov 2010 11:44:15 -0500 Received: from mx1.redhat.com ([209.132.183.28]:45607 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935009Ab0KQQoM (ORCPT ); Wed, 17 Nov 2010 11:44:12 -0500 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id oAHGi6AP010007 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 17 Nov 2010 11:44:07 -0500 Received: from dhcp-1-237.tlv.redhat.com (dhcp-1-237.tlv.redhat.com [10.35.1.237]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id oAHGi6ZJ019784; Wed, 17 Nov 2010 11:44:06 -0500 Received: by dhcp-1-237.tlv.redhat.com (Postfix, from userid 13519) id 73BEC133F81; Wed, 17 Nov 2010 18:44:04 +0200 (IST) From: Gleb Natapov To: qemu-devel@nongnu.org Cc: kvm@vger.kernel.org, blauwirbel@gmail.com, armbru@redhat.com, alex.williamson@redhat.com, mst@redhat.com, kevin@koconnor.net Subject: [PATCHv6 11/16] Add get_dev_path callback to scsi bus. Date: Wed, 17 Nov 2010 18:43:58 +0200 Message-Id: <1290012243-6087-12-git-send-email-gleb@redhat.com> In-Reply-To: <1290012243-6087-1-git-send-email-gleb@redhat.com> References: <1290012243-6087-1-git-send-email-gleb@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter1.kernel.org [140.211.167.41]); Wed, 17 Nov 2010 16:44:23 +0000 (UTC) diff --git a/hw/scsi-bus.c b/hw/scsi-bus.c index 5a3fd4b..db7482a 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(), @@ -528,3 +531,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); +}