qemu with hax to log dma reads & writes jcs.org/2018/11/12/vfio

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>

authored by

David Hildenbrand and committed by
Michael S. Tsirkin
b030958c 956b109f

+13 -9
+13 -9
hw/s390x/s390-virtio-ccw.c
··· 43 43 #include "hw/qdev-properties.h" 44 44 #include "hw/s390x/tod.h" 45 45 #include "sysemu/sysemu.h" 46 - #include "sysemu/balloon.h" 47 46 #include "hw/s390x/pv.h" 48 47 #include "migration/blocker.h" 49 48 ··· 329 328 ms->pv = false; 330 329 migrate_del_blocker(pv_mig_blocker); 331 330 error_free_or_abort(&pv_mig_blocker); 332 - qemu_balloon_inhibit(false); 331 + ram_block_discard_disable(false); 333 332 } 334 333 335 334 static int s390_machine_protect(S390CcwMachineState *ms) ··· 338 337 int rc; 339 338 340 339 /* 341 - * Ballooning on protected VMs needs support in the guest for 342 - * sharing and unsharing balloon pages. Block ballooning for 343 - * now, until we have a solution to make at least Linux guests 344 - * either support it or fail gracefully. 340 + * Discarding of memory in RAM blocks does not work as expected with 341 + * protected VMs. Sharing and unsharing pages would be required. Disable 342 + * it for now, until until we have a solution to make at least Linux 343 + * guests either support it (e.g., virtio-balloon) or fail gracefully. 345 344 */ 346 - qemu_balloon_inhibit(true); 345 + rc = ram_block_discard_disable(true); 346 + if (rc) { 347 + error_report("protected VMs: cannot disable RAM discard"); 348 + return rc; 349 + } 350 + 347 351 error_setg(&pv_mig_blocker, 348 352 "protected VMs are currently not migrateable."); 349 353 rc = migrate_add_blocker(pv_mig_blocker, &local_err); 350 354 if (rc) { 351 - qemu_balloon_inhibit(false); 355 + ram_block_discard_disable(false); 352 356 error_report_err(local_err); 353 357 error_free_or_abort(&pv_mig_blocker); 354 358 return rc; ··· 357 361 /* Create SE VM */ 358 362 rc = s390_pv_vm_enable(); 359 363 if (rc) { 360 - qemu_balloon_inhibit(false); 364 + ram_block_discard_disable(false); 361 365 migrate_del_blocker(pv_mig_blocker); 362 366 error_free_or_abort(&pv_mig_blocker); 363 367 return rc;