From nobody Fri May 10 03:00:01 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 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=1645548985; cv=none; d=zohomail.com; s=zohoarc; b=Oz7edrnRmXRqw5ATeFw7N3FjiRO7I+dpm/UxU0ygo1hl4J0DYyABugS7yuG5GHLg7a0P7GAPMPMUlBYBjNZM1EcB9bnVVZ1Bs2WHoErEXhmceI1smIrm4ZF7wC7COEHLCoMenhxtiHJsopWLinZ2FJpOgzFD4FrUHUab9ZlfJF8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1645548985; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=nVxulT/YBk4VfL/DJpIRG2XuWGWlaw6A4Jqez8WtYsA=; b=Ld+iMASfN8RF4lmh5D40FP7RbBSKSYx5fbkEdqwO5I4VPPDrMXGt7kPWD4S+/uYv3u/RFOCSIpvojeqzVs/udPH078G2rXNGoicekPN16fyYBRbW6mIwaJDLgLIwQVxRDTQTtUq73UrdXUwK4UbKARQV9+xmIxxFBEqeHKbwKls= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1645548985725564.3172941613807; Tue, 22 Feb 2022 08:56:25 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-546-pN9Dwz5YO1KK6XJT56vvVQ-1; Tue, 22 Feb 2022 11:56:21 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 10E9A6C502; Tue, 22 Feb 2022 16:56:16 +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 5CBF6866D5; Tue, 22 Feb 2022 16:56:15 +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 8ED924A701; Tue, 22 Feb 2022 16:56:14 +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 21MGuDq3016598 for ; Tue, 22 Feb 2022 11:56:13 -0500 Received: by smtp.corp.redhat.com (Postfix) id 05AC47F0CF; Tue, 22 Feb 2022 16:56:13 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.41]) by smtp.corp.redhat.com (Postfix) with ESMTP id EF1C17FFF3; Tue, 22 Feb 2022 16:55:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1645548984; 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:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=nVxulT/YBk4VfL/DJpIRG2XuWGWlaw6A4Jqez8WtYsA=; b=CwNLS5a3eFJ3X6v/gjxrZroDkUNxoM4nquyhHNn4UA8Bhunwe2sonLo3PvUxpjt0Pc688F 15T2NHZS72tvbxpzFv6WTKf65p8ZRLnumCamryTEvVIuZiR6/mNGoXUgnAD5CraqnOKIUy srrIdTfg3QnS6WwyRNMMPoxj/oaaj3c= X-MC-Unique: pN9Dwz5YO1KK6XJT56vvVQ-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH] qemu: blockjob: Avoid spurious log errors when cancelling a shallow copy with reused images Date: Tue, 22 Feb 2022 17:55:38 +0100 Message-Id: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Cc: Peter Krempa 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.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1645548987256100001 Content-Type: text/plain; charset="utf-8" In case when a user starts a block copy operation with VIR_DOMAIN_BLOCK_COPY_SHALLOW and VIR_DOMAIN_BLOCK_COPY_REUSE_EXT and both the reused image and the original disk have a backing image libvirt specifically does not insert the backing image until after the job is asked to be completed via virBlockJobAbort with VIR_DOMAIN_BLOCK_JOB_ABORT_PIVOT. This is so that management applications can copy the backing image on the background. Now when a user aborts the block job instead of cancelling it we'd ignore the fact that we didn't insert the backing image yet and the cancellation would result into a 'blockdev-del' of a invalid node name and thus an 'error' severity entry in the log. To solve this issue we use the same conditions when the backing image addition is avoided to remove the internal state for them prior to the call to unplug the mirror destination. Reported-by: Kashyap Chamarthy Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_blockjob.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/qemu/qemu_blockjob.c b/src/qemu/qemu_blockjob.c index 726df95067..2442865b9b 100644 --- a/src/qemu/qemu_blockjob.c +++ b/src/qemu/qemu_blockjob.c @@ -1406,6 +1406,8 @@ qemuBlockJobProcessEventConcludedCopyAbort(virQEMUDri= ver *driver, qemuBlockJobData *job, qemuDomainAsyncJob asyncJob) { + qemuDomainObjPrivate *priv =3D vm->privateData; + VIR_DEBUG("copy job '%s' on VM '%s' aborted", job->name, vm->def->name= ); /* mirror may be NULL for copy job corresponding to migration */ @@ -1413,6 +1415,21 @@ qemuBlockJobProcessEventConcludedCopyAbort(virQEMUDr= iver *driver, !job->disk->mirror) return; + if (!job->jobflagsmissing) { + bool shallow =3D job->jobflags & VIR_DOMAIN_BLOCK_COPY_SHALLOW; + bool reuse =3D job->jobflags & VIR_DOMAIN_BLOCK_COPY_REUSE_EXT; + + /* In the special case of a shallow copy with reused image we don't + * hotplug the full chain when QEMU_CAPS_BLOCKDEV_SNAPSHOT_ALLOW_W= RITE_ONLY + * is supported. Attempting to delete it would thus result in spur= ious + * errors as we'd attempt to blockdev-del images which were not ad= ded + * yet */ + if (reuse && shallow && + virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_BLOCKDEV_SNAPSHOT_ALL= OW_WRITE_ONLY) && + virStorageSourceHasBacking(job->disk->mirror)) + g_clear_pointer(&job->disk->mirror->backingStore, virObjectUnr= ef); + } + /* activeWrite bitmap is removed automatically here */ qemuBlockJobEventProcessConcludedRemoveChain(driver, vm, asyncJob, job= ->disk->mirror); g_clear_pointer(&job->disk->mirror, virObjectUnref); --=20 2.35.1