From nobody Mon May 6 08:39:01 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 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1521229587185927.0655057652176; Fri, 16 Mar 2018 12:46:27 -0700 (PDT) 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 mx1.redhat.com (Postfix) with ESMTPS id 69BA47FEBD; Fri, 16 Mar 2018 19:46:25 +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 138245D70A; Fri, 16 Mar 2018 19:46: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 3A105181B9FE; Fri, 16 Mar 2018 19:46:24 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w2GJkMEY020091 for ; Fri, 16 Mar 2018 15:46:22 -0400 Received: by smtp.corp.redhat.com (Postfix) id D192E5D75F; Fri, 16 Mar 2018 19:46:22 +0000 (UTC) Received: from mx1.redhat.com (ext-mx01.extmail.prod.ext.phx2.redhat.com [10.5.110.25]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8D35F5D70A; Fri, 16 Mar 2018 19:46:19 +0000 (UTC) Received: from smtp2.provo.novell.com (smtp2.provo.novell.com [137.65.250.81]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 23E7C7FEBE; Fri, 16 Mar 2018 19:46:18 +0000 (UTC) Received: from linux-tbji.provo.novell.com (prv-ext-foundry1int.gns.novell.com [137.65.251.240]) by smtp2.provo.novell.com with ESMTP (NOT encrypted); Fri, 16 Mar 2018 13:46:13 -0600 From: Jim Fehlig To: libvir-list@redhat.com Date: Fri, 16 Mar 2018 13:46:03 -0600 Message-Id: <20180316194603.9268-1-jfehlig@suse.com> X-Greylist: Sender passed SPF test, Sender IP whitelisted by DNSRBL, ACL 207 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Fri, 16 Mar 2018 19:46:18 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Fri, 16 Mar 2018 19:46:18 +0000 (UTC) for IP:'137.65.250.81' DOMAIN:'smtp2.provo.novell.com' HELO:'smtp2.provo.novell.com' FROM:'jfehlig@suse.com' RCPT:'' X-RedHat-Spam-Score: -2.301 (RCVD_IN_DNSWL_MED, SPF_PASS) 137.65.250.81 smtp2.provo.novell.com 137.65.250.81 smtp2.provo.novell.com X-Scanned-By: MIMEDefang 2.83 on 10.5.110.25 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH V2] libxl: MigratePrepare: use standard begin and end API pattern 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: , MIME-Version: 1.0 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.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Fri, 16 Mar 2018 19:46:26 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" libxlDomainMigrationPrepare adds the incoming domain def to the list of domains via virDomainObjListAdd, but never adds its own ref to the returned virDomainObj as other callers of virDomainObjListAdd do. libxlDomainMigrationPrepareTunnel3 suffers the same discrepancy. Change both to add a ref to the virDomainObj after a successful virDomainObjListAdd, similar to other callers. This ensures a consistent pattern throughout the drivers and allows using the virDomainObjEndAPI function for cleanup. Signed-off-by: Jim Fehlig Reviewed-by: John Ferlan --- V2 of https://www.redhat.com/archives/libvir-list/2018-March/msg00674.html Changes in V2: Add ref after call to virDomainObjListAdd so that EndAPI can be used in the usual pattern. src/libxl/libxl_migration.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/libxl/libxl_migration.c b/src/libxl/libxl_migration.c index 42a84bd35..7dc39ae02 100644 --- a/src/libxl/libxl_migration.c +++ b/src/libxl/libxl_migration.c @@ -583,6 +583,7 @@ libxlDomainMigrationPrepareTunnel3(virConnectPtr dconn, NULL))) goto error; =20 + virObjectRef(vm); *def =3D NULL; priv =3D vm->privateData; =20 @@ -635,13 +636,11 @@ libxlDomainMigrationPrepareTunnel3(virConnectPtr dcon= n, /* Remove virDomainObj from domain list */ if (vm) { virDomainObjListRemove(driver->domains, vm); - vm =3D NULL; + virObjectLock(vm); } =20 done: - if (vm) - virObjectUnlock(vm); - + virDomainObjEndAPI(&vm); return ret; } =20 @@ -683,6 +682,7 @@ libxlDomainMigrationPrepare(virConnectPtr dconn, NULL))) goto error; =20 + virObjectRef(vm); *def =3D NULL; priv =3D vm->privateData; =20 @@ -810,7 +810,7 @@ libxlDomainMigrationPrepare(virConnectPtr dconn, /* Remove virDomainObj from domain list */ if (vm) { virDomainObjListRemove(driver->domains, vm); - vm =3D NULL; + virObjectLock(vm); } =20 done: @@ -820,8 +820,7 @@ libxlDomainMigrationPrepare(virConnectPtr dconn, VIR_FREE(hostname); else virURIFree(uri); - if (vm) - virObjectUnlock(vm); + virDomainObjEndAPI(&vm); virObjectUnref(cfg); return ret; } --=20 2.16.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list