From nobody Wed Nov 27 08:30:10 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=redhat.com Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1723123911834225.4233939094995; Thu, 8 Aug 2024 06:31:51 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id B41D912AA; Thu, 8 Aug 2024 09:31:50 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id C377CE3A; Thu, 8 Aug 2024 09:31:29 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id C2B69A4C; Thu, 8 Aug 2024 09:31:26 -0400 (EDT) Received: from mx2.osci.io (francine.osci.io [8.43.85.230]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id EBC8B9F1 for ; Thu, 8 Aug 2024 09:31:25 -0400 (EDT) Received: by mx2.osci.io (Postfix, from userid 995) id EE1263FDA7; Thu, 8 Aug 2024 08:15:57 -0400 (EDT) Received: from mx3.osci.io (carla.osci.io [IPv6:2607:f0d0:1e02:35::3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-256)) (No client certificate requested) by mx2.osci.io (Postfix) with ESMTPS id 94CCE3FD76 for ; Thu, 8 Aug 2024 08:15:53 -0400 (EDT) Received: by mx3.osci.io (Postfix, from userid 990) id 5B7C130727A4; Thu, 8 Aug 2024 06:49:11 -0500 (CDT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (3072 bits) server-digest SHA256) (No client certificate requested) by mx3.osci.io (Postfix) with ESMTPS id DEB863072439 for ; Thu, 8 Aug 2024 06:49:09 -0500 (CDT) Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-464-BJeHqvIhNuqWBlpPKx4VCg-1; Thu, 08 Aug 2024 07:41:47 -0400 Received: from mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.40]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id BBBFE1944A87 for ; Thu, 8 Aug 2024 11:41:46 +0000 (UTC) Received: from orkuz (unknown [10.43.3.115]) by mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 49C5719560AA for ; Thu, 8 Aug 2024 11:41:46 +0000 (UTC) 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_NONE autolearn=unavailable autolearn_force=no version=3.4.4 X-Greylist: delayed 302 seconds by postgrey-1.37 at francine.osci.io; Thu, 08 Aug 2024 08:15:53 EDT X-Greylist: delayed 253 seconds by postgrey-1.37 at carla.osci.io; Thu, 08 Aug 2024 06:49:09 CDT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1723117562; h=from:from: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: in-reply-to:in-reply-to:references:references; bh=fAda+ipG2Dy/GoQWz3/LtAQ8Cj1pRFMUAGRK5G5Sn3M=; b=Wr6FjezcPbVNA8ZRjRJRFrFXWHvyfGsWlNcyAyM1wsYwmRLeYSnxtdaq7580E4vixPaBfJ Xdeq6XrXkbo7GEl9XBSOTVImKyMr0bk7xn3bj/4MBsd3UKa0MNEhpaVPigDa0CsVOKHPQv C6Y3ue9mbk+cyGACfN20oPtOLgUGExw= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1723117577; h=from:from: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: in-reply-to:in-reply-to:references:references; bh=fAda+ipG2Dy/GoQWz3/LtAQ8Cj1pRFMUAGRK5G5Sn3M=; b=WXcwl0WhcewcifaYvuR8idYZZrrujda+H2mmNHjLZGimW9hMdY08oU47055w4pLMpF7NGe GUylLwKbwIVzYs7WKz+QQg1cCC4oaD6ZpF5I1ArMlKi3n9ccUS4klsriUVMD8W6XcFrV7H 8jxi/J97TkayRSFV1ZUqZsqI0FHUbPw= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1723117706; h=from:from: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: in-reply-to:in-reply-to:references:references; bh=fAda+ipG2Dy/GoQWz3/LtAQ8Cj1pRFMUAGRK5G5Sn3M=; b=giTrJb7ksgxTuRv8FY4fIufwj9qWQrTq1G0FGssiCJ1TGpaEWAIgcAMIchpXxmVAIKm5Vd xw/jIEi+/88XD1AefaG+FCkHupuQEH9L/1vbMIA1qZAplFDwRexs8bT93TXTGR2/urgT3J SLecqpvVgmVxGwr5saeBS8cztQWP8Bw= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1723117749; h=from:from: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: in-reply-to:in-reply-to:references:references; bh=fAda+ipG2Dy/GoQWz3/LtAQ8Cj1pRFMUAGRK5G5Sn3M=; b=Z1yzYE8Azvs1FQhuD7y11McsuVZl8UnxVzlDu7UkA20mwnkmMjY1YnfRQ1Ma5NGsHhSA+X ZVj9e/liIH/mFrDASvGYYcx6BgUdoPkhE+bM4Aw6RICYBLsmYxuyXmJ9tPf8GpfEWz1SU0 SjB6BTHFoASBGXASlzPbmYOEzgbMCng= X-MC-Unique: BJeHqvIhNuqWBlpPKx4VCg-1 From: Jiri Denemark To: devel@lists.libvirt.org Subject: [PATCH 2/2] qemu: Avoid false failure when resuming post-copy migration Date: Thu, 8 Aug 2024 13:41:04 +0200 Message-ID: <16b9b585a3f67901bc1980d79988c458cf34833a.1723117197.git.jdenemar@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.40 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: EYQWAAFKNTFK2VYFBWQRZW76U2APEL73 X-Message-ID-Hash: EYQWAAFKNTFK2VYFBWQRZW76U2APEL73 X-MailFrom: jdenemar@redhat.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 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 (found 4 invalid signatures) X-ZM-MESSAGEID: 1723123912872116600 Content-Type: text/plain; charset="utf-8" Depending on timing between QEMU and libvirt an attempt to resume failed post-copy migration could immediately report a failure in post-copy phase again even though the migration actually resumed and is progressing just fine. This is caused by QEMU reporting the original migration state (i.e., postcopy-paused) until migration is successfully resumed and QEMU switches to postcopy-active. QEMU 9.1 introduced a new postcopy-recover-setup migration state which is entered immediately after requesting migration to be resumed and we can reliably wait for the migration to either continue or fail without being confused by the old state. https://issues.redhat.com/browse/RHEL-22166 Signed-off-by: Jiri Denemark --- src/qemu/qemu_migration.c | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index 4f02a9a053..7f905f8584 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -1962,6 +1962,7 @@ enum qemuMigrationCompletedFlags { QEMU_MIGRATION_COMPLETED_CHECK_STORAGE =3D (1 << 1), QEMU_MIGRATION_COMPLETED_POSTCOPY =3D (1 << 2), QEMU_MIGRATION_COMPLETED_PRE_SWITCHOVER =3D (1 << 3), + QEMU_MIRGATION_COMPLETED_RECOVERY =3D (1 << 4), }; =20 =20 @@ -2023,6 +2024,16 @@ qemuMigrationAnyCompleted(virDomainObj *vm, return 1; } =20 + /* When QEMU is new enough to enter postcopy-recover-setup state during + * post-copy recovery, the source waits for the recovery to start + * before letting the destination wait for migration to complete. + */ + if (flags & QEMU_MIRGATION_COMPLETED_RECOVERY && + jobData->status =3D=3D VIR_DOMAIN_JOB_STATUS_POSTCOPY) { + VIR_DEBUG("Post-copy recovery active"); + return 1; + } + if (jobData->status =3D=3D VIR_DOMAIN_JOB_STATUS_HYPERVISOR_COMPLETED) return 1; else @@ -5115,6 +5126,7 @@ qemuMigrationSrcResume(virDomainObj *vm, char **cookieout, int *cookieoutlen, qemuMigrationSpec *spec, + virConnectPtr dconn, unsigned int flags) { qemuDomainObjPrivate *priv =3D vm->privateData; @@ -5145,6 +5157,17 @@ qemuMigrationSrcResume(virDomainObj *vm, if (rc < 0) return -1; =20 + /* Wait for postcopy recovery to start (or fail) if QEMU is new enough= to + * support postcopy-recover-setup migration state. */ + if (priv->migrationRecoverSetup) { + VIR_DEBUG("Waiting for post-copy recovery to start"); + if (qemuMigrationSrcWaitForCompletion(vm, VIR_ASYNC_JOB_MIGRATION_= OUT, dconn, + QEMU_MIRGATION_COMPLETED_REC= OVERY) < 0) + return -1; + } else { + VIR_WARN("QEMU is too old, we may report a failure in post-copy ph= ase even though the migration may be running just fine"); + } + if (qemuMigrationCookieFormat(mig, driver, vm, QEMU_MIGRATION_SOURCE, cookieout, cookieoutlen, @@ -5249,7 +5272,7 @@ qemuMigrationSrcPerformNative(virQEMUDriver *driver, =20 if (flags & VIR_MIGRATE_POSTCOPY_RESUME) { ret =3D qemuMigrationSrcResume(vm, migParams, cookiein, cookieinle= n, - cookieout, cookieoutlen, &spec, flags= ); + cookieout, cookieoutlen, &spec, dconn= , flags); } else { ret =3D qemuMigrationSrcRun(driver, vm, xmlin, persist_xml, cookie= in, cookieinlen, cookieout, cookieoutlen, flags, resource, --=20 2.45.2