我想对 XCP 中的虚拟主机进行某种迁移。目前我通过使用 HTTP GET 下载文件然后使用 HTTP PUT 将其上传到另一台主机来做到这一点,这里是下载示例
curl = curl_easy_init();
//Auto escape user password
password = curl_easy_escape(curl, XEN.user_passwd, 0);
snprintf(api_req, sizeof(api_req), "http://%s:%s@%s/export?uuid=%s",
XEN.user_name, password, XEN.host_ip, uuid);
curl_free(password);
puts(api_req);
TASK_LOG(api_req);
curl_download=TRUE;
curl_easy_setopt(curl, CURLOPT_URL, api_req);
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, curl_write_func);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, xva_export);
curl_easy_setopt(curl, CURLOPT_NOPROGRESS, FALSE);
// Install the callback function
curl_easy_setopt(curl, CURLOPT_PROGRESSFUNCTION, curl_progress_func);
//And....go!
run_progress_bar = TRUE;
//g_timeout_add_seconds(1, (GSourceFunc)update_progress_bar, 0);
res = curl_easy_perform(curl);
并上传,如果需要
curl = curl_easy_init();
//Auto escape user password
char *password = curl_easy_escape(curl, XEN.user_passwd, 0);
snprintf(api_req, sizeof(api_req), "http://%s:%s@%s/import",XEN.user_name, password, XEN.host_ip);
curl_free(password);
puts(api_req);
TASK_LOG(api_req);
curl_upload=TRUE;
g_timeout_add_seconds(1, (GSourceFunc) update_progress_bar, 0);
abort_flag = 0;
curl_easy_setopt(curl, CURLOPT_URL, api_req);
curl_easy_setopt(curl, CURLOPT_READFUNCTION, export_read_callback);
curl_easy_setopt(curl, CURLOPT_UPLOAD, 1L);
curl_easy_setopt(curl, CURLOPT_PUT, 1L);
curl_easy_setopt(curl, CURLOPT_READDATA, xva);
curl_easy_setopt(curl, CURLOPT_INFILESIZE_LARGE,(curl_off_t)file_info.st_size);
curl_easy_setopt(curl, CURLOPT_NOPROGRESS, FALSE);
// Install the callback function
curl_easy_setopt(curl, CURLOPT_PROGRESSFUNCTION, curl_progress_func);
puts("Upload started");
TASK_LOG("Upload started");
CURLcode res = curl_easy_perform(curl);
我只是想知道是否可以在不下载的情况下将流量直接从一台机器传输到另一台机器?