Skip to content

Commit

Permalink
postcopy: Synchronize usage of the balloon inhibitor
Browse files Browse the repository at this point in the history
While the qemu_balloon_inhibit() interface appears rather general purpose,
postcopy uses it in a last-caller-wins approach with no guarantee of balanced
inhibits and de-inhibits.  Wrap postcopy's usage of the inhibitor to give it
one vote overall, using the same last-caller-wins approach as previously
implemented at the balloon level.

Fixes: 01ccbec ("balloon: Allow multiple inhibit users")
Reported-by: Christian Borntraeger <borntraeger@de.ibm.com>
Tested-by: Christian Borntraeger <borntraeger@de.ibm.com>
Reviewed-by: Cornelia Huck <cohuck@redhat.com>
Reviewed-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
  • Loading branch information
awilliam committed Aug 23, 2018
1 parent 8709b39 commit 154304c
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions migration/postcopy-ram.c
Expand Up @@ -509,6 +509,20 @@ int postcopy_ram_incoming_init(MigrationIncomingState *mis)
return 0;
}

/*
* 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.
*/
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -1107,7 +1121,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();

Expand Down

0 comments on commit 154304c

Please sign in to comment.