From nobody Sat May 4 11:39:22 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 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=1567176993; cv=none; d=zoho.com; s=zohoarc; b=njuYDotASUjprATYBFWDiiVM42Nnfdw+T0E9MyGKcwTPssImpuMLFXUD6WSQJI+OD1pPEtW6ujFgjuWejIrXHcfrN1u7lEgQy9GajLEhx5pRyOFnMHa8zwoomgDmTDO9EXWLejPaaIEsoh/xk59XqrVO5DvQ8Eb16LwD37oIyqY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1567176993; 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:ARC-Authentication-Results; bh=cFP+2g8SUrPyEqszmXb1Jgo8ts5/TwxyqIUrm/qMNs4=; b=WhbSjq05zpMg6WgQQ9y0k7pDPgX6LuKvj90qSN3oGGDD6xctAftNte675YpnR1uJrsLLO5WI7rLLpR2TnukU7/kIOmvqhF7XD9XEG/iHhj6stU7Jk2TGHyHsTtpWtjC1XEB/k+c6hd4WeDTWurnnFKZ/+bkx31pdQZVZO6Y7UWc= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 15671769930421009.9565425893511; Fri, 30 Aug 2019 07:56:33 -0700 (PDT) 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 mx1.redhat.com (Postfix) with ESMTPS id 8B38D3003AFE; Fri, 30 Aug 2019 14:56:31 +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 615E219C77; Fri, 30 Aug 2019 14:56:31 +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 D30A124F36; Fri, 30 Aug 2019 14:56: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 x7UEuFTE024488 for ; Fri, 30 Aug 2019 10:56:15 -0400 Received: by smtp.corp.redhat.com (Postfix) id C163460166; Fri, 30 Aug 2019 14:56:15 +0000 (UTC) Received: from moe.brq.redhat.com (unknown [10.43.2.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4A838600F8 for ; Fri, 30 Aug 2019 14:56:15 +0000 (UTC) From: Michal Privoznik To: libvir-list@redhat.com Date: Fri, 30 Aug 2019 16:56:08 +0200 Message-Id: <0c0c208727a0ebb5f6f9d0063762f23d06609f31.1567176843.git.mprivozn@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 for 5.7.0 v2 1/3] qemu_blockjob: Move active commit failed state handling into a function 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: , Content-Transfer-Encoding: quoted-printable 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-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.45]); Fri, 30 Aug 2019 14:56:32 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Currently, there are only a few lines of code so a separate function was not necessary, but this will change. So instead of putting all the new code under 'case QEMU_BLOCKJOB_TYPE_ACTIVE_COMMIT' create a separate function. Just like every other case has one. Signed-off-by: Michal Privoznik ACKed-by: Peter Krempa --- src/qemu/qemu_blockjob.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/src/qemu/qemu_blockjob.c b/src/qemu/qemu_blockjob.c index 3003e9c518..c77a129bfc 100644 --- a/src/qemu/qemu_blockjob.c +++ b/src/qemu/qemu_blockjob.c @@ -1121,6 +1121,20 @@ qemuBlockJobProcessEventConcludedCopyAbort(virQEMUDr= iverPtr driver, } =20 =20 +static void +qemuBlockJobProcessEventFailedActiveCommit(virDomainObjPtr vm, + qemuBlockJobDataPtr job) +{ + VIR_DEBUG("active commit job '%s' on VM '%s' failed", job->name, vm->d= ef->name); + + if (!job->disk) + return; + + virObjectUnref(job->disk->mirror); + job->disk->mirror =3D NULL; +} + + static void qemuBlockJobProcessEventConcludedCreate(virQEMUDriverPtr driver, virDomainObjPtr vm, @@ -1211,10 +1225,7 @@ qemuBlockJobEventProcessConcludedTransition(qemuBloc= kJobDataPtr job, break; =20 case QEMU_BLOCKJOB_TYPE_ACTIVE_COMMIT: - if (job->disk) { - virObjectUnref(job->disk->mirror); - job->disk->mirror =3D NULL; - } + qemuBlockJobProcessEventFailedActiveCommit(vm, job); break; =20 case QEMU_BLOCKJOB_TYPE_CREATE: --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sat May 4 11:39:22 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 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=1567176982; cv=none; d=zoho.com; s=zohoarc; b=TrXkaqKg+FQZCvFEbJhoTO3boWzELEXXes/1l05lOjAjdjs0MoZUvACKdZ9UdaMbcMmQYDGcVa+qBrdOM1Iwclt+FxW9SfUzQ6BWen088iXxYf4CRlVWIS1QeHgRL1CZpfPpSCpYhDbzZ2r1RSodPP2Eut81BNpOhOR5GckWSUk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1567176982; 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:ARC-Authentication-Results; bh=HbLekBdJIXjLePA6h1hc0oKxx1IGxQwYB2ri5mAbxAU=; b=nn21tJy8rrAI4y0fpRFJ5e86tWoJvVYlMcPAL4ROum9vSqhSn8d7OJOi/pTReGXcQxiqqem/o7CpNjpckFz3a7mE91SzFOSTqm4gl9M9nVmBzKoKd4jbpAc1o6ucOIW4is4F/VXTZRmMfUVstTL0tg/Pkmo1NFf5pNTLBneXsDA= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1567176982216486.2413146525927; Fri, 30 Aug 2019 07:56:22 -0700 (PDT) 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 mx1.redhat.com (Postfix) with ESMTPS id CF7E8C0546FB; Fri, 30 Aug 2019 14:56:20 +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 A735D5D772; Fri, 30 Aug 2019 14:56:20 +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 10F1A24F31; Fri, 30 Aug 2019 14:56:19 +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 x7UEuGkv024496 for ; Fri, 30 Aug 2019 10:56:16 -0400 Received: by smtp.corp.redhat.com (Postfix) id 8FD296012C; Fri, 30 Aug 2019 14:56:16 +0000 (UTC) Received: from moe.brq.redhat.com (unknown [10.43.2.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id 197A8600F8 for ; Fri, 30 Aug 2019 14:56:15 +0000 (UTC) From: Michal Privoznik To: libvir-list@redhat.com Date: Fri, 30 Aug 2019 16:56:09 +0200 Message-Id: <2739663219b4952bb846a67361d7409433903ef7.1567176843.git.mprivozn@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 for 5.7.0 v2 2/3] qemu_blockjob: Print image path on failed security metadata move too 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: , Content-Transfer-Encoding: quoted-printable 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-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Fri, 30 Aug 2019 14:56:21 +0000 (UTC) Content-Type: text/plain; charset="utf-8" When a block job is completed, the security image metadata are moved to the new image. If this fails an warning is printed, but the message contains only domain name and lacks image paths. Put them both into the warning message. Signed-off-by: Michal Privoznik ACKed-by: Peter Krempa --- src/qemu/qemu_blockjob.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/qemu/qemu_blockjob.c b/src/qemu/qemu_blockjob.c index c77a129bfc..1b22689e0c 100644 --- a/src/qemu/qemu_blockjob.c +++ b/src/qemu/qemu_blockjob.c @@ -646,8 +646,14 @@ qemuBlockJobEventProcessLegacyCompleted(virQEMUDriverP= tr driver, virDomainLockImageDetach(driver->lockManager, vm, disk->src); =20 /* Move secret driver metadata */ - if (qemuSecurityMoveImageMetadata(driver, vm, disk->src, disk->mir= ror) < 0) - VIR_WARN("Unable to move disk metadata on vm %s", vm->def->nam= e); + if (qemuSecurityMoveImageMetadata(driver, vm, disk->src, disk->mir= ror) < 0) { + VIR_WARN("Unable to move disk metadata on " + "vm %s from %s to %s (disk target %s)", + vm->def->name, + NULLSTR(disk->src->path), + NULLSTR(disk->mirror->path), + disk->dst); + } =20 virObjectUnref(disk->src); disk->src =3D disk->mirror; --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sat May 4 11:39:22 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 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=1567176997; cv=none; d=zoho.com; s=zohoarc; b=PzgXYjRGOdN/m7UivLJHXMrHaLDbu/wFqgMc4kTO/8FN0Io5nl0gVs1x8aG3BVg8ucPOsZhqw/YhkPSi2SJDkY/aJ8u2RF5lgnwbNIyqX7uTU9CxnNHJGeNUl3HzWIFDaLFn4PQzCc6xlggg01UalFl00RRQkBuuVi+i+FIAnuk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1567176997; 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:ARC-Authentication-Results; bh=aY3wBLqkt7Y+XQVDN+7twVIvwflh4gIe78UxNj6vEiI=; b=Oj7TFzlk2dmSp28/UA5P5QvQ/Q0t+7S449wzfV2eNl69qF0/zHGF8BvDafkCgyprvM+lucO7v2+4b/olOn6RLN4VPC+Dee819CF9NjHeJ7nvcQKlrl3G3varCiwRQkA0Y9uOS9r0dbhQoLDGdLJmzAxUQvxIfL8Z7I3fKgaRW04= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1567176997580482.8448705620124; Fri, 30 Aug 2019 07:56:37 -0700 (PDT) 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 mx1.redhat.com (Postfix) with ESMTPS id 5A3623082DDD; Fri, 30 Aug 2019 14:56:36 +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 2F8EB6012E; Fri, 30 Aug 2019 14:56:36 +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 834BC24F39; Fri, 30 Aug 2019 14:56:34 +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 x7UEuHPc024506 for ; Fri, 30 Aug 2019 10:56:17 -0400 Received: by smtp.corp.redhat.com (Postfix) id 62B9C600F8; Fri, 30 Aug 2019 14:56:17 +0000 (UTC) Received: from moe.brq.redhat.com (unknown [10.43.2.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id DE63460BD0 for ; Fri, 30 Aug 2019 14:56:16 +0000 (UTC) From: Michal Privoznik To: libvir-list@redhat.com Date: Fri, 30 Aug 2019 16:56:10 +0200 Message-Id: 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 for 5.7.0 v2 3/3] qemu_blockjob: Remove secdriver metadata more frequently 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: , Content-Transfer-Encoding: quoted-printable 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-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.46]); Fri, 30 Aug 2019 14:56:36 +0000 (UTC) Content-Type: text/plain; charset="utf-8" If a block job reaches failed/cancelled state, or is completed without pivot then we must remove security driver metadata associated to the backing chain so that we don't leave any metadata behind. Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=3D1741456 Signed-off-by: Michal Privoznik --- src/qemu/qemu_blockjob.c | 59 ++++++++++++++++++++++++++++++++++++---- 1 file changed, 54 insertions(+), 5 deletions(-) diff --git a/src/qemu/qemu_blockjob.c b/src/qemu/qemu_blockjob.c index 1b22689e0c..a991309ee7 100644 --- a/src/qemu/qemu_blockjob.c +++ b/src/qemu/qemu_blockjob.c @@ -659,7 +659,23 @@ qemuBlockJobEventProcessLegacyCompleted(virQEMUDriverP= tr driver, disk->src =3D disk->mirror; } else { if (disk->mirror) { + virStorageSourcePtr n; + virDomainLockImageDetach(driver->lockManager, vm, disk->mirror= ); + + /* Ideally, we would restore seclabels on the backing chain he= re + * but we don't know if somebody else is not using parts of it. + * Remove security driver metadata so that they are not leaked= . */ + for (n =3D disk->mirror; virStorageSourceIsBacking(n); n =3D n= ->backingStore) { + if (qemuSecurityMoveImageMetadata(driver, vm, n, NULL) < 0= ) { + VIR_WARN("Unable to remove disk metadata on " + "vm %s from %s (disk target %s)", + vm->def->name, + NULLSTR(disk->src->path), + disk->dst); + } + } + virObjectUnref(disk->mirror); } } @@ -728,7 +744,23 @@ qemuBlockJobEventProcessLegacy(virQEMUDriverPtr driver, case VIR_DOMAIN_BLOCK_JOB_FAILED: case VIR_DOMAIN_BLOCK_JOB_CANCELED: if (disk->mirror) { + virStorageSourcePtr n; + virDomainLockImageDetach(driver->lockManager, vm, disk->mirror= ); + + /* Ideally, we would restore seclabels on the backing chain he= re + * but we don't know if somebody else is not using parts of it. + * Remove security driver metadata so that they are not leaked= . */ + for (n =3D disk->mirror; virStorageSourceIsBacking(n); n =3D n= ->backingStore) { + if (qemuSecurityMoveImageMetadata(driver, vm, n, NULL) < 0= ) { + VIR_WARN("Unable to remove disk metadata on " + "vm %s from %s (disk target %s)", + vm->def->name, + NULLSTR(disk->src->path), + disk->dst); + } + } + virObjectUnref(disk->mirror); disk->mirror =3D NULL; } @@ -1128,16 +1160,33 @@ qemuBlockJobProcessEventConcludedCopyAbort(virQEMUD= riverPtr driver, =20 =20 static void -qemuBlockJobProcessEventFailedActiveCommit(virDomainObjPtr vm, +qemuBlockJobProcessEventFailedActiveCommit(virQEMUDriverPtr driver, + virDomainObjPtr vm, qemuBlockJobDataPtr job) { + virDomainDiskDefPtr disk =3D job->disk; + virStorageSourcePtr n; + VIR_DEBUG("active commit job '%s' on VM '%s' failed", job->name, vm->d= ef->name); =20 - if (!job->disk) + if (!disk) return; =20 - virObjectUnref(job->disk->mirror); - job->disk->mirror =3D NULL; + /* Ideally, we would make the backing chain read only again (yes, SELi= nux + * can do that using different labels). But that is not implemented ye= t and + * not leaking security driver metadata is more important. */ + for (n =3D disk->mirror; virStorageSourceIsBacking(n); n =3D n->backin= gStore) { + if (qemuSecurityMoveImageMetadata(driver, vm, n, NULL) < 0) { + VIR_WARN("Unable to remove disk metadata on " + "vm %s from %s (disk target %s)", + vm->def->name, + NULLSTR(disk->src->path), + disk->dst); + } + } + + virObjectUnref(disk->mirror); + disk->mirror =3D NULL; } =20 =20 @@ -1231,7 +1280,7 @@ qemuBlockJobEventProcessConcludedTransition(qemuBlock= JobDataPtr job, break; =20 case QEMU_BLOCKJOB_TYPE_ACTIVE_COMMIT: - qemuBlockJobProcessEventFailedActiveCommit(vm, job); + qemuBlockJobProcessEventFailedActiveCommit(driver, vm, job); break; =20 case QEMU_BLOCKJOB_TYPE_CREATE: --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list