void libxl__xc_domain_save(libxl__egc *egc, libxl__domain_save_state *dss, libxl__save_helper_state *shs) { STATE_AO_GC(dss->ao); unsigned cbflags = libxl__srm_callout_enumcallbacks_save(&shs->callbacks.save.a); const unsigned long argnums[] = { dss->domid, dss->xcflags, dss->hvm, cbflags, dss->checkpointed_stream, }; shs->ao = ao; shs->domid = dss->domid; shs->recv_callback = libxl__srm_callout_received_save; shs->completion_callback = libxl__xc_domain_save_done; shs->caller_state = dss; shs->need_results = 0; run_helper(egc, shs, "--save-domain", dss->fd, dss->recv_fd, NULL, 0, argnums, ARRAY_SIZE(argnums)); return; }
void libxl__xc_domain_save(libxl__egc *egc, libxl__domain_suspend_state *dss, unsigned long vm_generationid_addr) { STATE_AO_GC(dss->ao); int r, rc, toolstack_data_fd = -1; uint32_t toolstack_data_len = 0; /* Resources we need to free */ uint8_t *toolstack_data_buf = 0; unsigned cbflags = libxl__srm_callout_enumcallbacks_save (&dss->shs.callbacks.save.a); if (dss->shs.callbacks.save.toolstack_save) { r = dss->shs.callbacks.save.toolstack_save (dss->domid, &toolstack_data_buf, &toolstack_data_len, dss); if (r) { rc = ERROR_FAIL; goto out; } dss->shs.toolstack_data_file = tmpfile(); if (!dss->shs.toolstack_data_file) { LOGE(ERROR, "cannot create toolstack data tmpfile"); rc = ERROR_FAIL; goto out; } toolstack_data_fd = fileno(dss->shs.toolstack_data_file); r = libxl_write_exactly(CTX, toolstack_data_fd, toolstack_data_buf, toolstack_data_len, "toolstack data tmpfile", 0); if (r) { rc = ERROR_FAIL; goto out; } } const unsigned long argnums[] = { dss->domid, 0, 0, dss->xcflags, dss->hvm, vm_generationid_addr, toolstack_data_fd, toolstack_data_len, cbflags, }; dss->shs.ao = ao; dss->shs.domid = dss->domid; dss->shs.recv_callback = libxl__srm_callout_received_save; dss->shs.completion_callback = libxl__xc_domain_save_done; dss->shs.caller_state = dss; dss->shs.need_results = 0; free(toolstack_data_buf); run_helper(egc, &dss->shs, "--save-domain", dss->fd, &toolstack_data_fd, 1, argnums, ARRAY_SIZE(argnums)); return; out: free(toolstack_data_buf); if (dss->shs.toolstack_data_file) fclose(dss->shs.toolstack_data_file); libxl__xc_domain_save_done(egc, dss, rc, 0, 0); }