From nobody Sun May 5 05:35:54 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) client-ip=205.139.110.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 205.139.110.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=1587023202; cv=none; d=zohomail.com; s=zohoarc; b=Hd4QJBBA0orh7UTJe/QdnseFcyCH1Z7QGCwVw08nLoHhdXJVtO2n9+NdpnasN7V/yRYOU6rgzhwku2+iv2BARVvdIngZTXu7jEpBceIgvcwdOrRachHumT864EL2O1zV0iReWWXsrVlx1mpJx1e/Y75pvO8cmsC6m8enduk6fC8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1587023202; h=Content-Type:Content-Transfer-Encoding:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=VKILjby2OCjwuPv+6DphHfct6Orj56q7H8kq9jJnfDs=; b=A+5nGoZm0bot+263VbLyD6NWsdFsddUkG311EkKFgdUlyxiOyRuePxuy1wXcSYeW+hI27CTonaTCS9Mm/3Y3nYX3CHtocv6fq5lLe2/DEWKhJlgZcsXQAl3MNUKAIUpAN9MFPJn+tp+JlioJmrP0/RiyE7fSviksGZptSHf/uP0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.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 [205.139.110.120]) by mx.zohomail.com with SMTPS id 1587023202877562.5825974156588; Thu, 16 Apr 2020 00:46:42 -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-380-6tZZ4EmdOoKkywOiSRtE4w-1; Thu, 16 Apr 2020 03:46:39 -0400 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 B99AB801E67; Thu, 16 Apr 2020 07:46:33 +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 1AD3F116D8C; Thu, 16 Apr 2020 07:46:33 +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 ABAF493373; Thu, 16 Apr 2020 07:46:30 +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 03G7gp1U011433 for ; Thu, 16 Apr 2020 03:42:51 -0400 Received: by smtp.corp.redhat.com (Postfix) id 6E4F57E7C1; Thu, 16 Apr 2020 07:42:51 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.194.82]) by smtp.corp.redhat.com (Postfix) with ESMTP id E24387E7C0 for ; Thu, 16 Apr 2020 07:42:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1587023201; 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:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=VKILjby2OCjwuPv+6DphHfct6Orj56q7H8kq9jJnfDs=; b=Hza4S8g+A+QBml6PD41yVsmceY8G5VAfP/KlqkR6H4IALYBYZztL2wSQp+KwCajoLHlGTu K9RPiHOS4rIvlPxlQONdsA1oNGhKpfUgAzwnTx2oautOBerhrhDXwSihx6EeRtXGFVNmpv hAtpLrJYrKJ9QtRrZRsPDd7TcZXaQNE= X-MC-Unique: 6tZZ4EmdOoKkywOiSRtE4w-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH v2] qemu: Revoke access to mirror on failed blockcopy Date: Thu, 16 Apr 2020 09:42:46 +0200 Message-Id: <9cdae29c4f935cb3bac51d80db5f8f544cdcaacd.1587022901.git.mprivozn@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com 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-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" When preparing to do a blockcopy, the mirror image is modified so that QEMU can access it. For instance, the mirror has seclabels set, if it is a NVMe disk it is detached from the host and so on. And usually, the restore is done upon successful finish of the blockcopy operation. But, if something fails then we need to explicitly revoke the access to the mirror image (and thus reattach NVMe disk back to the host). Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=3D1822538 Signed-off-by: Michal Privoznik Reviewed-by: Pavel Mores --- diff to v1: - Fix call of qemuDomainStorageSourceChainAccessRevoke() so that it is called even if data =3D crdata =3D NULL. src/qemu/qemu_driver.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 31f199fdef..dfe0adaad8 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -17950,6 +17950,7 @@ qemuDomainBlockCopyCommon(virDomainObjPtr vm, virDomainDiskDefPtr disk =3D NULL; int ret =3D -1; bool need_unlink =3D false; + bool need_revoke =3D false; g_autoptr(virQEMUDriverConfig) cfg =3D virQEMUDriverGetConfig(driver); const char *format =3D NULL; bool mirror_reuse =3D !!(flags & VIR_DOMAIN_BLOCK_COPY_REUSE_EXT); @@ -18124,6 +18125,7 @@ qemuDomainBlockCopyCommon(virDomainObjPtr vm, =20 if (qemuDomainStorageSourceChainAccessAllow(driver, vm, mirror) < 0) goto endjob; + need_revoke =3D true; =20 if (blockdev) { if (mirror_reuse) { @@ -18232,14 +18234,17 @@ qemuDomainBlockCopyCommon(virDomainObjPtr vm, =20 endjob: if (ret < 0 && - virDomainObjIsActive(vm) && - (data || crdata)) { - qemuDomainObjEnterMonitor(driver, vm); - if (data) - qemuBlockStorageSourceChainDetach(priv->mon, data); - if (crdata) - qemuBlockStorageSourceAttachRollback(priv->mon, crdata->srcdat= a[0]); - ignore_value(qemuDomainObjExitMonitor(driver, vm)); + virDomainObjIsActive(vm)) { + if (data || crdata) { + qemuDomainObjEnterMonitor(driver, vm); + if (data) + qemuBlockStorageSourceChainDetach(priv->mon, data); + if (crdata) + qemuBlockStorageSourceAttachRollback(priv->mon, crdata->sr= cdata[0]); + ignore_value(qemuDomainObjExitMonitor(driver, vm)); + } + if (need_revoke) + qemuDomainStorageSourceChainAccessRevoke(driver, vm, mirror); } if (need_unlink && virStorageFileUnlink(mirror) < 0) VIR_WARN("%s", _("unable to remove just-created copy target")); --=20 2.25.3