From nobody Mon Feb 9 16:12:59 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=quarantine dis=quarantine) header.from=virtuozzo.com ARC-Seal: i=1; a=rsa-sha256; t=1604404978; cv=none; d=zohomail.com; s=zohoarc; b=Q9IZhMDScHb6aBNP1cTrPrRYNeR3MNnfrz8IQbXhRdmG/vUeG/HN+VAZ7JVWZc6Cs0fQQrTXHZnilH2j4HDiIBSIOIH1lDmaQbVj+KGwRf/8ZfUhT6yAed8XV7PCMbpA15TgZfh3kiobHjxUISaHw8P+WVfQPjw3/7uwIHLOWyU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1604404978; h=Content-Type:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=L/ioupDdQcbykVncIiMwYTH9n6rspZ7oMaDrvtBRkKw=; b=WYTruCMlTP0NjmYWgTb/7PLyv5CdwmPXfNpLQiuXIqknKFEdRzqy0J98MKZMO1vtt/051FA7sQUe+UlwwepsMG0bkIJ/pTLIWIPhC35wQmSHj3GAvsrtmIrgBO0lwxdSIABMkUc5cqqUb25G+9pYVQaJvybCRpgITrlx07/gqQM= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail header.from= (p=quarantine dis=quarantine) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by mx.zohomail.com with SMTPS id 1604404978293692.2675844872302; Tue, 3 Nov 2020 04:02:58 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-206-LXGwBWpoNCqYSg3zxMLOxA-1; Tue, 03 Nov 2020 07:02:52 -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 1A1B71007466; Tue, 3 Nov 2020 12:02:47 +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 ED19C5DA71; Tue, 3 Nov 2020 12:02:46 +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 BAF32181A050; Tue, 3 Nov 2020 12:02:46 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 0A3C2cbQ011915 for ; Tue, 3 Nov 2020 07:02:38 -0500 Received: by smtp.corp.redhat.com (Postfix) id 64ACC207A53C; Tue, 3 Nov 2020 12:02:38 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast02.extmail.prod.ext.rdu2.redhat.com [10.11.55.18]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 5FFBF2068FE5 for ; Tue, 3 Nov 2020 12:02:31 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-1.mimecast.com [207.211.31.81]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id D966B801224 for ; Tue, 3 Nov 2020 12:02:31 +0000 (UTC) Received: from relay3.sw.ru (relay.sw.ru [185.231.240.75]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-573-Dr3g47n2OrCePU6sWr5gTA-1; Tue, 03 Nov 2020 07:02:29 -0500 Received: from [10.28.15.159] (helo=vz7.sw.ru) by relay3.sw.ru with esmtp (Exim 4.94) (envelope-from ) id 1kZv0p-007EMR-3w for libvir-list@redhat.com; Tue, 03 Nov 2020 15:02:07 +0300 X-MC-Unique: LXGwBWpoNCqYSg3zxMLOxA-1 X-MC-Unique: Dr3g47n2OrCePU6sWr5gTA-1 From: Nikolay Shirokovskiy To: libvir-list@redhat.com Subject: [PATCH v2 09/10] qemu: qemuDomainDefineXMLFlags: move cleanup logic to cleanup section Date: Tue, 3 Nov 2020 15:00:07 +0300 Message-Id: <1604404808-825155-10-git-send-email-nshirokovskiy@virtuozzo.com> In-Reply-To: <1604404808-825155-1-git-send-email-nshirokovskiy@virtuozzo.com> References: <1604404808-825155-1-git-send-email-nshirokovskiy@virtuozzo.com> X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 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: 2 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Let's move objlist restoring to cleanup section so that we can handle failu= re of actions between virDomainObjListAdd and virDomainDefSave. We are going to add such actions in next patch. Signed-off-by: Nikolay Shirokovskiy --- src/qemu/qemu_driver.c | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 86ff74f..6c353a5 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -6705,7 +6705,7 @@ qemuDomainDefineXMLFlags(virConnectPtr conn, =20 if (!(def =3D virDomainDefParseString(xml, driver->xmlopt, NULL, parse_flags))) - goto cleanup; + return NULL; =20 if (virXMLCheckIllegalChars("name", def->name, "\n") < 0) goto cleanup; @@ -6719,10 +6719,23 @@ qemuDomainDefineXMLFlags(virConnectPtr conn, goto cleanup; def =3D NULL; =20 + if (virDomainDefSave(vm->newDef ? vm->newDef : vm->def, + driver->xmlopt, cfg->configDir) < 0) + goto cleanup; + vm->persistent =3D 1; =20 - if (virDomainDefSave(vm->newDef ? vm->newDef : vm->def, - driver->xmlopt, cfg->configDir) < 0) { + event =3D virDomainEventLifecycleNewFromObj(vm, + VIR_DOMAIN_EVENT_DEFINED, + !oldDef ? + VIR_DOMAIN_EVENT_DEFINED_ADDED : + VIR_DOMAIN_EVENT_DEFINED_UPDATED); + + VIR_INFO("Creating domain '%s'", vm->def->name); + dom =3D virGetDomain(conn, vm->def->name, vm->def->uuid, vm->def->id); + + cleanup: + if (!dom && !def) { if (oldDef) { /* There is backup so this VM was defined before. * Just restore the backup. */ @@ -6735,22 +6748,9 @@ qemuDomainDefineXMLFlags(virConnectPtr conn, } else { /* Brand new domain. Remove it */ VIR_INFO("Deleting domain '%s'", vm->def->name); - vm->persistent =3D 0; qemuDomainRemoveInactiveJob(driver, vm); } - goto cleanup; } - - event =3D virDomainEventLifecycleNewFromObj(vm, - VIR_DOMAIN_EVENT_DEFINED, - !oldDef ? - VIR_DOMAIN_EVENT_DEFINED_ADDED : - VIR_DOMAIN_EVENT_DEFINED_UPDATED); - - VIR_INFO("Creating domain '%s'", vm->def->name); - dom =3D virGetDomain(conn, vm->def->name, vm->def->uuid, vm->def->id); - - cleanup: virDomainDefFree(oldDef); virDomainDefFree(def); virDomainObjEndAPI(&vm); --=20 1.8.3.1