From nobody Mon Sep 16 19:21:09 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=fail(p=none dis=none) header.from=linux.microsoft.com Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1720091670055872.6862789061249; Thu, 4 Jul 2024 04:14:30 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 91E391480; Thu, 4 Jul 2024 07:14:28 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 841931543; Thu, 4 Jul 2024 07:13:46 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id EA31313C6; Thu, 4 Jul 2024 07:13:41 -0400 (EDT) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by lists.libvirt.org (Postfix) with ESMTP id 6349E1357 for ; Thu, 4 Jul 2024 07:13:41 -0400 (EDT) Received: from paekkaladevi-dev-u22.gi4irqh5pfqublruu4yyku2wof.phxx.internal.cloudapp.net (unknown [20.125.125.171]) by linux.microsoft.com (Postfix) with ESMTPSA id E151420B7004; Thu, 4 Jul 2024 04:13:39 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_PASS autolearn=unavailable autolearn_force=no version=3.4.4 DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com E151420B7004 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1720091620; bh=msig3PTlbFGBKbPDIBOXhKy2E03gVwfQCzSx0V43hMo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ljnRPOYpS2XQFomfp7shA/fQadZCKCRV5u+gnGGQDd3827nzmYYDlUoU9wGWJI2nQ mpqqd2QT1D0O7ELPhb8xXxeKzOD49/IDpxZmZ0ok07yCrTmdicwf9LxVpqVNYjLvRi nP1rJo+Y23hcFbhzm3xoHafJzlj0MTp/pr5C84EY= From: Purna Pavan Chandra To: devel@lists.libvirt.org Subject: [PATCH v2 1/8] ch: report response message instead of just code Date: Thu, 4 Jul 2024 11:13:31 +0000 Message-Id: <20240704111338.13133-2-paekkaladevi@linux.microsoft.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240704111338.13133-1-paekkaladevi@linux.microsoft.com> References: <20240704111338.13133-1-paekkaladevi@linux.microsoft.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-ID-Hash: VPNTSEYTBJE75X5747AEW5K5KVESYAFM X-Message-ID-Hash: VPNTSEYTBJE75X5747AEW5K5KVESYAFM X-MailFrom: paekkaladevi@linux.microsoft.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; header-match-devel.lists.libvirt.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header CC: paekkaladevi@microsoft.com, prapal@linux.microsoft.com, liuwe@microsoft.com, kumarpraveen@linux.microsoft.com, Purna Pavan Chandra X-Mailman-Version: 3.2.2 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-ZohoMail-DKIM: fail (Computed bodyhash is different from the expected one) X-ZM-MESSAGEID: 1720091670444100001 Content-Type: text/plain; charset="utf-8" The response message from CH for vm.add-net api will be more helpful in debugging. Hence, log the message instead of just response code. Signed-off-by: Purna Pavan Chandra --- src/ch/ch_process.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ch/ch_process.c b/src/ch/ch_process.c index 48190a1273..6f99fec900 100644 --- a/src/ch/ch_process.c +++ b/src/ch/ch_process.c @@ -665,7 +665,7 @@ chProcessAddNetworkDevices(virCHDriver *driver, } if (http_res !=3D 204 && http_res !=3D 200) { virReportError(VIR_ERR_INTERNAL_ERROR, - _("Unexpected response from CH: %1$d"), http_re= s); + _("Unexpected response from CH: %1$s"), respons= e); return -1; } } --=20 2.34.1 From nobody Mon Sep 16 19:21:09 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=fail(p=none dis=none) header.from=linux.microsoft.com Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1720091693479149.64080457189925; Thu, 4 Jul 2024 04:14:53 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 69E871421; Thu, 4 Jul 2024 07:14:52 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 34EFC1576; Thu, 4 Jul 2024 07:13:49 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 5E1E513B3; Thu, 4 Jul 2024 07:13:42 -0400 (EDT) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by lists.libvirt.org (Postfix) with ESMTP id ADB90139E for ; Thu, 4 Jul 2024 07:13:41 -0400 (EDT) Received: from paekkaladevi-dev-u22.gi4irqh5pfqublruu4yyku2wof.phxx.internal.cloudapp.net (unknown [20.125.125.171]) by linux.microsoft.com (Postfix) with ESMTPSA id 55BAD20B7007; Thu, 4 Jul 2024 04:13:40 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_PASS autolearn=unavailable autolearn_force=no version=3.4.4 DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 55BAD20B7007 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1720091620; bh=GHrqZeLK8HWsw9lPwfIBYKcDpCDk2eBRW4YzKHRRut8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AjQqaZhJoxXwEAuZXvA4sEcVnGkdGbhfpj91Y+SO9DtwrmcmabNYoPhjdd5f24SgZ /fNXxOiK9OjIlglaLQ5QiHNkkYewPfIZS/bMoIGn9CTmirT7RdqojIVny9spM4BDx+ lX52w7qbAWBGxZxt1Hqdzw/VUMAdcI28YQ3RNhmc= From: Purna Pavan Chandra To: devel@lists.libvirt.org Subject: [PATCH v2 2/8] ch: Pass net ids explicitly during vm creation Date: Thu, 4 Jul 2024 11:13:32 +0000 Message-Id: <20240704111338.13133-3-paekkaladevi@linux.microsoft.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240704111338.13133-1-paekkaladevi@linux.microsoft.com> References: <20240704111338.13133-1-paekkaladevi@linux.microsoft.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-ID-Hash: FQIFFDIJOMIVDR3XWNLDSZ5U6UIOX3HA X-Message-ID-Hash: FQIFFDIJOMIVDR3XWNLDSZ5U6UIOX3HA X-MailFrom: paekkaladevi@linux.microsoft.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; header-match-devel.lists.libvirt.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header CC: paekkaladevi@microsoft.com, prapal@linux.microsoft.com, liuwe@microsoft.com, kumarpraveen@linux.microsoft.com, Purna Pavan Chandra X-Mailman-Version: 3.2.2 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-ZohoMail-DKIM: fail (Computed bodyhash is different from the expected one) X-ZM-MESSAGEID: 1720091694526100001 Content-Type: text/plain; charset="utf-8" Pass "net_" as net id to CH. This is to have better control over the network configs. This id can be further used in performing operations like restore etc. Signed-off-by: Purna Pavan Chandra --- src/ch/ch_monitor.c | 7 ++++++- src/ch/ch_monitor.h | 4 +++- src/ch/ch_process.c | 2 +- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/ch/ch_monitor.c b/src/ch/ch_monitor.c index 7b6b77de1c..6af5b29d82 100644 --- a/src/ch/ch_monitor.c +++ b/src/ch/ch_monitor.c @@ -278,18 +278,23 @@ virCHMonitorBuildDisksJson(virJSONValue *content, vir= DomainDef *vmdef) /** * virCHMonitorBuildNetJson: * @net: pointer to a guest network definition + * @netindex: index of the guest network definition * @jsonstr: returned network json * * Build net json to send to CH * Returns 0 on success or -1 in case of error */ int -virCHMonitorBuildNetJson(virDomainNetDef *net, char **jsonstr) +virCHMonitorBuildNetJson(virDomainNetDef *net, int netindex, char **jsonst= r) { char macaddr[VIR_MAC_STRING_BUFLEN]; g_autoptr(virJSONValue) net_json =3D virJSONValueNewObject(); virDomainNetType actualType =3D virDomainNetGetActualType(net); =20 + g_autofree char *id =3D g_strdup_printf("%s_%d", CH_NET_ID_PREFIX, net= index); + if (virJSONValueObjectAppendString(net_json, "id", id) < 0) + return -1; + if (actualType =3D=3D VIR_DOMAIN_NET_TYPE_ETHERNET && net->guestIP.nips =3D=3D 1) { const virNetDevIPAddr *ip; diff --git a/src/ch/ch_monitor.h b/src/ch/ch_monitor.h index ea6b2a771b..bac80b5fcb 100644 --- a/src/ch/ch_monitor.h +++ b/src/ch/ch_monitor.h @@ -42,6 +42,8 @@ =20 #define VIRCH_THREAD_NAME_LEN 16 =20 +#define CH_NET_ID_PREFIX "net" + typedef enum { virCHThreadTypeEmulator, virCHThreadTypeVcpu, @@ -125,4 +127,4 @@ size_t virCHMonitorGetThreadInfo(virCHMonitor *mon, boo= l refresh, int virCHMonitorGetIOThreads(virCHMonitor *mon, virDomainIOThreadInfo ***iothreads); int -virCHMonitorBuildNetJson(virDomainNetDef *netdef, char **jsonstr); +virCHMonitorBuildNetJson(virDomainNetDef *netdef, int netindex, char **jso= nstr); diff --git a/src/ch/ch_process.c b/src/ch/ch_process.c index 6f99fec900..5907a6e81f 100644 --- a/src/ch/ch_process.c +++ b/src/ch/ch_process.c @@ -621,7 +621,7 @@ chProcessAddNetworkDevices(virCHDriver *driver, nicindexes, nnicindexes) < 0) return -1; =20 - if (virCHMonitorBuildNetJson(vmdef->nets[i], &payload) < 0) { + if (virCHMonitorBuildNetJson(vmdef->nets[i], i, &payload) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Failed to build net json")); return -1; --=20 2.34.1 From nobody Mon Sep 16 19:21:09 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=fail(p=none dis=none) header.from=linux.microsoft.com Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 172009171916449.5479752967442; Thu, 4 Jul 2024 04:15:19 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 322A9154E; Thu, 4 Jul 2024 07:15:18 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 373F314DC; Thu, 4 Jul 2024 07:13:51 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 89D1513B3; Thu, 4 Jul 2024 07:13:42 -0400 (EDT) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by lists.libvirt.org (Postfix) with ESMTP id D36DA135B for ; Thu, 4 Jul 2024 07:13:41 -0400 (EDT) Received: from paekkaladevi-dev-u22.gi4irqh5pfqublruu4yyku2wof.phxx.internal.cloudapp.net (unknown [20.125.125.171]) by linux.microsoft.com (Postfix) with ESMTPSA id BE03F20B7009; Thu, 4 Jul 2024 04:13:40 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_PASS autolearn=unavailable autolearn_force=no version=3.4.4 DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com BE03F20B7009 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1720091621; bh=o9i8EBXjxmQx5ZzbmAH7L8H1RnBLDvaGVzL7vUObvr8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=I+JA6FvCOBy9lwwC5V45D1TNGKOH80qgQ+Valx/4AjGFNRbLZ2FhZDuDCciYWk9nf YsCb9r2PA4Ytg5f5ikjs8BzBUuHhICkuOvZ87Ll2soNiPfzk3IT1MxTUhNV4NkG8p8 ghgvgzcyr5F74Tdaa6XjFxWFjSywLB9z7SdoM6C8= From: Purna Pavan Chandra To: devel@lists.libvirt.org Subject: [PATCH v2 3/8] ch: refactor chProcessAddNetworkDevices Date: Thu, 4 Jul 2024 11:13:33 +0000 Message-Id: <20240704111338.13133-4-paekkaladevi@linux.microsoft.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240704111338.13133-1-paekkaladevi@linux.microsoft.com> References: <20240704111338.13133-1-paekkaladevi@linux.microsoft.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-ID-Hash: SWNNRXGFFV6HX2VAPDFGRKBIA7GXSEKA X-Message-ID-Hash: SWNNRXGFFV6HX2VAPDFGRKBIA7GXSEKA X-MailFrom: paekkaladevi@linux.microsoft.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; header-match-devel.lists.libvirt.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header CC: paekkaladevi@microsoft.com, prapal@linux.microsoft.com, liuwe@microsoft.com, kumarpraveen@linux.microsoft.com, Purna Pavan Chandra X-Mailman-Version: 3.2.2 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-ZohoMail-DKIM: fail (Computed bodyhash is different from the expected one) X-ZM-MESSAGEID: 1720091720891100001 Content-Type: text/plain; charset="utf-8" Move monitor socket connection, response handling and closing FDs code into new functions in preparation for adding restore support for net devices. Signed-off-by: Purna Pavan Chandra --- src/ch/ch_process.c | 121 +++++++++++++++++++++++++++++--------------- 1 file changed, 80 insertions(+), 41 deletions(-) diff --git a/src/ch/ch_process.c b/src/ch/ch_process.c index 5907a6e81f..1943c4381b 100644 --- a/src/ch/ch_process.c +++ b/src/ch/ch_process.c @@ -490,6 +490,47 @@ virCHProcessSetup(virDomainObj *vm) } =20 =20 +/** + * chMonitorSocketConnect: + * @mon: pointer to monitor object + * + * Connects to the monitor socket. Caller is responsible for closing the s= ocketfd + * + * Returns socket fd on success, -1 on error + */ +static int +chMonitorSocketConnect(virCHMonitor *mon) +{ + struct sockaddr_un server_addr; + int sock; + + sock =3D socket(AF_UNIX, SOCK_STREAM, 0); + if (sock < 0) { + virReportSystemError(errno, "%s", _("Failed to open a UNIX socket"= )); + return -1; + } + + memset(&server_addr, 0, sizeof(server_addr)); + server_addr.sun_family =3D AF_UNIX; + if (virStrcpyStatic(server_addr.sun_path, mon->socketpath) < 0) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("UNIX socket path '%1$s' too long"), mon->socketp= ath); + goto error; + } + + if (connect(sock, (struct sockaddr *)&server_addr, + sizeof(server_addr)) =3D=3D -1) { + virReportSystemError(errno, "%s", _("Failed to connect to mon sock= et")); + goto error; + } + + return sock; + error: + VIR_FORCE_CLOSE(sock); + return -1; +} + + #define PKT_TIMEOUT_MS 500 /* ms */ =20 static char * @@ -532,6 +573,42 @@ chSocketRecv(int sock) =20 #undef PKT_TIMEOUT_MS =20 +static int +chSocketProcessHttpResponse(int sock) +{ + g_autofree char *response =3D NULL; + int http_res; + + response =3D chSocketRecv(sock); + if (response =3D=3D NULL) { + return -1; + } + + /* Parse the HTTP response code */ + if (sscanf(response, "HTTP/1.%*d %d", &http_res) !=3D 1) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Failed to parse HTTP response code")); + return -1; + } + if (http_res !=3D 204 && http_res !=3D 200) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Unexpected response from CH: %1$s"), response); + return -1; + } + + return 0; +} + +static int +chCloseFDs(int *fds, size_t nfds) +{ + size_t i; + for (i =3D 0; i < nfds; i++) { + VIR_FORCE_CLOSE(fds[i]); + } + return 0; +} + /** * chProcessAddNetworkDevices: * @driver: pointer to ch driver object @@ -554,7 +631,6 @@ chProcessAddNetworkDevices(virCHDriver *driver, { size_t i; VIR_AUTOCLOSE mon_sockfd =3D -1; - struct sockaddr_un server_addr; g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; g_auto(virBuffer) http_headers =3D VIR_BUFFER_INITIALIZER; =20 @@ -564,25 +640,8 @@ chProcessAddNetworkDevices(virCHDriver *driver, return -1; } =20 - mon_sockfd =3D socket(AF_UNIX, SOCK_STREAM, 0); - if (mon_sockfd < 0) { - virReportSystemError(errno, "%s", _("Failed to open a UNIX socket"= )); - return -1; - } - - memset(&server_addr, 0, sizeof(server_addr)); - server_addr.sun_family =3D AF_UNIX; - if (virStrcpyStatic(server_addr.sun_path, mon->socketpath) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("UNIX socket path '%1$s' too long"), mon->socketp= ath); - return -1; - } - - if (connect(mon_sockfd, (struct sockaddr *)&server_addr, - sizeof(server_addr)) =3D=3D -1) { - virReportSystemError(errno, "%s", _("Failed to connect to mon sock= et")); + if ((mon_sockfd =3D chMonitorSocketConnect(mon)) < 0) return -1; - } =20 virBufferAddLit(&http_headers, "PUT /api/v1/vm.add-net HTTP/1.1\r\n"); virBufferAddLit(&http_headers, "Host: localhost\r\n"); @@ -592,11 +651,9 @@ chProcessAddNetworkDevices(virCHDriver *driver, g_autofree int *tapfds =3D NULL; g_autofree char *payload =3D NULL; g_autofree char *response =3D NULL; - size_t j; size_t tapfd_len; size_t payload_len; int saved_errno; - int http_res; int rc; =20 if (vmdef->nets[i]->driver.virtio.queues =3D=3D 0) { @@ -640,9 +697,7 @@ chProcessAddNetworkDevices(virCHDriver *driver, saved_errno =3D errno; =20 /* Close sent tap fds in Libvirt, as they have been dup()ed in CH = */ - for (j =3D 0; j < tapfd_len; j++) { - VIR_FORCE_CLOSE(tapfds[j]); - } + chCloseFDs(tapfds, tapfd_len); =20 if (rc < 0) { virReportSystemError(saved_errno, "%s", @@ -650,24 +705,8 @@ chProcessAddNetworkDevices(virCHDriver *driver, return -1; } =20 - /* Process the response from CH */ - response =3D chSocketRecv(mon_sockfd); - if (response =3D=3D NULL) { + if (chSocketProcessHttpResponse(mon_sockfd) < 0) return -1; - } - - /* Parse the HTTP response code */ - rc =3D sscanf(response, "HTTP/1.%*d %d", &http_res); - if (rc !=3D 1) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Failed to parse HTTP response code")); - return -1; - } - if (http_res !=3D 204 && http_res !=3D 200) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Unexpected response from CH: %1$s"), respons= e); - return -1; - } } =20 return 0; --=20 2.34.1 From nobody Mon Sep 16 19:21:09 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=fail(p=none dis=none) header.from=linux.microsoft.com Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1720091740603195.44004856341587; Thu, 4 Jul 2024 04:15:40 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 8900A1550; Thu, 4 Jul 2024 07:15:39 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id CF1CE1589; Thu, 4 Jul 2024 07:13:52 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 1668D1419; Thu, 4 Jul 2024 07:13:43 -0400 (EDT) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by lists.libvirt.org (Postfix) with ESMTP id 95C8C1357 for ; Thu, 4 Jul 2024 07:13:42 -0400 (EDT) Received: from paekkaladevi-dev-u22.gi4irqh5pfqublruu4yyku2wof.phxx.internal.cloudapp.net (unknown [20.125.125.171]) by linux.microsoft.com (Postfix) with ESMTPSA id 3278120B700B; Thu, 4 Jul 2024 04:13:41 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_PASS autolearn=unavailable autolearn_force=no version=3.4.4 DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 3278120B700B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1720091621; bh=r6OTMSOAPtIv9IVMxZs25C3naBEqIW7R/Ob7yVJOTAw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UAefyO/KE1azn1aN21OwOnKDWLvpLeibaLGqcgyJi4PuoBD84LcjyzDYw1syg6ZBu PfKrDNq3n+IGMub5LoD+HHbUjpil6JbAd9ivKlkUMY61NBl1mrJM+gSVQb604KgYRm WZzZyvx4G/vhwk9sxyEUF18KPR2gmBSqxruxHx90= From: Purna Pavan Chandra To: devel@lists.libvirt.org Subject: [PATCH v2 4/8] ch: support poll with -1 in chSocketRecv Date: Thu, 4 Jul 2024 11:13:34 +0000 Message-Id: <20240704111338.13133-5-paekkaladevi@linux.microsoft.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240704111338.13133-1-paekkaladevi@linux.microsoft.com> References: <20240704111338.13133-1-paekkaladevi@linux.microsoft.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-ID-Hash: G4CQ75XNZKZP5OW3S7A4K2A4JRCGQ5PV X-Message-ID-Hash: G4CQ75XNZKZP5OW3S7A4K2A4JRCGQ5PV X-MailFrom: paekkaladevi@linux.microsoft.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; header-match-devel.lists.libvirt.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header CC: paekkaladevi@microsoft.com, prapal@linux.microsoft.com, liuwe@microsoft.com, kumarpraveen@linux.microsoft.com, Purna Pavan Chandra X-Mailman-Version: 3.2.2 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-ZohoMail-DKIM: fail (Computed bodyhash is different from the expected one) X-ZM-MESSAGEID: 1720091741162100001 Content-Type: text/plain; charset="utf-8" chSocketRecv fn can be used by operations such as restore, which cannot have a specific poll timeout. The runtime of these operations at server side (vmm) cannot be determined or capped as it depends on the guest configuration. Hence, add a new parameter 'use_timeout' which when set will pass -1 as timeout to poll, otherwise the default PKT_TIMEOUT_MS is used. Signed-off-by: Purna Pavan Chandra --- src/ch/ch_process.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/ch/ch_process.c b/src/ch/ch_process.c index 1943c4381b..851ab7545c 100644 --- a/src/ch/ch_process.c +++ b/src/ch/ch_process.c @@ -534,11 +534,12 @@ chMonitorSocketConnect(virCHMonitor *mon) #define PKT_TIMEOUT_MS 500 /* ms */ =20 static char * -chSocketRecv(int sock) +chSocketRecv(int sock, bool use_timeout) { struct pollfd pfds[1]; char *buf =3D NULL; size_t buf_len =3D 1024; + int timeout =3D PKT_TIMEOUT_MS; int ret; =20 buf =3D g_new0(char, buf_len); @@ -546,8 +547,11 @@ chSocketRecv(int sock) pfds[0].fd =3D sock; pfds[0].events =3D POLLIN; =20 + if (!use_timeout) + timeout =3D -1; + do { - ret =3D poll(pfds, G_N_ELEMENTS(pfds), PKT_TIMEOUT_MS); + ret =3D poll(pfds, G_N_ELEMENTS(pfds), timeout); } while (ret < 0 && errno =3D=3D EINTR); =20 if (ret <=3D 0) { @@ -574,12 +578,12 @@ chSocketRecv(int sock) #undef PKT_TIMEOUT_MS =20 static int -chSocketProcessHttpResponse(int sock) +chSocketProcessHttpResponse(int sock, bool use_poll_timeout) { g_autofree char *response =3D NULL; int http_res; =20 - response =3D chSocketRecv(sock); + response =3D chSocketRecv(sock, use_poll_timeout); if (response =3D=3D NULL) { return -1; } @@ -705,7 +709,7 @@ chProcessAddNetworkDevices(virCHDriver *driver, return -1; } =20 - if (chSocketProcessHttpResponse(mon_sockfd) < 0) + if (chSocketProcessHttpResponse(mon_sockfd, true) < 0) return -1; } =20 --=20 2.34.1 From nobody Mon Sep 16 19:21:09 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=fail(p=none dis=none) header.from=linux.microsoft.com Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1720091766341119.20122681097189; Thu, 4 Jul 2024 04:16:06 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 2B2081580; Thu, 4 Jul 2024 07:16:05 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 9A03A1551; Thu, 4 Jul 2024 07:13:55 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 1C9EF1357; Thu, 4 Jul 2024 07:13:43 -0400 (EDT) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by lists.libvirt.org (Postfix) with ESMTP id 6EF181359 for ; Thu, 4 Jul 2024 07:13:42 -0400 (EDT) Received: from paekkaladevi-dev-u22.gi4irqh5pfqublruu4yyku2wof.phxx.internal.cloudapp.net (unknown [20.125.125.171]) by linux.microsoft.com (Postfix) with ESMTPSA id 9BBF820B7004; Thu, 4 Jul 2024 04:13:41 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_PASS autolearn=unavailable autolearn_force=no version=3.4.4 DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 9BBF820B7004 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1720091621; bh=D9If4dKuWkJvMMSQNcCmmRDeBH/ocPZFS9/O70Jjusk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fmlTg/GIJZ0nbVsQhVeBWWx4Lx0k9iRBkIPZctV9p9oAJFMzaQCo/VlO1zraQiBqy NWhEfOlMfxg6nUngALctBLgkkymZOD3h9zCo5gryeLOtV3SiapyKDIq4lO1BZCTsie fpiC1Y21FFOQNXJwn3n55KiJKn1nTfbeVQvtKOQI= From: Purna Pavan Chandra To: devel@lists.libvirt.org Subject: [PATCH v2 5/8] ch: use monitor socket fd to send restore request Date: Thu, 4 Jul 2024 11:13:35 +0000 Message-Id: <20240704111338.13133-6-paekkaladevi@linux.microsoft.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240704111338.13133-1-paekkaladevi@linux.microsoft.com> References: <20240704111338.13133-1-paekkaladevi@linux.microsoft.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-ID-Hash: 2HSKBP7PXDGLJXZZ5ICVPPX4SFH76LP6 X-Message-ID-Hash: 2HSKBP7PXDGLJXZZ5ICVPPX4SFH76LP6 X-MailFrom: paekkaladevi@linux.microsoft.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; header-match-devel.lists.libvirt.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header CC: paekkaladevi@microsoft.com, prapal@linux.microsoft.com, liuwe@microsoft.com, kumarpraveen@linux.microsoft.com, Purna Pavan Chandra X-Mailman-Version: 3.2.2 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-ZohoMail-DKIM: fail (Computed bodyhash is different from the expected one) X-ZM-MESSAGEID: 1720091767065100001 Content-Type: text/plain; charset="utf-8" Instead of curl, use low-level socket connections to make restore api request to CH. This will enable passing new net FDs to CH while restoring domains with network configuration. Signed-off-by: Purna Pavan Chandra --- src/ch/ch_monitor.c | 13 +++++++++++-- src/ch/ch_monitor.h | 2 +- src/ch/ch_process.c | 40 ++++++++++++++++++++++++++++++++++------ 3 files changed, 46 insertions(+), 9 deletions(-) diff --git a/src/ch/ch_monitor.c b/src/ch/ch_monitor.c index 6af5b29d82..0875887fd8 100644 --- a/src/ch/ch_monitor.c +++ b/src/ch/ch_monitor.c @@ -991,9 +991,18 @@ virCHMonitorSaveVM(virCHMonitor *mon, const char *to) } =20 int -virCHMonitorRestoreVM(virCHMonitor *mon, const char *from) +virCHMonitorBuildRestoreJson(const char *from, char **jsonstr) { - return virCHMonitorSaveRestoreVM(mon, from, false); + g_autoptr(virJSONValue) restore_json =3D virJSONValueNewObject(); + + g_autofree char *path_url =3D g_strdup_printf("file://%s", from); + if (virJSONValueObjectAppendString(restore_json, "source_url", path_ur= l)) + return -1; + + if (!(*jsonstr =3D virJSONValueToString(restore_json, false))) + return -1; + + return 0; } =20 /** diff --git a/src/ch/ch_monitor.h b/src/ch/ch_monitor.h index bac80b5fcb..375b7a49a4 100644 --- a/src/ch/ch_monitor.h +++ b/src/ch/ch_monitor.h @@ -115,7 +115,6 @@ int virCHMonitorRebootVM(virCHMonitor *mon); int virCHMonitorSuspendVM(virCHMonitor *mon); int virCHMonitorResumeVM(virCHMonitor *mon); int virCHMonitorSaveVM(virCHMonitor *mon, const char *to); -int virCHMonitorRestoreVM(virCHMonitor *mon, const char *from); int virCHMonitorGetInfo(virCHMonitor *mon, virJSONValue **info); =20 void virCHMonitorCPUInfoFree(virCHMonitorCPUInfo *cpus); @@ -128,3 +127,4 @@ int virCHMonitorGetIOThreads(virCHMonitor *mon, virDomainIOThreadInfo ***iothreads); int virCHMonitorBuildNetJson(virDomainNetDef *netdef, int netindex, char **jso= nstr); +int virCHMonitorBuildRestoreJson(const char *from, char **jsonstr); diff --git a/src/ch/ch_process.c b/src/ch/ch_process.c index 851ab7545c..0ac0a5c9a2 100644 --- a/src/ch/ch_process.c +++ b/src/ch/ch_process.c @@ -912,6 +912,12 @@ virCHProcessStartRestore(virCHDriver *driver, virDomai= nObj *vm, const char *from { virCHDomainObjPrivate *priv =3D vm->privateData; g_autoptr(virCHDriverConfig) cfg =3D virCHDriverGetConfig(priv->driver= ); + g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) http_headers =3D VIR_BUFFER_INITIALIZER; + g_autofree char *payload =3D NULL; + g_autofree char *response =3D NULL; + VIR_AUTOCLOSE mon_sockfd =3D -1; + size_t payload_len; =20 if (!priv->monitor) { /* Get the first monitor connection if not already */ @@ -926,12 +932,6 @@ virCHProcessStartRestore(virCHDriver *driver, virDomai= nObj *vm, const char *from vm->def->id =3D vm->pid; priv->machineName =3D virCHDomainGetMachineName(vm); =20 - if (virCHMonitorRestoreVM(priv->monitor, from) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("failed to restore domain")); - return -1; - } - /* Pass 0, NULL as restore only works without networking support */ if (virDomainCgroupSetupCgroup("ch", vm, 0, NULL, /* nnicindexes, nicindexes */ @@ -942,6 +942,34 @@ virCHProcessStartRestore(virCHDriver *driver, virDomai= nObj *vm, const char *from priv->machineName) < 0) return -1; =20 + if (virCHMonitorBuildRestoreJson(from, &payload) < 0) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("failed to restore domain")); + return -1; + } + + virBufferAddLit(&http_headers, "PUT /api/v1/vm.restore HTTP/1.1\r\n"); + virBufferAddLit(&http_headers, "Host: localhost\r\n"); + virBufferAddLit(&http_headers, "Content-Type: application/json\r\n"); + virBufferAsprintf(&buf, "%s", virBufferCurrentContent(&http_headers)); + virBufferAsprintf(&buf, "Content-Length: %ld\r\n\r\n", strlen(payload)= ); + virBufferAsprintf(&buf, "%s", payload); + payload_len =3D virBufferUse(&buf); + payload =3D virBufferContentAndReset(&buf); + + if ((mon_sockfd =3D chMonitorSocketConnect(priv->monitor)) < 0) + return -1; + + if (virSocketSendMsgWithFDs(mon_sockfd, payload, payload_len, NULL, 0)= < 0) { + virReportSystemError(errno, "%s", + _("Failed to send restore request to CH")); + return -1; + } + + /* Restore is a syncronous operationin CH. so, pass false to wait unti= l there's a reponse */ + if (chSocketProcessHttpResponse(mon_sockfd, false) < 0) + return -1; + if (virCHProcessSetup(vm) < 0) return -1; =20 --=20 2.34.1 From nobody Mon Sep 16 19:21:09 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=fail(p=none dis=none) header.from=linux.microsoft.com Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1720091815132529.1806248275063; Thu, 4 Jul 2024 04:16:55 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 0DE3B1515; Thu, 4 Jul 2024 07:16:54 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id A92FB1599; Thu, 4 Jul 2024 07:13:58 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 0916E135B; Thu, 4 Jul 2024 07:13:44 -0400 (EDT) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by lists.libvirt.org (Postfix) with ESMTP id 6B26013B3 for ; Thu, 4 Jul 2024 07:13:43 -0400 (EDT) Received: from paekkaladevi-dev-u22.gi4irqh5pfqublruu4yyku2wof.phxx.internal.cloudapp.net (unknown [20.125.125.171]) by linux.microsoft.com (Postfix) with ESMTPSA id 105A620B7007; Thu, 4 Jul 2024 04:13:42 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_PASS autolearn=unavailable autolearn_force=no version=3.4.4 DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 105A620B7007 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1720091622; bh=3eBV4cZ8bxhKYaIb8eH1UiShwoAgp2Fu46VInmPq0Ug=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=h+dlODDZSegPkfMVizx9YL1VWP7KAbJ4D+yVy5dnDpsGdsZm+3ZSzhRs683Y4Kyoi 9yU9jDUsu0u9/TpzaM/ej2izl/LCuzvgqLm1OoCkIuFZDWYyE9BjCNeQFLJQlf0bmj AJvbd4VEOYDqRpxYNW8IpORtNYaMTbH5YFDWZ7xk= From: Purna Pavan Chandra To: devel@lists.libvirt.org Subject: [PATCH v2 6/8] ch: refactor virCHMonitorSaveVM Date: Thu, 4 Jul 2024 11:13:36 +0000 Message-Id: <20240704111338.13133-7-paekkaladevi@linux.microsoft.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240704111338.13133-1-paekkaladevi@linux.microsoft.com> References: <20240704111338.13133-1-paekkaladevi@linux.microsoft.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-ID-Hash: WQTBKMPNMB2ATOMD73NQYNPJZVQOLEXV X-Message-ID-Hash: WQTBKMPNMB2ATOMD73NQYNPJZVQOLEXV X-MailFrom: paekkaladevi@linux.microsoft.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; header-match-devel.lists.libvirt.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header CC: paekkaladevi@microsoft.com, prapal@linux.microsoft.com, liuwe@microsoft.com, kumarpraveen@linux.microsoft.com, Purna Pavan Chandra X-Mailman-Version: 3.2.2 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-ZohoMail-DKIM: fail (Computed bodyhash is different from the expected one) X-ZM-MESSAGEID: 1720091815285100001 Content-Type: text/plain; charset="utf-8" Remove the unwanted utility function and make api calls directly from virCHMonitorSaveVM fn Signed-off-by: Purna Pavan Chandra --- src/ch/ch_monitor.c | 27 +++++++-------------------- 1 file changed, 7 insertions(+), 20 deletions(-) diff --git a/src/ch/ch_monitor.c b/src/ch/ch_monitor.c index 0875887fd8..8d8be1f46e 100644 --- a/src/ch/ch_monitor.c +++ b/src/ch/ch_monitor.c @@ -925,8 +925,8 @@ virCHMonitorResumeVM(virCHMonitor *mon) return virCHMonitorPutNoContent(mon, URL_VM_RESUME); } =20 -static int -virCHMonitorSaveRestoreVM(virCHMonitor *mon, const char *path, bool save) +int +virCHMonitorSaveVM(virCHMonitor *mon, const char *to) { g_autofree char *url =3D NULL; int responseCode =3D 0; @@ -936,22 +936,15 @@ virCHMonitorSaveRestoreVM(virCHMonitor *mon, const ch= ar *path, bool save) struct curl_slist *headers =3D NULL; struct curl_data data =3D {0}; =20 - if (save) - url =3D g_strdup_printf("%s/%s", URL_ROOT, URL_VM_SAVE); - else - url =3D g_strdup_printf("%s/%s", URL_ROOT, URL_VM_RESTORE); + url =3D g_strdup_printf("%s/%s", URL_ROOT, URL_VM_SAVE); =20 headers =3D curl_slist_append(headers, "Accept: application/json"); headers =3D curl_slist_append(headers, "Content-Type: application/json= "); =20 - path_url =3D g_strdup_printf("file://%s", path); - if (save) { - if (virCHMonitorBuildKeyValueStringJson(&payload, "destination_url= ", path_url) !=3D 0) - return -1; - } else { - if (virCHMonitorBuildKeyValueStringJson(&payload, "source_url", pa= th_url) !=3D 0) - return -1; - } + path_url =3D g_strdup_printf("file://%s", to); + if (virCHMonitorBuildKeyValueStringJson(&payload, "destination_url", p= ath_url) !=3D 0) + return -1; + =20 VIR_WITH_OBJECT_LOCK_GUARD(mon) { /* reset all options of a libcurl session handle at first */ @@ -984,12 +977,6 @@ virCHMonitorSaveRestoreVM(virCHMonitor *mon, const cha= r *path, bool save) return ret; } =20 -int -virCHMonitorSaveVM(virCHMonitor *mon, const char *to) -{ - return virCHMonitorSaveRestoreVM(mon, to, true); -} - int virCHMonitorBuildRestoreJson(const char *from, char **jsonstr) { --=20 2.34.1 From nobody Mon Sep 16 19:21:09 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=fail(p=none dis=none) header.from=linux.microsoft.com Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1720091848818856.0724300233902; Thu, 4 Jul 2024 04:17:28 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 98ED21540; Thu, 4 Jul 2024 07:17:27 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 84C4E156B; Thu, 4 Jul 2024 07:14:00 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 1CBBF139E; Thu, 4 Jul 2024 07:13:44 -0400 (EDT) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by lists.libvirt.org (Postfix) with ESMTP id 392EB1359 for ; Thu, 4 Jul 2024 07:13:43 -0400 (EDT) Received: from paekkaladevi-dev-u22.gi4irqh5pfqublruu4yyku2wof.phxx.internal.cloudapp.net (unknown [20.125.125.171]) by linux.microsoft.com (Postfix) with ESMTPSA id 78CE920B700D; Thu, 4 Jul 2024 04:13:42 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_PASS autolearn=unavailable autolearn_force=no version=3.4.4 DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 78CE920B700D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1720091622; bh=eH+a6iA+7pEfEkn2zij2mww9/z2GWOwQEWijVgSt1T0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fhfiakS/Gvl0NH8QMPh9ZkuYJc7wEgZaAXKoLqJfFmm66+aRFXsXGzfkK9jQsoZbw hoaPOD7gxw5kQheeytYsAblgDEe4rta6lJdltOHh9bN6qg81Imsc0nqWHULmyYbENM BYZoyffxALxW0RZ9PrRI1Y/eCs7MU+ACCjR7Kmt4= From: Purna Pavan Chandra To: devel@lists.libvirt.org Subject: [PATCH v2 7/8] ch: support restore with net devices Date: Thu, 4 Jul 2024 11:13:37 +0000 Message-Id: <20240704111338.13133-8-paekkaladevi@linux.microsoft.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240704111338.13133-1-paekkaladevi@linux.microsoft.com> References: <20240704111338.13133-1-paekkaladevi@linux.microsoft.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-ID-Hash: 6BH5BU23Q73SKTCZBENIKC3QIM4YIDUN X-Message-ID-Hash: 6BH5BU23Q73SKTCZBENIKC3QIM4YIDUN X-MailFrom: paekkaladevi@linux.microsoft.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; header-match-devel.lists.libvirt.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header CC: paekkaladevi@microsoft.com, prapal@linux.microsoft.com, liuwe@microsoft.com, kumarpraveen@linux.microsoft.com, Purna Pavan Chandra X-Mailman-Version: 3.2.2 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-ZohoMail-DKIM: fail (Computed bodyhash is different from the expected one) X-ZM-MESSAGEID: 1720091849480100001 Content-Type: text/plain; charset="utf-8" Cloud-hypervisor now supports restoring with new net fds. Ref: https://github.com/cloud-hypervisor/cloud-hypervisor/pull/6402 So, pass new tap fds via SCM_RIGHTS to CH's restore api. Signed-off-by: Purna Pavan Chandra --- src/ch/ch_capabilities.c | 6 +++ src/ch/ch_capabilities.h | 1 + src/ch/ch_driver.c | 29 +++++++----- src/ch/ch_monitor.c | 21 ++++++++- src/ch/ch_monitor.h | 2 +- src/ch/ch_process.c | 98 +++++++++++++++++++++++++++++++++------- 6 files changed, 126 insertions(+), 31 deletions(-) diff --git a/src/ch/ch_capabilities.c b/src/ch/ch_capabilities.c index 5941851500..f3765a8095 100644 --- a/src/ch/ch_capabilities.c +++ b/src/ch/ch_capabilities.c @@ -65,6 +65,12 @@ virCHCapsInitCHVersionCaps(int version) if (version >=3D 36000000) virCHCapsSet(chCaps, CH_SOCKET_BACKEND_SERIAL_PORT); =20 + /* Starting v40, Cloud-Hypervisor supports restore with new net fds. + * This is required to be able to restore a guest with network config = define. + * https://github.com/cloud-hypervisor/cloud-hypervisor/releases/tag/v= 40.0 */ + if (version >=3D 40000000) + virCHCapsSet(chCaps, CH_RESTORE_WITH_NEW_TAPFDS); + return g_steal_pointer(&chCaps); =20 } diff --git a/src/ch/ch_capabilities.h b/src/ch/ch_capabilities.h index 03932511f6..e5efb14b68 100644 --- a/src/ch/ch_capabilities.h +++ b/src/ch/ch_capabilities.h @@ -28,6 +28,7 @@ typedef enum { CH_SERIAL_CONSOLE_IN_PARALLEL, /* Serial and Console ports can work in= parallel */ CH_MULTIFD_IN_ADDNET, /* Cloud-hypervisor can accept multiple FDs in a= dd-net api */ CH_SOCKET_BACKEND_SERIAL_PORT, /* Support Unix socket as a backend for= a serial port */ + CH_RESTORE_WITH_NEW_TAPFDS, /* Cloud-hypervisor support for restore wi= th new net fds */ =20 CH_CAPS_LAST /* this must always be the last item */ } virCHCapsFlags; diff --git a/src/ch/ch_driver.c b/src/ch/ch_driver.c index fbeac60825..24aed471c5 100644 --- a/src/ch/ch_driver.c +++ b/src/ch/ch_driver.c @@ -680,22 +680,24 @@ chDomainDestroy(virDomainPtr dom) } =20 static int -chDomainSaveAdditionalValidation(virDomainDef *vmdef) +chDomainSaveRestoreAdditionalValidation(virCHDriver *driver, virDomainDef = *vmdef) { - /* - SAVE and RESTORE are functional only without any networking and - device passthrough configuration - */ - if (vmdef->nnets > 0) { - virReportError(VIR_ERR_OPERATION_INVALID, "%s", - _("cannot save domain with network interfaces")); - return -1; - } + /* SAVE and RESTORE are functional only without any host device + * passthrough configuration */ if (vmdef->nhostdevs > 0) { virReportError(VIR_ERR_OPERATION_INVALID, "%s", - _("cannot save domain with host devices")); + _("cannot save/restore domain with host devices")); return -1; } + + if (vmdef->nnets > 0) { + if (!virBitmapIsBitSet(driver->chCaps, CH_RESTORE_WITH_NEW_TAPFDS)= ) { + virReportError(VIR_ERR_OPERATION_INVALID, "%s", + _("cannot save/restore domain with network devi= ces")); + return -1; + } + } + return 0; } =20 @@ -728,7 +730,7 @@ chDoDomainSave(virCHDriver *driver, VIR_AUTOCLOSE fd =3D -1; int ret =3D -1; =20 - if (chDomainSaveAdditionalValidation(vm->def) < 0) + if (chDomainSaveRestoreAdditionalValidation(driver, vm->def) < 0) goto end; =20 domainState =3D virDomainObjGetState(vm, NULL); @@ -1087,6 +1089,9 @@ chDomainRestoreFlags(virConnectPtr conn, if (virDomainRestoreFlagsEnsureACL(conn, def) < 0) goto cleanup; =20 + if (chDomainSaveRestoreAdditionalValidation(driver, def) < 0) + goto cleanup; + if (!(vm =3D virDomainObjListAdd(driver->domains, &def, driver->xmlopt, VIR_DOMAIN_OBJ_LIST_ADD_LIVE | diff --git a/src/ch/ch_monitor.c b/src/ch/ch_monitor.c index 8d8be1f46e..3af5e7f2d1 100644 --- a/src/ch/ch_monitor.c +++ b/src/ch/ch_monitor.c @@ -978,14 +978,31 @@ virCHMonitorSaveVM(virCHMonitor *mon, const char *to) } =20 int -virCHMonitorBuildRestoreJson(const char *from, char **jsonstr) +virCHMonitorBuildRestoreJson(virDomainDef *vmdef, const char *from, char *= *jsonstr) { + size_t i; g_autoptr(virJSONValue) restore_json =3D virJSONValueNewObject(); - g_autofree char *path_url =3D g_strdup_printf("file://%s", from); + if (virJSONValueObjectAppendString(restore_json, "source_url", path_ur= l)) return -1; =20 + /* Pass the netconfig needed to restore with new netfds */ + if (vmdef->nnets) { + g_autoptr(virJSONValue) nets =3D virJSONValueNewArray(); + for (i =3D 0; i < vmdef->nnets; i++) { + g_autoptr(virJSONValue) net_json =3D virJSONValueNewObject(); + g_autofree char *id =3D g_strdup_printf("%s_%ld", CH_NET_ID_PR= EFIX, i); + if (virJSONValueObjectAppendString(net_json, "id", id) < 0) + return -1; + if (virJSONValueObjectAppendNumberInt(net_json, "num_fds", vmd= ef->nets[i]->driver.virtio.queues)) + return -1; + virJSONValueArrayAppend(nets, &net_json); + } + if (virJSONValueObjectAppend(restore_json, "net_fds", &nets)) + return -1; + } + if (!(*jsonstr =3D virJSONValueToString(restore_json, false))) return -1; =20 diff --git a/src/ch/ch_monitor.h b/src/ch/ch_monitor.h index 375b7a49a4..02a6685d58 100644 --- a/src/ch/ch_monitor.h +++ b/src/ch/ch_monitor.h @@ -127,4 +127,4 @@ int virCHMonitorGetIOThreads(virCHMonitor *mon, virDomainIOThreadInfo ***iothreads); int virCHMonitorBuildNetJson(virDomainNetDef *netdef, int netindex, char **jso= nstr); -int virCHMonitorBuildRestoreJson(const char *from, char **jsonstr); +int virCHMonitorBuildRestoreJson(virDomainDef *vmdef, const char *from, ch= ar **jsonstr); diff --git a/src/ch/ch_process.c b/src/ch/ch_process.c index 0ac0a5c9a2..540bf6801d 100644 --- a/src/ch/ch_process.c +++ b/src/ch/ch_process.c @@ -29,6 +29,7 @@ #include "ch_process.h" #include "domain_cgroup.h" #include "domain_interface.h" +#include "viralloc.h" #include "virerror.h" #include "virfile.h" #include "virjson.h" @@ -716,6 +717,56 @@ chProcessAddNetworkDevices(virCHDriver *driver, return 0; } =20 +/** + * virCHRestoreCreateNetworkDevices: + * @driver: pointer to driver structure + * @vmdef: pointer to domain definition + * @vmtapfds: returned array of FDs of guest interfaces + * @nvmtapfds: returned number of network indexes + * @nicindexes: returned array of network indexes + * @nnicindexes: returned number of network indexes + * + * Create network devices for the domain. This function is called during + * domain restore. + * + * Returns 0 on success or -1 in case of error +*/ +static int +virCHRestoreCreateNetworkDevices(virCHDriver *driver, + virDomainDef *vmdef, + int **vmtapfds, + size_t *nvmtapfds, + int **nicindexes, + size_t *nnicindexes) +{ + size_t i, j; + size_t tapfd_len; + size_t index_vmtapfds; + for (i =3D 0; i < vmdef->nnets; i++) { + g_autofree int *tapfds =3D NULL; + tapfd_len =3D vmdef->nets[i]->driver.virtio.queues; + if (virCHDomainValidateActualNetDef(vmdef->nets[i]) < 0) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("net definition failed validation")); + return -1; + } + tapfds =3D g_new0(int, tapfd_len); + memset(tapfds, -1, (tapfd_len) * sizeof(int)); + + /* Connect Guest interfaces */ + if (virCHConnetNetworkInterfaces(driver, vmdef, vmdef->nets[i], ta= pfds, + nicindexes, nnicindexes) < 0) + return -1; + + index_vmtapfds =3D *nvmtapfds; + VIR_EXPAND_N(*vmtapfds, *nvmtapfds, tapfd_len); + for (j =3D 0; j < tapfd_len; j++) { + VIR_APPEND_ELEMENT_INPLACE(*vmtapfds, index_vmtapfds, tapfds[j= ]); + } + } + return 0; +} + /** * virCHProcessStartValidate: * @driver: pointer to driver structure @@ -917,7 +968,12 @@ virCHProcessStartRestore(virCHDriver *driver, virDomai= nObj *vm, const char *from g_autofree char *payload =3D NULL; g_autofree char *response =3D NULL; VIR_AUTOCLOSE mon_sockfd =3D -1; + g_autofree int *tapfds =3D NULL; + g_autofree int *nicindexes =3D NULL; size_t payload_len; + size_t ntapfds =3D 0; + size_t nnicindexes =3D 0; + int ret =3D -1; =20 if (!priv->monitor) { /* Get the first monitor connection if not already */ @@ -932,17 +988,7 @@ virCHProcessStartRestore(virCHDriver *driver, virDomai= nObj *vm, const char *from vm->def->id =3D vm->pid; priv->machineName =3D virCHDomainGetMachineName(vm); =20 - /* Pass 0, NULL as restore only works without networking support */ - if (virDomainCgroupSetupCgroup("ch", vm, - 0, NULL, /* nnicindexes, nicindexes */ - &priv->cgroup, - cfg->cgroupControllers, - 0, /*maxThreadsPerProc*/ - priv->driver->privileged, - priv->machineName) < 0) - return -1; - - if (virCHMonitorBuildRestoreJson(from, &payload) < 0) { + if (virCHMonitorBuildRestoreJson(vm->def, from, &payload) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("failed to restore domain")); return -1; @@ -960,20 +1006,40 @@ virCHProcessStartRestore(virCHDriver *driver, virDom= ainObj *vm, const char *from if ((mon_sockfd =3D chMonitorSocketConnect(priv->monitor)) < 0) return -1; =20 - if (virSocketSendMsgWithFDs(mon_sockfd, payload, payload_len, NULL, 0)= < 0) { + if (virCHRestoreCreateNetworkDevices(driver, vm->def, &tapfds, &ntapfd= s, &nicindexes, &nnicindexes) < 0) + goto cleanup; + + if (virDomainCgroupSetupCgroup("ch", vm, + nnicindexes, nicindexes, + &priv->cgroup, + cfg->cgroupControllers, + 0, /*maxThreadsPerProc*/ + priv->driver->privileged, + priv->machineName) < 0) + goto cleanup; + + /* Bring up netdevs before restoring vm */ + if (virDomainInterfaceStartDevices(vm->def) < 0) + goto cleanup; + + if (virSocketSendMsgWithFDs(mon_sockfd, payload, payload_len, tapfds, = ntapfds) < 0) { virReportSystemError(errno, "%s", _("Failed to send restore request to CH")); - return -1; + goto cleanup; } =20 /* Restore is a syncronous operationin CH. so, pass false to wait unti= l there's a reponse */ if (chSocketProcessHttpResponse(mon_sockfd, false) < 0) - return -1; + goto cleanup; =20 if (virCHProcessSetup(vm) < 0) - return -1; + goto cleanup; =20 virDomainObjSetState(vm, VIR_DOMAIN_PAUSED, VIR_DOMAIN_PAUSED_FROM_SNA= PSHOT); + ret =3D 0; =20 - return 0; + cleanup: + if (tapfds) + chCloseFDs(tapfds, ntapfds); + return ret; } --=20 2.34.1 From nobody Mon Sep 16 19:21:09 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=fail(p=none dis=none) header.from=linux.microsoft.com Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1720091865437588.2521453203284; Thu, 4 Jul 2024 04:17:45 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 5FA7513B3; Thu, 4 Jul 2024 07:17:44 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 5C7B015AE; Thu, 4 Jul 2024 07:14:03 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 2B3771359; Thu, 4 Jul 2024 07:13:44 -0400 (EDT) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by lists.libvirt.org (Postfix) with ESMTP id 96B411419 for ; Thu, 4 Jul 2024 07:13:43 -0400 (EDT) Received: from paekkaladevi-dev-u22.gi4irqh5pfqublruu4yyku2wof.phxx.internal.cloudapp.net (unknown [20.125.125.171]) by linux.microsoft.com (Postfix) with ESMTPSA id E19E820B7004; Thu, 4 Jul 2024 04:13:42 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_PASS autolearn=unavailable autolearn_force=no version=3.4.4 DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com E19E820B7004 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1720091623; bh=I1K2eDul6QRcfWJiawKvduAivM47+wRQsPw7VQI6B2Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=elfaImOCfmTNKuaXTOxliPwL7L+hqQA0/Ox49W8TnrcQIzCKw9enpH8YIzO3On1ma MedP5JHjJ6QGwtJTAnkVaRFh5yyXKTU+rgWHvFzbJv+f9N+ZSUfl9z3qcBrEkC4ev8 CUr6dK4WBYbcsL5kIGjLMNQthK8YoJpo0TsfmQcw= From: Purna Pavan Chandra To: devel@lists.libvirt.org Subject: [PATCH v2 8/8] ch: kill CH process if restore fails Date: Thu, 4 Jul 2024 11:13:38 +0000 Message-Id: <20240704111338.13133-9-paekkaladevi@linux.microsoft.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240704111338.13133-1-paekkaladevi@linux.microsoft.com> References: <20240704111338.13133-1-paekkaladevi@linux.microsoft.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-ID-Hash: BOEUBUPRDPDVSVNOWKVXCFWERBZWA5MC X-Message-ID-Hash: BOEUBUPRDPDVSVNOWKVXCFWERBZWA5MC X-MailFrom: paekkaladevi@linux.microsoft.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; header-match-devel.lists.libvirt.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header CC: paekkaladevi@microsoft.com, prapal@linux.microsoft.com, liuwe@microsoft.com, kumarpraveen@linux.microsoft.com, Purna Pavan Chandra X-Mailman-Version: 3.2.2 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-ZohoMail-DKIM: fail (Computed bodyhash is different from the expected one) X-ZM-MESSAGEID: 1720091867480100001 Content-Type: text/plain; charset="utf-8" Invoke virCHProcessStop to kill CH process incase of any failures during restore operation. Signed-off-by: Purna Pavan Chandra --- src/ch/ch_process.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/ch/ch_process.c b/src/ch/ch_process.c index 540bf6801d..b77ab97a9f 100644 --- a/src/ch/ch_process.c +++ b/src/ch/ch_process.c @@ -980,7 +980,7 @@ virCHProcessStartRestore(virCHDriver *driver, virDomain= Obj *vm, const char *from if (!(priv->monitor =3D virCHProcessConnectMonitor(driver, vm))) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("failed to create connection to CH socket")); - return -1; + goto cleanup; } } =20 @@ -991,7 +991,7 @@ virCHProcessStartRestore(virCHDriver *driver, virDomain= Obj *vm, const char *from if (virCHMonitorBuildRestoreJson(vm->def, from, &payload) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("failed to restore domain")); - return -1; + goto cleanup; } =20 virBufferAddLit(&http_headers, "PUT /api/v1/vm.restore HTTP/1.1\r\n"); @@ -1004,7 +1004,7 @@ virCHProcessStartRestore(virCHDriver *driver, virDoma= inObj *vm, const char *from payload =3D virBufferContentAndReset(&buf); =20 if ((mon_sockfd =3D chMonitorSocketConnect(priv->monitor)) < 0) - return -1; + goto cleanup; =20 if (virCHRestoreCreateNetworkDevices(driver, vm->def, &tapfds, &ntapfd= s, &nicindexes, &nnicindexes) < 0) goto cleanup; @@ -1041,5 +1041,7 @@ virCHProcessStartRestore(virCHDriver *driver, virDoma= inObj *vm, const char *from cleanup: if (tapfds) chCloseFDs(tapfds, ntapfds); + if (ret) + virCHProcessStop(driver, vm, VIR_DOMAIN_SHUTOFF_FAILED); return ret; } --=20 2.34.1