diff options
-rw-r--r-- | hw/vfio/common.c | 1 | ||||
-rw-r--r-- | hw/vfio/pci.c | 2 | ||||
-rw-r--r-- | migration/postcopy-ram.c | 18 |
3 files changed, 18 insertions, 3 deletions
diff --git a/hw/vfio/common.c b/hw/vfio/common.c index 3f31f80b12..7c185e5a2e 100644 --- a/hw/vfio/common.c +++ b/hw/vfio/common.c @@ -1432,6 +1432,7 @@ int vfio_get_device(VFIOGroup *group, const char *name, if (!QLIST_EMPTY(&group->device_list)) { error_setg(errp, "Inconsistent device balloon setting within group"); + close(fd); return -1; } diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c index 056f3a887a..866f0deeb7 100644 --- a/hw/vfio/pci.c +++ b/hw/vfio/pci.c @@ -2879,7 +2879,7 @@ static void vfio_realize(PCIDevice *pdev, Error **errp) tmp = g_strdup_printf("%s/subsystem", vdev->vbasedev.sysfsdev); subsys = realpath(tmp, NULL); g_free(tmp); - is_mdev = (strcmp(subsys, "/sys/bus/mdev") == 0); + is_mdev = subsys && (strcmp(subsys, "/sys/bus/mdev") == 0); free(subsys); trace_vfio_mdev(vdev->vbasedev.name, is_mdev); diff --git a/migration/postcopy-ram.c b/migration/postcopy-ram.c index 3952d78e6b..853d8b32ca 100644 --- a/migration/postcopy-ram.c +++ b/migration/postcopy-ram.c @@ -510,6 +510,20 @@ int postcopy_ram_incoming_init(MigrationIncomingState *mis) } /* + * Manage a single vote to the QEMU balloon inhibitor for all postcopy usage, + * last caller wins. + */ +static void postcopy_balloon_inhibit(bool state) +{ + static bool cur_state = false; + + if (state != cur_state) { + qemu_balloon_inhibit(state); + cur_state = state; + } +} + +/* * At the end of a migration where postcopy_ram_incoming_init was called. */ int postcopy_ram_incoming_cleanup(MigrationIncomingState *mis) @@ -539,7 +553,7 @@ int postcopy_ram_incoming_cleanup(MigrationIncomingState *mis) mis->have_fault_thread = false; } - qemu_balloon_inhibit(false); + postcopy_balloon_inhibit(false); if (enable_mlock) { if (os_mlock() < 0) { @@ -1109,7 +1123,7 @@ int postcopy_ram_enable_notify(MigrationIncomingState *mis) * Ballooning can mark pages as absent while we're postcopying * that would cause false userfaults. */ - qemu_balloon_inhibit(true); + postcopy_balloon_inhibit(true); trace_postcopy_ram_enable_notify(); |