From patchwork Mon Nov 29 16:04:06 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gerd Hoffmann X-Patchwork-Id: 73455 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 4CA3C1007D1 for ; Tue, 30 Nov 2010 03:44:30 +1100 (EST) Received: from localhost ([127.0.0.1]:34457 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PN6MV-0004CY-9b for incoming@patchwork.ozlabs.org; Mon, 29 Nov 2010 11:13:55 -0500 Received: from [140.186.70.92] (port=37795 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PN6DM-0008J1-CT for qemu-devel@nongnu.org; Mon, 29 Nov 2010 11:04:29 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PN6DK-0003zK-SS for qemu-devel@nongnu.org; Mon, 29 Nov 2010 11:04:28 -0500 Received: from mx1.redhat.com ([209.132.183.28]:50081) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PN6DK-0003z7-JW for qemu-devel@nongnu.org; Mon, 29 Nov 2010 11:04:26 -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 oATG4PC3012542 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 29 Nov 2010 11:04:25 -0500 Received: from rincewind.home.kraxel.org (vpn1-7-192.ams2.redhat.com [10.36.7.192]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id oATG4KsG021675; Mon, 29 Nov 2010 11:04:21 -0500 Received: by rincewind.home.kraxel.org (Postfix, from userid 500) id BEB3245252; Mon, 29 Nov 2010 17:04:10 +0100 (CET) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Mon, 29 Nov 2010 17:04:06 +0100 Message-Id: <1291046649-19353-10-git-send-email-kraxel@redhat.com> In-Reply-To: <1291046649-19353-1-git-send-email-kraxel@redhat.com> References: <1291046649-19353-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 09/12] 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 b049122..7b6a0d7 100644 --- a/hw/usb-msd.c +++ b/hw/usb-msd.c @@ -481,6 +481,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"); @@ -499,6 +500,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);