From nobody Fri Apr 26 04:55:58 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=1637839091; cv=none; d=zohomail.com; s=zohoarc; b=F6HUoOU6Zx1HTdyeoU61RNX9Ie7f75sFWwnpVrOLFfdJ0r0oF647i3++RR91jFPt62NotXJLnHtrxwXL+xqaIkSiaPPMDlun0+Kmvj7j3LqrcY5LntGoaMJtb/W85YKcRRm2KZP1CRR+NBCiA6OY7Sg38Y9vXxADvIrcI75SooA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1637839091; 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=AkfLOVxC8BGFVigJvip91Ac2KBwlL0rm5cxAtKxZmXA=; b=h5kBgD89GKmWRsSkL7TlK7Wf91dPHTIHEPSqRfDpwxh+DSmEgeJd73vc7Rmu6JDDFgof4lZ9PXHxGuMLyW8MXte143C5oJJI9WFxL2XXDm6IdJLmzCIAAK7nrZWeOENPbNeg8WkdIyuU1s1dSxolxT2+wz/EEdRClNn/8B+q5LA= 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 1637839091048449.7059134709119; Thu, 25 Nov 2021 03:18:11 -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-451-tfMPBC0LMHughIq5Y5dh_A-1; Thu, 25 Nov 2021 06:16:32 -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 57309801B00; Thu, 25 Nov 2021 11:16: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 DCD8176613; Thu, 25 Nov 2021 11:16: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 41D891809C89; Thu, 25 Nov 2021 11:16:24 +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 1APBGNAF022795 for ; Thu, 25 Nov 2021 06:16:23 -0500 Received: by smtp.corp.redhat.com (Postfix) id 605261000051; Thu, 25 Nov 2021 11:16:23 +0000 (UTC) Received: from antique-work.redhat.com (unknown [10.40.194.97]) by smtp.corp.redhat.com (Postfix) with ESMTP id D22D11002390 for ; Thu, 25 Nov 2021 11:16:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1637839090; 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=AkfLOVxC8BGFVigJvip91Ac2KBwlL0rm5cxAtKxZmXA=; b=ciiqSlJ+u9UT9tSbQjmGFda1cWpSxDYO7gBVJMbV7pyVcWp41XBu7sqXTQnkzB7AaXWgjP 4T6q1dUPanAzT4+VwTdi47veG4aCBn9Oo3hmYkF1SLaIAnfQh1DH+1gAjJsj1RJ3uhcSJr 9tStM80NLKqP677W8h1DSLdDJ/88qqo= X-MC-Unique: tfMPBC0LMHughIq5Y5dh_A-1 From: Pavel Hrdina To: libvir-list@redhat.com Subject: [libvirt PATCH 01/11] qemu_snapshot: create: move XML parsing to separate function Date: Thu, 25 Nov 2021 12:16:07 +0100 Message-Id: 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.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: 1637839092070100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: Pavel Hrdina Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_snapshot.c | 36 +++++++++++++++++++++++++----------- 1 file changed, 25 insertions(+), 11 deletions(-) diff --git a/src/qemu/qemu_snapshot.c b/src/qemu/qemu_snapshot.c index 661aeeb8aa..6ba3215ee3 100644 --- a/src/qemu/qemu_snapshot.c +++ b/src/qemu/qemu_snapshot.c @@ -1531,6 +1531,30 @@ qemuSnapshotCreateActiveExternal(virQEMUDriver *driv= er, } =20 =20 +static virDomainSnapshotDef* +qemuSnapshotCreateXMLParse(virDomainObj *vm, + virQEMUDriver *driver, + const char *xmlDesc, + unsigned int flags) +{ + qemuDomainObjPrivate *priv =3D vm->privateData; + unsigned int parse_flags =3D VIR_DOMAIN_SNAPSHOT_PARSE_DISKS; + + if (flags & VIR_DOMAIN_SNAPSHOT_CREATE_REDEFINE) + parse_flags |=3D VIR_DOMAIN_SNAPSHOT_PARSE_REDEFINE; + + if ((flags & VIR_DOMAIN_SNAPSHOT_CREATE_DISK_ONLY) || + !virDomainObjIsActive(vm)) + parse_flags |=3D VIR_DOMAIN_SNAPSHOT_PARSE_OFFLINE; + + if (flags & VIR_DOMAIN_SNAPSHOT_CREATE_VALIDATE) + parse_flags |=3D VIR_DOMAIN_SNAPSHOT_PARSE_VALIDATE; + + return virDomainSnapshotDefParseString(xmlDesc, driver->xmlopt, + priv->qemuCaps, NULL, parse_fla= gs); +} + + virDomainSnapshotPtr qemuSnapshotCreateXML(virDomainPtr domain, virDomainObj *vm, @@ -1544,7 +1568,6 @@ qemuSnapshotCreateXML(virDomainPtr domain, virDomainMomentObj *current =3D NULL; bool update_current =3D true; bool redefine =3D flags & VIR_DOMAIN_SNAPSHOT_CREATE_REDEFINE; - unsigned int parse_flags =3D VIR_DOMAIN_SNAPSHOT_PARSE_DISKS; int align_location =3D VIR_DOMAIN_SNAPSHOT_LOCATION_INTERNAL; bool align_match =3D true; g_autoptr(virQEMUDriverConfig) cfg =3D virQEMUDriverGetConfig(driver); @@ -1573,8 +1596,6 @@ qemuSnapshotCreateXML(virDomainPtr domain, if ((redefine && !(flags & VIR_DOMAIN_SNAPSHOT_CREATE_CURRENT)) || (flags & VIR_DOMAIN_SNAPSHOT_CREATE_NO_METADATA)) update_current =3D false; - if (redefine) - parse_flags |=3D VIR_DOMAIN_SNAPSHOT_PARSE_REDEFINE; =20 if (qemuDomainSupportsCheckpointsBlockjobs(vm) < 0) return NULL; @@ -1584,15 +1605,8 @@ qemuSnapshotCreateXML(virDomainPtr domain, _("cannot halt after transient domain snapshot")); return NULL; } - if ((flags & VIR_DOMAIN_SNAPSHOT_CREATE_DISK_ONLY) || - !virDomainObjIsActive(vm)) - parse_flags |=3D VIR_DOMAIN_SNAPSHOT_PARSE_OFFLINE; =20 - if (flags & VIR_DOMAIN_SNAPSHOT_CREATE_VALIDATE) - parse_flags |=3D VIR_DOMAIN_SNAPSHOT_PARSE_VALIDATE; - - if (!(def =3D virDomainSnapshotDefParseString(xmlDesc, driver->xmlopt, - priv->qemuCaps, NULL, pars= e_flags))) + if (!(def =3D qemuSnapshotCreateXMLParse(vm, driver, xmlDesc, flags))) return NULL; =20 /* reject snapshot names containing slashes or starting with dot as --=20 2.31.1 From nobody Fri Apr 26 04:55:58 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=1637839005; cv=none; d=zohomail.com; s=zohoarc; b=ASw8Y2UIwaKXBWsnFwcChpBDBE+YbY/NZBGvoH85qfSq9WiipwnY84b1B1qlnJP2ZsG/Jbc8NSQr6lLMat/jTBSjH1vPAxAiGkCEnSwhTVH0acDM4bt5PmYgH+EaQXEr0ViyqSlLgDRHETZZ7lQltZ4WCzg35MsoSOgq5BnqJQU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1637839005; 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=teKxrQbCGAwi4qJzqOhvoAmyuVwfDu8opbSYfVmFVDo=; b=F0qEYiA0v99W8wpkJB6O9gdBrOG996oUDf+Wd5MxSEQIu9VRRq5e7oIHN9W59H6s3XMUofxzVxsYu1AnivPQ9T8VV+0FR7s/wuylRPnBmSMwZ9r2f2Vh0oXhEYesTI2sbvLyT2hlYvNQIdZLMQTRK/j+vzouqVvWRUAgdtwiBbU= 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 1637839005026147.77902457651305; Thu, 25 Nov 2021 03:16: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-505-Z9-NzbJrP-abE5wMYZMWug-1; Thu, 25 Nov 2021 06:16:41 -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 0BE781475C; Thu, 25 Nov 2021 11:16:36 +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 E3F031972E; Thu, 25 Nov 2021 11:16:35 +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 B252A4BB7C; Thu, 25 Nov 2021 11:16:35 +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 1APBGObw022800 for ; Thu, 25 Nov 2021 06:16:24 -0500 Received: by smtp.corp.redhat.com (Postfix) id 450E81002390; Thu, 25 Nov 2021 11:16:24 +0000 (UTC) Received: from antique-work.redhat.com (unknown [10.40.194.97]) by smtp.corp.redhat.com (Postfix) with ESMTP id B6B891000051 for ; Thu, 25 Nov 2021 11:16:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1637839004; 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=teKxrQbCGAwi4qJzqOhvoAmyuVwfDu8opbSYfVmFVDo=; b=AO1EIOeJDB2A8N1M15gGcoYxrJDiDH86kccMqAiXB9NLal5cQr/woT2dQ1nohRlwLNNwuN Oq5UfwWOgh3qXjvVFLEoeAZV5b3XHDrljTFDYWat19HgYc3kM0jL8j81/mBgF8lPr2eCnZ lZAFW+8zf+evXERsDUeO7wMxyuBgJQU= X-MC-Unique: Z9-NzbJrP-abE5wMYZMWug-1 From: Pavel Hrdina To: libvir-list@redhat.com Subject: [libvirt PATCH 02/11] qemu_snapshot: create: move XML def validation to separate function Date: Thu, 25 Nov 2021 12:16:08 +0100 Message-Id: <2b2f9a557074b13aa2947751d3427be17ccf5ef0.1637838934.git.phrdina@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: 1637839006519100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: Pavel Hrdina Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_snapshot.c | 140 +++++++++++++++++++++------------------ 1 file changed, 77 insertions(+), 63 deletions(-) diff --git a/src/qemu/qemu_snapshot.c b/src/qemu/qemu_snapshot.c index 6ba3215ee3..5ebe959151 100644 --- a/src/qemu/qemu_snapshot.c +++ b/src/qemu/qemu_snapshot.c @@ -1555,6 +1555,82 @@ qemuSnapshotCreateXMLParse(virDomainObj *vm, } =20 =20 +static int +qemuSnapshotCreateXMLValidateDef(virDomainObj *vm, + virDomainSnapshotDef *def, + unsigned int flags) +{ + bool redefine =3D flags & VIR_DOMAIN_SNAPSHOT_CREATE_REDEFINE; + virDomainSnapshotState state; + + /* reject snapshot names containing slashes or starting with dot as + * snapshot definitions are saved in files named by the snapshot name = */ + if (!(flags & VIR_DOMAIN_SNAPSHOT_CREATE_NO_METADATA)) { + if (strchr(def->parent.name, '/')) { + virReportError(VIR_ERR_XML_DETAIL, + _("invalid snapshot name '%s': " + "name can't contain '/'"), + def->parent.name); + return -1; + } + + if (def->parent.name[0] =3D=3D '.') { + virReportError(VIR_ERR_XML_DETAIL, + _("invalid snapshot name '%s': " + "name can't start with '.'"), + def->parent.name); + return -1; + } + } + + /* reject the VIR_DOMAIN_SNAPSHOT_CREATE_LIVE flag where not supported= */ + if (flags & VIR_DOMAIN_SNAPSHOT_CREATE_LIVE && + (!virDomainObjIsActive(vm) || + def->memory !=3D VIR_DOMAIN_SNAPSHOT_LOCATION_EXTERNAL)) { + virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s", + _("live snapshot creation is supported only " + "during full system snapshots")); + return -1; + } + + /* allow snapshots only in certain states */ + state =3D redefine ? def->state : vm->state.state; + switch (state) { + /* valid states */ + case VIR_DOMAIN_SNAPSHOT_RUNNING: + case VIR_DOMAIN_SNAPSHOT_PAUSED: + case VIR_DOMAIN_SNAPSHOT_SHUTDOWN: + case VIR_DOMAIN_SNAPSHOT_SHUTOFF: + case VIR_DOMAIN_SNAPSHOT_CRASHED: + break; + + case VIR_DOMAIN_SNAPSHOT_DISK_SNAPSHOT: + if (!redefine) { + virReportError(VIR_ERR_INTERNAL_ERROR, _("Invalid domain state= %s"), + virDomainSnapshotStateTypeToString(state)); + return -1; + } + break; + + case VIR_DOMAIN_SNAPSHOT_PMSUSPENDED: + virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s", + _("qemu doesn't support taking snapshots of " + "PMSUSPENDED guests")); + return -1; + + /* invalid states */ + case VIR_DOMAIN_SNAPSHOT_NOSTATE: + case VIR_DOMAIN_SNAPSHOT_BLOCKED: /* invalid state, unused in qemu */ + case VIR_DOMAIN_SNAPSHOT_LAST: + virReportError(VIR_ERR_INTERNAL_ERROR, _("Invalid domain state %s"= ), + virDomainSnapshotStateTypeToString(state)); + return -1; + } + + return 0; +} + + virDomainSnapshotPtr qemuSnapshotCreateXML(virDomainPtr domain, virDomainObj *vm, @@ -1572,7 +1648,6 @@ qemuSnapshotCreateXML(virDomainPtr domain, bool align_match =3D true; g_autoptr(virQEMUDriverConfig) cfg =3D virQEMUDriverGetConfig(driver); qemuDomainObjPrivate *priv =3D vm->privateData; - virDomainSnapshotState state; g_autoptr(virDomainSnapshotDef) def =3D NULL; =20 virCheckFlags(VIR_DOMAIN_SNAPSHOT_CREATE_REDEFINE | @@ -1609,69 +1684,8 @@ qemuSnapshotCreateXML(virDomainPtr domain, if (!(def =3D qemuSnapshotCreateXMLParse(vm, driver, xmlDesc, flags))) return NULL; =20 - /* reject snapshot names containing slashes or starting with dot as - * snapshot definitions are saved in files named by the snapshot name = */ - if (!(flags & VIR_DOMAIN_SNAPSHOT_CREATE_NO_METADATA)) { - if (strchr(def->parent.name, '/')) { - virReportError(VIR_ERR_XML_DETAIL, - _("invalid snapshot name '%s': " - "name can't contain '/'"), - def->parent.name); - return NULL; - } - - if (def->parent.name[0] =3D=3D '.') { - virReportError(VIR_ERR_XML_DETAIL, - _("invalid snapshot name '%s': " - "name can't start with '.'"), - def->parent.name); - return NULL; - } - } - - /* reject the VIR_DOMAIN_SNAPSHOT_CREATE_LIVE flag where not supported= */ - if (flags & VIR_DOMAIN_SNAPSHOT_CREATE_LIVE && - (!virDomainObjIsActive(vm) || - def->memory !=3D VIR_DOMAIN_SNAPSHOT_LOCATION_EXTERNAL)) { - virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s", - _("live snapshot creation is supported only " - "during full system snapshots")); + if (qemuSnapshotCreateXMLValidateDef(vm, def, flags) < 0) return NULL; - } - - /* allow snapshots only in certain states */ - state =3D redefine ? def->state : vm->state.state; - switch (state) { - /* valid states */ - case VIR_DOMAIN_SNAPSHOT_RUNNING: - case VIR_DOMAIN_SNAPSHOT_PAUSED: - case VIR_DOMAIN_SNAPSHOT_SHUTDOWN: - case VIR_DOMAIN_SNAPSHOT_SHUTOFF: - case VIR_DOMAIN_SNAPSHOT_CRASHED: - break; - - case VIR_DOMAIN_SNAPSHOT_DISK_SNAPSHOT: - if (!redefine) { - virReportError(VIR_ERR_INTERNAL_ERROR, _("Invalid domain state= %s"), - virDomainSnapshotStateTypeToString(state)); - return NULL; - } - break; - - case VIR_DOMAIN_SNAPSHOT_PMSUSPENDED: - virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s", - _("qemu doesn't support taking snapshots of " - "PMSUSPENDED guests")); - return NULL; - - /* invalid states */ - case VIR_DOMAIN_SNAPSHOT_NOSTATE: - case VIR_DOMAIN_SNAPSHOT_BLOCKED: /* invalid state, unused in qemu */ - case VIR_DOMAIN_SNAPSHOT_LAST: - virReportError(VIR_ERR_INTERNAL_ERROR, _("Invalid domain state %s"= ), - virDomainSnapshotStateTypeToString(state)); - return NULL; - } =20 /* We are going to modify the domain below. Internal snapshots would u= se * a regular job, so we need to set the job mask to disallow query as --=20 2.31.1 From nobody Fri Apr 26 04:55:58 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=1637839006; cv=none; d=zohomail.com; s=zohoarc; b=FN2h5KC8CXeGNbdXAiuy/swQePfKooVOEHPP6ZF7p7d1Nkm8+p5m927x5Wij7yFECH081PoB9hqXMs0v94n+QvwRUIybRxM4+ru8iMUGWwZjwQLsLy9s05+IqX0XgRxKB5FxJ6CKDRq/R6R9qjFB38p+obIKDWH6b36SOCozf2g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1637839006; 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=FHu7eou+jypXOmhslTN0jxUHc3FqT3zWg3O3w/5NTbA=; b=GvDj5gLZvdRh5ax9xSs4ekDV/thsKdCBbV/Xs4m94gVMmdqc+PKDbEOR8qCfBpvnfiPoRWvwq/YkifyQ/dRhA7ni/DolcSnRPnjo7RBdrDLxnQQI0miNy6CGrX5LTJ0AQVMfva6rzp0/3UrpwQ6SHvGpLaOJCkJm1uFabITKrj0= 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 1637839006362402.0585730911746; Thu, 25 Nov 2021 03:16: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-374-iJUD_GNrPWGEjfDCW9vieg-1; Thu, 25 Nov 2021 06:16:41 -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 C87E681C9BE; Thu, 25 Nov 2021 11:16:36 +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 AC7DF60C7F; Thu, 25 Nov 2021 11:16:36 +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 75EDE4A7C8; Thu, 25 Nov 2021 11:16:36 +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 1APBGPPT022808 for ; Thu, 25 Nov 2021 06:16:25 -0500 Received: by smtp.corp.redhat.com (Postfix) id 29A791000051; Thu, 25 Nov 2021 11:16:25 +0000 (UTC) Received: from antique-work.redhat.com (unknown [10.40.194.97]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9AF5C1002390 for ; Thu, 25 Nov 2021 11:16:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1637839005; 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=FHu7eou+jypXOmhslTN0jxUHc3FqT3zWg3O3w/5NTbA=; b=beDRpBNiXLkYRo8DaolPUw+yIo6tJ40rbZMpdzery8H/3n7i5rfJU51y1fV3q71+TTcavG nrNdy4aXpeLe95vT3uINmdHhixGcY15sr6iuk3Dz/Y3A5ySmi/b41r/7rPzzk4qiyMB7Ei Y4luUF9WJ9MvQoMyVHzUM6n3KQfRzGI= X-MC-Unique: iJUD_GNrPWGEjfDCW9vieg-1 From: Pavel Hrdina To: libvir-list@redhat.com Subject: [libvirt PATCH 03/11] qemu_snapshot: create: move disk align to separate function Date: Thu, 25 Nov 2021 12:16:09 +0100 Message-Id: <5ccb4a4945fb7bc196badbb9be9b2ffeb1b4410f.1637838934.git.phrdina@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: 1637839006830100004 Content-Type: text/plain; charset="utf-8" Signed-off-by: Pavel Hrdina Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_snapshot.c | 115 ++++++++++++++++++++++----------------- 1 file changed, 65 insertions(+), 50 deletions(-) diff --git a/src/qemu/qemu_snapshot.c b/src/qemu/qemu_snapshot.c index 5ebe959151..7198a2aad3 100644 --- a/src/qemu/qemu_snapshot.c +++ b/src/qemu/qemu_snapshot.c @@ -1631,6 +1631,69 @@ qemuSnapshotCreateXMLValidateDef(virDomainObj *vm, } =20 =20 +static int +qemuSnapshotAlignDisks(virDomainObj *vm, + virDomainSnapshotDef *def, + virQEMUDriver *driver, + unsigned int flags) +{ + g_autofree char *xml =3D NULL; + qemuDomainObjPrivate *priv =3D vm->privateData; + int align_location =3D VIR_DOMAIN_SNAPSHOT_LOCATION_INTERNAL; + bool align_match =3D true; + + /* Easiest way to clone inactive portion of vm->def is via + * conversion in and back out of xml. */ + if (!(xml =3D qemuDomainDefFormatLive(driver, priv->qemuCaps, + vm->def, priv->origCPU, + true, true)) || + !(def->parent.dom =3D virDomainDefParseString(xml, driver->xmlopt, + priv->qemuCaps, + VIR_DOMAIN_DEF_PARSE_I= NACTIVE | + VIR_DOMAIN_DEF_PARSE_S= KIP_VALIDATE))) + return -1; + + if (vm->newDef) { + def->parent.inactiveDom =3D virDomainDefCopy(vm->newDef, + driver->xmlopt, priv->q= emuCaps, true); + if (!def->parent.inactiveDom) + return -1; + } + + 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 + def->state =3D VIR_DOMAIN_SNAPSHOT_SHUTOFF; + def->memory =3D VIR_DOMAIN_SNAPSHOT_LOCATION_NONE; + } 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); + + if (virDomainObjIsActive(vm) && + def->memory =3D=3D VIR_DOMAIN_SNAPSHOT_LOCATION_NONE) { + virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s", + _("internal snapshot of a running VM " + "must include the memory state")); + return -1; + } + + def->memory =3D (def->state =3D=3D VIR_DOMAIN_SNAPSHOT_SHUTOFF ? + VIR_DOMAIN_SNAPSHOT_LOCATION_NONE : + VIR_DOMAIN_SNAPSHOT_LOCATION_INTERNAL); + } + if (virDomainSnapshotAlignDisks(def, align_location, align_match) < 0) + return -1; + + return 0; +} + + virDomainSnapshotPtr qemuSnapshotCreateXML(virDomainPtr domain, virDomainObj *vm, @@ -1638,16 +1701,12 @@ qemuSnapshotCreateXML(virDomainPtr domain, unsigned int flags) { virQEMUDriver *driver =3D domain->conn->privateData; - g_autofree char *xml =3D NULL; virDomainMomentObj *snap =3D NULL; virDomainSnapshotPtr snapshot =3D NULL; virDomainMomentObj *current =3D NULL; bool update_current =3D true; bool redefine =3D flags & VIR_DOMAIN_SNAPSHOT_CREATE_REDEFINE; - int align_location =3D VIR_DOMAIN_SNAPSHOT_LOCATION_INTERNAL; - bool align_match =3D true; g_autoptr(virQEMUDriverConfig) cfg =3D virQEMUDriverGetConfig(driver); - qemuDomainObjPrivate *priv =3D vm->privateData; g_autoptr(virDomainSnapshotDef) def =3D NULL; =20 virCheckFlags(VIR_DOMAIN_SNAPSHOT_CREATE_REDEFINE | @@ -1703,54 +1762,10 @@ qemuSnapshotCreateXML(virDomainPtr domain, flags) < 0) goto endjob; } else { - /* Easiest way to clone inactive portion of vm->def is via - * conversion in and back out of xml. */ - if (!(xml =3D qemuDomainDefFormatLive(driver, priv->qemuCaps, - vm->def, priv->origCPU, - true, true)) || - !(def->parent.dom =3D virDomainDefParseString(xml, driver->xml= opt, - priv->qemuCaps, - VIR_DOMAIN_DEF_PAR= SE_INACTIVE | - VIR_DOMAIN_DEF_PAR= SE_SKIP_VALIDATE))) + if (qemuSnapshotAlignDisks(vm, def, driver, flags) < 0) goto endjob; =20 - if (vm->newDef) { - def->parent.inactiveDom =3D virDomainDefCopy(vm->newDef, - driver->xmlopt, pri= v->qemuCaps, true); - if (!def->parent.inactiveDom) - goto endjob; - } - - 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 - def->state =3D VIR_DOMAIN_SNAPSHOT_SHUTOFF; - def->memory =3D VIR_DOMAIN_SNAPSHOT_LOCATION_NONE; - } else if (def->memory =3D=3D VIR_DOMAIN_SNAPSHOT_LOCATION_EXTERNA= L) { - 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); - - if (virDomainObjIsActive(vm) && - def->memory =3D=3D VIR_DOMAIN_SNAPSHOT_LOCATION_NONE) { - virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s", - _("internal snapshot of a running VM " - "must include the memory state")); - goto endjob; - } - - def->memory =3D (def->state =3D=3D VIR_DOMAIN_SNAPSHOT_SHUTOFF= ? - VIR_DOMAIN_SNAPSHOT_LOCATION_NONE : - VIR_DOMAIN_SNAPSHOT_LOCATION_INTERNAL); - } - if (virDomainSnapshotAlignDisks(def, align_location, - align_match) < 0 || - qemuSnapshotPrepare(vm, def, &flags) < 0) + if (qemuSnapshotPrepare(vm, def, &flags) < 0) goto endjob; } =20 --=20 2.31.1 From nobody Fri Apr 26 04:55:58 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=1637839008; cv=none; d=zohomail.com; s=zohoarc; b=DRZ8a2tT2lRLP0+hvUXOCM0ExtUu2lS/RnCSyfYq2FnbLM2jp26rCiIdMeDbvgDcVB/As3TDKOfy6B+jy650OSV61h787OJXrxTNRNJEzFxgl3j+E1rKY8p38JKHYaQ+9LZiVsj3TD/EYiM4KZlJ0mcA5Feae8sc5gL0C535D3g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1637839008; 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=dLXw7EEpZcwX6BWAA3z6A8HkMgKl+ijz7ljcOp8pzHU=; b=CfztAULZznk3iYGzJDiFnbpNZajE2v7SfVjTN6dgSWINk39S6ERR+PqIIL2PBVwaHE0shDPD4bqB4zsPK4z8f1oUmmzF0ns/L3I/qQJLxTf69imZuNW0Wg5hsmSXSuwbLRQlN3OhUZeyYXnPj5AhFnmmSShpm3hxwyrpZJQpuio= 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 163783900896385.67281496888825; Thu, 25 Nov 2021 03:16: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-526-WXi0-S9nO2iwFpTi6nLGoQ-1; Thu, 25 Nov 2021 06:16:44 -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 98BC8192D791; Thu, 25 Nov 2021 11:16:39 +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 7AFD95F4F7; Thu, 25 Nov 2021 11:16:39 +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 2864018077BC; Thu, 25 Nov 2021 11:16:39 +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 1APBGQAX022822 for ; Thu, 25 Nov 2021 06:16:26 -0500 Received: by smtp.corp.redhat.com (Postfix) id 110E11002390; Thu, 25 Nov 2021 11:16:26 +0000 (UTC) Received: from antique-work.redhat.com (unknown [10.40.194.97]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7EEEF1000051 for ; Thu, 25 Nov 2021 11:16:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1637839008; 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=dLXw7EEpZcwX6BWAA3z6A8HkMgKl+ijz7ljcOp8pzHU=; b=CmI1clDLAK39u56givnLr4fw4jAh2KpSAxaGTnzWAFpVnZ726s5OQ+EUiX66u/VCO/a780 c4rNbE0L+EdlHOs+jnivOY18CB3epGrlaNMRTij1N6+V32/kOZYD4nV3HkfR4aRsP4HM6g Tl+CXf15Mim2l6JZdf1mpXb9cejJXsY= X-MC-Unique: WXi0-S9nO2iwFpTi6nLGoQ-1 From: Pavel Hrdina To: libvir-list@redhat.com Subject: [libvirt PATCH 04/11] qemu_snapshot: create: move virDomainSnapshotAssignDef to both code paths Date: Thu, 25 Nov 2021 12:16:10 +0100 Message-Id: <0e22dd26ade18c144b517c69b0c5f254f0b4bb5f.1637838934.git.phrdina@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: 1637839011094100001 Content-Type: text/plain; charset="utf-8" This makes it obvious that the function is called for creating new snapshot and redefining old snapshot as well. Signed-off-by: Pavel Hrdina Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_snapshot.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/qemu/qemu_snapshot.c b/src/qemu/qemu_snapshot.c index 7198a2aad3..6860133bbb 100644 --- a/src/qemu/qemu_snapshot.c +++ b/src/qemu/qemu_snapshot.c @@ -1761,15 +1761,18 @@ qemuSnapshotCreateXML(virDomainPtr domain, driver->xmlopt, flags) < 0) goto endjob; + + if (!snap) { + if (!(snap =3D virDomainSnapshotAssignDef(vm->snapshots, def))) + goto endjob; + } } else { if (qemuSnapshotAlignDisks(vm, def, driver, flags) < 0) goto endjob; =20 if (qemuSnapshotPrepare(vm, def, &flags) < 0) goto endjob; - } =20 - if (!snap) { if (!(snap =3D virDomainSnapshotAssignDef(vm->snapshots, def))) goto endjob; =20 --=20 2.31.1 From nobody Fri Apr 26 04:55:58 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=1637838996; cv=none; d=zohomail.com; s=zohoarc; b=jfW+yOPoUJclFwBlFYyQJwiOU9/DQT20bPoo26osP1ivRSpx7c8Yz0pIND4gl1DPzQhxUqG4Biyfel4aTFiDPxrZT6Ev+FMyUDQrYZTKByqQT4qGN3RL6+d3myZqzkvI0hZ/yqTsa9zKy/gmObOaptPEZ6kjvOahtOXQWngciyY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1637838996; 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=eqQhCYav57j7S2MvL/lro3in9skw/GLZys6NxVu68Ns=; b=ArHkJF3drVUS5juLccpiW/oRpTEkKfkgGrsfZ+p7kQcBJssbt71dm0GAk2/zun9RVMhRXBVR/12MagNSu5W3ulrSNi8FDJEBfe24m8do8f/6OObiuwflWwOFOVAejrJ5ExgPlF3HtKrP9VnSG4KRy0FrZMbuZ3dhnR0s+4H9XoI= 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 1637838996889830.595270219591; Thu, 25 Nov 2021 03:16:36 -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-598-6q4nH7-BMeOWlNFMM0l69A-1; Thu, 25 Nov 2021 06:16:34 -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 750C42F20; Thu, 25 Nov 2021 11:16:29 +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 2D28D1000051; Thu, 25 Nov 2021 11:16:29 +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 027FC1809CB8; Thu, 25 Nov 2021 11:16:29 +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 1APBGQda022834 for ; Thu, 25 Nov 2021 06:16:26 -0500 Received: by smtp.corp.redhat.com (Postfix) id E9F931002390; Thu, 25 Nov 2021 11:16:26 +0000 (UTC) Received: from antique-work.redhat.com (unknown [10.40.194.97]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6696E1000051 for ; Thu, 25 Nov 2021 11:16:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1637838995; 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=eqQhCYav57j7S2MvL/lro3in9skw/GLZys6NxVu68Ns=; b=XvMZ8Ik+3weg+A7i0vT8iqo/J4bX2q6qKYWpwQZ0ZaLG9LL7BBsF1dV2eofLNlw2vpYOZ7 ROhv0DGIXyJS2NhEXAJcnsH+dn00fuwbFfYj55FA/AnrcpTnpB8lY85yT+E2EEvcImnaQ9 8Bt3VAfMV9soj4J3KhnVZsta0WJBr/E= X-MC-Unique: 6q4nH7-BMeOWlNFMM0l69A-1 From: Pavel Hrdina To: libvir-list@redhat.com Subject: [libvirt PATCH 05/11] qemu_snapshot: create: virDomainSnapshotGetCurrent is not used with redefine Date: Thu, 25 Nov 2021 12:16:11 +0100 Message-Id: <9592831c17cd325c8932729e6a094c9f823089ee.1637838934.git.phrdina@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.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: 1637838997245100003 Content-Type: text/plain; charset="utf-8" Move it to code path for creating new snapshot. Signed-off-by: Pavel Hrdina Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_snapshot.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/qemu/qemu_snapshot.c b/src/qemu/qemu_snapshot.c index 6860133bbb..9a3f90e346 100644 --- a/src/qemu/qemu_snapshot.c +++ b/src/qemu/qemu_snapshot.c @@ -1703,7 +1703,6 @@ qemuSnapshotCreateXML(virDomainPtr domain, virQEMUDriver *driver =3D domain->conn->privateData; virDomainMomentObj *snap =3D NULL; virDomainSnapshotPtr snapshot =3D NULL; - virDomainMomentObj *current =3D NULL; bool update_current =3D true; bool redefine =3D flags & VIR_DOMAIN_SNAPSHOT_CREATE_REDEFINE; g_autoptr(virQEMUDriverConfig) cfg =3D virQEMUDriverGetConfig(driver); @@ -1767,6 +1766,8 @@ qemuSnapshotCreateXML(virDomainPtr domain, goto endjob; } } else { + virDomainMomentObj *current =3D NULL; + if (qemuSnapshotAlignDisks(vm, def, driver, flags) < 0) goto endjob; =20 @@ -1777,12 +1778,11 @@ qemuSnapshotCreateXML(virDomainPtr domain, goto endjob; =20 def =3D NULL; - } =20 - current =3D virDomainSnapshotGetCurrent(vm->snapshots); - if (current) { - if (!redefine) + current =3D virDomainSnapshotGetCurrent(vm->snapshots); + if (current) { snap->def->parent_name =3D g_strdup(current->def->name); + } } =20 /* actually do the snapshot */ --=20 2.31.1 From nobody Fri Apr 26 04:55:58 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=1637839006; cv=none; d=zohomail.com; s=zohoarc; b=j4IneF9g4vYzgmzY5jbgsNd91VUzBmWksthCJ/uhYb7W3xqj1XQ04yA7n0prS5mmUde7s2Lk35gTbEuwmbmh21nW7WWaG9772Gsm7YvXFREYWndrasUf15QwScECHRXCvYHZn49AOn7Q2xTkErCBWYgcnx4AYD+fMNPjMsCRo58= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1637839006; 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=wO/8VPbvmB5+pEzAFiRitl0XGfUY34xVPy+iSebzOYc=; b=OEWtM4jMVSPJLwpTHp8sGOEKhPcYYy8TJlSeWtiWYoJnUf6T4fXUxNmw20OJFAXgbI+npil9BTwGBKgEBhGJ4SlywLqi90vwnpDN/aGuyWp/GsxlpOmv7lWFTeopnbwrB/+5ODIdo4qQMllW/eAKz9K2687nmEz33LKTPYhTkOo= 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 1637839006459801.5727326630717; Thu, 25 Nov 2021 03:16: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-136-WEfGGvhONx2rS0nYC2Webg-1; Thu, 25 Nov 2021 06:16:41 -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 BD8FC192D796; Thu, 25 Nov 2021 11:16:36 +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 A1D721037F3C; Thu, 25 Nov 2021 11:16:36 +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 704DF4CA9B; Thu, 25 Nov 2021 11:16:36 +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 1APBGUD6022856 for ; Thu, 25 Nov 2021 06:16:30 -0500 Received: by smtp.corp.redhat.com (Postfix) id 7DBC61000051; Thu, 25 Nov 2021 11:16:30 +0000 (UTC) Received: from antique-work.redhat.com (unknown [10.40.194.97]) by smtp.corp.redhat.com (Postfix) with ESMTP id ED2371002390 for ; Thu, 25 Nov 2021 11:16:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1637839005; 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=wO/8VPbvmB5+pEzAFiRitl0XGfUY34xVPy+iSebzOYc=; b=jK0QrN3gCS1qqlP+8fgSOJS52k0JNVoMMRTDtRdthSMi8tzaEcXc364GxHl9tzaeDhvbPv i3oyjF2zrdZt+GQQDBJFjEZXM9zZGi5pnaMgq15D2L+9Dpm//lqRF4b+RB5Os+zOZ/CQAq MXv84uoTgsb38nHSBWFQwxIDr1Bj3tk= X-MC-Unique: WEfGGvhONx2rS0nYC2Webg-1 From: Pavel Hrdina To: libvir-list@redhat.com Subject: [libvirt PATCH 06/11] qemu_snapshot: create: drop update_current variable Date: Thu, 25 Nov 2021 12:16:12 +0100 Message-Id: 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.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: 1637839006780100003 Content-Type: text/plain; charset="utf-8" There is no need for the extra variable as it is used only at one place. Signed-off-by: Pavel Hrdina Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_snapshot.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/qemu/qemu_snapshot.c b/src/qemu/qemu_snapshot.c index 9a3f90e346..ac57d4e90e 100644 --- a/src/qemu/qemu_snapshot.c +++ b/src/qemu/qemu_snapshot.c @@ -1703,7 +1703,6 @@ qemuSnapshotCreateXML(virDomainPtr domain, virQEMUDriver *driver =3D domain->conn->privateData; virDomainMomentObj *snap =3D NULL; virDomainSnapshotPtr snapshot =3D NULL; - bool update_current =3D true; bool redefine =3D flags & VIR_DOMAIN_SNAPSHOT_CREATE_REDEFINE; g_autoptr(virQEMUDriverConfig) cfg =3D virQEMUDriverGetConfig(driver); g_autoptr(virDomainSnapshotDef) def =3D NULL; @@ -1726,10 +1725,6 @@ qemuSnapshotCreateXML(virDomainPtr domain, VIR_DOMAIN_SNAPSHOT_CREATE_REDEFINE, NULL); =20 - if ((redefine && !(flags & VIR_DOMAIN_SNAPSHOT_CREATE_CURRENT)) || - (flags & VIR_DOMAIN_SNAPSHOT_CREATE_NO_METADATA)) - update_current =3D false; - if (qemuDomainSupportsCheckpointsBlockjobs(vm) < 0) return NULL; =20 @@ -1824,7 +1819,7 @@ qemuSnapshotCreateXML(virDomainPtr domain, =20 endjob: if (snapshot && !(flags & VIR_DOMAIN_SNAPSHOT_CREATE_NO_METADATA)) { - if (update_current) + if (!redefine || (flags & VIR_DOMAIN_SNAPSHOT_CREATE_CURRENT)) qemuSnapshotSetCurrent(vm, snap); =20 if (qemuDomainSnapshotWriteMetadata(vm, snap, --=20 2.31.1 From nobody Fri Apr 26 04:55:58 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=1637839010; cv=none; d=zohomail.com; s=zohoarc; b=BdafMEFmlfqzoCiW5kBIEMNo/3s6UtUtxEvJcMg2gjW1DcVN2BJlo7EIYAnOIi5I/sajpMr0aD2pb74S+qJH6ymPz9SH4x/c51j/zSujTit9b8Igg3JuZK3BcUcJgb9CMudCjoYP575fdpZPCHDhc10WfJ5UTpzkmD007KBnb44= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1637839010; 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=qOc5WrRUa4Ynu+VPyPx8XZgrsrdBvRJadrzML9uIAdo=; b=N4nb0umAuqZqhpLxUesJlmA0z2zkcozp3YfsAj3U2qJ99xUEtggPjlyVzvEcadl8fll+G+tWib+DG0Sls8PEGaTE8D68MdxlwY4fs2fRwKFtp7o3Jf9UVgLcJMt+VlxWjlMcAT3EbHweusXhyUmnag+cQ8IcEFLgmW0r11iLOVs= 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 1637839010688646.05045443452; Thu, 25 Nov 2021 03:16: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-485-U5Yqa0Q1Owqe0LdD57DphA-1; Thu, 25 Nov 2021 06:16:46 -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 9087A100B3BC; Thu, 25 Nov 2021 11:16:39 +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 72D9D5D9C0; Thu, 25 Nov 2021 11:16:39 +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 24A1D1802E27; Thu, 25 Nov 2021 11:16:39 +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 1APBGVUF022867 for ; Thu, 25 Nov 2021 06:16:31 -0500 Received: by smtp.corp.redhat.com (Postfix) id 627EF1000051; Thu, 25 Nov 2021 11:16:31 +0000 (UTC) Received: from antique-work.redhat.com (unknown [10.40.194.97]) by smtp.corp.redhat.com (Postfix) with ESMTP id D40C11002390 for ; Thu, 25 Nov 2021 11:16:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1637839009; 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=qOc5WrRUa4Ynu+VPyPx8XZgrsrdBvRJadrzML9uIAdo=; b=h4XKi8bw/KLZF/McVwXqOBlg1Q6OPKFN+3PTcwlfhcvnV6QwzghY/vMJEafzb+9hXnCvNp 8sE7/FHwSqt74CJzU+L1uaqAbLXmzqG8/77z2fAHXI0EAC0/v3SQ5Ebbm0LQJn6A1MqSWF XtCUf21OtjHJO1LFIhGrN5MVxxkusBY= X-MC-Unique: U5Yqa0Q1Owqe0LdD57DphA-1 From: Pavel Hrdina To: libvir-list@redhat.com Subject: [libvirt PATCH 07/11] qemu_snapshot: create: refactor endjob in qemuSnapshotCreateXML Date: Thu, 25 Nov 2021 12:16:13 +0100 Message-Id: <42681b4f0793fa42802ec04d465aa59ea64b0805.1637838934.git.phrdina@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.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: 1637839011285100004 Content-Type: text/plain; charset="utf-8" The logic of saving metadata doesn't have to be in endjob section as it will only happen if we have successfully created snapshot. Signed-off-by: Pavel Hrdina Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_snapshot.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/qemu/qemu_snapshot.c b/src/qemu/qemu_snapshot.c index ac57d4e90e..46f65b8144 100644 --- a/src/qemu/qemu_snapshot.c +++ b/src/qemu/qemu_snapshot.c @@ -1815,10 +1815,10 @@ qemuSnapshotCreateXML(virDomainPtr domain, * do; we've successfully taken the snapshot, and we are now running * on it, so we have to go forward the best we can */ - snapshot =3D virGetDomainSnapshot(domain, snap->def->name); + if (!(snapshot =3D virGetDomainSnapshot(domain, snap->def->name))) + goto endjob; =20 - endjob: - if (snapshot && !(flags & VIR_DOMAIN_SNAPSHOT_CREATE_NO_METADATA)) { + if (!(flags & VIR_DOMAIN_SNAPSHOT_CREATE_NO_METADATA)) { if (!redefine || (flags & VIR_DOMAIN_SNAPSHOT_CREATE_CURRENT)) qemuSnapshotSetCurrent(vm, snap); =20 @@ -1832,13 +1832,17 @@ qemuSnapshotCreateXML(virDomainPtr domain, virReportError(VIR_ERR_INTERNAL_ERROR, _("unable to save metadata for snapshot %s"), snap->def->name); - virDomainSnapshotObjListRemove(vm->snapshots, snap); - } else { - virDomainSnapshotLinkParent(vm->snapshots, snap); + goto endjob; } - } else if (snap) { + + virDomainSnapshotLinkParent(vm->snapshots, snap); + snap =3D NULL; + } + + endjob: + + if (snap) virDomainSnapshotObjListRemove(vm->snapshots, snap); - } =20 qemuDomainObjEndAsyncJob(driver, vm); =20 --=20 2.31.1 From nobody Fri Apr 26 04:55:58 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=1637839011; cv=none; d=zohomail.com; s=zohoarc; b=d7cEzubq6FSwHA5HTBZyGmswKAciGXSRUfo4a55R2dSfDq2VxtDxK69udgsEy5g7rnULng+UyWPcyH+eo03PBlvOpm4zSsii/CQrwqkKyobeOsdTIcUv+XAtmS2oIbhnIzLBwA9NpQ3jW7bMNNppnwMfU2Vd/uz2uS4hNBv/1ZE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1637839011; 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=z324bFr4jxGfoWCAHv1qpLvT06UN0cNHB+RMM3P0/Ss=; b=O+lBfyRFNp8pLdex/zVqOB/AgJfkZ+KxnwBugLeEpPKJm4zwmdLzCFWXZRMxVC2p0+BnblEsoCMoGEKyBAomPoKzVqOgONbE4fYaWR7UcTlXNzi2yvdOOTi/hOSimW7ZhzmAl3U6x4GFqcR3m33U8bZ7iSbCeqStCxkJ155FtDE= 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 1637839011182497.31933765510155; Thu, 25 Nov 2021 03:16:51 -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-206-bM1WfedkOlyNstXVu9PMDA-1; Thu, 25 Nov 2021 06:16:48 -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 4D768835BE1; Thu, 25 Nov 2021 11:16:42 +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 2BC4D19D9F; Thu, 25 Nov 2021 11:16:42 +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 CD07B4A7CB; Thu, 25 Nov 2021 11:16:41 +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 1APBGZTZ022887 for ; Thu, 25 Nov 2021 06:16:35 -0500 Received: by smtp.corp.redhat.com (Postfix) id D25BA1042A90; Thu, 25 Nov 2021 11:16:35 +0000 (UTC) Received: from antique-work.redhat.com (unknown [10.40.194.97]) by smtp.corp.redhat.com (Postfix) with ESMTP id 501151037F3C for ; Thu, 25 Nov 2021 11:16:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1637839010; 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=z324bFr4jxGfoWCAHv1qpLvT06UN0cNHB+RMM3P0/Ss=; b=Vsrcs6RAyBamWD7aROKbKhfPWKzEn54Pr0rR48E58UySavVTrSqI4bzmEeKyqUfLhdV7Ym Aon13iTJIwb13S9oWZkUlpk6HgXLVrDBPiQAMt0gsyWVPU0IRzEqYDzBUkvOMEVpuBOyUV 6tvFUMNDcXQT50AfTUzdCOroJy1tdIw= X-MC-Unique: bM1WfedkOlyNstXVu9PMDA-1 From: Pavel Hrdina To: libvir-list@redhat.com Subject: [libvirt PATCH 08/11] qemu_snapshot: create: move saving metadata to separate function Date: Thu, 25 Nov 2021 12:16:14 +0100 Message-Id: <925614cf0a4c44a5168da259386efd6c1de822db.1637838934.git.phrdina@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: 1637839013368100007 Content-Type: text/plain; charset="utf-8" Signed-off-by: Pavel Hrdina Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_snapshot.c | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/src/qemu/qemu_snapshot.c b/src/qemu/qemu_snapshot.c index 46f65b8144..ce16236224 100644 --- a/src/qemu/qemu_snapshot.c +++ b/src/qemu/qemu_snapshot.c @@ -1694,6 +1694,27 @@ qemuSnapshotAlignDisks(virDomainObj *vm, } =20 =20 +static int +qemuSnapshotCreateWriteMetadata(virDomainObj *vm, + virDomainMomentObj *snap, + virQEMUDriver *driver, + virQEMUDriverConfig *cfg) +{ + if (qemuDomainSnapshotWriteMetadata(vm, snap, + driver->xmlopt, + cfg->snapshotDir) < 0) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("unable to save metadata for snapshot %s"), + snap->def->name); + return -1; + } + + virDomainSnapshotLinkParent(vm->snapshots, snap); + + return 0; +} + + virDomainSnapshotPtr qemuSnapshotCreateXML(virDomainPtr domain, virDomainObj *vm, @@ -1822,20 +1843,14 @@ qemuSnapshotCreateXML(virDomainPtr domain, if (!redefine || (flags & VIR_DOMAIN_SNAPSHOT_CREATE_CURRENT)) qemuSnapshotSetCurrent(vm, snap); =20 - if (qemuDomainSnapshotWriteMetadata(vm, snap, - driver->xmlopt, - cfg->snapshotDir) < 0) { + if (qemuSnapshotCreateWriteMetadata(vm, snap, driver, cfg) < 0) { /* if writing of metadata fails, error out rather than trying * to silently carry on without completing the snapshot */ virObjectUnref(snapshot); snapshot =3D NULL; - virReportError(VIR_ERR_INTERNAL_ERROR, - _("unable to save metadata for snapshot %s"), - snap->def->name); goto endjob; } =20 - virDomainSnapshotLinkParent(vm->snapshots, snap); snap =3D NULL; } =20 --=20 2.31.1 From nobody Fri Apr 26 04:55:58 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=1637839010; cv=none; d=zohomail.com; s=zohoarc; b=HZ7Cy5anXwno44caM+0VTGTmaz9O14rbfvO1cD2NAz9BDjgii8l7RwaNoQikWCRiz8GgaS5XrUQGE4kqYOfsBFnI1SHp+FoJ2nIOop4F3W4pAerDTG6koLyv9KXUBKLcaflYqJALKadEE1ozlESHhXlhXz4JTyxBYWseRcGjA84= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1637839010; 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=zeG/Jh7X1RUpyZwEb8e3GETGXO7A4kDGi8GENRbUvpE=; b=SVvkULeQ4Z7u4BkTwZj5AMvx0wymnrnMU8C7fcz1iX8BuqaxVaBlYl6n/0OKyqaGdcTkWjMcuWTxUu6kDXJHIb5PasERR/Uzpn5Hbt/w1rNTQ44qumHtBtfYwb13wB25s/VdCAo4ufGfjF3vjCmrF0LL0NGKlAMKCz42SSmVptc= 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 1637839009937612.230038631242; Thu, 25 Nov 2021 03:16:49 -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-401-lgWpOLvJOX-BhVsjbg0Mlg-1; Thu, 25 Nov 2021 06:16:45 -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 3761381CCCC; Thu, 25 Nov 2021 11:16:40 +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 E2D03E2C0; Thu, 25 Nov 2021 11:16:39 +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 ADF791806D2C; Thu, 25 Nov 2021 11:16:39 +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 1APBGa4O022893 for ; Thu, 25 Nov 2021 06:16:36 -0500 Received: by smtp.corp.redhat.com (Postfix) id B8DF1104B4DE; Thu, 25 Nov 2021 11:16:36 +0000 (UTC) Received: from antique-work.redhat.com (unknown [10.40.194.97]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3615F1002390 for ; Thu, 25 Nov 2021 11:16:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1637839008; 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=zeG/Jh7X1RUpyZwEb8e3GETGXO7A4kDGi8GENRbUvpE=; b=OSDL4IKcSXIOLkBPXtFkQ688TfnVN7i93Mn3bOuNXQO8LieWjmHZeW3QP69rT0PagVRPmM V/9dbuLtvm+Z5N/23hIbiXZJ4Ciw6Szx0Z+tvVc8otMeCN9Gy8KskamDDBZIxhbOXcHPOp LENRwLolB2niWrEFFc3Rg0dW31+Uo50= X-MC-Unique: lgWpOLvJOX-BhVsjbg0Mlg-1 From: Pavel Hrdina To: libvir-list@redhat.com Subject: [libvirt PATCH 09/11] qemu_snapshot: create: move snapshot redefine to separate function Date: Thu, 25 Nov 2021 12:16:15 +0100 Message-Id: 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: 1637839011197100002 Content-Type: text/plain; charset="utf-8" Signed-off-by: Pavel Hrdina Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_snapshot.c | 61 ++++++++++++++++++++++++++++++---------- 1 file changed, 46 insertions(+), 15 deletions(-) diff --git a/src/qemu/qemu_snapshot.c b/src/qemu/qemu_snapshot.c index ce16236224..d22f0522ed 100644 --- a/src/qemu/qemu_snapshot.c +++ b/src/qemu/qemu_snapshot.c @@ -1715,6 +1715,48 @@ qemuSnapshotCreateWriteMetadata(virDomainObj *vm, } =20 =20 +static virDomainSnapshotPtr +qemuSnapshotRedefine(virDomainObj *vm, + virDomainPtr domain, + virDomainSnapshotDef *def, + virQEMUDriver *driver, + virQEMUDriverConfig *cfg, + unsigned int flags) +{ + virDomainMomentObj *snap =3D NULL; + virDomainSnapshotPtr ret =3D NULL; + + if (virDomainSnapshotRedefinePrep(vm, &def, &snap, + driver->xmlopt, + flags) < 0) + return NULL; + + if (!snap) { + if (!(snap =3D virDomainSnapshotAssignDef(vm->snapshots, def))) + 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? */ + + if (flags & VIR_DOMAIN_SNAPSHOT_CREATE_CURRENT) + qemuSnapshotSetCurrent(vm, snap); + + if (qemuSnapshotCreateWriteMetadata(vm, snap, driver, cfg) < 0) + goto error; + + ret =3D virGetDomainSnapshot(domain, snap->def->name); + if (!ret) + goto error; + + return ret; + + error: + virDomainSnapshotObjListRemove(vm->snapshots, snap); + return NULL; +} + + virDomainSnapshotPtr qemuSnapshotCreateXML(virDomainPtr domain, virDomainObj *vm, @@ -1772,15 +1814,8 @@ qemuSnapshotCreateXML(virDomainPtr domain, qemuDomainObjSetAsyncJobMask(vm, QEMU_JOB_NONE); =20 if (redefine) { - if (virDomainSnapshotRedefinePrep(vm, &def, &snap, - driver->xmlopt, - flags) < 0) - goto endjob; - - if (!snap) { - if (!(snap =3D virDomainSnapshotAssignDef(vm->snapshots, def))) - goto endjob; - } + snapshot =3D qemuSnapshotRedefine(vm, domain, def, driver, cfg, fl= ags); + goto endjob; } else { virDomainMomentObj *current =3D NULL; =20 @@ -1802,11 +1837,7 @@ qemuSnapshotCreateXML(virDomainPtr domain, } =20 /* actually do the snapshot */ - if (redefine) { - /* 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? */ - } else if (virDomainObjIsActive(vm)) { + if (virDomainObjIsActive(vm)) { if (flags & VIR_DOMAIN_SNAPSHOT_CREATE_DISK_ONLY || virDomainSnapshotObjGetDef(snap)->memory =3D=3D VIR_DOMAIN_SNA= PSHOT_LOCATION_EXTERNAL) { /* external full system or disk snapshot */ @@ -1840,7 +1871,7 @@ qemuSnapshotCreateXML(virDomainPtr domain, goto endjob; =20 if (!(flags & VIR_DOMAIN_SNAPSHOT_CREATE_NO_METADATA)) { - if (!redefine || (flags & VIR_DOMAIN_SNAPSHOT_CREATE_CURRENT)) + if ((flags & VIR_DOMAIN_SNAPSHOT_CREATE_CURRENT)) qemuSnapshotSetCurrent(vm, snap); =20 if (qemuSnapshotCreateWriteMetadata(vm, snap, driver, cfg) < 0) { --=20 2.31.1 From nobody Fri Apr 26 04:55:58 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=1637839082; cv=none; d=zohomail.com; s=zohoarc; b=j5t/1FFELFag+069X7j+tEc5U0+sLN2vf9KO/BHremyPUKOjm6WslsR9ShxSrJOvUO2e9aP++dfuBWln+LWSxJN3AeggbNYRik/Gv1kr4FJ+P2jZ7HjXhCWpVQNKPT4a7pBLfloCvwWtOBK+U8NlivoD3ReVD4pQCZ9KeVjTei4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1637839082; 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=cJSYr/8g0OAJoHjmC/Dqk+2uoJIPPwC2oevyuox0vh8=; b=cFc7VyEldeIP2v+2xV+DccRci/cM5gTOa28SMVLZxgVbr6Lg1y8qZgx1mQERKIvT6AH+Nh6bcN8DAZOiw3d9UeeuBdWHz2kpxTibzE7TE2VvGfSTtKtHiYfGcL1tVMvXS7qSWfPIiLRxPnoEFMn0tXROG3QVB4AnZmBcGoxaQas= 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 1637839082885607.39553327623; Thu, 25 Nov 2021 03:18: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-282-jeTXGP54P8CjJddY3FpJ7Q-1; Thu, 25 Nov 2021 06:16:49 -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 A225D83DB64; Thu, 25 Nov 2021 11:16:44 +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 8347A7945B; Thu, 25 Nov 2021 11:16:44 +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 54AA81806D2C; Thu, 25 Nov 2021 11:16:44 +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 1APBGhB7022919 for ; Thu, 25 Nov 2021 06:16:43 -0500 Received: by smtp.corp.redhat.com (Postfix) id B9B6B1042A90; Thu, 25 Nov 2021 11:16:43 +0000 (UTC) Received: from antique-work.redhat.com (unknown [10.40.194.97]) by smtp.corp.redhat.com (Postfix) with ESMTP id 36A44104B4DE for ; Thu, 25 Nov 2021 11:16:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1637839081; 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=cJSYr/8g0OAJoHjmC/Dqk+2uoJIPPwC2oevyuox0vh8=; b=VmD+ey2FZ6F8QWN2zU8TyBrvbKY5JMmBxmygZMIteBjv+9hvwgzlHciGVuU5e3UnpHG58n pQGHk62ZgSRZYwwpJ4MSRapHyNB3+pRyFIsfa8MEyrTJOzSM0z85cn0B3+Exsk0YTtSaqa vYsQIN5TWZ7F1SycK0IHyqyzL4PR/tg= X-MC-Unique: jeTXGP54P8CjJddY3FpJ7Q-1 From: Pavel Hrdina To: libvir-list@redhat.com Subject: [libvirt PATCH 10/11] qemu_snapshot: create: move snapshot create to separate function Date: Thu, 25 Nov 2021 12:16:16 +0100 Message-Id: <6a833135fd2b5514d14dbf2ddbd18d8e703015cf.1637838934.git.phrdina@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.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: 1637839084557100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: Pavel Hrdina Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_snapshot.c | 149 ++++++++++++++++++++------------------- 1 file changed, 76 insertions(+), 73 deletions(-) diff --git a/src/qemu/qemu_snapshot.c b/src/qemu/qemu_snapshot.c index d22f0522ed..c5f0a5afe8 100644 --- a/src/qemu/qemu_snapshot.c +++ b/src/qemu/qemu_snapshot.c @@ -1757,6 +1757,81 @@ qemuSnapshotRedefine(virDomainObj *vm, } =20 =20 +static virDomainSnapshotPtr +qemuSnapshotCreate(virDomainObj *vm, + virDomainPtr domain, + virDomainSnapshotDef *def, + virQEMUDriver *driver, + virQEMUDriverConfig *cfg, + unsigned int flags) +{ + + virDomainMomentObj *snap =3D NULL; + virDomainMomentObj *current =3D NULL; + virDomainSnapshotPtr ret =3D NULL; + + if (qemuSnapshotAlignDisks(vm, def, driver, flags) < 0) + return NULL; + + if (qemuSnapshotPrepare(vm, def, &flags) < 0) + return NULL; + + if (!(snap =3D virDomainSnapshotAssignDef(vm->snapshots, def))) + return NULL; + + virObjectRef(def); + + current =3D virDomainSnapshotGetCurrent(vm->snapshots); + if (current) { + snap->def->parent_name =3D g_strdup(current->def->name); + } + + /* actually do the snapshot */ + if (virDomainObjIsActive(vm)) { + if (flags & VIR_DOMAIN_SNAPSHOT_CREATE_DISK_ONLY || + virDomainSnapshotObjGetDef(snap)->memory =3D=3D VIR_DOMAIN_SNA= PSHOT_LOCATION_EXTERNAL) { + /* external full system or disk snapshot */ + if (qemuSnapshotCreateActiveExternal(driver, vm, snap, cfg, fl= ags) < 0) + goto error; + } else { + /* internal full system */ + if (qemuSnapshotCreateActiveInternal(driver, vm, snap, flags) = < 0) + goto error; + } + } else { + /* inactive; qemuSnapshotPrepare guaranteed that we + * aren't mixing internal and external, and altered flags to + * contain DISK_ONLY if there is an external disk. */ + if (flags & VIR_DOMAIN_SNAPSHOT_CREATE_DISK_ONLY) { + bool reuse =3D !!(flags & VIR_DOMAIN_SNAPSHOT_CREATE_REUSE_EXT= ); + + if (qemuSnapshotCreateInactiveExternal(driver, vm, snap, reuse= ) < 0) + goto error; + } else { + if (qemuSnapshotCreateInactiveInternal(driver, vm, snap) < 0) + goto error; + } + } + + if (!(flags & VIR_DOMAIN_SNAPSHOT_CREATE_NO_METADATA)) { + qemuSnapshotSetCurrent(vm, snap); + + if (qemuSnapshotCreateWriteMetadata(vm, snap, driver, cfg) < 0) + goto error; + } + + ret =3D virGetDomainSnapshot(domain, snap->def->name); + if (!ret) + goto error; + + return ret; + + error: + virDomainSnapshotObjListRemove(vm->snapshots, snap); + return NULL; +} + + virDomainSnapshotPtr qemuSnapshotCreateXML(virDomainPtr domain, virDomainObj *vm, @@ -1764,7 +1839,6 @@ qemuSnapshotCreateXML(virDomainPtr domain, unsigned int flags) { virQEMUDriver *driver =3D domain->conn->privateData; - virDomainMomentObj *snap =3D NULL; virDomainSnapshotPtr snapshot =3D NULL; bool redefine =3D flags & VIR_DOMAIN_SNAPSHOT_CREATE_REDEFINE; g_autoptr(virQEMUDriverConfig) cfg =3D virQEMUDriverGetConfig(driver); @@ -1815,81 +1889,10 @@ qemuSnapshotCreateXML(virDomainPtr domain, =20 if (redefine) { snapshot =3D qemuSnapshotRedefine(vm, domain, def, driver, cfg, fl= ags); - goto endjob; } else { - virDomainMomentObj *current =3D NULL; - - if (qemuSnapshotAlignDisks(vm, def, driver, flags) < 0) - goto endjob; - - if (qemuSnapshotPrepare(vm, def, &flags) < 0) - goto endjob; - - if (!(snap =3D virDomainSnapshotAssignDef(vm->snapshots, def))) - goto endjob; - - def =3D NULL; - - current =3D virDomainSnapshotGetCurrent(vm->snapshots); - if (current) { - snap->def->parent_name =3D g_strdup(current->def->name); - } + snapshot =3D qemuSnapshotCreate(vm, domain, def, driver, cfg, flag= s); } =20 - /* actually do the snapshot */ - if (virDomainObjIsActive(vm)) { - if (flags & VIR_DOMAIN_SNAPSHOT_CREATE_DISK_ONLY || - virDomainSnapshotObjGetDef(snap)->memory =3D=3D VIR_DOMAIN_SNA= PSHOT_LOCATION_EXTERNAL) { - /* external full system or disk snapshot */ - if (qemuSnapshotCreateActiveExternal(driver, vm, snap, cfg, fl= ags) < 0) - goto endjob; - } else { - /* internal full system */ - if (qemuSnapshotCreateActiveInternal(driver, vm, snap, flags) = < 0) - goto endjob; - } - } else { - /* inactive; qemuSnapshotPrepare guaranteed that we - * aren't mixing internal and external, and altered flags to - * contain DISK_ONLY if there is an external disk. */ - if (flags & VIR_DOMAIN_SNAPSHOT_CREATE_DISK_ONLY) { - bool reuse =3D !!(flags & VIR_DOMAIN_SNAPSHOT_CREATE_REUSE_EXT= ); - - if (qemuSnapshotCreateInactiveExternal(driver, vm, snap, reuse= ) < 0) - goto endjob; - } else { - if (qemuSnapshotCreateInactiveInternal(driver, vm, snap) < 0) - goto endjob; - } - } - - /* If we fail after this point, there's not a whole lot we can - * do; we've successfully taken the snapshot, and we are now running - * on it, so we have to go forward the best we can - */ - if (!(snapshot =3D virGetDomainSnapshot(domain, snap->def->name))) - goto endjob; - - if (!(flags & VIR_DOMAIN_SNAPSHOT_CREATE_NO_METADATA)) { - if ((flags & VIR_DOMAIN_SNAPSHOT_CREATE_CURRENT)) - qemuSnapshotSetCurrent(vm, snap); - - if (qemuSnapshotCreateWriteMetadata(vm, snap, driver, cfg) < 0) { - /* if writing of metadata fails, error out rather than trying - * to silently carry on without completing the snapshot */ - virObjectUnref(snapshot); - snapshot =3D NULL; - goto endjob; - } - - snap =3D NULL; - } - - endjob: - - if (snap) - virDomainSnapshotObjListRemove(vm->snapshots, snap); - qemuDomainObjEndAsyncJob(driver, vm); =20 return snapshot; --=20 2.31.1 From nobody Fri Apr 26 04:55:58 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=1637839017; cv=none; d=zohomail.com; s=zohoarc; b=Iz3TAByam1NK5Zl100fRmwlnAAtC62bXlo7ZrzANdlJcUeMC5m09wQbz/lBk1h4nAkKSeaPuLSmhz/cvpjky8HDjpAHP4rOK3aQdRxvMzLmq4Ho5MVW/uaBKXk2lCtRIXi57kLUP5r3SJOvt02l+cg51geOmw0kozhR9JhOnN5A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1637839017; 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=AhiTcdQoHlKXHKoXW4I6qCns0TBOok5XqQmKcHaDD8M=; b=IlmbBn2ZqAam1O19N6Sq/g+NwfK2sluvZuBV7ylgs/jrWqwhSnRyNWuJH/uD368sz2Agna2EySMtRkMRLjcH+1hqOQTcq7SvtAt/MQs3lEO++gGHUHmH+bDevx+z3Gb9ak4GzG/zlfepUkoHvrQlHli9gzADz9A7N9MGoDT46Kk= 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 1637839017652377.03952743386446; Thu, 25 Nov 2021 03:16: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-353-X016PrH6O76qx93jTJQZ1Q-1; Thu, 25 Nov 2021 06:16:53 -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 20384101AFCC; Thu, 25 Nov 2021 11:16:48 +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 0182557BE; Thu, 25 Nov 2021 11:16:48 +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 CA6D61806D2E; Thu, 25 Nov 2021 11:16:47 +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 1APBGkO1022941 for ; Thu, 25 Nov 2021 06:16:46 -0500 Received: by smtp.corp.redhat.com (Postfix) id 755ED1042A90; Thu, 25 Nov 2021 11:16:46 +0000 (UTC) Received: from antique-work.redhat.com (unknown [10.40.194.97]) by smtp.corp.redhat.com (Postfix) with ESMTP id E627E104B4E0 for ; Thu, 25 Nov 2021 11:16:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1637839016; 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=AhiTcdQoHlKXHKoXW4I6qCns0TBOok5XqQmKcHaDD8M=; b=ZmIQlZRg3lms9T4NbrNwH5SGbGPEKYoNytkEU0dMq29ei8JzcAmLjPb6cbgJygJVWHwkSp bRyMqVteS9zp2IGnANp7yB6gRHYs6TRokimUM5Hl7j1QRZ6NphWeU8EwxJ4/WNuliBwG6X YkIi9YMD9BnvBO5S17aOw09vVZIntLA= X-MC-Unique: X016PrH6O76qx93jTJQZ1Q-1 From: Pavel Hrdina To: libvir-list@redhat.com Subject: [libvirt PATCH 11/11] qemu_snapshot: create: drop redefine boolean Date: Thu, 25 Nov 2021 12:16:17 +0100 Message-Id: <66e886ed961650a1d4fb9553e9e6c10a3f3dc091.1637838934.git.phrdina@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: 1637839018759100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: Pavel Hrdina Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_snapshot.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/qemu/qemu_snapshot.c b/src/qemu/qemu_snapshot.c index c5f0a5afe8..2b4d8e801b 100644 --- a/src/qemu/qemu_snapshot.c +++ b/src/qemu/qemu_snapshot.c @@ -1840,7 +1840,6 @@ qemuSnapshotCreateXML(virDomainPtr domain, { virQEMUDriver *driver =3D domain->conn->privateData; virDomainSnapshotPtr snapshot =3D NULL; - bool redefine =3D flags & VIR_DOMAIN_SNAPSHOT_CREATE_REDEFINE; g_autoptr(virQEMUDriverConfig) cfg =3D virQEMUDriverGetConfig(driver); g_autoptr(virDomainSnapshotDef) def =3D NULL; =20 @@ -1887,7 +1886,7 @@ qemuSnapshotCreateXML(virDomainPtr domain, =20 qemuDomainObjSetAsyncJobMask(vm, QEMU_JOB_NONE); =20 - if (redefine) { + if (flags & VIR_DOMAIN_SNAPSHOT_CREATE_REDEFINE) { snapshot =3D qemuSnapshotRedefine(vm, domain, def, driver, cfg, fl= ags); } else { snapshot =3D qemuSnapshotCreate(vm, domain, def, driver, cfg, flag= s); --=20 2.31.1