s390x/pv: Convert to ram_block_discard_disable()

Discarding RAM does not work as expected with protected VMs. Let's
switch to ram_block_discard_disable() for now, as we want to get rid
of qemu_balloon_inhibit(). Note that it will currently never fail, but
might fail in the future with new technologies (e.g., virtio-mem).

Acked-by: Cornelia Huck <cohuck@redhat.com>
Cc: Richard Henderson <rth@twiddle.net>
Cc: Cornelia Huck <cohuck@redhat.com>
Cc: Halil Pasic <pasic@linux.ibm.com>
Cc: Christian Borntraeger <borntraeger@de.ibm.com>
Cc: Janosch Frank <frankja@linux.ibm.com>
Signed-off-by: David Hildenbrand <david@redhat.com>
Message-Id: <20200626072248.78761-6-david@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
This commit is contained in:
David Hildenbrand 2020-06-26 09:22:32 +02:00 committed by Michael S. Tsirkin
parent 956b109fe3
commit b030958c2b

View file

@ -43,7 +43,6 @@
#include "hw/qdev-properties.h" #include "hw/qdev-properties.h"
#include "hw/s390x/tod.h" #include "hw/s390x/tod.h"
#include "sysemu/sysemu.h" #include "sysemu/sysemu.h"
#include "sysemu/balloon.h"
#include "hw/s390x/pv.h" #include "hw/s390x/pv.h"
#include "migration/blocker.h" #include "migration/blocker.h"
@ -329,7 +328,7 @@ static void s390_machine_unprotect(S390CcwMachineState *ms)
ms->pv = false; ms->pv = false;
migrate_del_blocker(pv_mig_blocker); migrate_del_blocker(pv_mig_blocker);
error_free_or_abort(&pv_mig_blocker); error_free_or_abort(&pv_mig_blocker);
qemu_balloon_inhibit(false); ram_block_discard_disable(false);
} }
static int s390_machine_protect(S390CcwMachineState *ms) static int s390_machine_protect(S390CcwMachineState *ms)
@ -338,17 +337,22 @@ static int s390_machine_protect(S390CcwMachineState *ms)
int rc; int rc;
/* /*
* Ballooning on protected VMs needs support in the guest for * Discarding of memory in RAM blocks does not work as expected with
* sharing and unsharing balloon pages. Block ballooning for * protected VMs. Sharing and unsharing pages would be required. Disable
* now, until we have a solution to make at least Linux guests * it for now, until until we have a solution to make at least Linux
* either support it or fail gracefully. * guests either support it (e.g., virtio-balloon) or fail gracefully.
*/ */
qemu_balloon_inhibit(true); rc = ram_block_discard_disable(true);
if (rc) {
error_report("protected VMs: cannot disable RAM discard");
return rc;
}
error_setg(&pv_mig_blocker, error_setg(&pv_mig_blocker,
"protected VMs are currently not migrateable."); "protected VMs are currently not migrateable.");
rc = migrate_add_blocker(pv_mig_blocker, &local_err); rc = migrate_add_blocker(pv_mig_blocker, &local_err);
if (rc) { if (rc) {
qemu_balloon_inhibit(false); ram_block_discard_disable(false);
error_report_err(local_err); error_report_err(local_err);
error_free_or_abort(&pv_mig_blocker); error_free_or_abort(&pv_mig_blocker);
return rc; return rc;
@ -357,7 +361,7 @@ static int s390_machine_protect(S390CcwMachineState *ms)
/* Create SE VM */ /* Create SE VM */
rc = s390_pv_vm_enable(); rc = s390_pv_vm_enable();
if (rc) { if (rc) {
qemu_balloon_inhibit(false); ram_block_discard_disable(false);
migrate_del_blocker(pv_mig_blocker); migrate_del_blocker(pv_mig_blocker);
error_free_or_abort(&pv_mig_blocker); error_free_or_abort(&pv_mig_blocker);
return rc; return rc;