* [PATCH 1/2] kvm tools: Move ioeventfd registration to virtio-pci
@ 2011-08-24 9:09 Sasha Levin
2011-08-24 9:09 ` [PATCH 2/2] kvm tools: Seperate pci layer out of virtio-console Sasha Levin
0 siblings, 1 reply; 2+ messages in thread
From: Sasha Levin @ 2011-08-24 9:09 UTC (permalink / raw)
To: penberg; +Cc: kvm, mingo, asias.hejun, gorcunov, Sasha Levin
This patch removed ioeventfd registration from devices and moves it
to a single place in virtio-pci layer.
Signed-off-by: Sasha Levin <levinsasha928@gmail.com>
---
tools/kvm/include/kvm/virtio-pci.h | 6 ++++++
tools/kvm/virtio/9p.c | 21 ---------------------
tools/kvm/virtio/balloon.c | 20 +-------------------
tools/kvm/virtio/blk.c | 21 ---------------------
tools/kvm/virtio/net.c | 19 -------------------
tools/kvm/virtio/pci.c | 33 +++++++++++++++++++++++++++++++++
tools/kvm/virtio/rng.c | 15 ---------------
7 files changed, 40 insertions(+), 95 deletions(-)
diff --git a/tools/kvm/include/kvm/virtio-pci.h b/tools/kvm/include/kvm/virtio-pci.h
index 0c2a035..ce44e84 100644
--- a/tools/kvm/include/kvm/virtio-pci.h
+++ b/tools/kvm/include/kvm/virtio-pci.h
@@ -22,6 +22,11 @@ struct virtio_pci_ops {
int (*get_size_vq)(struct kvm *kvm, void *dev, u32 vq);
};
+struct virtio_pci_ioevent_param {
+ struct virtio_pci *vpci;
+ u32 vq;
+};
+
struct virtio_pci {
struct pci_device_header pci_hdr;
struct virtio_pci_ops ops;
@@ -43,6 +48,7 @@ struct virtio_pci {
/* virtio queue */
u16 queue_selector;
+ struct virtio_pci_ioevent_param ioeventfds[VIRTIO_PCI_MAX_VQ];
};
int virtio_pci__init(struct kvm *kvm, struct virtio_pci *vpci, void *dev,
diff --git a/tools/kvm/virtio/9p.c b/tools/kvm/virtio/9p.c
index 1682e64..0dffc7a 100644
--- a/tools/kvm/virtio/9p.c
+++ b/tools/kvm/virtio/9p.c
@@ -2,7 +2,6 @@
#include "kvm/ioport.h"
#include "kvm/util.h"
#include "kvm/threadpool.h"
-#include "kvm/ioeventfd.h"
#include "kvm/irq.h"
#include "kvm/virtio-9p.h"
#include "kvm/guest_compat.h"
@@ -1116,13 +1115,6 @@ static void virtio_p9_do_io(struct kvm *kvm, void *param)
}
}
-static void ioevent_callback(struct kvm *kvm, void *param)
-{
- struct p9_dev_job *job = param;
-
- thread_pool__do_job(&job->job_id);
-}
-
static void set_config(struct kvm *kvm, void *dev, u8 data, u32 offset)
{
struct p9_dev *p9dev = dev;
@@ -1155,7 +1147,6 @@ static int init_vq(struct kvm *kvm, void *dev, u32 vq, u32 pfn)
struct p9_dev_job *job;
struct virt_queue *queue;
void *p;
- struct ioevent ioevent;
compat__remove_message(p9dev->compat_id);
@@ -1172,18 +1163,6 @@ static int init_vq(struct kvm *kvm, void *dev, u32 vq, u32 pfn)
};
thread_pool__init_job(&job->job_id, kvm, virtio_p9_do_io, job);
- ioevent = (struct ioevent) {
- .io_addr = p9dev->vpci.base_addr + VIRTIO_PCI_QUEUE_NOTIFY,
- .io_len = sizeof(u16),
- .fn = ioevent_callback,
- .fn_ptr = &p9dev->jobs[vq],
- .datamatch = vq,
- .fn_kvm = kvm,
- .fd = eventfd(0, 0),
- };
-
- ioeventfd__add_event(&ioevent);
-
return 0;
}
diff --git a/tools/kvm/virtio/balloon.c b/tools/kvm/virtio/balloon.c
index 6b93121..0f24539 100644
--- a/tools/kvm/virtio/balloon.c
+++ b/tools/kvm/virtio/balloon.c
@@ -7,7 +7,6 @@
#include "kvm/kvm.h"
#include "kvm/pci.h"
#include "kvm/threadpool.h"
-#include "kvm/ioeventfd.h"
#include "kvm/guest_compat.h"
#include "kvm/virtio-pci.h"
@@ -21,6 +20,7 @@
#include <sys/stat.h>
#include <sys/mman.h>
#include <pthread.h>
+#include <sys/eventfd.h>
#define NUM_VIRT_QUEUES 3
#define VIRTIO_BLN_QUEUE_SIZE 128
@@ -125,11 +125,6 @@ static void virtio_bln_do_io(struct kvm *kvm, void *param)
}
}
-static void ioevent_callback(struct kvm *kvm, void *param)
-{
- thread_pool__do_job(param);
-}
-
static int virtio_bln__collect_stats(void)
{
u64 tmp;
@@ -230,7 +225,6 @@ static int init_vq(struct kvm *kvm, void *dev, u32 vq, u32 pfn)
struct bln_dev *bdev = dev;
struct virt_queue *queue;
void *p;
- struct ioevent ioevent;
compat__remove_message(bdev->compat_id);
@@ -241,18 +235,6 @@ static int init_vq(struct kvm *kvm, void *dev, u32 vq, u32 pfn)
thread_pool__init_job(&bdev->jobs[vq], kvm, virtio_bln_do_io, queue);
vring_init(&queue->vring, VIRTIO_BLN_QUEUE_SIZE, p, VIRTIO_PCI_VRING_ALIGN);
- ioevent = (struct ioevent) {
- .io_addr = bdev->vpci.base_addr + VIRTIO_PCI_QUEUE_NOTIFY,
- .io_len = sizeof(u16),
- .fn = ioevent_callback,
- .fn_ptr = &bdev->jobs[vq],
- .datamatch = vq,
- .fn_kvm = kvm,
- .fd = eventfd(0, 0),
- };
-
- ioeventfd__add_event(&ioevent);
-
return 0;
}
diff --git a/tools/kvm/virtio/blk.c b/tools/kvm/virtio/blk.c
index 2e047d7..5f312b5 100644
--- a/tools/kvm/virtio/blk.c
+++ b/tools/kvm/virtio/blk.c
@@ -122,13 +122,6 @@ static void virtio_blk_do_io(struct kvm *kvm, struct virt_queue *vq, struct blk_
}
}
-static void ioevent_callback(struct kvm *kvm, void *param)
-{
- struct blk_dev *bdev = param;
-
- virtio_blk_do_io(kvm, &bdev->vqs[0], bdev);
-}
-
static void set_config(struct kvm *kvm, void *dev, u8 data, u32 offset)
{
struct blk_dev *bdev = dev;
@@ -160,7 +153,6 @@ static int init_vq(struct kvm *kvm, void *dev, u32 vq, u32 pfn)
struct blk_dev *bdev = dev;
struct virt_queue *queue;
void *p;
- struct ioevent ioevent;
compat__remove_message(bdev->compat_id);
@@ -170,18 +162,6 @@ static int init_vq(struct kvm *kvm, void *dev, u32 vq, u32 pfn)
vring_init(&queue->vring, VIRTIO_BLK_QUEUE_SIZE, p, VIRTIO_PCI_VRING_ALIGN);
- ioevent = (struct ioevent) {
- .io_addr = bdev->vpci.base_addr + VIRTIO_PCI_QUEUE_NOTIFY,
- .io_len = sizeof(u16),
- .fn = ioevent_callback,
- .fn_ptr = bdev,
- .datamatch = vq,
- .fn_kvm = kvm,
- .fd = eventfd(0, 0),
- };
-
- ioeventfd__add_event(&ioevent);
-
return 0;
}
@@ -261,7 +241,6 @@ void virtio_blk__delete_all(struct kvm *kvm)
struct blk_dev *bdev;
bdev = list_first_entry(&bdevs, struct blk_dev, list);
- ioeventfd__del_event(bdev->vpci.base_addr + VIRTIO_PCI_QUEUE_NOTIFY, 0);
list_del(&bdev->list);
free(bdev);
}
diff --git a/tools/kvm/virtio/net.c b/tools/kvm/virtio/net.c
index 6247642..4661e06 100644
--- a/tools/kvm/virtio/net.c
+++ b/tools/kvm/virtio/net.c
@@ -7,7 +7,6 @@
#include "kvm/kvm.h"
#include "kvm/irq.h"
#include "kvm/uip.h"
-#include "kvm/ioeventfd.h"
#include "kvm/guest_compat.h"
#include "kvm/virtio-pci.h"
@@ -170,11 +169,6 @@ static void virtio_net_handle_callback(struct kvm *kvm, u16 queue_index)
}
}
-static void ioevent_callback(struct kvm *kvm, void *param)
-{
- virtio_net_handle_callback(kvm, (u64)(long)param);
-}
-
static bool virtio_net__tap_init(const struct virtio_net_parameters *params)
{
int sock = socket(AF_INET, SOCK_STREAM, 0);
@@ -337,7 +331,6 @@ static int init_vq(struct kvm *kvm, void *dev, u32 vq, u32 pfn)
struct net_dev *ndev = dev;
struct virt_queue *queue;
void *p;
- struct ioevent ioevent;
compat__remove_message(ndev->compat_id);
@@ -347,18 +340,6 @@ static int init_vq(struct kvm *kvm, void *dev, u32 vq, u32 pfn)
vring_init(&queue->vring, VIRTIO_NET_QUEUE_SIZE, p, VIRTIO_PCI_VRING_ALIGN);
- ioevent = (struct ioevent) {
- .io_addr = ndev->vpci.base_addr + VIRTIO_PCI_QUEUE_NOTIFY,
- .io_len = sizeof(u16),
- .fn = ioevent_callback,
- .fn_ptr = (void *)(u64)vq,
- .datamatch = vq,
- .fn_kvm = kvm,
- .fd = eventfd(0, 0),
- };
-
- ioeventfd__add_event(&ioevent);
-
return 0;
}
diff --git a/tools/kvm/virtio/pci.c b/tools/kvm/virtio/pci.c
index 7181123..bb77f55 100644
--- a/tools/kvm/virtio/pci.c
+++ b/tools/kvm/virtio/pci.c
@@ -5,6 +5,7 @@
#include "kvm/virtio-pci-dev.h"
#include "kvm/irq.h"
#include "kvm/virtio.h"
+#include "kvm/ioeventfd.h"
#include <linux/virtio_pci.h>
#include <string.h>
@@ -14,6 +15,37 @@ static inline bool virtio_pci__msix_enabled(struct virtio_pci *vpci)
return vpci->pci_hdr.msix.ctrl & PCI_MSIX_FLAGS_ENABLE;
}
+static void virtio_pci__ioevent_callback(struct kvm *kvm, void *param)
+{
+ struct virtio_pci_ioevent_param *ioeventfd = param;
+
+ ioeventfd->vpci->ops.notify_vq(kvm, ioeventfd->vpci->dev, ioeventfd->vq);
+}
+
+static int virtio_pci__init_ioeventfd(struct kvm *kvm, struct virtio_pci *vpci, u32 vq)
+{
+ struct ioevent ioevent;
+
+ vpci->ioeventfds[vq] = (struct virtio_pci_ioevent_param) {
+ .vpci = vpci,
+ .vq = vq,
+ };
+
+ ioevent = (struct ioevent) {
+ .io_addr = vpci->base_addr + VIRTIO_PCI_QUEUE_NOTIFY,
+ .io_len = sizeof(u16),
+ .fn = virtio_pci__ioevent_callback,
+ .fn_ptr = &vpci->ioeventfds[vq],
+ .datamatch = vq,
+ .fn_kvm = kvm,
+ .fd = eventfd(0, 0),
+ };
+
+ ioeventfd__add_event(&ioevent);
+
+ return 0;
+}
+
static bool virtio_pci__specific_io_in(struct kvm *kvm, struct virtio_pci *vpci, u16 port,
void *data, int size, int offset)
{
@@ -140,6 +172,7 @@ static bool virtio_pci__io_out(struct ioport *ioport, struct kvm *kvm, u16 port,
break;
case VIRTIO_PCI_QUEUE_PFN:
val = ioport__read32(data);
+ virtio_pci__init_ioeventfd(kvm, vpci, vpci->queue_selector);
vpci->ops.init_vq(kvm, vpci->dev, vpci->queue_selector, val);
break;
case VIRTIO_PCI_QUEUE_SEL:
diff --git a/tools/kvm/virtio/rng.c b/tools/kvm/virtio/rng.c
index 5bea56c..dc97729 100644
--- a/tools/kvm/virtio/rng.c
+++ b/tools/kvm/virtio/rng.c
@@ -6,7 +6,6 @@
#include "kvm/util.h"
#include "kvm/kvm.h"
#include "kvm/threadpool.h"
-#include "kvm/ioeventfd.h"
#include "kvm/guest_compat.h"
#include "kvm/virtio-pci.h"
@@ -97,7 +96,6 @@ static int init_vq(struct kvm *kvm, void *dev, u32 vq, u32 pfn)
struct virt_queue *queue;
struct rng_dev_job *job;
void *p;
- struct ioevent ioevent;
compat__remove_message(rdev->compat_id);
@@ -114,18 +112,6 @@ static int init_vq(struct kvm *kvm, void *dev, u32 vq, u32 pfn)
.rdev = rdev,
};
- ioevent = (struct ioevent) {
- .io_addr = rdev->vpci.base_addr + VIRTIO_PCI_QUEUE_NOTIFY,
- .io_len = sizeof(u16),
- .fn = virtio_rng_do_io,
- .fn_ptr = &rdev->jobs[vq],
- .datamatch = vq,
- .fn_kvm = kvm,
- .fd = eventfd(0, 0),
- };
-
- ioeventfd__add_event(&ioevent);
-
thread_pool__init_job(&job->job_id, kvm, virtio_rng_do_io, job);
return 0;
@@ -192,7 +178,6 @@ void virtio_rng__delete_all(struct kvm *kvm)
rdev = list_first_entry(&rdevs, struct rng_dev, list);
list_del(&rdev->list);
- ioeventfd__del_event(rdev->vpci.base_addr + VIRTIO_PCI_QUEUE_NOTIFY, 0);
free(rdev);
}
}
--
1.7.6
^ permalink raw reply related [flat|nested] 2+ messages in thread
* [PATCH 2/2] kvm tools: Seperate pci layer out of virtio-console
2011-08-24 9:09 [PATCH 1/2] kvm tools: Move ioeventfd registration to virtio-pci Sasha Levin
@ 2011-08-24 9:09 ` Sasha Levin
0 siblings, 0 replies; 2+ messages in thread
From: Sasha Levin @ 2011-08-24 9:09 UTC (permalink / raw)
To: penberg; +Cc: kvm, mingo, asias.hejun, gorcunov, Sasha Levin
Signed-off-by: Sasha Levin <levinsasha928@gmail.com>
---
tools/kvm/virtio/console.c | 213 +++++++++++++++-----------------------------
1 files changed, 71 insertions(+), 142 deletions(-)
diff --git a/tools/kvm/virtio/console.c b/tools/kvm/virtio/console.c
index cb5a15e..035554c 100644
--- a/tools/kvm/virtio/console.c
+++ b/tools/kvm/virtio/console.c
@@ -11,6 +11,7 @@
#include "kvm/threadpool.h"
#include "kvm/irq.h"
#include "kvm/guest_compat.h"
+#include "kvm/virtio-pci.h"
#include <linux/virtio_console.h>
#include <linux/virtio_ring.h>
@@ -29,28 +30,13 @@
#define VIRTIO_CONSOLE_RX_QUEUE 0
#define VIRTIO_CONSOLE_TX_QUEUE 1
-static struct pci_device_header virtio_console_pci_device = {
- .vendor_id = PCI_VENDOR_ID_REDHAT_QUMRANET,
- .device_id = PCI_DEVICE_ID_VIRTIO_CONSOLE,
- .header_type = PCI_HEADER_TYPE_NORMAL,
- .revision_id = 0,
- .class = 0x078000,
- .subsys_vendor_id = PCI_SUBSYSTEM_VENDOR_ID_REDHAT_QUMRANET,
- .subsys_id = VIRTIO_ID_CONSOLE,
-};
-
struct con_dev {
pthread_mutex_t mutex;
+ struct virtio_pci vpci;
struct virt_queue vqs[VIRTIO_CONSOLE_NUM_QUEUES];
- struct virtio_console_config console_config;
- u32 host_features;
- u32 guest_features;
- u16 config_vector;
- u8 status;
- u8 isr;
- u16 queue_selector;
- u16 base_addr;
+ struct virtio_console_config config;
+ u32 features;
int compat_id;
struct thread_pool__job jobs[VIRTIO_CONSOLE_NUM_QUEUES];
@@ -59,13 +45,11 @@ struct con_dev {
static struct con_dev cdev = {
.mutex = PTHREAD_MUTEX_INITIALIZER,
- .console_config = {
+ .config = {
.cols = 80,
.rows = 24,
.max_nr_ports = 1,
},
-
- .host_features = 0,
};
/*
@@ -87,7 +71,7 @@ static void virtio_console__inject_interrupt_callback(struct kvm *kvm, void *par
head = virt_queue__get_iov(vq, iov, &out, &in, kvm);
len = term_getc_iov(CONSOLE_VIRTIO, iov, in);
virt_queue__set_used_elem(vq, head, len);
- virt_queue__trigger_irq(vq, virtio_console_pci_device.irq_line, &cdev.isr, kvm);
+ virtio_pci__signal_vq(kvm, &cdev.vpci, vq - cdev.vqs);
}
mutex_unlock(&cdev.mutex);
@@ -98,65 +82,6 @@ void virtio_console__inject_interrupt(struct kvm *kvm)
thread_pool__do_job(&cdev.jobs[VIRTIO_CONSOLE_RX_QUEUE]);
}
-static bool virtio_console_pci_io_device_specific_in(void *data, unsigned long offset, int size)
-{
- u8 *config_space = (u8 *) &cdev.console_config;
-
- if (size != 1)
- return false;
-
- if ((offset - VIRTIO_MSI_CONFIG_VECTOR) > sizeof(struct virtio_console_config))
- pr_error("config offset is too big: %li", offset - VIRTIO_MSI_CONFIG_VECTOR);
-
- ioport__write8(data, config_space[offset - VIRTIO_MSI_CONFIG_VECTOR]);
-
- return true;
-}
-
-static bool virtio_console_pci_io_in(struct ioport *ioport, struct kvm *kvm, u16 port, void *data, int size)
-{
- unsigned long offset = port - cdev.base_addr;
- bool ret = true;
-
- mutex_lock(&cdev.mutex);
-
- switch (offset) {
- case VIRTIO_PCI_HOST_FEATURES:
- ioport__write32(data, cdev.host_features);
- break;
- case VIRTIO_PCI_GUEST_FEATURES:
- ret = false;
- break;
- case VIRTIO_PCI_QUEUE_PFN:
- ioport__write32(data, cdev.vqs[cdev.queue_selector].pfn);
- break;
- case VIRTIO_PCI_QUEUE_NUM:
- ioport__write16(data, VIRTIO_CONSOLE_QUEUE_SIZE);
- break;
- case VIRTIO_PCI_QUEUE_SEL:
- case VIRTIO_PCI_QUEUE_NOTIFY:
- ret = false;
- break;
- case VIRTIO_PCI_STATUS:
- ioport__write8(data, cdev.status);
- break;
- case VIRTIO_PCI_ISR:
- ioport__write8(data, cdev.isr);
- kvm__irq_line(kvm, virtio_console_pci_device.irq_line, VIRTIO_IRQ_LOW);
- cdev.isr = VIRTIO_IRQ_LOW;
- break;
- case VIRTIO_MSI_CONFIG_VECTOR:
- ioport__write16(data, cdev.config_vector);
- break;
- default:
- ret = virtio_console_pci_io_device_specific_in(data, offset, size);
- };
-
- mutex_unlock(&cdev.mutex);
-
- return ret;
-}
-
static void virtio_console_handle_callback(struct kvm *kvm, void *param)
{
struct iovec iov[VIRTIO_CONSOLE_QUEUE_SIZE];
@@ -181,83 +106,87 @@ static void virtio_console_handle_callback(struct kvm *kvm, void *param)
}
-static bool virtio_console_pci_io_out(struct ioport *ioport, struct kvm *kvm, u16 port, void *data, int size)
+static void set_config(struct kvm *kvm, void *dev, u8 data, u32 offset)
{
- unsigned long offset = port - cdev.base_addr;
- bool ret = true;
+ struct con_dev *cdev = dev;
- mutex_lock(&cdev.mutex);
+ ((u8 *)(&cdev->config))[offset] = data;
+}
+
+static u8 get_config(struct kvm *kvm, void *dev, u32 offset)
+{
+ struct con_dev *cdev = dev;
- switch (offset) {
- case VIRTIO_PCI_GUEST_FEATURES:
- cdev.guest_features = ioport__read32(data);
- break;
- case VIRTIO_PCI_QUEUE_PFN: {
- struct virt_queue *queue;
- void *p;
+ return ((u8 *)(&cdev->config))[offset];
+}
+
+static u32 get_host_features(struct kvm *kvm, void *dev)
+{
+ return 0;
+}
- assert(cdev.queue_selector < VIRTIO_CONSOLE_NUM_QUEUES);
+static void set_guest_features(struct kvm *kvm, void *dev, u32 features)
+{
+ /* Unused */
+}
- compat__remove_message(cdev.compat_id);
+static int init_vq(struct kvm *kvm, void *dev, u32 vq, u32 pfn)
+{
+ struct virt_queue *queue;
+ void *p;
- queue = &cdev.vqs[cdev.queue_selector];
- queue->pfn = ioport__read32(data);
- p = guest_pfn_to_host(kvm, queue->pfn);
+ assert(vq < VIRTIO_CONSOLE_NUM_QUEUES);
- vring_init(&queue->vring, VIRTIO_CONSOLE_QUEUE_SIZE, p, VIRTIO_PCI_VRING_ALIGN);
+ compat__remove_message(cdev.compat_id);
- if (cdev.queue_selector == VIRTIO_CONSOLE_TX_QUEUE)
- thread_pool__init_job(&cdev.jobs[cdev.queue_selector], kvm, virtio_console_handle_callback, queue);
- else if (cdev.queue_selector == VIRTIO_CONSOLE_RX_QUEUE)
- thread_pool__init_job(&cdev.jobs[cdev.queue_selector], kvm, virtio_console__inject_interrupt_callback, queue);
+ queue = &cdev.vqs[vq];
+ queue->pfn = pfn;
+ p = guest_pfn_to_host(kvm, queue->pfn);
- break;
- }
- case VIRTIO_PCI_QUEUE_SEL:
- cdev.queue_selector = ioport__read16(data);
- break;
- case VIRTIO_PCI_QUEUE_NOTIFY: {
- u16 queue_index = ioport__read16(data);
- thread_pool__do_job(&cdev.jobs[queue_index]);
- break;
- }
- case VIRTIO_PCI_STATUS:
- cdev.status = ioport__read8(data);
- break;
- case VIRTIO_MSI_CONFIG_VECTOR:
- cdev.config_vector = VIRTIO_MSI_NO_VECTOR;
- break;
- case VIRTIO_MSI_QUEUE_VECTOR:
- break;
- default:
- ret = false;
- break;
- };
+ vring_init(&queue->vring, VIRTIO_CONSOLE_QUEUE_SIZE, p, VIRTIO_PCI_VRING_ALIGN);
- mutex_unlock(&cdev.mutex);
+ if (vq == VIRTIO_CONSOLE_TX_QUEUE)
+ thread_pool__init_job(&cdev.jobs[vq], kvm, virtio_console_handle_callback, queue);
+ else if (vq == VIRTIO_CONSOLE_RX_QUEUE)
+ thread_pool__init_job(&cdev.jobs[vq], kvm, virtio_console__inject_interrupt_callback, queue);
- return ret;
+ return 0;
}
-static struct ioport_operations virtio_console_io_ops = {
- .io_in = virtio_console_pci_io_in,
- .io_out = virtio_console_pci_io_out,
-};
+static int notify_vq(struct kvm *kvm, void *dev, u32 vq)
+{
+ struct con_dev *cdev = dev;
+
+ thread_pool__do_job(&cdev->jobs[vq]);
+
+ return 0;
+}
+
+static int get_pfn_vq(struct kvm *kvm, void *dev, u32 vq)
+{
+ struct con_dev *cdev = dev;
+
+ return cdev->vqs[vq].pfn;
+}
+
+static int get_size_vq(struct kvm *kvm, void *dev, u32 vq)
+{
+ return VIRTIO_CONSOLE_QUEUE_SIZE;
+}
void virtio_console__init(struct kvm *kvm)
{
- u8 dev, line, pin;
- u16 console_base_addr;
-
- if (irq__register_device(VIRTIO_ID_CONSOLE, &dev, &pin, &line) < 0)
- return;
-
- virtio_console_pci_device.irq_pin = pin;
- virtio_console_pci_device.irq_line = line;
- console_base_addr = ioport__register(IOPORT_EMPTY, &virtio_console_io_ops, IOPORT_SIZE, NULL);
- virtio_console_pci_device.bar[0] = console_base_addr | PCI_BASE_ADDRESS_SPACE_IO;
- cdev.base_addr = console_base_addr;
- pci__register(&virtio_console_pci_device, dev);
+ virtio_pci__init(kvm, &cdev.vpci, &cdev, PCI_DEVICE_ID_VIRTIO_CONSOLE, VIRTIO_ID_CONSOLE);
+ cdev.vpci.ops = (struct virtio_pci_ops) {
+ .set_config = set_config,
+ .get_config = get_config,
+ .get_host_features = get_host_features,
+ .set_guest_features = set_guest_features,
+ .init_vq = init_vq,
+ .notify_vq = notify_vq,
+ .get_pfn_vq = get_pfn_vq,
+ .get_size_vq = get_size_vq,
+ };
cdev.compat_id = compat__add_message("virtio-console device was not detected",
"While you have requested a virtio-console device, "
--
1.7.6
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2011-08-24 9:10 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-08-24 9:09 [PATCH 1/2] kvm tools: Move ioeventfd registration to virtio-pci Sasha Levin
2011-08-24 9:09 ` [PATCH 2/2] kvm tools: Seperate pci layer out of virtio-console Sasha Levin
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.