From nobody Tue Jan 21 04:09:19 2025 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 17369336603781023.8257264787833; Wed, 15 Jan 2025 01:34:20 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id BA85B1357; Wed, 15 Jan 2025 04:34:19 -0500 (EST) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 15EA012F8; Wed, 15 Jan 2025 04:33:56 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id C81431268; Wed, 15 Jan 2025 04:33:53 -0500 (EST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (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 438E211BE for ; Wed, 15 Jan 2025 04:33:53 -0500 (EST) Received: from mx-prod-mc-01.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-487-l0RIRe9EO-ykC9ysitXmCQ-1; Wed, 15 Jan 2025 04:33:50 -0500 Received: from mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.15]) (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-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 2F33419560BB for ; Wed, 15 Jan 2025 09:33:50 +0000 (UTC) Received: from orkuz (unknown [10.43.3.115]) by mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id AE2AD195608A for ; Wed, 15 Jan 2025 09:33:49 +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.5 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, RCVD_IN_VALIDITY_RPBL_BLOCKED,RCVD_IN_VALIDITY_SAFE_BLOCKED, SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=3.4.4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1736933632; 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; bh=42IS8FR7tI2hCWzFoPLYJkyKfqeA6fLD76nI2uRfBTI=; b=Gx3z77/oDPI/aPIXdQEuVEok2Z0cQM6+Dl3Kbs1HIZf6X1UGlKOSsGqp3/UkUZsnAzfviS y9JUXGWlNzApJb3dBx7iFZnDsC+nQGxCLaUfJwwQnRA90cvfyAVp/B5/qTFhLVedXWjTVp qVifrK/kr34umv4OdCentliF3ZWdoS0= X-MC-Unique: l0RIRe9EO-ykC9ysitXmCQ-1 X-Mimecast-MFC-AGG-ID: l0RIRe9EO-ykC9ysitXmCQ From: Jiri Denemark To: devel@lists.libvirt.org Subject: [PATCH] qemu: Report error from both sides of migration Date: Wed, 15 Jan 2025 10:33:40 +0100 Message-ID: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.15 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: oYZz4fxK353Lk1tlV0-yVC3RHMb8Xdz9Ji8EnDHjpDI_1736933630 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: CZCRSFQE2MOQQ5TVQORQ4ESKROOFLM4A X-Message-ID-Hash: CZCRSFQE2MOQQ5TVQORQ4ESKROOFLM4A 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 (Header signature does not verify) X-ZM-MESSAGEID: 1736933663811019000 Content-Type: text/plain; charset="utf-8" When migration fails in Perform phase, we call Finish on the destination host with cancelled=3D1 and get the error from there and report it to the user. This works well if the error on the destination caused the migration to fail. But in other cases the main error may reported by the source and the destination would just be complaining about broken migration stream. In other words, we don't really know which error caused the migration to fail and we have no way of detecting that. So instead of choosing one error, this patch will combine the error messages from both sides of migration into a single message and report it to the user. The result would be, for example: operation failed: migration failed. Message from the source host: operation failed: job 'migration out' failed: Certificate does not match the hostname ble.bla. Message from the destination host: operation failed: job 'migration in' failed: load of migration failed: Invalid argument And yes, this is ugly, but I wasn't able to come up with a better way of fixing this issue. https://issues.redhat.com/browse/RHEL-58933 Signed-off-by: Jiri Denemark Reviewed-by: J=C3=A1n Tomko --- src/libvirt-domain.c | 26 +++++++++++++------------- src/qemu/qemu_migration.c | 26 +++++++++++++------------- 2 files changed, 26 insertions(+), 26 deletions(-) diff --git a/src/libvirt-domain.c b/src/libvirt-domain.c index e8e5379672..efccafc4d2 100644 --- a/src/libvirt-domain.c +++ b/src/libvirt-domain.c @@ -3430,26 +3430,26 @@ virDomainMigrateVersion3Full(virDomainPtr domain, if (ddomain) { VIR_ERROR(_("finish step ignored that migration was cancelled"= )); } else { - /* If Finish reported a useful error, use it instead of the - * original "migration unexpectedly failed" error. + virErrorPtr err =3D virGetLastError(); + /* When both Confirm and Finish reported an error in QEMU driv= er, + * we don't really know which error is the root cause. Let's r= eport + * both errors to the user. * * This is ugly but we can't do better with the APIs we have. = We * only replace the error if Finish was called with cancelled = =3D=3D 1 * and reported a real error (old libvirt would report an error - * from RPC instead of MIGRATE_FINISH_OK), which only happens = when - * the domain died on destination. To further reduce a possibi= lity - * of false positives we also check that Perform returned - * VIR_ERR_OPERATION_FAILED. + * from RPC instead of MIGRATE_FINISH_OK). */ if (orig_err && orig_err->domain =3D=3D VIR_FROM_QEMU && - orig_err->code =3D=3D VIR_ERR_OPERATION_FAILED) { - virErrorPtr err =3D virGetLastError(); - if (err && - err->domain =3D=3D VIR_FROM_QEMU && - err->code !=3D VIR_ERR_MIGRATE_FINISH_OK) { - g_clear_pointer(&orig_err, virFreeError); - } + orig_err->code =3D=3D VIR_ERR_OPERATION_FAILED && + err && + err->domain =3D=3D VIR_FROM_QEMU && + err->code !=3D VIR_ERR_MIGRATE_FINISH_OK) { + virReportError(VIR_ERR_OPERATION_FAILED, + _("migration failed. Message from the sourc= e host: %1$s. Message from the destination host: %2$s"), + orig_err->message, err->message); + g_clear_pointer(&orig_err, virFreeError); } } } diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index 1582a738a3..8c0e522828 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -5904,26 +5904,26 @@ qemuMigrationSrcPerformPeer2Peer3(virQEMUDriver *dr= iver, if (ddomain) { VIR_ERROR(_("finish step ignored that migration was cancelled"= )); } else { - /* If Finish reported a useful error, use it instead of the - * original "migration unexpectedly failed" error. + virErrorPtr err =3D virGetLastError(); + /* When both Confirm and Finish reported an error in QEMU driv= er, + * we don't really know which error is the root cause. Let's r= eport + * both errors to the user. * * This is ugly but we can't do better with the APIs we have. = We * only replace the error if Finish was called with cancelled = =3D=3D 1 * and reported a real error (old libvirt would report an error - * from RPC instead of MIGRATE_FINISH_OK), which only happens = when - * the domain died on destination. To further reduce a possibi= lity - * of false positives we also check that Perform returned - * VIR_ERR_OPERATION_FAILED. + * from RPC instead of MIGRATE_FINISH_OK). */ if (orig_err && orig_err->domain =3D=3D VIR_FROM_QEMU && - orig_err->code =3D=3D VIR_ERR_OPERATION_FAILED) { - virErrorPtr err =3D virGetLastError(); - if (err && - err->domain =3D=3D VIR_FROM_QEMU && - err->code !=3D VIR_ERR_MIGRATE_FINISH_OK) { - g_clear_pointer(&orig_err, virFreeError); - } + orig_err->code =3D=3D VIR_ERR_OPERATION_FAILED && + err && + err->domain =3D=3D VIR_FROM_QEMU && + err->code !=3D VIR_ERR_MIGRATE_FINISH_OK) { + virReportError(VIR_ERR_OPERATION_FAILED, + _("migration failed. Message from the sourc= e host: %1$s. Message from the destination host: %2$s"), + orig_err->message, err->message); + g_clear_pointer(&orig_err, virFreeError); } } } --=20 2.47.1