Skip to content

Instantly share code, notes, and snippets.

trait Resource: Read {}
trait Factory {
type R: Resource;
fn get(&self, index: u8) -> Result<Self::R, ()>;
}
#[derive(Clone)]
@awsaba
awsaba / gist:5c807a8d07582c0f5770
Created June 21, 2015 16:59
Notes on Xen HVM guest physical maps
Xen leaves holes in it's p2m map which makes using dominfo.maxmemkb insufficient for accessing all of the guests physical memory.
xc_domain_maximum_gpfn() seems to return a usable value, but is also larger than necessary for guests with less than 4GB of ram.
Linux guest with 2GB of ram:
nr_pages: 80042
nr_outstanding_pages: 0
nr_shared_pages: 0
nr_paged_pages: 0
max_memkb: 200400
@awsaba
awsaba / page_size_size_test.c
Created April 16, 2015 14:56
sizeof(enum page_size)
$ gcc -lvmi -Wall -pedantic page_size_size_test.c
$ ./a.out
sizeof(enum page_size): 4
sizeof(page_size_t): 4
sizeof(VMI_PS_4KB): 4
$ gcc --version
gcc (Ubuntu 4.8.2-19ubuntu1) 4.8.2
Copyright (C) 2013 Free Software Foundation, Inc.