From nobody Mon Feb 9 08:31:26 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.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 216.205.24.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=1621601322; cv=none; d=zohomail.com; s=zohoarc; b=L1fUo/YFumDWpa/jQWEEJoXvy0KyXxZmgYxTP6unhWYk88wTEu8/LxFl3MaKAQgxbhiPwYRvlo9vok5yRW/QmqSGdlIemigXSja3VhsdU6B9lrU7tb0+k2KxZjCeYfEeghOxA3O/T/IPh9mIpDYGsH5Ox7dZDthU/Ep3z5zrxtA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1621601322; 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; bh=MrugLro1NazELu8mCc7L9mKzVNsrq2GNAGg6ciTXk2U=; b=BrcrzptMz3t1Yqx2NIAoLy46e0iweWX4BWqnQ0eyPTUrqiB1v0AdB6EFJjdP/ZQFmsCNZfpzZgdYbhUcEzZeB5iX7uLC8Rj9NAiA5G9jofHeV7xjgfRlmRIGNR2gsAQfzYorJ0I4Ul0joBXWq4zoau3QS2RJmLZl4ga4MskRers= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.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 [216.205.24.124]) by mx.zohomail.com with SMTPS id 1621601322044968.2339878057219; Fri, 21 May 2021 05:48:42 -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-559-lGxN2fAbPzyVcT3Pg9HuAg-1; Fri, 21 May 2021 08:48:38 -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 78444107ACFE; Fri, 21 May 2021 12:48:31 +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 59AB262467; Fri, 21 May 2021 12:48: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 292F91801028; Fri, 21 May 2021 12:48:31 +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 14LCmPRL031504 for ; Fri, 21 May 2021 08:48:25 -0400 Received: by smtp.corp.redhat.com (Postfix) id BBF6F421F; Fri, 21 May 2021 12:48:25 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.14]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2C32E5945B for ; Fri, 21 May 2021 12:48:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1621601321; 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: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=MrugLro1NazELu8mCc7L9mKzVNsrq2GNAGg6ciTXk2U=; b=Uib1DmC5jvP4JFakHu30kiesX77iX6JQ8gZixpXBcHwv2uRXHa8XmOWuXgj6YbF6zRdv2K V4EqayUyG/h5CWOR4kk53Rz+JssOw2tqs1YxnFBAUPGBwE6gcHJD0JpbnMoeC1Db/zByOw kOkjTWQRaUXRgMK4ob6UL8h1M3nHfXU= X-MC-Unique: lGxN2fAbPzyVcT3Pg9HuAg-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 29/35] qemu: Track creation of disk overlay individually Date: Fri, 21 May 2021 14:47:29 +0200 Message-Id: <35b543f458310716399efe98fdaca55b91660ff0.1621601161.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 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 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" In preparation for hotplug of disks we'll need to track whether the overlay file was created individually per-disk. Add 'transientOverlayCreated' to 'struct _qemuDomainDiskPrivate' and remove 'inhibitDiskTransientDelete' from 'qemuDomainObjPrivate' and adjust the code for the change. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_domain.c | 2 -- src/qemu/qemu_domain.h | 7 +++---- src/qemu/qemu_process.c | 33 +++++++++++++++++++-------------- 3 files changed, 22 insertions(+), 20 deletions(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 10641846b3..c5f994c4a5 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -1880,8 +1880,6 @@ qemuDomainObjPrivateDataClear(qemuDomainObjPrivate *p= riv) g_slist_free_full(g_steal_pointer(&priv->dbusVMStateIds), g_free); priv->dbusVMState =3D false; - - priv->inhibitDiskTransientDelete =3D false; } diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h index 4fc1969d9e..9cebf9e426 100644 --- a/src/qemu/qemu_domain.h +++ b/src/qemu/qemu_domain.h @@ -258,10 +258,6 @@ struct _qemuDomainObjPrivate { GSList *dbusVMStateIds; /* true if -object dbus-vmstate was added */ bool dbusVMState; - - /* prevent deletion of disk overlay files between startup = and - * successful setup of the overlays */ - bool inhibitDiskTransientDelete; }; #define QEMU_DOMAIN_PRIVATE(vm) \ @@ -292,6 +288,9 @@ struct _qemuDomainDiskPrivate { unsigned int effectiveBootindex; /* boot index of the disk based on one of the two ways we use to select a= boot device */ + + bool transientOverlayCreated; /* the overlay image of a transient disk= was + created and the definition was update= d */ }; #define QEMU_DOMAIN_STORAGE_SOURCE_PRIVATE(src) \ diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 7fe051505b..9302180403 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -5709,9 +5709,6 @@ qemuProcessInit(virQEMUDriver *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); @@ -7007,7 +7004,6 @@ static int qemuProcessSetupDisksTransientSnapshot(virDomainObj *vm, qemuDomainAsyncJob asyncJob) { - qemuDomainObjPrivate *priv =3D vm->privateData; g_autoptr(qemuSnapshotDiskContext) snapctxt =3D NULL; g_autoptr(GHashTable) blockNamedNodeData =3D NULL; size_t i; @@ -7039,8 +7035,14 @@ qemuProcessSetupDisksTransientSnapshot(virDomainObj = *vm, if (qemuSnapshotDiskCreate(snapctxt) < 0) return -1; - /* the overlays are established, so they can be deleted on shutdown */ - priv->inhibitDiskTransientDelete =3D false; + for (i =3D 0; i < vm->def->ndisks; i++) { + virDomainDiskDef *domdisk =3D vm->def->disks[i]; + + if (!domdisk->transient) + continue; + + QEMU_DOMAIN_DISK_PRIVATE(domdisk)->transientOverlayCreated =3D tru= e; + } return 0; } @@ -8077,7 +8079,7 @@ void qemuProcessStop(virQEMUDriver *driver, /* for now transient disks are forbidden with migration so they * can be handled here */ if (disk->transient && - !priv->inhibitDiskTransientDelete) { + QEMU_DOMAIN_DISK_PRIVATE(disk)->transientOverlayCreated) { VIR_DEBUG("Removing transient overlay '%s' of disk '%s'", disk->src->path, disk->dst); if (qemuDomainStorageFileInit(driver, vm, disk->src, NULL)= >=3D 0) { @@ -8505,10 +8507,6 @@ qemuProcessReconnect(void *opaque) if (oldjob.asyncJob =3D=3D QEMU_ASYNC_JOB_BACKUP && priv->backup) priv->backup->apiFlags =3D oldjob.apiFlags; - /* 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; @@ -8611,9 +8609,6 @@ 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. @@ -8662,6 +8657,16 @@ qemuProcessReconnect(void *opaque) if (qemuProcessRefreshDisks(driver, obj, QEMU_ASYNC_JOB_NONE) < 0) goto error; + /* At this point we've already checked that the startup of the VM was + * completed successfully before, thus that also implies that all tran= sient + * disk overlays were created. */ + for (i =3D 0; i < obj->def->ndisks; i++) { + virDomainDiskDef *disk =3D obj->def->disks[i]; + + if (disk->transient) + QEMU_DOMAIN_DISK_PRIVATE(disk)->transientOverlayCreated =3D tr= ue; + } + if (!virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_BLOCKDEV) && qemuBlockNodeNamesDetect(driver, obj, QEMU_ASYNC_JOB_NONE) < 0) goto error; --=20 2.31.1