From patchwork Thu Mar 25 05:34:02 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: john cooper X-Patchwork-Id: 48495 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 2CB3EB7C8E for ; Thu, 25 Mar 2010 16:57:17 +1100 (EST) Received: from localhost ([127.0.0.1]:44392 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Nug2r-0001S0-3c for incoming@patchwork.ozlabs.org; Thu, 25 Mar 2010 01:55:53 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Nufpo-0007bt-Nb for qemu-devel@nongnu.org; Thu, 25 Mar 2010 01:42:24 -0400 Received: from [140.186.70.92] (port=41866 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Nufpn-0007bW-8u for qemu-devel@nongnu.org; Thu, 25 Mar 2010 01:42:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1Nufpl-00011c-SD for qemu-devel@nongnu.org; Thu, 25 Mar 2010 01:42:23 -0400 Received: from mx1.redhat.com ([209.132.183.28]:40530) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Nufpl-00011V-Jy for qemu-devel@nongnu.org; Thu, 25 Mar 2010 01:42:21 -0400 Received: from int-mx05.intmail.prod.int.phx2.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.18]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o2P5gKrw029625 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 25 Mar 2010 01:42:20 -0400 Received: from anvil.naka.net (pilototp-int.redhat.com [10.11.232.41]) by int-mx05.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o2P5gBNe017362; Thu, 25 Mar 2010 01:42:14 -0400 Message-ID: <4BAAF5CA.2010401@redhat.com> Date: Thu, 25 Mar 2010 01:34:02 -0400 From: john cooper User-Agent: Thunderbird 2.0.0.9 (X11/20071115) MIME-Version: 1.0 To: Rusty Russell X-Scanned-By: MIMEDefang 2.67 on 10.5.11.18 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. Cc: john.cooper@redhat.com, Marc Haber , qemu-devel@nongnu.org Subject: [Qemu-devel] [PATCH 4/4] Add virtio disk identification 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 Return serial string to the guest application via ioctl driver call. Note this form of interface to the guest userland was the consensus when the prior version using the ATA_IDENTIFY came under dispute. Signed-off-by: john cooper diff --git a/drivers/block/virtio_blk.c b/drivers/block/virtio_blk.c index cd66806..0954193 100644 --- a/drivers/block/virtio_blk.c +++ b/drivers/block/virtio_blk.c @@ -225,6 +225,21 @@ static int virtblk_ioctl(struct block_device *bdev, fmode_t mode, struct gendisk *disk = bdev->bd_disk; struct virtio_blk *vblk = disk->private_data; + if (cmd == 'VBID') { + void *usr_data = (void __user *)data; + char *id_str; + int err; + + if (!(id_str = kmalloc(VIRTIO_BLK_ID_BYTES, GFP_KERNEL))) + err = -ENOMEM; + else if ((err = virtblk_get_id(disk, id_str))) + ; + else if (copy_to_user(usr_data, id_str, VIRTIO_BLK_ID_BYTES)) + err = -EFAULT; + if (id_str) + kfree(id_str); + return err; + } /* * Only allow the generic SCSI ioctls if the host can support it. */