From nobody Sun Feb 8 16:06:24 2026 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=1676996597; cv=none; d=zohomail.com; s=zohoarc; b=QA9AOMTVgEf3ld4BM1D7ENcvQ/9B2LkvP2yc4P+FDLfNctUOX/XLufaa9BDwX4OIL6Rw4l8cQ6wzYRZXb940m1+3imu1C6iAwYfKcYMoGPRUU8nLR9TILFvPEhmaSHw6A1Eze7aZtJKV5YooTQnPp07EG90tsh0j/v7mUrZua88= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1676996597; 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=L2MTfsz5UFZh6VJ2H7+ffypeciouHiJ8Ga5H8Jtra00=; b=R5oxutA0xw4p3QvOaQrVZvxU2CzXqlLz1V+s4YZrkU07lq06PRx/XrLc60T7woxdK5v+1QqbW55bSw5C2XoDtxfgRcdct52r5uGEGiTncIq8hXLTem2dD5PnsmwPQhKERjGdX4D4sHfdRjIcUe+PpL7FwcRwq4gaVanywE2Mwms= 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 1676996597759902.7667228725094; Tue, 21 Feb 2023 08:23:17 -0800 (PST) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-516-pLMZU2FMNomelq1D_G54YQ-1; Tue, 21 Feb 2023 11:23:12 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 3B6E7885635; Tue, 21 Feb 2023 16:23:07 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 287BF2166B26; Tue, 21 Feb 2023 16:23:07 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id ED07C1946588; Tue, 21 Feb 2023 16:23:06 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id D489C1946587 for ; Tue, 21 Feb 2023 16:23:03 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id BB18A440D9; Tue, 21 Feb 2023 16:23:03 +0000 (UTC) Received: from antique-work.redhat.com (unknown [10.45.224.40]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5FEAC440DC for ; Tue, 21 Feb 2023 16:23:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1676996596; 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=L2MTfsz5UFZh6VJ2H7+ffypeciouHiJ8Ga5H8Jtra00=; b=SynXI3htD9wmhhLie+4wi/pmjM7R6eb9amZu2rcZQyS4a0+56qE11GyiZxfmpS7VVZ9aYU 83APD/RyC+6RRmBEzKU+2X/TA1hvyGC+TjzxXC6JnLvE8vCUsa/i5vAaD//bRlJ42ToAm3 ocbo5yAmdOTKadiyZmFlXuB2IfCed8M= X-MC-Unique: pLMZU2FMNomelq1D_G54YQ-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Pavel Hrdina To: libvir-list@redhat.com Subject: [libvirt PATCH 2/3] qemu_snapshot: refactor qemuSnapshotDeleteExternalPrepare Date: Tue, 21 Feb 2023 17:23:00 +0100 Message-Id: <334375d0ed2e573463525207efaf07b0fa8f5689.1676996547.git.phrdina@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 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: 1676996599336100002 Content-Type: text/plain; charset="utf-8"; x-default="true" When user creates external snapshot with making only memory snapshot without any disks deleting that snapshot failed without reporting any meaningful error. The issue is that the qemuSnapshotDeleteExternalPrepare function returns NULL because the returned list is empty. This will not change so to make it clear if the function fails or not return int instead and have another parameter where we can pass the list. With the fixed memory snapshot deletion it will now correctly delete memory only snapshot as well. Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=3D2170826 Signed-off-by: Pavel Hrdina Reviewed-by: Peter Krempa --- src/qemu/qemu_snapshot.c | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/src/qemu/qemu_snapshot.c b/src/qemu/qemu_snapshot.c index 5cdcbc6290..cfa531edef 100644 --- a/src/qemu/qemu_snapshot.c +++ b/src/qemu/qemu_snapshot.c @@ -2301,9 +2301,10 @@ qemuSnapshotFindParentSnapForDisk(virDomainMomentObj= *snap, } =20 =20 -static GSList* +static int qemuSnapshotDeleteExternalPrepare(virDomainObj *vm, - virDomainMomentObj *snap) + virDomainMomentObj *snap, + GSList **externalData) { ssize_t i; virDomainSnapshotDef *snapdef =3D virDomainSnapshotObjGetDef(snap); @@ -2320,7 +2321,7 @@ qemuSnapshotDeleteExternalPrepare(virDomainObj *vm, virReportError(VIR_ERR_OPERATION_INVALID, _("snapshot disk '%s' was target of not complet= ed snapshot delete"), snapDisk->name); - return NULL; + return -1; } =20 data =3D g_new0(qemuSnapshotDeleteExternalData, 1); @@ -2328,18 +2329,18 @@ qemuSnapshotDeleteExternalPrepare(virDomainObj *vm, =20 data->domDisk =3D qemuDomainDiskByName(vm->def, snapDisk->name); if (!data->domDisk) - return NULL; + return -1; =20 data->diskSrc =3D virStorageSourceChainLookupBySource(data->domDis= k->src, data->snapDisk= ->src, &data->prevDis= kSrc); if (!data->diskSrc) - return NULL; + return -1; =20 if (!virStorageSourceIsSameLocation(data->diskSrc, data->snapDisk-= >src)) { virReportError(VIR_ERR_OPERATION_FAILED, "%s", _("VM disk source and snapshot disk source are = not the same")); - return NULL; + return -1; } =20 data->parentDomDisk =3D virDomainDiskByTarget(snapdef->parent.dom, @@ -2348,7 +2349,7 @@ qemuSnapshotDeleteExternalPrepare(virDomainObj *vm, virReportError(VIR_ERR_OPERATION_FAILED, _("failed to find disk '%s' in snapshot VM XML"= ), snapDisk->name); - return NULL; + return -1; } =20 if (virDomainObjIsActive(vm)) { @@ -2356,13 +2357,13 @@ qemuSnapshotDeleteExternalPrepare(virDomainObj *vm, if (!virStorageSourceIsBacking(data->parentDiskSrc)) { virReportError(VIR_ERR_OPERATION_FAILED, "%s", _("failed to find parent disk source in bac= king chain")); - return NULL; + return -1; } =20 if (!virStorageSourceIsSameLocation(data->parentDiskSrc, data-= >parentDomDisk->src)) { virReportError(VIR_ERR_OPERATION_FAILED, "%s", _("snapshot VM disk source and parent disk = source are not the same")); - return NULL; + return -1; } } =20 @@ -2371,15 +2372,16 @@ qemuSnapshotDeleteExternalPrepare(virDomainObj *vm, if (data->parentSnap && !virDomainSnapshotIsExternal(data->parentS= nap)) { virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s", _("deleting external snapshot that has internal= snapshot as parent not supported")); - return NULL; + return -1; } =20 ret =3D g_slist_prepend(ret, g_steal_pointer(&data)); } =20 ret =3D g_slist_reverse(ret); + *externalData =3D g_steal_pointer(&ret); =20 - return g_steal_pointer(&ret); + return 0; } =20 =20 @@ -3159,7 +3161,7 @@ qemuSnapshotDelete(virDomainObj *vm, g_autoslist(qemuSnapshotDeleteExternalData) tmpData =3D NULL; =20 /* this also serves as validation whether the snapshot can be = deleted */ - if (!(tmpData =3D qemuSnapshotDeleteExternalPrepare(vm, snap))) + if (qemuSnapshotDeleteExternalPrepare(vm, snap, &tmpData) < 0) goto endjob; =20 if (!virDomainObjIsActive(vm)) { @@ -3174,7 +3176,7 @@ qemuSnapshotDelete(virDomainObj *vm, =20 /* Call the prepare again as some data require that the VM= is * running to get everything we need. */ - if (!(externalData =3D qemuSnapshotDeleteExternalPrepare(v= m, snap))) + if (qemuSnapshotDeleteExternalPrepare(vm, snap, &externalD= ata) < 0) goto endjob; } else { qemuDomainJobPrivate *jobPriv =3D vm->job->privateData; --=20 2.39.1