static int hvmloader_flag(const char *key) { /* Params going to hvmloader need to convert "true" -> '1' as Xapi gets * this wrong when migrating from older hosts. */ char *val = xenstore_gets("%s",key); int ret = -1; if ( val ) { if ( !strcmp(val, "1") ) { ret = 1; goto out; } else if ( !strcmp(val, "0") ) { ret = 0; goto out; } if ( !strcasecmp(val, "true") ) ret = 1; else { errno = 0; ret = strtol(val, NULL, 0); if ( errno ) ret = 0; } xg_info("HVMLoader error: Fixing up key '%s' from '%s' to '%d'\n", key, val, ret); xenstore_putsv(key, "%d", !!ret); } else xenstore_puts(key, "0"); out: free(val); return ret; }
CAMLprim value stub_xc_domain_restore(value handle, value fd, value domid, value store_evtchn, value store_domid, value console_evtchn, value console_domid, value hvm, value no_incr_generationid) { CAMLparam5(handle, fd, domid, store_evtchn, console_evtchn); CAMLxparam1(hvm); CAMLlocal1(result); unsigned long store_mfn, console_mfn; domid_t c_store_domid, c_console_domid; unsigned long c_vm_generationid_addr; char c_vm_generationid_addr_s[32]; unsigned int c_store_evtchn, c_console_evtchn; int r; size_t size, written; struct flags f; get_flags(&f,_D(domid)); c_store_evtchn = Int_val(store_evtchn); c_store_domid = Int_val(store_domid); c_console_evtchn = Int_val(console_evtchn); c_console_domid = Int_val(console_domid); #ifdef HVM_PARAM_VIRIDIAN xc_set_hvm_param(_H(handle), _D(domid), HVM_PARAM_VIRIDIAN, f.viridian); #endif configure_vcpus(_H(handle), _D(domid), f); caml_enter_blocking_section(); r = xc_domain_restore(_H(handle), Int_val(fd), _D(domid), c_store_evtchn, &store_mfn, #ifdef XENGUEST_4_2 c_store_domid, #endif c_console_evtchn, &console_mfn, #ifdef XENGUEST_4_2 c_console_domid, #endif Bool_val(hvm), f.pae, 0 /*superpages*/ #ifdef XENGUEST_4_2 , Bool_val(no_incr_generationid), &c_vm_generationid_addr, NULL /* restore_callbacks */ #endif ); if (!r) { size = sizeof(c_vm_generationid_addr_s) - 1; /* guarantee a NULL remains on the end */ written = snprintf(c_vm_generationid_addr_s, size, "0x%lx", c_vm_generationid_addr); if (written < size) r = xenstore_puts(_D(domid), c_vm_generationid_addr_s, GENERATION_ID_ADDRESS); else { syslog(LOG_ERR|LOG_DAEMON,"Failed to write %s (%d >= %d)", GENERATION_ID_ADDRESS, written, size); r = 1; } } caml_leave_blocking_section(); if (r) failwith_oss_xc(_H(handle), "xc_domain_restore"); result = caml_alloc_tuple(2); Store_field(result, 0, caml_copy_nativeint(store_mfn)); Store_field(result, 1, caml_copy_nativeint(console_mfn)); CAMLreturn(result); }