qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH 4/4] Add virtio disk identification support


From: john cooper
Subject: [Qemu-devel] [PATCH 4/4] Add virtio disk identification support
Date: Thu, 25 Mar 2010 01:34:02 -0400
User-agent: Thunderbird 2.0.0.9 (X11/20071115)

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 <address@hidden>
---

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.
         */
-- 
address@hidden





reply via email to

[Prev in Thread] Current Thread [Next in Thread]