diff --git a/hw/virtio/virtio-pci.h b/hw/virtio/virtio-pci.h
index d7d5d403a948..a1b3f1bc45c9 100644
--- a/hw/virtio/virtio-pci.h
+++ b/hw/virtio/virtio-pci.h
@@ -141,6 +141,7 @@ struct VirtIOPCIProxy {
     bool disable_modern;
     bool ignore_backend_features;
     OnOffAuto disable_legacy;
+    bool ioeventfd_assign_started;
     uint32_t class_code;
     uint32_t nvectors;
     uint32_t dfselect;
diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c
index 883045a22354..0a8738c69541 100644
--- a/hw/virtio/virtio-pci.c
+++ b/hw/virtio/virtio-pci.c
@@ -243,47 +243,66 @@ static int virtio_pci_ioeventfd_assign(DeviceState *d, EventNotifier *notifier,
     hwaddr modern_addr = virtio_pci_queue_mem_mult(proxy) *
                          virtio_get_queue_index(vq);
     hwaddr legacy_addr = VIRTIO_PCI_QUEUE_NOTIFY;
+    bool transaction = !proxy->ioeventfd_assign_started;
 
     if (assign) {
         if (modern) {
             if (fast_mmio) {
-                memory_region_add_eventfd(modern_mr, modern_addr, 0,
-                                          false, n, notifier);
+                memory_region_add_eventfd_full(modern_mr, modern_addr, 0,
+                                               false, n, notifier, transaction);
             } else {
-                memory_region_add_eventfd(modern_mr, modern_addr, 2,
-                                          false, n, notifier);
+                memory_region_add_eventfd_full(modern_mr, modern_addr, 2,
+                                               false, n, notifier, transaction);
             }
             if (modern_pio) {
-                memory_region_add_eventfd(modern_notify_mr, 0, 2,
-                                              true, n, notifier);
+                memory_region_add_eventfd_full(modern_notify_mr, 0, 2,
+                                               true, n, notifier, transaction);
             }
         }
         if (legacy) {
-            memory_region_add_eventfd(legacy_mr, legacy_addr, 2,
-                                      true, n, notifier);
+            memory_region_add_eventfd_full(legacy_mr, legacy_addr, 2,
+                                           true, n, notifier, transaction);
         }
     } else {
         if (modern) {
             if (fast_mmio) {
-                memory_region_del_eventfd(modern_mr, modern_addr, 0,
-                                          false, n, notifier);
+                memory_region_del_eventfd_full(modern_mr, modern_addr, 0,
+                                               false, n, notifier, transaction);
             } else {
-                memory_region_del_eventfd(modern_mr, modern_addr, 2,
-                                          false, n, notifier);
+                memory_region_del_eventfd_full(modern_mr, modern_addr, 2,
+                                               false, n, notifier, transaction);
             }
             if (modern_pio) {
-                memory_region_del_eventfd(modern_notify_mr, 0, 2,
-                                          true, n, notifier);
+                memory_region_del_eventfd_full(modern_notify_mr, 0, 2,
+                                               true, n, notifier, transaction);
             }
         }
         if (legacy) {
-            memory_region_del_eventfd(legacy_mr, legacy_addr, 2,
-                                      true, n, notifier);
+            memory_region_del_eventfd_full(legacy_mr, legacy_addr, 2,
+                                           true, n, notifier, transaction);
         }
     }
     return 0;
 }
 
+static void virtio_pci_ioeventfd_assign_begin(DeviceState *d)
+{
+    VirtIOPCIProxy *proxy = to_virtio_pci_proxy(d);
+
+    assert(!proxy->ioeventfd_assign_started);
+    proxy->ioeventfd_assign_started = true;
+    memory_region_transaction_begin();
+}
+
+static void virtio_pci_ioeventfd_assign_commit(DeviceState *d)
+{
+    VirtIOPCIProxy *proxy = to_virtio_pci_proxy(d);
+
+    assert(proxy->ioeventfd_assign_started);
+    memory_region_transaction_commit();
+    proxy->ioeventfd_assign_started = false;
+}
+
 static void virtio_pci_start_ioeventfd(VirtIOPCIProxy *proxy)
 {
     virtio_bus_start_ioeventfd(&proxy->bus);
@@ -2161,6 +2180,8 @@ static void virtio_pci_bus_class_init(ObjectClass *klass, void *data)
     k->query_nvectors = virtio_pci_query_nvectors;
     k->ioeventfd_enabled = virtio_pci_ioeventfd_enabled;
     k->ioeventfd_assign = virtio_pci_ioeventfd_assign;
+    k->ioeventfd_assign_begin = virtio_pci_ioeventfd_assign_begin;
+    k->ioeventfd_assign_commit = virtio_pci_ioeventfd_assign_commit;
     k->get_dma_as = virtio_pci_get_dma_as;
     k->queue_enabled = virtio_pci_queue_enabled;
 }
diff --git a/softmmu/memory.c b/softmmu/memory.c
index 1b1942d521cc..0279e5671bcb 100644
--- a/softmmu/memory.c
+++ b/softmmu/memory.c
@@ -2368,7 +2368,7 @@ void memory_region_add_eventfd_full(MemoryRegion *mr,
     if (size) {
         adjust_endianness(mr, &mrfd.data, size_memop(size) | MO_TE);
     }
-    if (transaction) {
+    if (!transaction) {
         memory_region_transaction_begin();
     }
     for (i = 0; i < mr->ioeventfd_nb; ++i) {
@@ -2383,7 +2383,7 @@ void memory_region_add_eventfd_full(MemoryRegion *mr,
             sizeof(*mr->ioeventfds) * (mr->ioeventfd_nb-1 - i));
     mr->ioeventfds[i] = mrfd;
     ioeventfd_update_pending |= mr->enabled;
-    if (transaction) {
+    if (!transaction) {
         memory_region_transaction_commit();
     }
 }
