public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Anthony Liguori <aliguori-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
To: dor.laor-atKUWr5tajBWk0Htik3J/w@public.gmane.org
Cc: kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
Subject: Re: [RFC] virtio-blk PCI backend
Date: Thu, 08 Nov 2007 19:38:21 -0600	[thread overview]
Message-ID: <4733BA0D.1020105@us.ibm.com> (raw)
In-Reply-To: <4733A917.5000303-atKUWr5tajBWk0Htik3J/w@public.gmane.org>

Dor Laor wrote:
> Anthony Liguori wrote:
>> This still needs quite a lot of work but I wanted to post it for 
>> reference.
>>
>> Regards,
>>
>> Anthony Liguori
>>
>> diff --git a/qemu/Makefile.target b/qemu/Makefile.target
>>   
> ...
> Why change Rusty's codding standard? It will be harder to track changes.

Because Linux kernel coding standards aren't QEMU coding standards.  
Besides, this is supposed to be an ABI so it shouldn't be changing all 
that much :-)

I posted the QEMU bits as soon as I got it working.  I still have a lot 
to do in it however I have addressed some of the things you brought up 
already.

>> +    case VIRTIO_PCI_QUEUE_PFN:
>> +    pa = (ram_addr_t)val << TARGET_PAGE_BITS;
>> +    vdev->vq[vdev->queue_sel].pfn = val;
>>   
> Some validity checks are missing, you assume you have the queue_sel.

Yes, the code is carefully written so that queue_sel is always valid.

>> +    if (pa < (ram_size - TARGET_PAGE_SIZE))
>> +        vring_init(&vdev->vq[vdev->queue_sel], phys_ram_base + pa);
>> +    break;
>> +    case VIRTIO_PCI_QUEUE_SEL:
>> +    if (val < VIRTIO_PCI_QUEUE_MAX)
>> +        vdev->queue_sel = val;
>> +    break;
>> +    case VIRTIO_PCI_QUEUE_NOTIFY:
>> +    if (val < VIRTIO_PCI_QUEUE_MAX)
>> +        virtio_ring_kick(vdev, &vdev->vq[val]);
>> +    break;
>> +    case VIRTIO_PCI_STATUS:
>> +    vdev->status = val & 0xFF;
>>   
> we should keep another internal status and it will track the 
> initialization of all the above fields (
> pfn, queue_sel,..) the device will be active once all of them were 
> initialized by the guest

Hrm, I don't follow.  The only thing that has to be written to by the 
guest is the PFN which also has the effect of activating the queue.

>> +    break;
>> +    default:
>> +    if (addr >= VIRTIO_PCI_CONFIG && vdev->set_config)
>> +        vdev->set_config(vdev->opaque, addr - VIRTIO_PCI_CONFIG, val);
>> +    break;
>> +    }
>> +}
>> +
>>   
>
> What about having block/net/9p.. in separate files? It will grow over 
> time.

Yup, already have that in my own queue.

The latest version queue for the kernel side is at 
http://hg.codemonkey.ws/virtio-pci  (based on the master branch of 
Rusty's virtio tree).  The latest queue for the QEMU side is at 
http://hg.codemonkey.ws/qemu-virtio.  I have a functioning block and 9p 
transport.  I'll continue cleaning up tomorrow and will hopefully post 
another set of patches early next week.

Unfortunately, I uncovered a bug in the in-kernel APIC code today so you 
need to run with -no-kvm-irqchip if you want to use multiple virtio 
devices at once :-/

Regards,

Anthony Liguori

>> +#include <linux/virtio_blk.h>
>> +#include <stdbool.h>
>> +
>> +#define BLK_MAX_QUEUE_SIZE    127
>> +
>> +static bool virtio_blk_handle_request(BlockDriverState *bs,
>> +                      VirtIODevice *vdev, VirtQueue *vq)
>> +{
>> +    struct iovec iov[vq->vring.num];
>> +    unsigned int head, out_num, in_num, wlen;
>> +    struct virtio_blk_inhdr *in;
>> +    struct virtio_blk_outhdr *out;
>> +
> Great job, Dor.


-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/

      parent reply	other threads:[~2007-11-09  1:38 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-11-08  2:51 [RFC] virtio-blk PCI backend Anthony Liguori
     [not found] ` <11944902733951-git-send-email-aliguori-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
2007-11-08  6:24   ` Avi Kivity
     [not found]     ` <4732ABA0.5090603-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-11-08 13:57       ` Anthony Liguori
     [not found]         ` <473315DB.9030803-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
2007-11-08 14:02           ` Avi Kivity
     [not found]             ` <4733170B.70206-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-11-08 15:09               ` Anthony Liguori
     [not found]                 ` <473326B4.2080307-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
2007-11-08 15:19                   ` Avi Kivity
     [not found]                     ` <473328EC.4090905-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-11-08 16:22                       ` Anthony Liguori
     [not found]                         ` <473337B9.8040503-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
2007-11-09  0:13                           ` Dor Laor
     [not found]                             ` <4733A635.1080004-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-11-20  8:39                               ` Christian Borntraeger
     [not found]                                 ` <200711200939.19410.borntraeger-tA70FqPdS9bQT0dZR+AlfA@public.gmane.org>
2007-11-20 10:00                                   ` Avi Kivity
     [not found]                                     ` <4742B053.8080301-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-11-20 10:17                                       ` Arnd Bergmann
     [not found]                                         ` <200711201117.17900.arnd-r2nGTMty4D4@public.gmane.org>
2007-11-20 11:05                                           ` Carsten Otte
2007-11-11  9:23                           ` Avi Kivity
2007-11-08 15:31                   ` Avi Kivity
     [not found]                     ` <47332BB7.2000900-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-11-08 19:02                       ` Anthony Liguori
2007-11-09  0:25   ` Dor Laor
     [not found]     ` <4733A917.5000303-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-11-09  1:38       ` Anthony Liguori [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=4733BA0D.1020105@us.ibm.com \
    --to=aliguori-r/jw6+rmf7hqt0dzr+alfa@public.gmane.org \
    --cc=dor.laor-atKUWr5tajBWk0Htik3J/w@public.gmane.org \
    --cc=kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org \
    /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