From nobody Fri Apr 19 08:26:05 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=1642011089; cv=none; d=zohomail.com; s=zohoarc; b=npE7dfklge9l7K9b8b4BJL2Dq+0jlhHkj19+6RcYgfbW34w69r1H0fIkRlkhvJrffQyPENKwIdAjH6TBQlH6aB8mYqrp6+fdWgBvkFZ8vy01pp4WzstfDQFZSFZLWIWOm//A0jZ9CH5qwuVAeJ//e5FcgDgZePnJBOiAVZVA5N0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1642011089; 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=hy0C4AU9Z5YHyh4Q2K79kx4hGP6p/4R7xc97P1LFPW4=; b=bNF6SrKc9QexmGllzgnxnMAwUw2dFV2VjGIT+EmMiTx3+SH2PxJonrqfgSG8h+d9BdwoGq0FAj7o+Dh5Jh6LWuuZlX+Wfpch/hDYFJXpQ21xDe8u7Xj1nha7xDPNVRwkU56VdQXzSkX+sn0pb5rCdDcagA+ho79GuPYV2AhvVZc= 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 1642011089684783.9640869465754; Wed, 12 Jan 2022 10:11:29 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-592-ST_wLdedNMiM-b11PBrsMg-1; Wed, 12 Jan 2022 13:11:25 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id D91F183DD24; Wed, 12 Jan 2022 18:11:20 +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 BD3D21091ED6; Wed, 12 Jan 2022 18:11:20 +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 89EEB4A7CB; Wed, 12 Jan 2022 18:11:20 +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 20CIASN4002977 for ; Wed, 12 Jan 2022 13:10:28 -0500 Received: by smtp.corp.redhat.com (Postfix) id 8B7828AD01; Wed, 12 Jan 2022 18:10:28 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.34]) by smtp.corp.redhat.com (Postfix) with ESMTP id E0DEE8ACEA for ; Wed, 12 Jan 2022 18:10:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1642011088; 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=hy0C4AU9Z5YHyh4Q2K79kx4hGP6p/4R7xc97P1LFPW4=; b=SykDw1NDRq1qSCEMFVLTsABTKL2dkC+dbEbQNJskvHtoPZD0kSt82ycit71UDOUYQBg2Zb Rwu7evvIULkg/oJzyxnrIRtDFDxIj0R9+p5CUS/Al9z7uu7vxcvJTnA0jURpeWvMmori3B hrF8Ejwd2Ypp9LvunwlGmG0fL+6NGe4= X-MC-Unique: ST_wLdedNMiM-b11PBrsMg-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 01/17] qemuSnapshotRedefine: Rename 'def' to 'snapdef' Date: Wed, 12 Jan 2022 19:10:01 +0100 Message-Id: In-Reply-To: References: 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.84 on 10.5.11.22 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: 1642011091193100003 Content-Type: text/plain; charset="utf-8" 'def' is commonly used to refer to domain definition. Most of the snapshot code uses 'snapdef' for the snapshot definition. Signed-off-by: Peter Krempa --- src/qemu/qemu_snapshot.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/qemu/qemu_snapshot.c b/src/qemu/qemu_snapshot.c index 5d383279b0..624ace0314 100644 --- a/src/qemu/qemu_snapshot.c +++ b/src/qemu/qemu_snapshot.c @@ -1709,7 +1709,7 @@ qemuSnapshotCreateWriteMetadata(virDomainObj *vm, static virDomainSnapshotPtr qemuSnapshotRedefine(virDomainObj *vm, virDomainPtr domain, - virDomainSnapshotDef *def, + virDomainSnapshotDef *snapdef, virQEMUDriver *driver, virQEMUDriverConfig *cfg, unsigned int flags) @@ -1717,13 +1717,13 @@ qemuSnapshotRedefine(virDomainObj *vm, virDomainMomentObj *snap =3D NULL; virDomainSnapshotPtr ret =3D NULL; - if (virDomainSnapshotRedefinePrep(vm, &def, &snap, + if (virDomainSnapshotRedefinePrep(vm, &snapdef, &snap, driver->xmlopt, flags) < 0) return NULL; if (!snap) { - if (!(snap =3D virDomainSnapshotAssignDef(vm->snapshots, def))) + if (!(snap =3D virDomainSnapshotAssignDef(vm->snapshots, snapdef))) return NULL; } /* XXX Should we validate that the redefined snapshot even --=20 2.31.1 From nobody Fri Apr 19 08:26:05 2024 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=1642011126; cv=none; d=zohomail.com; s=zohoarc; b=JzM9uxH6u2qemAurhHy1Ag2k8Wc7OAqm/zPE6eilSQ/Rn1BSLC0/B8Q/E/bE4UMhIlKnze1k3YPtp2SzObAH0CVdyRpytIvrzdEd7BJY82a3n3/y3Du7WP7gSc90kP5DR8lgkOQB0X8Fpn9zMZCbB4bZdSYMRRKnC6K0/0EWn5I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1642011126; 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=luo5U7DmKFFQKOoIrORSOOCt75RlGun+vq4Mr82MiRU=; b=CmHqYDYIz5VOGX61CaLNaLdJ5e43iVceaJx3b3aUjW3YKLNjriWF2vg+1j7T9d2pd7RLUzzbFmQGl8GTnTSg/D5Dq8X2MIAt7z2D+NiHLngDMueBSBj28tDngYXGySX7yO6mkTjuaI0T/BhjalwE/tAGC7iZjhvz263e4FOwOPg= 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 164201112613472.12524861889233; Wed, 12 Jan 2022 10:12:06 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-214-DyWxb6wAMqWc32Y1rLJSmA-1; Wed, 12 Jan 2022 13:11:23 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id EE3341083F7B; Wed, 12 Jan 2022 18:11:16 +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 4AF351064145; Wed, 12 Jan 2022 18:11:16 +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 197CE1809CBF; Wed, 12 Jan 2022 18:11:16 +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 20CIATsN002988 for ; Wed, 12 Jan 2022 13:10:29 -0500 Received: by smtp.corp.redhat.com (Postfix) id A30DE8AD01; Wed, 12 Jan 2022 18:10:29 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.34]) by smtp.corp.redhat.com (Postfix) with ESMTP id ECED38ACEA for ; Wed, 12 Jan 2022 18:10:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1642011124; 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=luo5U7DmKFFQKOoIrORSOOCt75RlGun+vq4Mr82MiRU=; b=dB1a+8jqGbmxk1g063UHGi0ZGSivmOLIN+9u3baSZ75oUMqt8ejXodvVSRSXI5kO9+E2Gk KoO12c0D/CQcWGndgXxxsVDKR6ZzVoQRNF48opiDyl6xPgTTIcZIHu7JGBYKK18N9gInNP 59OCk0Niuna+O0CuT6ZCYx0TQpbyLSA= X-MC-Unique: DyWxb6wAMqWc32Y1rLJSmA-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 02/17] qemuSnapshotRedefine: Fix use of snapshot definition after free Date: Wed, 12 Jan 2022 19:10:02 +0100 Message-Id: <112a9482d13f276c46998cc06f52d40c6757744c.1642010887.git.pkrempa@redhat.com> In-Reply-To: References: 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.84 on 10.5.11.22 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: 1642011128474100001 Content-Type: text/plain; charset="utf-8" Commit f4aae9726df factored out the snapshot redefinition code into a separate function, but didn't account for the fact that the code is consuming the reference to the snapshot definition and by moving the code away the caller (qemuSnapshotCreateXML) now frees the definition which didn't happen before as we cleared the pointer. Fix it by increasing the reference locally. Later patches will refactor the code so that it's more obvious what's happening. Fixes: f4aae9726df Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=3D2039651 Signed-off-by: Peter Krempa --- src/qemu/qemu_snapshot.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/qemu/qemu_snapshot.c b/src/qemu/qemu_snapshot.c index 624ace0314..f92e00f9c0 100644 --- a/src/qemu/qemu_snapshot.c +++ b/src/qemu/qemu_snapshot.c @@ -1709,13 +1709,14 @@ qemuSnapshotCreateWriteMetadata(virDomainObj *vm, static virDomainSnapshotPtr qemuSnapshotRedefine(virDomainObj *vm, virDomainPtr domain, - virDomainSnapshotDef *snapdef, + virDomainSnapshotDef *snapdeftmp, virQEMUDriver *driver, virQEMUDriverConfig *cfg, unsigned int flags) { virDomainMomentObj *snap =3D NULL; virDomainSnapshotPtr ret =3D NULL; + g_autoptr(virDomainSnapshotDef) snapdef =3D virObjectRef(snapdeftmp); if (virDomainSnapshotRedefinePrep(vm, &snapdef, &snap, driver->xmlopt, @@ -1725,6 +1726,7 @@ qemuSnapshotRedefine(virDomainObj *vm, if (!snap) { if (!(snap =3D virDomainSnapshotAssignDef(vm->snapshots, snapdef))) return NULL; + snapdef =3D NULL; } /* XXX Should we validate that the redefined snapshot even * makes sense, such as checking that qemu-img recognizes the --=20 2.31.1 From nobody Fri Apr 19 08:26:05 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=1642011088; cv=none; d=zohomail.com; s=zohoarc; b=SLEpW6oY5dS/uE6XlMJjIy6PazaZx0MHVZPILUr1lP3MrI0KH65HYgzQaJBd9UhUqB0Merhx3gdkFYeJviuf9nyVmApnIJLennEAj+M0hd8vbNPwa0FpPK9VLku4YW3yCLZpg7Qg5ohDHjG59BeTN5OzJo3mUoh6gHG58CqoOyM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1642011088; 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=Fk/FzvF5pL2uytkA2y7V034+LSZPtWDpARHCHB7ErGk=; b=R6F6wGd6kH4TdPUvWFUqETSOnpANkvbgUAM3A+GsOnOfrzdmhON+4f5vKTkeloM3Bdx/TAZ3GZtmXCx0mR9j79oXVIUoBnaFMgBdg4zI8nM2Wxu5wp/XEUyj5y4FfhHjYhMCmSGNZOqqId2Dn/nxBQiNU+JHCdM/zJ2vIy6cMZM= 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 1642011088464546.7207474678534; Wed, 12 Jan 2022 10:11:28 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-488-9j-tVyDWMj-dADIJsGxSaQ-1; Wed, 12 Jan 2022 13:11:26 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B7872874991; Wed, 12 Jan 2022 18:11:19 +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 9468F105C89D; Wed, 12 Jan 2022 18:11:19 +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 31BA94A7C8; Wed, 12 Jan 2022 18:11:19 +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 20CIAUj0002998 for ; Wed, 12 Jan 2022 13:10:30 -0500 Received: by smtp.corp.redhat.com (Postfix) id B42ED8AD01; Wed, 12 Jan 2022 18:10:30 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.34]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1ED498AD18 for ; Wed, 12 Jan 2022 18:10:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1642011087; 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=Fk/FzvF5pL2uytkA2y7V034+LSZPtWDpARHCHB7ErGk=; b=c7GloUA34p568mEy8XSKkyetnRbljl+oBGIWqLnKqXDtAdmHTeYKa2rFpkO3PgH6KHZTWm sKNKK3kb5elbwDVfUC4pyvpb1dqx2cE4srv5uPXQs9bC4P1xX9xvCF2QmD1Y3mlCqdEnlN kTOodkPsYZ76W2aBqsTIRE9fkQMPPQE= X-MC-Unique: 9j-tVyDWMj-dADIJsGxSaQ-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 03/17] virDomainMomentAssignDef: Simplify error handling Date: Wed, 12 Jan 2022 19:10:03 +0100 Message-Id: <4eea5056d110ed9770024359ed74f8bc1bad539c.1642010887.git.pkrempa@redhat.com> In-Reply-To: References: 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.84 on 10.5.11.22 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: 1642011088882100001 Content-Type: text/plain; charset="utf-8" Remove error handling from the call to 'virDomainMomentObjNew' as it can't return NULL and replace 'virHashAddEntry' by 'g_hash_table_insert' as we've already checked that snapshot with such name doesn't exist in the hash table. This removes handling for two impossible errors. Signed-off-by: Peter Krempa --- src/conf/virdomainmomentobjlist.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/src/conf/virdomainmomentobjlist.c b/src/conf/virdomainmomentob= jlist.c index 8993c2310b..2f2467d13f 100644 --- a/src/conf/virdomainmomentobjlist.c +++ b/src/conf/virdomainmomentobjlist.c @@ -245,14 +245,9 @@ virDomainMomentAssignDef(virDomainMomentObjList *momen= ts, return NULL; } - if (!(moment =3D virDomainMomentObjNew())) - return NULL; - - if (virHashAddEntry(moments->objs, def->name, moment) < 0) { - VIR_FREE(moment); - return NULL; - } + moment =3D virDomainMomentObjNew(); moment->def =3D def; + g_hash_table_insert(moments->objs, g_strdup(def->name), moment); return moment; } --=20 2.31.1 From nobody Fri Apr 19 08:26:05 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=1642011046; cv=none; d=zohomail.com; s=zohoarc; b=mzLilIEQdU9+dgVkKJi52KfwCdDgBPw9q1u0nHOPbpUc+PxujKLARB5hO+NV4fk25tmltOxXWydaoSoSNixQ5febtDEltap/vlaqDYuY352Drv9bHSP6DBlKhTIIj1+d6is+lTNFavSi6yPoQJH/xRx8i4oKj8FlrJC13zGRIEs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1642011046; 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=GFv0nelKOQLgn3LvRt0XBmupwDdB0P4KmX/NM4EmqbY=; b=ayl7RwtwqP13TTKokf4o5JYIOQLlvo01g3Iq/fBqs1FXL5Dz1CouXas/JwkmLQVnxXYZzRYW7clFGJQ1PGk01IYCFs88uXjJbOjrsXx9FXWsuMbpIlyjDfMLYQKmhyElrUv+b9vHHZHp7CpnabDs95JwViXKqyAjv97exchx32Q= 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 164201104603433.432761508989074; Wed, 12 Jan 2022 10:10:46 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-460-fEadW5aUNDOrGElE2nGRiA-1; Wed, 12 Jan 2022 13:10:41 -0500 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 240AE1B18BC0; Wed, 12 Jan 2022 18:10:36 +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 E062B7766F; Wed, 12 Jan 2022 18:10:34 +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 07E5B1809CB8; Wed, 12 Jan 2022 18:10:33 +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 20CIAVLA003006 for ; Wed, 12 Jan 2022 13:10:31 -0500 Received: by smtp.corp.redhat.com (Postfix) id DFCEA8AD01; Wed, 12 Jan 2022 18:10:31 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.34]) by smtp.corp.redhat.com (Postfix) with ESMTP id 35C4D8CB1D for ; Wed, 12 Jan 2022 18:10:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1642011045; 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=GFv0nelKOQLgn3LvRt0XBmupwDdB0P4KmX/NM4EmqbY=; b=bGFqT+wj/upCDWJ1izcIE26SB4pHQY9q/U26X2f2gH/i28mst0qbjWvMeSE0GLiXhqqR26 0OqRNez5jbHvsdlNFfp3SmTI/JMuKfPjee2mLzgQCyc4zJdJqpnqaUOqM1Dtpb9dg+wInJ mrKjBIJ8TfAdXdPrSDJATq1yCLNX7zc= X-MC-Unique: fEadW5aUNDOrGElE2nGRiA-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 04/17] virDomainSnapshotRedefineValidate: Fix validation of VIR_DOMAIN_SNAPSHOT_CREATE_DISK_ONLY flag Date: Wed, 12 Jan 2022 19:10:04 +0100 Message-Id: <194cba971a75f4d8ff59440e8bf4b3f0c04a0835.1642010887.git.pkrempa@redhat.com> In-Reply-To: References: 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.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) X-ZM-MESSAGEID: 1642011047382100001 Content-Type: text/plain; charset="utf-8" External snapshot with memory is created without using the VIR_DOMAIN_SNAPSHOT_CREATE_DISK_ONLY flag, but rather with properly configuring the XML. When redefining the code should be checking the same thing as by definition an external snapshot with memory is not a disk-only snapshot. Signed-off-by: Peter Krempa --- src/conf/snapshot_conf.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/conf/snapshot_conf.c b/src/conf/snapshot_conf.c index fc6f0a859d..d46d9bd335 100644 --- a/src/conf/snapshot_conf.c +++ b/src/conf/snapshot_conf.c @@ -478,7 +478,8 @@ virDomainSnapshotRedefineValidate(virDomainSnapshotDef = *def, bool external =3D def->state =3D=3D VIR_DOMAIN_SNAPSHOT_DISK_SNAPSHOT = || virDomainSnapshotDefIsExternal(def); - if ((flags & VIR_DOMAIN_SNAPSHOT_CREATE_DISK_ONLY) && !external) { + if ((flags & VIR_DOMAIN_SNAPSHOT_CREATE_DISK_ONLY) && + def->state !=3D VIR_DOMAIN_SNAPSHOT_DISK_SNAPSHOT) { virReportError(VIR_ERR_INVALID_ARG, _("disk-only flag for snapshot %s requires " "disk-snapshot state"), --=20 2.31.1 From nobody Fri Apr 19 08:26:05 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=1642011092; cv=none; d=zohomail.com; s=zohoarc; b=YT4EDWMsrLepD42LfcMkeKeDakERgCHK14fa89uyZq82Ih6GZrKeAnaZgDNJVW/LwNOnC0DFDS378DltA/6sj2rzk1akzxyv/dvKbVRYjrzesQjp6IOKJxdz0jM7WdDKePEKExTwJAE7c8v8S4OfFioVwdHeZXLHDWVlJ7VMlQc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1642011092; 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=DLs7+YXfJLLiCupFypnzxCv4BCJLc40PtrPieCxHl5k=; b=IaWDmDmsztq2EfV7nRrM1hy9EihHFFyYt1W6yP9gRyqYM0hZ0B9aLcFbJRa4mE8Xm8bhVWHKcwYjYCuhuF+LWio4+b9NbBnGhB+r83UJprb+JBOVZ2hl1HNzrQHE8QN6LIEOmT6V32RFX/WxYOKYybTD368eyLf270ELhx4qYaM= 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 1642011092689574.2840574460885; Wed, 12 Jan 2022 10:11:32 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-544-UaN8pvERONKBXaWFjm83GQ-1; Wed, 12 Jan 2022 13:11:29 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 800F8874984; Wed, 12 Jan 2022 18:11:22 +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 5CE89105C725; Wed, 12 Jan 2022 18:11:22 +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 2CA764A7CD; Wed, 12 Jan 2022 18:11:22 +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 20CIAXTl003026 for ; Wed, 12 Jan 2022 13:10:33 -0500 Received: by smtp.corp.redhat.com (Postfix) id 0647A8AD18; Wed, 12 Jan 2022 18:10:33 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.34]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5B2718AD01 for ; Wed, 12 Jan 2022 18:10:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1642011091; 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=DLs7+YXfJLLiCupFypnzxCv4BCJLc40PtrPieCxHl5k=; b=SabuTuBeEV3jG0edFasJ8KF5e636Xea5rvzpnrY9IUl3T6xoAx8sviuOdngcUE/xJFM0Yf pb5S97mHBDlVtGxlaoH0hjLSwkem3bdBEeTl8E2WHZxWgC7xCxTtdUx/d0RQQiWel5UJm3 +byng04qOgTw3JR5snogXlX1dcRhkVA= X-MC-Unique: UaN8pvERONKBXaWFjm83GQ-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 05/17] virDomainSnapshotAlignDisks: Improve function comment Date: Wed, 12 Jan 2022 19:10:05 +0100 Message-Id: In-Reply-To: References: 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.84 on 10.5.11.22 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: 1642011093805100001 Content-Type: text/plain; charset="utf-8" Add description of arguments, reword the description for clarity, and fix improper argument names mentioned in the existing description. Signed-off-by: Peter Krempa --- src/conf/snapshot_conf.c | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/src/conf/snapshot_conf.c b/src/conf/snapshot_conf.c index d46d9bd335..d7e18596bc 100644 --- a/src/conf/snapshot_conf.c +++ b/src/conf/snapshot_conf.c @@ -622,13 +622,22 @@ virDomainSnapshotDefAssignExternalNames(virDomainSnap= shotDef *def) } -/* Align def->disks to def->parent.dom. Sort the list of def->disks, - * filling in any missing disks or snapshot state defaults given by - * the domain, with a fallback to a passed in default. Convert paths - * to disk targets for uniformity. Issue an error and return -1 if - * any def->disks[n]->name appears more than once or does not map to - * dom->disks. If require_match, also ensure that there is no - * conflicting requests for both internal and external snapshots. */ +/** + * virDomainSnapshotAlignDisks: + * @snapdef: Snapshot definition to align + * @default_snapshot: snapshot location to assign to disks which don't hav= e any + * @require_match: Require that all disks use the same snapshot mode + * + * Align snapdef->disks to snapdef->parent.dom, filling in any missing dis= ks or + * snapshot state defaults given by the domain, with a fallback to + * @default_snapshot. Ensure that there are no duplicate snapshot disk + * definitions in @snapdef and there are no disks described in @snapdef but + * missing from the domain definition. + * + * Convert paths to disk targets for uniformity. + * + * On error -1 is returned and a libvirt error is reported. + */ int virDomainSnapshotAlignDisks(virDomainSnapshotDef *snapdef, int default_snapshot, --=20 2.31.1 From nobody Fri Apr 19 08:26:05 2024 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=1642011095; cv=none; d=zohomail.com; s=zohoarc; b=C0ErldySs/bIdqYPUvmtNL+tWWA8tBNQ2ljW5+6AS5bI4hGGP0KZMUH9OVhaz/UmlHgOc8bfkGJkuau1WkJyOCfl/P29D7h4GwjruWWIaEzL8Hiz03mC4sI7ovZa/HRTMBct1V+JdKg53j/5ds7foy2ggTYwG6hCWDzfioBs/D0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1642011095; 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=mahRdiA1uk/iWgJNxf5HfsLZ3duMs37bDOaWKNyl+7M=; b=RwWFmD0WaAgU0ixfSvfZAzVfpUFH5jNw0GyEcnhffEdsaTzRAl0D56jUJ+lV3KLdWZGN9ET4mFxfJvMfUarh+whURTQxbhpQ2NZuc8i3TyR///hWVKeIZz61B1bXTz7pUn+U4ilkppE/1P+89CH2nuz+zkT1izNtDRudoDIUi9c= 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 1642011095544860.5228721838254; Wed, 12 Jan 2022 10:11:35 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-141-quwwKETsN7mE5feONVUorA-1; Wed, 12 Jan 2022 13:11:32 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 8941B100C62F; Wed, 12 Jan 2022 18:11:25 +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 5FCC5108F847; Wed, 12 Jan 2022 18:11:25 +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 F27851806D2B; Wed, 12 Jan 2022 18:11:24 +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 20CIAYG1003046 for ; Wed, 12 Jan 2022 13:10:34 -0500 Received: by smtp.corp.redhat.com (Postfix) id 2CFE48BB04; Wed, 12 Jan 2022 18:10:34 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.34]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7BAE48AD18 for ; Wed, 12 Jan 2022 18:10:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1642011094; 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=mahRdiA1uk/iWgJNxf5HfsLZ3duMs37bDOaWKNyl+7M=; b=CCxFZFsxnJWTverrUiA213lRWYdmP6JWwWobReWp8KqyKgD1pjWc1fv8zJ7jep3Ga+qPnG 5qFA2VEUYLJLlTc0MseKY+btNRkgj3bWZbkFyYmDL/UYUxtSOjYqQr+oQ/M6tteO6675Gr Lrox1yOwsmDQhQjce0ZVp86VD8eaHn4= X-MC-Unique: quwwKETsN7mE5feONVUorA-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 06/17] virDomainSnapshotAlignDisks: Convert @default_snapshot to virDomainSnapshotLocation Date: Wed, 12 Jan 2022 19:10:06 +0100 Message-Id: In-Reply-To: References: 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.84 on 10.5.11.22 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: 1642011096422100005 Content-Type: text/plain; charset="utf-8" Use the appropriate type for the variable and fix all callers. Signed-off-by: Peter Krempa --- src/conf/snapshot_conf.c | 4 ++-- src/conf/snapshot_conf.h | 2 +- src/qemu/qemu_snapshot.c | 2 +- src/test/test_driver.c | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/conf/snapshot_conf.c b/src/conf/snapshot_conf.c index d7e18596bc..f0ded7919c 100644 --- a/src/conf/snapshot_conf.c +++ b/src/conf/snapshot_conf.c @@ -473,7 +473,7 @@ virDomainSnapshotRedefineValidate(virDomainSnapshotDef = *def, virDomainXMLOption *xmlopt, unsigned int flags) { - int align_location =3D VIR_DOMAIN_SNAPSHOT_LOCATION_INTERNAL; + virDomainSnapshotLocation align_location =3D VIR_DOMAIN_SNAPSHOT_LOCAT= ION_INTERNAL; bool align_match =3D true; bool external =3D def->state =3D=3D VIR_DOMAIN_SNAPSHOT_DISK_SNAPSHOT = || virDomainSnapshotDefIsExternal(def); @@ -640,7 +640,7 @@ virDomainSnapshotDefAssignExternalNames(virDomainSnapsh= otDef *def) */ int virDomainSnapshotAlignDisks(virDomainSnapshotDef *snapdef, - int default_snapshot, + virDomainSnapshotLocation default_snapshot, bool require_match) { virDomainDef *domdef =3D snapdef->parent.dom; diff --git a/src/conf/snapshot_conf.h b/src/conf/snapshot_conf.h index a3ec0cd410..e5d4d0fc45 100644 --- a/src/conf/snapshot_conf.h +++ b/src/conf/snapshot_conf.h @@ -126,7 +126,7 @@ char *virDomainSnapshotDefFormat(const char *uuidstr, virDomainXMLOption *xmlopt, unsigned int flags); int virDomainSnapshotAlignDisks(virDomainSnapshotDef *snapshot, - int default_snapshot, + virDomainSnapshotLocation default_snapshot, bool require_match); bool virDomainSnapshotDefIsExternal(virDomainSnapshotDef *def); diff --git a/src/qemu/qemu_snapshot.c b/src/qemu/qemu_snapshot.c index f92e00f9c0..51df0ed8df 100644 --- a/src/qemu/qemu_snapshot.c +++ b/src/qemu/qemu_snapshot.c @@ -1630,7 +1630,7 @@ qemuSnapshotCreateAlignDisks(virDomainObj *vm, { g_autofree char *xml =3D NULL; qemuDomainObjPrivate *priv =3D vm->privateData; - int align_location =3D VIR_DOMAIN_SNAPSHOT_LOCATION_INTERNAL; + virDomainSnapshotLocation align_location =3D VIR_DOMAIN_SNAPSHOT_LOCAT= ION_INTERNAL; bool align_match =3D true; /* Easiest way to clone inactive portion of vm->def is via diff --git a/src/test/test_driver.c b/src/test/test_driver.c index 0e93b79922..2ff56cf03f 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -8717,7 +8717,7 @@ testDomainSnapshotAlignDisks(virDomainObj *vm, virDomainSnapshotDef *def, unsigned int flags) { - int align_location =3D VIR_DOMAIN_SNAPSHOT_LOCATION_INTERNAL; + virDomainSnapshotLocation align_location =3D VIR_DOMAIN_SNAPSHOT_LOCAT= ION_INTERNAL; bool align_match =3D true; if (flags & VIR_DOMAIN_SNAPSHOT_CREATE_DISK_ONLY) { --=20 2.31.1 From nobody Fri Apr 19 08:26:05 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=1642011102; cv=none; d=zohomail.com; s=zohoarc; b=L2PLzYIMhszD8U68Sfz8/8bSOxJFUQjA3MNe9HzIG7obAgdCRU7YumWmfi5nYFc0i2AbBZCTBsB/coz7w4+R9vgQi8sM/F1802LwEkCcecVrqa5ScdTgt35GS83sAcgujUsTkq1Ez7Y5e6hxfnj+7JcUPkmbwPmUp7xdbjk568o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1642011102; 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=Nauk54t8+RliN3kv5MTqSEoz3Y4cwVKkI7t4oZym0fQ=; b=mSGf7DPJkIGy5iEtc8BilL2DA2kbnCLUALvf9YZ/GLlHkpnbpiWvsjHUJj4SR0jY/9K75BTQpo3WJ7tEnnZke4A6U/Wdhw+FUu52zdWbRbFrKzi8unWLcz9TVYWRnHnXFM9G4O6oO0rAtNM2wffXj6MTvTLo/qECEZlgfJqp5fE= 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 1642011102283141.3249049647826; Wed, 12 Jan 2022 10:11:42 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-610-yc7nowhBORSsMRqz-ORyAw-1; Wed, 12 Jan 2022 13:11:34 -0500 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 A2D5E1083F70; Wed, 12 Jan 2022 18:11:28 +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 7C5BE77464; Wed, 12 Jan 2022 18:11:28 +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 494484A7CD; Wed, 12 Jan 2022 18:11:28 +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 20CIAZtZ003057 for ; Wed, 12 Jan 2022 13:10:35 -0500 Received: by smtp.corp.redhat.com (Postfix) id 4C7BF8BB04; Wed, 12 Jan 2022 18:10:35 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.34]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9A2098AD18 for ; Wed, 12 Jan 2022 18:10:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1642011101; 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=Nauk54t8+RliN3kv5MTqSEoz3Y4cwVKkI7t4oZym0fQ=; b=Ywgx8EIE6edn0TKZ4jevq9QWPdcyQA/6+nOSKqwNMYGcQNNF78X15N3UmnA8hMLZvDlH9d BtnsNRUHrKvKterHjqE8aC9kFCmBR9UzDBus+dQ1F1+Ml9zxpBhxwk2oGZb1zglPLbCAlO vlJw062pfPf9EmBFM1whYOnBDMzar1Y= X-MC-Unique: yc7nowhBORSsMRqz-ORyAw-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 07/17] virDomainSnapshotAlignDisks: Move 'require_match' selection logic inside Date: Wed, 12 Jan 2022 19:10:07 +0100 Message-Id: <9802d1c692df3c3009b152e2e559e1cf3fa0dcd5.1642010887.git.pkrempa@redhat.com> In-Reply-To: References: 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.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) X-ZM-MESSAGEID: 1642011103823100003 Content-Type: text/plain; charset="utf-8" 'require_match' set to true is only needed for internal snapshots taken by hypervisors (qemu) which don't have a way to control which disks take part in the snapshot (savevm). To de-clutter callers we can change the argument to mean 'this code path requires uniform snapshot for internal snapshots'. Change the argument and fix the callers. For now all callers pass 'true' but any new hypervisor or even usage in qemu is not going to share the limitation. Signed-off-by: Peter Krempa --- src/conf/snapshot_conf.c | 24 ++++++++++++++++-------- src/conf/snapshot_conf.h | 2 +- src/qemu/qemu_snapshot.c | 5 +---- src/test/test_driver.c | 5 +---- 4 files changed, 19 insertions(+), 17 deletions(-) diff --git a/src/conf/snapshot_conf.c b/src/conf/snapshot_conf.c index f0ded7919c..43f984912e 100644 --- a/src/conf/snapshot_conf.c +++ b/src/conf/snapshot_conf.c @@ -474,7 +474,6 @@ virDomainSnapshotRedefineValidate(virDomainSnapshotDef = *def, unsigned int flags) { virDomainSnapshotLocation align_location =3D VIR_DOMAIN_SNAPSHOT_LOCAT= ION_INTERNAL; - bool align_match =3D true; bool external =3D def->state =3D=3D VIR_DOMAIN_SNAPSHOT_DISK_SNAPSHOT = || virDomainSnapshotDefIsExternal(def); @@ -533,12 +532,10 @@ virDomainSnapshotRedefineValidate(virDomainSnapshotDe= f *def, } if (def->parent.dom) { - if (external) { + if (external) align_location =3D VIR_DOMAIN_SNAPSHOT_LOCATION_EXTERNAL; - align_match =3D false; - } - if (virDomainSnapshotAlignDisks(def, align_location, - align_match) < 0) + + if (virDomainSnapshotAlignDisks(def, align_location, true) < 0) return -1; } @@ -626,7 +623,8 @@ virDomainSnapshotDefAssignExternalNames(virDomainSnapsh= otDef *def) * virDomainSnapshotAlignDisks: * @snapdef: Snapshot definition to align * @default_snapshot: snapshot location to assign to disks which don't hav= e any - * @require_match: Require that all disks use the same snapshot mode + * @uniform_internal_snapshot: Require that for an internal snapshot all d= isks + * take part in the internal snapshot * * Align snapdef->disks to snapdef->parent.dom, filling in any missing dis= ks or * snapshot state defaults given by the domain, with a fallback to @@ -634,6 +632,11 @@ virDomainSnapshotDefAssignExternalNames(virDomainSnaps= hotDef *def) * definitions in @snapdef and there are no disks described in @snapdef but * missing from the domain definition. * + * When @uniform_internal_snapshot is true and @default_snapshot is + * VIR_DOMAIN_SNAPSHOT_LOCATION_INTERNAL, all disks in @snapdef must take = part + * in the internal snapshot. This is for hypervisors where granularity of = an + * internal snapshot can't be controlled. + * * Convert paths to disk targets for uniformity. * * On error -1 is returned and a libvirt error is reported. @@ -641,11 +644,12 @@ virDomainSnapshotDefAssignExternalNames(virDomainSnap= shotDef *def) int virDomainSnapshotAlignDisks(virDomainSnapshotDef *snapdef, virDomainSnapshotLocation default_snapshot, - bool require_match) + bool uniform_internal_snapshot) { virDomainDef *domdef =3D snapdef->parent.dom; g_autoptr(GHashTable) map =3D virHashNew(NULL); g_autofree virDomainSnapshotDiskDef *olddisks =3D NULL; + bool require_match =3D false; size_t oldndisks; size_t i; @@ -661,6 +665,10 @@ virDomainSnapshotAlignDisks(virDomainSnapshotDef *snap= def, return -1; } + if (uniform_internal_snapshot && + default_snapshot =3D=3D VIR_DOMAIN_SNAPSHOT_LOCATION_INTERNAL) + require_match =3D true; + /* Unlikely to have a guest without disks but technically possible. */ if (!domdef->ndisks) return 0; diff --git a/src/conf/snapshot_conf.h b/src/conf/snapshot_conf.h index e5d4d0fc45..505c9f785d 100644 --- a/src/conf/snapshot_conf.h +++ b/src/conf/snapshot_conf.h @@ -127,7 +127,7 @@ char *virDomainSnapshotDefFormat(const char *uuidstr, unsigned int flags); int virDomainSnapshotAlignDisks(virDomainSnapshotDef *snapshot, virDomainSnapshotLocation default_snapshot, - bool require_match); + bool uniform_internal_snapshot); bool virDomainSnapshotDefIsExternal(virDomainSnapshotDef *def); bool virDomainSnapshotIsExternal(virDomainMomentObj *snap); diff --git a/src/qemu/qemu_snapshot.c b/src/qemu/qemu_snapshot.c index 51df0ed8df..48fa19cebd 100644 --- a/src/qemu/qemu_snapshot.c +++ b/src/qemu/qemu_snapshot.c @@ -1631,7 +1631,6 @@ qemuSnapshotCreateAlignDisks(virDomainObj *vm, g_autofree char *xml =3D NULL; qemuDomainObjPrivate *priv =3D vm->privateData; virDomainSnapshotLocation align_location =3D VIR_DOMAIN_SNAPSHOT_LOCAT= ION_INTERNAL; - bool align_match =3D true; /* Easiest way to clone inactive portion of vm->def is via * conversion in and back out of xml. */ @@ -1653,7 +1652,6 @@ qemuSnapshotCreateAlignDisks(virDomainObj *vm, if (flags & VIR_DOMAIN_SNAPSHOT_CREATE_DISK_ONLY) { align_location =3D VIR_DOMAIN_SNAPSHOT_LOCATION_EXTERNAL; - align_match =3D false; if (virDomainObjIsActive(vm)) def->state =3D VIR_DOMAIN_SNAPSHOT_DISK_SNAPSHOT; else @@ -1662,7 +1660,6 @@ qemuSnapshotCreateAlignDisks(virDomainObj *vm, } else if (def->memory =3D=3D VIR_DOMAIN_SNAPSHOT_LOCATION_EXTERNAL) { def->state =3D virDomainObjGetState(vm, NULL); align_location =3D VIR_DOMAIN_SNAPSHOT_LOCATION_EXTERNAL; - align_match =3D false; } else { def->state =3D virDomainObjGetState(vm, NULL); @@ -1678,7 +1675,7 @@ qemuSnapshotCreateAlignDisks(virDomainObj *vm, VIR_DOMAIN_SNAPSHOT_LOCATION_NONE : VIR_DOMAIN_SNAPSHOT_LOCATION_INTERNAL); } - if (virDomainSnapshotAlignDisks(def, align_location, align_match) < 0) + if (virDomainSnapshotAlignDisks(def, align_location, true) < 0) return -1; return 0; diff --git a/src/test/test_driver.c b/src/test/test_driver.c index 2ff56cf03f..44f06530b5 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -8718,11 +8718,9 @@ testDomainSnapshotAlignDisks(virDomainObj *vm, unsigned int flags) { virDomainSnapshotLocation align_location =3D VIR_DOMAIN_SNAPSHOT_LOCAT= ION_INTERNAL; - bool align_match =3D true; if (flags & VIR_DOMAIN_SNAPSHOT_CREATE_DISK_ONLY) { align_location =3D VIR_DOMAIN_SNAPSHOT_LOCATION_EXTERNAL; - align_match =3D false; if (virDomainObjIsActive(vm)) def->state =3D VIR_DOMAIN_SNAPSHOT_DISK_SNAPSHOT; else @@ -8731,7 +8729,6 @@ testDomainSnapshotAlignDisks(virDomainObj *vm, } else if (def->memory =3D=3D VIR_DOMAIN_SNAPSHOT_LOCATION_EXTERNAL) { def->state =3D virDomainObjGetState(vm, NULL); align_location =3D VIR_DOMAIN_SNAPSHOT_LOCATION_EXTERNAL; - align_match =3D false; } else { def->state =3D virDomainObjGetState(vm, NULL); def->memory =3D def->state =3D=3D VIR_DOMAIN_SNAPSHOT_SHUTOFF ? @@ -8739,7 +8736,7 @@ testDomainSnapshotAlignDisks(virDomainObj *vm, VIR_DOMAIN_SNAPSHOT_LOCATION_INTERNAL; } - return virDomainSnapshotAlignDisks(def, align_location, align_match); + return virDomainSnapshotAlignDisks(def, align_location, true); } static virDomainSnapshotPtr --=20 2.31.1 From nobody Fri Apr 19 08:26:05 2024 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=1642011057; cv=none; d=zohomail.com; s=zohoarc; b=juXUqHIRhdH3O75PJ2+V8dNcMkczbH6oF/j3KP8WEYynAFF0zYm8CRQKa0YMvGCgz+kEpW3ICQu/qo6bvUVsO+LlNcym7HTH2Utte33D2XDtuheRWaOY0IeRHCoSr+MwQQ9o0/cjGrso+DMQuRuw8855Et8eKfZNbuGRD2gQa6w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1642011057; 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=7QTd8jD8WOgULi0uXKtHgn06arfP7fTpN35DnTu3Raw=; b=kDeTJVdh8beU31jYytoquGeMilcfRiC8BudZFSc3jzVrZZuWRBv9bGHAJMPCgyddULIxh0BA8af0MZ9vAmz/sYvFzTLCA0ZoudpbqRSrZj2oNyL4FzGUpkikrBumExPHUnyngBwUIZzSpOEOhPCSuf/jf9cdxnXrVDyCInD3pYI= 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 1642011057986312.97910067692976; Wed, 12 Jan 2022 10:10:57 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-237-QMMFGEoLPE6B_caJFdG1gg-1; Wed, 12 Jan 2022 13:10:53 -0500 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 9A0841083F61; Wed, 12 Jan 2022 18:10:47 +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 4D54B7A46D; Wed, 12 Jan 2022 18:10:47 +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 15CD14CA93; Wed, 12 Jan 2022 18:10:47 +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 20CIAaxL003073 for ; Wed, 12 Jan 2022 13:10:36 -0500 Received: by smtp.corp.redhat.com (Postfix) id 7E7108CB20; Wed, 12 Jan 2022 18:10:36 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.34]) by smtp.corp.redhat.com (Postfix) with ESMTP id ADB908AD18 for ; Wed, 12 Jan 2022 18:10:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1642011056; 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=7QTd8jD8WOgULi0uXKtHgn06arfP7fTpN35DnTu3Raw=; b=ZCasTPGwY23+qBKsidTWmr5p/B/2UGgCKyKu22xoTfP0U+QYqQ1OKE8AXfyXamjqGeVBY/ 4nU1uVoiV2yU+pKI7kNk0MBU+zh82lqPGlk2eXwFYTbyZgE+iVIc5czynVGximKIKCNaz2 WLOrQRECHQ1izHZydh6DanHMLT9PMak= X-MC-Unique: QMMFGEoLPE6B_caJFdG1gg-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 08/17] virDomainSnapshotAlignDisks: Allow alternate domain definition when redefining Date: Wed, 12 Jan 2022 19:10:08 +0100 Message-Id: In-Reply-To: References: 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: 1642011059784100001 Content-Type: text/plain; charset="utf-8" Due to historical reasons we allow users to redefine an existing snapshot without providing the domain definition which would correspond to it. In such case we'd use the domain definition from the snapshot that is being redefined. To prevent callers from doing complex moving of the domain definition object back and forth between the snapshot definitions we can add an argument to virDomainSnapshotAlignDisks which will allow us to pass in the alternate definition if the one from the snapshot is missing. Signed-off-by: Peter Krempa --- src/conf/snapshot_conf.c | 14 ++++++++++++-- src/conf/snapshot_conf.h | 1 + src/qemu/qemu_snapshot.c | 2 +- src/test/test_driver.c | 2 +- 4 files changed, 15 insertions(+), 4 deletions(-) diff --git a/src/conf/snapshot_conf.c b/src/conf/snapshot_conf.c index 43f984912e..be5deadc8c 100644 --- a/src/conf/snapshot_conf.c +++ b/src/conf/snapshot_conf.c @@ -535,7 +535,7 @@ virDomainSnapshotRedefineValidate(virDomainSnapshotDef = *def, if (external) align_location =3D VIR_DOMAIN_SNAPSHOT_LOCATION_EXTERNAL; - if (virDomainSnapshotAlignDisks(def, align_location, true) < 0) + if (virDomainSnapshotAlignDisks(def, NULL, align_location, true) <= 0) return -1; } @@ -622,16 +622,22 @@ virDomainSnapshotDefAssignExternalNames(virDomainSnap= shotDef *def) /** * virDomainSnapshotAlignDisks: * @snapdef: Snapshot definition to align + * @existingDomainDef: definition of the domain belonging to a redefined s= napshot * @default_snapshot: snapshot location to assign to disks which don't hav= e any * @uniform_internal_snapshot: Require that for an internal snapshot all d= isks * take part in the internal snapshot * - * Align snapdef->disks to snapdef->parent.dom, filling in any missing dis= ks or + * Align snapdef->disks to domain definition, filling in any missing disks= or * snapshot state defaults given by the domain, with a fallback to * @default_snapshot. Ensure that there are no duplicate snapshot disk * definitions in @snapdef and there are no disks described in @snapdef but * missing from the domain definition. * + * By default the domain definition from @snapdef->parent.dom is used, but= when + * redefining an existing snapshot the domain definition may be omitted in + * @snapdef. In such case callers must pass in the definition from the sna= psot + * being redefined as @existingDomainDef. In all other cases callers pass = NULL. + * * When @uniform_internal_snapshot is true and @default_snapshot is * VIR_DOMAIN_SNAPSHOT_LOCATION_INTERNAL, all disks in @snapdef must take = part * in the internal snapshot. This is for hypervisors where granularity of = an @@ -643,6 +649,7 @@ virDomainSnapshotDefAssignExternalNames(virDomainSnapsh= otDef *def) */ int virDomainSnapshotAlignDisks(virDomainSnapshotDef *snapdef, + virDomainDef *existingDomainDef, virDomainSnapshotLocation default_snapshot, bool uniform_internal_snapshot) { @@ -653,6 +660,9 @@ virDomainSnapshotAlignDisks(virDomainSnapshotDef *snapd= ef, size_t oldndisks; size_t i; + if (!domdef) + domdef =3D existingDomainDef; + if (!domdef) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("missing domain in snapshot")); diff --git a/src/conf/snapshot_conf.h b/src/conf/snapshot_conf.h index 505c9f785d..446d0870f4 100644 --- a/src/conf/snapshot_conf.h +++ b/src/conf/snapshot_conf.h @@ -126,6 +126,7 @@ char *virDomainSnapshotDefFormat(const char *uuidstr, virDomainXMLOption *xmlopt, unsigned int flags); int virDomainSnapshotAlignDisks(virDomainSnapshotDef *snapshot, + virDomainDef *existingDomainDef, virDomainSnapshotLocation default_snapshot, bool uniform_internal_snapshot); diff --git a/src/qemu/qemu_snapshot.c b/src/qemu/qemu_snapshot.c index 48fa19cebd..797972f4d4 100644 --- a/src/qemu/qemu_snapshot.c +++ b/src/qemu/qemu_snapshot.c @@ -1675,7 +1675,7 @@ qemuSnapshotCreateAlignDisks(virDomainObj *vm, VIR_DOMAIN_SNAPSHOT_LOCATION_NONE : VIR_DOMAIN_SNAPSHOT_LOCATION_INTERNAL); } - if (virDomainSnapshotAlignDisks(def, align_location, true) < 0) + if (virDomainSnapshotAlignDisks(def, NULL, align_location, true) < 0) return -1; return 0; diff --git a/src/test/test_driver.c b/src/test/test_driver.c index 44f06530b5..dde7bf1b8e 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -8736,7 +8736,7 @@ testDomainSnapshotAlignDisks(virDomainObj *vm, VIR_DOMAIN_SNAPSHOT_LOCATION_INTERNAL; } - return virDomainSnapshotAlignDisks(def, align_location, true); + return virDomainSnapshotAlignDisks(def, NULL, align_location, true); } static virDomainSnapshotPtr --=20 2.31.1 From nobody Fri Apr 19 08:26:05 2024 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=1642011101; cv=none; d=zohomail.com; s=zohoarc; b=mih74SdvG1jRrBzNrw7qdGakmzAnYhpNbIdsaDljNxN5bu+/A9mznm5xszxkl9g6mMvofpuDMrJ7z2n5Qk3NJFYKBTVBG/hoXD59sRPCgn7g1OPVQ/mTXBsXWGPkQXyJdOETqcShof55Omjq/cY9mcFA3HIC28cbLP/4Ulnwrvc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1642011101; 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=qpQgmNe+fcqYi7lMBYJtzTouNsFGFOXvoZB2eNvW7ds=; b=dDAzUBkp54CfLOLsBQGDlJuK70F57iZIAQVpS3Vqnv4e64Ps9Fhyb/wUcXBjfWcisDCn4HXhuD4tBZkhemGJ9fmxm6e7/bJfyaiuEK04nA8lbIB+xq0MJfIfiPEai4F44+aV3exWzKx2dps4X8C/i52m/Jm3cvDc8W2aRTvlKk0= 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 1642011101729514.397431570514; Wed, 12 Jan 2022 10:11:41 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-443-X7XbkA7wPgSJsjb5uVoYQw-1; Wed, 12 Jan 2022 13:11:38 -0500 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 8CF94345C8; Wed, 12 Jan 2022 18:11:31 +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 43AA377671; Wed, 12 Jan 2022 18:11: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 13F7A4A705; Wed, 12 Jan 2022 18:11:31 +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 20CIAbIU003081 for ; Wed, 12 Jan 2022 13:10:37 -0500 Received: by smtp.corp.redhat.com (Postfix) id 982738CB1D; Wed, 12 Jan 2022 18:10:37 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.34]) by smtp.corp.redhat.com (Postfix) with ESMTP id ED5128AD18 for ; Wed, 12 Jan 2022 18:10:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1642011100; 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=qpQgmNe+fcqYi7lMBYJtzTouNsFGFOXvoZB2eNvW7ds=; b=ARh4Jj8K8H2vtNC8pM6KOEQ3OzMv4AajILUwUDZBOZ4/PcMg0aX4xvrz3PE8aOyI8g5Yy+ +F10OCa1otqGrA/h8N6RXOzlyc9L6DcvCN7nb59FyTQNQo9stBYY+CKfW12HvEm1pk36JN Kd1ct2Yhs/ZQRB7m5rgyjliXPzjQU3w= X-MC-Unique: X7XbkA7wPgSJsjb5uVoYQw-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 09/17] virDomainSnapshotRedefineValidate: Unexport Date: Wed, 12 Jan 2022 19:10:09 +0100 Message-Id: In-Reply-To: References: 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.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) X-ZM-MESSAGEID: 1642011103683100001 Content-Type: text/plain; charset="utf-8" The function isn't used outside of src/conf/snapshot_conf.c Signed-off-by: Peter Krempa --- src/conf/snapshot_conf.c | 2 +- src/conf/snapshot_conf.h | 6 ------ 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/src/conf/snapshot_conf.c b/src/conf/snapshot_conf.c index be5deadc8c..1d61f93b65 100644 --- a/src/conf/snapshot_conf.c +++ b/src/conf/snapshot_conf.c @@ -466,7 +466,7 @@ virDomainSnapshotDefParseString(const char *xmlStr, /* Perform sanity checking on a redefined snapshot definition. If * @other is non-NULL, this may include swapping def->parent.dom from other * into def. */ -int +static int virDomainSnapshotRedefineValidate(virDomainSnapshotDef *def, const unsigned char *domain_uuid, virDomainMomentObj *other, diff --git a/src/conf/snapshot_conf.h b/src/conf/snapshot_conf.h index 446d0870f4..b04163efae 100644 --- a/src/conf/snapshot_conf.h +++ b/src/conf/snapshot_conf.h @@ -139,11 +139,5 @@ int virDomainSnapshotRedefinePrep(virDomainObj *vm, virDomainXMLOption *xmlopt, unsigned int flags); -int virDomainSnapshotRedefineValidate(virDomainSnapshotDef *def, - const unsigned char *domain_uuid, - virDomainMomentObj *other, - virDomainXMLOption *xmlopt, - unsigned int flags); - VIR_ENUM_DECL(virDomainSnapshotLocation); VIR_ENUM_DECL(virDomainSnapshotState); --=20 2.31.1 From nobody Fri Apr 19 08:26:05 2024 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=1642011105; cv=none; d=zohomail.com; s=zohoarc; b=KmArOpOuFU4/nYUzUYpEcK2FWZQo+Eda1zEaMFBz8jXY4FX7oSFjdhgpeC4ji8X9V1dPc9EAfZaD20SknlFajDvZ1bo0Rg43YbWlCG8XrpI/3vwSdOVO1gH57d4K9QXYDbRZI2hX3P0qXw0+Gqw8RwgfkbBvkFGb6/h9CsinqaQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1642011105; 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=repU4Y2Ph3VqQpzWHz3+KrxSjR7i2SgTKeMm70soThg=; b=JODMbxSasa8Ma48Jp9SGFqkJsnCXBUDyEUQ9j2r/nFHDhtjhvKpS9+Cb4sZFeQ+1ldNOn51vxN1v0NN83izzs7LcbG+qMx0WMpGCqEjQPm22BGbus9dTDLtMXJ9h3IZBwRbCqooMJOHOWGYwo61+/OOOBgLliyiUhhJgP6UKDYg= 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 1642011105155255.74498944400034; Wed, 12 Jan 2022 10:11:45 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-65-UNf5OHM2NZeF4xl7AM-61w-1; Wed, 12 Jan 2022 13:11:40 -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 26F70100C694; Wed, 12 Jan 2022 18:11:34 +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 03C197DE58; Wed, 12 Jan 2022 18:11:34 +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 C3ADC4A707; Wed, 12 Jan 2022 18:11:33 +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 20CIAddK003099 for ; Wed, 12 Jan 2022 13:10:39 -0500 Received: by smtp.corp.redhat.com (Postfix) id CF0E38CB1D; Wed, 12 Jan 2022 18:10:39 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.34]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2CCD08AD18 for ; Wed, 12 Jan 2022 18:10:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1642011104; 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=repU4Y2Ph3VqQpzWHz3+KrxSjR7i2SgTKeMm70soThg=; b=TjRKViDp5Xy3lhMmRtc34RSVz/lcZSBkKRlMY/WwyxzPN+Y6C9/X1GYXDzehYXzDfG/6LA WHUN2Ttj5WfKOpDxbYyRsu0b3hI/+85t3YtZ/haN9rhFId240ilsRkngSvk4fEIzFmI/E/ GCCUdHkmkSdJvW1ut8S6RxtHpKK8wjk= X-MC-Unique: UNf5OHM2NZeF4xl7AM-61w-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 10/17] virDomainSnapshotRedefinePrep: Use 'snapdef' for snapshot definition object Date: Wed, 12 Jan 2022 19:10:10 +0100 Message-Id: <8e5fed03c4225c614538b275a379f1406fc8d6b6.1642010887.git.pkrempa@redhat.com> In-Reply-To: References: 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.16 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: 1642011106287100001 Content-Type: text/plain; charset="utf-8" We use this variable name to distinguish it from the domain definition. Signed-off-by: Peter Krempa --- src/conf/snapshot_conf.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/conf/snapshot_conf.c b/src/conf/snapshot_conf.c index 1d61f93b65..4d2cfae128 100644 --- a/src/conf/snapshot_conf.c +++ b/src/conf/snapshot_conf.c @@ -980,23 +980,23 @@ virDomainSnapshotRedefinePrep(virDomainObj *vm, virDomainXMLOption *xmlopt, unsigned int flags) { - virDomainSnapshotDef *def =3D *defptr; + virDomainSnapshotDef *snapdef =3D *defptr; virDomainMomentObj *other; virDomainSnapshotDef *otherdef =3D NULL; bool check_if_stolen; - if (virDomainSnapshotCheckCycles(vm->snapshots, def, vm->def->name) < = 0) + if (virDomainSnapshotCheckCycles(vm->snapshots, snapdef, vm->def->name= ) < 0) return -1; - other =3D virDomainSnapshotFindByName(vm->snapshots, def->parent.name); + other =3D virDomainSnapshotFindByName(vm->snapshots, snapdef->parent.n= ame); if (other) otherdef =3D virDomainSnapshotObjGetDef(other); check_if_stolen =3D other && otherdef->parent.dom; - if (virDomainSnapshotRedefineValidate(def, vm->def->uuid, other, xmlop= t, + if (virDomainSnapshotRedefineValidate(snapdef, vm->def->uuid, other, x= mlopt, flags) < 0) { /* revert any stealing of the snapshot domain definition */ - if (check_if_stolen && def->parent.dom && !otherdef->parent.dom) - otherdef->parent.dom =3D g_steal_pointer(&def->parent.dom); + if (check_if_stolen && snapdef->parent.dom && !otherdef->parent.do= m) + otherdef->parent.dom =3D g_steal_pointer(&snapdef->parent.dom); return -1; } if (other) { --=20 2.31.1 From nobody Fri Apr 19 08:26:05 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=1642011094; cv=none; d=zohomail.com; s=zohoarc; b=cK6anCjr8p51SR3/QUyWgkhx0Xz6JFMcyf91tM/LKopbfqjO57n4MoMr0U2Mzv/KauR9f+Wmqy3BZUU+2wRFs+WBBrKyvH00AXxTpWGG/q5hfrcoruczl6mfMHn0F5+p50rIhvDiJWYXKWx7Ook2K6XFxwTOhG6T7ZSGvYxDsR0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1642011094; 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=EyhqNP4kz/9ot7zQCTYTWgXL3HYwEy4lt0l2cQE5LYA=; b=VTrwW7cwWzeNs04wIxft2KWqn4gtFoVw4l4TU7jMIGPZs7bdqAPcBUhWaxMZPPh7lIFqAWvXwgEIWuE9709rIfeLCYSFCilf4OooyN/TaPMPtu1RsA51N7FlOEnZHul8gqoV3ZlmAa80J/hgpPhbHtE+2RbdKYOR05P5p/qgK/M= 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 1642011094322880.0426022196805; Wed, 12 Jan 2022 10:11:34 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-650-L8gsn0csM1q_OnnQL0ZR3Q-1; Wed, 12 Jan 2022 13:11:31 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id ACB4183DD30; Wed, 12 Jan 2022 18:11:23 +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 828081091EDA; Wed, 12 Jan 2022 18:11:23 +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 3E917180BADA; Wed, 12 Jan 2022 18:11:23 +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 20CIAe3E003107 for ; Wed, 12 Jan 2022 13:10:40 -0500 Received: by smtp.corp.redhat.com (Postfix) id E93BF8CB1D; Wed, 12 Jan 2022 18:10:40 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.34]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4750A8AD18 for ; Wed, 12 Jan 2022 18:10:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1642011093; 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=EyhqNP4kz/9ot7zQCTYTWgXL3HYwEy4lt0l2cQE5LYA=; b=AAxElXZSf7RKVShWKCKZbzH35IixBG2QW8kQjMFFQ4s3hFqB7JiZHx5XKaWC3BTaY5PUnt +w19Vy1QPhoqDEGaCcsSspLn6X9vVUDM5TgITiXwC0aOfH85+UtqWJmOMM/RudO0zogFuT d3QH6xKztqSGK0A6pAi3rRsE9sANAxA= X-MC-Unique: L8gsn0csM1q_OnnQL0ZR3Q-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 11/17] virDomainSnapshotRedefineValidate: Don't modify the snapshot definition Date: Wed, 12 Jan 2022 19:10:11 +0100 Message-Id: <114eac9bd36fb3c985df70e22d33567d6e8bdec2.1642010887.git.pkrempa@redhat.com> In-Reply-To: References: 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.84 on 10.5.11.22 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: 1642011096152100002 Content-Type: text/plain; charset="utf-8" It is not expected that a function with 'Validate' in the name actually modifies the validated object, even worse when it even modifies another object and the ultimatively worst bit is that it doesn't undo the mess if the validation fails midway. Move the stealing of the domain definition from the definition of a snapshot being redefined into the caller along with the call to virDomainSnapshotAlignDisks. Signed-off-by: Peter Krempa --- src/conf/snapshot_conf.c | 56 +++++++++++++++++----------------------- 1 file changed, 24 insertions(+), 32 deletions(-) diff --git a/src/conf/snapshot_conf.c b/src/conf/snapshot_conf.c index 4d2cfae128..499fc5ad97 100644 --- a/src/conf/snapshot_conf.c +++ b/src/conf/snapshot_conf.c @@ -463,9 +463,7 @@ virDomainSnapshotDefParseString(const char *xmlStr, } -/* Perform sanity checking on a redefined snapshot definition. If - * @other is non-NULL, this may include swapping def->parent.dom from other - * into def. */ +/* Perform sanity checking on a redefined snapshot definition. */ static int virDomainSnapshotRedefineValidate(virDomainSnapshotDef *def, const unsigned char *domain_uuid, @@ -473,10 +471,6 @@ virDomainSnapshotRedefineValidate(virDomainSnapshotDef= *def, virDomainXMLOption *xmlopt, unsigned int flags) { - virDomainSnapshotLocation align_location =3D VIR_DOMAIN_SNAPSHOT_LOCAT= ION_INTERNAL; - bool external =3D def->state =3D=3D VIR_DOMAIN_SNAPSHOT_DISK_SNAPSHOT = || - virDomainSnapshotDefIsExternal(def); - if ((flags & VIR_DOMAIN_SNAPSHOT_CREATE_DISK_ONLY) && def->state !=3D VIR_DOMAIN_SNAPSHOT_DISK_SNAPSHOT) { virReportError(VIR_ERR_INVALID_ARG, @@ -524,22 +518,10 @@ virDomainSnapshotRedefineValidate(virDomainSnapshotDe= f *def, if (!virDomainDefCheckABIStability(otherdef->parent.dom, def->parent.dom, xmlopt= )) return -1; - } else { - /* Transfer the domain def */ - def->parent.dom =3D g_steal_pointer(&otherdef->parent.dom); } } } - if (def->parent.dom) { - if (external) - align_location =3D VIR_DOMAIN_SNAPSHOT_LOCATION_EXTERNAL; - - if (virDomainSnapshotAlignDisks(def, NULL, align_location, true) <= 0) - return -1; - } - - return 0; } @@ -982,28 +964,38 @@ virDomainSnapshotRedefinePrep(virDomainObj *vm, { virDomainSnapshotDef *snapdef =3D *defptr; virDomainMomentObj *other; - virDomainSnapshotDef *otherdef =3D NULL; - bool check_if_stolen; + virDomainSnapshotDef *otherSnapDef =3D NULL; + virDomainDef *otherDomDef =3D NULL; + virDomainSnapshotLocation align_location =3D VIR_DOMAIN_SNAPSHOT_LOCAT= ION_INTERNAL; if (virDomainSnapshotCheckCycles(vm->snapshots, snapdef, vm->def->name= ) < 0) return -1; - other =3D virDomainSnapshotFindByName(vm->snapshots, snapdef->parent.n= ame); - if (other) - otherdef =3D virDomainSnapshotObjGetDef(other); - check_if_stolen =3D other && otherdef->parent.dom; - if (virDomainSnapshotRedefineValidate(snapdef, vm->def->uuid, other, x= mlopt, - flags) < 0) { - /* revert any stealing of the snapshot domain definition */ - if (check_if_stolen && snapdef->parent.dom && !otherdef->parent.do= m) - otherdef->parent.dom =3D g_steal_pointer(&snapdef->parent.dom); - return -1; + if ((other =3D virDomainSnapshotFindByName(vm->snapshots, snapdef->par= ent.name))) { + otherSnapDef =3D virDomainSnapshotObjGetDef(other); + otherDomDef =3D otherSnapDef->parent.dom; } + + if (virDomainSnapshotRedefineValidate(snapdef, vm->def->uuid, other, x= mlopt, flags) < 0) + return -1; + + if (snapdef->state =3D=3D VIR_DOMAIN_SNAPSHOT_DISK_SNAPSHOT || + virDomainSnapshotDefIsExternal(snapdef)) + align_location =3D VIR_DOMAIN_SNAPSHOT_LOCATION_EXTERNAL; + + if (virDomainSnapshotAlignDisks(snapdef, otherDomDef, align_location, = true) < 0) + return -1; + if (other) { + /* steal the domain definition if redefining an existing snapshot = which + * with a snapshot definition lacking the domain definition */ + if (!snapdef->parent.dom) + snapdef->parent.dom =3D g_steal_pointer(&otherSnapDef->parent.= dom); + /* Drop and rebuild the parent relationship, but keep all * child relations by reusing snap. */ virDomainMomentDropParent(other); - virObjectUnref(otherdef); + virObjectUnref(otherSnapDef); other->def =3D &(*defptr)->parent; *defptr =3D NULL; *snap =3D other; --=20 2.31.1 From nobody Fri Apr 19 08:26:05 2024 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=1642011108; cv=none; d=zohomail.com; s=zohoarc; b=QCAFIhhsJLG6xdmGzrMV+tSGrQZH7sh/6PkU/uI0RtX9ED7AqFOFO8842mduEPhai40zWo+gDxgBcmhFYvw/kgzzNnooeb+V8F+e1NTEfPMuomfqS1iacUMZKhEXYEz7XZ7mUZEa/YRmYkzgExqot0NcMSGTk+naW99HzEtpv0E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1642011108; 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=PGrFiuWjlOM9VY6u2b0t3fdn8Lkb4g0/lHmNVtNNKVE=; b=CJlMOgZY0/3M/CzhuBIcPodU3NHAl0EAAfcyw+nyie0zJQw91SrVFQhijYhtROCswaXLYal+GXLIJP3UYb1q7mxVZp6NCdePhZjXMcr2WjfVkb/caVXy+9AC9aWnvjYwijx2uMWyauWXnZtoxm00Q4/j0+CM7RUIKRjSf6YLRWc= 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 1642011108710275.32734254604316; Wed, 12 Jan 2022 10:11:48 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-467-3jyPfQX1OiKQaxUw7hM29g-1; Wed, 12 Jan 2022 13:11:44 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 566A8100C66A; Wed, 12 Jan 2022 18:11:37 +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 383EB105C89D; Wed, 12 Jan 2022 18:11:37 +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 0725E1806D2D; Wed, 12 Jan 2022 18:11:37 +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 20CIAgmD003124 for ; Wed, 12 Jan 2022 13:10:42 -0500 Received: by smtp.corp.redhat.com (Postfix) id 179E18AD18; Wed, 12 Jan 2022 18:10:42 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.34]) by smtp.corp.redhat.com (Postfix) with ESMTP id 579EA8CB25 for ; Wed, 12 Jan 2022 18:10:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1642011107; 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=PGrFiuWjlOM9VY6u2b0t3fdn8Lkb4g0/lHmNVtNNKVE=; b=R+13P8ALcp9U7lcO2PcsRNG/DRwlYwEtO43igeHJrI+D8u5YKeN7IvZX9NkF/Kwtmcz6YK xrIABpDO7DEyWybV/EyaPzXrabRePvAyVn4VVqBGfqh4tjdH+WPP+vWcS9GDIO85Taod9W Frh44kvfDJMRjaOQ+3PDQqHw/M5vNGw= X-MC-Unique: 3jyPfQX1OiKQaxUw7hM29g-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 12/17] testDomainSnapshotCreateXML: Extract snapshot redefinition code Date: Wed, 12 Jan 2022 19:10:12 +0100 Message-Id: In-Reply-To: References: 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.84 on 10.5.11.22 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: 1642011110984100001 Content-Type: text/plain; charset="utf-8" The test driver code was copied from qemu but wasn't refactored recently. Split out the redefinition code similarly to what qemu driver did. Signed-off-by: Peter Krempa --- src/test/test_driver.c | 76 +++++++++++++++++++++++++++--------------- 1 file changed, 49 insertions(+), 27 deletions(-) diff --git a/src/test/test_driver.c b/src/test/test_driver.c index dde7bf1b8e..e772b2be2b 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -8739,6 +8739,33 @@ testDomainSnapshotAlignDisks(virDomainObj *vm, return virDomainSnapshotAlignDisks(def, NULL, align_location, true); } + +static virDomainSnapshotPtr +testDomainSnapshotRedefine(virDomainObj *vm, + virDomainPtr domain, + virDomainSnapshotDef *snapdeftmp, + virDomainMomentObj **snapout, + virDomainXMLOption *xmlopt, + unsigned int flags) +{ + virDomainMomentObj *snap =3D NULL; + g_autoptr(virDomainSnapshotDef) snapdef =3D virObjectRef(snapdeftmp); + + if (virDomainSnapshotRedefinePrep(vm, &snapdef, &snap, xmlopt, flags) = < 0) + return NULL; + + if (!snap) { + if (!(snap =3D virDomainSnapshotAssignDef(vm->snapshots, snapdef))) + return NULL; + snapdef =3D NULL; + } + + *snapout =3D snap; + + return virGetDomainSnapshot(domain, snap->def->name); +} + + static virDomainSnapshotPtr testDomainSnapshotCreateXML(virDomainPtr domain, const char *xmlDesc, @@ -8805,37 +8832,32 @@ testDomainSnapshotCreateXML(virDomainPtr domain, goto cleanup; if (redefine) { - if (virDomainSnapshotRedefinePrep(vm, &def, &snap, - privconn->xmlopt, - flags) < 0) - goto cleanup; - } else { - if (!(def->parent.dom =3D virDomainDefCopy(vm->def, - privconn->xmlopt, - NULL, - true))) - goto cleanup; - - if (testDomainSnapshotAlignDisks(vm, def, flags) < 0) - goto cleanup; + snapshot =3D testDomainSnapshotRedefine(vm, domain, def, &snap, + privconn->xmlopt, flags); + goto cleanup; } - if (!snap) { - if (!(snap =3D virDomainSnapshotAssignDef(vm->snapshots, def))) - goto cleanup; - def =3D NULL; - } + if (!(def->parent.dom =3D virDomainDefCopy(vm->def, + privconn->xmlopt, + NULL, + true))) + goto cleanup; - if (!redefine) { - snap->def->parent_name =3D g_strdup(virDomainSnapshotGetCurrentNam= e(vm->snapshots)); + if (testDomainSnapshotAlignDisks(vm, def, flags) < 0) + goto cleanup; - if ((flags & VIR_DOMAIN_SNAPSHOT_CREATE_HALT) && - virDomainObjIsActive(vm)) { - testDomainShutdownState(domain, vm, - VIR_DOMAIN_SHUTOFF_FROM_SNAPSHOT); - event =3D virDomainEventLifecycleNewFromObj(vm, VIR_DOMAIN_EVE= NT_STOPPED, - VIR_DOMAIN_EVENT_STOPPED_FROM_SNAPSHOT= ); - } + if (!(snap =3D virDomainSnapshotAssignDef(vm->snapshots, def))) + goto cleanup; + def =3D NULL; + + snap->def->parent_name =3D g_strdup(virDomainSnapshotGetCurrentName(vm= ->snapshots)); + + if ((flags & VIR_DOMAIN_SNAPSHOT_CREATE_HALT) && + virDomainObjIsActive(vm)) { + testDomainShutdownState(domain, vm, + VIR_DOMAIN_SHUTOFF_FROM_SNAPSHOT); + event =3D virDomainEventLifecycleNewFromObj(vm, VIR_DOMAIN_EVENT_S= TOPPED, + VIR_DOMAIN_EVENT_STOPPED= _FROM_SNAPSHOT); } snapshot =3D virGetDomainSnapshot(domain, snap->def->name); --=20 2.31.1 From nobody Fri Apr 19 08:26:05 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=1642011094; cv=none; d=zohomail.com; s=zohoarc; b=beDNlbBuc5Qaed1tUtUF5juvWSLTVJ2HB+1JZFOehMiWs4MdFs0xpa4s1LyxmIrjFJy/7iUav8//XfDnNhGwp4EO7QrB67HUihXFveRtiU4MsG4g/hCyeFHylQhAtt3g8YivGuZL1wCa7wcESU9pOlHVb7q0yRi6ch+ey7dLjCo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1642011094; 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=gWYISFxSyydrpcjaqCYDIV+2dQtXbKt1dxK4Lux/GFw=; b=kniqvgrZgNYn/0h19tt5ftJQqhNvALsgwjSOQOnPmnalE8Fb0cJAPheLJh8XGLVAjqBN0I5uICD0ztoCm1paJv++E4W8+gjh9eiX6Kq7VKCvDDqONXiA8y2XAV46GAy+hcm7UfgGzV8PNjNL+/PWd1t14XCaOEL4hNJeRrzohN4= 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 164201109429935.9896599711559; Wed, 12 Jan 2022 10:11:34 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-330-FH__qxQ7MVab9bK87hI3ZQ-1; Wed, 12 Jan 2022 13:11:32 -0500 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 B87BF100C66D; Wed, 12 Jan 2022 18:11:26 +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 5229A77C86; Wed, 12 Jan 2022 18:11:26 +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 22AB51806D2D; Wed, 12 Jan 2022 18:11:26 +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 20CIAm8G003146 for ; Wed, 12 Jan 2022 13:10:48 -0500 Received: by smtp.corp.redhat.com (Postfix) id D66638AC23; Wed, 12 Jan 2022 18:10:48 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.34]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3FEFB8AC21 for ; Wed, 12 Jan 2022 18:10:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1642011093; 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=gWYISFxSyydrpcjaqCYDIV+2dQtXbKt1dxK4Lux/GFw=; b=dPv6K1KknBJV9yO6DNrZj3caC6szOnaweX8CSbAVcKC8c5hBOKTBxX2Ly81Qje1kxPF4Ck WM00z1eYoqhHYX6GEsES9FvwIX4HJeW8vK7AXOsQjT+NHq0y/S8WTYMIvDhijq0/iEZQnJ RO9IA15HDxqvimhWKkCpKJGlmlPDTJA= X-MC-Unique: FH__qxQ7MVab9bK87hI3ZQ-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 13/17] qemuSnapshotCreate: Use 'snapdef' instead of 'def' Date: Wed, 12 Jan 2022 19:10:13 +0100 Message-Id: <4d4aefcf4134526db3134f2c5dae129fd49b5b8d.1642010887.git.pkrempa@redhat.com> In-Reply-To: References: 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.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) X-ZM-MESSAGEID: 1642011096108100001 Content-Type: text/plain; charset="utf-8" 'def' is commonly used for domain definition. Signed-off-by: Peter Krempa --- src/qemu/qemu_snapshot.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/qemu/qemu_snapshot.c b/src/qemu/qemu_snapshot.c index 797972f4d4..5f256a77df 100644 --- a/src/qemu/qemu_snapshot.c +++ b/src/qemu/qemu_snapshot.c @@ -1750,7 +1750,7 @@ qemuSnapshotRedefine(virDomainObj *vm, static virDomainSnapshotPtr qemuSnapshotCreate(virDomainObj *vm, virDomainPtr domain, - virDomainSnapshotDef *def, + virDomainSnapshotDef *snapdef, virQEMUDriver *driver, virQEMUDriverConfig *cfg, unsigned int flags) @@ -1760,17 +1760,17 @@ qemuSnapshotCreate(virDomainObj *vm, virDomainMomentObj *current =3D NULL; virDomainSnapshotPtr ret =3D NULL; - if (qemuSnapshotCreateAlignDisks(vm, def, driver, flags) < 0) + if (qemuSnapshotCreateAlignDisks(vm, snapdef, driver, flags) < 0) return NULL; - if (qemuSnapshotPrepare(vm, def, &flags) < 0) + if (qemuSnapshotPrepare(vm, snapdef, &flags) < 0) return NULL; if (flags & VIR_DOMAIN_SNAPSHOT_CREATE_NO_METADATA) { snap =3D tmpsnap =3D virDomainMomentObjNew(); - snap->def =3D &def->parent; + snap->def =3D &snapdef->parent; } else { - if (!(snap =3D virDomainSnapshotAssignDef(vm->snapshots, def))) + if (!(snap =3D virDomainSnapshotAssignDef(vm->snapshots, snapdef))) return NULL; if ((current =3D virDomainSnapshotGetCurrent(vm->snapshots))) { @@ -1778,7 +1778,7 @@ qemuSnapshotCreate(virDomainObj *vm, } } - virObjectRef(def); + virObjectRef(snapdef); /* actually do the snapshot */ if (virDomainObjIsActive(vm)) { --=20 2.31.1 From nobody Fri Apr 19 08:26:05 2024 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=1642011135; cv=none; d=zohomail.com; s=zohoarc; b=fsZ4edqSfqq3Xk3Wu0xUILfsKqBIX4xUz4GQOfT6RfYtZItVFcZDEy8hyWPvOxxfTNmLTTMH19FKyjflWkyxdPpTR9JT1EjD390RaL8nawVrGUNsRnb0Z2F12LfeA42YnZPDX92EBNqjSMYxfPtMgRBZh4/LGBJiLA2ESkiJNTI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1642011135; 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=PkKpzomalVkKcOQX2PEyjb7PgEFAOzg9VIBty6RVz7c=; b=POlMlUYa9lsa5EHiLrhZx2o50W5DMdtXioSW5PG9L2Fj4HJfS1qw6fsLL6RXIU1gk6nnhR2a6N9y5VmgrDdqMbEGRvbz5THGWn6jWMV1UehpUBqkrtj0pQ+PFYvZK7JBRtINSs6f1l29SpWfqONSbv6TAR4j0ZT1gdV1reh/TUQ= 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 164201113569257.978624826018745; Wed, 12 Jan 2022 10:12:15 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-208-xkTMSIHANPGdJbTMW9XJoA-1; Wed, 12 Jan 2022 13:11:36 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B9EC687499B; Wed, 12 Jan 2022 18:11:30 +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 8CD7D1091EDC; Wed, 12 Jan 2022 18:11:30 +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 4DB831806D2D; Wed, 12 Jan 2022 18:11:30 +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 20CIAnDi003156 for ; Wed, 12 Jan 2022 13:10:49 -0500 Received: by smtp.corp.redhat.com (Postfix) id E62378AC21; Wed, 12 Jan 2022 18:10:49 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.34]) by smtp.corp.redhat.com (Postfix) with ESMTP id 43F658AD18 for ; Wed, 12 Jan 2022 18:10:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1642011134; 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=PkKpzomalVkKcOQX2PEyjb7PgEFAOzg9VIBty6RVz7c=; b=S8NpCK5m8UBv0piHyB7S3os4UhXdvWtlHT3UlUcNpw7oANnuXXaP+k2htenKLY45i5eT2t p+39csO9niR59n0Zn5uTwuXbgexjAtoT8qBhLyq/QTlZwNRru9V6apr15hr9z6fPUEf76V YHmNZ8afW1hD8FSH3Qig7gwd3+nGtoU= X-MC-Unique: xkTMSIHANPGdJbTMW9XJoA-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 14/17] qemuSnapshotCreate: Standardize handling of the reference on @snapdef Date: Wed, 12 Jan 2022 19:10:14 +0100 Message-Id: In-Reply-To: References: 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.84 on 10.5.11.22 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: 1642011136238100001 Content-Type: text/plain; charset="utf-8" As with qemuSnapshotRedefine, make an extra reference in a temporary autocleaned variable and use that instead of refing the definition after it's stolen. Signed-off-by: Peter Krempa --- src/qemu/qemu_snapshot.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/qemu/qemu_snapshot.c b/src/qemu/qemu_snapshot.c index 5f256a77df..c5379d583e 100644 --- a/src/qemu/qemu_snapshot.c +++ b/src/qemu/qemu_snapshot.c @@ -1750,11 +1750,12 @@ qemuSnapshotRedefine(virDomainObj *vm, static virDomainSnapshotPtr qemuSnapshotCreate(virDomainObj *vm, virDomainPtr domain, - virDomainSnapshotDef *snapdef, + virDomainSnapshotDef *snapdeftmp, virQEMUDriver *driver, virQEMUDriverConfig *cfg, unsigned int flags) { + g_autoptr(virDomainSnapshotDef) snapdef =3D virObjectRef(snapdeftmp); g_autoptr(virDomainMomentObj) tmpsnap =3D NULL; virDomainMomentObj *snap =3D NULL; virDomainMomentObj *current =3D NULL; @@ -1769,17 +1770,17 @@ qemuSnapshotCreate(virDomainObj *vm, if (flags & VIR_DOMAIN_SNAPSHOT_CREATE_NO_METADATA) { snap =3D tmpsnap =3D virDomainMomentObjNew(); snap->def =3D &snapdef->parent; + snapdef =3D NULL; } else { if (!(snap =3D virDomainSnapshotAssignDef(vm->snapshots, snapdef))) return NULL; + snapdef =3D NULL; if ((current =3D virDomainSnapshotGetCurrent(vm->snapshots))) { snap->def->parent_name =3D g_strdup(current->def->name); } } - virObjectRef(snapdef); - /* actually do the snapshot */ if (virDomainObjIsActive(vm)) { if (flags & VIR_DOMAIN_SNAPSHOT_CREATE_DISK_ONLY || --=20 2.31.1 From nobody Fri Apr 19 08:26:05 2024 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=1642011073; cv=none; d=zohomail.com; s=zohoarc; b=fFIIOgNEGU+p3i8whIjRNOjSX59UYuktGF+aN7T4iHDswy3TjOUH4fBCAH7HCKBpBxez2vAcYmTd5cl2wq3+cR9hg4MswMoJHCY93xG7ekvDhHbkHVW7wOD4BZwcTCs1U8fVwI1FW1D1P/5Zm3kdPuwbM+1mK+KHFbUyW564me8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1642011073; 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=VMVHTJjmExJkak2/87RrbMZPKSvadRsQ2gCNWfX99Hw=; b=hCqEeUjUo1SAtKPYeWveXUQd0hB8IAhYwKJNMBTmFesskyhvgtMUZ4RmhGTH6e4E5HLjwd+/vLtr04OqjtACRywdM/M/asPOZ46yO8orBJHCkGa8+okdlmqBgWjcYV+7V+I9SEcezpRVYQFTHYEWdHp1Um/tD0MhmTodMwvE4I4= 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 1642011073432864.8688921630079; Wed, 12 Jan 2022 10:11:13 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-633-7M_yw_JTPBenhRoaSh7CBg-1; Wed, 12 Jan 2022 13:10:59 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 75DF29251F; Wed, 12 Jan 2022 18:10:53 +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 50C7E7E64F; Wed, 12 Jan 2022 18:10:53 +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 16FDA4BB7C; Wed, 12 Jan 2022 18:10:53 +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 20CIAoU3003166 for ; Wed, 12 Jan 2022 13:10:51 -0500 Received: by smtp.corp.redhat.com (Postfix) id EE6B08AC23; Wed, 12 Jan 2022 18:10:50 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.34]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5CD3D8AC21 for ; Wed, 12 Jan 2022 18:10:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1642011069; 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=VMVHTJjmExJkak2/87RrbMZPKSvadRsQ2gCNWfX99Hw=; b=Mz0UtA+Saa1mRnZ40TnhMlDfVKs+sGMGtaWhHUw1K4gwIhBJ/qTYxulFHJYqhddcKeerHl J5LoM9N5l+CbmasL5+ZHtNPW18oMkaEfJNqh+KbcoRbLh3UF4M2pN8fHDSmchQGvv8rabl Cuy0sI37VMcrHIpRGcr5P8svgbcEUi0= X-MC-Unique: 7M_yw_JTPBenhRoaSh7CBg-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 15/17] qemuDomainSnapshotLoad: Refactor handling of snapshot definition object Date: Wed, 12 Jan 2022 19:10:15 +0100 Message-Id: <9cfd151e312feffcbf3e13f9e3309587747b7b82.1642010887.git.pkrempa@redhat.com> In-Reply-To: References: 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.11 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: 1642011075385100001 Content-Type: text/plain; charset="utf-8" Move the variable holding the snapshot definition into the loop and use automatic clearing for it. Adjust the code for parity. Note that the clearing of 'snapdef' on success of 'virDomainSnapshotAssignDef' will be refactored in upcoming patches. Signed-off-by: Peter Krempa --- src/qemu/qemu_driver.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 65ac5ef367..b3588f9478 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -343,7 +343,6 @@ qemuDomainSnapshotLoad(virDomainObj *vm, g_autofree char *snapDir =3D NULL; g_autoptr(DIR) dir =3D NULL; struct dirent *entry; - virDomainSnapshotDef *def =3D NULL; virDomainMomentObj *snap =3D NULL; virDomainMomentObj *current =3D NULL; bool cur; @@ -367,6 +366,7 @@ qemuDomainSnapshotLoad(virDomainObj *vm, goto cleanup; while ((direrr =3D virDirRead(dir, &entry, NULL)) > 0) { + g_autoptr(virDomainSnapshotDef) snapdef =3D NULL; g_autofree char *xmlStr =3D NULL; g_autofree char *fullpath =3D NULL; @@ -384,11 +384,11 @@ qemuDomainSnapshotLoad(virDomainObj *vm, continue; } - def =3D virDomainSnapshotDefParseString(xmlStr, - qemu_driver->xmlopt, - priv->qemuCaps, &cur, - flags); - if (def =3D=3D NULL) { + snapdef =3D virDomainSnapshotDefParseString(xmlStr, + qemu_driver->xmlopt, + priv->qemuCaps, &cur, + flags); + if (snapdef =3D=3D NULL) { /* Nothing we can do here, skip this one */ virReportError(VIR_ERR_INTERNAL_ERROR, _("Failed to parse snapshot XML from file '%s'"= ), @@ -396,10 +396,10 @@ qemuDomainSnapshotLoad(virDomainObj *vm, continue; } - snap =3D virDomainSnapshotAssignDef(vm->snapshots, def); - if (snap =3D=3D NULL) { - virObjectUnref(def); - } else if (cur) { + snap =3D virDomainSnapshotAssignDef(vm->snapshots, snapdef); + if (snap) + snapdef =3D NULL; + if (cur && snap) { if (current) virReportError(VIR_ERR_INTERNAL_ERROR, _("Too many snapshots claiming to be curren= t for domain %s"), --=20 2.31.1 From nobody Fri Apr 19 08:26:05 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=1642011064; cv=none; d=zohomail.com; s=zohoarc; b=PxFqkwLiS80qb7b4tY7ExlTBgD3mV18tMLNaX9aTqDIwNC2P1bLWtXWWso2l9MjLreSHZijVZ2JdWPhW9J7F9Bvu+h9/NqZ5k3TPTCyX+2FHQQmNovIVI5+X5sIfsmETH24UHdfREGXYn1AJs5z3kY2lxlxtaePa67ZkbiN/upk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1642011064; 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=s/71ZddneA6Nk/yZ+LPi8lLlQXFPuCtqhgknHN3SslM=; b=VB0MWLHQnWQLEF9N9SgDtp7LQUHTkQGEOM/UK8HwVUWD+JPO18CISniK5R3Uu00KuAZa/vz34HtvBVuvX1jgfzjh2LrjSY6dxTSXTWibtEJof6s6bZJcwXP6oEsDrr8K/yZSw0MdScPhxVKsW4ILiRodLPxGjcbO+Cnnmi+UHB0= 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 1642011064151391.8485050983794; Wed, 12 Jan 2022 10:11:04 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-88-o9QTtImVOGes_5CoCIyi-A-1; Wed, 12 Jan 2022 13:11:01 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 4A478100C618; Wed, 12 Jan 2022 18:10:56 +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 2AE42105C725; Wed, 12 Jan 2022 18:10:56 +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 ECB654A7C8; Wed, 12 Jan 2022 18:10:55 +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 20CIAqXc003184 for ; Wed, 12 Jan 2022 13:10:52 -0500 Received: by smtp.corp.redhat.com (Postfix) id 0C77D8AC23; Wed, 12 Jan 2022 18:10:52 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.34]) by smtp.corp.redhat.com (Postfix) with ESMTP id 633EF8AC21 for ; Wed, 12 Jan 2022 18:10:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1642011063; 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=s/71ZddneA6Nk/yZ+LPi8lLlQXFPuCtqhgknHN3SslM=; b=DMdRFcRWH3HsDIc4uhctTFPx/qaPNtOkbXzHqhNSxbW2c2VWG4NXevkHhq9Lf+4wKSj9O9 AbZ0xSY65P7JwR5BrwEJlaDltXyIFDGK0ea2nxMh5vgaRK8JfpRGQf+I9H3avuXuLx60G/ /+6BT/QgE0oue44L727YznZCinljMPU= X-MC-Unique: o9QTtImVOGes_5CoCIyi-A-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 16/17] virDomainSnapshotAssignDef: Clear second argument when it is consumed Date: Wed, 12 Jan 2022 19:10:16 +0100 Message-Id: In-Reply-To: References: 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.84 on 10.5.11.22 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: 1642011065080100001 Content-Type: text/plain; charset="utf-8" Rather than callers second-guessing when the snapshot definition is assigned turn it into a double pointer and clear it on success. Fix callers to work with the new semantics. Signed-off-by: Peter Krempa --- src/conf/virdomainsnapshotobjlist.c | 10 ++++++++-- src/conf/virdomainsnapshotobjlist.h | 2 +- src/qemu/qemu_driver.c | 4 +--- src/qemu/qemu_snapshot.c | 6 ++---- src/test/test_driver.c | 12 ++++-------- src/vz/vz_sdk.c | 3 +-- 6 files changed, 17 insertions(+), 20 deletions(-) diff --git a/src/conf/virdomainsnapshotobjlist.c b/src/conf/virdomainsnapsh= otobjlist.c index 0ccdf31ae0..6b074d5994 100644 --- a/src/conf/virdomainsnapshotobjlist.c +++ b/src/conf/virdomainsnapshotobjlist.c @@ -42,9 +42,15 @@ struct _virDomainSnapshotObjList { virDomainMomentObj * virDomainSnapshotAssignDef(virDomainSnapshotObjList *snapshots, - virDomainSnapshotDef *def) + virDomainSnapshotDef **snapdefptr) { - return virDomainMomentAssignDef(snapshots->base, &def->parent); + virDomainSnapshotDef *snapdef =3D *snapdefptr; + virDomainMomentObj *ret =3D virDomainMomentAssignDef(snapshots->base, = &snapdef->parent); + + if (ret) + *snapdefptr =3D NULL; + + return ret; } diff --git a/src/conf/virdomainsnapshotobjlist.h b/src/conf/virdomainsnapsh= otobjlist.h index eebeb9f5a3..bdbc17f6d5 100644 --- a/src/conf/virdomainsnapshotobjlist.h +++ b/src/conf/virdomainsnapshotobjlist.h @@ -30,7 +30,7 @@ virDomainSnapshotObjList *virDomainSnapshotObjListNew(voi= d); void virDomainSnapshotObjListFree(virDomainSnapshotObjList *snapshots); virDomainMomentObj *virDomainSnapshotAssignDef(virDomainSnapshotObjList *s= napshots, - virDomainSnapshotDef *def); + virDomainSnapshotDef **snap= defptr); int virDomainSnapshotObjListGetNames(virDomainSnapshotObjList *snapshots, virDomainMomentObj *from, diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index b3588f9478..e150b86cef 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -396,9 +396,7 @@ qemuDomainSnapshotLoad(virDomainObj *vm, continue; } - snap =3D virDomainSnapshotAssignDef(vm->snapshots, snapdef); - if (snap) - snapdef =3D NULL; + snap =3D virDomainSnapshotAssignDef(vm->snapshots, &snapdef); if (cur && snap) { if (current) virReportError(VIR_ERR_INTERNAL_ERROR, diff --git a/src/qemu/qemu_snapshot.c b/src/qemu/qemu_snapshot.c index c5379d583e..3e35ff5463 100644 --- a/src/qemu/qemu_snapshot.c +++ b/src/qemu/qemu_snapshot.c @@ -1721,9 +1721,8 @@ qemuSnapshotRedefine(virDomainObj *vm, return NULL; if (!snap) { - if (!(snap =3D virDomainSnapshotAssignDef(vm->snapshots, snapdef))) + if (!(snap =3D virDomainSnapshotAssignDef(vm->snapshots, &snapdef)= )) return NULL; - snapdef =3D NULL; } /* XXX Should we validate that the redefined snapshot even * makes sense, such as checking that qemu-img recognizes the @@ -1772,9 +1771,8 @@ qemuSnapshotCreate(virDomainObj *vm, snap->def =3D &snapdef->parent; snapdef =3D NULL; } else { - if (!(snap =3D virDomainSnapshotAssignDef(vm->snapshots, snapdef))) + if (!(snap =3D virDomainSnapshotAssignDef(vm->snapshots, &snapdef)= )) return NULL; - snapdef =3D NULL; if ((current =3D virDomainSnapshotGetCurrent(vm->snapshots))) { snap->def->parent_name =3D g_strdup(current->def->name); diff --git a/src/test/test_driver.c b/src/test/test_driver.c index e772b2be2b..14617d4f0d 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -968,7 +968,7 @@ testParseDomainSnapshots(testDriver *privconn, for (i =3D 0; i < nsdata->num_snap_nodes; i++) { virDomainMomentObj *snap; - virDomainSnapshotDef *def; + g_autoptr(virDomainSnapshotDef) def =3D NULL; xmlNodePtr node =3D testParseXMLDocFromFile(nodes[i], file, "domainsnapshot"); if (!node) @@ -984,10 +984,8 @@ testParseDomainSnapshots(testDriver *privconn, if (!def) return -1; - if (!(snap =3D virDomainSnapshotAssignDef(domobj->snapshots, def))= ) { - virObjectUnref(def); + if (!(snap =3D virDomainSnapshotAssignDef(domobj->snapshots, &def)= )) return -1; - } if (cur) { if (virDomainSnapshotGetCurrent(domobj->snapshots)) { @@ -8755,9 +8753,8 @@ testDomainSnapshotRedefine(virDomainObj *vm, return NULL; if (!snap) { - if (!(snap =3D virDomainSnapshotAssignDef(vm->snapshots, snapdef))) + if (!(snap =3D virDomainSnapshotAssignDef(vm->snapshots, &snapdef)= )) return NULL; - snapdef =3D NULL; } *snapout =3D snap; @@ -8846,9 +8843,8 @@ testDomainSnapshotCreateXML(virDomainPtr domain, if (testDomainSnapshotAlignDisks(vm, def, flags) < 0) goto cleanup; - if (!(snap =3D virDomainSnapshotAssignDef(vm->snapshots, def))) + if (!(snap =3D virDomainSnapshotAssignDef(vm->snapshots, &def))) goto cleanup; - def =3D NULL; snap->def->parent_name =3D g_strdup(virDomainSnapshotGetCurrentName(vm= ->snapshots)); diff --git a/src/vz/vz_sdk.c b/src/vz/vz_sdk.c index 5ed33902fd..94c6cd5c7a 100644 --- a/src/vz/vz_sdk.c +++ b/src/vz/vz_sdk.c @@ -4661,9 +4661,8 @@ prlsdkParseSnapshotTree(const char *treexml) } VIR_FREE(xmlstr); - if (!(snapshot =3D virDomainSnapshotAssignDef(snapshots, def))) + if (!(snapshot =3D virDomainSnapshotAssignDef(snapshots, &def))) goto cleanup; - def =3D NULL; xmlstr =3D virXPathString("string(./@current)", ctxt); if (xmlstr && STREQ("yes", xmlstr)) { --=20 2.31.1 From nobody Fri Apr 19 08:26:05 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=1642011110; cv=none; d=zohomail.com; s=zohoarc; b=JIOhs8uWRDqf4AyjSEW6Xs0gXvtuMq5tdIB5qnWjQkbxaG15mdhFd7H0IJO+iKfCQpr+zKqXapL5IJl7Kh1dAQz37LkdaOQO+7nk2CRGud0h2JChmCrUGzRCF67mev0j1Ks4+CqBSLLmzkyy2Z8MGulA+8Z1i7gDe/rfFmzD3Fk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1642011110; 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=9nH2PxvOrqIcUM2j1qfnN4PIprjY4zsKdZ8Uj29GB3Q=; b=cRwaD/bxU5dHHrC9Bob71MH96dj3s3K8YXkQCNpzZXIjq4kDgxrTKBV3vJ6x0wVtFOhUFI7qxZsQGllnceePhQcoNzay0X12nQ3WgLb1LKabNCS20P6FDDoA+luHBpjT2tkOxjj7yy9nHL49OwKoEvOAbCwSUdDj1/A29qrxxmA= 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 1642011110640968.2474954619743; Wed, 12 Jan 2022 10:11:50 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-628-M97KCdMrOeSS8GEJ6A_Dzw-1; Wed, 12 Jan 2022 13:11:46 -0500 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 D614C100C686; Wed, 12 Jan 2022 18:11:40 +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 B386577464; Wed, 12 Jan 2022 18:11:40 +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 7EAD44A707; Wed, 12 Jan 2022 18:11:40 +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 20CIArAx003196 for ; Wed, 12 Jan 2022 13:10:53 -0500 Received: by smtp.corp.redhat.com (Postfix) id 173838AC23; Wed, 12 Jan 2022 18:10:53 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.34]) by smtp.corp.redhat.com (Postfix) with ESMTP id 777538AC21 for ; Wed, 12 Jan 2022 18:10:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1642011109; 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=9nH2PxvOrqIcUM2j1qfnN4PIprjY4zsKdZ8Uj29GB3Q=; b=Mail0ITKI3PuNiVZrYiVSJNxURC63Qcw2QmoAobijIOcczWOKYg7cyLbv+2KABdBV+m2/j 8k+X53+cGBNK4rcblvYSMzZOkoiRD4bRLXmGZdTryr/HgM8xFGOmMh831Masj0eeul1rHy LMwCmaoss678JJqMZSYY5JkN1IVdJAY= X-MC-Unique: M97KCdMrOeSS8GEJ6A_Dzw-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 17/17] virDomainSnapshotRedefinePrep: Don't do partial redefine Date: Wed, 12 Jan 2022 19:10:17 +0100 Message-Id: In-Reply-To: References: 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.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) X-ZM-MESSAGEID: 1642011111468100003 Content-Type: text/plain; charset="utf-8" 'virDomainSnapshotRedefinePrep' does everything needed for a redefine when the snapshot exists but not when we are defining metadata for a new snapshot. This gives us weird semantics. Extract the code for replacing the definition of an existing snapshot into a new helper 'virDomainSnapshotReplaceDef' and refactor all callers. Signed-off-by: Peter Krempa --- src/conf/snapshot_conf.c | 20 +++----------------- src/conf/snapshot_conf.h | 2 +- src/conf/virdomainsnapshotobjlist.c | 19 +++++++++++++++++++ src/conf/virdomainsnapshotobjlist.h | 3 +++ src/libvirt_private.syms | 1 + src/qemu/qemu_snapshot.c | 9 +++++---- src/test/test_driver.c | 6 ++++-- 7 files changed, 36 insertions(+), 24 deletions(-) diff --git a/src/conf/snapshot_conf.c b/src/conf/snapshot_conf.c index 499fc5ad97..2d4c7190ba 100644 --- a/src/conf/snapshot_conf.c +++ b/src/conf/snapshot_conf.c @@ -957,12 +957,11 @@ virDomainSnapshotIsExternal(virDomainMomentObj *snap) int virDomainSnapshotRedefinePrep(virDomainObj *vm, - virDomainSnapshotDef **defptr, + virDomainSnapshotDef *snapdef, virDomainMomentObj **snap, virDomainXMLOption *xmlopt, unsigned int flags) { - virDomainSnapshotDef *snapdef =3D *defptr; virDomainMomentObj *other; virDomainSnapshotDef *otherSnapDef =3D NULL; virDomainDef *otherDomDef =3D NULL; @@ -976,6 +975,8 @@ virDomainSnapshotRedefinePrep(virDomainObj *vm, otherDomDef =3D otherSnapDef->parent.dom; } + *snap =3D other; + if (virDomainSnapshotRedefineValidate(snapdef, vm->def->uuid, other, x= mlopt, flags) < 0) return -1; @@ -986,20 +987,5 @@ virDomainSnapshotRedefinePrep(virDomainObj *vm, if (virDomainSnapshotAlignDisks(snapdef, otherDomDef, align_location, = true) < 0) return -1; - if (other) { - /* steal the domain definition if redefining an existing snapshot = which - * with a snapshot definition lacking the domain definition */ - if (!snapdef->parent.dom) - snapdef->parent.dom =3D g_steal_pointer(&otherSnapDef->parent.= dom); - - /* Drop and rebuild the parent relationship, but keep all - * child relations by reusing snap. */ - virDomainMomentDropParent(other); - virObjectUnref(otherSnapDef); - other->def =3D &(*defptr)->parent; - *defptr =3D NULL; - *snap =3D other; - } - return 0; } diff --git a/src/conf/snapshot_conf.h b/src/conf/snapshot_conf.h index b04163efae..c8997c710c 100644 --- a/src/conf/snapshot_conf.h +++ b/src/conf/snapshot_conf.h @@ -134,7 +134,7 @@ bool virDomainSnapshotDefIsExternal(virDomainSnapshotDe= f *def); bool virDomainSnapshotIsExternal(virDomainMomentObj *snap); int virDomainSnapshotRedefinePrep(virDomainObj *vm, - virDomainSnapshotDef **def, + virDomainSnapshotDef *snapdef, virDomainMomentObj **snap, virDomainXMLOption *xmlopt, unsigned int flags); diff --git a/src/conf/virdomainsnapshotobjlist.c b/src/conf/virdomainsnapsh= otobjlist.c index 6b074d5994..2520a4bca4 100644 --- a/src/conf/virdomainsnapshotobjlist.c +++ b/src/conf/virdomainsnapshotobjlist.c @@ -54,6 +54,25 @@ virDomainSnapshotAssignDef(virDomainSnapshotObjList *sna= pshots, } +void +virDomainSnapshotReplaceDef(virDomainMomentObj *snap, + virDomainSnapshotDef **snapdefptr) +{ + virDomainSnapshotDef *snapdef =3D *snapdefptr; + g_autoptr(virDomainSnapshotDef) origsnapdef =3D virDomainSnapshotObjGe= tDef(snap); + + /* steal the domain definition if redefining an existing snapshot which + * with a snapshot definition lacking the domain definition */ + if (!snapdef->parent.dom) + snapdef->parent.dom =3D g_steal_pointer(&origsnapdef->parent.dom); + + /* Drop and rebuild the parent relationship, but keep all child relati= ons by reusing snap. */ + virDomainMomentDropParent(snap); + snap->def =3D &snapdef->parent; + *snapdefptr =3D NULL; +} + + static bool virDomainSnapshotFilter(virDomainMomentObj *obj, unsigned int flags) diff --git a/src/conf/virdomainsnapshotobjlist.h b/src/conf/virdomainsnapsh= otobjlist.h index bdbc17f6d5..ce9d77e10b 100644 --- a/src/conf/virdomainsnapshotobjlist.h +++ b/src/conf/virdomainsnapshotobjlist.h @@ -32,6 +32,9 @@ void virDomainSnapshotObjListFree(virDomainSnapshotObjLis= t *snapshots); virDomainMomentObj *virDomainSnapshotAssignDef(virDomainSnapshotObjList *s= napshots, virDomainSnapshotDef **snap= defptr); +void virDomainSnapshotReplaceDef(virDomainMomentObj *snap, + virDomainSnapshotDef **snapdefptr); + int virDomainSnapshotObjListGetNames(virDomainSnapshotObjList *snapshots, virDomainMomentObj *from, char **const names, int maxnames, diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 5b76e66e61..f75dea36c4 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -1212,6 +1212,7 @@ virDomainSnapshotObjListNew; virDomainSnapshotObjListNum; virDomainSnapshotObjListRemove; virDomainSnapshotObjListRemoveAll; +virDomainSnapshotReplaceDef; virDomainSnapshotSetCurrent; virDomainSnapshotUpdateRelations; diff --git a/src/qemu/qemu_snapshot.c b/src/qemu/qemu_snapshot.c index 3e35ff5463..9cf185026c 100644 --- a/src/qemu/qemu_snapshot.c +++ b/src/qemu/qemu_snapshot.c @@ -1715,15 +1715,16 @@ qemuSnapshotRedefine(virDomainObj *vm, virDomainSnapshotPtr ret =3D NULL; g_autoptr(virDomainSnapshotDef) snapdef =3D virObjectRef(snapdeftmp); - if (virDomainSnapshotRedefinePrep(vm, &snapdef, &snap, - driver->xmlopt, - flags) < 0) + if (virDomainSnapshotRedefinePrep(vm, snapdef, &snap, driver->xmlopt, = flags) < 0) return NULL; - if (!snap) { + if (snap) { + virDomainSnapshotReplaceDef(snap, &snapdef); + } else { if (!(snap =3D virDomainSnapshotAssignDef(vm->snapshots, &snapdef)= )) return NULL; } + /* XXX Should we validate that the redefined snapshot even * makes sense, such as checking that qemu-img recognizes the * snapshot name in at least one of the domain's disks? */ diff --git a/src/test/test_driver.c b/src/test/test_driver.c index 14617d4f0d..1504334c30 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -8749,10 +8749,12 @@ testDomainSnapshotRedefine(virDomainObj *vm, virDomainMomentObj *snap =3D NULL; g_autoptr(virDomainSnapshotDef) snapdef =3D virObjectRef(snapdeftmp); - if (virDomainSnapshotRedefinePrep(vm, &snapdef, &snap, xmlopt, flags) = < 0) + if (virDomainSnapshotRedefinePrep(vm, snapdef, &snap, xmlopt, flags) <= 0) return NULL; - if (!snap) { + if (snap) { + virDomainSnapshotReplaceDef(snap, &snapdef); + } else { if (!(snap =3D virDomainSnapshotAssignDef(vm->snapshots, &snapdef)= )) return NULL; } --=20 2.31.1