From nobody Sat Feb 7 05:01:07 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1634309433; cv=none; d=zohomail.com; s=zohoarc; b=nkfgtFiEmflI8AP8dYYKPat5EMTJIhWqQDQuB8X6ADd++RUoetJrhRdH8aBjjoaaKG/8V0vjrRWAKM8QtQ1IdQJ2NDbvw6Y1Hk6hAv6YEkvj/9rKs1l+Y4ayl7URNm+7+6icMuS+IUeg1DBykWDAFjmQuJKohR4ndXg96IODOFs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1634309433; 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=ckAhHJNXd2DDZTBa58nv8L2ZuPl5dBrsmiXNpboTThU=; b=FYc0lqmeOsgW/ETwiyTPzyZnMh6ySjKlnj0vVoHZPmGsbMVoAj6qhknpSji3nOv6cV8XWCnEIIXz6QQdcT9FXalNTUhJwt+UeVl6Kxbz0EWD/ClMpVpu1E4LhVK3WU1w6GZZ4QDTJhTHrShu8QUCM58qGSDfaPZIqm+gzDhPqR0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1634309433924285.88045978531466; Fri, 15 Oct 2021 07:50:33 -0700 (PDT) Received: from localhost ([::1]:46096 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mbOXY-0002Cs-3k for importer@patchew.org; Fri, 15 Oct 2021 10:50:32 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59192) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mbOVY-00086w-BT for qemu-devel@nongnu.org; Fri, 15 Oct 2021 10:48:28 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:49948) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mbOVV-0001T6-0I for qemu-devel@nongnu.org; Fri, 15 Oct 2021 10:48:26 -0400 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-128-Vonz5hmBOQ6QboIn9qTC0g-1; Fri, 15 Oct 2021 10:48:21 -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 CE39780365C for ; Fri, 15 Oct 2021 14:48:20 +0000 (UTC) Received: from merkur.fritz.box (unknown [10.39.193.44]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3386619736; Fri, 15 Oct 2021 14:48:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1634309303; h=from:from: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; bh=ckAhHJNXd2DDZTBa58nv8L2ZuPl5dBrsmiXNpboTThU=; b=GzsyAeGOKILDWvrC5lKe+JCywEjD4sqdcsmZaCpA9blHlDJGg5ULuRaTc4nAtlAiFitdaY 4QRTuOU2QDDhN2UeMAiL9mRR8CeYDs4ld4ZUH92Q2kyDlXC7mcAEHGEd+NyUJhcgg5SGvp WPvZqhsm2KHf2nAe2BddjK2Hqhxi2xk= X-MC-Unique: Vonz5hmBOQ6QboIn9qTC0g-1 From: Kevin Wolf To: qemu-devel@nongnu.org Subject: [PULL 01/15] net: Introduce NetClientInfo.check_peer_type() Date: Fri, 15 Oct 2021 16:46:26 +0200 Message-Id: <20211015144640.198044-2-kwolf@redhat.com> In-Reply-To: <20211015144640.198044-1-kwolf@redhat.com> References: <20211015144640.198044-1-kwolf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=kwolf@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=kwolf@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.049, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1634309436399100001 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 Message-Id: <20211008133442.141332-2-kwolf@redhat.com> Reviewed-by: Damien Hedde Acked-by: Jason Wang Reviewed-by: Michael S. Tsirkin Tested-by: Peter Krempa Signed-off-by: Kevin Wolf --- 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