| Updated: January 28, 2026 |
Add, modify, or delete address-space regions in the guest system
#include <qvm/gasp.h>
void gasp_region_set(struct guest_system *gsp,
unsigned num_regions,
const struct gasp_region *rgn)
This function serves the same purpose as gasp_region_set_soft() but implicitly calls gasp_lock() and gasp_unlock() to ensure that another vdev cannot interfere while you are manipulating the guest address space. Another difference is that a fatal error causes it to terminate the running process (i.e., the qvm process instance with the vdev that called gasp_region_set()). To not terminate the running process on a fatal error, use gasp_region_set_soft() instead.
/*
* Before deleting memory regions, check if the memory has been split.
* Here, blk points to a qvm_state_block struct, which sets the information for
* the region being deleted. And rgn points to a gasp_region struct, which will
* store the results from the function call that retrieves guest region
* information, which includes the qvm_state_block struct inside.
*/
// blk.location is set first
remaining_length = blk.length;
while (remaining_length > 0) {
if (gasp_region_info(gsp, &blk, &rgn) != EOK) {
// error handling goes here
}
blk.length = rgn.guest.length;
gasp_region_set(gsp, 1, &rgn);
blk.location += blk.length; // update to the next location
remaining_length -= blk.length; // subtract length of region that was deleted
blk.length = remaining_length; // used for nexy gasp_region_info() query
}