From nobody Sun Feb 8 18:56:03 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.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.129.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=1687879598; cv=none; d=zohomail.com; s=zohoarc; b=hkKGic8iTixvGyiBFe0astx51QoEXCPUaowwXqceR0vANVn1yB87TmhDk+JDRowd0a2E5YVRuS9U40occDGCimXGr+wtqTEHM7eGd2moYdbklGO7HoYAVGDe5AEbktcWKFd7M9yIEkwpWAKw2bfJXYYkZMO2cEy7Z+ApvSz3JfI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1687879598; 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=KEH6nhUmhscP/MylJEv+o4MZaO8JpyVv5X7Y8bE6Zdw=; b=g+62yA28B6acDnv9KuYJJkbemQbxtjBNNTIifhoFGuActQ2ubdNBkmTgU8jP81Fy3HJKHXaCcRb4xB75bn3QtC4FTFBoGLvo8KfCsx2vpIP63dORNu4xawScH5i/UKR0cEsvQtkl50tGBsudMK5iH4uSXfJ5f2YmBBMnXSdRlAw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.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.129.124]) by mx.zohomail.com with SMTPS id 1687879597983864.4235354090177; Tue, 27 Jun 2023 08:26:37 -0700 (PDT) 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-595-WLiHqocuNWWtQsCZJhY_OA-1; Tue, 27 Jun 2023 11:22:43 -0400 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id C30CC8870D5; Tue, 27 Jun 2023 15:07:34 +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 AE631425368; Tue, 27 Jun 2023 15:07:34 +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 765641946A78; Tue, 27 Jun 2023 15:07:34 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 163C21946587 for ; Tue, 27 Jun 2023 15:07:33 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 0520F48FB01; Tue, 27 Jun 2023 15:07:33 +0000 (UTC) Received: from antique-work.redhat.com (unknown [10.45.225.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9D2D6400E88 for ; Tue, 27 Jun 2023 15:07:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1687879592; 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=KEH6nhUmhscP/MylJEv+o4MZaO8JpyVv5X7Y8bE6Zdw=; b=MQQJB/iYb/jd6ue0x9VGYW6vz/onEpzdplhkku14Gtw7F9xqbj5NpGW3igHJA1MIwM+Qbp tArAp2pwEfxE+OaQO42GdymMAOREVzav1TWobA3PVN3JTqjAfjhaEgP/033eiZlsgrd87j Ar0tNFwaE02X47H3HyQpPcxX3R/VBvs= X-MC-Unique: WLiHqocuNWWtQsCZJhY_OA-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Pavel Hrdina To: libvir-list@redhat.com Subject: [libvirt PATCH v2 07/24] qemu_snapshot: use virDomainDiskByName while updating domain def Date: Tue, 27 Jun 2023 17:07:10 +0200 Message-ID: <63f65501fd1fb6c74f91693645bc4564cbe1b123.1687877087.git.phrdina@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 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.10 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: 1687879599161100001 Content-Type: text/plain; charset="utf-8"; x-default="true" When creating external snapshot this function is called only when the VM is not running so there is only one definition to care about. However, it will be used by external snapshot revert code for active and inactive definition and they may be different if a disk was (un)plugged only for the active or inactive definition. The current code would crash so use virDomainDiskByName() to get the correct disk from the domain definition based on the disk name and make sure it exists. Signed-off-by: Pavel Hrdina Reviewed-by: Peter Krempa --- src/qemu/qemu_snapshot.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/qemu/qemu_snapshot.c b/src/qemu/qemu_snapshot.c index 72a0f71d4f..8e1eb21b5d 100644 --- a/src/qemu/qemu_snapshot.c +++ b/src/qemu/qemu_snapshot.c @@ -152,11 +152,14 @@ qemuSnapshotDomainDefUpdateDisk(virDomainDef *domdef, for (i =3D 0; i < snapdef->ndisks; i++) { g_autoptr(virStorageSource) newsrc =3D NULL; virDomainSnapshotDiskDef *snapdisk =3D &(snapdef->disks[i]); - virDomainDiskDef *defdisk =3D domdef->disks[i]; + virDomainDiskDef *defdisk =3D virDomainDiskByName(domdef, snapdisk= ->name, false); =20 if (snapdisk->snapshot !=3D VIR_DOMAIN_SNAPSHOT_LOCATION_EXTERNAL) continue; =20 + if (!defdisk) + continue; + if (!(newsrc =3D virStorageSourceCopy(snapdisk->src, false))) return -1; =20 --=20 2.41.0