[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v2 23/42] ivshmem: Assert interrupts are set up once
From: |
Markus Armbruster |
Subject: |
[Qemu-devel] [PATCH v2 23/42] ivshmem: Assert interrupts are set up once |
Date: |
Mon, 7 Mar 2016 20:25:35 +0100 |
An interrupt is set up when the interrupt's file descriptor is
received. Each message applies to the next interrupt vector.
Therefore, each vector cannot be set up more than once.
ivshmem_add_kvm_msi_virq() half-heartedly tries not to rely on this by
doing nothing then, but that's not going to recover from this error
should it become possible in the future. watch_vector_notifier()
doesn't even try.
Simply assert what is the case, so we get alerted if we ever screw it
up.
Signed-off-by: Markus Armbruster <address@hidden>
Reviewed-by: Marc-André Lureau <address@hidden>
---
hw/misc/ivshmem.c | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)
diff --git a/hw/misc/ivshmem.c b/hw/misc/ivshmem.c
index fc37feb..9d2209d 100644
--- a/hw/misc/ivshmem.c
+++ b/hw/misc/ivshmem.c
@@ -349,7 +349,7 @@ static void watch_vector_notifier(IVShmemState *s,
EventNotifier *n,
{
int eventfd = event_notifier_get_fd(n);
- /* if MSI is supported we need multiple interrupts */
+ assert(!s->msi_vectors[vector].pdev);
s->msi_vectors[vector].pdev = PCI_DEVICE(s);
qemu_set_fd_handler(eventfd, ivshmem_vector_notify,
@@ -535,10 +535,7 @@ static int ivshmem_add_kvm_msi_virq(IVShmemState *s, int
vector)
int ret;
IVSHMEM_DPRINTF("ivshmem_add_kvm_msi_virq vector:%d\n", vector);
-
- if (s->msi_vectors[vector].pdev != NULL) {
- return 0;
- }
+ assert(!s->msi_vectors[vector].pdev);
ret = kvm_irqchip_add_msi_route(kvm_state, msg, pdev);
if (ret < 0) {
--
2.4.3
- Re: [Qemu-devel] [PATCH v2 03/42] target-ppc: Document TOCTTOU in hugepage support, (continued)
[Qemu-devel] [PATCH v2 16/42] ivshmem: Drop ivshmem_event() stub, Markus Armbruster, 2016/03/07
[Qemu-devel] [PATCH v2 23/42] ivshmem: Assert interrupts are set up once,
Markus Armbruster <=
[Qemu-devel] [PATCH v2 24/42] ivshmem: Simplify rejection of invalid peer ID from server, Markus Armbruster, 2016/03/07
[Qemu-devel] [PATCH v2 36/42] qdev: New DEFINE_PROP_ON_OFF_AUTO, Markus Armbruster, 2016/03/07
[Qemu-devel] [PATCH v2 25/42] ivshmem: Disentangle ivshmem_read(), Markus Armbruster, 2016/03/07
[Qemu-devel] [PATCH v2 40/42] ivshmem: Drop ivshmem property x-memdev, Markus Armbruster, 2016/03/07
[Qemu-devel] [PATCH v2 34/42] ivshmem: Simplify memory regions for BAR 2 (shared memory), Markus Armbruster, 2016/03/07
[Qemu-devel] [PATCH v2 33/42] ivshmem: Implement shm=... with a memory backend, Markus Armbruster, 2016/03/07