From nobody Sun May 19 06:23:00 2024 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=1662036609; cv=none; d=zohomail.com; s=zohoarc; b=gyOs9WTZEA0blexzIebJpxQCWKje3+kshBDEads7vE1TEraK861UVhZbp4nFHRlXOY7QYfVMznXU4U/Gw4NuyhCdtUWvOvrcLDEE4uo6AX0epCWJ3oe5v77zQ7oSMdYqm9fzzX0P962iBSwnpAh/n5WX267KRJ9OdOZYCjrxjv4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1662036609; 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=gH/q+1/RAQgxJij1hvsKp+6z8/dju58KXiSYZwNbfy4=; b=TEYzVKN6jXYhLIiRn/jG7CFzoomzdrfUUswwunUWmQQ0atv0YDyToo1Fs+kheRB4zUJHmFVBtmu23JPy4byW1EWglzfgyAjU3WIzgcgQreNgA2pUgh9qXWxXFzIXMuRukWas6ExYeM+1oAenmQMkyZ++tZNVVOqdCbDbYtp2Oxw= 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 1662036609271114.28923263139188; Thu, 1 Sep 2022 05:50:09 -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-587-hsBDSwh_Oeii63B5rAionA-1; Thu, 01 Sep 2022 08:49:56 -0400 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 5AF1080D2A2; Thu, 1 Sep 2022 12:49:54 +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 47FD42026D4C; Thu, 1 Sep 2022 12:49: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 8974A1940342; Thu, 1 Sep 2022 12:49:53 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 099251946A5E for ; Thu, 1 Sep 2022 12:47:45 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id CB1BC20296CB; Thu, 1 Sep 2022 12:47:44 +0000 (UTC) Received: from virval.usersys.redhat.com (unknown [10.43.2.227]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 9A0C420296B9 for ; Thu, 1 Sep 2022 12:47:44 +0000 (UTC) Received: by virval.usersys.redhat.com (Postfix, from userid 500) id 5E839240049; Thu, 1 Sep 2022 14:47:43 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1662036608; 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=gH/q+1/RAQgxJij1hvsKp+6z8/dju58KXiSYZwNbfy4=; b=MFdqA5y20E/9qs2EXdVjj5GOr9mmHzCkrRsQlofyd6itYDrbnnwyWmgzCh7xYEDQiS/KH3 CdS1p/gBiUZraaZZiVdwnqwFQaRVvrSWWmcFruT4OxuGqi8o0svXfxSKx/niv/nWzltD9/ rHfn6NE3m5ZlBbpD9nZqNeaalO40fgw= X-MC-Unique: hsBDSwh_Oeii63B5rAionA-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Jiri Denemark To: libvir-list@redhat.com Subject: [libvirt PATCH 1/3] qemu: Rename qemuMigrationSrcCancel Date: Thu, 1 Sep 2022 14:47:39 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 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 2.78 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: 1662036610812100001 Content-Type: text/plain; charset="utf-8" Let's call this qemuMigrationSrcCancelUnattended as the function is supposed to be used when no other thread is watching the migration. Signed-off-by: Jiri Denemark Reviewed-by: Peter Krempa --- src/qemu/qemu_migration.c | 2 +- src/qemu/qemu_migration.h | 2 +- src/qemu/qemu_process.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index b3b25d78b4..67d83ca743 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -6943,7 +6943,7 @@ qemuMigrationSrcToFile(virQEMUDriver *driver, virDoma= inObj *vm, =20 =20 int -qemuMigrationSrcCancel(virDomainObj *vm) +qemuMigrationSrcCancelUnattended(virDomainObj *vm) { qemuDomainObjPrivate *priv =3D vm->privateData; bool storage =3D false; diff --git a/src/qemu/qemu_migration.h b/src/qemu/qemu_migration.h index d518889c19..bbc71d118d 100644 --- a/src/qemu/qemu_migration.h +++ b/src/qemu/qemu_migration.h @@ -241,7 +241,7 @@ qemuMigrationSrcToFile(virQEMUDriver *driver, ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) G_GNUC_WARN_UNUSED_RESULT; =20 int -qemuMigrationSrcCancel(virDomainObj *vm); +qemuMigrationSrcCancelUnattended(virDomainObj *vm); =20 int qemuMigrationAnyFetchStats(virDomainObj *vm, diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 32f03ff79a..4e8daf83fe 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -3537,7 +3537,7 @@ qemuProcessRecoverMigrationOut(virQEMUDriver *driver, */ VIR_DEBUG("Cancelling unfinished migration of domain %s", vm->def->name); - if (qemuMigrationSrcCancel(vm) < 0) { + if (qemuMigrationSrcCancelUnattended(vm) < 0) { VIR_WARN("Could not cancel ongoing migration of domain %s", vm->def->name); } --=20 2.37.2 From nobody Sun May 19 06:23:00 2024 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=1662036602; cv=none; d=zohomail.com; s=zohoarc; b=Bln5XejnWJXElrrWA6bS6X0NPk0jhBS88NWM0zLBlzGisjQNNPDmoMFH+WPY5/58zVEohg9ju8W/Lh4JgH4Xtx+7f5p4y+31aKJkxb1CQd1NvCeD2oKyUwbNjh7XILqgSrnrFGcke84QbIT6O2Gl8R1xjSwM5EMDxAee2A2J+08= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1662036602; 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=REyJcmOOk8wmaDps8gmIVas8HUCZ91A56Tz9c2P/QGU=; b=UFelLTP3l3eskrCt0SKhG5aI5FeL4im5Yl2+4OdCcjHMczMTQyVGT6xTTCkXKGflWtyqivranrbjv6Xb5dPEFaX7ctDInlLrrzDYA5l3FiQQdiG+/z2dC9Bkit6ZREDLix/9Ay/Tu8zRumH0Lthc4QBdHPlkciLrE3fZ1S2tXUo= 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 1662036602755655.7257319725575; Thu, 1 Sep 2022 05:50:02 -0700 (PDT) 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-467-xEZTQ_TiOViQTlucWCPGXg-1; Thu, 01 Sep 2022 08:49:56 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id D2F913800C38; Thu, 1 Sep 2022 12:49:53 +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 87EE6C15BB3; Thu, 1 Sep 2022 12:49: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 4305C1943214; Thu, 1 Sep 2022 12:49:53 +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 D68FD194322D for ; Thu, 1 Sep 2022 12:47:44 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id C2BE6403350; Thu, 1 Sep 2022 12:47:44 +0000 (UTC) Received: from virval.usersys.redhat.com (unknown [10.43.2.227]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 84753403373 for ; Thu, 1 Sep 2022 12:47:44 +0000 (UTC) Received: by virval.usersys.redhat.com (Postfix, from userid 500) id 5F91C240A7B; Thu, 1 Sep 2022 14:47:43 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1662036600; 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=REyJcmOOk8wmaDps8gmIVas8HUCZ91A56Tz9c2P/QGU=; b=MwE2ebE7yku9AGGs3IATeWSEsA1GCc9DhgtyiB9aKuf2byxb06KmGJ/i+DNDIPx+QLFqEq 1ZqCAwwkKHd5yggM0/XGohhwA+BkPUiDfa2IytZTFrbH33Uvc8EWnMSVFZeGgBY1Gehju7 5v4kEFPoz+6q/8+0dl3ksQxsxqtH56M= X-MC-Unique: xEZTQ_TiOViQTlucWCPGXg-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Jiri Denemark To: libvir-list@redhat.com Subject: [libvirt PATCH 2/3] qemu: Create wrapper for qemuMonitorMigrateCancel Date: Thu, 1 Sep 2022 14:47:40 +0200 Message-Id: <8ac22e2ae546b4cbbe7764e7b2ffecb33138e056.1662036411.git.jdenemar@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.85 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 2.85 on 10.11.54.8 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: 1662036604770100001 Content-Type: text/plain; charset="utf-8" We will need a little bit more code around qemuMonitorMigrateCancel to make sure it works as expected. The new qemuMigrationSrcCancel helper will avoid repeating the code in several places. Signed-off-by: Jiri Denemark Reviewed-by: Peter Krempa --- src/qemu/qemu_driver.c | 9 +-------- src/qemu/qemu_migration.c | 37 +++++++++++++++++++++++-------------- src/qemu/qemu_migration.h | 4 ++++ src/qemu/qemu_process.c | 5 +---- 4 files changed, 29 insertions(+), 26 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 707f4cc1bb..a86efc769a 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -12808,17 +12808,10 @@ qemuDomainGetJobStats(virDomainPtr dom, static int qemuDomainAbortJobMigration(virDomainObj *vm) { - qemuDomainObjPrivate *priv =3D vm->privateData; - int ret; - VIR_DEBUG("Cancelling migration job at client request"); =20 qemuDomainObjAbortAsyncJob(vm); - qemuDomainObjEnterMonitor(vm); - ret =3D qemuMonitorMigrateCancel(priv->mon); - qemuDomainObjExitMonitor(vm); - - return ret; + return qemuMigrationSrcCancel(vm, VIR_ASYNC_JOB_NONE); } =20 =20 diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index 67d83ca743..5845dfdb9c 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -4611,6 +4611,24 @@ qemuMigrationSrcStart(virDomainObj *vm, } =20 =20 +int +qemuMigrationSrcCancel(virDomainObj *vm, + virDomainAsyncJob asyncJob) +{ + qemuDomainObjPrivate *priv =3D vm->privateData; + + VIR_DEBUG("Cancelling outgoing migration of domain %s", vm->def->name); + + if (qemuDomainObjEnterMonitorAsync(vm, asyncJob) < 0) + return -1; + + qemuMonitorMigrateCancel(priv->mon); + qemuDomainObjExitMonitor(vm); + + return 0; +} + + static int qemuMigrationSrcRun(virQEMUDriver *driver, virDomainObj *vm, @@ -4952,11 +4970,8 @@ qemuMigrationSrcRun(virQEMUDriver *driver, } =20 if (cancel && - priv->job.current->status !=3D VIR_DOMAIN_JOB_STATUS_HYPERVISO= R_COMPLETED && - qemuDomainObjEnterMonitorAsync(vm, VIR_ASYNC_JOB_MIGRATION_OUT= ) =3D=3D 0) { - qemuMonitorMigrateCancel(priv->mon); - qemuDomainObjExitMonitor(vm); - } + priv->job.current->status !=3D VIR_DOMAIN_JOB_STATUS_HYPERVISO= R_COMPLETED) + qemuMigrationSrcCancel(vm, VIR_ASYNC_JOB_MIGRATION_OUT); =20 /* cancel any outstanding NBD jobs */ if (mig && mig->nbd) @@ -6900,11 +6915,8 @@ qemuMigrationSrcToFile(virQEMUDriver *driver, virDom= ainObj *vm, if (rc =3D=3D -2) { virErrorPreserveLast(&orig_err); virCommandAbort(compressor); - if (virDomainObjIsActive(vm) && - qemuDomainObjEnterMonitorAsync(vm, asyncJob) =3D=3D 0) { - qemuMonitorMigrateCancel(priv->mon); - qemuDomainObjExitMonitor(vm); - } + if (virDomainObjIsActive(vm)) + qemuMigrationSrcCancel(vm, asyncJob); } goto cleanup; } @@ -6945,16 +6957,13 @@ qemuMigrationSrcToFile(virQEMUDriver *driver, virDo= mainObj *vm, int qemuMigrationSrcCancelUnattended(virDomainObj *vm) { - qemuDomainObjPrivate *priv =3D vm->privateData; bool storage =3D false; size_t i; =20 VIR_DEBUG("Canceling unfinished outgoing migration of domain %s", vm->def->name); =20 - qemuDomainObjEnterMonitor(vm); - ignore_value(qemuMonitorMigrateCancel(priv->mon)); - qemuDomainObjExitMonitor(vm); + qemuMigrationSrcCancel(vm, VIR_ASYNC_JOB_NONE); =20 for (i =3D 0; i < vm->def->ndisks; i++) { virDomainDiskDef *disk =3D vm->def->disks[i]; diff --git a/src/qemu/qemu_migration.h b/src/qemu/qemu_migration.h index bbc71d118d..31a5547399 100644 --- a/src/qemu/qemu_migration.h +++ b/src/qemu/qemu_migration.h @@ -243,6 +243,10 @@ qemuMigrationSrcToFile(virQEMUDriver *driver, int qemuMigrationSrcCancelUnattended(virDomainObj *vm); =20 +int +qemuMigrationSrcCancel(virDomainObj *vm, + virDomainAsyncJob asyncJob); + int qemuMigrationAnyFetchStats(virDomainObj *vm, virDomainAsyncJob asyncJob, diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 4e8daf83fe..4465fa89e9 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -3674,7 +3674,6 @@ qemuProcessRecoverJob(virQEMUDriver *driver, virDomainJobObj *job, unsigned int *stopFlags) { - qemuDomainObjPrivate *priv =3D vm->privateData; virDomainState state; int reason; =20 @@ -3697,9 +3696,7 @@ qemuProcessRecoverJob(virQEMUDriver *driver, case VIR_ASYNC_JOB_SAVE: case VIR_ASYNC_JOB_DUMP: case VIR_ASYNC_JOB_SNAPSHOT: - qemuDomainObjEnterMonitor(vm); - ignore_value(qemuMonitorMigrateCancel(priv->mon)); - qemuDomainObjExitMonitor(vm); + qemuMigrationSrcCancel(vm, VIR_ASYNC_JOB_NONE); /* resume the domain but only if it was paused as a result of * running a migration-to-file operation. Although we are * recovering an async job, this function is run at startup --=20 2.37.2 From nobody Sun May 19 06:23:00 2024 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=1662036612; cv=none; d=zohomail.com; s=zohoarc; b=cHUfo0E5nZa+RSWezI9PDX+FGY7UiKHM6fX/lHGRhi2xOP09rTGAMaJ1ZWPFhZKqWc7gPZVFw7iAu1QfpB8T61V6vytIasH6yakHeEIzBy20NBcbSC9NpJP5bvdxlLEh6mGB8/DM8Au/RBxiOqLg6BcnRQcoPvlmGfrzdnLOKvU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1662036612; 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=7bvAkTwieNQMtOi4MOhBuF9a2tI7ObFFGG0+DpORV9E=; b=D2tSH5G/oEzX9JHzIaRGjbct3idxuKp0cZwyohbYFcq4HBijiOgKc+Ndfexpu2PUMoqLCy8LRqCh2LlrHpFjovo8Yy3qhsBf/+sB3TXopdirdPuzh3Ie/419OcdQI8YwtjMLgd0hnCF7ag6XbcTldsqyAVVn8J8Gf15NnhqIzVE= 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 1662036612698732.5324794276679; Thu, 1 Sep 2022 05:50:12 -0700 (PDT) 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-1-j9F2qlHOMQe_nrzLomuwRQ-1; Thu, 01 Sep 2022 08:50:08 -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 13B163800C35; Thu, 1 Sep 2022 12:50:06 +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 00335492CA2; Thu, 1 Sep 2022 12:50: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 D36D71943214; Thu, 1 Sep 2022 12:50:05 +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 D68451946A5E for ; Thu, 1 Sep 2022 12:47:44 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id A6281403344; Thu, 1 Sep 2022 12:47:44 +0000 (UTC) Received: from virval.usersys.redhat.com (unknown [10.43.2.227]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 6D242492C3B for ; Thu, 1 Sep 2022 12:47:44 +0000 (UTC) Received: by virval.usersys.redhat.com (Postfix, from userid 500) id 61302240A7C; Thu, 1 Sep 2022 14:47:43 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1662036611; 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=7bvAkTwieNQMtOi4MOhBuF9a2tI7ObFFGG0+DpORV9E=; b=egmpYu/+tV5PfG41Elne+g0pVK2Lg7+lv2MOP0gjdbigVnulSqxG0PyAYtSV8t8Cv7Lur3 XRh/MUypaRFXT3/OfTc3/gpEzDJZjByPFlI0HEw1mAGM+Zbk7oREeT/cBaN/Sne7bJwQJH sJBR//m5Ep28VNlHftuE4Z6my2vPzVU= X-MC-Unique: j9F2qlHOMQe_nrzLomuwRQ-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Jiri Denemark To: libvir-list@redhat.com Subject: [libvirt PATCH 3/3] qemu: Make qemuMigrationSrcCancel optionally synchronous Date: Thu, 1 Sep 2022 14:47:41 +0200 Message-Id: <0c9b7fc17023923c574fa8a3e91f48226b76e449.1662036411.git.jdenemar@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.85 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 2.85 on 10.11.54.9 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: 1662036614802100001 Content-Type: text/plain; charset="utf-8" We have always considered "migrate_cancel" QMP command to return after successfully cancelling the migration. But this is no longer true (to be honest I'm not sure it ever was) as it just changes the migration state to "cancelling". In most cases the migration is canceled pretty quickly and we don't really notice anything, but sometimes it takes so long we even get to clearing migration capabilities before the migration is actually canceled, which fails as capabilities can only be changed when no migration is running. So to avoid this issue, we can wait for the migration to be really canceled after sending migrate_cancel. The only place where we don't need synchronous behavior is when we're cancelling migration on user's request while it is actively watched by another thread. https://bugzilla.redhat.com/show_bug.cgi?id=3D2114866 Signed-off-by: Jiri Denemark Reviewed-by: Peter Krempa --- src/qemu/qemu_driver.c | 2 +- src/qemu/qemu_migration.c | 45 +++++++++++++++++++++++++++++++++++---- src/qemu/qemu_migration.h | 3 ++- src/qemu/qemu_process.c | 2 +- 4 files changed, 45 insertions(+), 7 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index a86efc769a..71a1de19b8 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -12811,7 +12811,7 @@ qemuDomainAbortJobMigration(virDomainObj *vm) VIR_DEBUG("Cancelling migration job at client request"); =20 qemuDomainObjAbortAsyncJob(vm); - return qemuMigrationSrcCancel(vm, VIR_ASYNC_JOB_NONE); + return qemuMigrationSrcCancel(vm, VIR_ASYNC_JOB_NONE, false); } =20 =20 diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index 5845dfdb9c..83c3ca4dcf 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -4611,9 +4611,37 @@ qemuMigrationSrcStart(virDomainObj *vm, } =20 =20 +static bool +qemuMigrationSrcIsCanceled(virDomainObj *vm) +{ + qemuDomainObjPrivate *priv =3D vm->privateData; + virDomainJobData *jobData =3D priv->job.current; + + qemuMigrationUpdateJobType(jobData); + switch (jobData->status) { + case VIR_DOMAIN_JOB_STATUS_FAILED: + case VIR_DOMAIN_JOB_STATUS_CANCELED: + case VIR_DOMAIN_JOB_STATUS_COMPLETED: + case VIR_DOMAIN_JOB_STATUS_NONE: + return true; + + case VIR_DOMAIN_JOB_STATUS_MIGRATING: + case VIR_DOMAIN_JOB_STATUS_POSTCOPY: + case VIR_DOMAIN_JOB_STATUS_PAUSED: + case VIR_DOMAIN_JOB_STATUS_HYPERVISOR_COMPLETED: + case VIR_DOMAIN_JOB_STATUS_POSTCOPY_PAUSED: + case VIR_DOMAIN_JOB_STATUS_ACTIVE: + break; + } + + return false; +} + + int qemuMigrationSrcCancel(virDomainObj *vm, - virDomainAsyncJob asyncJob) + virDomainAsyncJob asyncJob, + bool wait) { qemuDomainObjPrivate *priv =3D vm->privateData; =20 @@ -4625,6 +4653,15 @@ qemuMigrationSrcCancel(virDomainObj *vm, qemuMonitorMigrateCancel(priv->mon); qemuDomainObjExitMonitor(vm); =20 + if (virDomainObjIsActive(vm) && wait) { + VIR_DEBUG("Waiting for migration to be canceled"); + + while (!qemuMigrationSrcIsCanceled(vm)) { + if (qemuDomainObjWait(vm) < 0) + return -1; + } + } + return 0; } =20 @@ -4971,7 +5008,7 @@ qemuMigrationSrcRun(virQEMUDriver *driver, =20 if (cancel && priv->job.current->status !=3D VIR_DOMAIN_JOB_STATUS_HYPERVISO= R_COMPLETED) - qemuMigrationSrcCancel(vm, VIR_ASYNC_JOB_MIGRATION_OUT); + qemuMigrationSrcCancel(vm, VIR_ASYNC_JOB_MIGRATION_OUT, true); =20 /* cancel any outstanding NBD jobs */ if (mig && mig->nbd) @@ -6916,7 +6953,7 @@ qemuMigrationSrcToFile(virQEMUDriver *driver, virDoma= inObj *vm, virErrorPreserveLast(&orig_err); virCommandAbort(compressor); if (virDomainObjIsActive(vm)) - qemuMigrationSrcCancel(vm, asyncJob); + qemuMigrationSrcCancel(vm, asyncJob, true); } goto cleanup; } @@ -6963,7 +7000,7 @@ qemuMigrationSrcCancelUnattended(virDomainObj *vm) VIR_DEBUG("Canceling unfinished outgoing migration of domain %s", vm->def->name); =20 - qemuMigrationSrcCancel(vm, VIR_ASYNC_JOB_NONE); + qemuMigrationSrcCancel(vm, VIR_ASYNC_JOB_NONE, true); =20 for (i =3D 0; i < vm->def->ndisks; i++) { virDomainDiskDef *disk =3D vm->def->disks[i]; diff --git a/src/qemu/qemu_migration.h b/src/qemu/qemu_migration.h index 31a5547399..fbea45ad4e 100644 --- a/src/qemu/qemu_migration.h +++ b/src/qemu/qemu_migration.h @@ -245,7 +245,8 @@ qemuMigrationSrcCancelUnattended(virDomainObj *vm); =20 int qemuMigrationSrcCancel(virDomainObj *vm, - virDomainAsyncJob asyncJob); + virDomainAsyncJob asyncJob, + bool wait); =20 int qemuMigrationAnyFetchStats(virDomainObj *vm, diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 4465fa89e9..08eefd0fba 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -3696,7 +3696,7 @@ qemuProcessRecoverJob(virQEMUDriver *driver, case VIR_ASYNC_JOB_SAVE: case VIR_ASYNC_JOB_DUMP: case VIR_ASYNC_JOB_SNAPSHOT: - qemuMigrationSrcCancel(vm, VIR_ASYNC_JOB_NONE); + qemuMigrationSrcCancel(vm, VIR_ASYNC_JOB_NONE, true); /* resume the domain but only if it was paused as a result of * running a migration-to-file operation. Although we are * recovering an async job, this function is run at startup --=20 2.37.2