From patchwork Fri Dec 17 11:26:26 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gerd Hoffmann X-Patchwork-Id: 75863 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 B72CA1007D3 for ; Fri, 17 Dec 2010 22:34:46 +1100 (EST) Received: from localhost ([127.0.0.1]:46936 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PTYZs-0003pJ-2x for incoming@patchwork.ozlabs.org; Fri, 17 Dec 2010 06:34:24 -0500 Received: from [140.186.70.92] (port=39058 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PTYSn-0007vR-Kg for qemu-devel@nongnu.org; Fri, 17 Dec 2010 06:27:10 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PTYSl-0007RU-V8 for qemu-devel@nongnu.org; Fri, 17 Dec 2010 06:27:04 -0500 Received: from mx1.redhat.com ([209.132.183.28]:10155) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PTYSl-0007RQ-Kt for qemu-devel@nongnu.org; Fri, 17 Dec 2010 06:27:03 -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 oBHBR2VT025570 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 17 Dec 2010 06:27:03 -0500 Received: from rincewind.home.kraxel.org (vpn2-10-81.ams2.redhat.com [10.36.10.81]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id oBHBQwn4007954; Fri, 17 Dec 2010 06:26:58 -0500 Received: by rincewind.home.kraxel.org (Postfix, from userid 500) id 965D941308; Fri, 17 Dec 2010 12:26:47 +0100 (CET) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Fri, 17 Dec 2010 12:26:26 +0100 Message-Id: <1292585206-24862-11-git-send-email-kraxel@redhat.com> In-Reply-To: <1292585206-24862-1-git-send-email-kraxel@redhat.com> References: <1292585206-24862-1-git-send-email-kraxel@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: Gerd Hoffmann Subject: [Qemu-devel] [PATCH 10/30] usb storage: serial number support 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 If a serial number is present for the drive fill it into the usb serialnumber string descriptor. Signed-off-by: Gerd Hoffmann --- hw/usb-msd.c | 6 ++++++ 1 files changed, 6 insertions(+), 0 deletions(-) diff --git a/hw/usb-msd.c b/hw/usb-msd.c index 20ab886..9aa8888 100644 --- a/hw/usb-msd.c +++ b/hw/usb-msd.c @@ -482,6 +482,7 @@ static int usb_msd_initfn(USBDevice *dev) { MSDState *s = DO_UPCAST(MSDState, dev, dev); BlockDriverState *bs = s->conf.bs; + DriveInfo *dinfo; if (!bs) { error_report("usb-msd: drive property not set"); @@ -500,6 +501,11 @@ static int usb_msd_initfn(USBDevice *dev) bdrv_detach(bs, &s->dev.qdev); s->conf.bs = NULL; + dinfo = drive_get_by_blockdev(bs); + if (dinfo && dinfo->serial) { + usb_desc_set_string(dev, STR_SERIALNUMBER, dinfo->serial); + } + s->dev.speed = USB_SPEED_FULL; scsi_bus_new(&s->bus, &s->dev.qdev, 0, 1, usb_msd_command_complete); s->scsi_dev = scsi_bus_legacy_add_drive(&s->bus, bs, 0);