From: Matt Evans <matt@ozlabs.org>
To: kvm@vger.kernel.org, kvm-ppc@vger.kernel.org
Subject: [PATCH 8/8] kvm tools: Make virtio-pci's ioeventfd__add_event() fall
Date: Tue, 06 Dec 2011 04:06:57 +0000 [thread overview]
Message-ID: <4EDD94E1.7040705@ozlabs.org> (raw)
In-Reply-To: <cover.1323143103.git.matt@ozlabs.org>
PPC KVM doesn't yet support ioeventfds, so don't bomb out/die. virtio-pci is
able to function if it instead uses normal IO port notification.
Signed-off-by: Matt Evans <matt@ozlabs.org>
---
tools/kvm/include/kvm/ioeventfd.h | 3 ++-
tools/kvm/ioeventfd.c | 12 +++++++++---
tools/kvm/virtio/pci.c | 11 ++++++++++-
3 files changed, 21 insertions(+), 5 deletions(-)
diff --git a/tools/kvm/include/kvm/ioeventfd.h b/tools/kvm/include/kvm/ioeventfd.h
index df01750..5e458be 100644
--- a/tools/kvm/include/kvm/ioeventfd.h
+++ b/tools/kvm/include/kvm/ioeventfd.h
@@ -4,6 +4,7 @@
#include <linux/types.h>
#include <linux/list.h>
#include <sys/eventfd.h>
+#include <stdbool.h>
struct kvm;
@@ -21,7 +22,7 @@ struct ioevent {
void ioeventfd__init(void);
void ioeventfd__start(void);
-void ioeventfd__add_event(struct ioevent *ioevent);
+bool ioeventfd__add_event(struct ioevent *ioevent);
void ioeventfd__del_event(u64 addr, u64 datamatch);
#endif
diff --git a/tools/kvm/ioeventfd.c b/tools/kvm/ioeventfd.c
index 3a240e4..37f9a63 100644
--- a/tools/kvm/ioeventfd.c
+++ b/tools/kvm/ioeventfd.c
@@ -26,7 +26,7 @@ void ioeventfd__init(void)
die("Failed creating epoll fd");
}
-void ioeventfd__add_event(struct ioevent *ioevent)
+bool ioeventfd__add_event(struct ioevent *ioevent)
{
struct kvm_ioeventfd kvm_ioevent;
struct epoll_event epoll_event;
@@ -48,8 +48,13 @@ void ioeventfd__add_event(struct ioevent *ioevent)
.flags = KVM_IOEVENTFD_FLAG_PIO | KVM_IOEVENTFD_FLAG_DATAMATCH,
};
- if (ioctl(ioevent->fn_kvm->vm_fd, KVM_IOEVENTFD, &kvm_ioevent) != 0)
- die("Failed creating new ioeventfd");
+ if (ioctl(ioevent->fn_kvm->vm_fd, KVM_IOEVENTFD, &kvm_ioevent) != 0) {
+ /* Not all KVM implementations may support KVM_IOEVENTFD,
+ * so be graceful.
+ */
+ free(new_ioevent);
+ return false;
+ }
epoll_event = (struct epoll_event) {
.events = EPOLLIN,
@@ -60,6 +65,7 @@ void ioeventfd__add_event(struct ioevent *ioevent)
die("Failed assigning new event to the epoll fd");
list_add_tail(&new_ioevent->list, &used_ioevents);
+ return true;
}
void ioeventfd__del_event(u64 addr, u64 datamatch)
diff --git a/tools/kvm/virtio/pci.c b/tools/kvm/virtio/pci.c
index ffa3768..06d3b79 100644
--- a/tools/kvm/virtio/pci.c
+++ b/tools/kvm/virtio/pci.c
@@ -50,7 +50,16 @@ static int virtio_pci__init_ioeventfd(struct kvm *kvm, struct virtio_trans *vtra
.fd = eventfd(0, 0),
};
- ioeventfd__add_event(&ioevent);
+ if (!ioeventfd__add_event(&ioevent)) {
+#ifndef CONFIG_PPC
+ /* PPC64 doesn't have kvm ioevents yet, so we expect this to
+ * fail -- don't need to be verbose about it! For virtio-pci,
+ * this is fine. It catches the IO accesses anyway, so
+ * still works (but slower).
+ */
+ pr_warning("Failed creating new ioeventfd");
+#endif
+ }
if (vtrans->virtio_ops->notify_vq_eventfd)
vtrans->virtio_ops->notify_vq_eventfd(kvm, vpci->dev, vq, ioevent.fd);
WARNING: multiple messages have this Message-ID (diff)
From: Matt Evans <matt@ozlabs.org>
To: kvm@vger.kernel.org, kvm-ppc@vger.kernel.org
Subject: [PATCH 8/8] kvm tools: Make virtio-pci's ioeventfd__add_event() fall back gracefully if ioeventfds unavailable
Date: Tue, 06 Dec 2011 15:06:57 +1100 [thread overview]
Message-ID: <4EDD94E1.7040705@ozlabs.org> (raw)
In-Reply-To: <cover.1323143103.git.matt@ozlabs.org>
PPC KVM doesn't yet support ioeventfds, so don't bomb out/die. virtio-pci is
able to function if it instead uses normal IO port notification.
Signed-off-by: Matt Evans <matt@ozlabs.org>
---
tools/kvm/include/kvm/ioeventfd.h | 3 ++-
tools/kvm/ioeventfd.c | 12 +++++++++---
tools/kvm/virtio/pci.c | 11 ++++++++++-
3 files changed, 21 insertions(+), 5 deletions(-)
diff --git a/tools/kvm/include/kvm/ioeventfd.h b/tools/kvm/include/kvm/ioeventfd.h
index df01750..5e458be 100644
--- a/tools/kvm/include/kvm/ioeventfd.h
+++ b/tools/kvm/include/kvm/ioeventfd.h
@@ -4,6 +4,7 @@
#include <linux/types.h>
#include <linux/list.h>
#include <sys/eventfd.h>
+#include <stdbool.h>
struct kvm;
@@ -21,7 +22,7 @@ struct ioevent {
void ioeventfd__init(void);
void ioeventfd__start(void);
-void ioeventfd__add_event(struct ioevent *ioevent);
+bool ioeventfd__add_event(struct ioevent *ioevent);
void ioeventfd__del_event(u64 addr, u64 datamatch);
#endif
diff --git a/tools/kvm/ioeventfd.c b/tools/kvm/ioeventfd.c
index 3a240e4..37f9a63 100644
--- a/tools/kvm/ioeventfd.c
+++ b/tools/kvm/ioeventfd.c
@@ -26,7 +26,7 @@ void ioeventfd__init(void)
die("Failed creating epoll fd");
}
-void ioeventfd__add_event(struct ioevent *ioevent)
+bool ioeventfd__add_event(struct ioevent *ioevent)
{
struct kvm_ioeventfd kvm_ioevent;
struct epoll_event epoll_event;
@@ -48,8 +48,13 @@ void ioeventfd__add_event(struct ioevent *ioevent)
.flags = KVM_IOEVENTFD_FLAG_PIO | KVM_IOEVENTFD_FLAG_DATAMATCH,
};
- if (ioctl(ioevent->fn_kvm->vm_fd, KVM_IOEVENTFD, &kvm_ioevent) != 0)
- die("Failed creating new ioeventfd");
+ if (ioctl(ioevent->fn_kvm->vm_fd, KVM_IOEVENTFD, &kvm_ioevent) != 0) {
+ /* Not all KVM implementations may support KVM_IOEVENTFD,
+ * so be graceful.
+ */
+ free(new_ioevent);
+ return false;
+ }
epoll_event = (struct epoll_event) {
.events = EPOLLIN,
@@ -60,6 +65,7 @@ void ioeventfd__add_event(struct ioevent *ioevent)
die("Failed assigning new event to the epoll fd");
list_add_tail(&new_ioevent->list, &used_ioevents);
+ return true;
}
void ioeventfd__del_event(u64 addr, u64 datamatch)
diff --git a/tools/kvm/virtio/pci.c b/tools/kvm/virtio/pci.c
index ffa3768..06d3b79 100644
--- a/tools/kvm/virtio/pci.c
+++ b/tools/kvm/virtio/pci.c
@@ -50,7 +50,16 @@ static int virtio_pci__init_ioeventfd(struct kvm *kvm, struct virtio_trans *vtra
.fd = eventfd(0, 0),
};
- ioeventfd__add_event(&ioevent);
+ if (!ioeventfd__add_event(&ioevent)) {
+#ifndef CONFIG_PPC
+ /* PPC64 doesn't have kvm ioevents yet, so we expect this to
+ * fail -- don't need to be verbose about it! For virtio-pci,
+ * this is fine. It catches the IO accesses anyway, so
+ * still works (but slower).
+ */
+ pr_warning("Failed creating new ioeventfd");
+#endif
+ }
if (vtrans->virtio_ops->notify_vq_eventfd)
vtrans->virtio_ops->notify_vq_eventfd(kvm, vpci->dev, vq, ioevent.fd);
next prev parent reply other threads:[~2011-12-06 4:06 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <cover.1323143103.git.matt@ozlabs.org>
2011-12-06 4:05 ` [PATCH 1/8] kvm tools: Add initial SPAPR PPC64 architecture support Matt Evans
2011-12-06 4:05 ` Matt Evans
2011-12-06 18:03 ` Scott Wood
2011-12-06 18:03 ` Scott Wood
2011-12-06 18:33 ` Pekka Enberg
2011-12-06 18:33 ` Pekka Enberg
2011-12-06 18:54 ` Scott Wood
2011-12-06 18:54 ` Scott Wood
2011-12-07 7:35 ` Matt Evans
2011-12-07 7:35 ` Matt Evans
2011-12-07 18:31 ` Scott Wood
2011-12-07 18:31 ` Scott Wood
2011-12-08 2:57 ` Matt Evans
2011-12-08 2:57 ` Matt Evans
2011-12-06 4:06 ` [PATCH 2/8] kvm tools: Generate SPAPR PPC64 guest device tree Matt Evans
2011-12-06 4:06 ` Matt Evans
2011-12-06 4:06 ` [PATCH 3/8] kvm tools: Add SPAPR PPC64 hcall & rtascall structure Matt Evans
2011-12-06 4:06 ` Matt Evans
2011-12-06 4:06 ` [PATCH 4/8] kvm tools: Add SPAPR PPC64 HV console Matt Evans
2011-12-06 4:06 ` Matt Evans
2011-12-06 4:06 ` [PATCH 5/8] kvm tools: Add PPC64 XICS interrupt controller support Matt Evans
2011-12-06 4:06 ` Matt Evans
2011-12-06 4:06 ` [PATCH 6/8] kvm tools: Add PPC64 PCI Host Bridge Matt Evans
2011-12-06 4:06 ` Matt Evans
2011-12-06 4:06 ` [PATCH 7/8] kvm tools: Add PPC64 kvm_cpu__emulate_io() Matt Evans
2011-12-06 4:06 ` Matt Evans
2011-12-06 4:06 ` Matt Evans [this message]
2011-12-06 4:06 ` [PATCH 8/8] kvm tools: Make virtio-pci's ioeventfd__add_event() fall back gracefully if ioeventfds unavailable Matt Evans
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=4EDD94E1.7040705@ozlabs.org \
--to=matt@ozlabs.org \
--cc=kvm-ppc@vger.kernel.org \
--cc=kvm@vger.kernel.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 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.