From nobody Thu May 2 10:26:52 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=1586856750; cv=none; d=zohomail.com; s=zohoarc; b=LeTaLvGP0Bqy9LJEF+5G6ceKWg5QFlnwSThZYDxPxnibviT+zkv7l3T0q+1sevIEnx1hfTWkAZKSN2eq5fy2D1m0C/0NEaJT/TOFXts+sg7ii0+6dlOrRWBdP3rS6il+hqov4YSNC9Uh+0NpGrJTBI3iaxTmQaDQw1TGE78lwy8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1586856750; 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=EldVyjztXqZsTlpn45X2N6sxrEuSnaxtiZQ2VX3Il0A=; b=K2gk6+dPDy3bwV8oiFW4SKt7odjotyLVRMoUMIFGvjS8fl4EbkOAwvOHiDgb1t1OOi7iPvpyxz3IYYhXI3Wc+e4vqaiOaQ0CzG/Udnq5Cz1B39MxHX2LlQA4n+D6TrG1Z7XKwKvoEhOBQZ/5BYx6WcsXUzmJVeNRKgX28qOaGOQ= 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 1586856750521504.59849548527484; Tue, 14 Apr 2020 02:32:30 -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-393-Fxl-HZ10NWSHVXJEhfXf0A-1; Tue, 14 Apr 2020 05:32:27 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id C7DB6107ACCC; Tue, 14 Apr 2020 09:32:21 +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 145FE11D2CA; Tue, 14 Apr 2020 09:32:21 +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 16AB9938E2; Tue, 14 Apr 2020 09:32:20 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 03E9WIFw018758 for ; Tue, 14 Apr 2020 05:32:18 -0400 Received: by smtp.corp.redhat.com (Postfix) id B141B5C1B0; Tue, 14 Apr 2020 09:32:18 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.193.117]) by smtp.corp.redhat.com (Postfix) with ESMTP id 307A35C1D4 for ; Tue, 14 Apr 2020 09:32:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1586856749; 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=EldVyjztXqZsTlpn45X2N6sxrEuSnaxtiZQ2VX3Il0A=; b=cwfJJe+V9de/cjGPid89fBV58lJiciuacvBvMiEf4X46q8bqeUy/BbBV3Tzc2vGWBTVKER /QMMkd3TQ2VmL1j+AhJ+PE2tf2wky4RCi4imjaz8Izvpi/v5TaFNG9IDSVcU1/Usjg+wDO xPYiyyggCxv6J6Km5FDGQQVmLSdJDd4= X-MC-Unique: Fxl-HZ10NWSHVXJEhfXf0A-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH] qemu: Revoke access to mirror on failed blockcopy Date: Tue, 14 Apr 2020 11:32:08 +0200 Message-Id: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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.11 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: Daniel Henrique Barboza --- src/qemu/qemu_driver.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 31f199fdef..9475235f01 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) { @@ -18240,6 +18242,8 @@ qemuDomainBlockCopyCommon(virDomainObjPtr vm, if (crdata) qemuBlockStorageSourceAttachRollback(priv->mon, crdata->srcdat= a[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.24.1