From nobody Sun May 5 23:46:44 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) client-ip=207.211.31.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 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=1575546917; cv=none; d=zohomail.com; s=zohoarc; b=IPHvhfMkEAWpoCTtsCey5JjSxwYmImX9jnsP95uYPKSn3vTNcUAlfCjbgjO21JG3VD1acaoF4umujwA2V/egmLcw3TBPBIn/UibsuYw6dAby63Tme/x4NFFED5Px7D7yRNXOXemsQgkVdX2wToFb8SVuEugq4bPI7EzfwBl7gRY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1575546917; 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=4QvbHSYnhCjNJ/MaAX5F9mKWkVoxrLuIzRU0j7lFvZU=; b=BBg6+JGeRECfdK1khaH/8mYAtgxxi6P7eCEit2AomeO+7R7dA4MLaZT0s7aYvsZuorafSVmXeXKvQTwMkvqZkz5obUXPyK2H1V3yBSGBpQlgsrskjLkihxyGyG52PhH/SGimEtH5inpUletAziodCs4UJyB2E72/CZipCOZWhII= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by mx.zohomail.com with SMTPS id 157554691717077.88287908437792; Thu, 5 Dec 2019 03:55:17 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-259-XhhEK5X4P9CTlbONkup_yQ-1; Thu, 05 Dec 2019 06:55:13 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 253A7800D54; Thu, 5 Dec 2019 11:55:08 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id EAFCD5D6A5; Thu, 5 Dec 2019 11:55:07 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 85A7518089CD; Thu, 5 Dec 2019 11:55:07 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id xB5Bskfq009480 for ; Thu, 5 Dec 2019 06:54:46 -0500 Received: by smtp.corp.redhat.com (Postfix) id D5EDC60126; Thu, 5 Dec 2019 11:54:46 +0000 (UTC) Received: from angien.redhat.com (unknown [10.43.2.48]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5EE4B600F0 for ; Thu, 5 Dec 2019 11:54:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1575546916; 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=4QvbHSYnhCjNJ/MaAX5F9mKWkVoxrLuIzRU0j7lFvZU=; b=Yu91JJhJojC/OjtfH0oes69gJ48cKJ3x100dOYBeILbOb0ZmpD2uM4QUjB+BCLQvRB+WA7 qG5It8q4Pv/LL5u3CgzeuVcxC8H2fNkL0VzXM+4MH6cpxGIeD+4bJ8HPPgbAa3h1/dOf8X ZVPcpyUcqd8z+lOI/w0EiGIiETCVpN8= From: Peter Krempa To: libvir-list@redhat.com Date: Thu, 5 Dec 2019 12:54:38 +0100 Message-Id: <9acd0054eda3153262e94d4310d406f163e26dc7.1575546793.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 1/2] qemu: driver: Split out cancellation of migration from qemuDomainAbortJob X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-MC-Unique: XhhEK5X4P9CTlbONkup_yQ-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Following patch will refactor qemuDomainAbortJob to use a per-job-type switch where we will need to abort a migration job in various branches. Save some code duplication by introducing a helper. Signed-off-by: Peter Krempa Reviewed-by: Jiri Denemark --- src/qemu/qemu_driver.c | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 1911073f3e..4cfc1ca9e7 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -13996,6 +13996,24 @@ qemuDomainGetJobStats(virDomainPtr dom, } +static int +qemuDomainAbortJobMigration(virDomainObjPtr vm) +{ + qemuDomainObjPrivatePtr priv =3D vm->privateData; + int ret; + + VIR_DEBUG("Cancelling migration job at client request"); + + qemuDomainObjAbortAsyncJob(vm); + qemuDomainObjEnterMonitor(priv->driver, vm); + ret =3D qemuMonitorMigrateCancel(priv->mon); + if (qemuDomainObjExitMonitor(priv->driver, vm) < 0) + ret =3D -1; + + return ret; +} + + static int qemuDomainAbortJob(virDomainPtr dom) { virQEMUDriverPtr driver =3D dom->conn->privateData; @@ -14047,12 +14065,7 @@ static int qemuDomainAbortJob(virDomainPtr dom) goto endjob; } - VIR_DEBUG("Cancelling job at client request"); - qemuDomainObjAbortAsyncJob(vm); - qemuDomainObjEnterMonitor(driver, vm); - ret =3D qemuMonitorMigrateCancel(priv->mon); - if (qemuDomainObjExitMonitor(driver, vm) < 0) - ret =3D -1; + ret =3D qemuDomainAbortJobMigration(vm); endjob: qemuDomainObjEndJob(driver, vm); --=20 2.23.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun May 5 23:46:44 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) client-ip=207.211.31.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 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=1575546902; cv=none; d=zohomail.com; s=zohoarc; b=JR5ofK2H+BHNDtIGYrZ4Uch9PBKq8mDcvg22YnNuqw87mZeuCE4jU/glffWKZHNr0AYVEWwPSdVrB7guyNgEn4cCev4rVPawdDjkULIM31vwO1b8MEzkB+sAGxdwonbHqoFLkTHbsBDOAhPR7KtQmbOlPUG2NucSdsmQT9a56w0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1575546902; 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=I4ppd25OG387ekmRtQb1UXVJ1/ORyhZIsPKmqoMKW3Q=; b=nlmQy0aPZinpsxK9CFkWqc1hiaHYItDqqYCkBYl6GCuz5Z3TTOVMaxu17kqbdT0LBA7LHkRRYjSWne3LVMUB5AVMl5rHypHQwGfnZTY1GhYdL56jSsryUcaTcABL64AOcNshzQKRYfDW6uBVDLPFkDmEiL/JL4NRZRKIQHSW6F4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by mx.zohomail.com with SMTPS id 1575546902203706.999723911387; Thu, 5 Dec 2019 03:55:02 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-181-dNNulVTeOBKIGorB88nKLg-1; Thu, 05 Dec 2019 06:54:59 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 7FF6A801E74; Thu, 5 Dec 2019 11:54:52 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D42435D6AE; Thu, 5 Dec 2019 11:54:51 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 57A0D65D1C; Thu, 5 Dec 2019 11:54:50 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id xB5BslIL009485 for ; Thu, 5 Dec 2019 06:54:47 -0500 Received: by smtp.corp.redhat.com (Postfix) id A7ECE60126; Thu, 5 Dec 2019 11:54:47 +0000 (UTC) Received: from angien.redhat.com (unknown [10.43.2.48]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3039A600F0 for ; Thu, 5 Dec 2019 11:54:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1575546901; 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=I4ppd25OG387ekmRtQb1UXVJ1/ORyhZIsPKmqoMKW3Q=; b=DwmXrktON4H2yhAhoSzi5BIWKHTP0B52gC7ObuHMFkCnQ3olxoSphtoL6wXxX3g+PRWSCK PqQ5H8ST28bjnBY2qb4TTSOr6dJx7auiRjVUo9vCMZYvrt3O5yV++GqRdusSvy2xTf50PY PH/SuR3rL9w5YfoDSO/wF8oPFq0WpBo= From: Peter Krempa To: libvir-list@redhat.com Date: Thu, 5 Dec 2019 12:54:39 +0100 Message-Id: <3bfdac541a4a38ec6372f312758ce0aef6f3571b.1575546793.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 2/2] qemu: Convert aborting of a domain job to a switch statement X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-MC-Unique: dNNulVTeOBKIGorB88nKLg-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Until now we only really aborted migration via qemuDomainAbortJob. This will change with the upcoming addition of the backup job. Additionally there were a bunch of if statements checking various aspects of the current job. To make it more obvious convert qemuDomainAbortJob to use a switch statement and move the individual conditions to the appropriate job type. Every job type has now it's own case despite multiple job types just plainly cancelling the job for clarity and future extension. Signed-off-by: Peter Krempa Reviewed-by: Jiri Denemark --- src/qemu/qemu_driver.c | 67 ++++++++++++++++++++++++++++-------------- 1 file changed, 45 insertions(+), 22 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 4cfc1ca9e7..bad2fb52f3 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -14036,36 +14036,59 @@ static int qemuDomainAbortJob(virDomainPtr dom) priv =3D vm->privateData; - if (!priv->job.asyncJob) { - virReportError(VIR_ERR_OPERATION_INVALID, - "%s", _("no job is active on the domain")); - goto endjob; - } + switch (priv->job.asyncJob) { + case QEMU_ASYNC_JOB_NONE: + virReportError(VIR_ERR_OPERATION_INVALID, "%s", + _("no job is active on the domain")); + break; - if (priv->job.asyncJob =3D=3D QEMU_ASYNC_JOB_MIGRATION_IN) { + case QEMU_ASYNC_JOB_MIGRATION_IN: virReportError(VIR_ERR_OPERATION_INVALID, "%s", _("cannot abort incoming migration;" " use virDomainDestroy instead")); - goto endjob; - } + break; - if (priv->job.asyncJob =3D=3D QEMU_ASYNC_JOB_DUMP && - priv->job.apiFlags & VIR_DUMP_MEMORY_ONLY) { + case QEMU_ASYNC_JOB_START: virReportError(VIR_ERR_OPERATION_INVALID, "%s", - _("cannot abort memory-only dump")); - goto endjob; - } + _("cannot abort VM start;" + " use virDomainDestroy instead")); + break; - if (priv->job.asyncJob =3D=3D QEMU_ASYNC_JOB_MIGRATION_OUT && - (priv->job.current->status =3D=3D QEMU_DOMAIN_JOB_STATUS_POSTCOPY = || - (virDomainObjGetState(vm, &reason) =3D=3D VIR_DOMAIN_PAUSED && - reason =3D=3D VIR_DOMAIN_PAUSED_POSTCOPY))) { - virReportError(VIR_ERR_OPERATION_INVALID, "%s", - _("cannot abort migration in post-copy mode")); - goto endjob; - } + case QEMU_ASYNC_JOB_MIGRATION_OUT: + if ((priv->job.current->status =3D=3D QEMU_DOMAIN_JOB_STATUS_POSTC= OPY || + (virDomainObjGetState(vm, &reason) =3D=3D VIR_DOMAIN_PAUSED && + reason =3D=3D VIR_DOMAIN_PAUSED_POSTCOPY))) { + virReportError(VIR_ERR_OPERATION_INVALID, "%s", + _("cannot abort migration in post-copy mode")); + goto endjob; + } - ret =3D qemuDomainAbortJobMigration(vm); + ret =3D qemuDomainAbortJobMigration(vm); + break; + + case QEMU_ASYNC_JOB_SAVE: + ret =3D qemuDomainAbortJobMigration(vm); + break; + + case QEMU_ASYNC_JOB_DUMP: + if (priv->job.apiFlags & VIR_DUMP_MEMORY_ONLY) { + virReportError(VIR_ERR_OPERATION_INVALID, "%s", + _("cannot abort memory-only dump")); + goto endjob; + } + + ret =3D qemuDomainAbortJobMigration(vm); + break; + + case QEMU_ASYNC_JOB_SNAPSHOT: + ret =3D qemuDomainAbortJobMigration(vm); + break; + + case QEMU_ASYNC_JOB_LAST: + default: + virReportEnumRangeError(qemuDomainAsyncJob, priv->job.asyncJob); + break; + } endjob: qemuDomainObjEndJob(driver, vm); --=20 2.23.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list