From nobody Sat May 4 12:26:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 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=1559208891; cv=none; d=zoho.com; s=zohoarc; b=LaBJeMyqjhuP2rBAqAIFGqecyK6uTQv8f1Ng53DHKC01dnau2ElOQqJzQgI5NZ+SHzv7gOIoFgQ1G7Cbwykf0zV5WVwuzrBum6O8WR83HR7ip0YuljijbW82t0yF1Wn1VfLQ1crxOPGBiHf0uGHzKtyGeDqCk4PxidSHY4tmYPg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1559208891; h=Content-Type:Content-Transfer-Encoding:Cc: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:ARC-Authentication-Results; bh=PNb2fG+Y4sSVr1fz7G28CWxr/Rc8oObLpfIxDT9/AsY=; b=JcNa6YUaAVh0tVQtcJzEPBxK+QQEuNuAkuW12FUk13ehBl68U+vmmp53HrqqOQ2+I2RqADKDcnxsSxg6slNOC1UBAuzLPLWExz0cyd+XgfIi0IeNh5yYPsUL8gOWSDOM6GQNzt/c152Eld2KE1e+d/o31thNlcNQAEDrw60v9To= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1559208891389115.2107796365857; Thu, 30 May 2019 02:34:51 -0700 (PDT) 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 mx1.redhat.com (Postfix) with ESMTPS id 12D39C13070F; Thu, 30 May 2019 09:34:34 +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 7B1B91724A; Thu, 30 May 2019 09:34:25 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 1ECA21806B0F; Thu, 30 May 2019 09:34:12 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x4U9YATF027453 for ; Thu, 30 May 2019 05:34:10 -0400 Received: by smtp.corp.redhat.com (Postfix) id 9BB4D60C7E; Thu, 30 May 2019 09:34:10 +0000 (UTC) Received: from moe.brq.redhat.com (unknown [10.43.2.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id F32B97D536; Thu, 30 May 2019 09:34:09 +0000 (UTC) From: Michal Privoznik To: libvir-list@redhat.com Date: Thu, 30 May 2019 11:33:56 +0200 Message-Id: <96158fedd7e6a3fe0bb68c58298991b917536712.1559208506.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com Cc: nshirokovskiy@virtuozzo.com Subject: [libvirt] [PATCH 1/9] virDomainObjListAddLocked: Drop useless @cleanup label 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: , Content-Transfer-Encoding: quoted-printable 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-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Thu, 30 May 2019 09:34:49 +0000 (UTC) Content-Type: text/plain; charset="utf-8" It's a premature optimization. It's perfectly acceptable for 'error' label to deal with @vm =3D=3D NULL case. Signed-off-by: Michal Privoznik Reviewed-by: Nikolay Shirokovskiy --- src/conf/virdomainobjlist.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/conf/virdomainobjlist.c b/src/conf/virdomainobjlist.c index f5a7ecc4a4..d58d25f847 100644 --- a/src/conf/virdomainobjlist.c +++ b/src/conf/virdomainobjlist.c @@ -332,7 +332,7 @@ virDomainObjListAddLocked(virDomainObjListPtr doms, } =20 if (!(vm =3D virDomainObjNew(xmlopt))) - goto cleanup; + goto error; vm->def =3D def; =20 if (virDomainObjListAddObjLocked(doms, vm) < 0) { @@ -340,7 +340,7 @@ virDomainObjListAddLocked(virDomainObjListPtr doms, goto error; } } - cleanup: + return vm; =20 error: --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sat May 4 12:26:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 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=1559208910; cv=none; d=zoho.com; s=zohoarc; b=LtOiiRngKcCQCS8zwmUYzBhLLphIY4sv197MsYlXqSVRh3EiOvtI6cXlrjNTpap3wMgX+ol0nJu0uqPKQ+iu3veGOIftYs0tILivU7ya0XVzY/P0phGYTO7cjvhxTI+4ifOWwn1R8PljYbj5CLW5F2UTdeqdqLEwogpVVB6OoXY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1559208910; h=Content-Type:Content-Transfer-Encoding:Cc: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:ARC-Authentication-Results; bh=vI52PD/qS5VXtlYzGLvwTWga4Om2AJe32iXtdvHCFN4=; b=JZSHqOgWvecjSMM5z3DxtTsF3+o/TFHX13VMRSXQZiXWtO5B3Lld3riAJQNA59VnXtv1Pck96g0DyQhKB9LVvuouO+Cnwjgfc+37iBwbl0386dW3zzexGmdhtgiUGCrDZRrtOJewDif0xKZ1KmytiBOBrGuSf+myL/dbjq0fuLs= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1559208910107748.4743907831703; Thu, 30 May 2019 02:35:10 -0700 (PDT) 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 mx1.redhat.com (Postfix) with ESMTPS id 520E89FFCB; Thu, 30 May 2019 09:35:08 +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 279BE341EB; Thu, 30 May 2019 09:35:08 +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 CB6251806B18; Thu, 30 May 2019 09:35:06 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x4U9YBp4027458 for ; Thu, 30 May 2019 05:34:11 -0400 Received: by smtp.corp.redhat.com (Postfix) id 8FE2460C7E; Thu, 30 May 2019 09:34:11 +0000 (UTC) Received: from moe.brq.redhat.com (unknown [10.43.2.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id E6FE37D536; Thu, 30 May 2019 09:34:10 +0000 (UTC) From: Michal Privoznik To: libvir-list@redhat.com Date: Thu, 30 May 2019 11:33:57 +0200 Message-Id: <903eedec94da536777b8efa28cbe38a447c87e5c.1559208506.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com Cc: nshirokovskiy@virtuozzo.com Subject: [libvirt] [PATCH 2/9] virDomainObjListAddObjLocked: Don't expect vm->def to be set 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: , Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Thu, 30 May 2019 09:35:08 +0000 (UTC) Content-Type: text/plain; charset="utf-8" In near future vm->def might be not set when calling this function. Therefore, have caller explicitly state what UUID and name the domain object should be stored under. Signed-off-by: Michal Privoznik Reviewed-by: Nikolay Shirokovskiy --- src/conf/virdomainobjlist.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/conf/virdomainobjlist.c b/src/conf/virdomainobjlist.c index d58d25f847..28cccd0035 100644 --- a/src/conf/virdomainobjlist.c +++ b/src/conf/virdomainobjlist.c @@ -223,6 +223,8 @@ virDomainObjListFindByName(virDomainObjListPtr doms, /** * @doms: Domain object list pointer * @vm: Domain object to be added + * @uuid: domain UUID + * @name: domain name * * Upon entry @vm should have at least 1 ref and be locked. * @@ -238,16 +240,18 @@ virDomainObjListFindByName(virDomainObjListPtr doms, */ static int virDomainObjListAddObjLocked(virDomainObjListPtr doms, - virDomainObjPtr vm) + virDomainObjPtr vm, + const unsigned char *uuid, + const char *name) { char uuidstr[VIR_UUID_STRING_BUFLEN]; =20 - virUUIDFormat(vm->def->uuid, uuidstr); + virUUIDFormat(uuid, uuidstr); if (virHashAddEntry(doms->objs, uuidstr, vm) < 0) return -1; virObjectRef(vm); =20 - if (virHashAddEntry(doms->objsName, vm->def->name, vm) < 0) { + if (virHashAddEntry(doms->objsName, name, vm) < 0) { virHashRemoveEntry(doms->objs, uuidstr); return -1; } @@ -335,7 +339,7 @@ virDomainObjListAddLocked(virDomainObjListPtr doms, goto error; vm->def =3D def; =20 - if (virDomainObjListAddObjLocked(doms, vm) < 0) { + if (virDomainObjListAddObjLocked(doms, vm, def->uuid, def->name) <= 0) { vm->def =3D NULL; goto error; } @@ -564,7 +568,7 @@ virDomainObjListLoadStatus(virDomainObjListPtr doms, goto error; } =20 - if (virDomainObjListAddObjLocked(doms, obj) < 0) + if (virDomainObjListAddObjLocked(doms, obj, obj->def->uuid, obj->def->= name) < 0) goto error; =20 if (notify) --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sat May 4 12:26:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 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=1559208891; cv=none; d=zoho.com; s=zohoarc; b=lZkEQxnh8ZHLb9eKf16T3YJqdBitT3HSDn8idoDDIDThU6WTI7DHmETmos+mr/64AOaRCARHhEinbWFj+ADfraODmKoYXzjQ1NUphUBuN9lpdYeuQpcoDZ5VHxRYnRZCSo7Mfa3qQpNwTVEdeHAtewPh4A4laETJn2QVqwFu+hA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1559208891; h=Content-Type:Content-Transfer-Encoding:Cc: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:ARC-Authentication-Results; bh=rc+DHT3k3djjd9D4Op/1eFDwHKezXrG+YRmAFrAl+RM=; b=m8nlqNJO1YNE2ZoTzd4fTnXqbIV4Iyujk+dg7iJUEsxAj5euDxBM1ixHstRvz7il1ziSaR81CdZYjuvZRDKlSVMw3naScLqTJICxmjpg3+ekcBiqXK78lf2YBv1+dUIUoF50JBUE4y+K1tSBAVguhNQCYfcc/JdfBbhebym3jW4= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1559208891282425.49152160969606; Thu, 30 May 2019 02:34:51 -0700 (PDT) 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 mx1.redhat.com (Postfix) with ESMTPS id 8619B30833C1; Thu, 30 May 2019 09:34:34 +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 205685C23E; Thu, 30 May 2019 09:34:28 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id E362F1806B11; Thu, 30 May 2019 09:34:16 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x4U9YCVx027469 for ; Thu, 30 May 2019 05:34:12 -0400 Received: by smtp.corp.redhat.com (Postfix) id 868A860C7E; Thu, 30 May 2019 09:34:12 +0000 (UTC) Received: from moe.brq.redhat.com (unknown [10.43.2.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id DBF9B7D551; Thu, 30 May 2019 09:34:11 +0000 (UTC) From: Michal Privoznik To: libvir-list@redhat.com Date: Thu, 30 May 2019 11:33:58 +0200 Message-Id: <3d96a501fbfc41139d707d0e93c34c6422926614.1559208506.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com Cc: nshirokovskiy@virtuozzo.com Subject: [libvirt] [PATCH 3/9] virDomainObjListAddLocked: Set vm->def only in success path 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: , Content-Transfer-Encoding: quoted-printable 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-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.44]); Thu, 30 May 2019 09:34:49 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Because of past limitation of virDomainObjListAddObjLocked() we had to set vm->def even before the object was on the domains list. Signed-off-by: Michal Privoznik Reviewed-by: Nikolay Shirokovskiy --- src/conf/virdomainobjlist.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/conf/virdomainobjlist.c b/src/conf/virdomainobjlist.c index 28cccd0035..1086aec421 100644 --- a/src/conf/virdomainobjlist.c +++ b/src/conf/virdomainobjlist.c @@ -337,12 +337,11 @@ virDomainObjListAddLocked(virDomainObjListPtr doms, =20 if (!(vm =3D virDomainObjNew(xmlopt))) goto error; + + if (virDomainObjListAddObjLocked(doms, vm, def->uuid, def->name) <= 0) + goto error; + vm->def =3D def; - - if (virDomainObjListAddObjLocked(doms, vm, def->uuid, def->name) <= 0) { - vm->def =3D NULL; - goto error; - } } =20 return vm; --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sat May 4 12:26:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 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=1559208910; cv=none; d=zoho.com; s=zohoarc; b=WtVcR8++aiHys1Blgcozk51IHSQppZmmpPDaiOF+ew/zmUda/+Bfhq5gr5KrXGO1yTcWMTaej6El/FDWUvMtz656+Wzv6H/qIRWrJMUYHQhnTDgs9URZBjwiABOoRbnnt45+d43gJjoAFd7v64gSR2qO3BZ2WJMMJgEdsx27/BQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1559208910; h=Content-Type:Content-Transfer-Encoding:Cc: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:ARC-Authentication-Results; bh=ingXaTPk5/qRyooAL9l+cTBR1V41Bx/6uKvEskR0q8I=; b=LL8LHS7uy1oI96ZrFdZcE/1zgXgOx4rSzF2xjBsHuuL1i1QsyO8pzjDbheRnXFumIiDfG5HfTdcK2SfT4UrQMlv/0oAvuv2GL4f7NV/lbKe4i5l1FMyDHyJTctYhgAZdnnk9uHdm/XUwvWJB4dAspBkBEULFy9o10VQWyZhFPGI= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1559208910024902.8503689351511; Thu, 30 May 2019 02:35:10 -0700 (PDT) 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 mx1.redhat.com (Postfix) with ESMTPS id 506573082E23; Thu, 30 May 2019 09:35:08 +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 2658F1001E77; Thu, 30 May 2019 09:35:07 +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 CDEE224F19; Thu, 30 May 2019 09:35:06 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x4U9YDXH027480 for ; Thu, 30 May 2019 05:34:13 -0400 Received: by smtp.corp.redhat.com (Postfix) id 781982B1CA; Thu, 30 May 2019 09:34:13 +0000 (UTC) Received: from moe.brq.redhat.com (unknown [10.43.2.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id CFBF560C7E; Thu, 30 May 2019 09:34:12 +0000 (UTC) From: Michal Privoznik To: libvir-list@redhat.com Date: Thu, 30 May 2019 11:33:59 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com Cc: nshirokovskiy@virtuozzo.com Subject: [libvirt] [PATCH 4/9] virDomainObjIsActive: Allow vm->def to be NULL 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: , Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.46]); Thu, 30 May 2019 09:35:08 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Signed-off-by: Michal Privoznik Reviewed-by: Nikolay Shirokovskiy --- src/conf/domain_conf.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index fa0756b634..e1b5df7e46 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -2766,7 +2766,7 @@ int virDomainDefValidate(virDomainDefPtr def, static inline bool virDomainObjIsActive(virDomainObjPtr dom) { - return dom->def->id !=3D -1; + return dom->def && dom->def->id !=3D -1; } =20 int virDomainObjCheckActive(virDomainObjPtr dom); --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sat May 4 12:26:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 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=1559208919; cv=none; d=zoho.com; s=zohoarc; b=avkfneofqXF/VIbug0Gnn0AG39wKUdWMGL+0hdLD4W5UfyJRYW8m+mYC/fR05yZx4lGltFbdG4+rU558azl98Gim4PSu8kFeeNkzpuVWuI8y5UGDPwoAkl5u+hJHM4dEjRYdl/WX8TjW/GgNQ0Ns7VsM1wom1FWNuvvK/3T2ULE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1559208919; h=Content-Type:Content-Transfer-Encoding:Cc: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:ARC-Authentication-Results; bh=vS2lYX2uiKLCfFfEESWkpmy44jsn4g8YWU4q3MLbzPU=; b=RPKQsZ8o7r7gMVm0eINLmzPHjCmRWKySGg/mGC31hNRgu0KRowalUwAmWbohR0wbGYK3bSIj0CN7fNyb/yVbx8byMuZQHN87SiJh5IRnS1Zoda0plga9bQdB1qiZYu728LhpUAYBBTx1AjGg2F6u9dk+vyBwOAu8S7rKHq2MZuM= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1559208919106909.3125495504381; Thu, 30 May 2019 02:35:19 -0700 (PDT) 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 mx1.redhat.com (Postfix) with ESMTPS id 448B430BC577; Thu, 30 May 2019 09:35:17 +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 304961017E31; Thu, 30 May 2019 09:35:16 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id D94641806B1A; Thu, 30 May 2019 09:35:14 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x4U9YEJp027485 for ; Thu, 30 May 2019 05:34:14 -0400 Received: by smtp.corp.redhat.com (Postfix) id 91CE860C7E; Thu, 30 May 2019 09:34:14 +0000 (UTC) Received: from moe.brq.redhat.com (unknown [10.43.2.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id C47C02B1CA; Thu, 30 May 2019 09:34:13 +0000 (UTC) From: Michal Privoznik To: libvir-list@redhat.com Date: Thu, 30 May 2019 11:34:00 +0200 Message-Id: <5e4e2c998092aa00f055c3ddabfd201fbfec1b22.1559208506.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com Cc: nshirokovskiy@virtuozzo.com Subject: [libvirt] [PATCH 5/9] virDomainObjListAdd: Leave def assigning as an exercise for caller 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: , Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.49]); Thu, 30 May 2019 09:35:17 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Some driver have concept of jobs (e.g. qemu, lxc, libxl and vz). This means that whenever something wants to modify a domain object it needs to acquire job (to mutually exclude with other threads trying to modify the same object). And aforementioned drivers do that more or less successfully. Except for virDomainObjListAdd() which may modify the domain object without acquiring job. This is harmful because if a thread that's executing say an API in qemu driver unlock a domain object and locks it again the object has changed even though the thread acquired job before. Signed-off-by: Michal Privoznik Reviewed-by: Nikolay Shirokovskiy --- src/bhyve/bhyve_driver.c | 10 ++++++---- src/conf/virdomainobjlist.c | 29 +++++++---------------------- src/conf/virdomainobjlist.h | 3 +-- src/libxl/libxl_driver.c | 22 ++++++++++++---------- src/libxl/libxl_migration.c | 12 ++++++------ src/lxc/lxc_driver.c | 10 +++++----- src/openvz/openvz_conf.c | 12 ++++++------ src/openvz/openvz_driver.c | 17 +++++++++-------- src/qemu/qemu_driver.c | 22 +++++++++++----------- src/qemu/qemu_migration.c | 6 +++--- src/test/test_driver.c | 21 ++++++++++++--------- src/vmware/vmware_conf.c | 4 ++-- src/vmware/vmware_driver.c | 9 ++++----- src/vz/vz_sdk.c | 4 +++- 14 files changed, 87 insertions(+), 94 deletions(-) diff --git a/src/bhyve/bhyve_driver.c b/src/bhyve/bhyve_driver.c index 061888ab0b..23b916406a 100644 --- a/src/bhyve/bhyve_driver.c +++ b/src/bhyve/bhyve_driver.c @@ -540,9 +540,10 @@ bhyveDomainDefineXMLFlags(virConnectPtr conn, const ch= ar *xml, unsigned int flag goto cleanup; =20 if (!(vm =3D virDomainObjListAdd(privconn->domains, def, - privconn->xmlopt, - 0, &oldDef))) + privconn->xmlopt, 0))) goto cleanup; + + virDomainObjAssignDef(vm, def, false, &oldDef); def =3D NULL; vm->persistent =3D 1; =20 @@ -941,9 +942,10 @@ bhyveDomainCreateXML(virConnectPtr conn, =20 if (!(vm =3D virDomainObjListAdd(privconn->domains, def, privconn->xmlopt, - VIR_DOMAIN_OBJ_LIST_ADD_LIVE | - VIR_DOMAIN_OBJ_LIST_ADD_CHECK_LIVE, NUL= L))) + VIR_DOMAIN_OBJ_LIST_ADD_CHECK_LIVE))) goto cleanup; + + virDomainObjAssignDef(vm, def, true, NULL); def =3D NULL; =20 if (virBhyveProcessStart(conn, privconn, vm, diff --git a/src/conf/virdomainobjlist.c b/src/conf/virdomainobjlist.c index 1086aec421..e2b829b91c 100644 --- a/src/conf/virdomainobjlist.c +++ b/src/conf/virdomainobjlist.c @@ -265,12 +265,7 @@ virDomainObjListAddObjLocked(virDomainObjListPtr doms, * virDomainObjListAddLocked: * * If flags & VIR_DOMAIN_OBJ_LIST_ADD_CHECK_LIVE then - * this will refuse updating an existing def if the - * current def is Live - * - * If flags & VIR_DOMAIN_OBJ_LIST_ADD_LIVE then - * the @def being added is assumed to represent a - * live config, not a future inactive config + * this will fail if domain is already active or starting up. * * The returned @vm from this function will be locked and ref * counted. The caller is expected to use virDomainObjEndAPI @@ -280,15 +275,11 @@ static virDomainObjPtr virDomainObjListAddLocked(virDomainObjListPtr doms, virDomainDefPtr def, virDomainXMLOptionPtr xmlopt, - unsigned int flags, - virDomainDefPtr *oldDef) + unsigned int flags) { virDomainObjPtr vm; char uuidstr[VIR_UUID_STRING_BUFLEN]; =20 - if (oldDef) - *oldDef =3D NULL; - /* See if a VM with matching UUID already exists */ if ((vm =3D virDomainObjListFindByUUIDLocked(doms, def->uuid))) { if (vm->removing) { @@ -320,11 +311,6 @@ virDomainObjListAddLocked(virDomainObjListPtr doms, goto error; } } - - virDomainObjAssignDef(vm, - def, - !!(flags & VIR_DOMAIN_OBJ_LIST_ADD_LIVE), - oldDef); } else { /* UUID does not match, but if a name matches, refuse it */ if ((vm =3D virDomainObjListFindByNameLocked(doms, def->name))) { @@ -340,8 +326,6 @@ virDomainObjListAddLocked(virDomainObjListPtr doms, =20 if (virDomainObjListAddObjLocked(doms, vm, def->uuid, def->name) <= 0) goto error; - - vm->def =3D def; } =20 return vm; @@ -355,13 +339,12 @@ virDomainObjListAddLocked(virDomainObjListPtr doms, virDomainObjPtr virDomainObjListAdd(virDomainObjListPtr doms, virDomainDefPtr def, virDomainXMLOptionPtr xmlopt, - unsigned int flags, - virDomainDefPtr *oldDef) + unsigned int flags) { virDomainObjPtr ret; =20 virObjectRWLockWrite(doms); - ret =3D virDomainObjListAddLocked(doms, def, xmlopt, flags, oldDef); + ret =3D virDomainObjListAddLocked(doms, def, xmlopt, flags); virObjectRWUnlock(doms); return ret; } @@ -513,9 +496,11 @@ virDomainObjListLoadConfig(virDomainObjListPtr doms, if ((autostart =3D virFileLinkPointsTo(autostartLink, configFile)) < 0) goto error; =20 - if (!(dom =3D virDomainObjListAddLocked(doms, def, xmlopt, 0, &oldDef)= )) + if (!(dom =3D virDomainObjListAddLocked(doms, def, xmlopt, 0))) goto error; =20 + virDomainObjAssignDef(dom, def, false, &oldDef); + dom->autostart =3D autostart; =20 if (notify) diff --git a/src/conf/virdomainobjlist.h b/src/conf/virdomainobjlist.h index c1ffee76ad..552a7cfaf2 100644 --- a/src/conf/virdomainobjlist.h +++ b/src/conf/virdomainobjlist.h @@ -44,8 +44,7 @@ enum { virDomainObjPtr virDomainObjListAdd(virDomainObjListPtr doms, virDomainDefPtr def, virDomainXMLOptionPtr xmlopt, - unsigned int flags, - virDomainDefPtr *oldDef); + unsigned int flags); =20 typedef int (*virDomainObjListRenameCallback)(virDomainObjPtr dom, const char *new_name, diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c index 2b9c6f1866..809d298ac1 100644 --- a/src/libxl/libxl_driver.c +++ b/src/libxl/libxl_driver.c @@ -603,9 +603,10 @@ libxlAddDom0(libxlDriverPrivatePtr driver) =20 if (!(vm =3D virDomainObjListAdd(driver->domains, def, driver->xmlopt, - 0, - &oldDef))) + 0))) goto cleanup; + + virDomainObjAssignDef(vm, def, false, &oldDef); def =3D NULL; =20 vm->persistent =3D 1; @@ -1031,10 +1032,10 @@ libxlDomainCreateXML(virConnectPtr conn, const char= *xml, =20 if (!(vm =3D virDomainObjListAdd(driver->domains, def, driver->xmlopt, - VIR_DOMAIN_OBJ_LIST_ADD_LIVE | - VIR_DOMAIN_OBJ_LIST_ADD_CHECK_LIVE, - NULL))) + VIR_DOMAIN_OBJ_LIST_ADD_CHECK_LIVE))) goto cleanup; + + virDomainObjAssignDef(vm, def, true, NULL); def =3D NULL; =20 if (libxlDomainObjBeginJob(driver, vm, LIBXL_JOB_MODIFY) < 0) { @@ -1951,10 +1952,10 @@ libxlDomainRestoreFlags(virConnectPtr conn, const c= har *from, =20 if (!(vm =3D virDomainObjListAdd(driver->domains, def, driver->xmlopt, - VIR_DOMAIN_OBJ_LIST_ADD_LIVE | - VIR_DOMAIN_OBJ_LIST_ADD_CHECK_LIVE, - NULL))) + VIR_DOMAIN_OBJ_LIST_ADD_CHECK_LIVE))) goto cleanup; + + virDomainObjAssignDef(vm, def, true, NULL); def =3D NULL; =20 if (libxlDomainObjBeginJob(driver, vm, LIBXL_JOB_MODIFY) < 0) { @@ -2851,9 +2852,10 @@ libxlDomainDefineXMLFlags(virConnectPtr conn, const = char *xml, unsigned int flag =20 if (!(vm =3D virDomainObjListAdd(driver->domains, def, driver->xmlopt, - 0, - &oldDef))) + 0))) goto cleanup; + + virDomainObjAssignDef(vm, def, false, &oldDef); def =3D NULL; =20 vm->persistent =3D 1; diff --git a/src/libxl/libxl_migration.c b/src/libxl/libxl_migration.c index 76bcb66a11..35403380d0 100644 --- a/src/libxl/libxl_migration.c +++ b/src/libxl/libxl_migration.c @@ -568,10 +568,10 @@ libxlDomainMigrationDstPrepareTunnel3(virConnectPtr d= conn, =20 if (!(vm =3D virDomainObjListAdd(driver->domains, *def, driver->xmlopt, - VIR_DOMAIN_OBJ_LIST_ADD_LIVE | - VIR_DOMAIN_OBJ_LIST_ADD_CHECK_LIVE, - NULL))) + VIR_DOMAIN_OBJ_LIST_ADD_CHECK_LIVE))) goto error; + + virDomainObjAssignDef(vm, *def, true, NULL); *def =3D NULL; =20 /* @@ -677,10 +677,10 @@ libxlDomainMigrationDstPrepare(virConnectPtr dconn, =20 if (!(vm =3D virDomainObjListAdd(driver->domains, *def, driver->xmlopt, - VIR_DOMAIN_OBJ_LIST_ADD_LIVE | - VIR_DOMAIN_OBJ_LIST_ADD_CHECK_LIVE, - NULL))) + VIR_DOMAIN_OBJ_LIST_ADD_CHECK_LIVE))) goto error; + + virDomainObjAssignDef(vm, *def, true, NULL); *def =3D NULL; =20 /* diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c index 9db2a02dee..eaf26563f5 100644 --- a/src/lxc/lxc_driver.c +++ b/src/lxc/lxc_driver.c @@ -445,10 +445,10 @@ lxcDomainDefineXMLFlags(virConnectPtr conn, const cha= r *xml, unsigned int flags) } =20 if (!(vm =3D virDomainObjListAdd(driver->domains, def, - driver->xmlopt, - 0, &oldDef))) + driver->xmlopt, 0))) goto cleanup; =20 + virDomainObjAssignDef(vm, def, false, &oldDef); def =3D NULL; vm->persistent =3D 1; =20 @@ -1193,10 +1193,10 @@ lxcDomainCreateXMLWithFiles(virConnectPtr conn, =20 if (!(vm =3D virDomainObjListAdd(driver->domains, def, driver->xmlopt, - VIR_DOMAIN_OBJ_LIST_ADD_LIVE | - VIR_DOMAIN_OBJ_LIST_ADD_CHECK_LIVE, - NULL))) + VIR_DOMAIN_OBJ_LIST_ADD_CHECK_LIVE))) goto cleanup; + + virDomainObjAssignDef(vm, def, true, NULL); def =3D NULL; =20 if (virLXCDomainObjBeginJob(driver, vm, LXC_JOB_MODIFY) < 0) { diff --git a/src/openvz/openvz_conf.c b/src/openvz/openvz_conf.c index be5f89ea45..2ee8af067c 100644 --- a/src/openvz/openvz_conf.c +++ b/src/openvz/openvz_conf.c @@ -517,7 +517,8 @@ int openvzLoadDomains(struct openvz_driver *driver) =20 line =3D outbuf; while (line[0] !=3D '\0') { - unsigned int flags =3D 0; + bool active =3D false; + if (virStrToLong_i(line, &status, 10, &veid) < 0 || *status++ !=3D ' ' || (line =3D strchr(status, '\n')) =3D=3D NULL) { @@ -578,17 +579,16 @@ int openvzLoadDomains(struct openvz_driver *driver) openvzReadMemConf(def, veid); =20 virUUIDFormat(def->uuid, uuidstr); - flags =3D VIR_DOMAIN_OBJ_LIST_ADD_CHECK_LIVE; - if (STRNEQ(status, "stopped")) - flags |=3D VIR_DOMAIN_OBJ_LIST_ADD_LIVE; + active =3D STRNEQ(status, "stopped"); =20 if (!(dom =3D virDomainObjListAdd(driver->domains, def, driver->xmlopt, - flags, - NULL))) + VIR_DOMAIN_OBJ_LIST_ADD_CHECK_LIVE= ))) goto cleanup; =20 + virDomainObjAssignDef(dom, def, active, NULL); + if (STREQ(status, "stopped")) { virDomainObjSetState(dom, VIR_DOMAIN_SHUTOFF, VIR_DOMAIN_SHUTOFF_UNKNOWN); diff --git a/src/openvz/openvz_driver.c b/src/openvz/openvz_driver.c index 39eeb2c12e..6d4f7325b5 100644 --- a/src/openvz/openvz_driver.c +++ b/src/openvz/openvz_driver.c @@ -918,9 +918,10 @@ openvzDomainDefineXMLFlags(virConnectPtr conn, const c= har *xml, unsigned int fla goto cleanup; =20 if (!(vm =3D virDomainObjListAdd(driver->domains, vmdef, - driver->xmlopt, - 0, NULL))) + driver->xmlopt, 0))) goto cleanup; + + virDomainObjAssignDef(vm, vmdef, false, NULL); vmdef =3D NULL; vm->persistent =3D 1; =20 @@ -1007,10 +1008,10 @@ openvzDomainCreateXML(virConnectPtr conn, const cha= r *xml, if (!(vm =3D virDomainObjListAdd(driver->domains, vmdef, driver->xmlopt, - VIR_DOMAIN_OBJ_LIST_ADD_LIVE | - VIR_DOMAIN_OBJ_LIST_ADD_CHECK_LIVE, - NULL))) + VIR_DOMAIN_OBJ_LIST_ADD_CHECK_LIVE))) goto cleanup; + + virDomainObjAssignDef(vm, vmdef, true, NULL); vmdef =3D NULL; /* All OpenVZ domains seem to be persistent - this is a bit of a viola= tion * of this libvirt API which is intended for transient domain creation= */ @@ -2174,10 +2175,10 @@ openvzDomainMigratePrepare3Params(virConnectPtr dco= nn, =20 if (!(vm =3D virDomainObjListAdd(driver->domains, def, driver->xmlopt, - VIR_DOMAIN_OBJ_LIST_ADD_LIVE | - VIR_DOMAIN_OBJ_LIST_ADD_CHECK_LIVE, - NULL))) + VIR_DOMAIN_OBJ_LIST_ADD_CHECK_LIVE))) goto error; + + virDomainObjAssignDef(vm, def, true, NULL); def =3D NULL; =20 if (!uri_in) { diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 42b1ce2521..8bbac339e0 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -1703,10 +1703,10 @@ static virDomainPtr qemuDomainCreateXML(virConnectP= tr conn, =20 if (!(vm =3D virDomainObjListAdd(driver->domains, def, driver->xmlopt, - VIR_DOMAIN_OBJ_LIST_ADD_LIVE | - VIR_DOMAIN_OBJ_LIST_ADD_CHECK_LIVE, - NULL))) + VIR_DOMAIN_OBJ_LIST_ADD_CHECK_LIVE))) goto cleanup; + + virDomainObjAssignDef(vm, def, true, NULL); def =3D NULL; =20 if (qemuProcessBeginJob(driver, vm, VIR_DOMAIN_JOB_OPERATION_START, @@ -6973,10 +6973,10 @@ qemuDomainRestoreFlags(virConnectPtr conn, =20 if (!(vm =3D virDomainObjListAdd(driver->domains, def, driver->xmlopt, - VIR_DOMAIN_OBJ_LIST_ADD_LIVE | - VIR_DOMAIN_OBJ_LIST_ADD_CHECK_LIVE, - NULL))) + VIR_DOMAIN_OBJ_LIST_ADD_CHECK_LIVE))) goto cleanup; + + virDomainObjAssignDef(vm, def, true, NULL); def =3D NULL; =20 if (flags & VIR_DOMAIN_SAVE_RUNNING) @@ -7648,9 +7648,10 @@ qemuDomainDefineXMLFlags(virConnectPtr conn, goto cleanup; =20 if (!(vm =3D virDomainObjListAdd(driver->domains, def, - driver->xmlopt, - 0, &oldDef))) + driver->xmlopt, 0))) goto cleanup; + + virDomainObjAssignDef(vm, def, false, &oldDef); def =3D NULL; =20 vm->persistent =3D 1; @@ -16885,11 +16886,10 @@ static virDomainPtr qemuDomainQemuAttach(virConne= ctPtr conn, =20 if (!(vm =3D virDomainObjListAdd(driver->domains, def, driver->xmlopt, - VIR_DOMAIN_OBJ_LIST_ADD_LIVE | - VIR_DOMAIN_OBJ_LIST_ADD_CHECK_LIVE, - NULL))) + VIR_DOMAIN_OBJ_LIST_ADD_CHECK_LIVE))) goto cleanup; =20 + virDomainObjAssignDef(vm, def, true, NULL); def =3D NULL; =20 if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_MODIFY) < 0) { diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index 32b3040473..9e19c923ee 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -2405,10 +2405,10 @@ qemuMigrationDstPrepareAny(virQEMUDriverPtr driver, =20 if (!(vm =3D virDomainObjListAdd(driver->domains, *def, driver->xmlopt, - VIR_DOMAIN_OBJ_LIST_ADD_LIVE | - VIR_DOMAIN_OBJ_LIST_ADD_CHECK_LIVE, - NULL))) + VIR_DOMAIN_OBJ_LIST_ADD_CHECK_LIVE))) goto cleanup; + + virDomainObjAssignDef(vm, *def, true, NULL); *def =3D NULL; =20 priv =3D vm->privateData; diff --git a/src/test/test_driver.c b/src/test/test_driver.c index 2f58a1da95..e353d7a300 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -913,11 +913,13 @@ testParseDomains(testDriverPtr privconn, !(obj =3D virDomainObjListAdd(privconn->domains, def, privconn->xmlopt, - 0, NULL))) { + 0))) { virDomainDefFree(def); goto error; } =20 + virDomainObjAssignDef(obj, def, false, NULL); + if (testParseDomainSnapshots(privconn, obj, file, ctxt) < 0) goto error; =20 @@ -1620,10 +1622,10 @@ testDomainCreateXML(virConnectPtr conn, const char = *xml, if (!(dom =3D virDomainObjListAdd(privconn->domains, def, privconn->xmlopt, - VIR_DOMAIN_OBJ_LIST_ADD_LIVE | - VIR_DOMAIN_OBJ_LIST_ADD_CHECK_LIVE, - NULL))) + VIR_DOMAIN_OBJ_LIST_ADD_CHECK_LIVE))) goto cleanup; + + virDomainObjAssignDef(dom, def, true, NULL); def =3D NULL; =20 if (testDomainStartState(privconn, dom, VIR_DOMAIN_RUNNING_BOOTED) < 0= ) { @@ -2143,10 +2145,10 @@ testDomainRestoreFlags(virConnectPtr conn, if (!(dom =3D virDomainObjListAdd(privconn->domains, def, privconn->xmlopt, - VIR_DOMAIN_OBJ_LIST_ADD_LIVE | - VIR_DOMAIN_OBJ_LIST_ADD_CHECK_LIVE, - NULL))) + VIR_DOMAIN_OBJ_LIST_ADD_CHECK_LIVE))) goto cleanup; + + virDomainObjAssignDef(dom, def, true, NULL); def =3D NULL; =20 if (testDomainStartState(privconn, dom, VIR_DOMAIN_RUNNING_RESTORED) <= 0) { @@ -2722,9 +2724,10 @@ static virDomainPtr testDomainDefineXMLFlags(virConn= ectPtr conn, if (!(dom =3D virDomainObjListAdd(privconn->domains, def, privconn->xmlopt, - 0, - &oldDef))) + 0))) goto cleanup; + + virDomainObjAssignDef(dom, def, false, &oldDef); def =3D NULL; dom->persistent =3D 1; =20 diff --git a/src/vmware/vmware_conf.c b/src/vmware/vmware_conf.c index 963e7a9876..3ab7125b60 100644 --- a/src/vmware/vmware_conf.c +++ b/src/vmware/vmware_conf.c @@ -169,10 +169,10 @@ vmwareLoadDomains(struct vmware_driver *driver) } =20 if (!(vm =3D virDomainObjListAdd(driver->domains, vmdef, - driver->xmlopt, - 0, NULL))) + driver->xmlopt, 0))) goto cleanup; =20 + virDomainObjAssignDef(vm, vmdef, false, NULL); pDomain =3D vm->privateData; =20 if (VIR_STRDUP(pDomain->vmxPath, vmxPath) < 0) diff --git a/src/vmware/vmware_driver.c b/src/vmware/vmware_driver.c index 1bc8a06c39..d27313095d 100644 --- a/src/vmware/vmware_driver.c +++ b/src/vmware/vmware_driver.c @@ -442,10 +442,10 @@ vmwareDomainDefineXMLFlags(virConnectPtr conn, const = char *xml, unsigned int fla if (!(vm =3D virDomainObjListAdd(driver->domains, vmdef, driver->xmlopt, - VIR_DOMAIN_OBJ_LIST_ADD_CHECK_LIVE, - NULL))) + VIR_DOMAIN_OBJ_LIST_ADD_CHECK_LIVE))) goto cleanup; =20 + virDomainObjAssignDef(vm, vmdef, false, NULL); pDomain =3D vm->privateData; if (VIR_STRDUP(pDomain->vmxPath, vmxPath) < 0) goto cleanup; @@ -702,11 +702,10 @@ vmwareDomainCreateXML(virConnectPtr conn, const char = *xml, if (!(vm =3D virDomainObjListAdd(driver->domains, vmdef, driver->xmlopt, - VIR_DOMAIN_OBJ_LIST_ADD_LIVE | - VIR_DOMAIN_OBJ_LIST_ADD_CHECK_LIVE, - NULL))) + VIR_DOMAIN_OBJ_LIST_ADD_CHECK_LIVE))) goto cleanup; =20 + virDomainObjAssignDef(vm, vmdef, true, NULL); pDomain =3D vm->privateData; if (VIR_STRDUP(pDomain->vmxPath, vmxPath) < 0) goto cleanup; diff --git a/src/vz/vz_sdk.c b/src/vz/vz_sdk.c index 478443298f..4e934ec526 100644 --- a/src/vz/vz_sdk.c +++ b/src/vz/vz_sdk.c @@ -1955,9 +1955,11 @@ prlsdkLoadDomain(vzDriverPtr driver, =20 virObjectLock(driver); if (!(olddom =3D virDomainObjListFindByUUID(driver->domains, def->= uuid))) - dom =3D virDomainObjListAdd(driver->domains, def, driver->xmlo= pt, 0, NULL); + dom =3D virDomainObjListAdd(driver->domains, def, driver->xmlo= pt, 0); virObjectUnlock(driver); =20 + virDomainObjAssignDef(dom, def, false, NULL); + if (olddom) { virDomainDefFree(def); return olddom; --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sat May 4 12:26:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 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=1559208915; cv=none; d=zoho.com; s=zohoarc; b=i2dan4x/TtI69DfPwEZmV4vbkBaPX3feGaYm3yXlNGUh2kfEE5hd3jq3AMHWbMsxg/3fkPCbPs1E2Kxk5NN9W9Gmg5nVGHrLonw+rdghpQ2Fu8QYR5/BYC5iaCusSvKyXf07xyTOvfkYU3+g7lZhKXofdnn3l9iX3JjTFdewHkQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1559208915; h=Content-Type:Content-Transfer-Encoding:Cc: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:ARC-Authentication-Results; bh=vtN9R1wKdMWmcmo9Z9bD0sYfA1bgzcLjdfHRVplVAvo=; b=Un/fnpdCBr1NVnMcBwSf9v/XjGIBhOh/sZqXL6xoCZ8q22myxdk1cz+8dKoMA3rPuGtS6ojWBa2Y8yM7q9c/GofqPyfigAjzfwZjXi1GRAhXZhaGatBEFr8euwk9/3yG6D8KKVnBRiI5BmcksJewVu4VqJzvvdDJRa1+kolc9ho= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1559208915951177.0229823770277; Thu, 30 May 2019 02:35:15 -0700 (PDT) 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 mx1.redhat.com (Postfix) with ESMTPS id 4262E882FB; Thu, 30 May 2019 09:35:14 +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 0D29918662; Thu, 30 May 2019 09:35:14 +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 B9C611806B15; Thu, 30 May 2019 09:35:12 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x4U9YFxK027493 for ; Thu, 30 May 2019 05:34:15 -0400 Received: by smtp.corp.redhat.com (Postfix) id 86C202B1CA; Thu, 30 May 2019 09:34:15 +0000 (UTC) Received: from moe.brq.redhat.com (unknown [10.43.2.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id DD06A60C7E; Thu, 30 May 2019 09:34:14 +0000 (UTC) From: Michal Privoznik To: libvir-list@redhat.com Date: Thu, 30 May 2019 11:34:01 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com Cc: nshirokovskiy@virtuozzo.com Subject: [libvirt] [PATCH 6/9] qemu: Allow vm->def == NULL in job control APIs 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: , Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Thu, 30 May 2019 09:35:14 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Soon we will be acquiring job for every virDomainObjAssignDef() call. This, however, means that in some cases vm->def might not be set just yet. Fortunately, the only thing from domain definition used in qemuDomainObjBeginJob()/qemuDomainObjEndJob() (and friends) is the domain name and even that is used only for debug printings. Therefore, we can safely replace obj->def->name with some NULLSTR() magic. There is one other place where vm->def might be used - qemuDomainObjSaveJob() - but this function does something only for active domains which already have vm->def pointer set. Signed-off-by: Michal Privoznik --- src/qemu/qemu_domain.c | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index e50e84a3b2..c61d39b12b 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -7175,6 +7175,7 @@ qemuDomainObjBeginJobInternal(virQEMUDriverPtr driver, virQEMUDriverConfigPtr cfg =3D virQEMUDriverGetConfig(driver); const char *blocker =3D NULL; const char *agentBlocker =3D NULL; + const char *domName =3D NULLSTR(obj->def ? obj->def->name : NULL); int ret =3D -1; unsigned long long duration =3D 0; unsigned long long agentDuration =3D 0; @@ -7185,7 +7186,7 @@ qemuDomainObjBeginJobInternal(virQEMUDriverPtr driver, qemuDomainJobTypeToString(job), qemuDomainAgentJobTypeToString(agentJob), qemuDomainAsyncJobTypeToString(asyncJob), - obj, obj->def->name, + obj, domName, qemuDomainJobTypeToString(priv->job.active), qemuDomainAgentJobTypeToString(priv->job.agentActive), qemuDomainAsyncJobTypeToString(priv->job.asyncJob)); @@ -7209,7 +7210,7 @@ qemuDomainObjBeginJobInternal(virQEMUDriverPtr driver, if (nowait) goto cleanup; =20 - VIR_DEBUG("Waiting for async job (vm=3D%p name=3D%s)", obj, obj->d= ef->name); + VIR_DEBUG("Waiting for async job (vm=3D%p name=3D%s)", obj, domNam= e); if (virCondWaitUntil(&priv->job.asyncCond, &obj->parent.lock, then= ) < 0) goto error; } @@ -7218,7 +7219,7 @@ qemuDomainObjBeginJobInternal(virQEMUDriverPtr driver, if (nowait) goto cleanup; =20 - VIR_DEBUG("Waiting for job (vm=3D%p name=3D%s)", obj, obj->def->na= me); + VIR_DEBUG("Waiting for job (vm=3D%p name=3D%s)", obj, domName); if (virCondWaitUntil(&priv->job.cond, &obj->parent.lock, then) < 0) goto error; } @@ -7237,7 +7238,7 @@ qemuDomainObjBeginJobInternal(virQEMUDriverPtr driver, VIR_DEBUG("Started job: %s (async=3D%s vm=3D%p name=3D%s)", qemuDomainJobTypeToString(job), qemuDomainAsyncJobTypeToString(priv->job.asyncJob), - obj, obj->def->name); + obj, domName); priv->job.active =3D job; priv->job.owner =3D virThreadSelfID(); priv->job.ownerAPI =3D virThreadJobGet(); @@ -7245,7 +7246,7 @@ qemuDomainObjBeginJobInternal(virQEMUDriverPtr driver, } else { VIR_DEBUG("Started async job: %s (vm=3D%p name=3D%s)", qemuDomainAsyncJobTypeToString(asyncJob), - obj, obj->def->name); + obj, domName); qemuDomainObjResetAsyncJob(priv); if (VIR_ALLOC(priv->job.current) < 0) goto cleanup; @@ -7263,7 +7264,7 @@ qemuDomainObjBeginJobInternal(virQEMUDriverPtr driver, =20 VIR_DEBUG("Started agent job: %s (vm=3D%p name=3D%s job=3D%s async= =3D%s)", qemuDomainAgentJobTypeToString(agentJob), - obj, obj->def->name, + obj, domName, qemuDomainJobTypeToString(priv->job.active), qemuDomainAsyncJobTypeToString(priv->job.asyncJob)); priv->job.agentActive =3D agentJob; @@ -7294,7 +7295,7 @@ qemuDomainObjBeginJobInternal(virQEMUDriverPtr driver, qemuDomainJobTypeToString(job), qemuDomainAgentJobTypeToString(agentJob), qemuDomainAsyncJobTypeToString(asyncJob), - obj->def->name, + domName, qemuDomainJobTypeToString(priv->job.active), qemuDomainAgentJobTypeToString(priv->job.agentActive), qemuDomainAsyncJobTypeToString(priv->job.asyncJob), @@ -7507,13 +7508,14 @@ qemuDomainObjEndJob(virQEMUDriverPtr driver, virDom= ainObjPtr obj) { qemuDomainObjPrivatePtr priv =3D obj->privateData; qemuDomainJob job =3D priv->job.active; + const char *domName =3D NULLSTR(obj->def ? obj->def->name : NULL); =20 priv->jobs_queued--; =20 VIR_DEBUG("Stopping job: %s (async=3D%s vm=3D%p name=3D%s)", qemuDomainJobTypeToString(job), qemuDomainAsyncJobTypeToString(priv->job.asyncJob), - obj, obj->def->name); + obj, domName); =20 qemuDomainObjResetJob(priv); if (qemuDomainTrackJob(job)) @@ -7528,13 +7530,14 @@ qemuDomainObjEndAgentJob(virDomainObjPtr obj) { qemuDomainObjPrivatePtr priv =3D obj->privateData; qemuDomainAgentJob agentJob =3D priv->job.agentActive; + const char *domName =3D NULLSTR(obj->def ? obj->def->name : NULL); =20 priv->jobs_queued--; =20 VIR_DEBUG("Stopping agent job: %s (async=3D%s vm=3D%p name=3D%s)", qemuDomainAgentJobTypeToString(agentJob), qemuDomainAsyncJobTypeToString(priv->job.asyncJob), - obj, obj->def->name); + obj, domName); =20 qemuDomainObjResetAgentJob(priv); /* We indeed need to wake up ALL threads waiting because @@ -7549,6 +7552,7 @@ qemuDomainObjEndJobWithAgent(virQEMUDriverPtr driver, qemuDomainObjPrivatePtr priv =3D obj->privateData; qemuDomainJob job =3D priv->job.active; qemuDomainAgentJob agentJob =3D priv->job.agentActive; + const char *domName =3D NULLSTR(obj->def ? obj->def->name : NULL); =20 priv->jobs_queued--; =20 @@ -7556,7 +7560,7 @@ qemuDomainObjEndJobWithAgent(virQEMUDriverPtr driver, qemuDomainJobTypeToString(job), qemuDomainAgentJobTypeToString(agentJob), qemuDomainAsyncJobTypeToString(priv->job.asyncJob), - obj, obj->def->name); + obj, domName); =20 qemuDomainObjResetJob(priv); qemuDomainObjResetAgentJob(priv); @@ -7571,12 +7575,13 @@ void qemuDomainObjEndAsyncJob(virQEMUDriverPtr driver, virDomainObjPtr obj) { qemuDomainObjPrivatePtr priv =3D obj->privateData; + const char *domName =3D NULLSTR(obj->def ? obj->def->name : NULL); =20 priv->jobs_queued--; =20 VIR_DEBUG("Stopping async job: %s (vm=3D%p name=3D%s)", qemuDomainAsyncJobTypeToString(priv->job.asyncJob), - obj, obj->def->name); + obj, domName); =20 qemuDomainObjResetAsyncJob(priv); qemuDomainObjSaveJob(driver, obj); --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sat May 4 12:26:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 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=1559208919; cv=none; d=zoho.com; s=zohoarc; b=QNIKv/Td+g22YJrxQw/TDoghas7pMtcMyTQscQPdYd0LVqX4IrY1axJCdu96G89/1dNgK4NavL5sFXAF8ehvxbF7MTEUwkw0AiOcFgZTfzItE5dDopGWDWwTD69ZMpeAMzvklCJZ0LWwtGpWjHi+7QWgSvkwmx1ErrWgHIVbAjI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1559208919; h=Content-Type:Content-Transfer-Encoding:Cc: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:ARC-Authentication-Results; bh=TI+1JNCQ7GdMKhirH12VhbUDJEgAn6weamSEgHSEpYM=; b=Gn2EiSVg9bIY63DtFns7vyWjIgD93iOm71eserePKht1VC1zbKAMuZ5ZC/kmZ7U4cKkB357Vj8xQxzqI9TvtjoNrI93GH7qEkpbDMhyISMlKdYuZP16ZLmk2v9JhxHbdr7OSmaKU39uq3H6KbE4jONAvtepiSxJXK+2y8demHzw= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1559208919916324.4326020903816; Thu, 30 May 2019 02:35:19 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 24785F9E75; Thu, 30 May 2019 09:35:18 +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 EE1D16C35F; Thu, 30 May 2019 09:35:17 +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 A1CE51806B1A; Thu, 30 May 2019 09:35:17 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x4U9YISH027514 for ; Thu, 30 May 2019 05:34:18 -0400 Received: by smtp.corp.redhat.com (Postfix) id 5DF4860C7E; Thu, 30 May 2019 09:34:18 +0000 (UTC) Received: from moe.brq.redhat.com (unknown [10.43.2.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id B651F7B001; Thu, 30 May 2019 09:34:15 +0000 (UTC) From: Michal Privoznik To: libvir-list@redhat.com Date: Thu, 30 May 2019 11:34:02 +0200 Message-Id: <6b6d5d944b7a257a964f144ec1de9aa6a98504d3.1559208506.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com Cc: nshirokovskiy@virtuozzo.com Subject: [libvirt] [PATCH 7/9] qemu: Grab modify job for changing domain XML 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: , Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Thu, 30 May 2019 09:35:18 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Changing domain definition must be guarded with acquiring modify job. The problem is if there is a thread executing say qemuDomainSetMemoryStatsPeriod() which is an API that acquires modify job and then possibly unlock the domain object and locks it again. However, becasue virDomainObjAssignDef() does not take a job (only object lock) it may have changed the domain definition while the other thread unlocked the domain object in order to talk on the monitor. For instance: Thread1: 1) lookup domain object and lock it 2) acquire job 3) get pointers to live and persistent defs 4) unlock the domain object 5) talk to qemu on the monitor Thread2 (Execute qemuDomainDefineXMLFlags): 1) lookup domain object and lock it 2) virDomainObjAssignDef() which overwrites persistent def and frees the old one 3) unlock domain object Thread1: 6) lock the domain object again 7) try to access the persistent def via pointer stored in 3) Now this will crash because the pointer from step 3) points to a memory that was freed. However, if Thread2 waited and acquired modify job (just like Thread1) then these two would serialize and no harm would be done. Signed-off-by: Michal Privoznik --- src/qemu/qemu_domain.c | 3 ++- src/qemu/qemu_driver.c | 29 +++++++++++++++++++++++++---- src/qemu/qemu_migration.c | 7 +++++++ 3 files changed, 34 insertions(+), 5 deletions(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index c61d39b12b..fff2f1932e 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -8784,7 +8784,8 @@ qemuDomainRemoveInactive(virQEMUDriverPtr driver, return; } =20 - qemuDomainRemoveInactiveCommon(driver, vm); + if (vm->def) + qemuDomainRemoveInactiveCommon(driver, vm); =20 virDomainObjListRemove(driver->domains, vm); } diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 8bbac339e0..77cb7e4b87 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -1706,9 +1706,16 @@ static virDomainPtr qemuDomainCreateXML(virConnectPt= r conn, VIR_DOMAIN_OBJ_LIST_ADD_CHECK_LIVE))) goto cleanup; =20 + if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_MODIFY) < 0) { + qemuDomainRemoveInactive(driver, vm); + goto cleanup; + } + virDomainObjAssignDef(vm, def, true, NULL); def =3D NULL; =20 + qemuDomainObjEndJob(driver, vm); + if (qemuProcessBeginJob(driver, vm, VIR_DOMAIN_JOB_OPERATION_START, flags) < 0) { qemuDomainRemoveInactiveJob(driver, vm); @@ -6976,6 +6983,11 @@ qemuDomainRestoreFlags(virConnectPtr conn, VIR_DOMAIN_OBJ_LIST_ADD_CHECK_LIVE))) goto cleanup; =20 + if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_MODIFY) < 0) { + qemuDomainRemoveInactive(driver, vm); + goto cleanup; + } + virDomainObjAssignDef(vm, def, true, NULL); def =3D NULL; =20 @@ -6988,6 +7000,7 @@ qemuDomainRestoreFlags(virConnectPtr conn, priv =3D vm->privateData; priv->hookRun =3D true; } + qemuDomainObjEndJob(driver, vm); =20 if (qemuProcessBeginJob(driver, vm, VIR_DOMAIN_JOB_OPERATION_RESTORE, flags) < 0) @@ -7651,6 +7664,11 @@ qemuDomainDefineXMLFlags(virConnectPtr conn, driver->xmlopt, 0))) goto cleanup; =20 + if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_MODIFY) < 0) { + qemuDomainRemoveInactive(driver, vm); + goto cleanup; + } + virDomainObjAssignDef(vm, def, false, &oldDef); def =3D NULL; =20 @@ -7673,7 +7691,7 @@ qemuDomainDefineXMLFlags(virConnectPtr conn, vm->persistent =3D 0; qemuDomainRemoveInactiveJob(driver, vm); } - goto cleanup; + goto endjob; } =20 event =3D virDomainEventLifecycleNewFromObj(vm, @@ -7685,6 +7703,9 @@ qemuDomainDefineXMLFlags(virConnectPtr conn, VIR_INFO("Creating domain '%s'", vm->def->name); dom =3D virGetDomain(conn, vm->def->name, vm->def->uuid, vm->def->id); =20 + endjob: + qemuDomainObjEndJob(driver, vm); + cleanup: virDomainDefFree(oldDef); virDomainDefFree(def); @@ -16889,14 +16910,14 @@ static virDomainPtr qemuDomainQemuAttach(virConne= ctPtr conn, VIR_DOMAIN_OBJ_LIST_ADD_CHECK_LIVE))) goto cleanup; =20 - virDomainObjAssignDef(vm, def, true, NULL); - def =3D NULL; - if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_MODIFY) < 0) { qemuDomainRemoveInactive(driver, vm); goto cleanup; } =20 + virDomainObjAssignDef(vm, def, true, NULL); + def =3D NULL; + if (qemuProcessAttach(conn, driver, vm, pid, pidfile, monConfig, monJSON) < 0) { qemuDomainRemoveInactive(driver, vm); diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index 9e19c923ee..32325c9588 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -2408,9 +2408,16 @@ qemuMigrationDstPrepareAny(virQEMUDriverPtr driver, VIR_DOMAIN_OBJ_LIST_ADD_CHECK_LIVE))) goto cleanup; =20 + if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_MODIFY) < 0) { + qemuDomainRemoveInactive(driver, vm); + goto cleanup; + } + virDomainObjAssignDef(vm, *def, true, NULL); *def =3D NULL; =20 + qemuDomainObjEndJob(driver, vm); + priv =3D vm->privateData; if (VIR_STRDUP(priv->origname, origname) < 0) goto cleanup; --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sat May 4 12:26:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 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=1559208930; cv=none; d=zoho.com; s=zohoarc; b=JqvfTQfmqs6FuIFGOsT37FwencUscxfBS/VBNzWgOMVYQgfISNaFL+46qI9V51Tl2K4HdWosnt9MoV/eZZxcVZVKsCK3wOpNE1pItP9F1vlspc66P66cuCfxRDVfvVbI9o0W0LW0l/OBbccjE6sJRA5Tf49WNZwHNufcU19hRRk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1559208930; h=Content-Type:Content-Transfer-Encoding:Cc: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:ARC-Authentication-Results; bh=qxoy26Qzhu1/QO4Lj9lBTqgWsFMtj4UeSLe6Wg7y2x8=; b=C9ZjlgXsm+EeGu3uTb2OgONbi3T9NeonYfY8eLum4vt30FIZm51GjfuN89Qd89ctzx8mX75Xq+T4lsr/3AEDZs+ib5ouCTOtSf9PwUysoL6N6GxXgDL2SQwG/gfkDO7b2YnQmcPD1rH/bt1qhESqurZVOY/AwXDjxxM7KCzvBpk= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1559208930227476.30749300044556; Thu, 30 May 2019 02:35:30 -0700 (PDT) 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 mx1.redhat.com (Postfix) with ESMTPS id 93D333082263; Thu, 30 May 2019 09:35:23 +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 640D87D5C8; Thu, 30 May 2019 09:35:23 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 10B67206D2; Thu, 30 May 2019 09:35:23 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x4U9YJiZ027526 for ; Thu, 30 May 2019 05:34:19 -0400 Received: by smtp.corp.redhat.com (Postfix) id 50D4B60C7E; Thu, 30 May 2019 09:34:19 +0000 (UTC) Received: from moe.brq.redhat.com (unknown [10.43.2.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id A99397D536; Thu, 30 May 2019 09:34:18 +0000 (UTC) From: Michal Privoznik To: libvir-list@redhat.com Date: Thu, 30 May 2019 11:34:03 +0200 Message-Id: <2ef24feb0ad4a04e1df2e92af3793af608bfeaa2.1559208506.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com Cc: nshirokovskiy@virtuozzo.com Subject: [libvirt] [PATCH 8/9] lxc: Grab modify job for changing domain XML 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: , Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.45]); Thu, 30 May 2019 09:35:29 +0000 (UTC) Content-Type: text/plain; charset="utf-8" The reasoning here is the same as in qemu driver fixed in previous commit. Long story short, changing an XML of a domain requires modify job to be acquired. Signed-off-by: Michal Privoznik --- src/lxc/lxc_domain.c | 3 ++- src/lxc/lxc_driver.c | 23 ++++++++++++++++------- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/src/lxc/lxc_domain.c b/src/lxc/lxc_domain.c index 51a9fd36eb..609cfa6dae 100644 --- a/src/lxc/lxc_domain.c +++ b/src/lxc/lxc_domain.c @@ -93,6 +93,7 @@ virLXCDomainObjBeginJob(virLXCDriverPtr driver ATTRIBUTE_= UNUSED, virLXCDomainObjPrivatePtr priv =3D obj->privateData; unsigned long long now; unsigned long long then; + const char *domName =3D NULLSTR(obj->def ? obj->def->name : NULL); =20 if (virTimeMillisNow(&now) < 0) return -1; @@ -117,7 +118,7 @@ virLXCDomainObjBeginJob(virLXCDriverPtr driver ATTRIBUT= E_UNUSED, VIR_WARN("Cannot start job (%s) for domain %s;" " current job is (%s) owned by (%d)", virLXCDomainJobTypeToString(job), - obj->def->name, + domName, virLXCDomainJobTypeToString(priv->job.active), priv->job.owner); =20 diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c index eaf26563f5..2bd1274c90 100644 --- a/src/lxc/lxc_driver.c +++ b/src/lxc/lxc_driver.c @@ -448,6 +448,12 @@ lxcDomainDefineXMLFlags(virConnectPtr conn, const char= *xml, unsigned int flags) driver->xmlopt, 0))) goto cleanup; =20 + if (virLXCDomainObjBeginJob(driver, vm, LXC_JOB_MODIFY) < 0) { + if (!vm->persistent) + virDomainObjListRemove(driver->domains, vm); + goto cleanup; + } + virDomainObjAssignDef(vm, def, false, &oldDef); def =3D NULL; vm->persistent =3D 1; @@ -455,7 +461,7 @@ lxcDomainDefineXMLFlags(virConnectPtr conn, const char = *xml, unsigned int flags) if (virDomainSaveConfig(cfg->configDir, driver->caps, vm->newDef ? vm->newDef : vm->def) < 0) { virDomainObjListRemove(driver->domains, vm); - goto cleanup; + goto endjob; } =20 event =3D virDomainEventLifecycleNewFromObj(vm, @@ -466,6 +472,9 @@ lxcDomainDefineXMLFlags(virConnectPtr conn, const char = *xml, unsigned int flags) =20 dom =3D virGetDomain(conn, vm->def->name, vm->def->uuid, vm->def->id); =20 + endjob: + virLXCDomainObjEndJob(driver, vm); + cleanup: virDomainDefFree(def); virDomainDefFree(oldDef); @@ -1196,15 +1205,15 @@ lxcDomainCreateXMLWithFiles(virConnectPtr conn, VIR_DOMAIN_OBJ_LIST_ADD_CHECK_LIVE))) goto cleanup; =20 + if (virLXCDomainObjBeginJob(driver, vm, LXC_JOB_MODIFY) < 0) { + if (!vm->persistent) + virDomainObjListRemove(driver->domains, vm); + goto cleanup; + } + virDomainObjAssignDef(vm, def, true, NULL); def =3D NULL; =20 - if (virLXCDomainObjBeginJob(driver, vm, LXC_JOB_MODIFY) < 0) { - if (!vm->persistent) - virDomainObjListRemove(driver->domains, vm); - goto cleanup; - } - if (virLXCProcessStart(conn, driver, vm, nfiles, files, (flags & VIR_DOMAIN_START_AUTODESTROY), --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sat May 4 12:26:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 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=1559208939; cv=none; d=zoho.com; s=zohoarc; b=i6Vgi2kMrsOm4j1SWQ09Y60Jp75mIDfkYWXN4yXbixaUPRVPHPZwDWOt4wekj7y8R8Bt9XKyMoFAUieH+BqQbLTzJwk+p/RacTxDmWfqW4oAjlB8eASqmahze5yyC/MmZJBiJhOuppeKuckJuObuG6rMUqckFiF95igqyvudu3k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1559208939; h=Content-Type:Content-Transfer-Encoding:Cc: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:ARC-Authentication-Results; bh=pQBH25bxi5HbOAjKpYxLxiWwrf2vnppqr5VmCS+VZYs=; b=Z+wc027gpoRq6RllMWpUWRyLUVfIHAwoR0fEf5rPoypiEQxcDKi8tKZeeFxVfLSlXalxA2MomZsiANg0/uQLI7lpkgQN7uz3kuDV6oWNi9zqRPwChziV0LLQkJc0nD9cp2cCzWaHn/+Iv3vbxpnO3gaMeSj/AXnBoMYaeVrM0Zk= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1559208939924644.0190520725727; Thu, 30 May 2019 02:35:39 -0700 (PDT) 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 mx1.redhat.com (Postfix) with ESMTPS id 3DA902E97D5; Thu, 30 May 2019 09:35:33 +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 05426348F4; Thu, 30 May 2019 09:35:32 +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 AD6981806B0E; Thu, 30 May 2019 09:35:31 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x4U9YKrB027534 for ; Thu, 30 May 2019 05:34:20 -0400 Received: by smtp.corp.redhat.com (Postfix) id 4757B7B001; Thu, 30 May 2019 09:34:20 +0000 (UTC) Received: from moe.brq.redhat.com (unknown [10.43.2.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9D9D960C7E; Thu, 30 May 2019 09:34:19 +0000 (UTC) From: Michal Privoznik To: libvir-list@redhat.com Date: Thu, 30 May 2019 11:34:04 +0200 Message-Id: <517128acb505d222e65eb19febd24e4e25b1eb86.1559208506.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com Cc: nshirokovskiy@virtuozzo.com Subject: [libvirt] [PATCH 9/9] libxl: Grab modify job for changing domain XML 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: , Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Thu, 30 May 2019 09:35:38 +0000 (UTC) Content-Type: text/plain; charset="utf-8" The reasoning here is the same as in qemu driver fixed in previous commit. Long story short, changing an XML of a domain requires modify job to be acquired. Signed-off-by: Michal Privoznik --- src/libxl/libxl_domain.c | 3 ++- src/libxl/libxl_driver.c | 34 ++++++++++++++++++++++++---------- src/libxl/libxl_migration.c | 10 ++++------ 3 files changed, 30 insertions(+), 17 deletions(-) diff --git a/src/libxl/libxl_domain.c b/src/libxl/libxl_domain.c index 2d8569e592..a2c90f0461 100644 --- a/src/libxl/libxl_domain.c +++ b/src/libxl/libxl_domain.c @@ -115,6 +115,7 @@ libxlDomainObjBeginJob(libxlDriverPrivatePtr driver ATT= RIBUTE_UNUSED, libxlDomainObjPrivatePtr priv =3D obj->privateData; unsigned long long now; unsigned long long then; + const char *domName =3D NULLSTR(obj->def ? obj->def->name : NULL); =20 if (virTimeMillisNow(&now) < 0) return -1; @@ -141,7 +142,7 @@ libxlDomainObjBeginJob(libxlDriverPrivatePtr driver ATT= RIBUTE_UNUSED, VIR_WARN("Cannot start job (%s) for domain %s;" " current job is (%s) owned by (%d)", libxlDomainJobTypeToString(job), - obj->def->name, + domName, libxlDomainJobTypeToString(priv->job.active), priv->job.owner); =20 diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c index 809d298ac1..1bd7148345 100644 --- a/src/libxl/libxl_driver.c +++ b/src/libxl/libxl_driver.c @@ -606,22 +606,29 @@ libxlAddDom0(libxlDriverPrivatePtr driver) 0))) goto cleanup; =20 + if (libxlDomainObjBeginJob(driver, vm, LIBXL_JOB_MODIFY) < 0) { + virDomainObjListRemove(driver->domains, vm); + goto cleanup; + } + virDomainObjAssignDef(vm, def, false, &oldDef); def =3D NULL; =20 vm->persistent =3D 1; virDomainObjSetState(vm, VIR_DOMAIN_RUNNING, VIR_DOMAIN_RUNNING_BOOTED= ); if (virDomainDefSetVcpusMax(vm->def, d_info.vcpu_max_id + 1, driver->x= mlopt)) - goto cleanup; + goto endjob; =20 if (virDomainDefSetVcpus(vm->def, d_info.vcpu_online) < 0) - goto cleanup; + goto endjob; vm->def->mem.cur_balloon =3D d_info.current_memkb; if (libxlDriverGetDom0MaxmemConf(cfg, &maxmem) < 0) maxmem =3D d_info.current_memkb; virDomainDefSetMemoryTotal(vm->def, maxmem); =20 ret =3D 0; + endjob: + libxlDomainObjEndJob(driver, vm); =20 cleanup: libxl_dominfo_dispose(&d_info); @@ -1035,15 +1042,15 @@ libxlDomainCreateXML(virConnectPtr conn, const char= *xml, VIR_DOMAIN_OBJ_LIST_ADD_CHECK_LIVE))) goto cleanup; =20 - virDomainObjAssignDef(vm, def, true, NULL); - def =3D NULL; - if (libxlDomainObjBeginJob(driver, vm, LIBXL_JOB_MODIFY) < 0) { if (!vm->persistent) virDomainObjListRemove(driver->domains, vm); goto cleanup; } =20 + virDomainObjAssignDef(vm, def, true, NULL); + def =3D NULL; + if (libxlDomainStartNew(driver, vm, (flags & VIR_DOMAIN_START_PAUSED) !=3D 0) < 0) { if (!vm->persistent) @@ -1955,15 +1962,15 @@ libxlDomainRestoreFlags(virConnectPtr conn, const c= har *from, VIR_DOMAIN_OBJ_LIST_ADD_CHECK_LIVE))) goto cleanup; =20 - virDomainObjAssignDef(vm, def, true, NULL); - def =3D NULL; - if (libxlDomainObjBeginJob(driver, vm, LIBXL_JOB_MODIFY) < 0) { if (!vm->persistent) virDomainObjListRemove(driver->domains, vm); goto cleanup; } =20 + virDomainObjAssignDef(vm, def, true, NULL); + def =3D NULL; + ret =3D libxlDomainStartRestore(driver, vm, (flags & VIR_DOMAIN_SAVE_PAUSED) !=3D 0, fd, hdr.version); @@ -2855,16 +2862,20 @@ libxlDomainDefineXMLFlags(virConnectPtr conn, const= char *xml, unsigned int flag 0))) goto cleanup; =20 + if (libxlDomainObjBeginJob(driver, vm, LIBXL_JOB_MODIFY) < 0) { + virDomainObjListRemove(driver->domains, vm); + goto cleanup; + } + virDomainObjAssignDef(vm, def, false, &oldDef); def =3D NULL; - vm->persistent =3D 1; =20 if (virDomainSaveConfig(cfg->configDir, cfg->caps, vm->newDef ? vm->newDef : vm->def) < 0) { virDomainObjListRemove(driver->domains, vm); - goto cleanup; + goto endjob; } =20 dom =3D virGetDomain(conn, vm->def->name, vm->def->uuid, vm->def->id); @@ -2874,6 +2885,9 @@ libxlDomainDefineXMLFlags(virConnectPtr conn, const c= har *xml, unsigned int flag VIR_DOMAIN_EVENT_DEFINED_ADDED : VIR_DOMAIN_EVENT_DEFINED_UPDATED); =20 + endjob: + libxlDomainObjEndJob(driver, vm); + cleanup: virDomainDefFree(def); virDomainDefFree(oldDef); diff --git a/src/libxl/libxl_migration.c b/src/libxl/libxl_migration.c index 35403380d0..64bc10bc34 100644 --- a/src/libxl/libxl_migration.c +++ b/src/libxl/libxl_migration.c @@ -571,9 +571,6 @@ libxlDomainMigrationDstPrepareTunnel3(virConnectPtr dco= nn, VIR_DOMAIN_OBJ_LIST_ADD_CHECK_LIVE))) goto error; =20 - virDomainObjAssignDef(vm, *def, true, NULL); - *def =3D NULL; - /* * Unless an error is encountered in this function, the job will * be terminated in the finish phase. @@ -581,6 +578,8 @@ libxlDomainMigrationDstPrepareTunnel3(virConnectPtr dco= nn, if (libxlDomainObjBeginJob(driver, vm, LIBXL_JOB_MODIFY) < 0) goto error; =20 + virDomainObjAssignDef(vm, *def, true, NULL); + *def =3D NULL; priv =3D vm->privateData; =20 if (taint_hook) { @@ -680,9 +679,6 @@ libxlDomainMigrationDstPrepare(virConnectPtr dconn, VIR_DOMAIN_OBJ_LIST_ADD_CHECK_LIVE))) goto error; =20 - virDomainObjAssignDef(vm, *def, true, NULL); - *def =3D NULL; - /* * Unless an error is encountered in this function, the job will * be terminated in the finish phase. @@ -690,6 +686,8 @@ libxlDomainMigrationDstPrepare(virConnectPtr dconn, if (libxlDomainObjBeginJob(driver, vm, LIBXL_JOB_MODIFY) < 0) goto error; =20 + virDomainObjAssignDef(vm, *def, true, NULL); + *def =3D NULL; priv =3D vm->privateData; =20 if (taint_hook) { --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list