From nobody Thu Oct 31 00:23:43 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; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 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=1633700203; cv=none; d=zohomail.com; s=zohoarc; b=hMzMEhupR5+DhCmtWlPM8a0S5o13CyrbdEZqBqSlNvJ00VHRvkyabtZPX7leCXqgKkrIRBfvUyeghFFuvetFcDOlD/8JlxgcP0N6ZwluAdzLYq83O6YCNcS3CKkDW1N7FUPfnNucgQJ4UJs+yi2bqFJOW/uHKUKuxs6xWrxUT3g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1633700203; h=Content-Type:Content-Transfer-Encoding:Cc: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=qMRjZ6WLEjUe77WmF4qBLUxaeOl4O8zaeA39m27yLOc=; b=h7DnjKXzBwSqdq5HOr81FovlHtq1r8zXxFBG7aDG3slmWUytCnSkp3a0qpP3e3HXPDx6GfjD/dQ0SGK86nNM4cGeWX9ffPS0Ukecp6lcnKCtgpiye0TeqETpWm2t8eeLirntPFo9GTOLZo4LmwQDxHqB+zDJEVY+ZEuCOx/TkKI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) 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 1633700203982834.8798920653039; Fri, 8 Oct 2021 06:36:43 -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-418-_4wc_FfPOreM1zuXArcx6A-1; Fri, 08 Oct 2021 09:36:41 -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 B32B810247CC; Fri, 8 Oct 2021 13:35:08 +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 831A419724; Fri, 8 Oct 2021 13:35:08 +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 3938B1801241; Fri, 8 Oct 2021 13:35:08 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 198DZ5m4026032 for ; Fri, 8 Oct 2021 09:35:05 -0400 Received: by smtp.corp.redhat.com (Postfix) id 426291973B; Fri, 8 Oct 2021 13:35:05 +0000 (UTC) Received: from merkur.redhat.com (unknown [10.39.193.204]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2A9A519724; Fri, 8 Oct 2021 13:35:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1633700202; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc: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=qMRjZ6WLEjUe77WmF4qBLUxaeOl4O8zaeA39m27yLOc=; b=X7SQxmLsHgRcmktBp+jpycer1Lx/ubKxknSHVkhUCUeNfaQycJUYOFBthp9A6aA08szNBB Tx8Insc1OxTj5BDHPllACE63FDfMNDXV10zeri6EgdX+8UIYI/X0zYQZ/hOgXvArnN8tBg wDam9i3HxFJJC5meJgtaMdSj8OgfXus= X-MC-Unique: _4wc_FfPOreM1zuXArcx6A-1 From: Kevin Wolf To: qemu-devel@nongnu.org Subject: [PATCH v2 01/15] net: Introduce NetClientInfo.check_peer_type() Date: Fri, 8 Oct 2021 15:34:28 +0200 Message-Id: <20211008133442.141332-2-kwolf@redhat.com> In-Reply-To: <20211008133442.141332-1-kwolf@redhat.com> References: <20211008133442.141332-1-kwolf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Cc: kwolf@redhat.com, damien.hedde@greensocs.com, pkrempa@redhat.com, ehabkost@redhat.com, qemu-block@nongnu.org, mst@redhat.com, libvir-list@redhat.com, jasowang@redhat.com, quintela@redhat.com, armbru@redhat.com, vsementsov@virtuozzo.com, lvivier@redhat.com, its@irrelevant.dk, pbonzini@redhat.com, eblake@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 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 X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1633700205752100001 Content-Type: text/plain; charset="utf-8" Some network backends (vhost-user and vhost-vdpa) work only with specific devices. At startup, they second guess what the command line option handling will do and error out if they think a non-virtio device will attach to them. This second guessing is not only ugly, it can lead to wrong error messages ('-device floppy,netdev=3Dfoo' should complain about an unknown property, not about the wrong kind of network device being attached) and completely ignores hotplugging. Add a callback where backends can check compatibility with a device when it actually tries to attach, even on hotplug. Signed-off-by: Kevin Wolf Acked-by: Jason Wang Reviewed-by: Damien Hedde --- include/net/net.h | 2 ++ hw/core/qdev-properties-system.c | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/include/net/net.h b/include/net/net.h index 5d1508081f..986288eb07 100644 --- a/include/net/net.h +++ b/include/net/net.h @@ -62,6 +62,7 @@ typedef struct SocketReadState SocketReadState; typedef void (SocketReadStateFinalize)(SocketReadState *rs); typedef void (NetAnnounce)(NetClientState *); typedef bool (SetSteeringEBPF)(NetClientState *, int); +typedef bool (NetCheckPeerType)(NetClientState *, ObjectClass *, Error **); =20 typedef struct NetClientInfo { NetClientDriver type; @@ -84,6 +85,7 @@ typedef struct NetClientInfo { SetVnetBE *set_vnet_be; NetAnnounce *announce; SetSteeringEBPF *set_steering_ebpf; + NetCheckPeerType *check_peer_type; } NetClientInfo; =20 struct NetClientState { diff --git a/hw/core/qdev-properties-system.c b/hw/core/qdev-properties-sys= tem.c index e71f5d64d1..a91f60567a 100644 --- a/hw/core/qdev-properties-system.c +++ b/hw/core/qdev-properties-system.c @@ -431,6 +431,12 @@ static void set_netdev(Object *obj, Visitor *v, const = char *name, goto out; } =20 + if (peers[i]->info->check_peer_type) { + if (!peers[i]->info->check_peer_type(peers[i], obj->class, err= p)) { + goto out; + } + } + ncs[i] =3D peers[i]; ncs[i]->queue_index =3D i; } --=20 2.31.1