From nobody Sun Feb 8 20:17:32 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.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 63.128.21.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=1600947927; cv=none; d=zohomail.com; s=zohoarc; b=O3XVczlXUsYga6km6aOEZBywUuAU4InYJAOHcXOGQh1yPLTCO/AEN87YdOJJdkFzMo3VV/2FggkvBBpmD5LDC07uZDBL5CkxsAPiV5ftC9MfJ1LwPH5xRYnMkB3JrR8EWQIsKJbG98G0LrX2eO5QdXz6QdLQq83rVQLU6fOyfaY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1600947927; 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; bh=bbNwb2Ch7O/KveuuBvOYJL6Dys3a+sEb9fvcS6XNgI4=; b=Mm611wqrEoAHtWLA90G5AX0OThfhG1zBbndCTVflkidEe2jVFhyweR0z92YxvPDKXRVut6h0V4fGaAZvtvijdSqGQwkDW+Qc3AmmkMkubdj5zrVcT0D9mlfGB1r9VrWQ79+iM4pIxMjmc/96OEIr9Nv87zsjnZikyO1fP86zc7c= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 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-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by mx.zohomail.com with SMTPS id 1600947927532515.9989333837204; Thu, 24 Sep 2020 04:45:27 -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-430-rhmGeAlwO-alflgXc3UqwQ-1; Thu, 24 Sep 2020 07:45:24 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 4A3461084D79; Thu, 24 Sep 2020 11:45:19 +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 281315C1C7; Thu, 24 Sep 2020 11:45:19 +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 E78831826D2D; Thu, 24 Sep 2020 11:45:18 +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 08OBi6KF009046 for ; Thu, 24 Sep 2020 07:44:06 -0400 Received: by smtp.corp.redhat.com (Postfix) id C311461177; Thu, 24 Sep 2020 11:44:06 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id D0D916115F; Thu, 24 Sep 2020 11:44:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1600947926; 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: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=bbNwb2Ch7O/KveuuBvOYJL6Dys3a+sEb9fvcS6XNgI4=; b=NtnNmzYrRF4mz+PDfLT5QA9J65QbkhpIRtdlqSLEEq4WsfLrWX3xrq+S0zJ07aUYXrpwzG dskkE+yeAZhOQqSkZaNhm6TWVd6dx0VRsdtymWFMU/cxqBRuwEULZ3lxuwldyNsBF9kuTN /82l1dc9ULKifjvgdl0kpjDbNK0mNwI= X-MC-Unique: rhmGeAlwO-alflgXc3UqwQ-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH v4 02/11] qemu: prepare cleanup for disk overlays Date: Thu, 24 Sep 2020 13:43:49 +0200 Message-Id: <1656df715c59b37bc5158b7f280f440da89802a3.1600947699.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com Cc: Masayoshi Mizuma 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.16 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) Content-Type: text/plain; charset="utf-8" Later patches will implement support for disks in libvirt by installing an overlay on top of the configured image. This will require cleanup after the VM will be stopped so that the state is correctly discarded. Since the overlay will be installed only during the startup phase of the VM we need to ensure that qemuProcessStop doesn't delete the original file on some previous failure. This is solved by adding 'inhibitDiskTransientDelete' VM private data member which is set prior to any startup step and will be cleared once transient disk overlays are established. Based on that we can then delete the overlays for any disk. Signed-off-by: Peter Krempa Tested-by: Masayoshi Mizuma --- src/qemu/qemu_domain.c | 2 ++ src/qemu/qemu_domain.h | 4 ++++ src/qemu/qemu_process.c | 22 ++++++++++++++++++++++ 3 files changed, 28 insertions(+) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 279de2997d..dc5949edfa 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -1792,6 +1792,8 @@ qemuDomainObjPrivateDataClear(qemuDomainObjPrivatePtr= priv) priv->dbusVMStateIds =3D NULL; priv->dbusVMState =3D false; + + priv->inhibitDiskTransientDelete =3D false; } diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h index c7c3c5c073..ec776ced72 100644 --- a/src/qemu/qemu_domain.h +++ b/src/qemu/qemu_domain.h @@ -263,6 +263,10 @@ struct _qemuDomainObjPrivate { char **dbusVMStateIds; /* true if -object dbus-vmstate was added */ bool dbusVMState; + + /* prevent deletion of disk overlay files between startup = and + * succesful setup of the overlays */ + bool inhibitDiskTransientDelete; }; #define QEMU_DOMAIN_PRIVATE(vm) \ diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index f21b8f1585..ffb3afa9c5 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -5616,6 +5616,9 @@ qemuProcessInit(virQEMUDriverPtr driver, if (virDomainObjSetDefTransient(driver->xmlopt, vm, priv->qemuCaps) < = 0) goto cleanup; + /* don't clean up files for disks until we set them up */ + priv->inhibitDiskTransientDelete =3D true; + if (flags & VIR_QEMU_PROCESS_START_PRETEND) { if (qemuDomainSetPrivatePaths(driver, vm) < 0) { virDomainObjRemoveTransientDef(vm); @@ -7710,6 +7713,18 @@ void qemuProcessStop(virQEMUDriverPtr driver, } qemuBlockRemoveImageMetadata(driver, vm, disk->dst, disk->src); + + /* for now transient disks are forbidden with migration so they + * can be handled here */ + if (disk->transient && + !priv->inhibitDiskTransientDelete) { + VIR_DEBUG("Removing transient overlay '%s' of disk '%s'", + disk->src->path, disk->dst); + if (qemuDomainStorageFileInit(driver, vm, disk->src, NULL)= >=3D 0) { + virStorageFileUnlink(disk->src); + virStorageFileDeinit(disk->src); + } + } } } @@ -8125,6 +8140,10 @@ qemuProcessReconnect(void *opaque) cfg =3D virQEMUDriverGetConfig(driver); priv =3D obj->privateData; + /* expect that libvirt might have crashed during VM start, so prevent + * cleanup of transient disks */ + priv->inhibitDiskTransientDelete =3D true; + if (qemuDomainObjBeginJob(driver, obj, QEMU_JOB_MODIFY) < 0) goto error; jobStarted =3D true; @@ -8228,6 +8247,9 @@ qemuProcessReconnect(void *opaque) goto error; } + /* vm startup complete, we can remove transient disks if required */ + priv->inhibitDiskTransientDelete =3D false; + /* In case the domain shutdown while we were not running, * we need to finish the shutdown process. And we need to do it after * we have virQEMUCaps filled in. --=20 2.26.2