From nobody Mon Feb 9 06:34:36 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=1583864015; cv=none; d=zohomail.com; s=zohoarc; b=R1q3SpYMq2qiWtyVuqwRqdcrm7WPUwuGVy7AaYoRnnDiJWxGlAVmKBC2u7p6rXf7gkHw022GVCkxE08ewVP/PiEa0+gNVDOc8dET5t3VZ0mr/WaCuiAwhBB6xk6LfyNXaJWiKB2U10WnIwG2CmVObkKBeOh7pkRyIu8ceHK91DA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1583864015; 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=nnhOS+HNlx+RSocFk3m4F2+s63FEZx51ovSunOYV7QI=; b=f7HJBN+YgxA7JQUCMW+D33ldjxdo6mJw9r/5ouq+TSHPFT7KGRSwxHp8u+KhwFn6JHNM88aZBgRpcKl6jZjPgpHkHao/KWKNcKZ7W+jGGTegge17kbGNInusDs74oni4VpLBmmxoUYpECPzHuOwEk+htXGP1w8tu21yivLO+vrg= 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 1583864015395417.2994359106424; Tue, 10 Mar 2020 11:13:35 -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-406-gSM9OXfxN0CRMlsS2ILS9g-1; Tue, 10 Mar 2020 14:13:31 -0400 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id C066418A5507; Tue, 10 Mar 2020 18:13: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 94C19391; Tue, 10 Mar 2020 18:13: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 9164818089C8; Tue, 10 Mar 2020 18:13: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 02AIDNHW010503 for ; Tue, 10 Mar 2020 14:13:23 -0400 Received: by smtp.corp.redhat.com (Postfix) id 1586E7388D; Tue, 10 Mar 2020 18:13:23 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-112-62.ams2.redhat.com [10.36.112.62]) by smtp.corp.redhat.com (Postfix) with ESMTP id CFCD25C13D; Tue, 10 Mar 2020 18:13:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1583864014; 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=nnhOS+HNlx+RSocFk3m4F2+s63FEZx51ovSunOYV7QI=; b=hilPxG8VE19ikMUtd9lOqN5dtzIfnri22cTxeRT3XHT0rpwh3YOSk/RHom/WgBK6TL5+Pz jK/csF6NVUY9Le9nlZ2FOc8LAzlhVTcBNUgwrmbfnPeUGpEpoIREJWfb2prSi4Bl7MQuAM BY+9fOR4OA5a3iedlAkLsUwi1dLp9O0= X-MC-Unique: gSM9OXfxN0CRMlsS2ILS9g-1 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Subject: [libvirt PATCH 2/3] rpc: avoid name lookup when dispatching node device APIs Date: Tue, 10 Mar 2020 18:13:13 +0000 Message-Id: <20200310181314.3613846-3-berrange@redhat.com> In-Reply-To: <20200310181314.3613846-1-berrange@redhat.com> References: <20200310181314.3613846-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" The node device APIs are a little unusual because we don't use a "remote_nonnull_node_device" object on the wire, instead we just have a "remote_string" for the device name. This meant dispatcher code generation needed special cases. In doing so we mistakenly used the virNodeDeviceLookupByName() API which gets dispatched into the driver, instead of get_nonnull_node_device() which directly populates a virNodeDevicePtr object. This wasn't a problem with monolithic libvirtd, as the virNodeDeviceLookupByName() API call was trivially satisfied by the registered driver, albeit with an extra (undesirable) authentication check. With the split daemons, the call to virNodeDeviceLookupByName() fails in virtqemud, because the node device driver obviously doesn't exist in that daemon. Signed-off-by: Daniel P. Berrang=C3=A9 --- src/remote/remote_daemon_dispatch.c | 7 +++++++ src/rpc/gendispatch.pl | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/remote/remote_daemon_dispatch.c b/src/remote/remote_daemon= _dispatch.c index 2741a32f63..226049fed6 100644 --- a/src/remote/remote_daemon_dispatch.c +++ b/src/remote/remote_daemon_dispatch.c @@ -95,6 +95,7 @@ static virNWFilterBindingPtr get_nonnull_nwfilter_binding= (virConnectPtr conn, re static virDomainCheckpointPtr get_nonnull_domain_checkpoint(virDomainPtr d= om, remote_nonnull_domain_checkpoint checkpoint); static virDomainSnapshotPtr get_nonnull_domain_snapshot(virDomainPtr dom, = remote_nonnull_domain_snapshot snapshot); static virNodeDevicePtr get_nonnull_node_device(virConnectPtr conn, remote= _nonnull_node_device dev); +static virNodeDevicePtr get_nonnull_node_device_name(virConnectPtr conn, r= emote_nonnull_string devdev); static void make_nonnull_domain(remote_nonnull_domain *dom_dst, virDomainP= tr dom_src); static void make_nonnull_network(remote_nonnull_network *net_dst, virNetwo= rkPtr net_src); static void make_nonnull_network_port(remote_nonnull_network_port *port_ds= t, virNetworkPortPtr port_src); @@ -7291,6 +7292,12 @@ get_nonnull_node_device(virConnectPtr conn, remote_n= onnull_node_device dev) return virGetNodeDevice(conn, dev.name); } =20 +static virNodeDevicePtr +get_nonnull_node_device_name(virConnectPtr conn, remote_nonnull_string dev= name) +{ + return virGetNodeDevice(conn, devname); +} + static void make_nonnull_domain(remote_nonnull_domain *dom_dst, virDomainPtr dom_src) { diff --git a/src/rpc/gendispatch.pl b/src/rpc/gendispatch.pl index c140ed712c..0b2ae59910 100755 --- a/src/rpc/gendispatch.pl +++ b/src/rpc/gendispatch.pl @@ -571,7 +571,7 @@ elsif ($mode eq "server") { $has_node_device =3D 1; push(@vars_list, "virNodeDevicePtr dev =3D NULL"); push(@getters_list, - " if (!(dev =3D virNodeDeviceLookupByName($conn_va= r, args->name)))\n" . + " if (!(dev =3D get_nonnull_node_device_name($conn= _var, args->name)))\n" . " goto cleanup;\n"); push(@args_list, "dev"); push(@free_list, --=20 2.24.1