From nobody Fri Apr 26 11:06:08 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=1641894817; cv=none; d=zohomail.com; s=zohoarc; b=WVmBRzu0TrQbwU5NPqzTP9hX9vnW5dty8PMu5DjrnY3ZG/67FgC+O4Dvf6DBqu7It1AA+cg59tgMr82UfDihiWnMN/7TUhyhOppCKTlhAl+om+QQE3J+Lu6yzbbRZKXPuLbLGMqXKOWhDlVDVazDdjwTtjo1P1SiC/mY4hs3TWI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1641894817; 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=LE1a7j+WxcmFEIujUT2J9+fRiFdPkcmvESRtvHOFMbE=; b=S1lRbUsbk9eBqlJtNeapddK6FC35g51dzk89j0clJj2WmgnB1snAje0kq+2IzG0yVSA2lTqwUDTh0ZHPQG3GHCa+nrC80E+ZAQmr3YFOaPwLwqhFZmmlSqr6XQkotTlyaBkwFFH24trNIeZfSnLOJAe9IN38yluWR8M5z3bKhME= 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 1641894817623263.3073279214997; Tue, 11 Jan 2022 01:53:37 -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-550-XwkO52PUPhScYyHzP3b69g-1; Tue, 11 Jan 2022 04:53:32 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E2BB418982A1; Tue, 11 Jan 2022 09:53:27 +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 BFC301F426; Tue, 11 Jan 2022 09:53:27 +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 743031809CBF; Tue, 11 Jan 2022 09:53:27 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 20B9rQjq002584 for ; Tue, 11 Jan 2022 04:53:26 -0500 Received: by smtp.corp.redhat.com (Postfix) id 0F3091059154; Tue, 11 Jan 2022 09:53:26 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.34]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4221F10550B1 for ; Tue, 11 Jan 2022 09:53:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1641894816; 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=LE1a7j+WxcmFEIujUT2J9+fRiFdPkcmvESRtvHOFMbE=; b=MdVr/PSz15NptdHrSp1OXORnZMBWEZa5FwkvS1bYPLapkvIb4H7PkZbfQMyD8KdJpevqsF pxRkEHSOIC0QCl5LaOB902H1S81zfa3zmhwUQ+LuhJHdpXdh8CZ1dvRw8YTwo+Won6pyOf 4wQuu7hrPvmIRFDBz3EeZyE0YSuxDp4= X-MC-Unique: XwkO52PUPhScYyHzP3b69g-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 1/3] virdomainmomentobjlist.h: Convert to modern header style Date: Tue, 11 Jan 2022 10:53:20 +0100 Message-Id: <01c9b4c0136f1b8dd01ed584b864b641de2dc927.1641894644.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 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.23 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: 1641894818979100003 Content-Type: text/plain; charset="utf-8" Format the function prototypes the same way as in the .c file. Signed-off-by: Peter Krempa Reviewed-by: Michal Privoznik --- src/conf/virdomainmomentobjlist.h | 113 ++++++++++++++++++------------ 1 file changed, 70 insertions(+), 43 deletions(-) diff --git a/src/conf/virdomainmomentobjlist.h b/src/conf/virdomainmomentob= jlist.h index dd8f798301..e42f9a7e9e 100644 --- a/src/conf/virdomainmomentobjlist.h +++ b/src/conf/virdomainmomentobjlist.h @@ -50,24 +50,33 @@ struct _virDomainMomentObj { virDomainMomentObj *first_child; /* NULL if no children */ }; -int virDomainMomentForEachChild(virDomainMomentObj *moment, - virHashIterator iter, - void *data); -int virDomainMomentForEachDescendant(virDomainMomentObj *moment, - virHashIterator iter, - void *data); -void virDomainMomentDropParent(virDomainMomentObj *moment); -void virDomainMomentDropChildren(virDomainMomentObj *moment); -void virDomainMomentMoveChildren(virDomainMomentObj *from, - virDomainMomentObj *to); -void virDomainMomentLinkParent(virDomainMomentObjList *moments, - virDomainMomentObj *moment); - -virDomainMomentObjList *virDomainMomentObjListNew(void); -void virDomainMomentObjListFree(virDomainMomentObjList *moments); - -virDomainMomentObj *virDomainMomentAssignDef(virDomainMomentObjList *momen= ts, - virDomainMomentDef *def); +int +virDomainMomentForEachChild(virDomainMomentObj *moment, + virHashIterator iter, + void *data); +int +virDomainMomentForEachDescendant(virDomainMomentObj *moment, + virHashIterator iter, + void *data); +void +virDomainMomentDropParent(virDomainMomentObj *moment); +void +virDomainMomentDropChildren(virDomainMomentObj *moment); +void +virDomainMomentMoveChildren(virDomainMomentObj *from, + virDomainMomentObj *to); +void +virDomainMomentLinkParent(virDomainMomentObjList *moments, + virDomainMomentObj *moment); + +virDomainMomentObjList * +virDomainMomentObjListNew(void); +void +virDomainMomentObjListFree(virDomainMomentObjList *moments); + +virDomainMomentObj * +virDomainMomentAssignDef(virDomainMomentObjList *moments, + virDomainMomentDef *def); /* Various enum bits that map to public API filters. Note that the * values of the internal bits are not the same as the public ones for @@ -97,28 +106,46 @@ typedef enum { VIR_DOMAIN_MOMENT_FILTERS_METADATA | \ VIR_DOMAIN_MOMENT_FILTERS_LEAVES) -int virDomainMomentObjListGetNames(virDomainMomentObjList *moments, - virDomainMomentObj *from, - char **const names, - int maxnames, - unsigned int moment_flags, - virDomainMomentObjListFilter filter, - unsigned int filter_flags); -virDomainMomentObj *virDomainMomentFindByName(virDomainMomentObjList *mome= nts, - const char *name); -int virDomainMomentObjListSize(virDomainMomentObjList *moments); -virDomainMomentObj *virDomainMomentGetCurrent(virDomainMomentObjList *mome= nts); -const char *virDomainMomentGetCurrentName(virDomainMomentObjList *moments); -void virDomainMomentSetCurrent(virDomainMomentObjList *moments, - virDomainMomentObj *moment); -bool virDomainMomentObjListRemove(virDomainMomentObjList *moments, - virDomainMomentObj *moment); -void virDomainMomentObjListRemoveAll(virDomainMomentObjList *moments); -int virDomainMomentForEach(virDomainMomentObjList *moments, - virHashIterator iter, - void *data); -int virDomainMomentUpdateRelations(virDomainMomentObjList *moments); -int virDomainMomentCheckCycles(virDomainMomentObjList *list, - virDomainMomentDef *def, - const char *domname); -virDomainMomentObj *virDomainMomentFindLeaf(virDomainMomentObjList *list); +int +virDomainMomentObjListGetNames(virDomainMomentObjList *moments, + virDomainMomentObj *from, + char **const names, + int maxnames, + unsigned int moment_flags, + virDomainMomentObjListFilter filter, + unsigned int filter_flags); +virDomainMomentObj * +virDomainMomentFindByName(virDomainMomentObjList *moments, + const char *name); +int +virDomainMomentObjListSize(virDomainMomentObjList *moments); + +virDomainMomentObj * +virDomainMomentGetCurrent(virDomainMomentObjList *moments); +const char * +virDomainMomentGetCurrentName(virDomainMomentObjList *moments); +void +virDomainMomentSetCurrent(virDomainMomentObjList *moments, + virDomainMomentObj *moment); + +bool +virDomainMomentObjListRemove(virDomainMomentObjList *moments, + virDomainMomentObj *moment); +void +virDomainMomentObjListRemoveAll(virDomainMomentObjList *moments); + +int +virDomainMomentForEach(virDomainMomentObjList *moments, + virHashIterator iter, + void *data); + +int +virDomainMomentUpdateRelations(virDomainMomentObjList *moments); + +int +virDomainMomentCheckCycles(virDomainMomentObjList *list, + virDomainMomentDef *def, + const char *domname); + +virDomainMomentObj * +virDomainMomentFindLeaf(virDomainMomentObjList *list); --=20 2.31.1 From nobody Fri Apr 26 11:06:08 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=1641894820; cv=none; d=zohomail.com; s=zohoarc; b=ZNtsbM+CWfuu/FPp01ywjZqo90OYhqMJoBhH75ZGv29oJHsnLQ8TsWE3zGkl04fXpCyB04NukZXA6qIFGFpmp12TqLVuke976rkM801/0VNyow90kMwo2rzfClJEBMmKgDE1MMewoyOksW8gA7J82htkXLFSLsH6Ait7qTOixV8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1641894820; 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=clvSosNCv8FTIv/wss4lIBl5Du0CYYbXDr0afo5MAgA=; b=L0oLP3V9gYmULg71zFAItHlHm1aZwlmS9gHwdSM2SbD6vu5A7Fspbw4p9/F8xVSwv/OpkRWPgi5/Nboi9MiRKfX6chxeAZQv5gCTZCYAg3gAOcdpI39rK7OP8VP/DQLqaZx7R6Ed5UYflV5CR/hH3BUznoBdMSWemBlrtvjUjzs= 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 1641894820887469.7432257973119; Tue, 11 Jan 2022 01:53:40 -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-316-o51FgEVINXKVAnHw1gf-xg-1; Tue, 11 Jan 2022 04:53:36 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 7A13D100CCDB; Tue, 11 Jan 2022 09:53: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 13FAA7E11D; Tue, 11 Jan 2022 09:53: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 C906B4A7C8; Tue, 11 Jan 2022 09:53:30 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 20B9rRjk002594 for ; Tue, 11 Jan 2022 04:53:27 -0500 Received: by smtp.corp.redhat.com (Postfix) id 1772410550B1; Tue, 11 Jan 2022 09:53:27 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.34]) by smtp.corp.redhat.com (Postfix) with ESMTP id 70A221059154 for ; Tue, 11 Jan 2022 09:53:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1641894819; 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=clvSosNCv8FTIv/wss4lIBl5Du0CYYbXDr0afo5MAgA=; b=GqPysyRNonwpiL64Uw57FyW7jSt9Q+ZHSEHMB+0QXNsKw/pdHTYNU+/G5K4PqHnhIo8G77 naFjf9N2LQjDKToMu89oqGENlFr+whPcyhhHg0xIRSog68ONRAqbeCxN/G0Qgn7VhndObz moQ+NI/wWt5Peh3VMjlGreeJfWr1vGI= X-MC-Unique: o51FgEVINXKVAnHw1gf-xg-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 2/3] conf: moment: Export helpers to create the virDomainMoment wrapper Date: Tue, 11 Jan 2022 10:53:21 +0100 Message-Id: <4cf97bc48bbf42fb0ecc2d1dd41e21278c0f365d.1641894644.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 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.12 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: 1641894821420100001 Content-Type: text/plain; charset="utf-8" Export 'virDomainMomentObjNew' and 'virDomainMomentObjFree' and define the latter as autoptr cleanup function for 'virDomainMomentObj'. Signed-off-by: Peter Krempa Reviewed-by: Michal Privoznik --- src/conf/virdomainmomentobjlist.c | 4 ++-- src/conf/virdomainmomentobjlist.h | 8 ++++++++ src/libvirt_private.syms | 2 ++ 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/conf/virdomainmomentobjlist.c b/src/conf/virdomainmomentob= jlist.c index 60f7eec106..8993c2310b 100644 --- a/src/conf/virdomainmomentobjlist.c +++ b/src/conf/virdomainmomentobjlist.c @@ -205,7 +205,7 @@ virDomainMomentMoveChildren(virDomainMomentObj *from, } -static virDomainMomentObj * +virDomainMomentObj * virDomainMomentObjNew(void) { virDomainMomentObj *moment; @@ -218,7 +218,7 @@ virDomainMomentObjNew(void) } -static void +void virDomainMomentObjFree(virDomainMomentObj *moment) { if (!moment) diff --git a/src/conf/virdomainmomentobjlist.h b/src/conf/virdomainmomentob= jlist.h index e42f9a7e9e..d2ab3b46b1 100644 --- a/src/conf/virdomainmomentobjlist.h +++ b/src/conf/virdomainmomentobjlist.h @@ -50,6 +50,14 @@ struct _virDomainMomentObj { virDomainMomentObj *first_child; /* NULL if no children */ }; +virDomainMomentObj * +virDomainMomentObjNew(void); + +void +virDomainMomentObjFree(virDomainMomentObj *moment); + +G_DEFINE_AUTOPTR_CLEANUP_FUNC(virDomainMomentObj, virDomainMomentObjFree); + int virDomainMomentForEachChild(virDomainMomentObj *moment, virHashIterator iter, diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index ee14b99d88..5b76e66e61 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -1175,6 +1175,8 @@ virDomainMomentDropParent; virDomainMomentForEachChild; virDomainMomentForEachDescendant; virDomainMomentMoveChildren; +virDomainMomentObjFree; +virDomainMomentObjNew; # conf/virdomainobjlist.h --=20 2.31.1 From nobody Fri Apr 26 11:06:08 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=1641894842; cv=none; d=zohomail.com; s=zohoarc; b=dm+xr4Shd6iHDXYj5+WRVecLxeXXPnLhYSnNetxoUx65j9i4uzUM2WHtCibo7jqtYG3QWBk9Lfo/s+fiTMlA9WkSubOEFa2nyYVrUDo+8QJG6aX9CrkiIUir1yDnJFY18Zf33NnnYuOR11DOJdI7WjOv9/K+M/mw5/6aw7qOE+8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1641894842; 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=EETsKaZYo4uIuFkK+u1l6LFFvp5RaARTEybZfBOEbt4=; b=lfnarRrfBlWO4lkoBHbAfpShJmYdM62LLy72NRbN3iNjDlkjYadnMvUKkTOXC7YvF5BMeOX+G1nrGUUCn6eq/A7ffmNA/FqrQ0Vj3Hj3JJUv2VBKWsTejt1VzdsfS+1vscyQVjbS3iV8fPZfNUtOCUgz9ethMah0PVHFA1kZsyQ= 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 1641894842460849.6068237018693; Tue, 11 Jan 2022 01:54:02 -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-564-zu7OmJZCPyeWTht71nDfPw-1; Tue, 11 Jan 2022 04:53:35 -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 25FF1871801; Tue, 11 Jan 2022 09:53: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 03D1A6F11C; Tue, 11 Jan 2022 09:53: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 C38C14CA9B; Tue, 11 Jan 2022 09:53:30 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 20B9rS1Q002602 for ; Tue, 11 Jan 2022 04:53:28 -0500 Received: by smtp.corp.redhat.com (Postfix) id 1A8E81059154; Tue, 11 Jan 2022 09:53:28 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.34]) by smtp.corp.redhat.com (Postfix) with ESMTP id 781241059155 for ; Tue, 11 Jan 2022 09:53:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1641894841; 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=EETsKaZYo4uIuFkK+u1l6LFFvp5RaARTEybZfBOEbt4=; b=NauzAuBFkZF1j+xIuweX8bQ8Zv938i5CBtIX5SF8IykOjAOmxKsLa4+8ewMbS3RFs83luu 2DhOe8oper3tAnrLCqLoTZF4dg+HF9D9Cgw7Zr6T+OuxxF0iO1rPpY0ipMpZZ/otqnGb6i IHRukVYjJT1byh8Do/8TjKwoChO3xBs= X-MC-Unique: zu7OmJZCPyeWTht71nDfPw-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 3/3] qemuSnapshotCreate: Don't insert snapshot into list with VIR_DOMAIN_SNAPSHOT_CREATE_NO_METADATA Date: Tue, 11 Jan 2022 10:53:22 +0100 Message-Id: <68fed3242164f50582b9fca4a31ded7a903ad92a.1641894644.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 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: 1641894846329100001 Content-Type: text/plain; charset="utf-8" Our approach to snapshots without metadata was to insert them to the snapshot list and then later remove them from the list when the flag is present. This quirky logic was broken in a recent refactor of the snapshot code causing that the snapshot stayed inserted in the snapshot list. Recent refactor of the snapshot code didn't faithfully relocate this logic to the new function. Rather than attempting to restore the quirky logic of adding and then removing the object, don't add the snapshot into the list at all when the user doesn't want metadata. We achieve this by creating a temporary 'virDomainMomentObj' wrapper which is not inserted into the list and using that instead of calling virDomainSnapshotAssignDef. Fixes: 9bad0fb809b Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=3D2039131 Signed-off-by: Peter Krempa Reviewed-by: Michal Privoznik --- src/qemu/qemu_snapshot.c | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/src/qemu/qemu_snapshot.c b/src/qemu/qemu_snapshot.c index 9a5d3e60aa..e9fc9051c1 100644 --- a/src/qemu/qemu_snapshot.c +++ b/src/qemu/qemu_snapshot.c @@ -1756,7 +1756,7 @@ qemuSnapshotCreate(virDomainObj *vm, virQEMUDriverConfig *cfg, unsigned int flags) { - + g_autoptr(virDomainMomentObj) noMetadataSnap =3D NULL; virDomainMomentObj *snap =3D NULL; virDomainMomentObj *current =3D NULL; virDomainSnapshotPtr ret =3D NULL; @@ -1767,16 +1767,20 @@ qemuSnapshotCreate(virDomainObj *vm, if (qemuSnapshotPrepare(vm, def, &flags) < 0) return NULL; - if (!(snap =3D virDomainSnapshotAssignDef(vm->snapshots, def))) - return NULL; - - virObjectRef(def); + if (flags & VIR_DOMAIN_SNAPSHOT_CREATE_NO_METADATA) { + snap =3D noMetadataSnap =3D virDomainMomentObjNew(); + snap->def =3D &def->parent; + } else { + if (!(snap =3D virDomainSnapshotAssignDef(vm->snapshots, def))) + return NULL; - current =3D virDomainSnapshotGetCurrent(vm->snapshots); - if (current) { - snap->def->parent_name =3D g_strdup(current->def->name); + if ((current =3D virDomainSnapshotGetCurrent(vm->snapshots))) { + snap->def->parent_name =3D g_strdup(current->def->name); + } } + virObjectRef(def); + /* actually do the snapshot */ if (virDomainObjIsActive(vm)) { if (flags & VIR_DOMAIN_SNAPSHOT_CREATE_DISK_ONLY || @@ -1804,7 +1808,7 @@ qemuSnapshotCreate(virDomainObj *vm, } } - if (!(flags & VIR_DOMAIN_SNAPSHOT_CREATE_NO_METADATA)) { + if (!noMetadataSnap) { qemuSnapshotSetCurrent(vm, snap); if (qemuSnapshotCreateWriteMetadata(vm, snap, driver, cfg) < 0) @@ -1818,7 +1822,8 @@ qemuSnapshotCreate(virDomainObj *vm, return ret; error: - virDomainSnapshotObjListRemove(vm->snapshots, snap); + if (!noMetadataSnap) + virDomainSnapshotObjListRemove(vm->snapshots, snap); return NULL; } --=20 2.31.1