Ejemplo n.º 1
0
 def before(u):
     u.gdbsx_guest_memio = ffi.new('struct xen_domctl_gdbsx_memio')
     u.gdbsx_guest_memio.pgd3val = pgd3val
     u.gdbsx_guest_memio.gva = gva
     u.gdbsx_guest_memio.uva = uva
     u.gdbsx_guest_memio.len = len_
     u.gdbsx_guest_memio.gwr = gwr
Ejemplo n.º 2
0
 def domain_get_guest_width(self, domid):
     word_size = ffi.new('unsigned int *')
     err = lib.xc_domain_get_guest_width(self.xch, domid, word_size)
     if err != 0:
         raise XenException('Failed to get word size for domain',
                            self.domid,
                            'with err =',
                            err,
                            errno=True)
     return word_size[0]
Ejemplo n.º 3
0
    def map_by_mfn(self, domid, base_mfn, offset, size, prot):
        num_pages = (size + lib.XC_PAGE_SIZE - 1) >> lib.XC_PAGE_SHIFT
        pages = ffi.new('xen_pfn_t[]',
                        [base_mfn + i for i in range(num_pages)])
        mem_page_base = lib.xenforeignmemory_map(self.fmem, domid, prot,
                                                 num_pages, pages, ffi.NULL)
        if mem_page_base == ffi.NULL:
            raise XenException('failed to map xen foreign memory', errno=True)

        def cleanup():
            err = lib.xenforeignmemory_unmap(self.fmem, mem_page_base,
                                             num_pages)
            if err:
                raise XenException('failed to unmap xen foreign memory',
                                   mem_page_base,
                                   'with err',
                                   err,
                                   errno=True)

        return mem_page_base + offset, cleanup
Ejemplo n.º 4
0
 def vcpu_getcontext(self, domid, vcpu):
     ctxt = ffi.new('vcpu_guest_context_any_t *')
     err = lib.xc_vcpu_getcontext(self.xch, domid, vcpu, ctxt)
     if err != 0:
         raise XenException('Failed to get vcpu context', errno=True)
     return ctxt
Ejemplo n.º 5
0
 def domain_getinfo(self, domid):
     dominfo = ffi.new('xc_dominfo_t *')
     n = lib.xc_domain_getinfo(self.xch, domid, 1, dominfo)
     if n != 1:
         raise XenException('Failed to get domain info', errno=True)
     return dominfo
Ejemplo n.º 6
0
 def directory(self, path):
     num_entries = ffi.new('unsigned int *')
     entries = lib.xs_directory(self.xsh, lib.XBT_NULL, path, num_entries)
     if entries == ffi.NULL:
         raise XenException('failed to read directory', path, errno=True)
     return [ffi.string(entries[i]) for i in range(num_entries[0])]