From patchwork Thu Dec 9 12:30:12 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gerd Hoffmann X-Patchwork-Id: 74937 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 A21AEB6F14 for ; Fri, 10 Dec 2010 03:44:32 +1100 (EST) Received: from localhost ([127.0.0.1]:38251 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PQjbZ-0000kL-19 for incoming@patchwork.ozlabs.org; Thu, 09 Dec 2010 11:44:29 -0500 Received: from [140.186.70.92] (port=49749 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PQfe3-0001T8-31 for qemu-devel@nongnu.org; Thu, 09 Dec 2010 07:30:48 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PQfe2-0005Gb-1N for qemu-devel@nongnu.org; Thu, 09 Dec 2010 07:30:47 -0500 Received: from mx1.redhat.com ([209.132.183.28]:12054) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PQfe1-0005GR-Q8 for qemu-devel@nongnu.org; Thu, 09 Dec 2010 07:30:45 -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 oB9CUi0c016419 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 9 Dec 2010 07:30:45 -0500 Received: from rincewind.home.kraxel.org (vpn1-4-138.ams2.redhat.com [10.36.4.138]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id oB9CUe4u004033; Thu, 9 Dec 2010 07:30:40 -0500 Received: by rincewind.home.kraxel.org (Postfix, from userid 500) id A24DC4521A; Thu, 9 Dec 2010 13:30:28 +0100 (CET) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Thu, 9 Dec 2010 13:30:12 +0100 Message-Id: <1291897827-11424-10-git-send-email-kraxel@redhat.com> In-Reply-To: <1291897827-11424-1-git-send-email-kraxel@redhat.com> References: <1291897827-11424-1-git-send-email-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. Cc: Gerd Hoffmann Subject: [Qemu-devel] [PATCH 09/24] 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);