From nobody Mon Nov 25 22:43:10 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=1588845057; cv=none; d=zohomail.com; s=zohoarc; b=hAOpRnpimrGDDblDr1QxZiT/G8s7XjBk7vYmmUWm0wQKTDyJswbv5WE/OSK2WDpfjhQwb3BhJRrDfN+/9pog3juLqH1JPXsrba1KWg5nVyPCKB3xUzWPG1piI90TTNdGxwJDo7dP3AUUO2fO5K+ORIWqZHQP8rbgBi/YjaurAbA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1588845057; 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=XJbQM9z4jRQ/j0FlF35Ee+R9MR+kY9Fg7ucD1rVWHxQ=; b=kXVAguf1UUcMFLESKAYB3E0Mk+m3DKeXZBvxJdhq2u0VbbiHactCV6FrX3q62ErTThzJLvamh+LxjHNxDqHrNjAi9rWav7GBPxfgYrvwgeC8uQ0xRrW6oYPteraiPUqR53QqaixwYPZyDebn5z6DUAQHwvnSLloWPGN3RUayElc= 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 1588845057784125.6521584825706; Thu, 7 May 2020 02:50:57 -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-399-noIoBJnLM0Ssn6yzdNv6YA-1; Thu, 07 May 2020 05:50:54 -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 A01E2107ACCA; Thu, 7 May 2020 09:50:48 +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 73C3E62A50; Thu, 7 May 2020 09:50:48 +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 C59AA1809542; Thu, 7 May 2020 09:50:47 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 0479oj13002332 for ; Thu, 7 May 2020 05:50:45 -0400 Received: by smtp.corp.redhat.com (Postfix) id C3F4C60CD0; Thu, 7 May 2020 09:50:45 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.193.214]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4220A60CCC for ; Thu, 7 May 2020 09:50:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1588845056; 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=XJbQM9z4jRQ/j0FlF35Ee+R9MR+kY9Fg7ucD1rVWHxQ=; b=b7IR0xi5HQ5PswNNuLX+hGXsSUZf70mVWyPR+qhi53L65Wqtb1xVyDBSVhkjKDCHTyzw1P CmQxZiXiqkZyOQvXFkrH9x1lzv3rbmq/TC+AV3pU325VP/KL7rUo0nlOLzLT5t6ydrh3LY jgJwWp5RW95DvD0Bonh42tPmJF2Q85Y= X-MC-Unique: noIoBJnLM0Ssn6yzdNv6YA-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH v2] qemuProcessStop: Reattach NVMe disks a domain is mirroring into Date: Thu, 7 May 2020 11:50:40 +0200 Message-Id: <54c21d447691e86e518f638e25e4693b5009986f.1588844958.git.mprivozn@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 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" In v5.10.0-rc1~42 (which was later fixed in v6.0.0-rc1~487) I am removing XATTRs for a file that QEMU is mirroring a disk into but it is killed meanwhile. Well, we can call qemuSecurityRestoreImageLabel() which will not only remove XATTRs but also use them to restore the original owner of the file. Moreover, if the mirror destination is not a file but a NVMe disk, then call qemuHostdevReAttachOneNVMeDisk() to reattach the NVMe back to the host. All of this would be done by blockjob code when the job finishes, but in this case the job won't finish - QEMU is killed meanwhile. Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=3D1825785 Signed-off-by: Michal Privoznik Reviewed-by: Peter Krempa --- v2 of: https://www.redhat.com/archives/libvir-list/2020-May/msg00210.html diff to v1: - per Peter's review, instead of calling qemuDomainStorageSourceAccessRevok= e() call only some functions it would call. src/qemu/qemu_process.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 8ea470f75f..65d51e58c9 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -7604,8 +7604,13 @@ void qemuProcessStop(virQEMUDriverPtr driver, for (i =3D 0; i < def->ndisks; i++) { virDomainDiskDefPtr disk =3D def->disks[i]; =20 - if (disk->mirror) - qemuBlockRemoveImageMetadata(driver, vm, disk->dst, disk->= mirror); + if (disk->mirror) { + if (qemuSecurityRestoreImageLabel(driver, vm, disk->mirror= , false) < 0) + VIR_WARN("Unable to restore security label on %s", dis= k->dst); + + if (virStorageSourceChainHasNVMe(disk->mirror)) + qemuHostdevReAttachOneNVMeDisk(driver, vm->def->name, = disk->mirror); + } =20 qemuBlockRemoveImageMetadata(driver, vm, disk->dst, disk->src); } --=20 2.26.2