From nobody Sun Feb 8 12:31:44 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) client-ip=205.139.110.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 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=1576848370; cv=none; d=zohomail.com; s=zohoarc; b=Ou3287cZo+Yzx/MRFb5GmIoLcIko4BsFIrhT5dAfRWItzWeVFj9hA4wMBe/ZJ0kjYAOmqE4I0MANsiwU96DwpfopnPuFSfFhBNSA9b9UBnjEqM51PmaaqSrWl8xzP7OcJ3UmjygYuOaEmE0aytM9N4mVJtw8toBLHeIWApdgCf4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1576848370; 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=XOOcRucbzjTfa+g6y8ZjOKNXY2wrIxh/uiLTGLG7SwQ=; b=exz1lGafawKqqOJ1ZiDnuPuEB7eZyJ7IvwrIsosKafrYwfYgt59mLbxtgQZtXCndfIMdy6o23RWB/pebTU6o+IUQpw89IQsOYRglzJgX9ZPFTQOYLDkFo7mt9q0qTwwN/Y/LwdMMxGNAB6NOZfeSMJBw4VJQEdHY9VY5fDyXfDc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 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-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by mx.zohomail.com with SMTPS id 1576848370567809.4773035482964; Fri, 20 Dec 2019 05:26:10 -0800 (PST) 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-20-7HaBEHZ8NViqCtn2R07T5g-1; Fri, 20 Dec 2019 08:26:07 -0500 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 443FE800D48; Fri, 20 Dec 2019 13:26:00 +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 0E88F5C57C; Fri, 20 Dec 2019 13:26:00 +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 BB16B252ED; Fri, 20 Dec 2019 13:25:59 +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 xBKDPd9q028857 for ; Fri, 20 Dec 2019 08:25:39 -0500 Received: by smtp.corp.redhat.com (Postfix) id 5EBB21CE; Fri, 20 Dec 2019 13:25:39 +0000 (UTC) Received: from angien.redhat.com (unknown [10.43.2.48]) by smtp.corp.redhat.com (Postfix) with ESMTP id DC35763B93 for ; Fri, 20 Dec 2019 13:25:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1576848369; 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=XOOcRucbzjTfa+g6y8ZjOKNXY2wrIxh/uiLTGLG7SwQ=; b=cOW0TcpUJSxM8FX7naJKa8iXFE2hSJ3aGpG27jBEcQguPDtARpHCkOn7HMsQXZh1RWzXic pnvhuIZV5GBZFGb54roWhvpeiCKzQen1s4n9xNztFqgxtLfc4s0ChAv8lvaRtdwvemBc8F Gqvd0lSI7kxNCTWtVUxj/NJzq5XCi9A= From: Peter Krempa To: libvir-list@redhat.com Date: Fri, 20 Dec 2019 14:25:22 +0100 Message-Id: <183e299733392efbfa37ba5d58f319bd3aa6f549.1576847165.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 Subject: [libvirt] [PATCH 04/11] qemu: backup: Move deletion of backup images to job termination 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 X-MC-Unique: 7HaBEHZ8NViqCtn2R07T5g-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" While qemu is running both locations are identical in semantics, but the move will allow us to fix the scenario when the VM is destroyed or crashes where we'd leak the images. Signed-off-by: Peter Krempa Reviewed-by: Daniel P. Berrang=C3=A9 --- src/qemu/qemu_backup.c | 24 ++++++++++++++++++++++++ src/qemu/qemu_blockjob.c | 15 +-------------- 2 files changed, 25 insertions(+), 14 deletions(-) diff --git a/src/qemu/qemu_backup.c b/src/qemu/qemu_backup.c index de4730441b..4ab9a2b17e 100644 --- a/src/qemu/qemu_backup.c +++ b/src/qemu/qemu_backup.c @@ -614,6 +614,7 @@ qemuBackupJobTerminate(virDomainObjPtr vm, { qemuDomainObjPrivatePtr priv =3D vm->privateData; + size_t i; qemuDomainJobInfoUpdateTime(priv->job.current); @@ -630,6 +631,29 @@ qemuBackupJobTerminate(virDomainObjPtr vm, qemuDomainEventEmitJobCompleted(priv->driver, vm); + if (!(priv->job.apiFlags & VIR_DOMAIN_BACKUP_BEGIN_REUSE_EXTERNAL) && + (priv->backup->type =3D=3D VIR_DOMAIN_BACKUP_TYPE_PULL || + (priv->backup->type =3D=3D VIR_DOMAIN_BACKUP_TYPE_PUSH && + jobstatus !=3D QEMU_DOMAIN_JOB_STATUS_COMPLETED))) { + + g_autoptr(virQEMUDriverConfig) cfg =3D virQEMUDriverGetConfig(priv= ->driver); + + for (i =3D 0; i < priv->backup->ndisks; i++) { + virDomainBackupDiskDefPtr backupdisk =3D priv->backup->disks += i; + uid_t uid; + gid_t gid; + + if (!backupdisk->store || + backupdisk->store->type !=3D VIR_STORAGE_TYPE_FILE) + continue; + + qemuDomainGetImageIds(cfg, vm, backupdisk->store, NULL, &uid, = &gid); + if (virFileRemove(backupdisk->store->path, uid, gid) < 0) + VIR_WARN("failed to remove scratch file '%s'", + backupdisk->store->path); + } + } + virDomainBackupDefFree(priv->backup); priv->backup =3D NULL; qemuDomainObjEndAsyncJob(priv->driver, vm); diff --git a/src/qemu/qemu_blockjob.c b/src/qemu/qemu_blockjob.c index 498e2a716f..131b53d88d 100644 --- a/src/qemu/qemu_blockjob.c +++ b/src/qemu/qemu_blockjob.c @@ -1335,9 +1335,6 @@ qemuBlockJobProcessEventConcludedBackup(virQEMUDriver= Ptr driver, unsigned long long progressCurrent, unsigned long long progressTotal) { - g_autoptr(virQEMUDriverConfig) cfg =3D virQEMUDriverGetConfig(driver); - uid_t uid; - gid_t gid; g_autoptr(qemuBlockStorageSourceAttachData) backend =3D NULL; g_autoptr(virJSONValue) actions =3D NULL; @@ -1369,18 +1366,8 @@ qemuBlockJobProcessEventConcludedBackup(virQEMUDrive= rPtr driver, if (qemuDomainObjExitMonitor(driver, vm) < 0) return; - if (job->data.backup.store) { + if (job->data.backup.store) qemuDomainStorageSourceAccessRevoke(driver, vm, job->data.backup.s= tore); - - if (job->data.backup.deleteStore && - job->data.backup.store->type =3D=3D VIR_STORAGE_TYPE_FILE) { - qemuDomainGetImageIds(cfg, vm, job->data.backup.store, NULL, &= uid, &gid); - - if (virFileRemove(job->data.backup.store->path, uid, gid) < 0) - VIR_WARN("failed to remove scratch file '%s'", - job->data.backup.store->path); - } - } } --=20 2.23.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list