From: john cooper <john.cooper@redhat.com>
To: Rusty Russell <rusty@rustcorp.com.au>,
Marc Haber <mh+qemu-devel@zugschlus.de>
Cc: john.cooper@redhat.com, qemu-devel@nongnu.org
Subject: [Qemu-devel] Re: [PATCH 4/4] Add virtio disk identification support
Date: Tue, 30 Mar 2010 01:52:33 -0400 [thread overview]
Message-ID: <4BB191A1.5060101@redhat.com> (raw)
In-Reply-To: <201003301553.29570.rusty@rustcorp.com.au>
Rusty Russell wrote:
> On Thu, 25 Mar 2010 04:04:02 pm john cooper wrote:
>> Return serial string to the guest application via
>> ioctl driver call.
>
> This is quite nice. Minor nits:
>
>> + if (cmd == 'VBID') {
>> + void *usr_data = (void __user *)data;
>
> void __user *usr_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;
>> + }
>
> We can't put the id_str on the stack? Makes it even simpler :)
At a VIRTIO_BLK_ID_BYTES of the current 20 bytes it seems
safe but there was discussion of extending it so I thought
to locate it in safer storage.
Note the above was intended as more of an example to
illustrate the mechanism. Marc had proposed a /sys
style interface to retrieve a virtio id string which
is what motivated revisiting this issue.
Marc, if you don't foresee tying off that work relatively
soon where a /sys interface would be made available, I'll
rework the above to be a little more general. The first
version of the S/N patch pulled a user buffer size from
the caller and limited the copy out to that length.
-john
--
john.cooper@redhat.com
prev parent reply other threads:[~2010-03-30 6:14 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-03-25 5:34 [Qemu-devel] [PATCH 4/4] Add virtio disk identification support john cooper
2010-03-30 5:23 ` [Qemu-devel] " Rusty Russell
2010-03-30 5:52 ` john cooper [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4BB191A1.5060101@redhat.com \
--to=john.cooper@redhat.com \
--cc=mh+qemu-devel@zugschlus.de \
--cc=qemu-devel@nongnu.org \
--cc=rusty@rustcorp.com.au \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).