[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v2 19/42] ivshmem: Failed realize() can leave migrat
From: |
Markus Armbruster |
Subject: |
[Qemu-devel] [PATCH v2 19/42] ivshmem: Failed realize() can leave migration blocker behind |
Date: |
Mon, 7 Mar 2016 20:25:31 +0100 |
If pci_ivshmem_realize() fails after it created its migration blocker,
the blocker is left in place. Fix that by creating it last.
Likewise, if it fails after it called fifo8_create(), it leaks fifo
memory. Fix that the same way.
Signed-off-by: Markus Armbruster <address@hidden>
Reviewed-by: Marc-André Lureau <address@hidden>
---
hw/misc/ivshmem.c | 23 ++++++++++++++---------
1 file changed, 14 insertions(+), 9 deletions(-)
diff --git a/hw/misc/ivshmem.c b/hw/misc/ivshmem.c
index eb53d9a..1392426 100644
--- a/hw/misc/ivshmem.c
+++ b/hw/misc/ivshmem.c
@@ -824,6 +824,7 @@ static void ivshmem_write_config(PCIDevice *pdev, uint32_t
address,
static void pci_ivshmem_realize(PCIDevice *dev, Error **errp)
{
IVShmemState *s = IVSHMEM(dev);
+ Error *err = NULL;
uint8_t *pci_conf;
uint8_t attr = PCI_BASE_ADDRESS_SPACE_MEMORY |
PCI_BASE_ADDRESS_MEM_PREFETCH;
@@ -855,8 +856,6 @@ static void pci_ivshmem_realize(PCIDevice *dev, Error
**errp)
s->ivshmem_size = size;
}
- fifo8_create(&s->incoming_fifo, sizeof(int64_t));
-
/* IRQFD requires MSI */
if (ivshmem_has_feature(s, IVSHMEM_IOEVENTFD) &&
!ivshmem_has_feature(s, IVSHMEM_MSI)) {
@@ -878,12 +877,6 @@ static void pci_ivshmem_realize(PCIDevice *dev, Error
**errp)
s->role_val = IVSHMEM_MASTER; /* default */
}
- if (s->role_val == IVSHMEM_PEER) {
- error_setg(&s->migration_blocker,
- "Migration is disabled when using feature 'peer mode' in
device 'ivshmem'");
- migrate_add_blocker(s->migration_blocker);
- }
-
pci_conf = dev->config;
pci_conf[PCI_COMMAND] = PCI_COMMAND_IO | PCI_COMMAND_MEMORY;
@@ -962,7 +955,19 @@ static void pci_ivshmem_realize(PCIDevice *dev, Error
**errp)
return;
}
- create_shared_memory_BAR(s, fd, attr, errp);
+ create_shared_memory_BAR(s, fd, attr, &err);
+ if (err) {
+ error_propagate(errp, err);
+ return;
+ }
+ }
+
+ fifo8_create(&s->incoming_fifo, sizeof(int64_t));
+
+ if (s->role_val == IVSHMEM_PEER) {
+ error_setg(&s->migration_blocker,
+ "Migration is disabled when using feature 'peer mode' in
device 'ivshmem'");
+ migrate_add_blocker(s->migration_blocker);
}
}
--
2.4.3
- [Qemu-devel] [PATCH v2 00/42] ivshmem: Fixes, cleanups, device model split, Markus Armbruster, 2016/03/07
- [Qemu-devel] [PATCH v2 10/42] ivshmem-test: Clean up wait for devices to become operational, Markus Armbruster, 2016/03/07
- [Qemu-devel] [PATCH v2 11/42] ivshmem-test: Improve test cases /ivshmem/server-*, Markus Armbruster, 2016/03/07
- [Qemu-devel] [PATCH v2 04/42] ivshmem-server: Fix and clean up command line help, Markus Armbruster, 2016/03/07
- [Qemu-devel] [PATCH v2 13/42] ivshmem: Add missing newlines to debug printfs, Markus Armbruster, 2016/03/07
- [Qemu-devel] [PATCH v2 01/42] exec: Fix memory allocation when memory path names new file, Markus Armbruster, 2016/03/07
- [Qemu-devel] [PATCH v2 09/42] ivshmem-test: Improve test case /ivshmem/single, Markus Armbruster, 2016/03/07
- [Qemu-devel] [PATCH v2 14/42] ivshmem: Compile debug prints unconditionally to prevent bit-rot, Markus Armbruster, 2016/03/07
- [Qemu-devel] [PATCH v2 08/42] tests/libqos/pci-pc: Fix qpci_pc_iomap() to map BARs aligned, Markus Armbruster, 2016/03/07
- [Qemu-devel] [PATCH v2 19/42] ivshmem: Failed realize() can leave migration blocker behind,
Markus Armbruster <=
- [Qemu-devel] [PATCH v2 02/42] exec: Fix memory allocation when memory path isn't on hugetlbfs, Markus Armbruster, 2016/03/07
- [Qemu-devel] [PATCH v2 21/42] ivshmem: Clean up MSI-X conditions, Markus Armbruster, 2016/03/07
- [Qemu-devel] [PATCH v2 03/42] target-ppc: Document TOCTTOU in hugepage support, Markus Armbruster, 2016/03/07