本文整理汇总了C++中xc_interface_close函数的典型用法代码示例。如果您正苦于以下问题:C++ xc_interface_close函数的具体用法?C++ xc_interface_close怎么用?C++ xc_interface_close使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了xc_interface_close函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char *argv[])
{
int i, ret = 0;
xc_physinfo_t physinfo = { 0 };
int nr_matches = 0;
int matches_main_options[ARRAY_SIZE(main_options)];
if ( argc < 2 )
{
show_help();
return 0;
}
xc_handle = xc_interface_open(0,0,0);
if ( !xc_handle )
{
fprintf(stderr, "failed to get the handler\n");
return EIO;
}
ret = xc_physinfo(xc_handle, &physinfo);
if ( ret )
{
ret = errno;
fprintf(stderr, "failed to get processor information (%d - %s)\n",
ret, strerror(ret));
xc_interface_close(xc_handle);
return ret;
}
max_cpu_nr = physinfo.nr_cpus;
/* calculate how many options match with user's input */
for ( i = 0; i < ARRAY_SIZE(main_options); i++ )
if ( !strncmp(main_options[i].name, argv[1], strlen(argv[1])) )
matches_main_options[nr_matches++] = i;
if ( nr_matches > 1 )
{
fprintf(stderr, "Ambiguous options: ");
for ( i = 0; i < nr_matches; i++ )
fprintf(stderr, " %s", main_options[matches_main_options[i]].name);
fprintf(stderr, "\n");
ret = EINVAL;
}
else if ( nr_matches == 1 )
/* dispatch to the corresponding function handler */
main_options[matches_main_options[0]].function(argc - 2, argv + 2);
else
{
show_help();
ret = EINVAL;
}
xc_interface_close(xc_handle);
return ret;
}
示例2: xencpu_init
static int xencpu_init (void)
{
xc_handle = xc_interface_open(XC_INTERFACE_INIT_ARGS);
if (!xc_handle)
{
ERROR ("xencpu: xc_interface_open() failed");
return (-1);
}
xc_physinfo_t *physinfo;
physinfo = calloc(1, sizeof(xc_physinfo_t));
if (physinfo == NULL)
{
ERROR ("xencpu plugin: calloc() for physinfo failed.");
xc_interface_close(xc_handle);
return (ENOMEM);
}
if (xc_physinfo(xc_handle, physinfo) < 0)
{
ERROR ("xencpu plugin: xc_physinfo() failed");
xc_interface_close(xc_handle);
free(physinfo);
return (-1);
}
num_cpus = physinfo->nr_cpus;
free(physinfo);
INFO ("xencpu plugin: Found %"PRIu32" processors.", num_cpus);
cpu_info = calloc(num_cpus, sizeof(xc_cpuinfo_t));
if (cpu_info == NULL)
{
ERROR ("xencpu plugin: calloc() for num_cpus failed.");
xc_interface_close(xc_handle);
return (ENOMEM);
}
cpu_states = calloc (num_cpus, sizeof (value_to_rate_state_t));
if (cpu_states == NULL)
{
ERROR ("xencpu plugin: calloc() for cpu_states failed.");
xc_interface_close(xc_handle);
free(cpu_info);
return (ENOMEM);
}
return (0);
} /* static int xencpu_init */
示例3: xencpu_shutdown
static int xencpu_shutdown(void) {
free(cpu_states);
free(cpu_info);
xc_interface_close(xc_handle);
return 0;
} /* static int xencpu_shutdown */
示例4: xen_init
static int xen_init(MachineState *ms)
{
PCMachineState *pcms = PC_MACHINE(ms);
/* Disable ACPI build because Xen handles it */
pcms->acpi_build_enabled = false;
xen_xc = xc_interface_open(0, 0, 0);
if (xen_xc == NULL) {
xen_pv_printf(NULL, 0, "can't open xen interface\n");
return -1;
}
xen_fmem = xenforeignmemory_open(0, 0);
if (xen_fmem == NULL) {
xen_pv_printf(NULL, 0, "can't open xen fmem interface\n");
xc_interface_close(xen_xc);
return -1;
}
qemu_add_vm_change_state_handler(xen_change_state_handler, NULL);
global_state_set_optional();
savevm_skip_configuration();
savevm_skip_section_footers();
return 0;
}
示例5: checkpoint_close
void checkpoint_close(checkpoint_state* s)
{
if (s->timer)
delete_suspend_timer(s);
if (s->suspend_thr)
stop_suspend_thread(s);
release_shutdown_watch(s);
release_suspend_evtchn(s);
if (s->xch >= 0) {
xc_interface_close(s->xch);
s->xch = -1;
}
if (s->xce >= 0) {
xc_evtchn_close(s->xce);
s->xce = -1;
}
if (s->xsh) {
xs_daemon_close(s->xsh);
s->xsh = NULL;
}
s->domid = 0;
s->fd = -1;
}
示例6: xen_setup
bool xen_setup(void)
{
xs = xs_daemon_open();
if (xs == NULL) {
dolog(LOG_ERR,
"Failed to contact xenstore (%m). Is it running?");
goto out;
}
xc = xc_interface_open();
if (xc == -1) {
dolog(LOG_ERR, "Failed to contact hypervisor (%m)");
goto out;
}
if (!xs_watch(xs, "@introduceDomain", "domlist")) {
dolog(LOG_ERR, "xenstore watch on @introduceDomain fails.");
goto out;
}
if (!xs_watch(xs, "@releaseDomain", "domlist")) {
dolog(LOG_ERR, "xenstore watch on @releaseDomain fails.");
goto out;
}
return true;
out:
if (xs)
xs_daemon_close(xs);
if (xc != -1)
xc_interface_close(xc);
return false;
}
示例7: xc_interface_open
static PyObject *pyflask_load(PyObject *self, PyObject *args, PyObject *kwds)
{
int xc_handle;
char *policy;
uint32_t len;
int ret;
static char *kwd_list[] = { "policy", NULL };
if( !PyArg_ParseTupleAndKeywords(args, kwds, "s#", kwd_list, &policy, &len) )
return NULL;
xc_handle = xc_interface_open();
if (xc_handle < 0) {
errno = xc_handle;
return PyErr_SetFromErrno(xc_error_obj);
}
ret = flask_load(xc_handle, policy, len);
xc_interface_close(xc_handle);
if ( ret != 0 ) {
errno = -ret;
return PyErr_SetFromErrno(xc_error_obj);
}
return Py_BuildValue("i", ret);
}
示例8: __hypercall_perform
static int __hypercall_perform(unsigned long cmd, unsigned long *arr)
{
int ret;
xc_interface *xch = xc_interface_open(0, 0, 0);
DECLARE_HYPERCALL;
if (xch == NULL)
goto err;
hypercall.op = __HYPERVISOR_xen_version;
hypercall.arg[0] = cmd;
hypercall.arg[1] = (unsigned long) arr;
ret = do_xen_hypercall(xch, &hypercall);
xc_interface_close(xch);
if (ret != 0)
goto err;
out:
return ret;
err:
ret = -1;
goto out;
}
示例9: sizeof
static PyObject *getpolicy(PyObject *self, PyObject *args)
{
struct acm_getpolicy getpolicy;
int xc_handle, rc;
uint8_t pull_buffer[8192];
PyObject *result;
uint32_t len = sizeof(pull_buffer);
memset(&getpolicy, 0x0, sizeof(getpolicy));
set_xen_guest_handle(getpolicy.pullcache, pull_buffer);
getpolicy.pullcache_size = sizeof(pull_buffer);
if ((xc_handle = xc_interface_open()) <= 0) {
PyErr_SetString(PyExc_IOError, ctrlif_op);
return NULL;
}
rc = xc_acm_op(xc_handle, ACMOP_getpolicy, &getpolicy, sizeof(getpolicy));
xc_interface_close(xc_handle);
if (rc == 0) {
struct acm_policy_buffer *header =
(struct acm_policy_buffer *)pull_buffer;
if (ntohl(header->len) < sizeof(pull_buffer))
len = ntohl(header->len);
} else {
len = 0;
}
result = Py_BuildValue("is#", rc, pull_buffer, len);
return result;
}
示例10: xc_interface_open
/**
* map_tbufs - memory map Xen trace buffers into user space
* @tbufs_mfn: mfn of the trace buffers
* @num: number of trace buffers to map
* @size: size of each trace buffer
*
* Maps the Xen trace buffers them into process address space.
*/
struct t_buf *map_tbufs(unsigned long tbufs_mfn, unsigned int num,
unsigned long size)
{
int xc_handle;
struct t_buf *tbufs_mapped;
xc_handle = xc_interface_open();
if ( xc_handle < 0 )
{
exit(EXIT_FAILURE);
}
tbufs_mapped = xc_map_foreign_range(xc_handle, DOMID_XEN,
size * num, PROT_READ | PROT_WRITE,
tbufs_mfn);
xc_interface_close(xc_handle);
if ( tbufs_mapped == 0 )
{
PERROR("Failed to mmap trace buffers");
exit(EXIT_FAILURE);
}
return tbufs_mapped;
}
示例11: complete
static void complete(int retval) {
int errnoval = retval ? errno : 0; /* suppress irrelevant errnos */
xtl_log(&logger,XTL_DEBUG,errnoval,program,"complete r=%d",retval);
helper_stub_complete(retval,errnoval,0);
xc_interface_close(xch);
exit(0);
}
示例12: main
int main(int argc, char **argv)
{
int opt;
while ((opt = getopt(argc, argv, "h")) != -1) {
switch (opt) {
case 'h':
usage(0);
break;
default:
usage(1);
}
}
argv += optind;
argc -= optind;
if (argc <= 0)
usage(1);
xch = xc_interface_open(NULL, NULL, 0);
if (!xch)
err(1, "opening xc interface");
if (strcmp(argv[0], "reset") == 0)
gcov_reset();
else if (strcmp(argv[0], "read") == 0)
gcov_read(argc > 1 ? argv[1] : "-");
else
usage(1);
xc_interface_close(xch);
return 0;
}
示例13: PERROR
/* generic shared function */
static void *__getssid(int domid, uint32_t *buflen)
{
struct acm_getssid getssid;
int xc_handle;
#define SSID_BUFFER_SIZE 4096
void *buf = NULL;
if ((xc_handle = xc_interface_open()) < 0) {
goto out1;
}
if ((buf = malloc(SSID_BUFFER_SIZE)) == NULL) {
PERROR("acm.policytype: Could not allocate ssid buffer!\n");
goto out2;
}
memset(buf, 0, SSID_BUFFER_SIZE);
set_xen_guest_handle(getssid.ssidbuf, buf);
getssid.ssidbuf_size = SSID_BUFFER_SIZE;
getssid.get_ssid_by = ACM_GETBY_domainid;
getssid.id.domainid = domid;
if (xc_acm_op(xc_handle, ACMOP_getssid, &getssid, sizeof(getssid)) < 0) {
if (errno == EACCES)
PERROR("ACM operation failed.");
free(buf);
buf = NULL;
goto out2;
} else {
*buflen = SSID_BUFFER_SIZE;
goto out2;
}
out2:
xc_interface_close(xc_handle);
out1:
return buf;
}
示例14: main
int main(int argc, char **argv)
{
int err = 0;
xc_interface *xch;
int value;
if (argc != 3)
usage(argv);
value = str2bool(argv[2]);
xch = xc_interface_open(0,0,0);
if ( !xch )
{
fprintf(stderr, "Unable to create interface to xenctrl: %s\n",
strerror(errno));
err = 1;
goto done;
}
err = xc_flask_setbool(xch, argv[1], value, 1);
if (err) {
fprintf(stderr, "xc_flask_setbool: Unable to set boolean %s=%s: %s (%d)",
argv[1], argv[2], strerror(errno), err);
err = 2;
goto done;
}
done:
if ( xch )
xc_interface_close(xch);
return err;
}
示例15: xen_setup
int
xen_setup(void)
{
xs = xs_daemon_open();
if (xs == NULL) {
dolog(LOG_ERR,
"Failed to contact xenstore (%s). Is it running?",
strerror(errno));
goto out;
}
xc = xc_interface_open();
if (xc == -1) {
dolog(LOG_ERR, "Failed to contact hypervisor (%s)",
strerror(errno));
goto out;
}
if (!xs_watch(xs, DOMAIN_PATH, "backend")) {
dolog(LOG_ERR, "xenstore watch on backend fails.");
goto out;
}
return 0;
out:
if (xs)
xs_daemon_close(xs);
if (xc != -1)
xc_interface_close(xc);
return -1;
}