From nobody Thu May 2 00:03:28 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) client-ip=207.211.31.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 207.211.31.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=WGXmvfmKeL+m84wMgUjenFFc+rcjwdF5wCsp8O/EJYLqcWcwIRmlRMFN7ytSVcmTJXS7qp7z/BJfcRZbZhb7JgZ1k9R9mBA0B7uDB7yDIB/80RHd339ENWYpfprIvGOVIF8m5DaBdHbWQMf2a/zLz912u9Zrw68MeRPt3258ieM= 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=erfmPFhftLwVBj41j6yqYKp3B0HKCD+8oYoQuIUM9zs=; b=KpLyxpLve9/KghLxRydZMCbN3wkNIrDEwSxaBcpW8wuPgPyo/0/tAF6RyyiwF+klBNhZkPqyDIjuLTJZt9JO2v8hjlAGOKFBWwA3/VS9zKdCoQLBxJ6sKoW/YD3gn2pTRcvCfgVpuGZli9Z242I60yUkdbiRrmNZi3IsmSSCYT8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.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 [207.211.31.120]) by mx.zohomail.com with SMTPS id 1583864015185314.4414278376819; 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-129-LRUR7P4pNGmBUVhwrcKVuw-1; Tue, 10 Mar 2020 14:13:31 -0400 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 5846B800D5F; 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 1136C60BF4; 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 5A6B318089CD; 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 02AIDLXp010493 for ; Tue, 10 Mar 2020 14:13:21 -0400 Received: by smtp.corp.redhat.com (Postfix) id 6718F5C13D; Tue, 10 Mar 2020 18:13:21 +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 906ED7388D; Tue, 10 Mar 2020 18:13:20 +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=erfmPFhftLwVBj41j6yqYKp3B0HKCD+8oYoQuIUM9zs=; b=KiiqOztH+Tarod44UlRe23vyN4pvj+y01oApjNOL/6cqMcF97b0x+ZUR/oZpg+dW9fckqv 9Qk3CdZoxJkwkZKlQPw0CvnqCR0ZckMr//AZrw8xb3M6UpmWF85RaZSVudj6kYqkD396eU NiRk5YfaMcA/Gm2iDus0m2q1U+DvpqA= X-MC-Unique: LRUR7P4pNGmBUVhwrcKVuw-1 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Subject: [libvirt PATCH 1/3] rpc: fix dispatch for node device APIs for virt drivers Date: Tue, 10 Mar 2020 18:13:12 +0000 Message-Id: <20200310181314.3613846-2-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.79 on 10.5.11.12 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" Despite their names, the following APIs: virNodeDeviceDettach virNodeDeviceDetachFlags virNodeDeviceReAttach virNodeDeviceReset are all handled by the virt drivers, not the node device driver. A bug in the RPC generator meant that these APIs were sent to the nodedev driver for handling. This caused breakage with the split daemons, since nothing was available to process them. Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Michal Privoznik --- src/rpc/gendispatch.pl | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/rpc/gendispatch.pl b/src/rpc/gendispatch.pl index 987a136566..c140ed712c 100755 --- a/src/rpc/gendispatch.pl +++ b/src/rpc/gendispatch.pl @@ -171,7 +171,13 @@ sub get_conn_method { if ($proc =3D~ /Connect.*Network/) { return "remoteGetNetworkConn"; } - if ($proc =3D~ /Node.*Device/) { + # Carefully whitelist a few APIs with NodeDevice name + # prefix which actually get handled by the virt drivers + if ($proc =3D~ /Node.*Device/ && + !($proc =3D~ /NodeDeviceReset/ || + $proc =3D~ /NodeDeviceReAttach/ || + $proc =3D~ /NodeDeviceDettach/ || + $proc =3D~ /NodeDeviceDetachFlags/)) { return "remoteGetNodeDevConn"; } if ($proc =3D~ /Connect.*NWFilter/) { --=20 2.24.1 From nobody Thu May 2 00:03:28 2024 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 Reviewed-by: Michal Privoznik --- 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 From nobody Thu May 2 00:03:28 2024 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=1583864024; cv=none; d=zohomail.com; s=zohoarc; b=BgtO9ZlY/l+UPrFknTmUGFE2baxDpqM1PuAIzYRHpndWg5OhcFZMtZayeup0hGnFr6LjsLw6qIvBe23rC7+Wpfeysoi5orkgEHMKCGGMqUtXo2auq9ORtQkzm4CcpHstlKCRay4qg0GjL2YsQ8iee6T1DQx+TcsFLURjE4YTvpI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1583864024; 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=wah911ldKRZ3M0pUyM2hTz8zIcr9KVlOlHOncV/FvjQ=; b=f4cb3bP6aG/bS59Mztwvf6j7VxbLgrj1ZKaHm6DO/dTaycJkGJR3drfCX+6UorHKc1y2DB7HezXVxuyHBEbaEApCHAZncfIpHVko7TJ3krKQyxWcTuN2zJDSzq8+CGbD6bp3ni/jxqrSwY80frGOCMKwcnAROFxRzYEJcAg/ESE= 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 1583864024962461.437967715381; Tue, 10 Mar 2020 11:13:44 -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-282-NK5daSOXNBe7Q4E8NF1WMA-1; Tue, 10 Mar 2020 14:13:40 -0400 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id DA4A6DB2E; Tue, 10 Mar 2020 18:13: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 A84C68F354; Tue, 10 Mar 2020 18:13:34 +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 5011B18089CD; Tue, 10 Mar 2020 18:13:34 +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 02AIDOjL010510 for ; Tue, 10 Mar 2020 14:13:24 -0400 Received: by smtp.corp.redhat.com (Postfix) id 4718E7388D; Tue, 10 Mar 2020 18:13:24 +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 73E6B5C13D; Tue, 10 Mar 2020 18:13:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1583864022; 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=wah911ldKRZ3M0pUyM2hTz8zIcr9KVlOlHOncV/FvjQ=; b=LdycVnumNhVG7xh+vrVAY0WOGvHfioe+yTrTrF6b1Ga53mitAi8KCGsbaeBeSOIwRNWN9f 1P5+sE+1KgZBBRO36BDLrEz1/GO2SbNbxnCk++elYIbnwQoPLlZRiTR8oo09yzVd/r0BJ/ KHBHX8JQ6RczJkJ/qGrOqWW7WxGi5Uc= X-MC-Unique: NK5daSOXNBe7Q4E8NF1WMA-1 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Subject: [libvirt PATCH 3/3] qemu: lookup node device against nodedev driver before getting XML Date: Tue, 10 Mar 2020 18:13:14 +0000 Message-Id: <20200310181314.3613846-4-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.79 on 10.5.11.11 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" Some of the node device APIs are a little odd because they accept a virNodeDevicePtr object but are still implemented by the virt drivers. The first thing the virt drivers need to do is get the XML config associated with the node device, and that means talking to the node device driver. This worked previously because with monolithic libvirtd, both the virt driver and node device driver were in the same daemon and thus a single virConnectPtr can talk to both drivers. With the split daemon world though, the virNodeDevicePtr passed into the APIs is associated with the QEMU driver virConnectPtr, which has no ability to invoke APIs against the node device driver. We must thus get a duplicate virNodeDevicePtr object which is associated with a virConnectPtr for the node device driver. Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Michal Privoznik --- src/libxl/libxl_driver.c | 63 ++++++++++++++++++++++++++++++++++++++-- src/qemu/qemu_driver.c | 63 ++++++++++++++++++++++++++++++++++++++-- 2 files changed, 120 insertions(+), 6 deletions(-) diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c index f2387e2a20..eca45da097 100644 --- a/src/libxl/libxl_driver.c +++ b/src/libxl/libxl_driver.c @@ -5787,10 +5787,23 @@ libxlNodeDeviceDetachFlags(virNodeDevicePtr dev, char *xml =3D NULL; libxlDriverPrivatePtr driver =3D dev->conn->privateData; virHostdevManagerPtr hostdev_mgr =3D driver->hostdevMgr; + virConnectPtr nodeconn =3D NULL; + virNodeDevicePtr nodedev =3D NULL; =20 virCheckFlags(0, -1); =20 - xml =3D virNodeDeviceGetXMLDesc(dev, 0); + if (!(nodeconn =3D virGetConnectNodeDev())) + goto cleanup; + + /* 'dev' is associated with the QEMU virConnectPtr, + * so for split daemons, we need to get a copy that + * is associated with the virnodedevd daemon. + */ + if (!(nodedev =3D virNodeDeviceLookupByName( + nodeconn, virNodeDeviceGetName(dev)))) + goto cleanup; + + xml =3D virNodeDeviceGetXMLDesc(nodedev, 0); if (!xml) goto cleanup; =20 @@ -5798,6 +5811,8 @@ libxlNodeDeviceDetachFlags(virNodeDevicePtr dev, if (!def) goto cleanup; =20 + /* ACL check must happen against original 'dev', + * not the new 'nodedev' we acquired */ if (virNodeDeviceDetachFlagsEnsureACL(dev->conn, def) < 0) goto cleanup; =20 @@ -5823,6 +5838,10 @@ libxlNodeDeviceDetachFlags(virNodeDevicePtr dev, cleanup: virPCIDeviceFree(pci); virNodeDeviceDefFree(def); + if (nodedev) + virNodeDeviceFree(nodedev); + if (nodeconn) + virConnectClose(nodeconn); VIR_FREE(xml); return ret; } @@ -5843,8 +5862,21 @@ libxlNodeDeviceReAttach(virNodeDevicePtr dev) char *xml =3D NULL; libxlDriverPrivatePtr driver =3D dev->conn->privateData; virHostdevManagerPtr hostdev_mgr =3D driver->hostdevMgr; + virConnectPtr nodeconn =3D NULL; + virNodeDevicePtr nodedev =3D NULL; + + if (!(nodeconn =3D virGetConnectNodeDev())) + goto cleanup; =20 - xml =3D virNodeDeviceGetXMLDesc(dev, 0); + /* 'dev' is associated with the QEMU virConnectPtr, + * so for split daemons, we need to get a copy that + * is associated with the virnodedevd daemon. + */ + if (!(nodedev =3D virNodeDeviceLookupByName( + nodeconn, virNodeDeviceGetName(dev)))) + goto cleanup; + + xml =3D virNodeDeviceGetXMLDesc(nodedev, 0); if (!xml) goto cleanup; =20 @@ -5852,6 +5884,8 @@ libxlNodeDeviceReAttach(virNodeDevicePtr dev) if (!def) goto cleanup; =20 + /* ACL check must happen against original 'dev', + * not the new 'nodedev' we acquired */ if (virNodeDeviceReAttachEnsureACL(dev->conn, def) < 0) goto cleanup; =20 @@ -5870,6 +5904,10 @@ libxlNodeDeviceReAttach(virNodeDevicePtr dev) cleanup: virPCIDeviceFree(pci); virNodeDeviceDefFree(def); + if (nodedev) + virNodeDeviceFree(nodedev); + if (nodeconn) + virConnectClose(nodeconn); VIR_FREE(xml); return ret; } @@ -5884,8 +5922,21 @@ libxlNodeDeviceReset(virNodeDevicePtr dev) char *xml =3D NULL; libxlDriverPrivatePtr driver =3D dev->conn->privateData; virHostdevManagerPtr hostdev_mgr =3D driver->hostdevMgr; + virConnectPtr nodeconn =3D NULL; + virNodeDevicePtr nodedev =3D NULL; + + if (!(nodeconn =3D virGetConnectNodeDev())) + goto cleanup; + + /* 'dev' is associated with the QEMU virConnectPtr, + * so for split daemons, we need to get a copy that + * is associated with the virnodedevd daemon. + */ + if (!(nodedev =3D virNodeDeviceLookupByName( + nodeconn, virNodeDeviceGetName(dev)))) + goto cleanup; =20 - xml =3D virNodeDeviceGetXMLDesc(dev, 0); + xml =3D virNodeDeviceGetXMLDesc(nodedev, 0); if (!xml) goto cleanup; =20 @@ -5893,6 +5944,8 @@ libxlNodeDeviceReset(virNodeDevicePtr dev) if (!def) goto cleanup; =20 + /* ACL check must happen against original 'dev', + * not the new 'nodedev' we acquired */ if (virNodeDeviceResetEnsureACL(dev->conn, def) < 0) goto cleanup; =20 @@ -5911,6 +5964,10 @@ libxlNodeDeviceReset(virNodeDevicePtr dev) cleanup: virPCIDeviceFree(pci); virNodeDeviceDefFree(def); + if (nodedev) + virNodeDeviceFree(nodedev); + if (nodeconn) + virConnectClose(nodeconn); VIR_FREE(xml); return ret; } diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index cd761f87b5..d8f264ba7f 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -12965,10 +12965,23 @@ qemuNodeDeviceDetachFlags(virNodeDevicePtr dev, g_autofree char *xml =3D NULL; bool vfio =3D qemuHostdevHostSupportsPassthroughVFIO(); virHostdevManagerPtr hostdev_mgr =3D driver->hostdevMgr; + virConnectPtr nodeconn =3D NULL; + virNodeDevicePtr nodedev =3D NULL; =20 virCheckFlags(0, -1); =20 - xml =3D virNodeDeviceGetXMLDesc(dev, 0); + if (!(nodeconn =3D virGetConnectNodeDev())) + goto cleanup; + + /* 'dev' is associated with the QEMU virConnectPtr, + * so for split daemons, we need to get a copy that + * is associated with the virnodedevd daemon. + */ + if (!(nodedev =3D virNodeDeviceLookupByName( + nodeconn, virNodeDeviceGetName(dev)))) + goto cleanup; + + xml =3D virNodeDeviceGetXMLDesc(nodedev, 0); if (!xml) goto cleanup; =20 @@ -12976,6 +12989,8 @@ qemuNodeDeviceDetachFlags(virNodeDevicePtr dev, if (!def) goto cleanup; =20 + /* ACL check must happen against original 'dev', + * not the new 'nodedev' we acquired */ if (virNodeDeviceDetachFlagsEnsureACL(dev->conn, def) < 0) goto cleanup; =20 @@ -13012,6 +13027,10 @@ qemuNodeDeviceDetachFlags(virNodeDevicePtr dev, cleanup: virPCIDeviceFree(pci); virNodeDeviceDefFree(def); + if (nodedev) + virNodeDeviceFree(nodedev); + if (nodeconn) + virConnectClose(nodeconn); return ret; } =20 @@ -13031,8 +13050,21 @@ qemuNodeDeviceReAttach(virNodeDevicePtr dev) virNodeDeviceDefPtr def =3D NULL; g_autofree char *xml =3D NULL; virHostdevManagerPtr hostdev_mgr =3D driver->hostdevMgr; + virConnectPtr nodeconn =3D NULL; + virNodeDevicePtr nodedev =3D NULL; + + if (!(nodeconn =3D virGetConnectNodeDev())) + goto cleanup; =20 - xml =3D virNodeDeviceGetXMLDesc(dev, 0); + /* 'dev' is associated with the QEMU virConnectPtr, + * so for split daemons, we need to get a copy that + * is associated with the virnodedevd daemon. + */ + if (!(nodedev =3D virNodeDeviceLookupByName( + nodeconn, virNodeDeviceGetName(dev)))) + goto cleanup; + + xml =3D virNodeDeviceGetXMLDesc(nodedev, 0); if (!xml) goto cleanup; =20 @@ -13040,6 +13072,8 @@ qemuNodeDeviceReAttach(virNodeDevicePtr dev) if (!def) goto cleanup; =20 + /* ACL check must happen against original 'dev', + * not the new 'nodedev' we acquired */ if (virNodeDeviceReAttachEnsureACL(dev->conn, def) < 0) goto cleanup; =20 @@ -13055,6 +13089,10 @@ qemuNodeDeviceReAttach(virNodeDevicePtr dev) virPCIDeviceFree(pci); cleanup: virNodeDeviceDefFree(def); + if (nodedev) + virNodeDeviceFree(nodedev); + if (nodeconn) + virConnectClose(nodeconn); return ret; } =20 @@ -13068,8 +13106,21 @@ qemuNodeDeviceReset(virNodeDevicePtr dev) virNodeDeviceDefPtr def =3D NULL; g_autofree char *xml =3D NULL; virHostdevManagerPtr hostdev_mgr =3D driver->hostdevMgr; + virConnectPtr nodeconn =3D NULL; + virNodeDevicePtr nodedev =3D NULL; + + if (!(nodeconn =3D virGetConnectNodeDev())) + goto cleanup; + + /* 'dev' is associated with the QEMU virConnectPtr, + * so for split daemons, we need to get a copy that + * is associated with the virnodedevd daemon. + */ + if (!(nodedev =3D virNodeDeviceLookupByName( + nodeconn, virNodeDeviceGetName(dev)))) + goto cleanup; =20 - xml =3D virNodeDeviceGetXMLDesc(dev, 0); + xml =3D virNodeDeviceGetXMLDesc(nodedev, 0); if (!xml) goto cleanup; =20 @@ -13077,6 +13128,8 @@ qemuNodeDeviceReset(virNodeDevicePtr dev) if (!def) goto cleanup; =20 + /* ACL check must happen against original 'dev', + * not the new 'nodedev' we acquired */ if (virNodeDeviceResetEnsureACL(dev->conn, def) < 0) goto cleanup; =20 @@ -13092,6 +13145,10 @@ qemuNodeDeviceReset(virNodeDevicePtr dev) virPCIDeviceFree(pci); cleanup: virNodeDeviceDefFree(def); + if (nodedev) + virNodeDeviceFree(nodedev); + if (nodeconn) + virConnectClose(nodeconn); return ret; } =20 --=20 2.24.1