bdpayne/libvmi — pull request #98 by mzguanglin (2013-09-10 20:07:38+00:00)
Title: Direct Guest Physical Memory Access (DGPMA) of shm-snapshot

Users now can get a read only pointer to the shm-snapshot by the vmi_get_dgpma(vmi) function, and then read the shm-snapshot content in a non-copy manner (ideally at a native speed like reading the local memory) , bypassing the vmi_read_pa(vmi) function.

Example:

1. without DGPMA:
vmi_init(&vmi, VMI_AUTO | VMI_INIT_COMPLETE, vm);
void* pmem = malloc(ANY_SIZE);
vmi_read_pa(vmi, A_PHY_ADDR, pmem, ANY_SIZE); // with memcpy() inside
any_vmi_processing(pmem, ANY_SIZE);
free(pmem);
vmi_shm_snapshot_destroy(vmi);
vmi_destroy(vmi);

2. with DGPMA:
vmi_init(&vmi, VMI_AUTO | VMI_INIT_COMPLETE, vm);
vmi_shm_snapshot_create(vmi);
const void* pmem = vmi_get_dgpma(vmi);
if (NULL == pmem) {
printf("fail to get dpgma\n");
return 1;
}
any_vmi_processing(pmem + A_PHY_ADDR, ANY_SIZE);
vmi_shm_snapshot_destroy(vmi);
vmi_destroy(vmi);