From nobody Fri May 17 03:13:03 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1621978889; cv=none; d=zohomail.com; s=zohoarc; b=duXCaxV9Z3hJ/OM7H5wdO8tVWRGK+rmYq0FXSDGyWj0qAy20BQ+kWuY/zcOiBiQbKEG0/PRye0VsRxCoQZR0n5lx87HAFEMfxnOPPIHL/lmlRvAgJsl0mZBvPhVzprLTg5cvsB5Z/tmbj7AD0EH1Os9H/6rPWdpqpUtZfMWT32s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1621978889; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=FYbcz7DbY0TOU6GuL8mZBbvT3xAdkaSLYIHnXafAai0=; b=GxQec8Hs8mjYZMFb+pEJWQ7Dt96uN8qoPoke/Wg77Q7MGO+6BDHHtRa+S34GjQGLhbmI5K2MbtjGDLkhOD+KcIzDcK6pV4Jzrv6XRjy7O8mTnolWVvbVDDZ6KsWVLJ/deGb5hmnKIOZS6QTsyMRkoVjug470tKrPJr7XjB2cFfE= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1621978889865352.3888799162885; Tue, 25 May 2021 14:41:29 -0700 (PDT) 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-404-VUBJFiy7PoysGkC1GHOd7Q-1; Tue, 25 May 2021 17:41:26 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E688E1009465; Tue, 25 May 2021 21:41:21 +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 D8451100EBAF; Tue, 25 May 2021 21:41:19 +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 CDA651800BB8; Tue, 25 May 2021 21:41:14 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 14PLfCBm004822 for ; Tue, 25 May 2021 17:41:13 -0400 Received: by smtp.corp.redhat.com (Postfix) id BC30D20287C0; Tue, 25 May 2021 21:41:12 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast04.extmail.prod.ext.rdu2.redhat.com [10.11.55.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B742820FD552 for ; Tue, 25 May 2021 21:41:10 +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-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id E83B5101D23D for ; Tue, 25 May 2021 21:41:09 +0000 (UTC) Received: from mo4-p00-ob.smtp.rzone.de (mo4-p00-ob.smtp.rzone.de [85.215.255.23]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-414-ET4SqSWHNM-LWlXEI2uUXw-1; Tue, 25 May 2021 17:41:04 -0400 Received: from sender by smtp.strato.de (RZmta 47.26.2 AUTH) with ESMTPSA id J039e4x4PLf11HJ (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256 bits)) (Client did not present a certificate); Tue, 25 May 2021 23:41:01 +0200 (CEST) X-MC-Unique: VUBJFiy7PoysGkC1GHOd7Q-1 X-MC-Unique: ET4SqSWHNM-LWlXEI2uUXw-1 X-RZG-AUTH: ":P2EQZWCpfu+qG7CngxMFH1J+3q8wa/QXkBR9MXjAuzpIG0mv9coXAgs09ValFcstyKtnZMLOo4jr88Zf5nXI1mYJUK+h" X-RZG-CLASS-ID: mo00 From: Olaf Hering To: libvir-list@redhat.com Subject: [PATCH v4] libxl: adjust handling of libxl_device_nic objects Date: Tue, 25 May 2021 23:40:59 +0200 Message-Id: <20210525214059.4857-1-olaf@aepfle.de> MIME-Version: 1.0 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.6 X-loop: libvir-list@redhat.com Cc: Olaf Hering X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" libxl objects are supposed to be initialized and disposed. Adjust libxlMakeNic to use an already initialized object, it is owned by the caller. Adjust libxlMakeNicList to initialize the list of objects, before they are filled by libxlMakeNic. In case of error the objects are disposed by libxl_domain_config_dispose. Signed-off-by: Olaf Hering --- src/libxl/libxl_conf.c | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/src/libxl/libxl_conf.c b/src/libxl/libxl_conf.c index 2ecbcf6911..c672bafbe9 100644 --- a/src/libxl/libxl_conf.c +++ b/src/libxl/libxl_conf.c @@ -1335,8 +1335,6 @@ libxlMakeNic(virDomainDef *def, return -1; } =20 - libxl_device_nic_init(x_nic); - virMacAddrGetRaw(&l_nic->mac, x_nic->mac); =20 /* @@ -1531,8 +1529,9 @@ libxlMakeNicList(virDomainDef *def, libxl_domain_con= fig *d_config) if (virDomainNetGetActualType(l_nics[i]) =3D=3D VIR_DOMAIN_NET_TYP= E_HOSTDEV) continue; =20 + libxl_device_nic_init(&x_nics[nvnics]); if (libxlMakeNic(def, l_nics[i], &x_nics[nvnics], false)) - goto error; + return -1; /* * The devid (at least right now) will not get initialized by * libxl in the setup case but is required for starting the @@ -1549,12 +1548,6 @@ libxlMakeNicList(virDomainDef *def, libxl_domain_co= nfig *d_config) d_config->num_nics =3D nvnics; =20 return 0; - - error: - for (i =3D 0; i < nnics; i++) - libxl_device_nic_dispose(&x_nics[i]); - VIR_FREE(x_nics); - return -1; } =20 int