From nobody Tue May 7 10:53:57 2024 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=1629897844; cv=none; d=zohomail.com; s=zohoarc; b=Q85OOVEPZvuy/9YcJrUggL5dGeg1rQswSe8r3r+niLWbZC9pn1ZqQLkNVmsWYoakqbM1Ph2uD6tPizg2JMQymJYbCOD3ob1VrFA34Yj7L4MbcwIrW8T3JTOWW2MzQ8uL+reFtIBpfHwN9dDD5KJReDxyxcVQ1p1v/nZMhJYnJa8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1629897844; h=Content-Type:Content-Transfer-Encoding:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=ggiMK4rwLpxrlCV8inBcehBEIlhtEIPJ9cuyHoyq1mc=; b=QDkSif4EW/p+ZigWBI2KmXLCsklfLwe4jQQ9nNKvbgHu6V8hSiA7ZhNC53D1YZTRsIy+ZijW3jYQvGhjT1qikHYcaMXid+bfF5l/cHPXu3OOUh8UxWG47NneqGhQHYT8n+sSt/uJh8Ybqwz84d3xVnzctjYdkbCLvEGV1MXabBU= 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 1629897844407426.3782493343607; Wed, 25 Aug 2021 06:24:04 -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-384-AoYAKE4NPcGgbCPzoLT0-w-1; Wed, 25 Aug 2021 09:24:01 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 448BC8B5BDC; Wed, 25 Aug 2021 13:23:12 +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 D46945DF5E; Wed, 25 Aug 2021 13:23:10 +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 524FB4BB7C; Wed, 25 Aug 2021 13:23:07 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 17PDN6Df017216 for ; Wed, 25 Aug 2021 09:23:06 -0400 Received: by smtp.corp.redhat.com (Postfix) id 488E2779D0; Wed, 25 Aug 2021 13:23:06 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.33]) by smtp.corp.redhat.com (Postfix) with ESMTP id A213E6A057 for ; Wed, 25 Aug 2021 13:22:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1629897843; 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:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=ggiMK4rwLpxrlCV8inBcehBEIlhtEIPJ9cuyHoyq1mc=; b=VFk2O7w/n73HqR565D38wZg9lJuM8lPrw5xi2qYF/OMWKw36717gCGusmKBTYq9hRIsUFm pSXg9e1NqRXajP/5PKSjxdXrKntAkRtmV1zGOgXDifiWqw3+vkJGa3ER9A5c+gefrysCZQ zBhTAnscTTj1/m4UkfN5y/PQBqbWi8g= X-MC-Unique: AoYAKE4NPcGgbCPzoLT0-w-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH] qemu: snapshot: Translate 'volume' disks before attempting offline snapshot manipulation Date: Wed, 25 Aug 2021 15:22:58 +0200 Message-Id: <5b0405d89bef373b80115072210796530d99959c.1629897778.git.pkrempa@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 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.14 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) X-ZM-MESSAGEID: 1629897845178100001 Content-Type: text/plain; charset="utf-8" When the VM is inactive the 'virStorageSource' struct doesn't have the necessary data pointing to the actual storage. This is a problem for inactive snapshot operations on VMs which use disk type=3D'volume'. Add the translation steps for reversion and deletion of snapshots. Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=3D1977155 Resolves: https://gitlab.com/libvirt/libvirt/-/issues/202 Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_domain.c | 6 ++++++ src/qemu/qemu_snapshot.c | 7 +++++++ 2 files changed, 13 insertions(+) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 50a921c80d..962343cb2d 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -7088,6 +7088,7 @@ qemuDomainSnapshotDiscard(virQEMUDriver *driver, if (!metadata_only) { if (!virDomainObjIsActive(vm)) { + size_t i; /* Ignore any skipped disks */ /* Prefer action on the disks in use at the time the snapshot = was @@ -7098,6 +7099,11 @@ qemuDomainSnapshotDiscard(virQEMUDriver *driver, if (!def) def =3D vm->def; + for (i =3D 0; i < def->ndisks; i++) { + if (virDomainDiskTranslateSourcePool(def->disks[i]) < 0) + return -1; + } + if (qemuDomainSnapshotForEachQcow2(driver, def, snap, "-d", tr= ue) < 0) return -1; } else { diff --git a/src/qemu/qemu_snapshot.c b/src/qemu/qemu_snapshot.c index 4e74ddd7f8..fa1f9ce973 100644 --- a/src/qemu/qemu_snapshot.c +++ b/src/qemu/qemu_snapshot.c @@ -1813,6 +1813,8 @@ qemuSnapshotRevertInactive(virQEMUDriver *driver, virDomainObj *vm, virDomainMomentObj *snap) { + size_t i; + /* Prefer action on the disks in use at the time the snapshot was * created; but fall back to current definition if dealing with a * snapshot created prior to libvirt 0.9.5. */ @@ -1821,6 +1823,11 @@ qemuSnapshotRevertInactive(virQEMUDriver *driver, if (!def) def =3D vm->def; + for (i =3D 0; i < def->ndisks; i++) { + if (virDomainDiskTranslateSourcePool(def->disks[i]) < 0) + return -1; + } + /* Try all disks, but report failure if we skipped any. */ if (qemuDomainSnapshotForEachQcow2(driver, def, snap, "-a", true) !=3D= 0) return -1; --=20 2.31.1