From nobody Sun Feb 8 20:17:33 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) client-ip=205.139.110.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 205.139.110.120 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=1575453423; cv=none; d=zohomail.com; s=zohoarc; b=QlW36XB2v85Cf1jBE54SnVsaB50tnTBNNv6lQ5c47ApFjEWL9nj8TxVf7O+Hvim5FPZtCxmHT9YyfxmGMYsMFTVc46aFB3RhHjlYEw42+KIzCzE0bdrSfT7eBGubUwswvFfsnkab8b4i7csUDKWkIsWkCY6GtAOTTVdLXyZ6Z2s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1575453423; 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=tNk+HRD9Dw48sEsA5T5gjT0OdPOXYAO587FNTG6Zu80=; b=hpUDxQyq1ULyGB/eJg8/IUg9MMfX9B6WiCxYiY7nn3HxJGeGDbM3qA0qjxdNBDRwC9Ch7otBIl2EJpuRMfDrWMgapiTYS6bd9dNtFJSPuo1Uz9EhMba6U6Ceo5RWC0ZvZvrSOGb1rqOGIq38aYnUjvrMJurLKcie5GIW8JlT56U= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by mx.zohomail.com with SMTPS id 1575453423358486.0669967272272; Wed, 4 Dec 2019 01:57:03 -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-325-FcAsUDZGPLCbjQxvoiGtng-1; Wed, 04 Dec 2019 04:56:15 -0500 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id A8E991083A51; Wed, 4 Dec 2019 09:56:07 +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 802CD60F8D; Wed, 4 Dec 2019 09:56: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 3E53D180880B; Wed, 4 Dec 2019 09:56:07 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id xB49tjG2023760 for ; Wed, 4 Dec 2019 04:55:45 -0500 Received: by smtp.corp.redhat.com (Postfix) id CF4555DA7B; Wed, 4 Dec 2019 09:55:45 +0000 (UTC) Received: from moe.redhat.com (unknown [10.43.2.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id 57DEC5DA70 for ; Wed, 4 Dec 2019 09:55:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1575453422; 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=tNk+HRD9Dw48sEsA5T5gjT0OdPOXYAO587FNTG6Zu80=; b=hSDN0Yf4aX+ryJD4CFo+vThmI+Fr3+DaTeq2RrFKXbZYVxFu6JVXk7n4LHWOMwuzpJOFh5 0IQ9xQR+9D9woZgBcLgWZiVeguoantXCx54qNThOCoSKkJh7VGkZT+Y5cIoIcTY+ixTRjF Y2ga+OLbnfFOLuAAm/KoP6aL7QNztcI= From: Michal Privoznik To: libvir-list@redhat.com Date: Wed, 4 Dec 2019 10:55:30 +0100 Message-Id: <6b0c88f2267c0d4ef1565431b04ebe4cc995fc49.1575453027.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 5/9] libxl: Don't use dom->conn to lookup virNetwork 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.12 X-MC-Unique: FcAsUDZGPLCbjQxvoiGtng-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" When using the monolithic daemon, then dom->conn has all driver tables filled in properly and thus it's safe to call an API other than virDomain*(). However, when using split daemons then dom->conn has only hypervisor driver table set (dom->conn->driver) and the rest is NULL. Therefore, if we want to call a non-domain API (virNetworkLookupByName() in this case), we have obtain the cached connection object accessible via virGetConnectNetwork(). Signed-off-by: Michal Privoznik --- src/libxl/libxl_driver.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c index 44a74e8779..ccef4f3955 100644 --- a/src/libxl/libxl_driver.c +++ b/src/libxl/libxl_driver.c @@ -6235,10 +6235,10 @@ static int libxlNodeGetSecurityModel(virConnectPtr = conn, } =20 static int -libxlGetDHCPInterfaces(virDomainPtr dom, - virDomainObjPtr vm, +libxlGetDHCPInterfaces(virDomainObjPtr vm, virDomainInterfacePtr **ifaces) { + g_autoptr(virConnect) conn =3D NULL; int rv =3D -1; int n_leases =3D 0; size_t i, j; @@ -6249,12 +6249,8 @@ libxlGetDHCPInterfaces(virDomainPtr dom, virNetworkDHCPLeasePtr *leases =3D NULL; virDomainInterfacePtr *ifaces_ret =3D NULL; =20 - if (!dom->conn->networkDriver || - !dom->conn->networkDriver->networkGetDHCPLeases) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Network driver does not support DHCP lease query= ")); + if (!(conn =3D virGetConnectNetwork())) return -1; - } =20 for (i =3D 0; i < vm->def->nnets; i++) { if (vm->def->nets[i]->type !=3D VIR_DOMAIN_NET_TYPE_NETWORK) @@ -6262,8 +6258,10 @@ libxlGetDHCPInterfaces(virDomainPtr dom, =20 virMacAddrFormat(&(vm->def->nets[i]->mac), macaddr); virObjectUnref(network); - network =3D virNetworkLookupByName(dom->conn, + network =3D virNetworkLookupByName(conn, vm->def->nets[i]->data.network.na= me); + if (!network) + goto error; =20 if ((n_leases =3D virNetworkGetDHCPLeases(network, macaddr, &leases, 0)) < 0) @@ -6351,7 +6349,7 @@ libxlDomainInterfaceAddresses(virDomainPtr dom, =20 switch (source) { case VIR_DOMAIN_INTERFACE_ADDRESSES_SRC_LEASE: - ret =3D libxlGetDHCPInterfaces(dom, vm, ifaces); + ret =3D libxlGetDHCPInterfaces(vm, ifaces); break; =20 default: --=20 2.23.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list