From nobody Mon Feb 9 04:20:46 2026 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=1567087985; cv=none; d=zoho.com; s=zohoarc; b=A5lbfe0Nt/LHEnzEuK6szY3WE1btAT6/CmhRQjVgxlEBXuu1VacR9H3eUJSfIH69/hFSlvvJgPHCoLdSNWS1IHLGQ2iMZgFNurgbBJRGL0up3DfM93BNags3jA1Qhr+e6SGsl+VQp5Q8GcB006w2TSa27Oe5dGpfAmJHfd54KK0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1567087985; h=Content-Type:Content-Transfer-Encoding:Cc: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=tCCLQOmApMLBOAzVlfdRkztNrnAGP1HRI8EfcxSCYss=; b=TJR0GF+2oZwSby0+itbGj/eOVRgA7nmiRy8GRb0MDdC0zcOI3eLns0/bC5zt+jDCzwzghzC7UIQv2bbp2W1GJsNeqI7/vOYXnK0K+QRklzbYpXZhv59HaEiHdm9knD0QaXEMVYD6RGjLA/8b6mhlVX/0vXC1Xtiedh0XjiCA/PQ= 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 1567087985373410.6613049844658; Thu, 29 Aug 2019 07:13:05 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C3C998AC6F6; Thu, 29 Aug 2019 14:13:03 +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 9E55A5D9C9; Thu, 29 Aug 2019 14:13:03 +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 5BF39C592; Thu, 29 Aug 2019 14:13:03 +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 x7TED1wp012593 for ; Thu, 29 Aug 2019 10:13:01 -0400 Received: by smtp.corp.redhat.com (Postfix) id 193E4600F8; Thu, 29 Aug 2019 14:13:01 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6E975600C1; Thu, 29 Aug 2019 14:13:00 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Thu, 29 Aug 2019 16:12:46 +0200 Message-Id: <3eee13061c9fa6dc412927b887ef995b715d4b6c.1567087655.git.pkrempa@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 Cc: Peter Krempa Subject: [libvirt] [PATCH v2 1/9] qemu: snapshot: Fix image lock handling when taking a snapshot 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.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.6.2 (mx1.redhat.com [10.5.110.69]); Thu, 29 Aug 2019 14:13:04 +0000 (UTC) Content-Type: text/plain; charset="utf-8" When we take a snapshot we must properly remove our locking infrastructure locks. This was broken by commit 3817fa10c4ad9 which attempted to properly track the readonly state for the image as the locking code was executed after this change. Since we forced the image which was locked as read-write to read-only prior to unlocking it the write lock was not dropped. Fix it by moving the locking code prior to modifying the readonly flag. https://bugzilla.redhat.com/show_bug.cgi?id=3D1745618 Signed-off-by: Peter Krempa --- src/qemu/qemu_driver.c | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 78f5471b79..a1f4105cc3 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -15432,6 +15432,13 @@ qemuDomainSnapshotUpdateDiskSources(virQEMUDriverP= tr driver, if (qemuSecurityMoveImageMetadata(driver, vm, dd->disk->src, dd->src) = < 0) VIR_WARN("Unable to move disk metadata on vm %s", vm->def->name); + /* unlock the write lock on the original image as qemu will no longer = write to it */ + virDomainLockImageDetach(driver->lockManager, vm, dd->disk->src); + + /* unlock also the new image if the VM is paused to follow the locking= semantics */ + if (virDomainObjGetState(vm, NULL) !=3D VIR_DOMAIN_RUNNING) + virDomainLockImageDetach(driver->lockManager, vm, dd->src); + /* the old disk image is now readonly */ dd->disk->src->readonly =3D true; @@ -15550,23 +15557,8 @@ qemuDomainSnapshotCreateDiskActive(virQEMUDriverPt= r driver, ret =3D 0; cleanup: - if (ret < 0) { + if (ret < 0) virErrorPreserveLast(&orig_err); - } else { - /* on successful snapshot we need to remove locks from the now-old - * disks and if the VM is paused release locks on the images since= qemu - * stopped using them*/ - bool paused =3D virDomainObjGetState(vm, NULL) !=3D VIR_DOMAIN_RUN= NING; - - for (i =3D 0; i < ndiskdata; i++) { - if (paused) - virDomainLockImageDetach(driver->lockManager, vm, - diskdata[i].disk->src); - - virDomainLockImageDetach(driver->lockManager, vm, - diskdata[i].disk->src->backingStore); - } - } if (virDomainSaveStatus(driver->xmlopt, cfg->stateDir, vm, driver->cap= s) < 0 || (vm->newDef && virDomainSaveConfig(cfg->configDir, driver->caps, --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list