#!/usr/bin/python from ctypes import * from ctypes.util import find_library import os, platform xs_transaction_t = c_ulong struct_xs_handle = c_void_p xenstore = CDLL(find_library("xenstore")) xs_read = xenstore.__getattr__("xs_read") xs_read.argtypes = [ struct_xs_handle, xs_transaction_t, c_char_p, POINTER(c_uint) ] xs_read.restype = c_char_p xs_domain_open = xenstore.__getattr__("xs_domain_open") xs_domain_open.restype = struct_xs_handle xs_transaction_start = xenstore.__getattr__("xs_transaction_start") xs_transaction_start.argtypes = [ struct_xs_handle ] xs_transaction_start.restype = xs_transaction_t xs_transaction_end = xenstore.__getattr__("xs_transaction_end") xs_transaction_end.argtypes = [ struct_xs_handle, xs_transaction_t, c_bool ] xs_transaction_end.restype = c_bool path = "memory/target" length = c_uint() ret = 0 transaction = 0 xsh = None xst = 0 if transaction: xsh = xs_domain_open() xst = xs_transaction_start(xsh) val = xs_read(xsh, xst, path, byref(length)) if val == None: ret = 1 if transaction: xs_transaction_end(xsh, xth, ret)