diff mbox

[2/3] kvm tools: Use virt_queue__trigger_irq() to trigger IRQ for virtio blk

Message ID 1304820847-13125-2-git-send-email-asias.hejun@gmail.com (mailing list archive)
State New, archived
Headers show

Commit Message

Asias He May 8, 2011, 2:14 a.m. UTC
This patch uses IRQ injection mechanism introduced by
virt_queue__trigger_irq() which respect virtio IRQ status
and VRING_AVAIL_F_NO_INTERRUPT.

Signed-off-by: Asias He <asias.hejun@gmail.com>
---
 tools/kvm/virtio/blk.c |    8 +++++---
 1 files changed, 5 insertions(+), 3 deletions(-)
diff mbox

Patch

diff --git a/tools/kvm/virtio/blk.c b/tools/kvm/virtio/blk.c
index cc3dc78..12c7029 100644
--- a/tools/kvm/virtio/blk.c
+++ b/tools/kvm/virtio/blk.c
@@ -38,6 +38,7 @@  struct blk_dev {
 	u32				guest_features;
 	u16				config_vector;
 	u8				status;
+	u8				isr;
 	u8				idx;
 
 	/* virtio queue */
@@ -102,8 +103,9 @@  static bool virtio_blk_pci_io_in(struct kvm *self, u16 port, void *data, int siz
 		ioport__write8(data, bdev->status);
 		break;
 	case VIRTIO_PCI_ISR:
-		ioport__write8(data, 0x1);
-		kvm__irq_line(self, bdev->pci_hdr.irq_line, 0);
+		ioport__write8(data, bdev->isr);
+		kvm__irq_line(self, bdev->pci_hdr.irq_line, VIRTIO_IRQ_LOW);
+		bdev->isr = VIRTIO_IRQ_LOW;
 		break;
 	case VIRTIO_MSI_CONFIG_VECTOR:
 		ioport__write16(data, bdev->config_vector);
@@ -167,7 +169,7 @@  static void virtio_blk_do_io(struct kvm *kvm, void *param)
 	while (virt_queue__available(vq))
 		virtio_blk_do_io_request(kvm, bdev, vq);
 
-	kvm__irq_line(kvm, bdev->pci_hdr.irq_line, 1);
+	virt_queue__trigger_irq(vq, bdev->pci_hdr.irq_line, &bdev->isr, kvm);
 }
 
 static bool virtio_blk_pci_io_out(struct kvm *self, u16 port, void *data, int size, u32 count)