From nobody Mon Feb 9 16:02:50 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) client-ip=205.139.110.61; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.61 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=1588765376; cv=none; d=zohomail.com; s=zohoarc; b=EH/W9F1lCV7c1K9lBasPaK1GpDgKjrtT3EtIuCUIzEErMd1TBr5ytVu7f2VH5xQpnYwdqnPGRvyLkZU9YwmUTJlaQSAdc6PL+1DqXbOoibAkzb1RHdOgRlrXVynxvz3gZY6x7n7uVvn/NxZcZxxDj+AmJKIDJZIWRAbHvnheQHU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1588765376; h=Content-Type:Content-Transfer-Encoding:Cc: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=dM6DuqoeohFVz2baOT3hCi9xkDzHrDrG7MPo77by3Ts=; b=Exevq+icv30Og2szykjSZ5n+hD5q0xTY/BDOmoU31PhykrFqwH/x8PZoozaLyVzdaXKgc+LbnjpJ8Dr1UPOifrGAAXW8m+yqcxTfTH0EQXMsuWWOKtYgtNeCkMPdvEBCHOKibLrRmmIwIsPHu4uwNgjManjzwlz2zptdsrO/x1U= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.61 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-delivery-1.mimecast.com (us-smtp-2.mimecast.com [205.139.110.61]) by mx.zohomail.com with SMTPS id 1588765376123326.81554197829996; Wed, 6 May 2020 04:42:56 -0700 (PDT) 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-424-o70iKMFoP0eMSMnujOIxNQ-1; Wed, 06 May 2020 07:42:51 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id C6CB18B1345; Wed, 6 May 2020 11:42:37 +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 9ED092E172; Wed, 6 May 2020 11:42:37 +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 DBE311809554; Wed, 6 May 2020 11:42:36 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 046BgVdY026758 for ; Wed, 6 May 2020 07:42:31 -0400 Received: by smtp.corp.redhat.com (Postfix) id CA5CE1053B1F; Wed, 6 May 2020 11:42:31 +0000 (UTC) Received: from ibm-p8-15-fsp.mgmt.pnr.lab.eng.rdu2.redhat.com (unknown [10.40.195.180]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0732210013D9; Wed, 6 May 2020 11:42:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1588765373; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc: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=dM6DuqoeohFVz2baOT3hCi9xkDzHrDrG7MPo77by3Ts=; b=VbAL3XbSH5kN90isTRv1V641E0/O4tGcMBD/DmhdfpvoTi2vfEZDygCsY3copem9R1uD07 nxOrvl2gGbqY6N6xYx5L7huEUOZMGTwqzXmsEHjPUG2hucCp1aTARlBzH6L0iaOg6zs+BP S13OOZfAAc7BL8InqECaYJORNPIqMvo= X-MC-Unique: o70iKMFoP0eMSMnujOIxNQ-1 From: Pavel Mores To: libvir-list@redhat.com Subject: [libvirt PATCH v2 03/10] qemu: block: factor implementation out of qemuDomainBlockJobAbort() Date: Wed, 6 May 2020 13:42:19 +0200 Message-Id: <20200506114226.2538196-4-pmores@redhat.com> In-Reply-To: <20200506114226.2538196-1-pmores@redhat.com> References: <20200506114226.2538196-1-pmores@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com Cc: Pavel Mores 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.84 on 10.5.11.23 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Just as with the qemuDomainBlockCommit() refactor in the commit before the previous one, the motivation is primarily to make blockjob abortion callable from within the QEMU driver where only virDomainObj instance is available but no virDomain. Signed-off-by: Pavel Mores --- src/qemu/qemu_driver.c | 62 ++++++++++++++++++++++++++++-------------- 1 file changed, 41 insertions(+), 21 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 09300c1e90..6ffd53503b 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -163,6 +163,12 @@ qemuDomainBlockCommitImpl(virDomainObjPtr vm, unsigned long bandwidth, unsigned int flags); =20 +static int +qemuDomainBlockJobAbortImpl(virQEMUDriverPtr driver, + virDomainObjPtr vm, + const char *path, + unsigned int flags); + /* Looks up the domain object from snapshot and unlocks the * driver. The returned domain object is locked and ref'd and the * caller must call virDomainObjEndAPI() on it. */ @@ -17541,45 +17547,31 @@ qemuDomainBlockPullCommon(virDomainObjPtr vm, return ret; } =20 - static int -qemuDomainBlockJobAbort(virDomainPtr dom, - const char *path, - unsigned int flags) +qemuDomainBlockJobAbortImpl(virQEMUDriverPtr driver, + virDomainObjPtr vm, + const char *path, + unsigned int flags) { - virQEMUDriverPtr driver =3D dom->conn->privateData; virDomainDiskDefPtr disk =3D NULL; g_autoptr(virQEMUDriverConfig) cfg =3D virQEMUDriverGetConfig(driver); bool pivot =3D !!(flags & VIR_DOMAIN_BLOCK_JOB_ABORT_PIVOT); bool async =3D !!(flags & VIR_DOMAIN_BLOCK_JOB_ABORT_ASYNC); g_autoptr(qemuBlockJobData) job =3D NULL; - virDomainObjPtr vm; qemuDomainObjPrivatePtr priv =3D NULL; bool blockdev =3D false; int ret =3D -1; =20 - virCheckFlags(VIR_DOMAIN_BLOCK_JOB_ABORT_ASYNC | - VIR_DOMAIN_BLOCK_JOB_ABORT_PIVOT, -1); - - if (!(vm =3D qemuDomainObjFromDomain(dom))) - return -1; - - if (virDomainBlockJobAbortEnsureACL(dom->conn, vm->def) < 0) - goto cleanup; - - if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_MODIFY) < 0) - goto cleanup; - if (virDomainObjCheckActive(vm) < 0) - goto endjob; + return -1; =20 if (!(disk =3D qemuDomainDiskByName(vm->def, path))) - goto endjob; + return -1; =20 if (!(job =3D qemuBlockJobDiskGetJob(disk))) { virReportError(VIR_ERR_INVALID_ARG, _("disk %s does not have an active block job"), dis= k->dst); - goto endjob; + return -1; } =20 priv =3D vm->privateData; @@ -17650,6 +17642,34 @@ qemuDomainBlockJobAbort(virDomainPtr dom, endjob: if (job && !async) qemuBlockJobSyncEnd(vm, job, QEMU_ASYNC_JOB_NONE); + + return ret; +} + + +static int +qemuDomainBlockJobAbort(virDomainPtr dom, + const char *path, + unsigned int flags) +{ + virQEMUDriverPtr driver =3D dom->conn->privateData; + virDomainObjPtr vm; + int ret =3D -1; + + virCheckFlags(VIR_DOMAIN_BLOCK_JOB_ABORT_ASYNC | + VIR_DOMAIN_BLOCK_JOB_ABORT_PIVOT, -1); + + if (!(vm =3D qemuDomainObjFromDomain(dom))) + return -1; + + if (virDomainBlockJobAbortEnsureACL(dom->conn, vm->def) < 0) + goto cleanup; + + if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_MODIFY) < 0) + goto cleanup; + + ret =3D qemuDomainBlockJobAbortImpl(driver, vm, path, flags); + qemuDomainObjEndJob(driver, vm); =20 cleanup: --=20 2.24.1