From nobody Mon Feb 9 19:04:25 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) client-ip=207.211.31.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=virtuozzo.com ARC-Seal: i=1; a=rsa-sha256; t=1583223622; cv=none; d=zohomail.com; s=zohoarc; b=nd2wYgn97FVkOzwK/Q9QsSueyzo0duBfUNcs9DpRPTE5bYFdVVTbhQAkW255zZPJGnPmPHY2mHOsfSyhJX/mOHQpwMQ0G3UDgB6B8zrd43UnMOUhBTIQhZh+rcTU4443RhgQn8wtGeasKtPT1Iuyd8t5g5z4GwjQq04Yq3fo1FM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1583223622; 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=5JV+/WR0f2oeZK/UmxVdvIQWMFimz/deTzhNmpVebFc=; b=RKwuUcTytH6o8zwfco9xWU3+RnnlijkpmgDRqcDJAx90gISPNSpEzccS1jIcns+Qm6ChRYCU3Yilhmq3ieTt1cJ3e0pafB4c21BiWdKKuwmCqj58oep4epV046M4cuJKywSzaRqo1Urqifqr2w2C1Q2dHwXzm26ojKrDh9p/8Cg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by mx.zohomail.com with SMTPS id 1583223622176209.2505353904446; Tue, 3 Mar 2020 00:20:22 -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-225-4uNSnnNBNcKBy2lRaTC2bQ-1; Tue, 03 Mar 2020 03:20:19 -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 081EC19067E0; Tue, 3 Mar 2020 08:20:13 +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 CFDCB5C1D6; Tue, 3 Mar 2020 08:20:12 +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 706D21808878; Tue, 3 Mar 2020 08:20:12 +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 0238JllN003655 for ; Tue, 3 Mar 2020 03:19:47 -0500 Received: by smtp.corp.redhat.com (Postfix) id 56FA12063211; Tue, 3 Mar 2020 08:19:47 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast06.extmail.prod.ext.rdu2.redhat.com [10.11.55.22]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 4FBDE206320C for ; Tue, 3 Mar 2020 08:19:44 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) (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 90B81185A78E for ; Tue, 3 Mar 2020 08:19:44 +0000 (UTC) Received: from relay.sw.ru (relay.sw.ru [185.231.240.75]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-452-kwn-3pK4Ok6zcPE_vGS9iw-1; Tue, 03 Mar 2020 03:19:42 -0500 Received: from dhcp-172-16-24-106.sw.ru ([172.16.24.106] helo=shiny.sw.ru) by relay.sw.ru with esmtp (Exim 4.92.3) (envelope-from ) id 1j92mB-0002uR-Lf for libvir-list@redhat.com; Tue, 03 Mar 2020 11:19:39 +0300 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1583223621; 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=5JV+/WR0f2oeZK/UmxVdvIQWMFimz/deTzhNmpVebFc=; b=dTTiH98qW6sV02XJ5JAJUyy3KMBDrXsqPy1ifMQUj17OEAL3/XGOOkq4kTG1PZr8DfVx07 d4dm6hkhqvdxjCouDK5oW27IjDIbnWcmRqajchIb8ZZiNhXS/9bBNkJHZmVffd+114oaLd TWP861MF/bo+6JXtjW8Z0yoqlohGVUo= X-MC-Unique: 4uNSnnNBNcKBy2lRaTC2bQ-1 X-MC-Unique: kwn-3pK4Ok6zcPE_vGS9iw-1 From: Nikolay Shirokovskiy To: libvir-list@redhat.com Subject: [PATCH 7/8] qemu: refactor qemuDomainDefineXMLFlags Date: Tue, 3 Mar 2020 11:19:21 +0300 Message-Id: <20200303081922.9157-8-nshirokovskiy@virtuozzo.com> In-Reply-To: <20200303081922.9157-1-nshirokovskiy@virtuozzo.com> References: <20200303081922.9157-1-nshirokovskiy@virtuozzo.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-MIME-Autoconverted: from quoted-printable to 8bit by lists01.pubmisc.prod.ext.phx2.redhat.com id 0238JllN003655 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 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Let's move objlist restoring to cleanup section so that we can handle failure of actions between virDomainObjListAdd and virDomainDefSave. 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 4553ebfb80..e1b9240893 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -7630,7 +7630,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; @@ -7644,10 +7644,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 (!def) { if (oldDef) { /* There is backup so this VM was defined before. * Just restore the backup. */ @@ -7660,22 +7673,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 2.23.0