CAMLprim value stub_xc_domain_save(value handle, value fd, value domid, value max_iters, value max_factors, value flags, value hvm) { CAMLparam5(handle, fd, domid, max_iters, max_factors); CAMLxparam2(flags, hvm); struct save_callbacks callbacks; uint32_t c_flags; uint32_t c_domid; int r; unsigned long generation_id_addr; c_flags = caml_convert_flag_list(flags, suspend_flag_list); c_domid = _D(domid); memset(&callbacks, 0, sizeof(callbacks)); callbacks.data = (void*) c_domid; callbacks.suspend = dispatch_suspend; callbacks.switch_qemu_logdirty = switch_qemu_logdirty; caml_enter_blocking_section(); generation_id_addr = xenstore_get(c_domid, GENERATION_ID_ADDRESS); r = xc_domain_save(_H(handle), Int_val(fd), c_domid, Int_val(max_iters), Int_val(max_factors), c_flags, &callbacks, Bool_val(hvm) #ifdef XENGUEST_4_2 ,generation_id_addr #endif ); caml_leave_blocking_section(); if (r) failwith_oss_xc(_H(handle), "xc_domain_save"); CAMLreturn(Val_unit); }
static void get_flags(struct flags *f) { char * tmp; int n; f->vcpus = xenstore_get("platform/vcpu/number"); f->vcpu_affinity = malloc(sizeof(char*) * f->vcpus); for (n = 0; n < f->vcpus; n++) { f->vcpu_affinity[n] = xenstore_gets("platform/vcpu/%d/affinity", n); } f->vcpus_current = xenstore_get("platform/vcpu/current"); f->vcpu_weight = xenstore_get("platform/vcpu/weight"); f->vcpu_cap = xenstore_get("platform/vcpu/cap"); f->nx = xenstore_get("platform/nx"); f->viridian = xenstore_get("platform/viridian"); f->viridian_time_ref_count = xenstore_get("platform/viridian_time_ref_count"); f->viridian_reference_tsc = xenstore_get("platform/viridian_reference_tsc"); f->apic = xenstore_get("platform/apic"); f->pae = xenstore_get("platform/pae"); f->tsc_mode = xenstore_get("platform/tsc_mode"); f->nested_hvm = xenstore_get("platform/exp-nested-hvm"); f->cores_per_socket = xenstore_get("platform/cores-per-socket"); /* Params going to hvmloader - need to convert "true" -> '1' as Xapi gets * this wrong when migrating from older hosts. */ f->acpi = hvmloader_flag("platform/acpi"); f->acpi_s4 = hvmloader_flag("platform/acpi_s4"); f->acpi_s3 = hvmloader_flag("platform/acpi_s3"); /* * HACK - Migrated VMs wont have this xs key set, so the naive action * would result in the HPET mysteriously disappearing. If the key is not * present then enable the hpet to match its default. */ tmp = xenstore_gets("platform/hpet"); if ( tmp && strlen(tmp) ) f->hpet = xenstore_get("platform/hpet"); else f->hpet = 1; free(tmp); xg_info("Determined the following parameters from xenstore:\n"); xg_info("vcpu/number:%d vcpu/weight:%d vcpu/cap:%d\n", f->vcpus, f->vcpu_weight, f->vcpu_cap); xg_info("nx: %d, pae %d, cores-per-socket %u\n", f->nx, f->pae, f->cores_per_socket); xg_info("apic: %d acpi: %d acpi_s4: %d acpi_s3: %d tsc_mode: %d hpet: %d\n", f->apic, f->acpi, f->acpi_s4, f->acpi_s3, f->tsc_mode, f->hpet); xg_info("viridian: %d, time_ref_count: %d, reference_tsc: %d\n", f->viridian, f->viridian_time_ref_count, f->viridian_reference_tsc); for (n = 0; n < f->vcpus; n++){ xg_info("vcpu/%d/affinity:%s\n", n, (f->vcpu_affinity[n])?f->vcpu_affinity[n]:"unset"); } }
static void get_flags(struct flags *f, int domid) { int n; size_t host_pv_kernel_max_size; size_t host_pv_ramdisk_max_size; size_t vm_pv_kernel_max_size; size_t vm_pv_ramdisk_max_size; f->vcpus = xenstore_get(domid, "platform/vcpu/number"); f->vcpu_affinity = (const char**)(malloc(sizeof(char*) * f->vcpus)); for (n = 0; n < f->vcpus; n++) { f->vcpu_affinity[n] = xenstore_gets(domid, "platform/vcpu/%d/affinity", n); } f->vcpus_current = xenstore_get(domid, "platform/vcpu/current"); f->vcpu_weight = xenstore_get(domid, "platform/vcpu/weight"); f->vcpu_cap = xenstore_get(domid, "platform/vcpu/cap"); f->nx = xenstore_get(domid, "platform/nx"); f->viridian = xenstore_get(domid, "platform/viridian"); f->apic = xenstore_get(domid, "platform/apic"); f->acpi = xenstore_get(domid, "platform/acpi"); f->pae = xenstore_get(domid, "platform/pae"); f->acpi_s4 = xenstore_get(domid, "platform/acpi_s4"); f->acpi_s3 = xenstore_get(domid, "platform/acpi_s3"); f->mmio_size_mib = xenstore_get(domid, "platform/mmio_size_mib"); f->tsc_mode = xenstore_get(domid, "platform/tsc_mode"); xenstore_get_host_limits(&host_pv_kernel_max_size, &host_pv_ramdisk_max_size); vm_pv_kernel_max_size = xenstore_get(domid, "pv-kernel-max-size"); vm_pv_ramdisk_max_size = xenstore_get(domid, "pv-ramdisk-max-size"); f->kernel_max_size = vm_pv_kernel_max_size ? vm_pv_kernel_max_size : host_pv_kernel_max_size; f->ramdisk_max_size = vm_pv_ramdisk_max_size ? vm_pv_ramdisk_max_size : host_pv_ramdisk_max_size; syslog(LOG_INFO|LOG_DAEMON,"Determined the following parameters from xenstore:"); syslog(LOG_INFO|LOG_DAEMON,"vcpu/number:%d vcpu/weight:%d vcpu/cap:%d nx: %d viridian: %d apic: %d acpi: %d pae: %d acpi_s4: %d acpi_s3: %d mmio_size_mib: %ld tsc_mode %d", f->vcpus,f->vcpu_weight,f->vcpu_cap,f->nx,f->viridian,f->apic,f->acpi,f->pae,f->acpi_s4,f->acpi_s3,f->mmio_size_mib,f->tsc_mode); for (n = 0; n < f->vcpus; n++){ syslog(LOG_INFO|LOG_DAEMON,"vcpu/%d/affinity:%s", n, (f->vcpu_affinity[n])?f->vcpu_affinity[n]:"unset"); } syslog(LOG_INFO|LOG_DAEMON,"kernel/ramdisk host limits: (%zu,%zu), VM overrides: (%zu,%zu)", host_pv_kernel_max_size, host_pv_ramdisk_max_size, vm_pv_kernel_max_size, vm_pv_ramdisk_max_size); }
static void get_flags(struct flags *f, int domid) { int n; f->vcpus = xenstore_get(domid, "platform/vcpu/number"); f->vcpu_affinity = (const char**)(malloc(sizeof(char*) * f->vcpus)); for (n = 0; n < f->vcpus; n++) { f->vcpu_affinity[n] = xenstore_gets(domid, "platform/vcpu/%d/affinity", n); } f->vcpus_current = xenstore_get(domid, "platform/vcpu/current"); f->vcpu_weight = xenstore_get(domid, "platform/vcpu/weight"); f->vcpu_cap = xenstore_get(domid, "platform/vcpu/cap"); f->nx = xenstore_get(domid, "platform/nx"); f->viridian = xenstore_get(domid, "platform/viridian"); f->apic = xenstore_get(domid, "platform/apic"); f->acpi = xenstore_get(domid, "platform/acpi"); f->pae = xenstore_get(domid, "platform/pae"); f->acpi_s4 = xenstore_get(domid, "platform/acpi_s4"); f->acpi_s3 = xenstore_get(domid, "platform/acpi_s3"); f->mmio_size_mib = xenstore_get(domid, "platform/mmio_size_mib"); f->tsc_mode = xenstore_get(domid, "platform/tsc_mode"); openlog("xenguest",LOG_NDELAY,LOG_DAEMON); syslog(LOG_INFO|LOG_DAEMON,"Determined the following parameters from xenstore:"); syslog(LOG_INFO|LOG_DAEMON,"vcpu/number:%d vcpu/weight:%d vcpu/cap:%d nx: %d viridian: %d apic: %d acpi: %d pae: %d acpi_s4: %d acpi_s3: %d mmio_size_mib: %ld tsc_mode %d", f->vcpus,f->vcpu_weight,f->vcpu_cap,f->nx,f->viridian,f->apic,f->acpi,f->pae,f->acpi_s4,f->acpi_s3,f->mmio_size_mib,f->tsc_mode); for (n = 0; n < f->vcpus; n++){ syslog(LOG_INFO|LOG_DAEMON,"vcpu/%d/affinity:%s", n, (f->vcpu_affinity[n])?f->vcpu_affinity[n]:"unset"); } closelog(); }