From nobody Mon Feb 9 01:44:24 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.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.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1671115082; cv=none; d=zohomail.com; s=zohoarc; b=Z3tUAMa6Zjp6Xr+RsS6XMb/LaeKrUtCuJPSztBlNGa1HdTiehv7ugSQbSElUxN1v5CuWRDTx/xGU04tcprYdWi72Mw5OA05IVXSdM6D3AJesHbfN7SLA2RaU5SYHrWdGOnRZZeJtuJT8OVwhXCKDUOvd3Iv1HHBY1gYZD6QL38E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1671115082; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=X0ai4Cb6MqijOPjCT+6SAL1Rg1pDtNbKRUL9EzyyPco=; b=aqG07u7Z6ODGk0TFOCy84Vp7wFwxZhQ4VocUW8UTiNPUvMC5PNK5phyXEO0ib3YPz1YKeqCy2860YDn5BI4zMNVXCZlFrs2THRhpLJP6MNhkzdA/p5TSQL9D9LzkDABN3obqSSVLLX85JDfwOEyS7iTjdrSNTZkzITFlOjKkcRE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1671115082017835.4322595705553; Thu, 15 Dec 2022 06:38:02 -0800 (PST) Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-608-30LtdudSOdGcYrNGr-yPzQ-1; Thu, 15 Dec 2022 09:37:56 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 6A9E938123AB; Thu, 15 Dec 2022 14:37:52 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 521432026D2B; Thu, 15 Dec 2022 14:37:52 +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 524AA19466DF; Thu, 15 Dec 2022 14:37:51 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 6588F1946A6F for ; Thu, 15 Dec 2022 14:37:49 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 44A24492C18; Thu, 15 Dec 2022 14:37:49 +0000 (UTC) Received: from virval.usersys.redhat.com (unknown [10.43.2.227]) by smtp.corp.redhat.com (Postfix) with ESMTP id 05A22492C14 for ; Thu, 15 Dec 2022 14:37:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1671115080; 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: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=X0ai4Cb6MqijOPjCT+6SAL1Rg1pDtNbKRUL9EzyyPco=; b=PO7muv8dQRRQxPmxGoNPJjt7PGoRpuXUsDFhte4t3uQYzJ1KjD7FeB1Hchh7+KoPBNeEqh rx7xypx7dvDcdLtZMaKjl4Dr2uSdI3lm0cn3yF6XawpmuhfIqAX/+B6gPqCbT4RE307vOY DLpxzcsdAp9Q7VVBmGRR46qSdCHWgls= X-MC-Unique: 30LtdudSOdGcYrNGr-yPzQ-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Jiri Denemark To: libvir-list@redhat.com Subject: [libvirt PATCH 1/4] conf: Drop virDomainJobOperation parameter from virDomainObjIsPostcopy Date: Thu, 15 Dec 2022 15:37:41 +0100 Message-Id: <8fb5ca49e2cb6cede344e45145f58cd1570e31f2.1671114079.git.jdenemar@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 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.4 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1671115083536100002 Content-Type: text/plain; charset="utf-8" The parameter was only used to select which states correspond to an active or failed post-copy migration. But these states are either applicable to both operations or the check would just paper over a code bug in case of an impossible combination of state and operation. By dropping the check we can make the code simpler and also reuse existing virDomainObjIsFailedPostcopy function and only check for active post-copy states. Signed-off-by: Jiri Denemark Reviewed-by: Michal Privoznik --- src/conf/domain_conf.c | 23 +++++++---------------- src/conf/domain_conf.h | 3 +-- src/qemu/qemu_driver.c | 4 ++-- src/qemu/qemu_migration.c | 6 +++--- src/qemu/qemu_process.c | 6 +++--- 5 files changed, 16 insertions(+), 26 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index a180398b14..d1def730a4 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -27883,24 +27883,15 @@ virDomainObjIsFailedPostcopy(virDomainObj *dom) =20 =20 bool -virDomainObjIsPostcopy(virDomainObj *dom, - virDomainJobOperation op) +virDomainObjIsPostcopy(virDomainObj *dom) { - if (op !=3D VIR_DOMAIN_JOB_OPERATION_MIGRATION_IN && - op !=3D VIR_DOMAIN_JOB_OPERATION_MIGRATION_OUT) - return false; - - if (op =3D=3D VIR_DOMAIN_JOB_OPERATION_MIGRATION_IN) { - return (dom->state.state =3D=3D VIR_DOMAIN_PAUSED && - dom->state.reason =3D=3D VIR_DOMAIN_PAUSED_POSTCOPY_FAILED= ) || - (dom->state.state =3D=3D VIR_DOMAIN_RUNNING && - (dom->state.reason =3D=3D VIR_DOMAIN_RUNNING_POSTCOPY || - dom->state.reason =3D=3D VIR_DOMAIN_RUNNING_POSTCOPY_FAIL= ED)); - } + if (virDomainObjIsFailedPostcopy(dom)) + return true; =20 - return dom->state.state =3D=3D VIR_DOMAIN_PAUSED && - (dom->state.reason =3D=3D VIR_DOMAIN_PAUSED_POSTCOPY || - dom->state.reason =3D=3D VIR_DOMAIN_PAUSED_POSTCOPY_FAILED); + return (dom->state.state =3D=3D VIR_DOMAIN_PAUSED && + dom->state.reason =3D=3D VIR_DOMAIN_PAUSED_POSTCOPY) || + (dom->state.state =3D=3D VIR_DOMAIN_RUNNING && + dom->state.reason =3D=3D VIR_DOMAIN_RUNNING_POSTCOPY); } =20 =20 diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index c19dfc5470..3abf018574 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -3933,8 +3933,7 @@ bool virDomainObjIsFailedPostcopy(virDomainObj *obj) ATTRIBUTE_NONNULL(1); bool -virDomainObjIsPostcopy(virDomainObj *dom, - virDomainJobOperation op) +virDomainObjIsPostcopy(virDomainObj *dom) ATTRIBUTE_NONNULL(1); =20 virSecurityLabelDef * diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index d509582719..dea3d65b57 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -12614,7 +12614,7 @@ qemuDomainAbortJobFlags(virDomainPtr dom, =20 if (flags & VIR_DOMAIN_ABORT_JOB_POSTCOPY && (vm->job->asyncJob !=3D VIR_ASYNC_JOB_MIGRATION_OUT || - !virDomainObjIsPostcopy(vm, VIR_DOMAIN_JOB_OPERATION_MIGRATION_OU= T))) { + !virDomainObjIsPostcopy(vm))) { virReportError(VIR_ERR_OPERATION_INVALID, "%s", _("current job is not outgoing migration in post-co= py mode")); goto endjob; @@ -12639,7 +12639,7 @@ qemuDomainAbortJobFlags(virDomainPtr dom, break; =20 case VIR_ASYNC_JOB_MIGRATION_OUT: - if (virDomainObjIsPostcopy(vm, VIR_DOMAIN_JOB_OPERATION_MIGRATION_= OUT)) + if (virDomainObjIsPostcopy(vm)) ret =3D qemuDomainAbortJobPostcopy(vm, flags); else ret =3D qemuDomainAbortJobMigration(vm); diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index f4441d61ae..fd8583ca34 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -2294,7 +2294,7 @@ qemuMigrationAnyConnectionClosed(virDomainObj *vm, break; =20 case QEMU_MIGRATION_PHASE_PERFORM3_DONE: - if (virDomainObjIsPostcopy(vm, VIR_DOMAIN_JOB_OPERATION_MIGRATION_= OUT)) { + if (virDomainObjIsPostcopy(vm)) { VIR_DEBUG("Migration protocol interrupted in post-copy mode"); postcopy =3D true; } else { @@ -2683,7 +2683,7 @@ qemuMigrationAnyCanResume(virDomainObj *vm, return false; } =20 - if (!virDomainObjIsPostcopy(vm, vm->job->current->operation)) { + if (!virDomainObjIsPostcopy(vm)) { virReportError(VIR_ERR_OPERATION_INVALID, _("migration of domain %s is not in post-copy phase= "), vm->def->name); @@ -3911,7 +3911,7 @@ qemuMigrationSrcConfirmPhase(virQEMUDriver *driver, virCheckFlags(QEMU_MIGRATION_FLAGS, -1); =20 if (retcode !=3D 0 && - virDomainObjIsPostcopy(vm, VIR_DOMAIN_JOB_OPERATION_MIGRATION_OUT)= && + virDomainObjIsPostcopy(vm) && currentData->stats.mig.status =3D=3D QEMU_MONITOR_MIGRATION_STATUS= _COMPLETED) { VIR_DEBUG("Finish phase failed, but QEMU reports post-copy migrati= on is completed; forcing success"); retcode =3D 0; diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index b6adcf2f2a..2e989256ff 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -1503,7 +1503,7 @@ qemuProcessHandleMigrationStatus(qemuMonitor *mon G_G= NUC_UNUSED, * watching it in any thread. Let's make sure the migration is pro= perly * finished in case we get a "completed" event. */ - if (virDomainObjIsPostcopy(vm, vm->job->current->operation) && + if (virDomainObjIsPostcopy(vm) && vm->job->phase =3D=3D QEMU_MIGRATION_PHASE_POSTCOPY_FAILED && vm->job->asyncOwner =3D=3D 0) { qemuProcessEventSubmit(vm, QEMU_PROCESS_EVENT_UNATTENDED_MIGRA= TION, @@ -3476,7 +3476,7 @@ qemuProcessRecoverMigrationIn(virQEMUDriver *driver, /* migration finished, we started resuming the domain but didn't * confirm success or failure yet; killing it seems safest unless * we already started guest CPUs or we were in post-copy mode */ - if (virDomainObjIsPostcopy(vm, VIR_DOMAIN_JOB_OPERATION_MIGRATION_= IN)) + if (virDomainObjIsPostcopy(vm)) return 1; =20 if (state !=3D VIR_DOMAIN_RUNNING) { @@ -3511,7 +3511,7 @@ qemuProcessRecoverMigrationOut(virQEMUDriver *driver, int reason, unsigned int *stopFlags) { - bool postcopy =3D virDomainObjIsPostcopy(vm, VIR_DOMAIN_JOB_OPERATION_= MIGRATION_OUT); + bool postcopy =3D virDomainObjIsPostcopy(vm); bool resume =3D false; =20 VIR_DEBUG("Active outgoing migration in phase %s", --=20 2.39.0 From nobody Mon Feb 9 01:44:24 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.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.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1671115082; cv=none; d=zohomail.com; s=zohoarc; b=BHjez5/QlY/fkRSDcIqQvTG+pEg+7iEkZPCTMKSJrOOKLsHeKJ91nl69TpWjxAAqCAARcn/Syeb1Gwm2duDYVW/qOzr93d1eIB4oaxmakcaqoB/XDVJf2btNljIQE1Vp9wXbOW7VIf0TwXjLonGj2I8ILz6T1QH8NfPdtc5iQYQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1671115082; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=ttQJZRu2FwLXOCsYudxBj4CluZzu4PM0ZohE6ZiMbnQ=; b=ZxIonB1VNQHZJn0H+06Dusga+gTfAKQCbolsQfi0HjbEzDGHJj7bPwMY2Y/VzYD2m5LMI87dhItPBd0ZpajtW6BIfma5+1hdG/Wt5/dPXZANr8tcQYD7ocPpq8A82G3mUmQ/qmyk1UgZTzL979IRJZmWuaIxdFsB/HGXPO1abI4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1671115082182550.8296988367982; Thu, 15 Dec 2022 06:38:02 -0800 (PST) Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-30-HFm3aylDO-Wp1l16nDu_nQ-1; Thu, 15 Dec 2022 09:37:56 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id ECF66280373C; Thu, 15 Dec 2022 14:37:52 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id CE41040C2006; Thu, 15 Dec 2022 14:37:52 +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 9B9261947042; Thu, 15 Dec 2022 14:37:51 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 66FA21946A77 for ; Thu, 15 Dec 2022 14:37:50 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 4D73340C2004; Thu, 15 Dec 2022 14:37:50 +0000 (UTC) Received: from virval.usersys.redhat.com (unknown [10.43.2.227]) by smtp.corp.redhat.com (Postfix) with ESMTP id 103B940C2064 for ; Thu, 15 Dec 2022 14:37:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1671115081; 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: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=ttQJZRu2FwLXOCsYudxBj4CluZzu4PM0ZohE6ZiMbnQ=; b=GDf0PijjKD+svnC4i9QyMgLA5okZmVxGpudF8YEgKhk5UHUYMqXCwmp/AI0wPB8EyCP2QK WeClV7xRxHYMhIe4wI9gjX00PStIhAq5yM636KyVIb0jbe3vLjGgAp9O1tfLLoXZCF0WRZ O97hl8MPJNzucOqI3FE5MfFcHkdri9E= X-MC-Unique: HFm3aylDO-Wp1l16nDu_nQ-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Jiri Denemark To: libvir-list@redhat.com Subject: [libvirt PATCH 2/4] conf: Add job parameter to virDomainObjIsFailedPostcopy Date: Thu, 15 Dec 2022 15:37:42 +0100 Message-Id: <50167b897dd21233773ebf4c17410ae3f3b0a2a7.1671114079.git.jdenemar@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 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.1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1671115083496100001 Content-Type: text/plain; charset="utf-8" Unused for now, but this will change soon. Signed-off-by: Jiri Denemark Reviewed-by: Michal Privoznik --- src/conf/domain_conf.c | 8 +++++--- src/conf/domain_conf.h | 6 ++++-- src/qemu/qemu_driver.c | 4 ++-- src/qemu/qemu_migration.c | 22 +++++++++++----------- src/qemu/qemu_process.c | 8 ++++---- 5 files changed, 26 insertions(+), 22 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index d1def730a4..9e2eea79e7 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -27873,7 +27873,8 @@ virDomainObjGetState(virDomainObj *dom, int *reason) =20 =20 bool -virDomainObjIsFailedPostcopy(virDomainObj *dom) +virDomainObjIsFailedPostcopy(virDomainObj *dom, + virDomainJobObj *job G_GNUC_UNUSED) { return ((dom->state.state =3D=3D VIR_DOMAIN_PAUSED && dom->state.reason =3D=3D VIR_DOMAIN_PAUSED_POSTCOPY_FAILED) || @@ -27883,9 +27884,10 @@ virDomainObjIsFailedPostcopy(virDomainObj *dom) =20 =20 bool -virDomainObjIsPostcopy(virDomainObj *dom) +virDomainObjIsPostcopy(virDomainObj *dom, + virDomainJobObj *job) { - if (virDomainObjIsFailedPostcopy(dom)) + if (virDomainObjIsFailedPostcopy(dom, job)) return true; =20 return (dom->state.state =3D=3D VIR_DOMAIN_PAUSED && diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 3abf018574..becc147dab 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -3930,10 +3930,12 @@ virDomainObjGetState(virDomainObj *obj, int *reason) ATTRIBUTE_NONNULL(1); =20 bool -virDomainObjIsFailedPostcopy(virDomainObj *obj) +virDomainObjIsFailedPostcopy(virDomainObj *obj, + virDomainJobObj *job) ATTRIBUTE_NONNULL(1); bool -virDomainObjIsPostcopy(virDomainObj *dom) +virDomainObjIsPostcopy(virDomainObj *dom, + virDomainJobObj *job) ATTRIBUTE_NONNULL(1); =20 virSecurityLabelDef * diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index dea3d65b57..2257a17cde 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -12614,7 +12614,7 @@ qemuDomainAbortJobFlags(virDomainPtr dom, =20 if (flags & VIR_DOMAIN_ABORT_JOB_POSTCOPY && (vm->job->asyncJob !=3D VIR_ASYNC_JOB_MIGRATION_OUT || - !virDomainObjIsPostcopy(vm))) { + !virDomainObjIsPostcopy(vm, vm->job))) { virReportError(VIR_ERR_OPERATION_INVALID, "%s", _("current job is not outgoing migration in post-co= py mode")); goto endjob; @@ -12639,7 +12639,7 @@ qemuDomainAbortJobFlags(virDomainPtr dom, break; =20 case VIR_ASYNC_JOB_MIGRATION_OUT: - if (virDomainObjIsPostcopy(vm)) + if (virDomainObjIsPostcopy(vm, vm->job)) ret =3D qemuDomainAbortJobPostcopy(vm, flags); else ret =3D qemuDomainAbortJobMigration(vm); diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index fd8583ca34..27a74795d6 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -2294,7 +2294,7 @@ qemuMigrationAnyConnectionClosed(virDomainObj *vm, break; =20 case QEMU_MIGRATION_PHASE_PERFORM3_DONE: - if (virDomainObjIsPostcopy(vm)) { + if (virDomainObjIsPostcopy(vm, vm->job)) { VIR_DEBUG("Migration protocol interrupted in post-copy mode"); postcopy =3D true; } else { @@ -2683,7 +2683,7 @@ qemuMigrationAnyCanResume(virDomainObj *vm, return false; } =20 - if (!virDomainObjIsPostcopy(vm)) { + if (!virDomainObjIsPostcopy(vm, vm->job)) { virReportError(VIR_ERR_OPERATION_INVALID, _("migration of domain %s is not in post-copy phase= "), vm->def->name); @@ -2691,7 +2691,7 @@ qemuMigrationAnyCanResume(virDomainObj *vm, } =20 if (vm->job->phase < QEMU_MIGRATION_PHASE_POSTCOPY_FAILED && - !virDomainObjIsFailedPostcopy(vm)) { + !virDomainObjIsFailedPostcopy(vm, vm->job)) { virReportError(VIR_ERR_OPERATION_INVALID, _("post-copy migration of domain %s has not failed"= ), vm->def->name); @@ -3911,7 +3911,7 @@ qemuMigrationSrcConfirmPhase(virQEMUDriver *driver, virCheckFlags(QEMU_MIGRATION_FLAGS, -1); =20 if (retcode !=3D 0 && - virDomainObjIsPostcopy(vm) && + virDomainObjIsPostcopy(vm, vm->job) && currentData->stats.mig.status =3D=3D QEMU_MONITOR_MIGRATION_STATUS= _COMPLETED) { VIR_DEBUG("Finish phase failed, but QEMU reports post-copy migrati= on is completed; forcing success"); retcode =3D 0; @@ -3919,7 +3919,7 @@ qemuMigrationSrcConfirmPhase(virQEMUDriver *driver, =20 if (flags & VIR_MIGRATE_POSTCOPY_RESUME) { phase =3D QEMU_MIGRATION_PHASE_CONFIRM_RESUME; - } else if (virDomainObjIsFailedPostcopy(vm)) { + } else if (virDomainObjIsFailedPostcopy(vm, vm->job)) { /* Keep the original migration phase in case post-copy failed as t= he * job will stay active even though migration API finishes with an * error. @@ -3979,7 +3979,7 @@ qemuMigrationSrcConfirmPhase(virQEMUDriver *driver, if (virDomainObjGetState(vm, &reason) =3D=3D VIR_DOMAIN_PAUSED && reason =3D=3D VIR_DOMAIN_PAUSED_POSTCOPY) { qemuMigrationSrcPostcopyFailed(vm); - } else if (!virDomainObjIsFailedPostcopy(vm)) { + } else if (!virDomainObjIsFailedPostcopy(vm, vm->job)) { qemuMigrationSrcRestoreDomainState(driver, vm); =20 qemuMigrationParamsReset(vm, VIR_ASYNC_JOB_MIGRATION_OUT, @@ -4020,7 +4020,7 @@ qemuMigrationSrcConfirm(virQEMUDriver *driver, * job will stay active even though migration API finishes with an * error. */ - if (virDomainObjIsFailedPostcopy(vm)) + if (virDomainObjIsFailedPostcopy(vm, vm->job)) phase =3D vm->job->phase; else if (cancelled) phase =3D QEMU_MIGRATION_PHASE_CONFIRM3_CANCELLED; @@ -4039,7 +4039,7 @@ qemuMigrationSrcConfirm(virQEMUDriver *driver, cookiein, cookieinlen, flags, cancelled); =20 - if (virDomainObjIsFailedPostcopy(vm)) { + if (virDomainObjIsFailedPostcopy(vm, vm->job)) { ignore_value(qemuMigrationJobSetPhase(vm, QEMU_MIGRATION_PHASE_POS= TCOPY_FAILED)); qemuMigrationJobContinue(vm, qemuProcessCleanupMigrationJob); } else { @@ -6093,7 +6093,7 @@ qemuMigrationSrcPerformJob(virQEMUDriver *driver, if (ret < 0) virErrorPreserveLast(&orig_err); =20 - if (virDomainObjIsFailedPostcopy(vm)) { + if (virDomainObjIsFailedPostcopy(vm, vm->job)) { ignore_value(qemuMigrationJobSetPhase(vm, QEMU_MIGRATION_PHASE_POS= TCOPY_FAILED)); qemuMigrationJobContinue(vm, qemuProcessCleanupMigrationJob); } else { @@ -6184,7 +6184,7 @@ qemuMigrationSrcPerformPhase(virQEMUDriver *driver, ret =3D 0; =20 cleanup: - if (ret < 0 && !virDomainObjIsFailedPostcopy(vm)) { + if (ret < 0 && !virDomainObjIsFailedPostcopy(vm, vm->job)) { qemuMigrationSrcRestoreDomainState(driver, vm); qemuMigrationParamsReset(vm, VIR_ASYNC_JOB_MIGRATION_OUT, jobPriv->migParams, vm->job->apiFlags); @@ -6725,7 +6725,7 @@ qemuMigrationDstFinishActive(virQEMUDriver *driver, } } =20 - if (virDomainObjIsFailedPostcopy(vm)) { + if (virDomainObjIsFailedPostcopy(vm, vm->job)) { ignore_value(qemuMigrationJobSetPhase(vm, QEMU_MIGRATION_PHASE_POS= TCOPY_FAILED)); qemuProcessAutoDestroyRemove(driver, vm); *finishJob =3D false; diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 2e989256ff..6091c9f1a9 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -1473,7 +1473,7 @@ qemuProcessHandleMigrationStatus(qemuMonitor *mon G_G= NUC_UNUSED, break; =20 case QEMU_MONITOR_MIGRATION_STATUS_POSTCOPY_RECOVER: - if (virDomainObjIsFailedPostcopy(vm)) { + if (virDomainObjIsFailedPostcopy(vm, vm->job)) { int eventType =3D -1; int eventDetail =3D -1; =20 @@ -1503,7 +1503,7 @@ qemuProcessHandleMigrationStatus(qemuMonitor *mon G_G= NUC_UNUSED, * watching it in any thread. Let's make sure the migration is pro= perly * finished in case we get a "completed" event. */ - if (virDomainObjIsPostcopy(vm) && + if (virDomainObjIsPostcopy(vm, vm->job) && vm->job->phase =3D=3D QEMU_MIGRATION_PHASE_POSTCOPY_FAILED && vm->job->asyncOwner =3D=3D 0) { qemuProcessEventSubmit(vm, QEMU_PROCESS_EVENT_UNATTENDED_MIGRA= TION, @@ -3476,7 +3476,7 @@ qemuProcessRecoverMigrationIn(virQEMUDriver *driver, /* migration finished, we started resuming the domain but didn't * confirm success or failure yet; killing it seems safest unless * we already started guest CPUs or we were in post-copy mode */ - if (virDomainObjIsPostcopy(vm)) + if (virDomainObjIsPostcopy(vm, job)) return 1; =20 if (state !=3D VIR_DOMAIN_RUNNING) { @@ -3511,7 +3511,7 @@ qemuProcessRecoverMigrationOut(virQEMUDriver *driver, int reason, unsigned int *stopFlags) { - bool postcopy =3D virDomainObjIsPostcopy(vm); + bool postcopy =3D virDomainObjIsPostcopy(vm, job); bool resume =3D false; =20 VIR_DEBUG("Active outgoing migration in phase %s", --=20 2.39.0 From nobody Mon Feb 9 01:44:24 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=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1671115081; cv=none; d=zohomail.com; s=zohoarc; b=HtV2Gd5N0+UeWsVZQK9CkGqScY7A7dv7Jxa8jKOVJLYCFuXN08uopQy+JBOPAq3t10QJ4FYsdWgJsXhoOJow6t4hoh7WWSLqD9zEOxXs6alTq2SQbuLrieH8WOqBf8v/8DDhbFGKMFZGZc2E+FAlQwavcAGI8nKL7gIfq8PKhT0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1671115081; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=+Vyxj9zvoU6gPSCw6NFButv3NwmbkuoVYbZCbvVXU6E=; b=OSBd6qB8N2KHdWv38KpO16lRk2zrMK3U7z8GWE8OQUsYTrgZgbrgDHkIho54oqsbRE96yg23nZzxmuKyyWamXO9A2PPD8IKKAgruBozuPM1gQ90GlKYD1f6UxNIjcAsXWe1rTqDZIJeckpiGhfRp2uljpnxzE4Y9QB6c+4TmKwo= 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=pass header.from= (p=none dis=none) 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 1671115081241846.3094322435114; Thu, 15 Dec 2022 06:38:01 -0800 (PST) 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-411-XcyP_NHyPfKgnic6BEoVEg-1; Thu, 15 Dec 2022 09:37:57 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 44F1380556A; Thu, 15 Dec 2022 14:37:53 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2D0BC408572B; Thu, 15 Dec 2022 14:37:53 +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 BC84419466DF; Thu, 15 Dec 2022 14:37:52 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 800C71946A7D for ; Thu, 15 Dec 2022 14:37:51 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 648CF49BB6A; Thu, 15 Dec 2022 14:37:51 +0000 (UTC) Received: from virval.usersys.redhat.com (unknown [10.43.2.227]) by smtp.corp.redhat.com (Postfix) with ESMTP id 26D48400F5A for ; Thu, 15 Dec 2022 14:37:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1671115079; 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: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=+Vyxj9zvoU6gPSCw6NFButv3NwmbkuoVYbZCbvVXU6E=; b=QdLZP/wOeDytRuXB2T4jxyfITxc0s1caAJpxtqyq3h3piULW++cQbIJm89Aoxj+Vj1O847 /JM6PchaN4aYe6RXTKlT57uCsik7tv6H3dL6kbC4bj+2/i9zveynjSkopjyb5eRcqdOUIH tp564hzpihe263UIf7PsK5qIFTqsKyE= X-MC-Unique: XcyP_NHyPfKgnic6BEoVEg-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Jiri Denemark To: libvir-list@redhat.com Subject: [libvirt PATCH 3/4] qemu: Remember failed post-copy migration in job Date: Thu, 15 Dec 2022 15:37:43 +0100 Message-Id: <02fea52fe4614cdc0fe948ec504d86adbf0eeda4.1671114079.git.jdenemar@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 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.2 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1671115083545100004 Content-Type: text/plain; charset="utf-8" When post-copy migration fails, the domain stays running on the destination with a VIR_DOMAIN_RUNNING_POSTCOPY_FAILED reason. Both the state and the reason can later be rewritten in case the domain gets paused for other reasons (such as an I/O error). Thus we need a separate place to remember the post-copy migration failed to be able to resume the migration. https://bugzilla.redhat.com/show_bug.cgi?id=3D2111948 Signed-off-by: Jiri Denemark Reviewed-by: Michal Privoznik --- src/conf/domain_conf.c | 7 ++++++- src/conf/virdomainjob.c | 1 + src/conf/virdomainjob.h | 1 + src/qemu/qemu_domainjob.c | 9 +++++++++ src/qemu/qemu_migration.c | 34 +++++++++++++++++++++++----------- src/qemu/qemu_process.c | 15 +++++++++++++++ 6 files changed, 55 insertions(+), 12 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 9e2eea79e7..f83586c549 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -27874,8 +27874,13 @@ virDomainObjGetState(virDomainObj *dom, int *reaso= n) =20 bool virDomainObjIsFailedPostcopy(virDomainObj *dom, - virDomainJobObj *job G_GNUC_UNUSED) + virDomainJobObj *job) { + if (job && job->asyncPaused && + (job->asyncJob =3D=3D VIR_ASYNC_JOB_MIGRATION_IN || + job->asyncJob =3D=3D VIR_ASYNC_JOB_MIGRATION_OUT)) + return true; + return ((dom->state.state =3D=3D VIR_DOMAIN_PAUSED && dom->state.reason =3D=3D VIR_DOMAIN_PAUSED_POSTCOPY_FAILED) || (dom->state.state =3D=3D VIR_DOMAIN_RUNNING && diff --git a/src/conf/virdomainjob.c b/src/conf/virdomainjob.c index 256b665a42..c4cbbe8f6d 100644 --- a/src/conf/virdomainjob.c +++ b/src/conf/virdomainjob.c @@ -174,6 +174,7 @@ virDomainObjResetAsyncJob(virDomainJobObj *job) job->asyncOwner =3D 0; g_clear_pointer(&job->asyncOwnerAPI, g_free); job->asyncStarted =3D 0; + job->asyncPaused =3D false; job->phase =3D 0; job->mask =3D VIR_JOB_DEFAULT_MASK; job->abortJob =3D false; diff --git a/src/conf/virdomainjob.h b/src/conf/virdomainjob.h index b1ac36a2fa..0d62bab287 100644 --- a/src/conf/virdomainjob.h +++ b/src/conf/virdomainjob.h @@ -176,6 +176,7 @@ struct _virDomainJobObj { unsigned long long asyncOwner; /* Thread which set current async = job */ char *asyncOwnerAPI; /* The API which owns the async jo= b */ unsigned long long asyncStarted; /* When the current async job star= ted */ + bool asyncPaused; /* The async job is paused */ int phase; /* Job phase (mainly for migration= s) */ unsigned long long mask; /* Jobs allowed during async job */ virDomainJobData *current; /* async job progress data */ diff --git a/src/qemu/qemu_domainjob.c b/src/qemu/qemu_domainjob.c index 8d958b9d21..27beb5229f 100644 --- a/src/qemu/qemu_domainjob.c +++ b/src/qemu/qemu_domainjob.c @@ -695,6 +695,8 @@ qemuDomainObjPrivateXMLFormatJob(virBuffer *buf, if (vm->job->asyncJob !=3D VIR_ASYNC_JOB_NONE) { virBufferAsprintf(&attrBuf, " flags=3D'0x%x'", vm->job->apiFlags); virBufferAsprintf(&attrBuf, " asyncStarted=3D'%llu'", vm->job->asy= ncStarted); + if (vm->job->asyncPaused) + virBufferAddLit(&attrBuf, " asyncPaused=3D'yes'"); } =20 if (vm->job->cb && @@ -732,6 +734,7 @@ qemuDomainObjPrivateXMLParseJob(virDomainObj *vm, =20 if ((tmp =3D virXPathString("string(@async)", ctxt))) { int async; + virTristateBool paused; =20 if ((async =3D virDomainAsyncJobTypeFromString(tmp)) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, @@ -757,6 +760,12 @@ qemuDomainObjPrivateXMLParseJob(virDomainObj *vm, _("Invalid async job start")); return -1; } + + if (virXMLPropTristateBool(ctxt->node, "asyncPaused", VIR_XML_PROP= _NONE, + &paused) < 0) + return -1; + + vm->job->asyncPaused =3D paused =3D=3D VIR_TRISTATE_BOOL_YES; } =20 if (virXMLPropUInt(ctxt->node, "flags", 16, VIR_XML_PROP_NONE, diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index 27a74795d6..f258e7d700 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -1666,17 +1666,19 @@ qemuMigrationSrcPostcopyFailed(virDomainObj *vm) =20 state =3D virDomainObjGetState(vm, &reason); =20 - VIR_DEBUG("%s/%s", + VIR_DEBUG("%s/%s, asyncPaused=3D%u", virDomainStateTypeToString(state), - virDomainStateReasonToString(state, reason)); + virDomainStateReasonToString(state, reason), + vm->job->asyncPaused); =20 if (state !=3D VIR_DOMAIN_PAUSED || - reason =3D=3D VIR_DOMAIN_PAUSED_POSTCOPY_FAILED) + virDomainObjIsFailedPostcopy(vm, vm->job)) return; =20 VIR_WARN("Migration of domain %s failed during post-copy; " "leaving the domain paused", vm->def->name); =20 + vm->job->asyncPaused =3D true; virDomainObjSetState(vm, VIR_DOMAIN_PAUSED, VIR_DOMAIN_PAUSED_POSTCOPY_FAILED); event =3D virDomainEventLifecycleNewFromObj(vm, VIR_DOMAIN_EVENT_SUSPE= NDED, @@ -1696,21 +1698,31 @@ qemuMigrationDstPostcopyFailed(virDomainObj *vm) =20 state =3D virDomainObjGetState(vm, &reason); =20 - VIR_DEBUG("%s/%s", + VIR_DEBUG("%s/%s, asyncPaused=3D%u", virDomainStateTypeToString(state), - virDomainStateReasonToString(state, reason)); + virDomainStateReasonToString(state, reason), + vm->job->asyncPaused); =20 - if (state !=3D VIR_DOMAIN_RUNNING || - reason =3D=3D VIR_DOMAIN_RUNNING_POSTCOPY_FAILED) + if ((state !=3D VIR_DOMAIN_RUNNING && state !=3D VIR_DOMAIN_PAUSED) || + virDomainObjIsFailedPostcopy(vm, vm->job)) return; =20 VIR_WARN("Incoming migration of domain '%s' failed during post-copy; " "leaving the domain running", vm->def->name); =20 - virDomainObjSetState(vm, VIR_DOMAIN_RUNNING, - VIR_DOMAIN_RUNNING_POSTCOPY_FAILED); - event =3D virDomainEventLifecycleNewFromObj(vm, VIR_DOMAIN_EVENT_RESUM= ED, - VIR_DOMAIN_EVENT_RESUMED_POS= TCOPY_FAILED); + vm->job->asyncPaused =3D true; + if (state =3D=3D VIR_DOMAIN_RUNNING) { + virDomainObjSetState(vm, VIR_DOMAIN_RUNNING, + VIR_DOMAIN_RUNNING_POSTCOPY_FAILED); + event =3D virDomainEventLifecycleNewFromObj(vm, VIR_DOMAIN_EVENT_R= ESUMED, + VIR_DOMAIN_EVENT_RESUMED= _POSTCOPY_FAILED); + } else { + /* The domain was paused for other reasons (I/O error, ...) so we = don't + * want to rewrite the original reason and just emit a postcopy-fa= iled + * event. */ + event =3D virDomainEventLifecycleNewFromObj(vm, VIR_DOMAIN_EVENT_S= USPENDED, + VIR_DOMAIN_EVENT_SUSPEND= ED_POSTCOPY_FAILED); + } virObjectEventStateQueue(driver->domainEventState, event); } =20 diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 6091c9f1a9..017a05d57e 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -712,6 +712,15 @@ qemuProcessHandleResume(qemuMonitor *mon G_GNUC_UNUSED, vm->def->name, virDomainRunningReasonTypeToString(reason= ), eventDetail); =20 + /* When a domain is running in (failed) post-copy migration on the + * destination host, we need to make sure to set the appropriate r= eason + * here. */ + if (virDomainObjIsPostcopy(vm, vm->job)) { + if (virDomainObjIsFailedPostcopy(vm, vm->job)) + reason =3D VIR_DOMAIN_RUNNING_POSTCOPY_FAILED; + else + reason =3D VIR_DOMAIN_RUNNING_POSTCOPY; + } virDomainObjSetState(vm, VIR_DOMAIN_RUNNING, reason); event =3D virDomainEventLifecycleNewFromObj(vm, VIR_DOMAIN_EVENT_RESUMED, @@ -1491,6 +1500,7 @@ qemuProcessHandleMigrationStatus(qemuMonitor *mon G_G= NUC_UNUSED, vm->def->name, virDomainStateTypeToString(state), NULLSTR(virDomainStateReasonToString(state, reason))= ); + vm->job->asyncPaused =3D false; virDomainObjSetState(vm, state, reason); event =3D virDomainEventLifecycleNewFromObj(vm, eventType, eve= ntDetail); qemuDomainSaveStatus(vm); @@ -3420,6 +3430,7 @@ qemuProcessRestoreMigrationJob(virDomainObj *vm, job->privateData =3D g_steal_pointer(&vm->job->privateData); vm->job->privateData =3D jobPriv; vm->job->apiFlags =3D job->apiFlags; + vm->job->asyncPaused =3D job->asyncPaused; =20 qemuDomainCleanupAdd(vm, qemuProcessCleanupMigrationJob); } @@ -3645,6 +3656,7 @@ qemuProcessRecoverMigration(virQEMUDriver *driver, if (migStatus =3D=3D VIR_DOMAIN_JOB_STATUS_POSTCOPY) { VIR_DEBUG("Post-copy migration of domain %s still running, it = will be handled as unattended", vm->def->name); + vm->job->asyncPaused =3D false; return 0; } =20 @@ -3653,6 +3665,9 @@ qemuProcessRecoverMigration(virQEMUDriver *driver, qemuMigrationSrcPostcopyFailed(vm); else qemuMigrationDstPostcopyFailed(vm); + /* Set the asyncPaused flag in case we're reconnecting to a do= main + * started by an older libvirt. */ + vm->job->asyncPaused =3D true; return 0; } =20 --=20 2.39.0 From nobody Mon Feb 9 01:44:24 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=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1671115083; cv=none; d=zohomail.com; s=zohoarc; b=e4n8NinfNHIi/DkGm0SzeLe25aJPCEo+jbNNEuM1XA54GxcSMdWlcFMj7x1hWrIw4f1Q601+IqRl8eh43Gq/7lL+9IVRXjj/uuFrl7I6yV4G1jwSi6DOUFpW+rIfugjDNm71+9xsv2svfX44FW4kdZZz+S9k1hwUrcA4EFQL1LI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1671115083; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=zeLnWqoUHLSbWbF1PhA960PFsQBwcGKW8WHd6jXIMeY=; b=evR5TgAL6eZ1SAoi8+wrbbHFVgy2HHKNzt4TdTysA8XBBA0JCXhJWqLNmw7UtyUxpYlqMytQ6IQ174s/wUc41gPMSmd2WiWLOqhSKpg76m7OBIJ+b2MguGSdSeVASsCLqXCzBs+42D7wZjlhSPEmUqvRLOd26zkE1utozi3ZJew= 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=pass header.from= (p=none dis=none) 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 1671115083860880.0580282266195; Thu, 15 Dec 2022 06:38:03 -0800 (PST) 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-311-OIwCYENpOEiO6s7gGr67Bg-1; Thu, 15 Dec 2022 09:37:57 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 14EC3857A84; Thu, 15 Dec 2022 14:37:54 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 01BC01121314; Thu, 15 Dec 2022 14:37:54 +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 EC01C19466DF; Thu, 15 Dec 2022 14:37:53 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 8E72319465B2 for ; Thu, 15 Dec 2022 14:37:52 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 81CC6492C3C; Thu, 15 Dec 2022 14:37:52 +0000 (UTC) Received: from virval.usersys.redhat.com (unknown [10.43.2.227]) by smtp.corp.redhat.com (Postfix) with ESMTP id 43677492C18 for ; Thu, 15 Dec 2022 14:37:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1671115082; 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: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=zeLnWqoUHLSbWbF1PhA960PFsQBwcGKW8WHd6jXIMeY=; b=aLVJFVm5bYgEbo76OvvNGwC/AIj7tD7vjosfoprf1LdcP4RqArRr+XLxO2lUmsSrMohFsq D3a/1MtCyd4dTMB3sC3InmlW9VltUtUDzsBP4XUdrP5ojA1NNIO/IDeRe1gvP/Rshl2h5G qeDLnbB4n1M65zwr5D1lARWKl6sVtPs= X-MC-Unique: OIwCYENpOEiO6s7gGr67Bg-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Jiri Denemark To: libvir-list@redhat.com Subject: [libvirt PATCH 4/4] virDomainObjGetState: Promote VIR_DOMAIN_PAUSED_POSTCOPY_FAILED Date: Thu, 15 Dec 2022 15:37:44 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 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.3 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1671115085486100007 Content-Type: text/plain; charset="utf-8" In case a domain is in failed post-copy migration but paused for a different reason, report VIR_DOMAIN_PAUSED_POSTCOPY_FAILED instead to make it more visible. Reviewed-by: Michal Privoznik --- Notes: This commit is intentionally missing =20 Signed-off-by: Jiri Denemark =20 because I can find reasons for both pushing and not pushing this change. It is pretty ugly and masks the real reason behind the paused state. On the other hand, reporting the real reason means users would not really know post-copy migration failed unless they saw the corresponding event. src/conf/domain_conf.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index f83586c549..6097ea3ffc 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -27865,8 +27865,15 @@ virDomainObjCopyPersistentDef(virDomainObj *dom, virDomainState virDomainObjGetState(virDomainObj *dom, int *reason) { - if (reason) - *reason =3D dom->state.reason; + if (reason) { + if (dom->state.state =3D=3D VIR_DOMAIN_PAUSED && + dom->job && dom->job->asyncPaused && + (dom->job->asyncJob =3D=3D VIR_ASYNC_JOB_MIGRATION_IN || + dom->job->asyncJob =3D=3D VIR_ASYNC_JOB_MIGRATION_OUT)) + *reason =3D VIR_DOMAIN_PAUSED_POSTCOPY_FAILED; + else + *reason =3D dom->state.reason; + } =20 return dom->state.state; } --=20 2.39.0