[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 17/40] ivshmem: Failed realize() can leave migration
From: |
Markus Armbruster |
Subject: |
[Qemu-devel] [PULL 17/40] ivshmem: Failed realize() can leave migration blocker behind |
Date: |
Fri, 18 Mar 2016 18:01:04 +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>
Message-Id: <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 299cf5b..51ad255 100644
--- a/hw/misc/ivshmem.c
+++ b/hw/misc/ivshmem.c
@@ -825,6 +825,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;
@@ -856,8 +857,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)) {
@@ -879,12 +878,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;
@@ -963,7 +956,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] [PULL 10/40] ivshmem: Rewrite specification document, (continued)
- [Qemu-devel] [PULL 10/40] ivshmem: Rewrite specification document, Markus Armbruster, 2016/03/18
- [Qemu-devel] [PULL 32/40] ivshmem: Simplify memory regions for BAR 2 (shared memory), Markus Armbruster, 2016/03/18
- [Qemu-devel] [PULL 04/40] qemu-doc: Fix ivshmem huge page example, Markus Armbruster, 2016/03/18
- [Qemu-devel] [PULL 29/40] ivshmem: Simplify how we cope with short reads from server, Markus Armbruster, 2016/03/18
- [Qemu-devel] [PULL 19/40] ivshmem: Clean up MSI-X conditions, Markus Armbruster, 2016/03/18
- [Qemu-devel] [PULL 35/40] ivshmem: Replace int role_val by OnOffAuto master, Markus Armbruster, 2016/03/18
- [Qemu-devel] [PULL 13/40] ivshmem: Clean up after commit 9940c32, Markus Armbruster, 2016/03/18
- [Qemu-devel] [PULL 02/40] ivshmem-server: Fix and clean up command line help, Markus Armbruster, 2016/03/18
- [Qemu-devel] [PULL 23/40] ivshmem: Disentangle ivshmem_read(), Markus Armbruster, 2016/03/18
- [Qemu-devel] [PULL 16/40] ivshmem: Fix harmless misuse of Error, Markus Armbruster, 2016/03/18
- [Qemu-devel] [PULL 17/40] ivshmem: Failed realize() can leave migration blocker behind,
Markus Armbruster <=
- [Qemu-devel] [PULL 25/40] ivshmem: Receive shared memory synchronously in realize(), Markus Armbruster, 2016/03/18
- [Qemu-devel] [PULL 30/40] ivshmem: Tighten check of property "size", Markus Armbruster, 2016/03/18
- [Qemu-devel] [PULL 27/40] ivshmem: Rely on server sending the ID right after the version, Markus Armbruster, 2016/03/18
- [Qemu-devel] [PULL 37/40] ivshmem: Clean up after the previous commit, Markus Armbruster, 2016/03/18
- [Qemu-devel] [PULL 28/40] ivshmem: Drop the hackish test for UNIX domain chardev, Markus Armbruster, 2016/03/18
- [Qemu-devel] [PULL 31/40] ivshmem: Implement shm=... with a memory backend, Markus Armbruster, 2016/03/18
- [Qemu-devel] [PULL 21/40] ivshmem: Assert interrupts are set up once, Markus Armbruster, 2016/03/18
- [Qemu-devel] [PULL 40/40] contrib/ivshmem-server: Print "not for production" warning, Markus Armbruster, 2016/03/18
- [Qemu-devel] [PULL 34/40] qdev: New DEFINE_PROP_ON_OFF_AUTO, Markus Armbruster, 2016/03/18
- [Qemu-devel] [PULL 36/40] ivshmem: Split ivshmem-plain, ivshmem-doorbell off ivshmem, Markus Armbruster, 2016/03/18