From nobody Sun Feb 8 10:49:22 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=quarantine dis=quarantine) header.from=suse.com ARC-Seal: i=1; a=rsa-sha256; t=1688761095; cv=none; d=zohomail.com; s=zohoarc; b=OK0+h6F0Gah41/4zTxCGcrh9xR+RBMwVQXVoqG01E6x2lfyekTyxxlpOtdUorJZyBB1jpulkAt7TVYmmxML/Ld7FnJCgtnBbFyAkdTGw71WnuTOQRAdjP4p0/zTg/qN1AhSRvOSdy3V+Ya1J0VKoPeiF0KDVe9h+6ttinDsZ1Po= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1688761095; h=Content-Type:Content-Transfer-Encoding:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=+hmnHfXL4AuBs3Z68amOwIPdWSbh6D6XXShna6I0aCk=; b=DMTcqldBuQEC3Fsn/dxzZZWbl1VicVdH/kQGYsRqBsTEm+k2Git+jWiaM0MYSCYkZ/BGdJJstYfpTUt2z07WNECCo1usJKaCNLKAupdEZnMZMnUsD7LRP0CEPRsnT7ec6XnwCkyOPGXSyJr93SYXu3DGVncDHshQzVF9ERWOka0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail header.from= (p=quarantine dis=quarantine) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1688761095367438.0469421987351; Fri, 7 Jul 2023 13:18:15 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-539-e66XfhCrMzqjeI1ZWDKvLA-1; Fri, 07 Jul 2023 16:18:10 -0400 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 20EAF800969; Fri, 7 Jul 2023 20:18:08 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 971F3492B01; Fri, 7 Jul 2023 20:18:05 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 52DF01946A5A; Fri, 7 Jul 2023 20:18:05 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 95EE81946A54 for ; Fri, 7 Jul 2023 20:18:04 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 464591454151; Fri, 7 Jul 2023 20:18:04 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast08.extmail.prod.ext.rdu2.redhat.com [10.11.55.24]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 3E02A1454150 for ; Fri, 7 Jul 2023 20:18:04 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-2.mimecast.com [207.211.31.81]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 1C6E93803509 for ; Fri, 7 Jul 2023 20:18:04 +0000 (UTC) Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on2051.outbound.protection.outlook.com [40.107.22.51]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-103-TwJw5Rv5PwSEWL8vMt6y-w-1; Fri, 07 Jul 2023 16:18:02 -0400 Received: from DB7PR04MB5980.eurprd04.prod.outlook.com (2603:10a6:10:88::11) by AM8PR04MB7811.eurprd04.prod.outlook.com (2603:10a6:20b:236::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6565.25; Fri, 7 Jul 2023 20:18:00 +0000 Received: from DB7PR04MB5980.eurprd04.prod.outlook.com ([fe80::8209:a05f:7b01:24c0]) by DB7PR04MB5980.eurprd04.prod.outlook.com ([fe80::8209:a05f:7b01:24c0%5]) with mapi id 15.20.6565.016; Fri, 7 Jul 2023 20:17:59 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1688761094; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=+hmnHfXL4AuBs3Z68amOwIPdWSbh6D6XXShna6I0aCk=; b=GT7ERo69HStxFgghVj40ghsNtkrp4eC5l3Bs1uiLQvlNnxnLTXGfF+PIWjOhwxsH6/Zsia kODqx3tKw3znPpfUsNTZs4bX7KPyA6hXJAK765ry8MdYNRVPwAoZ87zm0dXBHCcNdtasSS oFg9sr2V4bgDy0tZNuc+XUOSTKCeWGc= X-MC-Unique: e66XfhCrMzqjeI1ZWDKvLA-1 X-Original-To: libvir-list@listman.corp.redhat.com X-MC-Unique: TwJw5Rv5PwSEWL8vMt6y-w-1 From: Jim Fehlig To: libvir-list@redhat.com Subject: [PATCH] libxl: Defer starting job until migration perform phase Date: Fri, 7 Jul 2023 14:17:43 -0600 Message-ID: <20230707201754.17060-1-jfehlig@suse.com> X-ClientProxiedBy: MW4PR03CA0044.namprd03.prod.outlook.com (2603:10b6:303:8e::19) To DB7PR04MB5980.eurprd04.prod.outlook.com (2603:10a6:10:88::11) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DB7PR04MB5980:EE_|AM8PR04MB7811:EE_ X-MS-Office365-Filtering-Correlation-Id: 2824e63f-ce12-445c-dbb8-08db7f27425e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0 X-Microsoft-Antispam-Message-Info: vSilQb4BkXRmQhHVPpbTgBSR/2E/SxVrz0A7dUbC0f00stngJqyG7Y6dZgT4FiJnlZyXNhNY7LKdNcQJHHvzdc9OLTl4pSmaCvU8DVQAre0mq50BYf67GMOBBFld5PMn+fzB8Ft7rawDXyka1SHfzf436jwLbhvLgcs6fruQpt1vrAO8AzGE9BAicZL1t0enLUEfTxfD1KdTY8mHoKnp5or9JBIpb31vdryNM58NvJ3eKDVWHBsOdVh5svKDb6YDz1Sn1W9MSQ7E99BkAwtuJ9tqdJqeGU2SRJOWEPM9a8Y4xQ0tOR9UuI6fsacXD6giG0g0VD//W7rezwzncvepDRZqrv8ofhPpqF5mI5Zze9m/grkAf1n7nUSv7RAnYUyIRM6yZMUvkrUCwF83bWeAyNUOGmaE4CiXssNDn7mOck5Vg9WfHh9Qc6w4R0qV/jWIYzQobgu1PZgANEN7gAdwzogaebeOwVKxydpKFc/G4ajAIytQLouo+u+igaWVcZWh2rVV8NPM+xLmVefsov4VOqHqwWeF3OhTvQLGOumJwL8c8xWIvJPiAq+vyt0rU6Wc X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DB7PR04MB5980.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230028)(136003)(396003)(346002)(39860400002)(376002)(366004)(451199021)(8676002)(83380400001)(2616005)(2906002)(6916009)(6486002)(66476007)(66556008)(66946007)(316002)(6666004)(478600001)(5660300002)(6512007)(6506007)(186003)(1076003)(26005)(41300700001)(8936002)(38100700002)(36756003)(86362001); DIR:OUT; SFP:1101 X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?Ui2VBQoJN/7Lhu1ZvW7jIlpOcXhjDoPALNtGnSNPvQKPowdgl73q/JPYj8O3?= =?us-ascii?Q?TTM9iaZKF4N8A9QRk/0C/YOIZ/FsmMHu72fZvVZIAkQDBjn6UPoC+Jx9rkDN?= =?us-ascii?Q?0EVDKXNrmaenmgo8raZlnkPPpL6n7Byf083ULna9SeS3BV9yhZtzNppSQyX2?= =?us-ascii?Q?MKnN5Xb1lVgnXt9MdAMjuqsJ7ciJJIk4ML/MdQD8MtH0w9VqyTFpUg4iTawR?= =?us-ascii?Q?90NZT88SAHofVEo5SGomFDh7HoDLnwfEpznbrEM6zlKf+ffg+WY/qD6QmCsZ?= =?us-ascii?Q?rkl7bO9XGFMHVMd330wXiutRXwC+F8t1Dgu0jggv3Kxlc1lV90DBUhefotws?= =?us-ascii?Q?khokYlVXjF8HvsB1f77cnaIEhK0dbEVWELXW33PXlkcgEoTi4136+xopkQ6U?= =?us-ascii?Q?+WrEh257+h+EJFtdgWG9IbgSsib/krSCgdLCb28ofZesfAYKkhC3G2h/UNIf?= =?us-ascii?Q?EYDryaNH3f9/mqKFN+4BAKHP5aYPRzJdpSqLRbdMCKYl2AH6CN3tch2dfkAE?= =?us-ascii?Q?Hannk9eimrg48Cc8vZCoiHDKAN1KGSjlHb/ReAeNcn2r0vYjKQFQ+dRXMlxF?= =?us-ascii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nApnqa5WzipSSkeJaZ4?= =?us-ascii?Q?Vi/mSMMXI1kYPK9V/drCgSjtqNVaIycrYCSDcn+auK0Ovz1XyGYtbweTbNoe?= =?us-ascii?Q?q2NE9o6jNmvR8k8guUk8YE8BE9J8jEkaJUN0usFS?= X-OriginatorOrg: suse.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2824e63f-ce12-445c-dbb8-08db7f27425e X-MS-Exchange-CrossTenant-AuthSource: DB7PR04MB5980.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Jul 2023 20:17:59.9399 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: f7a17af6-1c5c-4a36-aa8b-f5be247aa4ba X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: SLjtLjNz9SgOWTIjQ6aYvLUvQDKJNnSUigknkbWTGX3mmvHegU+18xo3o/5v3NfWBWy7x/1CUbLnbvreqXIobg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM8PR04MB7811 X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: suse.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1688761095888100001 Content-Type: text/plain; charset="utf-8" Currently the libxl driver calls virDomainObjBeginJob in the begin phase of migration on the source host, expecting to call virDomainObjEndJob in the confirm phase. But the confirm phase is never executed if the prepare or perform phases fail. The job was already being terminated in the perform phase in case of failure, but there is no way to do that if the prepare phase fails since it runs on the destination host. Move the call to virDomainObjBeginJob to the perform phase. It can be terminated there in the event of failure. On success, the confirm phase will be executed, ensuring the job is terminated. Signed-off-by: Jim Fehlig --- src/libxl/libxl_migration.c | 37 +++++++++++++++---------------------- 1 file changed, 15 insertions(+), 22 deletions(-) diff --git a/src/libxl/libxl_migration.c b/src/libxl/libxl_migration.c index 961815f9f7..126265f895 100644 --- a/src/libxl/libxl_migration.c +++ b/src/libxl/libxl_migration.c @@ -378,19 +378,11 @@ libxlDomainMigrationSrcBegin(virConnectPtr conn, virDomainDef *def; char *xml =3D NULL; =20 - /* - * In the case of successful migration, a job is started here and - * terminated in the confirm phase. Errors in the begin or perform - * phase will also terminate the job. - */ - if (virDomainObjBeginJob(vm, VIR_JOB_MODIFY) < 0) - goto cleanup; - if (!(mig =3D libxlMigrationCookieNew(vm))) - goto endjob; + goto cleanup; =20 if (libxlMigrationBakeCookie(mig, cookieout, cookieoutlen) < 0) - goto endjob; + goto cleanup; =20 if (xmlin) { if (!(tmpdef =3D virDomainDefParseString(xmlin, @@ -398,10 +390,10 @@ libxlDomainMigrationSrcBegin(virConnectPtr conn, NULL, VIR_DOMAIN_DEF_PARSE_INACTI= VE | VIR_DOMAIN_DEF_PARSE_SKIP_V= ALIDATE))) - goto endjob; + goto cleanup; =20 if (!libxlDomainDefCheckABIStability(driver, vm->def, tmpdef)) - goto endjob; + goto cleanup; =20 def =3D tmpdef; } else { @@ -409,15 +401,9 @@ libxlDomainMigrationSrcBegin(virConnectPtr conn, } =20 if (!libxlDomainMigrationIsAllowed(def)) - goto endjob; + goto cleanup; =20 xml =3D virDomainDefFormat(def, driver->xmlopt, VIR_DOMAIN_DEF_FORMAT_= SECURE); - /* Valid xml means success! EndJob in the confirm phase */ - if (xml) - goto cleanup; - - endjob: - virDomainObjEndJob(vm); =20 cleanup: libxlMigrationCookieFree(mig); @@ -1209,6 +1195,13 @@ libxlDomainMigrationSrcPerform(libxlDriverPrivate *d= river, sockfd =3D virNetSocketDupFD(sock, true); virObjectUnref(sock); =20 + /* + * Start a job for the migration and terminate it in the confirm + * phase, taking care to handle error cases. + */ + if (virDomainObjBeginJob(vm, VIR_JOB_MODIFY) < 0) + return -1; + /* suspend vm and send saved data to dst through socket fd */ virObjectUnlock(vm); ret =3D libxlDoMigrateSrcSend(driver, vm, flags, sockfd); @@ -1223,8 +1216,8 @@ libxlDomainMigrationSrcPerform(libxlDriverPrivate *dr= iver, } } else { /* - * Confirm phase will not be executed if perform fails. End the - * job started in begin phase. + * End the job since the confirm phase will not be executed if + * perform fails. */ virDomainObjEndJob(vm); } @@ -1383,7 +1376,7 @@ libxlDomainMigrationSrcConfirm(libxlDriverPrivate *dr= iver, ret =3D 0; =20 cleanup: - /* EndJob for corresponding BeginJob in begin phase */ + /* EndJob for corresponding BeginJob in perform phase */ virDomainObjEndJob(vm); virObjectEventStateQueue(driver->domainEventState, event); virObjectUnref(cfg); --=20 2.41.0