QEMU support for virtio (v2)
cover QEMU support for virtio (v2)
This patch series implements QEMU support for PCI based virtio devices. The series also updates the kvm-userspace tree to have the ability to build virtio devices as modules from an external tree (just as we do with the kvm modules).
There's still some notable TODO's left so it's not mergable in it's current state. I just wanted to get it out there for some feedback.
Things seem to work pretty well right now. These patches depend on having a guest kernel using Rusty's virtio tree (and patches/1 branch). They also require my virtio patch queue. The latest version of these patches are available at:
http://hg.codemonkey.ws/qemu-virtio
And my patch queue against Rusty's tree is at:
http://hg.codemonkey.ws/virtio-pci
-------------------------------------------------------------------------
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/
A message that is not in the archive (sent off-list or not yet received): 11947512401155-git-send-email-aliguori-r/[email protected]
PATCH 1/6 Basic virtio infrastructure for QEMU (v2)
This implements the basic virtio and virtio_ring infrastructure for QEMU. It's designed at the moment with intimate knowledge of the virtio_pci device. In the future, we may want to abstract that a little further so that the virtio backend device doesn't have any knowledge of the virtio transport.
qemu/Makefile.target +3 -0
@@ -448,6 +448,9 @@ VL_OBJS += rtl8139.o # PCI Hypercall VL_OBJS+= hypercall.o +# virtio devices +VL_OBJS += virtio.o + ifeq ($(TARGET_BASE_ARCH), i386) # Hardware support VL_OBJS+= ide.o pckbd.o ps2.o vga.o $(SOUND_HW) dma.o $(AUDIODRV)
qemu/hw/virtio.c new file +336 -0
336 lines not on this page · raw message
qemu/hw/virtio.h new file +136 -0
136 lines not on this page · raw message
qemu/vl.h +4 -0
@@ -1392,6 +1392,10 @@ typedef struct ADBDevice ADBDevice;void pci_hypercall_init (PCIBus *bus);void vmchannel_init (CharDriverState *hd,uint32_t deviceid,uint32_t index); +/* virtio.c */ + +typedef struct VirtIODevice VirtIODevice ; +/* buf = NULL means polling */ typedef int ADBDeviceRequest (ADBDevice *d,uint8_t *buf_out,const uint8_t *buf,int len);
-------------------------------------------------------------------------
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/
PATCH 2/6 virtio block driver for QEMU (v2)
In reply to a message not in the archiveThis patch implements a very naive virtio block device backend in QEMU. There's a lot of room for future optimization. We need to merge a -disk patch before we can provide a mechanism to expose this to users.
qemu/Makefile.target +1 -1
@@ -449,7 +449,7 @@ VL_OBJS += rtl8139.o VL_OBJS+= hypercall.o # virtio devices -VL_OBJS += virtio.o +VL_OBJS += virtio.o virtio-blk.o ifeq ($(TARGET_BASE_ARCH), i386) # Hardware support
qemu/hw/pc.c +8 -0
@@ -943,6 +943,14 @@ static void pc_init1(ram_addr_t ram_size, int vga_ram_size, int boot_device,#ifdef USE_HYPERCALL pci_hypercall_init (pci_bus);#endif + +if (1 ) { +BlockDriverState *bs =bdrv_new ("vda" ); +if (bdrv_open (bs,"/home/anthony/images/linux.img" ,BDRV_O_SNAPSHOT )) +exit (1 ); +virtio_blk_init (pci_bus,0x5002 ,0x2258 , bs); + } +if (pci_enabled) {pci_piix3_ide_init (pci_bus, bs_table, piix3_devfn +1 , i8259); }else {
qemu/hw/virtio-blk.c new file +162 -0
162 lines not on this page · raw message
qemu/vl.h +3 -0
@@ -1396,6 +1396,9 @@ void vmchannel_init(CharDriverState *hd, uint32_t deviceid, uint32_t index);typedef struct VirtIODevice VirtIODevice ; +VirtIODevice *virtio_blk_init (PCIBus *bus,uint16_t vendor,uint16_t device, +BlockDriverState *bs); +/* buf = NULL means polling */ typedef int ADBDeviceRequest (ADBDevice *d,uint8_t *buf_out,const uint8_t *buf,int len);
-------------------------------------------------------------------------
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/
A message that is not in the archive (sent off-list or not yet received): 11947512432057-git-send-email-aliguori-r/[email protected]
Re: [PATCH 2/6] virtio block driver for QEMU (v2)
Quoted 9 lines · Anthony Liguori
This patch implements a very naive virtio block device backend in QEMU. There's a lot of room for future optimization. We need to merge a -disk patch before we can provide a mechanism to expose this to users.
Signed-off-by Anthony Liguori <aliguori-r/[email protected]>qemu/Makefile.target +0
-0
[snip]
qemu/Makefile.target
Quoted 6 lines
qemu/Makefile.target +5
-0+ + if (1) { + BlockDriverState *bs = bdrv_new("vda"); + if (bdrv_open(bs, "/home/anthony/images/linux.img", BDRV_O_SNAPSHOT)) + exit(1);
Can you add a printf to the exit(1). I had to gdb the code to find why my qemu is not running no more (in earlier version
I did remember to change the path but not after the new patches. [snip]
Quoted 40 lines
qemu/Makefile.target +39
-0+ +static void virtio_blk_handle_output(VirtIODevice *vdev, VirtQueue *vq) +{ + VirtIOBlock *s = to_virtio_blk(vdev); + VirtQueueElement elem; + unsigned int count; + + while ((count = virtqueue_pop(vq, &elem)) != 0) { + struct virtio_blk_inhdr *in; + struct virtio_blk_outhdr *out; + unsigned int wlen; + off_t off; + int i; + + out = (void *)elem.out_sg[0].iov_base; + in = (void *)elem.in_sg[elem.in_num - 1].iov_base; + off = out->sector; + + if (out->type & VIRTIO_BLK_T_SCSI_CMD) { + wlen = sizeof(*in); + in->status = VIRTIO_BLK_S_UNSUPP; + } else if (out->type & VIRTIO_BLK_T_OUT) { + wlen = sizeof(*in); + + for (i = 1; i < elem.out_num; i++) { + bdrv_write(s->bs, off, + elem.out_sg[i].iov_base, + elem.out_sg[i].iov_len / 512); + off += elem.out_sg[i].iov_len / 512; + } + + in->status = VIRTIO_BLK_S_OK; + } else { + wlen = sizeof(*in); + + for (i = 0; i < elem.in_num - 1; i++) { + bdrv_read(s->bs, off, + elem.in_sg[i].iov_base, + elem.in_sg[i].iov_len / 512);
qemu/Makefile.target
Quoted 10 lines
qemu/Makefile.target +10
-0+ off += elem.in_sg[i].iov_len / 512; + wlen += elem.in_sg[i].iov_len; + } + + in->status = VIRTIO_BLK_S_OK; + } + + virtqueue_push(vq, &elem, wlen); + virtio_notify(vdev, vq); + }
You can move the notify out of the while loop. This way you save irqs.
Quoted 9 lines
qemu/Makefile.target +8
-0+} + +static void virtio_blk_update_config(VirtIODevice *vdev, uint8_t *config) +{ + VirtIOBlock *s = to_virtio_blk(vdev); + int64_t capacity; + uint32_t v; +
qemu/Makefile.target
Quoted 10 lines
qemu/Makefile.target +10
-0+ bdrv_get_geometry(s->bs, &capacity); + memcpy(config + VIRTIO_CONFIG_BLK_F_CAPACITY, &capacity, sizeof(capacity)); + + v = VIRTQUEUE_MAX_SIZE - 2; + memcpy(config + VIRTIO_CONFIG_BLK_F_SEG_MAX, &v, sizeof(v)); +} + +static uint32_t virtio_blk_get_features(VirtIODevice *vdev) +{ + return (1 << VIRTIO_BLK_F_SEG_MAX);
In general I think we need to add another feature or even version number ( I know you guys hate it).
The reason is - Let's say you dont change functionality but change the irq protocol (for example the isr won't be zeroed on read), then an old guest driver wouldn't know it runs on a new host version and will have its irq line pulled up.
So I suggest adding a capability of VIRTIO_ISR_CLEAR_XXX or adding a version number.
Comments?
Quoted 26 lines
qemu/Makefile.target +19
-0+} + +VirtIODevice *virtio_blk_init(PCIBus *bus, uint16_t vendor, uint16_t device, + BlockDriverState *bs) +{ + VirtIOBlock *s; + + s = (VirtIOBlock *)virtio_init_pci(bus, "virtio-blk", vendor, device, + vendor, VIRTIO_ID_BLOCK, + 16, sizeof(VirtIOBlock)); + + s->vdev.update_config = virtio_blk_update_config; + s->vdev.get_features = virtio_blk_get_features; + s->bs = bs; + + virtio_add_queue(&s->vdev, virtio_blk_handle_output); + + return &s->vdev; +}qemu/vl.h +0
-0
qemu/vl.h void vmchannel_init(CharDriverState *hd, uint32_t deviceid, uint32_t index); · line 1404
Quoted 9 lines
qemu/vl.h +3
-0@@ -1396,6 +1396,9 @@ void vmchannel_init(CharDriverState *hd, uint32_t deviceid, uint32_t index);typedef struct VirtIODevice VirtIODevice ; +VirtIODevice *virtio_blk_init (PCIBus *bus,uint16_t vendor,uint16_t device, +BlockDriverState *bs); +/* buf = NULL means polling */ typedef int ADBDeviceRequest (ADBDevice *d,uint8_t *buf_out,const uint8_t *buf,int len);
-------------------------------------------------------------------------
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/
A message that is not in the archive (sent off-list or not yet received): 47373ADF.3000607-atKUWr5tajBWk0Htik3J/[email protected]
Re: [PATCH 2/6] virtio block driver for QEMU (v2)
Quoted 10 lines · Dor Laor
Quoted 7 lines
qemu/hw/pc.c +4
-0+ +if (1 ) { +BlockDriverState *bs =bdrv_new ("vda" ); + if (bdrv_open(bs, "/home/anthony/images/linux.img",
BDRV_O_SNAPSHOT))
+ exit(1);Can you add a printf to the exit(1). I had to gdb the code to find why my qemu is not running no more (in earlier version
I did remember to change the path but not after the new patches.
Heh, sorry about that.
Quoted 6 lines
[snip]
qemu/hw/virtio-blk.c line 125
Quoted 4 lines
qemu/hw/virtio-blk.c new file +3
-0+virtqueue_push (vq, &elem, wlen); +virtio_notify (vdev, vq); + }You can move the notify out of the while loop. This way you save irqs.
I don't think it does actually. This raises the line multiple times, but if the line is already raised, it's effectively a nop. Now, with KVM's in-kernel APIC, it ends up generating more syscalls than is necessary so it's worth changing.
Quoted 22 lines
Quoted 13 lines
qemu/hw/pc.c +3
-0+} + +static void virtio_blk_update_config(VirtIODevice *vdev, uint8_t*config)
qemu/hw/virtio-blk.c new file +7
-0+{ +VirtIOBlock *s =to_virtio_blk (vdev); +int64_t capacity; +uint32_t v; + +bdrv_get_geometry (s->bs, &capacity); + memcpy(config + VIRTIO_CONFIG_BLK_F_CAPACITY, &capacity,sizeof(capacity));
qemu/hw/virtio-blk.c line 143
Quoted 8 lines
qemu/hw/virtio-blk.c new file +8
-0+ + v =VIRTQUEUE_MAX_SIZE -2 ; +memcpy (config +VIRTIO_CONFIG_BLK_F_SEG_MAX , &v,sizeof (v)); +} + +static uint32_t virtio_blk_get_features (VirtIODevice *vdev) +{ +return (1 <<VIRTIO_BLK_F_SEG_MAX );In general I think we need to add another feature or even version
Quoted 8 lines
number ( I know you guys hate it).
The reason is - Let's say you dont change functionality but change the irq protocol (for example the isr won't be zeroed on read), then an old guest driver wouldn't know it runs on a new host version and will have its irq line pulled up.
So I suggest adding a capability ofVIRTIO_ISR_CLEAR_XXXor adding a version number.
Comments?
I don't think we'll actually change the ISR protocol. I think it's the best that it can actually be. However, if we do need to change the ABI for some reason, I think the right thing to do is just use a new device ID (since it's effectively a new device).
Regards,
Anthony Liguori
Quoted 30 lines
Quoted 30 lines
qemu/hw/pc.c +3
-0+} + +VirtIODevice *virtio_blk_init(PCIBus *bus, uint16_t vendor, uint16_tdevice,
qemu/hw/virtio-blk.c new file +5
-0+ BlockDriverState *bs) +{ +VirtIOBlock *s; + + s = (VirtIOBlock *)virtio_init_pci(bus, "virtio-blk", vendor,device,
qemu/hw/virtio-blk.c new file +11
-0+ vendor,VIRTIO_ID_BLOCK , + 16, sizeof(VirtIOBlock)); + + s->vdev.update_config = virtio_blk_update_config; + s->vdev.get_features = virtio_blk_get_features; + s->bs = bs; + +virtio_add_queue (&s->vdev, virtio_blk_handle_output); + +return &s->vdev; +}qemu/vl.h +0
-0@@ -1396,6 +1396,9 @@ void vmchannel_init(CharDriverState *hd, uint32_t deviceid, uint32_t index);typedef struct VirtIODevice VirtIODevice ;
Quoted 10 lines
Quoted 9 lines
qemu/vl.h +3
-0+VirtIODevice *virtio_blk_init (PCIBus *bus,uint16_t vendor,uint16_t device, +BlockDriverState *bs); +/* buf = NULL means polling */ typedef int ADBDeviceRequest(ADBDevice *d,
uint8_t*buf_out,const uint8_t *buf, int len);
-------------------------------------------------------------------------
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/
A message that is not in the archive (sent off-list or not yet received): 47375731.7020007-r/[email protected]
Re: [PATCH 2/6] virtio block driver for QEMU (v2)
Quoted 13 lines · Anthony Liguori
Quoted 11 lines · Dor Laor
Quoted 1 line
In general I think we need to add another feature or even version number ( I know you guys hate it).
The reason is - Let's say you dont change functionality but change the irq protocol (for example the isr won't be zeroed on read), then an old
guest driver wouldn't know it runs on a new host version and will have its irq line pulled up.
So I suggest adding a capability ofVIRTIO_ISR_CLEAR_XXXor adding a version number.
Comments?
Quoted 8 lines
I don't think we'll actually change the ISR protocol. I think it's the best that it can actually be. However, if we do need to change the ABI for some reason, I think the right thing to do is just use a new device ID (since it's effectively a new device).
Regards,
Anthony Liguori
Changing the devid is acceptable and much more easier then backward compatibility support, I prefer it too.
Note that there are some disadvantages when changing the devid - For example,
if you installed an old device drivers in the guest kernel and after a while you bring the guest down,
upgrade the kvm host version and bring the guest back up. If it has a new device id (and since the abi is not maintained the driver won't match VENDOR=virtio; DEVID=*),
then the guest won't have a driver for the new device.
In that case I think a guest agent can switch to fully virtualized device and afterwards install the driver automatically. This is what we do in our production environment.
Regards,
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/
A message that is not in the archive (sent off-list or not yet received): 4738452F.8070502-atKUWr5tajBWk0Htik3J/[email protected]
Re: [PATCH 2/6] virtio block driver for QEMU (v2)
Quoted 22 lines · Dor Laor
Quoted 13 lines · Anthony Liguori
Quoted 11 lines · Dor Laor
Quoted 1 line
In general I think we need to add another feature or even version number ( I know you guys hate it).
The reason is - Let's say you dont change functionality but change the irq protocol (for example the isr won't be zeroed on read), then an old
guest driver wouldn't know it runs on a new host version and will have its irq line pulled up.
So I suggest adding a capability ofVIRTIO_ISR_CLEAR_XXXor adding a version number.
Comments?Quoted 8 lines
I don't think we'll actually change the ISR protocol. I think it's the best that it can actually be. However, if we do need to change the ABI for some reason, I think the right thing to do is just use a new device ID (since it's effectively a new device).
Regards,
Anthony Liguori
Quoted 13 lines
Changing the devid is acceptable and much more easier then backward compatibility support, I prefer it too.
Note that there are some disadvantages when changing the devid - For example,
if you installed an old device drivers in the guest kernel and after a while you bring the guest down,
upgrade the kvm host version and bring the guest back up. If it has a new device id (and since the abi is not maintained the driver won't match VENDOR=virtio; DEVID=*),
then the guest won't have a driver for the new device.
In that case I think a guest agent can switch to fully virtualized device and afterwards install the driver automatically. This is what we do in our production environment.
Hrm, I have to think about backwards compatibility at the virtio-pci layer. virtio-pci basically exposes two things, the first is an ABI for doing bidirectional notification and setting driver status. The second is a standard and transparent mechanism for virt_rings.
I think that the first is simply enough that we don't need a feature mask or a version number. Maybe perhaps with the status bits, I don't know. For the virt_rings, if we had something more sophisticated than virt_rings down the road, that can be discovered/configured in the per-device configuration area so I don't think we need feature/version info for that.
Rusty, Avi: any thoughts? I'm a bit on the fence.
Regards,
Anthony Liguori
Quoted 2 lines
Regards,
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/
A message that is not in the archive (sent off-list or not yet received): 4738E102.2050200-r/[email protected]
Re: [PATCH 2/6] virtio block driver for QEMU (v2)
Quoted 42 lines · On Tuesday 13 November 2007 10:25:54 Anthony Liguori wrote:
Quoted 22 lines · Dor Laor
Quoted 12 lines · Anthony Liguori
Quoted 10 lines · Dor Laor
In general I think we need to add another feature or even version number ( I know you guys hate it).
The reason is - Let's say you dont change functionality but change the irq protocol (for example the isr won't be zeroed on read), then an old
guest driver wouldn't know it runs on a new host version and will have its irq line pulled up.
So I suggest adding a capability ofVIRTIO_ISR_CLEAR_XXXor adding a version number.
Comments?Quoted 8 lines
I don't think we'll actually change the ISR protocol. I think it's the best that it can actually be. However, if we do need to change the ABI for some reason, I think the right thing to do is just use a new device ID (since it's effectively a new device).
Regards,
Anthony Liguori
Quoted 13 lines
Changing the devid is acceptable and much more easier then backward compatibility support, I prefer it too.
Note that there are some disadvantages when changing the devid - For example,
if you installed an old device drivers in the guest kernel and after a while you bring the guest down,
upgrade the kvm host version and bring the guest back up. If it has a new device id (and since the abi is not maintained the driver won't match VENDOR=virtio; DEVID=*),
then the guest won't have a driver for the new device.
In that case I think a guest agent can switch to fully virtualized device and afterwards install the driver automatically. This is what we do in our production environment.Hrm, I have to think about backwards compatibility at the virtio-pci layer. virtio-pci basically exposes two things, the first is an ABI for doing bidirectional notification and setting driver status. The second is a standard and transparent mechanism for
virt_rings.
Quoted 6 lines
I think that the first is simply enough that we don't need a feature mask or a version number. Maybe perhaps with the status bits, I don't know. For the
virt_rings, if we had something more sophisticated thanvirt_ringsdown the road, that can be discovered/configured in the per-device configuration area so I don't think we need feature/version info for that.
I originally had feature bits on each virtqueue for just such a reason. Used the same "ack" logic as the normal feature bits (ie. set corresponding bit to indicate guest wants to use the feature).
Probably worth engineering this in now.
Cheers,
Rusty.
-------------------------------------------------------------------------
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/
A message that is not in the archive (sent off-list or not yet received): 200711131128.44492.rusty-8n+1lVoiYb80n/[email protected]
Re: [PATCH 2/6] virtio block driver for QEMU (v2)
Quoted 55 lines · Rusty Russell
Quoted 45 lines · On Tuesday 13 November 2007 10:25:54 Anthony Liguori wrote:
Quoted 24 lines · Dor Laor
Quoted 13 lines · Anthony Liguori
Quoted 11 lines · Dor Laor
In general I think we need to add another feature or even version number ( I know you guys hate it).
The reason is - Let's say you dont change functionality but change the irq protocol (for example the isr won't be zeroed on read), then an old
guest driver wouldn't know it runs on a new host version and will have its irq line pulled up.
So I suggest adding a capability ofVIRTIO_ISR_CLEAR_XXXor adding a version number.
Comments?Quoted 9 lines
I don't think we'll actually change the ISR protocol. I think it's the best that it can actually be. However, if we do need to change the ABI for some reason, I think the right thing to do is just use a new device ID (since it's effectively a new device).
Regards,
Anthony Liguori
Quoted 14 lines
Changing the devid is acceptable and much more easier then backward compatibility support, I prefer it too.
Note that there are some disadvantages when changing the devid - For example,
if you installed an old device drivers in the guest kernel and after a while you bring the guest down,
upgrade the kvm host version and bring the guest back up. If it has a new device id (and since the abi is not maintained the driver won't match VENDOR=virtio; DEVID=*),
then the guest won't have a driver for the new device.
In that case I think a guest agent can switch to fully virtualized device and afterwards install the driver automatically. This is what we do in our production environment.Hrm, I have to think about backwards compatibility at the virtio-pci layer. virtio-pci basically exposes two things, the first is an ABI for doing bidirectional notification and setting driver status. The second is a standard and transparent mechanism for
virt_rings.Quoted 7 lines
I think that the first is simply enough that we don't need a feature mask or a version number. Maybe perhaps with the status bits, I don't know. For the
virt_rings, if we had something more sophisticated thanvirt_ringsdown the road, that can be discovered/configured in the per-device configuration area so I don't think we need feature/version info for that.
Quoted 7 lines
I originally had feature bits on each virtqueue for just such a reason. Used the same "ack" logic as the normal feature bits (ie. set corresponding bit to indicate guest wants to use the feature).
Probably worth engineering this in now.
I don't think a per-queue feature bit is worthwhile. What we need is feature bits for the ABI.
I'd start with one feature bit for the base device ABI. We can add further bits if we add new descriptor types, new queues, or newer config features The feature bits would be explicitly named and documented, instead of "I have a third virtqueue so I can use this new ABI".
Signature · 7 lines
error compiling committee.c: too many arguments to function ------------------------------------------------------------------------- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2005. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
Re: [PATCH 2/6] virtio block driver for QEMU (v2)
In reply to a message not in the archiveQuoted 3 lines · Anthony Liguori
This patch implements a very naive virtio block device backend in QEMU. There's a lot of room for future optimization. We need to merge a -disk patch before we can provide a mechanism to expose this to users.
The latest generation of -disk patches posted to upstream qemu-devel are looking quite promising & with any luck should get accepted for merge in the very near future.
Are these block & net drivers able todo hot-plug/unplug after a domain has been created ? If so we'd also want to have disk_add/disk_remove and net_add/net_remove monitor commands (cf usb_add/usb_remove) for on-the-fly changes.
Regards
Dan.
Signature · 10 lines
|=- Red Hat, Engineering, Emerging Technologies, Boston. +1 978 392 2496 -=| |=- Perl modules: http://search.cpan.org/~danberr/ -=| |=- Projects: http://freshmeat.net/~danielpb/ -=| |=- GnuPG: 7D3B9505 F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 -=| ------------------------------------------------------------------------- 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/
A message that is not in the archive (sent off-list or not yet received): [email protected]
Re: [PATCH 2/6] virtio block driver for QEMU (v2)
Quoted 7 lines · Daniel P. Berrange
Quoted 4 lines · Anthony Liguori
This patch implements a very naive virtio block device backend in QEMU. There's a lot of room for future optimization. We need to merge a -disk patch before we can provide a mechanism to expose this to users.
Quoted 9 lines
The latest generation of -disk patches posted to upstream qemu-devel are looking quite promising & with any luck should get accepted for merge in the very near future.
Are these block & net drivers able todo hot-plug/unplug after a domain has been created ? If so we'd also want to have disk_add/disk_remove and net_add/net_remove monitor commands (cf usb_add/usb_remove) for on-the-fly changes.
Some poor soul would need to add this functionality to kvm's acpi tables.
Signature · 8 lines
error compiling committee.c: too many arguments to function ------------------------------------------------------------------------- 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/
A message that is not in the archive (sent off-list or not yet received): 47386BA9.8050000-atKUWr5tajBWk0Htik3J/[email protected]
Re: [PATCH 2/6] virtio block driver for QEMU (v2)
Quoted 13 lines · Avi Kivity
Quoted 12 lines · Daniel P. Berrange
Quoted 5 lines · Anthony Liguori
This patch implements a very naive virtio block device backend in QEMU. There's a lot of room for future optimization. We need to merge a -disk patch
before we can provide a mechanism to expose this to users.The latest generation of -disk patches posted to upstream qemu-devel are looking quite promising & with any luck should get accepted for merge in the very near future.
Quoted 7 lines
Quoted 5 lines
Are these block & net drivers able todo hot-plug/unplug after a domain has been created ? If so we'd also want to have disk_add/disk_remove and net_add/net_remove monitor commands (cf usb_add/usb_remove) for on-the-fly changes.
Some poor soul would need to add this functionality to kvm's acpi tables.
I don't think there's anything I need to do in virtio-pci to support this. I would just see a ->probe() event I imagine.
Regards,
Anthony Liguori
-------------------------------------------------------------------------
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/
PATCH 3/6 9p virtio transport for QEMU (v2)
In reply to a message not in the archiveThis patch implements a very simple virtio transport for 9p in QEMU. The kernel side of this is going to change dramatically in the very near future so this is just a demonstration for the moment. It requires an external 9p file server and communicates with it over a TCP port. In future versions of this patch, we'll link directly against a 9p file server library and expose the ability to expose filesystems directly from the QEMU command line.
qemu/Makefile.target +1 -1
@@ -449,7 +449,7 @@ VL_OBJS += rtl8139.o VL_OBJS+= hypercall.o # virtio devices -VL_OBJS += virtio.o virtio-blk.o +VL_OBJS += virtio.o virtio-blk.o virtio-9p.o ifeq ($(TARGET_BASE_ARCH), i386) # Hardware support
qemu/hw/pc.c +3 -0
@@ -951,6 +951,9 @@ static void pc_init1(ram_addr_t ram_size, int vga_ram_size, int boot_device,virtio_blk_init (pci_bus,0x5002 ,0x2258 , bs); } +if (1 ) +virtio_9p_init (pci_bus,0x5002 ,0x2258 ); +if (pci_enabled) {pci_piix3_ide_init (pci_bus, bs_table, piix3_devfn +1 , i8259); }else {
qemu/hw/virtio-9p.c new file +121 -0
121 lines not on this page · raw message
qemu/vl.h +2 -0
@@ -1399,6 +1399,8 @@ typedef struct VirtIODevice VirtIODevice;VirtIODevice *virtio_blk_init (PCIBus *bus,uint16_t vendor,uint16_t device,BlockDriverState *bs); +VirtIODevice *virtio_9p_init (PCIBus *bus,uint16_t vendor,uint16_t device); +/* buf = NULL means polling */ typedef int ADBDeviceRequest (ADBDevice *d,uint8_t *buf_out,const uint8_t *buf,int len);
-------------------------------------------------------------------------
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/
PATCH 4/6 virtio network driver for QEMU (v2)
In reply to a message not in the archiveThis patch implements a very naive virtio network device backend in QEMU. Even with this simple implementation, it get's about 3x the throughput of rtl8139. Of course, there's a whole lot of room for optimization to eliminate the unnecessary copying and support more advanced features.
To use a virtio network device, simply specific '-net nic,model=virtio'
qemu/Makefile.target +1 -1
@@ -449,7 +449,7 @@ VL_OBJS += rtl8139.o VL_OBJS+= hypercall.o # virtio devices -VL_OBJS += virtio.o virtio-blk.o virtio-9p.o +VL_OBJS += virtio.o virtio-blk.o virtio-9p.o virtio-net.o ifeq ($(TARGET_BASE_ARCH), i386) # Hardware support
qemu/hw/pci.c +2 -0
@@ -588,6 +588,8 @@ void pci_nic_init(PCIBus *bus, NICInfo *nd, int devfn)pci_rtl8139_init (bus, nd, devfn); }else if (strcmp (nd->model,"pcnet" ) ==0 ) {pci_pcnet_init (bus, nd, devfn); + }else if (strcmp (nd->model,"virtio" ) ==0 ) { +virtio_net_init (bus,0x5002 ,0x2258 , nd, devfn); }else if (strcmp (nd->model,"?" ) ==0 ) {fprintf (stderr,"qemu: Supported PCI NICs: i82551 i82557b i82559er" " ne2k_pci pcnet rtl8139\n" );
qemu/hw/virtio-net.c new file +175 -0
175 lines not on this page · raw message
qemu/vl.h +3 -0
@@ -1401,6 +1401,9 @@ VirtIODevice *virtio_blk_init(PCIBus *bus, uint16_t vendor, uint16_t device,VirtIODevice *virtio_9p_init (PCIBus *bus,uint16_t vendor,uint16_t device); +VirtIODevice *virtio_net_init (PCIBus *bus,uint16_t vendor,uint16_t device, +NICInfo *nd,int devfn); +/* buf = NULL means polling */ typedef int ADBDeviceRequest (ADBDevice *d,uint8_t *buf_out,const uint8_t *buf,int len);
-------------------------------------------------------------------------
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/
A message that is not in the archive (sent off-list or not yet received): 11947512454030-git-send-email-aliguori-r/[email protected]
Re: [PATCH 4/6] virtio network driver for QEMU (v2)
Quoted 9 lines · Anthony Liguori
This patch implements a very naive virtio network device backend in QEMU. Even with this simple implementation, it get's about 3x the throughput of rtl8139. Of course, there's a whole lot of room for optimization to eliminate the unnecessary copying and support more advanced features.
To use a virtio network device, simply specific '-net nic,model=virtio'
Signed-off-by Anthony Liguori <aliguori-r/[email protected]>
[snip]
Quoted 12 lines
qemu/hw/virtio-net.c new file +11
-0+/* TX */ +static void virtio_net_handle_tx (VirtIODevice *vdev,VirtQueue *vq) +{ +VirtIONet *n =to_virtio_net (vdev); +VirtQueueElement elem; + +while (virtqueue_pop (vq, &elem)) { +int i; +size_t len =0 ; + +/* ignore the header for now */
qemu/hw/virtio-net.c line 154
Quoted 10 lines
qemu/hw/virtio-net.c new file +10
-0+for (i =1 ; i < elem.out_num; i++) { +qemu_send_packet (n->vc, elem.out_sg[i].iov_base, + elem.out_sg[i].iov_len); + len += elem.out_sg[i].iov_len; + } + +virtqueue_push (vq, &elem,sizeof (struct virtio_net_hdr ) + len); +virtio_notify (&n->vdev, vq); + } +}
Get the notify out of the while please.
Regardless of above, at the moment you copy the receive packets into virtio sg's.
I had a did an incomplete job of adding vectored read to qemu. What's your opinion about it? Maybe using qemu's pending dma functions? Regards & cheers,
Dor.
Quoted 28 lines
qemu/hw/virtio-net.c new file +21
-0+ +VirtIODevice *virtio_net_init (PCIBus *bus,uint16_t vendor,uint16_t device, +NICInfo *nd,int devfn) +{ +VirtIONet *n; + + n = (VirtIONet *)virtio_init_pci (bus,"virtio-net" , vendor, device, + vendor,VIRTIO_ID_NET , +6 ,sizeof (VirtIONet)); + + n->vdev.update_config = virtio_net_update_config; + n->vdev.get_features = virtio_net_get_features; + n->rx_vq =virtio_add_queue (&n->vdev, virtio_net_handle_rx); + n->tx_vq =virtio_add_queue (&n->vdev, virtio_net_handle_tx); + n->can_receive =0 ; +memcpy (n->mac, nd->macaddr,6 ); + n->vc =qemu_new_vlan_client (nd->vlan, virtio_net_receive, + virtio_net_can_receive, n); + +return &n->vdev; +}qemu/vl.h +0
-0
qemu/vl.h VirtIODevice *virtio_blk_init(PCIBus *bus, uint16_t vendor, uint16_t device, · line 1409
Quoted 9 lines
qemu/vl.h +3
-0@@ -1401,6 +1401,9 @@ VirtIODevice *virtio_blk_init(PCIBus *bus, uint16_t vendor, uint16_t device,VirtIODevice *virtio_9p_init (PCIBus *bus,uint16_t vendor,uint16_t device); +VirtIODevice *virtio_net_init (PCIBus *bus,uint16_t vendor,uint16_t device, +NICInfo *nd,int devfn); +/* buf = NULL means polling */ typedef int ADBDeviceRequest (ADBDevice *d,uint8_t *buf_out,const uint8_t *buf,int len);
-------------------------------------------------------------------------
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/
A message that is not in the archive (sent off-list or not yet received): 47373C6B.7090102-atKUWr5tajBWk0Htik3J/[email protected]
Re: [PATCH 4/6] virtio network driver for QEMU (v2)
Quoted 39 lines · Dor Laor
Quoted 12 lines · Anthony Liguori
This patch implements a very naive virtio network device backend in QEMU.
Even with this simple implementation, it get's about 3x the throughput of
rtl8139. Of course, there's a whole lot of room for optimization to eliminate
the unnecessary copying and support more advanced features.To use a virtio network device, simply specific '-net nic,model=virtio'
Signed-off-by Anthony Liguori <aliguori-r/[email protected]>[snip]
Quoted 12 lines
qemu/hw/virtio-net.c new file +11
-0+/* TX */ +static void virtio_net_handle_tx (VirtIODevice *vdev,VirtQueue *vq) +{ +VirtIONet *n =to_virtio_net (vdev); +VirtQueueElement elem; + +while (virtqueue_pop (vq, &elem)) { +int i; +size_t len =0 ; + +/* ignore the header for now */ qemu/hw/virtio-net.c line 154
Quoted 10 lines
qemu/hw/virtio-net.c new file +10
-0+for (i =1 ; i < elem.out_num; i++) { +qemu_send_packet (n->vc, elem.out_sg[i].iov_base, + elem.out_sg[i].iov_len); + len += elem.out_sg[i].iov_len; + } + +virtqueue_push (vq, &elem,sizeof (struct virtio_net_hdr ) + len); +virtio_notify (&n->vdev, vq); + } +}Get the notify out of the while please.
Quoted 4 lines
Regardless of above, at the moment you copy the receive packets into virtio sg's.
I had a did an incomplete job of adding vectored read to qemu. What's your opinion about it? Maybe using qemu's pending dma functions?
I did a quick hack where I had direct access to the tun's fd so that I could readv/writev directly. It didn't seem to help all that much but I'm not too surprised by that, it's was still synchronous.
The dma API is definitely a step in the right direction. The way I'm approaching optimization is to first hack things up so that my particular case works, and then figure out how to fit it in within the rest of QEMU.
For instance, I'm playing around right now with having the block driver open a file directly, and using the most recent linux-aio routines. It apparently now supports but fd notification (through eventfd) and
asynchronous fdsync support (for barriers). I think we should be able
to get very good performance with this. Once I get promising performance results, I'll figure out how to work it into the existing block API.
Regards,
Anthony Liguori
Quoted 34 lines
Regards & cheers,
Dor.Quoted 32 lines
(quoted diff) +2
-0+ +VirtIODevice *virtio_net_init(PCIBus *bus, uint16_t vendor, uint16_tdevice,
qemu/hw/virtio-net.c new file +19
-0+ NICInfo *nd, int devfn) +{ +VirtIONet *n; + + n = (VirtIONet *)virtio_init_pci (bus,"virtio-net" , vendor, device, + vendor,VIRTIO_ID_NET , +6 ,sizeof (VirtIONet)); + + n->vdev.update_config = virtio_net_update_config; + n->vdev.get_features = virtio_net_get_features; + n->rx_vq =virtio_add_queue (&n->vdev, virtio_net_handle_rx); + n->tx_vq =virtio_add_queue (&n->vdev, virtio_net_handle_tx); + n->can_receive =0 ; +memcpy (n->mac, nd->macaddr,6 ); + n->vc =qemu_new_vlan_client (nd->vlan, virtio_net_receive, + virtio_net_can_receive, n); + +return &n->vdev; +}qemu/vl.h +0
-0@@ -1401,6 +1401,9 @@ VirtIODevice *virtio_blk_init(PCIBus *bus, uint16_t vendor, uint16_t device, VirtIODevice *virtio_9p_init(PCIBus *bus, uint16_t vendor, uint16_t device);
Quoted 10 lines
Quoted 9 lines
qemu/vl.h +3
-0+VirtIODevice *virtio_net_init (PCIBus *bus,uint16_t vendor,uint16_t device, +NICInfo *nd,int devfn); +/* buf = NULL means polling */
typedef int ADBDeviceRequest(ADBDevice *d,uint8_t*buf_out,const uint8_t *buf, int len);
-------------------------------------------------------------------------
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/
PATCH 5/6 Remove hypercall driver (v2)
In reply to a message not in the archiveI don't think there's any plans for this driver to every be used seriously as virtio seems like the agreed upon layer. So let's remove the code from the tree so I can use the drivers/ directory for something else.
drivers/Kbuild deleted +0 -3
@@ -1,3 +0,0 @@ -EXTRA_CFLAGS := -I$(src)/../ -obj-m := hypercall.o -#hypercall-objs := hypercall.o
drivers/Makefile deleted +0 -21
@@ -1,21 +0,0 @@ -include ../config.mak -KERNELDIR ?= /lib/modules/$(shell uname -r)/build -KVERREL = $(patsubst /lib/modules/%/build,%,$(KERNELDIR)) - -DESTDIR= - -INSTALLDIR = $(patsubst %/build,%/extra,$(KERNELDIR)) - -all:: - $(MAKE) -C $(KERNELDIR) M=`pwd` "$$@" - -install: - mkdir -p $(DESTDIR)/$(INSTALLDIR) - cp *.ko $(DESTDIR)/$(INSTALLDIR) - /sbin/depmod -a - -clean: - $(MAKE) -C $(KERNELDIR) M=`pwd` $@ - -svnclean: - svn st | grep '^\?' | awk '{print $2}' | xargs rm -rf
drivers/hypercall.c deleted +0 -497
497 lines not on this page · raw message
-------------------------------------------------------------------------
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/
A message that is not in the archive (sent off-list or not yet received): 1194751246584-git-send-email-aliguori-r/[email protected]
Re: [PATCH 5/6] Remove hypercall driver (v2)
Quoted 5 lines · Anthony Liguori
I don't think there's any plans for this driver to every be used seriously as virtio seems like the agreed upon layer. So let's remove the code from the tree so I can use the
drivers/directory for something else.
There's also some vmchannel cmdline parameter that can be erased.
Quoted 533 lines
Signed-off-by Anthony Liguori <aliguori-r/[email protected]>drivers/Kbuild deleted +0
-3@@ -1,3 +0,0 @@ -EXTRA_CFLAGS := -I$(src)/../ -obj-m := hypercall.o -#hypercall-objs := hypercall.odrivers/Makefile deleted +0
-21@@ -1,21 +0,0 @@ -include ../config.mak -KERNELDIR ?= /lib/modules/$(shell uname -r)/build -KVERREL = $(patsubst /lib/modules/%/build,%,$(KERNELDIR)) - -DESTDIR= - -INSTALLDIR = $(patsubst %/build,%/extra,$(KERNELDIR)) - -all:: - $(MAKE) -C $(KERNELDIR) M=`pwd` "$$@" - -install: - mkdir -p $(DESTDIR)/$(INSTALLDIR) - cp *.ko $(DESTDIR)/$(INSTALLDIR) - /sbin/depmod -a - -clean: - $(MAKE) -C $(KERNELDIR) M=`pwd` $@ - -svnclean: - svn st | grep '^\?' | awk '{print $2}' | xargs rm -rfdrivers/hypercall.c deleted +0
-487@@ -1,497 +0,0 @@ - -#include <linux/module.h> -#include <linux/kernel.h> -#include <linux/compiler.h> -#include <linux/pci.h> -#include <linux/init.h> -#include <linux/ioport.h> -#include <linux/completion.h> -#include <linux/interrupt.h> -#include <asm/io.h> -#include <asm/uaccess.h> -#include <asm/irq.h> - -#define HYPERCALL_DRIVER_NAME "Qumranet_hypercall_driver" -#define HYPERCALL_DRIVER_VERSION "1" -#define PCI_VENDOR_ID_HYPERCALL 0x5002 -#define PCI_DEVICE_ID_HYPERCALL 0x2258 - -MODULE_AUTHOR ("Dor Laor <dor.laor-atKUWr5tajBWk0Htik3J/[email protected]>" ); -MODULE_DESCRIPTION (HYPERCALL_DRIVER_NAME ); -MODULE_LICENSE ("GPL" ); -MODULE_VERSION (HYPERCALL_DRIVER_VERSION ); - -static int debug =0 ; -module_param (debug, int,0 ); -MODULE_PARM_DESC (debug,"toggle debug flag" ); - -#define HYPERCALL_DEBUG 1 -#if HYPERCALL_DEBUG -# define DPRINTK(fmt, args...) printk(KERN_DEBUG "%s: " fmt, __FUNCTION__ , ## args) -# define assert (expr) \ - if(unlikely(!(expr))) { \ - printk(KERN_ERR "Assertion failed! %s,%s,%s,line=%d\n", \ - #expr,__FILE__,__FUNCTION__,__LINE__); \ - } -#else -# define DPRINTK(fmt, args...) -# define assert (expr) do {} while (0) -#endif - -static struct pci_device_id hypercall_pci_tbl[] = { - {PCI_VENDOR_ID_HYPERCALL ,PCI_DEVICE_ID_HYPERCALL ,PCI_ANY_ID ,PCI_ANY_ID ,0 ,0 ,0 }, - {0 ,} -}; -MODULE_DEVICE_TABLE (pci, hypercall_pci_tbl); - - - -/****** Hypercall device definitions ***************/ -#include <qemu/hw/hypercall.h> - -/* read PIO/MMIO register */ -#define HIO_READ8 (reg, ioaddr) ioread8(ioaddr + (reg)) -#define HIO_READ16 (reg, ioaddr) ioread16(ioaddr + (reg)) -#define HIO_READ32 (reg, ioaddr) ioread32(ioaddr + (reg)) - -/* write PIO/MMIO register */ -#define HIO_WRITE8 (reg, val8, ioaddr) iowrite8((val8), ioaddr + (reg)) -#define HIO_WRITE16 (reg, val16, ioaddr) iowrite16((val16), ioaddr + (reg)) -#define HIO_WRITE32 (reg, val32, ioaddr) iowrite32((val32), ioaddr + (reg)) - - -struct hypercall_dev { -struct pci_dev *pci_dev; -struct kobject kobject; -u32 state; -spinlock_t lock; -u8 name[128 ]; -u16 irq; -u32 regs_len; -void __iomem *io_addr; -unsigned long base_addr;/* device I/O address */ -unsigned long cmd; -}; - - -static int hypercall_close (struct hypercall_dev * dev); -static int hypercall_open (struct hypercall_dev *dev); -static void hypercall_cleanup_dev (struct hypercall_dev *dev); -static irqreturn_t hypercall_interrupt (int irq,void *dev_instance, -struct pt_regs *regs); - -static void __exit hypercall_sysfs_remove(struct hypercall_dev *dev); -static int hypercall_sysfs_add (struct hypercall_dev *dev); - - -static int __devinit hypercall_init_board (struct pci_dev *pdev, -struct hypercall_dev **dev_out) -{ -unsigned long ioaddr; -struct hypercall_dev *dev; -int rc; -u32 disable_dev_on_err =0 ; -unsigned long pio_start, pio_end, pio_flags, pio_len; -unsigned long mmio_start, mmio_end, mmio_flags, mmio_len; - -assert (pdev !=NULL ); - - *dev_out =NULL ; - - dev =kzalloc (sizeof (*dev),GFP_KERNEL ); -if (dev ==NULL ) { -printk (KERN_ERR "%s: Unable to alloc hypercall device\n" ,pci_name (pdev)); -return -ENOMEM ; - } - dev->pci_dev = pdev; - rc =pci_enable_device (pdev); -if (rc) - goto err_out; - disable_dev_on_err =1 ; - - pio_start =pci_resource_start (pdev,0 ); - pio_end =pci_resource_end (pdev,0 ); - pio_flags =pci_resource_flags (pdev,0 ); - pio_len =pci_resource_len (pdev,0 ); - - mmio_start =pci_resource_start (pdev,1 ); - mmio_end =pci_resource_end (pdev,1 ); - mmio_flags =pci_resource_flags (pdev,1 ); - mmio_len =pci_resource_len (pdev,1 ); - -DPRINTK ("PIO region size == 0x%02lX\n" , pio_len); -DPRINTK ("MMIO region size == 0x%02lX\n" , mmio_len); - - rc =pci_request_regions (pdev,"hypercall" ); -if (rc) - goto err_out; - -#define USE_IO_OPS 1 -#ifdef USE_IO_OPS - ioaddr = (unsigned long )pci_iomap (pdev,0 ,0 ); -//ioaddr = ioport_map(pio_start, pio_len); -if (!ioaddr) { -printk (KERN_ERR "%s: cannot map PIO, aborting\n" ,pci_name (pdev)); - rc = -EIO ; - goto err_out; - } - dev->base_addr = (unsigned long )pio_start; - dev->io_addr = (void *)ioaddr; - dev->regs_len = pio_len; -#else - ioaddr =pci_iomap (pdev,1 ,0 ); -if (ioaddr ==NULL ) { -printk (KERN_ERR "%s: cannot remap MMIO, aborting\n" ,pci_name (pdev)); - rc = -EIO ; - goto err_out; - } - dev->base_addr = ioaddr; - dev->io_addr = (void *)ioaddr; - dev->regs_len = mmio_len; -#endif /* USE_IO_OPS */ - - *dev_out = dev; -return 0 ; - -err_out: -hypercall_cleanup_dev (dev); -if (disable_dev_on_err) -pci_disable_device (pdev); -return rc; -} - -static int __devinit hypercall_init_one (struct pci_dev *pdev, -const struct pci_device_id *ent) -{ -struct hypercall_dev *dev; -u8 pci_rev; - -assert (pdev !=NULL ); -assert (ent !=NULL ); - -pci_read_config_byte (pdev,PCI_REVISION_ID , &pci_rev); - -if (pdev->vendor ==PCI_VENDOR_ID_HYPERCALL && - pdev->device ==PCI_DEVICE_ID_HYPERCALL ) { -printk (KERN_INFO "pci dev %s (id %04x:%04x rev %02x) is a guest hypercall device\n" , -pci_name (pdev), pdev->vendor, pdev->device, pci_rev); - } - -if (hypercall_init_board (pdev, &dev) !=0 ) -return -1 ; - -assert (dev !=NULL ); - - dev->irq = pdev->irq; - -spin_lock_init (&dev->lock); -pci_set_drvdata (pdev, dev); - -printk (KERN_INFO "name=%s: base_addr=0x%lx, io_addr=0x%lx, IRQ=%d\n" , - dev->name, dev->base_addr, (unsigned long )dev->io_addr, dev->irq); -hypercall_open (dev); - -if (hypercall_sysfs_add (dev) !=0 ) -return -1 ; - -return 0 ; -} - -static void __devexit hypercall_remove_one(struct pci_dev *pdev) -{ -struct hypercall_dev *dev =pci_get_drvdata (pdev); - -assert (dev !=NULL ); - -hypercall_close (dev); -hypercall_sysfs_remove (dev); -hypercall_cleanup_dev (dev); -pci_disable_device (pdev); -} - -static int hypercall_tx (struct hypercall_dev *dev,unsigned char *buf,size_t len) -{ -void __iomem *ioaddr = (void __iomem *)dev->io_addr; -int i; - -if (len >HP_MEM_SIZE ) -return -EINVAL ; - -spin_lock (&dev->lock); -HIO_WRITE8 (HP_TXSIZE , len, ioaddr); -for (i=0 ; i< len; i++) -HIO_WRITE8 (HP_TXBUFF , buf[i], ioaddr); -spin_unlock (&dev->lock); - -return 0 ; -} - -/* -* The interrupt handler does all of the rx work and cleans up -* after the tx -*/ -static irqreturn_t hypercall_interrupt (int irq,void *dev_instance, -struct pt_regs *regs) -{ -struct hypercall_dev *dev = (struct hypercall_dev *)dev_instance; -void __iomem *ioaddr = (void __iomem *)dev->io_addr; -u32 status; -int irq_handled =IRQ_NONE ; -int rx_buf_size; -int i; -u8 buffer[HP_MEM_SIZE ]; -u8 *pbuf; - -DPRINTK ("base addr is 0x%lx, io_addr=0x%lx\n" , dev->base_addr, (long )dev->io_addr); - -spin_lock (&dev->lock); - status =HIO_READ8 (HSR_REGISTER , ioaddr); -DPRINTK ("irq status is 0x%x\n" , status); - -/* shared irq? */ -if (unlikely ((status &HSR_VDR ) ==0 )) { -DPRINTK ("not handeling irq, not ours\n" ); - goto out; - } - -/* Disable device interrupts */ -HIO_WRITE8 (HCR_REGISTER ,HCR_DI , ioaddr); -DPRINTK ("disable device interrupts\n" ); - - rx_buf_size =HIO_READ8 (HP_RXSIZE , ioaddr); -DPRINTK ("Rx buffer size is %d\n" , rx_buf_size); - -if (rx_buf_size >HP_MEM_SIZE ) - rx_buf_size =HP_MEM_SIZE ; - -for (i=0 , pbuf=buffer; i<rx_buf_size; i++, pbuf++) { - *pbuf =HIO_READ8 (HP_RXBUFF , ioaddr + i); -DPRINTK ("Read 0x%x as dword %d\n" , *pbuf, i); - } - *pbuf ='\0' ; -DPRINTK ("Read buffer %s" , (char *)buffer); - -HIO_WRITE8 (HCR_REGISTER ,HCR_EI , ioaddr); -DPRINTK ("Enable interrupt\n" ); - irq_handled =IRQ_HANDLED ; - out: -spin_unlock (&dev->lock); - - -hypercall_tx (dev,"hello host" ,sizeof ("hello host" )); -return irq_handled; -} - - -static int hypercall_open (struct hypercall_dev *dev) -{ -int rc; - - rc =request_irq (dev->irq, &hypercall_interrupt, -SA_SHIRQ , dev->name, dev); -if (rc) { -printk (KERN_ERR "%s failed to request an irq\n" , __FUNCTION__); -return rc; - } - -//hypercall_thread_start(dev); - -return 0 ; -} - -static int hypercall_close (struct hypercall_dev * dev) -{ -//hypercall_thread_stop(dev); -synchronize_irq (dev->irq); -free_irq (dev->irq, dev); - -return 0 ; -} - -#ifdef CONFIG_PM - -static int hypercall_suspend (struct pci_dev *pdev,pm_message_t state) -{ -pci_save_state (pdev); -pci_set_power_state (pdev, PCI_D3hot); -DPRINTK ("Power mgmt suspend, set power state to PCI_D3hot\n" ); - -return 0 ; -} - -static int hypercall_resume (struct pci_dev *pdev) -{ -pci_restore_state (pdev); -pci_set_power_state (pdev,PCI_D0 ); -DPRINTK ("Power mgmt resume, set power state to PCI_D0\n" ); - -return 0 ; -} - -#endif /* CONFIG_PM */ - -static void hypercall_cleanup_dev (struct hypercall_dev *dev) -{ -DPRINTK ("cleaning up\n" ); -pci_release_regions (dev->pci_dev); -pci_iounmap (dev->pci_dev, (void *)dev->io_addr); -pci_set_drvdata (dev->pci_dev,NULL ); -kfree (dev); -} - -static struct pci_driver hypercall_pci_driver = { - .name =HYPERCALL_DRIVER_NAME , - .id_table = hypercall_pci_tbl, - .probe = hypercall_init_one, - .remove =__devexit_p (hypercall_remove_one), -#ifdef CONFIG_PM - .suspend = hypercall_suspend, - .resume = hypercall_resume, -#endif /* CONFIG_PM */ -}; - -static int __init hypercall_init_module (void ) -{ - printk (KERN_INFO HYPERCALL_DRIVER_NAME "\n"); - return pci_module_init(&hypercall_pci_driver); -} - -static void __exit hypercall_cleanup_module(void) -{ -pci_unregister_driver (&hypercall_pci_driver); -} - -/* -* sysfs support -*/ - -struct hypercall_attribute { -struct attribute attr; -ssize_t (*show)(struct hypercall_dev *,char *buf); -ssize_t (*store)(struct hypercall_dev *,unsigned long val); -}; - -static ssize_t hypercall_attribute_show (struct kobject *kobj, -struct attribute *attr,char *buf) -{ -struct hypercall_attribute *hypercall_attr; -struct hypercall_dev *hdev; - - hypercall_attr = container_of(attr, struct hypercall_attribute, attr); - hdev = container_of(kobj, struct hypercall_dev, kobject); - -if (!hypercall_attr->show) -return -EIO ; - -return hypercall_attr->show (hdev, buf); -} - -static ssize_t hypercall_attribute_store (struct kobject *kobj, -struct attribute *attr,const char *buf,size_t count) -{ -struct hypercall_attribute *hypercall_attr; -struct hypercall_dev *hdev; -char *endp; -unsigned long val; -int rc; - - val =simple_strtoul (buf, &endp,0 ); - - hypercall_attr = container_of(attr, struct hypercall_attribute, attr); - hdev = container_of(kobj, struct hypercall_dev, kobject); - -if (!hypercall_attr->store) -return -EIO ; - - rc = hypercall_attr->store (hdev, val); -if (!rc) - rc = count; -return rc; -} - -#define MAKE_HYPERCALL_R_ATTR (_name) \ -static ssize_t _name##_show(struct hypercall_dev *hdev, char *buf) \ -{ \ - return sprintf(buf, "%lu\n", (unsigned long)hdev->_name); \ -} \ -struct hypercall_attribute hypercall_attr_##_name = __ATTR_RO(_name) - -#define MAKE_HYPERCALL_WR_ATTR (_name) \ -static int _name##_store(struct hypercall_dev *hdev, unsigned long val) \ -{ \ - hdev->_name = (typeof(hdev->_name))val; \ - return 0; \ -} \ -static ssize_t _name##_show(struct hypercall_dev *hdev, char *buf) \ -{ \ - return sprintf(buf, "%lu\n", (unsigned long)hdev->_name); \ -} \ -struct hypercall_attribute hypercall_attr_##_name = \ - __ATTR(_name,S_IRUGO|S_IWUGO,_name##_show,_name##_store) - -MAKE_HYPERCALL_R_ATTR (base_addr); -MAKE_HYPERCALL_R_ATTR (irq); -MAKE_HYPERCALL_WR_ATTR (cmd); - -#define GET_HYPERCALL_ATTR (_name) (&hypercall_attr_##_name.attr) - -static struct attribute *hypercall_default_attrs[] = { -GET_HYPERCALL_ATTR (base_addr), -GET_HYPERCALL_ATTR (irq), -GET_HYPERCALL_ATTR (cmd), -NULL -}; - -static struct sysfs_ops hypercall_sysfs_ops = { - .show = hypercall_attribute_show, - .store = hypercall_attribute_store, -}; - -static void hypercall_sysfs_release (struct kobject *kobj) -{ -DPRINTK (" called for obj name %s\n" , kobj->name); -} - -static struct kobj_type hypercall_ktype = { - .release = hypercall_sysfs_release, - .sysfs_ops = &hypercall_sysfs_ops, - .default_attrs = hypercall_default_attrs -}; - - -static int hypercall_sysfs_add (struct hypercall_dev *dev) -{ -int rc; - -kobject_init (&dev->kobject); - dev->kobject.ktype = &hypercall_ktype; - rc =kobject_set_name (&dev->kobject,"%s" ,HYPERCALL_DRIVER_NAME ); -if (rc !=0 ) { -printk ("%s: kobject_set_name failed, err=%d\n" , __FUNCTION__, rc); -return rc; - } - - rc =kobject_add (&dev->kobject); -if (rc !=0 ) { -printk ("%s: kobject_add failed, err=%d\n" , __FUNCTION__, rc); -return rc; - } - - rc =sysfs_create_link (&dev->pci_dev->dev.kobj, &dev->kobject, -HYPERCALL_DRIVER_NAME ); -if (rc !=0 ) { -printk ("%s: sysfs_create_link failed, err=%d\n" , __FUNCTION__, rc); -kobject_del (&dev->kobject); - } - -return rc;
drivers/hypercall.c line 497
Quoted 10 lines
drivers/hypercall.c deleted +0
-10-} - -static void hypercall_sysfs_remove (struct hypercall_dev *dev) -{ -sysfs_remove_link (&dev->pci_dev->dev.kobj,HYPERCALL_DRIVER_NAME ); -kobject_del (&dev->kobject); -} - -module_init (hypercall_init_module); -module_exit (hypercall_cleanup_module);
-------------------------------------------------------------------------
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/
Avi Kivity
AppliedRe: [PATCH 5/6] Remove hypercall driver (v2)
In reply to a message not in the archiveQuoted 5 lines · Anthony Liguori
I don't think there's any plans for this driver to every be used seriously as virtio seems like the agreed upon layer. So let's remove the code from the tree so I can use the
drivers/directory for something else.
Applied, thanks.
Signature · 7 lines
error compiling committee.c: too many arguments to function ------------------------------------------------------------------------- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2005. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
PATCH 6/6 Provide a mechanism to build virtio drivers as modules (v2)
In reply to a message not in the archiveThis provides a make sync within the drivers/ directory to allow virtio drivers to be built as third-party modules much as we do with the KVM driver.
.gitignore +8 -1
@@ -26,4 +26,11 @@ kernel/x86_emulate.[ch] kernel/include/linux/kvm*.h kernel/Module.symvers kernel/Modules.symvers -kernel/.tmp_versions +kernel/.tmp_versions +drivers/config.c +drivers/virtio.c +drivers/virtio_ring.c +drivers/virtio_pci.c +drivers/virtio_blk.c +drivers/virtio_net.c +drivers/include/linux/virtio*.h
Makefile +1 -1
@@ -68,7 +68,7 @@ srpm: $(RM) $(tmpspec) clean: - for i in $(if $(WANT_MODULE), kernel) user libkvm qemu; do \ + for i in $(if $(WANT_MODULE), kernel drivers) user libkvm qemu; do \ make -C $$i clean; \ done rm -f config.mak user/config.mak
drivers/Kbuild new file +2 -0
@@ -0,0 +1,2 @@ +EXTRA_CFLAGS := -I$(src)/include -include $(src)/external-module-compat.h +obj-m := virtio.o virtio_ring.o virtio_pci.o virtio_net.o virtio_blk.o
drivers/Makefile new file +23 -0
@@ -0,0 +1,23 @@ +include ../config.mak + +KVERREL = $(patsubst /lib/modules/%/build,%,$(KERNELDIR)) + +DESTDIR= + +INSTALLDIR = $(patsubst %/build,%/extra,$(KERNELDIR)) +ORIGMODDIR = $(patsubst %/build,%/kernel,$(KERNELDIR)) + +LINUX = ../linux-2.6 + +all:: + $(MAKE) -C $(KERNELDIR) M=`pwd` "$$@" + +sync: + mkdir -p include/linux + rsync --exclude='*.mod.c' "$(LINUX)"/drivers/virtio/*.[ch] . + rsync "$(LINUX)"/include/linux/virtio*.h include/linux + rsync "$(LINUX)"/drivers/block/virtio_blk.c . + rsync "$(LINUX)"/drivers/net/virtio_net.c . + +clean: + $(MAKE) -C $(KERNELDIR) M=`pwd` $@
drivers/external-module-compat.h new file +14 -0
@@ -0,0 +1,14 @@ +#ifndef _VIRTIO_EXT_MOD_COMPAT_H +#define _VIRTIO_EXT_MOD_COMPAT_H + +/* make sure out copies of the headers get included */ + +#include "include/linux/virtio.h" +#include "include/linux/virtio_config.h" +#include "include/linux/virtio_ring.h" +#include "include/linux/virtio_pci.h" +#include "include/linux/virtio_blk.h" +#include "include/linux/virtio_net.h" +#include "include/linux/virtio_9p.h" + +#endif
-------------------------------------------------------------------------
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/
A message that is not in the archive (sent off-list or not yet received): 11947512473786-git-send-email-aliguori-r/[email protected]
Re: [PATCH 6/6] Provide a mechanism to build virtio drivers as modules (v2)
Quoted 4 lines · Anthony Liguori
This provides a make sync within the
drivers/directory to allow virtio drivers to be built as third-party modules much as we do with the KVM driver.
We will want to ship and build guest drivers as a separate package (that's not to say that this patch is wrong; but the drivers package will need its own configure/make/install thing).
Signature · 7 lines
error compiling committee.c: too many arguments to function ------------------------------------------------------------------------- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2005. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/