From nobody Fri May 3 15:00:59 2024 Delivered-To: importer2@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+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1652843964; cv=none; d=zohomail.com; s=zohoarc; b=VFdgtVgVDd2LcdX/mlYfiyH+WD5o4arVn6jOJ13mG8A/K3UVzb7jZq2cQ9xW8LkBEnWpEeWAgr0E+cmqWOqJmk0qR7qs8oAy9q/LA42jXaxcktovG2TY1GbaoR1vkjn15X5iAomZbNujFyYqwB4r3oYZlSG7vnwMUbHanvbs1F4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1652843964; 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=vsSZDH1m9868V116vfpQyPNdE0S6lB7OhpLwIQbLZe8=; b=hj0wdqUgvOP26zddvKAjP8N3yZCDR4rjv/AkuNuY/HImQEE0xHUXhpU3jisdrHHMersgJpXlCelYGuDjT0z8JHfgY3Hur1B4ya87gA9+5vTOaIsEoo/EN8Radm0xGQfhLLKnKPiIX99S5p41PPTNUP+4jsl/oD5bE8o2OB9wayk= 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+importer2=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 1652843964108346.644809589465; Tue, 17 May 2022 20:19:24 -0700 (PDT) Received: from localhost ([::1]:44334 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nrADb-0007Xe-4x for importer2@patchew.org; Tue, 17 May 2022 23:19:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55596) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nrA6t-0006kW-K6 for qemu-devel@nongnu.org; Tue, 17 May 2022 23:12:28 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:25807) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nrA6r-0004mu-Ux for qemu-devel@nongnu.org; Tue, 17 May 2022 23:12:27 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-638-GlS1IvkaOKu_uqSILiMDSA-1; Tue, 17 May 2022 23:12:23 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id E11EA811E75; Wed, 18 May 2022 03:12:22 +0000 (UTC) Received: from localhost.localdomain (ovpn-14-27.pek2.redhat.com [10.72.14.27]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1865D40C1421; Wed, 18 May 2022 03:12:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1652843544; 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=vsSZDH1m9868V116vfpQyPNdE0S6lB7OhpLwIQbLZe8=; b=GW3O+3K5TuraBvoB/lQFSrRnQxFVzLweuymVUDPUQgvPk/6QWFmRhQHobE7IolYQYdznGA +cZzFPlvVHzr3JsyKNtgTPljM47E8ipeD5AAsEy/WIptjQyK//vaBn5PKWYwbv7I0F1aWI 34QXwQsa0pq72NKVtoUqShX1eYZ7keE= X-MC-Unique: GlS1IvkaOKu_uqSILiMDSA-1 From: Jason Wang To: jasowang@redhat.com, qemu-devel@nongnu.org, peter.maydell@linaro.org Cc: Vladislav Yaroshchuk , Akihiko Odaki , Vladislav Yaroshchuk Subject: [PULL 1/8] net/vmnet: add vmnet dependency and customizable option Date: Wed, 18 May 2022 11:12:07 +0800 Message-Id: <20220518031214.93760-2-jasowang@redhat.com> In-Reply-To: <20220518031214.93760-1-jasowang@redhat.com> References: <20220518031214.93760-1-jasowang@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 2.84 on 10.11.54.2 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+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=jasowang@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.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1652843965945100001 Content-Type: text/plain; charset="utf-8" From: Vladislav Yaroshchuk vmnet.framework dependency is added with 'vmnet' option to enable or disable it. Default value is 'auto'. used vmnet features are available since macOS 11.0, but new backend can be built and work properly with subset of them on 10.15 too. Reviewed-by: Akihiko Odaki Tested-by: Akihiko Odaki Signed-off-by: Vladislav Yaroshchuk Signed-off-by: Jason Wang --- meson.build | 16 +++++++++++++++- meson_options.txt | 2 ++ scripts/meson-buildoptions.sh | 1 + 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/meson.build b/meson.build index 53a4728250..52f6befc0f 100644 --- a/meson.build +++ b/meson.build @@ -580,6 +580,18 @@ if cocoa.found() and get_option('gtk').enabled() error('Cocoa and GTK+ cannot be enabled at the same time') endif =20 +vmnet =3D dependency('appleframeworks', modules: 'vmnet', required: get_op= tion('vmnet')) +if vmnet.found() and not cc.has_header_symbol('vmnet/vmnet.h', + 'VMNET_BRIDGED_MODE', + dependencies: vmnet) + vmnet =3D not_found + if get_option('vmnet').enabled() + error('vmnet.framework API is outdated') + else + warning('vmnet.framework API is outdated, disabling') + endif +endif + seccomp =3D not_found if not get_option('seccomp').auto() or have_system or have_tools seccomp =3D dependency('libseccomp', version: '>=3D2.3.0', @@ -1741,6 +1753,7 @@ config_host_data.set('CONFIG_VHOST_KERNEL', have_vhos= t_kernel) config_host_data.set('CONFIG_VHOST_USER', have_vhost_user) config_host_data.set('CONFIG_VHOST_CRYPTO', have_vhost_user_crypto) config_host_data.set('CONFIG_VHOST_VDPA', have_vhost_vdpa) +config_host_data.set('CONFIG_VMNET', vmnet.found()) config_host_data.set('CONFIG_VHOST_USER_BLK_SERVER', have_vhost_user_blk_s= erver) config_host_data.set('CONFIG_PNG', png.found()) config_host_data.set('CONFIG_VNC', vnc.found()) @@ -3897,7 +3910,8 @@ summary(summary_info, bool_yn: true, section: 'Crypto= ') # Libraries summary_info =3D {} if targetos =3D=3D 'darwin' - summary_info +=3D {'Cocoa support': cocoa} + summary_info +=3D {'Cocoa support': cocoa} + summary_info +=3D {'vmnet.framework support': vmnet} endif summary_info +=3D {'SDL support': sdl} summary_info +=3D {'SDL image support': sdl_image} diff --git a/meson_options.txt b/meson_options.txt index 29c6b90cec..7325cdad45 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -197,6 +197,8 @@ option('netmap', type : 'feature', value : 'auto', description: 'netmap network backend support') option('vde', type : 'feature', value : 'auto', description: 'vde network backend support') +option('vmnet', type : 'feature', value : 'auto', + description: 'vmnet.framework network backend support') option('virglrenderer', type : 'feature', value : 'auto', description: 'virgl rendering support') option('png', type : 'feature', value : 'auto', diff --git a/scripts/meson-buildoptions.sh b/scripts/meson-buildoptions.sh index 5d2172bfb4..9b0d151dad 100644 --- a/scripts/meson-buildoptions.sh +++ b/scripts/meson-buildoptions.sh @@ -158,6 +158,7 @@ meson_options_help() { printf "%s\n" ' vhost-kernel vhost kernel backend support' printf "%s\n" ' vhost-net vhost-net kernel acceleration support' printf "%s\n" ' vhost-user vhost-user backend support' + printf "%s\n" ' vmnet vmnet.framework network backend support' printf "%s\n" ' vhost-user-blk-server' printf "%s\n" ' build vhost-user-blk server' printf "%s\n" ' vhost-vdpa vhost-vdpa kernel backend support' --=20 2.25.1 From nobody Fri May 3 15:00:59 2024 Delivered-To: importer2@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+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1652843756; cv=none; d=zohomail.com; s=zohoarc; b=gJ5oECQuxIy7Ip4/MJJE2BElklFyq1t27ga0zvZacjXHxUOXebZ7l/ymf5oRC2ZhqcaLpVwCUH3tQ2RK60fbFIsM4Lto0NGFLMH1xQTlJLpOHIYrYfdEulDwRmijEGTNf4WF3nd64YKhsFEm6lFKhW8UQQmJc4pOMMvNdPwMWNA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1652843756; 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=InaR8eLlgRfR7DlEsFRstB4rWgnShC26XERHLpGLgV4=; b=AbNaxYeGkGBuLuZdFDi+ipo58pHyR31cQTtgy2c3HnbTQA3wqdCIky19FILzfrvnAgO0eO+Spn6jTZuRDZFpqsXW5Ob5qMSIzKCpymPLXlMDfdmBHo777MOUbrzGYS2YPTkQ0sa43VY2GM+HUoChdinJK0vUIDJbIaxwsh06664= 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+importer2=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 165284375603615.050065496216007; Tue, 17 May 2022 20:15:56 -0700 (PDT) Received: from localhost ([::1]:35116 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nrAAE-0001BJ-W0 for importer2@patchew.org; Tue, 17 May 2022 23:15:55 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55638) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nrA70-0006py-LR for qemu-devel@nongnu.org; Tue, 17 May 2022 23:12:35 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:46364) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nrA6x-0004nD-4d for qemu-devel@nongnu.org; Tue, 17 May 2022 23:12:33 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-335-esmil93zN0q2hbg88C9dig-1; Tue, 17 May 2022 23:12:27 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id C31CB101AA42; Wed, 18 May 2022 03:12:26 +0000 (UTC) Received: from localhost.localdomain (ovpn-14-27.pek2.redhat.com [10.72.14.27]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9B4E1400E114; Wed, 18 May 2022 03:12:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1652843550; 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=InaR8eLlgRfR7DlEsFRstB4rWgnShC26XERHLpGLgV4=; b=R/gstp7gwTVScAPNt+IU9HeDzg3Vx/KFulKiOmudBf9iWU7tFYj/S9b7H5g3y+zTECpZC6 wZwJ1uVsbsb+2Z0DmkBHCXht2Ji9aH4Z8yO55DISic1nUzv49wfCteLiDtztDm1p4RW5rN gdpRoTFrZIeEMUOiuKYSYN+5Nx4am5E= X-MC-Unique: esmil93zN0q2hbg88C9dig-1 From: Jason Wang To: jasowang@redhat.com, qemu-devel@nongnu.org, peter.maydell@linaro.org Cc: Vladislav Yaroshchuk , Akihiko Odaki , Markus Armbruster , Vladislav Yaroshchuk Subject: [PULL 2/8] net/vmnet: add vmnet backends to qapi/net Date: Wed, 18 May 2022 11:12:08 +0800 Message-Id: <20220518031214.93760-3-jasowang@redhat.com> In-Reply-To: <20220518031214.93760-1-jasowang@redhat.com> References: <20220518031214.93760-1-jasowang@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 2.84 on 10.11.54.2 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+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=jasowang@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.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1652843757101100003 Content-Type: text/plain; charset="utf-8" From: Vladislav Yaroshchuk Create separate netdevs for each vmnet operating mode: - vmnet-host - vmnet-shared - vmnet-bridged Reviewed-by: Akihiko Odaki Tested-by: Akihiko Odaki Acked-by: Markus Armbruster Signed-off-by: Vladislav Yaroshchuk Signed-off-by: Jason Wang --- net/clients.h | 11 ++++ net/meson.build | 7 +++ net/net.c | 10 ++++ net/vmnet-bridged.m | 25 +++++++++ net/vmnet-common.m | 19 +++++++ net/vmnet-host.c | 24 ++++++++ net/vmnet-shared.c | 25 +++++++++ net/vmnet_int.h | 25 +++++++++ qapi/net.json | 133 +++++++++++++++++++++++++++++++++++++++++++- 9 files changed, 277 insertions(+), 2 deletions(-) create mode 100644 net/vmnet-bridged.m create mode 100644 net/vmnet-common.m create mode 100644 net/vmnet-host.c create mode 100644 net/vmnet-shared.c create mode 100644 net/vmnet_int.h diff --git a/net/clients.h b/net/clients.h index 92f9b59aed..c9157789f2 100644 --- a/net/clients.h +++ b/net/clients.h @@ -63,4 +63,15 @@ int net_init_vhost_user(const Netdev *netdev, const char= *name, =20 int net_init_vhost_vdpa(const Netdev *netdev, const char *name, NetClientState *peer, Error **errp); +#ifdef CONFIG_VMNET +int net_init_vmnet_host(const Netdev *netdev, const char *name, + NetClientState *peer, Error **errp); + +int net_init_vmnet_shared(const Netdev *netdev, const char *name, + NetClientState *peer, Error **errp); + +int net_init_vmnet_bridged(const Netdev *netdev, const char *name, + NetClientState *peer, Error **errp); +#endif /* CONFIG_VMNET */ + #endif /* QEMU_NET_CLIENTS_H */ diff --git a/net/meson.build b/net/meson.build index c965e83b26..754e2d1d40 100644 --- a/net/meson.build +++ b/net/meson.build @@ -44,4 +44,11 @@ if have_vhost_net_vdpa softmmu_ss.add(files('vhost-vdpa.c')) endif =20 +vmnet_files =3D files( + 'vmnet-common.m', + 'vmnet-bridged.m', + 'vmnet-host.c', + 'vmnet-shared.c' +) +softmmu_ss.add(when: vmnet, if_true: vmnet_files) subdir('can') diff --git a/net/net.c b/net/net.c index a094cf1d29..2db160e063 100644 --- a/net/net.c +++ b/net/net.c @@ -1020,6 +1020,11 @@ static int (* const net_client_init_fun[NET_CLIENT_D= RIVER__MAX])( #ifdef CONFIG_L2TPV3 [NET_CLIENT_DRIVER_L2TPV3] =3D net_init_l2tpv3, #endif +#ifdef CONFIG_VMNET + [NET_CLIENT_DRIVER_VMNET_HOST] =3D net_init_vmnet_host, + [NET_CLIENT_DRIVER_VMNET_SHARED] =3D net_init_vmnet_shared, + [NET_CLIENT_DRIVER_VMNET_BRIDGED] =3D net_init_vmnet_bridged, +#endif /* CONFIG_VMNET */ }; =20 =20 @@ -1105,6 +1110,11 @@ void show_netdevs(void) #endif #ifdef CONFIG_VHOST_VDPA "vhost-vdpa", +#endif +#ifdef CONFIG_VMNET + "vmnet-host", + "vmnet-shared", + "vmnet-bridged", #endif }; =20 diff --git a/net/vmnet-bridged.m b/net/vmnet-bridged.m new file mode 100644 index 0000000000..91c1a2f2c7 --- /dev/null +++ b/net/vmnet-bridged.m @@ -0,0 +1,25 @@ +/* + * vmnet-bridged.m + * + * Copyright(c) 2022 Vladislav Yaroshchuk + * + * This work is licensed under the terms of the GNU GPL, version 2 or late= r. + * See the COPYING file in the top-level directory. + * + */ + +#include "qemu/osdep.h" +#include "qapi/qapi-types-net.h" +#include "vmnet_int.h" +#include "clients.h" +#include "qemu/error-report.h" +#include "qapi/error.h" + +#include + +int net_init_vmnet_bridged(const Netdev *netdev, const char *name, + NetClientState *peer, Error **errp) +{ + error_setg(errp, "vmnet-bridged is not implemented yet"); + return -1; +} diff --git a/net/vmnet-common.m b/net/vmnet-common.m new file mode 100644 index 0000000000..3bf42fc643 --- /dev/null +++ b/net/vmnet-common.m @@ -0,0 +1,19 @@ +/* + * vmnet-common.m - network client wrapper for Apple vmnet.framework + * + * Copyright(c) 2022 Vladislav Yaroshchuk + * Copyright(c) 2021 Phillip Tennen + * + * This work is licensed under the terms of the GNU GPL, version 2 or late= r. + * See the COPYING file in the top-level directory. + * + */ + +#include "qemu/osdep.h" +#include "qapi/qapi-types-net.h" +#include "vmnet_int.h" +#include "clients.h" +#include "qemu/error-report.h" +#include "qapi/error.h" + +#include diff --git a/net/vmnet-host.c b/net/vmnet-host.c new file mode 100644 index 0000000000..a461d507c5 --- /dev/null +++ b/net/vmnet-host.c @@ -0,0 +1,24 @@ +/* + * vmnet-host.c + * + * Copyright(c) 2022 Vladislav Yaroshchuk + * + * This work is licensed under the terms of the GNU GPL, version 2 or late= r. + * See the COPYING file in the top-level directory. + * + */ + +#include "qemu/osdep.h" +#include "qapi/qapi-types-net.h" +#include "vmnet_int.h" +#include "clients.h" +#include "qemu/error-report.h" +#include "qapi/error.h" + +#include + +int net_init_vmnet_host(const Netdev *netdev, const char *name, + NetClientState *peer, Error **errp) { + error_setg(errp, "vmnet-host is not implemented yet"); + return -1; +} diff --git a/net/vmnet-shared.c b/net/vmnet-shared.c new file mode 100644 index 0000000000..6dfb133a18 --- /dev/null +++ b/net/vmnet-shared.c @@ -0,0 +1,25 @@ +/* + * vmnet-shared.c + * + * Copyright(c) 2022 Vladislav Yaroshchuk + * + * This work is licensed under the terms of the GNU GPL, version 2 or late= r. + * See the COPYING file in the top-level directory. + * + */ + +#include "qemu/osdep.h" +#include "qapi/qapi-types-net.h" +#include "vmnet_int.h" +#include "clients.h" +#include "qemu/error-report.h" +#include "qapi/error.h" + +#include + +int net_init_vmnet_shared(const Netdev *netdev, const char *name, + NetClientState *peer, Error **errp) +{ + error_setg(errp, "vmnet-shared is not implemented yet"); + return -1; +} diff --git a/net/vmnet_int.h b/net/vmnet_int.h new file mode 100644 index 0000000000..c383038a1d --- /dev/null +++ b/net/vmnet_int.h @@ -0,0 +1,25 @@ +/* + * vmnet_int.h + * + * Copyright(c) 2022 Vladislav Yaroshchuk + * + * This work is licensed under the terms of the GNU GPL, version 2 or late= r. + * See the COPYING file in the top-level directory. + * + */ +#ifndef VMNET_INT_H +#define VMNET_INT_H + +#include "qemu/osdep.h" +#include "vmnet_int.h" +#include "clients.h" + +#include + +typedef struct VmnetState { + NetClientState nc; + +} VmnetState; + + +#endif /* VMNET_INT_H */ diff --git a/qapi/net.json b/qapi/net.json index b92f3f5fb4..d6f7cfd4d6 100644 --- a/qapi/net.json +++ b/qapi/net.json @@ -452,6 +452,120 @@ '*vhostdev': 'str', '*queues': 'int' } } =20 +## +# @NetdevVmnetHostOptions: +# +# vmnet (host mode) network backend. +# +# Allows the vmnet interface to communicate with other vmnet +# interfaces that are in host mode and also with the host. +# +# @start-address: The starting IPv4 address to use for the interface. +# Must be in the private IP range (RFC 1918). Must be +# specified along with @end-address and @subnet-mask. +# This address is used as the gateway address. The +# subsequent address up to and including end-address are +# placed in the DHCP pool. +# +# @end-address: The DHCP IPv4 range end address to use for the +# interface. Must be in the private IP range (RFC 1918). +# Must be specified along with @start-address and +# @subnet-mask. +# +# @subnet-mask: The IPv4 subnet mask to use on the interface. Must +# be specified along with @start-address and @subnet-mask. +# +# @isolated: Enable isolation for this interface. Interface isolation +# ensures that vmnet interface is not able to communicate +# with any other vmnet interfaces. Only communication with +# host is allowed. Requires at least macOS Big Sur 11.0. +# +# @net-uuid: The identifier (UUID) to uniquely identify the isolated +# network vmnet interface should be added to. If +# set, no DHCP service is provided for this interface and +# network communication is allowed only with other interfaces +# added to this network identified by the UUID. Requires +# at least macOS Big Sur 11.0. +# +# Since: 7.1 +## +{ 'struct': 'NetdevVmnetHostOptions', + 'data': { + '*start-address': 'str', + '*end-address': 'str', + '*subnet-mask': 'str', + '*isolated': 'bool', + '*net-uuid': 'str' }, + 'if': 'CONFIG_VMNET' } + +## +# @NetdevVmnetSharedOptions: +# +# vmnet (shared mode) network backend. +# +# Allows traffic originating from the vmnet interface to reach the +# Internet through a network address translator (NAT). +# The vmnet interface can communicate with the host and with +# other shared mode interfaces on the same subnet. If no DHCP +# settings, subnet mask and IPv6 prefix specified, the interface can +# communicate with any of other interfaces in shared mode. +# +# @start-address: The starting IPv4 address to use for the interface. +# Must be in the private IP range (RFC 1918). Must be +# specified along with @end-address and @subnet-mask. +# This address is used as the gateway address. The +# subsequent address up to and including end-address are +# placed in the DHCP pool. +# +# @end-address: The DHCP IPv4 range end address to use for the +# interface. Must be in the private IP range (RFC 1918). +# Must be specified along with @start-address and @subnet-ma= sk. +# +# @subnet-mask: The IPv4 subnet mask to use on the interface. Must +# be specified along with @start-address and @subnet-mask. +# +# @isolated: Enable isolation for this interface. Interface isolation +# ensures that vmnet interface is not able to communicate +# with any other vmnet interfaces. Only communication with +# host is allowed. Requires at least macOS Big Sur 11.0. +# +# @nat66-prefix: The IPv6 prefix to use into guest network. Must be a +# unique local address i.e. start with fd00::/8 and have +# length of 64. +# +# Since: 7.1 +## +{ 'struct': 'NetdevVmnetSharedOptions', + 'data': { + '*start-address': 'str', + '*end-address': 'str', + '*subnet-mask': 'str', + '*isolated': 'bool', + '*nat66-prefix': 'str' }, + 'if': 'CONFIG_VMNET' } + +## +# @NetdevVmnetBridgedOptions: +# +# vmnet (bridged mode) network backend. +# +# Bridges the vmnet interface with a physical network interface. +# +# @ifname: The name of the physical interface to be bridged. +# +# @isolated: Enable isolation for this interface. Interface isolation +# ensures that vmnet interface is not able to communicate +# with any other vmnet interfaces. Only communication with +# host is allowed. Requires at least macOS Big Sur 11.0. +# +# Since: 7.1 +## +{ 'struct': 'NetdevVmnetBridgedOptions', + 'data': { + 'ifname': 'str', + '*isolated': 'bool' }, + 'if': 'CONFIG_VMNET' } + ## # @NetClientDriver: # @@ -460,10 +574,16 @@ # Since: 2.7 # # @vhost-vdpa since 5.1 +# @vmnet-host since 7.1 +# @vmnet-shared since 7.1 +# @vmnet-bridged since 7.1 ## { 'enum': 'NetClientDriver', 'data': [ 'none', 'nic', 'user', 'tap', 'l2tpv3', 'socket', 'vde', - 'bridge', 'hubport', 'netmap', 'vhost-user', 'vhost-vdpa' ] } + 'bridge', 'hubport', 'netmap', 'vhost-user', 'vhost-vdpa', + { 'name': 'vmnet-host', 'if': 'CONFIG_VMNET' }, + { 'name': 'vmnet-shared', 'if': 'CONFIG_VMNET' }, + { 'name': 'vmnet-bridged', 'if': 'CONFIG_VMNET' }] } =20 ## # @Netdev: @@ -477,6 +597,9 @@ # Since: 1.2 # # 'l2tpv3' - since 2.1 +# 'vmnet-host' - since 7.1 +# 'vmnet-shared' - since 7.1 +# 'vmnet-bridged' - since 7.1 ## { 'union': 'Netdev', 'base': { 'id': 'str', 'type': 'NetClientDriver' }, @@ -492,7 +615,13 @@ 'hubport': 'NetdevHubPortOptions', 'netmap': 'NetdevNetmapOptions', 'vhost-user': 'NetdevVhostUserOptions', - 'vhost-vdpa': 'NetdevVhostVDPAOptions' } } + 'vhost-vdpa': 'NetdevVhostVDPAOptions', + 'vmnet-host': { 'type': 'NetdevVmnetHostOptions', + 'if': 'CONFIG_VMNET' }, + 'vmnet-shared': { 'type': 'NetdevVmnetSharedOptions', + 'if': 'CONFIG_VMNET' }, + 'vmnet-bridged': { 'type': 'NetdevVmnetBridgedOptions', + 'if': 'CONFIG_VMNET' } } } =20 ## # @RxState: --=20 2.25.1 From nobody Fri May 3 15:00:59 2024 Delivered-To: importer2@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+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1652844125; cv=none; d=zohomail.com; s=zohoarc; b=hiriyINSQccmC8NsAOLT4KA/Q/2wmkyjMSoGTzTvtGkVEEBPo+ioZwKaCpTDtizWSE1jfNB9LpQJzzqG+8zBtIvAS663e2bNqc/P6uRMK4o/b2mtVtX+7Mj2Li6ybRCqQbn9PUDa9XcruXzdioTaTMU35WQ1rcU59PatF/fpzrI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1652844125; 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=ayF4F+uxwPPb8KFRGAu6UrRmBMiL7U/I9AVyzFAUsZE=; b=n+ZOcYqS2ncZJgYNsCRGyTiVfsSyMkBfyYHaknjklMmOnwjvoJz6dhnnlT119KZFpay2b5MRBRzcBYPnncF+qDy9TqoRDLhpXWqX3Rtyz3vYGkbgO4tAom0rw8itXI0VZ8j4TpincXHtQPxQ1OURFWrUAVffam/sJZMSzNeVPMg= 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+importer2=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 1652844125231890.185209167403; Tue, 17 May 2022 20:22:05 -0700 (PDT) Received: from localhost ([::1]:51138 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nrAGB-0003pz-Fs for importer2@patchew.org; Tue, 17 May 2022 23:22:03 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55652) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nrA73-0006rk-MG for qemu-devel@nongnu.org; Tue, 17 May 2022 23:12:42 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:55135) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nrA71-0004ng-0R for qemu-devel@nongnu.org; Tue, 17 May 2022 23:12:37 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-280-s8En_XYbOfapc3UJzbabeA-1; Tue, 17 May 2022 23:12:31 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 0219285A5A8; Wed, 18 May 2022 03:12:31 +0000 (UTC) Received: from localhost.localdomain (ovpn-14-27.pek2.redhat.com [10.72.14.27]) by smtp.corp.redhat.com (Postfix) with ESMTP id A40FC40C1421; Wed, 18 May 2022 03:12:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1652843554; 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=ayF4F+uxwPPb8KFRGAu6UrRmBMiL7U/I9AVyzFAUsZE=; b=JxGMhA/uqabGkxDDU/gsSBQCuEvfMm5rFUp+ND/jDLctNa4YczuFAyPli2HNrFhv7Mdqdl dvHMIK/Ok8LP4vZ+dRcEN8UPnsCHe47WeruTdEGA4W9vOb4NYqrXb/DEzQalfwevsKwBg5 NkOhe0OqazccdmzoH6WqEXfCQmvF6UY= X-MC-Unique: s8En_XYbOfapc3UJzbabeA-1 From: Jason Wang To: jasowang@redhat.com, qemu-devel@nongnu.org, peter.maydell@linaro.org Cc: Vladislav Yaroshchuk , Akihiko Odaki , Phillip Tennen , Vladislav Yaroshchuk Subject: [PULL 3/8] net/vmnet: implement shared mode (vmnet-shared) Date: Wed, 18 May 2022 11:12:09 +0800 Message-Id: <20220518031214.93760-4-jasowang@redhat.com> In-Reply-To: <20220518031214.93760-1-jasowang@redhat.com> References: <20220518031214.93760-1-jasowang@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 2.84 on 10.11.54.2 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+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=jasowang@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.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1652844126967100001 Content-Type: text/plain; charset="utf-8" From: Vladislav Yaroshchuk Interaction with vmnet.framework in different modes differs only on configuration stage, so we can create common `send`, `receive`, etc. procedures and reuse them. Reviewed-by: Akihiko Odaki Tested-by: Akihiko Odaki Signed-off-by: Phillip Tennen Signed-off-by: Vladislav Yaroshchuk Signed-off-by: Jason Wang --- net/vmnet-common.m | 359 +++++++++++++++++++++++++++++++++++++++++++++ net/vmnet-shared.c | 97 +++++++++++- net/vmnet_int.h | 40 ++++- 3 files changed, 491 insertions(+), 5 deletions(-) diff --git a/net/vmnet-common.m b/net/vmnet-common.m index 3bf42fc643..2cb60b9ddd 100644 --- a/net/vmnet-common.m +++ b/net/vmnet-common.m @@ -10,6 +10,8 @@ */ =20 #include "qemu/osdep.h" +#include "qemu/main-loop.h" +#include "qemu/log.h" #include "qapi/qapi-types-net.h" #include "vmnet_int.h" #include "clients.h" @@ -17,3 +19,360 @@ #include "qapi/error.h" =20 #include +#include + + +static void vmnet_send_completed(NetClientState *nc, ssize_t len); + + +const char *vmnet_status_map_str(vmnet_return_t status) +{ + switch (status) { + case VMNET_SUCCESS: + return "success"; + case VMNET_FAILURE: + return "general failure (possibly not enough privileges)"; + case VMNET_MEM_FAILURE: + return "memory allocation failure"; + case VMNET_INVALID_ARGUMENT: + return "invalid argument specified"; + case VMNET_SETUP_INCOMPLETE: + return "interface setup is not complete"; + case VMNET_INVALID_ACCESS: + return "invalid access, permission denied"; + case VMNET_PACKET_TOO_BIG: + return "packet size is larger than MTU"; + case VMNET_BUFFER_EXHAUSTED: + return "buffers exhausted in kernel"; + case VMNET_TOO_MANY_PACKETS: + return "packet count exceeds limit"; +#if defined(MAC_OS_VERSION_11_0) && \ + MAC_OS_X_VERSION_MIN_REQUIRED >=3D MAC_OS_VERSION_11_0 + case VMNET_SHARING_SERVICE_BUSY: + return "conflict, sharing service is in use"; +#endif + default: + return "unknown vmnet error"; + } +} + + +/** + * Write packets from QEMU to vmnet interface. + * + * vmnet.framework supports iov, but writing more than + * one iov into vmnet interface fails with + * 'VMNET_INVALID_ARGUMENT'. Collecting provided iovs into + * one and passing it to vmnet works fine. That's the + * reason why receive_iov() left unimplemented. But it still + * works with good performance having .receive() only. + */ +ssize_t vmnet_receive_common(NetClientState *nc, + const uint8_t *buf, + size_t size) +{ + VmnetState *s =3D DO_UPCAST(VmnetState, nc, nc); + struct vmpktdesc packet; + struct iovec iov; + int pkt_cnt; + vmnet_return_t if_status; + + if (size > s->max_packet_size) { + warn_report("vmnet: packet is too big, %zu > %" PRIu64, + packet.vm_pkt_size, + s->max_packet_size); + return -1; + } + + iov.iov_base =3D (char *) buf; + iov.iov_len =3D size; + + packet.vm_pkt_iovcnt =3D 1; + packet.vm_flags =3D 0; + packet.vm_pkt_size =3D size; + packet.vm_pkt_iov =3D &iov; + pkt_cnt =3D 1; + + if_status =3D vmnet_write(s->vmnet_if, &packet, &pkt_cnt); + if (if_status !=3D VMNET_SUCCESS) { + error_report("vmnet: write error: %s\n", + vmnet_status_map_str(if_status)); + return -1; + } + + if (pkt_cnt) { + return size; + } + return 0; +} + + +/** + * Read packets from vmnet interface and write them + * to temporary buffers in VmnetState. + * + * Returns read packets number (may be 0) on success, + * -1 on error + */ +static int vmnet_read_packets(VmnetState *s) +{ + assert(s->packets_send_current_pos =3D=3D s->packets_send_end_pos); + + struct vmpktdesc *packets =3D s->packets_buf; + vmnet_return_t status; + int i; + + /* Read as many packets as present */ + s->packets_send_current_pos =3D 0; + s->packets_send_end_pos =3D VMNET_PACKETS_LIMIT; + for (i =3D 0; i < s->packets_send_end_pos; ++i) { + packets[i].vm_pkt_size =3D s->max_packet_size; + packets[i].vm_pkt_iovcnt =3D 1; + packets[i].vm_flags =3D 0; + } + + status =3D vmnet_read(s->vmnet_if, packets, &s->packets_send_end_pos); + if (status !=3D VMNET_SUCCESS) { + error_printf("vmnet: read failed: %s\n", + vmnet_status_map_str(status)); + s->packets_send_current_pos =3D 0; + s->packets_send_end_pos =3D 0; + return -1; + } + return s->packets_send_end_pos; +} + + +/** + * Write packets from temporary buffers in VmnetState + * to QEMU. + */ +static void vmnet_write_packets_to_qemu(VmnetState *s) +{ + while (s->packets_send_current_pos < s->packets_send_end_pos) { + ssize_t size =3D qemu_send_packet_async(&s->nc, + s->iov_buf[s->packets_send_current_p= os].iov_base, + s->packets_buf[s->packets_send_curre= nt_pos].vm_pkt_size, + vmnet_send_completed); + + if (size =3D=3D 0) { + /* QEMU is not ready to consume more packets - + * stop and wait for completion callback call */ + return; + } + ++s->packets_send_current_pos; + } +} + + +/** + * Bottom half callback that transfers packets from vmnet interface + * to QEMU. + * + * The process of transferring packets is three-staged: + * 1. Handle vmnet event; + * 2. Read packets from vmnet interface into temporary buffer; + * 3. Write packets from temporary buffer to QEMU. + * + * QEMU may suspend this process on the last stage, returning 0 from + * qemu_send_packet_async function. If this happens, we should + * respectfully wait until it is ready to consume more packets, + * write left ones in temporary buffer and only after this + * continue reading more packets from vmnet interface. + * + * Packets to be transferred are stored into packets_buf, + * in the window [packets_send_current_pos..packets_send_end_pos) + * including current_pos, excluding end_pos. + * + * Thus, if QEMU is not ready, buffer is not read and + * packets_send_current_pos < packets_send_end_pos. + */ +static void vmnet_send_bh(void *opaque) +{ + NetClientState *nc =3D (NetClientState *) opaque; + VmnetState *s =3D DO_UPCAST(VmnetState, nc, nc); + + /* + * Do nothing if QEMU is not ready - wait + * for completion callback invocation + */ + if (s->packets_send_current_pos < s->packets_send_end_pos) { + return; + } + + /* Read packets from vmnet interface */ + if (vmnet_read_packets(s) > 0) { + /* Send them to QEMU */ + vmnet_write_packets_to_qemu(s); + } +} + + +/** + * Completion callback to be invoked by QEMU when it becomes + * ready to consume more packets. + */ +static void vmnet_send_completed(NetClientState *nc, ssize_t len) +{ + VmnetState *s =3D DO_UPCAST(VmnetState, nc, nc); + + /* Callback is invoked eq queued packet is sent */ + ++s->packets_send_current_pos; + + /* Complete sending packets left in VmnetState buffers */ + vmnet_write_packets_to_qemu(s); + + /* And read new ones from vmnet if VmnetState buffer is ready */ + if (s->packets_send_current_pos < s->packets_send_end_pos) { + qemu_bh_schedule(s->send_bh); + } +} + + +static void vmnet_bufs_init(VmnetState *s) +{ + struct vmpktdesc *packets =3D s->packets_buf; + struct iovec *iov =3D s->iov_buf; + int i; + + for (i =3D 0; i < VMNET_PACKETS_LIMIT; ++i) { + iov[i].iov_len =3D s->max_packet_size; + iov[i].iov_base =3D g_malloc0(iov[i].iov_len); + packets[i].vm_pkt_iov =3D iov + i; + } +} + + +int vmnet_if_create(NetClientState *nc, + xpc_object_t if_desc, + Error **errp) +{ + VmnetState *s =3D DO_UPCAST(VmnetState, nc, nc); + dispatch_semaphore_t if_created_sem =3D dispatch_semaphore_create(0); + __block vmnet_return_t if_status; + + s->if_queue =3D dispatch_queue_create( + "org.qemu.vmnet.if_queue", + DISPATCH_QUEUE_SERIAL + ); + + xpc_dictionary_set_bool( + if_desc, + vmnet_allocate_mac_address_key, + false + ); + +#ifdef DEBUG + qemu_log("vmnet.start.interface_desc:\n"); + xpc_dictionary_apply(if_desc, + ^bool(const char *k, xpc_object_t v) { + char *desc =3D xpc_copy_description(v); + qemu_log(" %s=3D%s\n", k, desc); + free(desc); + return true; + }); +#endif /* DEBUG */ + + s->vmnet_if =3D vmnet_start_interface( + if_desc, + s->if_queue, + ^(vmnet_return_t status, xpc_object_t interface_param) { + if_status =3D status; + if (status !=3D VMNET_SUCCESS || !interface_param) { + dispatch_semaphore_signal(if_created_sem); + return; + } + +#ifdef DEBUG + qemu_log("vmnet.start.interface_param:\n"); + xpc_dictionary_apply(interface_param, + ^bool(const char *k, xpc_object_t v) { + char *desc =3D xpc_copy_description(v= ); + qemu_log(" %s=3D%s\n", k, desc); + free(desc); + return true; + }); +#endif /* DEBUG */ + + s->mtu =3D xpc_dictionary_get_uint64( + interface_param, + vmnet_mtu_key); + s->max_packet_size =3D xpc_dictionary_get_uint64( + interface_param, + vmnet_max_packet_size_key); + + dispatch_semaphore_signal(if_created_sem); + }); + + if (s->vmnet_if =3D=3D NULL) { + dispatch_release(s->if_queue); + dispatch_release(if_created_sem); + error_setg(errp, + "unable to create interface with requested params"); + return -1; + } + + dispatch_semaphore_wait(if_created_sem, DISPATCH_TIME_FOREVER); + dispatch_release(if_created_sem); + + if (if_status !=3D VMNET_SUCCESS) { + dispatch_release(s->if_queue); + error_setg(errp, + "cannot create vmnet interface: %s", + vmnet_status_map_str(if_status)); + return -1; + } + + s->send_bh =3D aio_bh_new(qemu_get_aio_context(), vmnet_send_bh, nc); + vmnet_bufs_init(s); + + s->packets_send_current_pos =3D 0; + s->packets_send_end_pos =3D 0; + + vmnet_interface_set_event_callback( + s->vmnet_if, + VMNET_INTERFACE_PACKETS_AVAILABLE, + s->if_queue, + ^(interface_event_t event_id, xpc_object_t event) { + assert(event_id =3D=3D VMNET_INTERFACE_PACKETS_AVAILABLE); + /* + * This function is being called from a non qemu thread, so + * we only schedule a BH, and do the rest of the io completion + * handling from vmnet_send_bh() which runs in a qemu context. + */ + qemu_bh_schedule(s->send_bh); + }); + + return 0; +} + + +void vmnet_cleanup_common(NetClientState *nc) +{ + VmnetState *s =3D DO_UPCAST(VmnetState, nc, nc); + dispatch_semaphore_t if_stopped_sem; + + if (s->vmnet_if =3D=3D NULL) { + return; + } + + if_stopped_sem =3D dispatch_semaphore_create(0); + vmnet_stop_interface( + s->vmnet_if, + s->if_queue, + ^(vmnet_return_t status) { + assert(status =3D=3D VMNET_SUCCESS); + dispatch_semaphore_signal(if_stopped_sem); + }); + dispatch_semaphore_wait(if_stopped_sem, DISPATCH_TIME_FOREVER); + + qemu_purge_queued_packets(nc); + + qemu_bh_delete(s->send_bh); + dispatch_release(if_stopped_sem); + dispatch_release(s->if_queue); + + for (int i =3D 0; i < VMNET_PACKETS_LIMIT; ++i) { + g_free(s->iov_buf[i].iov_base); + } +} diff --git a/net/vmnet-shared.c b/net/vmnet-shared.c index 6dfb133a18..18cadc72bd 100644 --- a/net/vmnet-shared.c +++ b/net/vmnet-shared.c @@ -10,16 +10,105 @@ =20 #include "qemu/osdep.h" #include "qapi/qapi-types-net.h" +#include "qapi/error.h" #include "vmnet_int.h" #include "clients.h" -#include "qemu/error-report.h" -#include "qapi/error.h" =20 #include =20 + +static bool validate_options(const Netdev *netdev, Error **errp) +{ + const NetdevVmnetSharedOptions *options =3D &(netdev->u.vmnet_shared); + +#if !defined(MAC_OS_VERSION_11_0) || \ + MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_VERSION_11_0 + if (options->has_isolated) { + error_setg(errp, + "vmnet-shared.isolated feature is " + "unavailable: outdated vmnet.framework API"); + return false; + } +#endif + + if ((options->has_start_address || + options->has_end_address || + options->has_subnet_mask) && + !(options->has_start_address && + options->has_end_address && + options->has_subnet_mask)) { + error_setg(errp, + "'start-address', 'end-address', 'subnet-mask' " + "should be provided together" + ); + return false; + } + + return true; +} + +static xpc_object_t build_if_desc(const Netdev *netdev) +{ + const NetdevVmnetSharedOptions *options =3D &(netdev->u.vmnet_shared); + xpc_object_t if_desc =3D xpc_dictionary_create(NULL, NULL, 0); + + xpc_dictionary_set_uint64( + if_desc, + vmnet_operation_mode_key, + VMNET_SHARED_MODE + ); + + if (options->has_nat66_prefix) { + xpc_dictionary_set_string(if_desc, + vmnet_nat66_prefix_key, + options->nat66_prefix); + } + + if (options->has_start_address) { + xpc_dictionary_set_string(if_desc, + vmnet_start_address_key, + options->start_address); + xpc_dictionary_set_string(if_desc, + vmnet_end_address_key, + options->end_address); + xpc_dictionary_set_string(if_desc, + vmnet_subnet_mask_key, + options->subnet_mask); + } + +#if defined(MAC_OS_VERSION_11_0) && \ + MAC_OS_X_VERSION_MIN_REQUIRED >=3D MAC_OS_VERSION_11_0 + xpc_dictionary_set_bool( + if_desc, + vmnet_enable_isolation_key, + options->isolated + ); +#endif + + return if_desc; +} + +static NetClientInfo net_vmnet_shared_info =3D { + .type =3D NET_CLIENT_DRIVER_VMNET_SHARED, + .size =3D sizeof(VmnetState), + .receive =3D vmnet_receive_common, + .cleanup =3D vmnet_cleanup_common, +}; + int net_init_vmnet_shared(const Netdev *netdev, const char *name, NetClientState *peer, Error **errp) { - error_setg(errp, "vmnet-shared is not implemented yet"); - return -1; + NetClientState *nc =3D qemu_new_net_client(&net_vmnet_shared_info, + peer, "vmnet-shared", name); + xpc_object_t if_desc; + int result =3D -1; + + if (!validate_options(netdev, errp)) { + return result; + } + + if_desc =3D build_if_desc(netdev); + result =3D vmnet_if_create(nc, if_desc, errp); + xpc_release(if_desc); + return result; } diff --git a/net/vmnet_int.h b/net/vmnet_int.h index c383038a1d..adf6e8c20d 100644 --- a/net/vmnet_int.h +++ b/net/vmnet_int.h @@ -15,11 +15,49 @@ #include "clients.h" =20 #include +#include + +/** + * From vmnet.framework documentation + * + * Each read/write call allows up to 200 packets to be + * read or written for a maximum of 256KB. + * + * Each packet written should be a complete + * ethernet frame. + * + * https://developer.apple.com/documentation/vmnet + */ +#define VMNET_PACKETS_LIMIT 200 =20 typedef struct VmnetState { - NetClientState nc; + NetClientState nc; + interface_ref vmnet_if; + + uint64_t mtu; + uint64_t max_packet_size; =20 + dispatch_queue_t if_queue; + + QEMUBH *send_bh; + + struct vmpktdesc packets_buf[VMNET_PACKETS_LIMIT]; + int packets_send_current_pos; + int packets_send_end_pos; + + struct iovec iov_buf[VMNET_PACKETS_LIMIT]; } VmnetState; =20 +const char *vmnet_status_map_str(vmnet_return_t status); + +int vmnet_if_create(NetClientState *nc, + xpc_object_t if_desc, + Error **errp); + +ssize_t vmnet_receive_common(NetClientState *nc, + const uint8_t *buf, + size_t size); + +void vmnet_cleanup_common(NetClientState *nc); =20 #endif /* VMNET_INT_H */ --=20 2.25.1 From nobody Fri May 3 15:00:59 2024 Delivered-To: importer2@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+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1652843755; cv=none; d=zohomail.com; s=zohoarc; b=ZpXK8mdZFNoL5Hk2juGxCGbGWdafNhbOuyu4WWR7KO3sELoQKHu+zJQzWUmA5NR+lNlkGJP+2w1dKaoCMkCBUYVCdbyr9rYGEu7iy4XsgvefPMczs11+TChnMAbv5bOwxJxH69cikD+Yoyzkf5e9cxjKalR9x3P0JmOVWrchfFM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1652843755; 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=YCe8pLQ5X1CtoanCekvHstqnaB+ZqhBT/3RTCUrWRTw=; b=iXGpHIQo13D9sVwzXlSJJNL7FdYS2XzlOELElIbS7Da5ZXWNypFPlyP1AkPgOzyqYjgbqzHn0M8aTanaNWZOK7ErTR2QP5mEx//k3sfpj7femE+RocQJXDsfQL+cap9uUurXtVNIHvyI79yVRT7NrRTIV+dkcUL8kl88qGAxJng= 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+importer2=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 165284375556988.70911493405004; Tue, 17 May 2022 20:15:55 -0700 (PDT) Received: from localhost ([::1]:35118 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nrAAE-0001BT-AH for importer2@patchew.org; Tue, 17 May 2022 23:15:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55686) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nrA77-0006rw-4W for qemu-devel@nongnu.org; Tue, 17 May 2022 23:12:42 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:42452) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nrA74-0004ny-Ur for qemu-devel@nongnu.org; Tue, 17 May 2022 23:12:40 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-215-SDH5U5IMP32-XrcFYJf6UQ-1; Tue, 17 May 2022 23:12:34 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 72219811E75; Wed, 18 May 2022 03:12:34 +0000 (UTC) Received: from localhost.localdomain (ovpn-14-27.pek2.redhat.com [10.72.14.27]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9FB2440C1244; Wed, 18 May 2022 03:12:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1652843558; 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=YCe8pLQ5X1CtoanCekvHstqnaB+ZqhBT/3RTCUrWRTw=; b=NDrUplE+rTW/vPiN2k3qTtn81YGTPad6U3fnH7JUaj6jOZiC4SBLt24va0Oeo1SFzSzVij PfoCWzNSI/WvYRtsxLnlC7iYDYppCfI/OfM6bMewc6EB3aw3Pmw+tOuM5xGAqIMWHueX+W VmSyRX3GJnzoEBDi6cZaK6vuu1yryr0= X-MC-Unique: SDH5U5IMP32-XrcFYJf6UQ-1 From: Jason Wang To: jasowang@redhat.com, qemu-devel@nongnu.org, peter.maydell@linaro.org Cc: Vladislav Yaroshchuk , Akihiko Odaki , Vladislav Yaroshchuk Subject: [PULL 4/8] net/vmnet: implement host mode (vmnet-host) Date: Wed, 18 May 2022 11:12:10 +0800 Message-Id: <20220518031214.93760-5-jasowang@redhat.com> In-Reply-To: <20220518031214.93760-1-jasowang@redhat.com> References: <20220518031214.93760-1-jasowang@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 2.84 on 10.11.54.2 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+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=jasowang@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.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1652843757170100005 Content-Type: text/plain; charset="utf-8" From: Vladislav Yaroshchuk Reviewed-by: Akihiko Odaki Tested-by: Akihiko Odaki Signed-off-by: Vladislav Yaroshchuk Signed-off-by: Jason Wang --- net/vmnet-host.c | 116 ++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 110 insertions(+), 6 deletions(-) diff --git a/net/vmnet-host.c b/net/vmnet-host.c index a461d507c5..05f8d78864 100644 --- a/net/vmnet-host.c +++ b/net/vmnet-host.c @@ -9,16 +9,120 @@ */ =20 #include "qemu/osdep.h" +#include "qemu/uuid.h" #include "qapi/qapi-types-net.h" -#include "vmnet_int.h" -#include "clients.h" -#include "qemu/error-report.h" #include "qapi/error.h" +#include "clients.h" +#include "vmnet_int.h" =20 #include =20 + +static bool validate_options(const Netdev *netdev, Error **errp) +{ + const NetdevVmnetHostOptions *options =3D &(netdev->u.vmnet_host); + +#if defined(MAC_OS_VERSION_11_0) && \ + MAC_OS_X_VERSION_MIN_REQUIRED >=3D MAC_OS_VERSION_11_0 + + QemuUUID net_uuid; + if (options->has_net_uuid && + qemu_uuid_parse(options->net_uuid, &net_uuid) < 0) { + error_setg(errp, "Invalid UUID provided in 'net-uuid'"); + return false; + } +#else + if (options->has_isolated) { + error_setg(errp, + "vmnet-host.isolated feature is " + "unavailable: outdated vmnet.framework API"); + return false; + } + + if (options->has_net_uuid) { + error_setg(errp, + "vmnet-host.net-uuid feature is " + "unavailable: outdated vmnet.framework API"); + return false; + } +#endif + + if ((options->has_start_address || + options->has_end_address || + options->has_subnet_mask) && + !(options->has_start_address && + options->has_end_address && + options->has_subnet_mask)) { + error_setg(errp, + "'start-address', 'end-address', 'subnet-mask' " + "should be provided together"); + return false; + } + + return true; +} + +static xpc_object_t build_if_desc(const Netdev *netdev) +{ + const NetdevVmnetHostOptions *options =3D &(netdev->u.vmnet_host); + xpc_object_t if_desc =3D xpc_dictionary_create(NULL, NULL, 0); + + xpc_dictionary_set_uint64(if_desc, + vmnet_operation_mode_key, + VMNET_HOST_MODE); + +#if defined(MAC_OS_VERSION_11_0) && \ + MAC_OS_X_VERSION_MIN_REQUIRED >=3D MAC_OS_VERSION_11_0 + + xpc_dictionary_set_bool(if_desc, + vmnet_enable_isolation_key, + options->isolated); + + QemuUUID net_uuid; + if (options->has_net_uuid) { + qemu_uuid_parse(options->net_uuid, &net_uuid); + xpc_dictionary_set_uuid(if_desc, + vmnet_network_identifier_key, + net_uuid.data); + } +#endif + + if (options->has_start_address) { + xpc_dictionary_set_string(if_desc, + vmnet_start_address_key, + options->start_address); + xpc_dictionary_set_string(if_desc, + vmnet_end_address_key, + options->end_address); + xpc_dictionary_set_string(if_desc, + vmnet_subnet_mask_key, + options->subnet_mask); + } + + return if_desc; +} + +static NetClientInfo net_vmnet_host_info =3D { + .type =3D NET_CLIENT_DRIVER_VMNET_HOST, + .size =3D sizeof(VmnetState), + .receive =3D vmnet_receive_common, + .cleanup =3D vmnet_cleanup_common, +}; + int net_init_vmnet_host(const Netdev *netdev, const char *name, - NetClientState *peer, Error **errp) { - error_setg(errp, "vmnet-host is not implemented yet"); - return -1; + NetClientState *peer, Error **errp) +{ + NetClientState *nc =3D qemu_new_net_client(&net_vmnet_host_info, + peer, "vmnet-host", name); + xpc_object_t if_desc; + int result =3D -1; + + if (!validate_options(netdev, errp)) { + return result; + } + + if_desc =3D build_if_desc(netdev); + result =3D vmnet_if_create(nc, if_desc, errp); + xpc_release(if_desc); + return result; } --=20 2.25.1 From nobody Fri May 3 15:00:59 2024 Delivered-To: importer2@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+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1652844041; cv=none; d=zohomail.com; s=zohoarc; b=F0FmYjp+BpwNIuesN/oelrWZEi/KMNWBW1XdorSK5fcInwtopQC8JrXXGSY63eBUKDc37/0tHqB53c90c3YHhuNcG4p/F2NvAxRK1t9VvSchj1OS2LIbB1Pu8QWmgKVRYyqU3dHhSxTel2B+VqIL7a1VgV0roxnb0vBSub+yuLM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1652844041; 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=A9sA/oA1jIo2YJQY9IVfyY7kEFKrX7mf4vJ2T23UPpA=; b=eSmiuBrLGTpYea5yv8/VvlTgocNtYEbpXtnXm5mycf4bv6lmFbg7vptF4lMKvzNga/e6F6rjH2VrFr9VqUfglbe+BGb9cYR0RP3+a59gc/w15tXTTeDWHBiwwOiBQ/KVUH/kU2ybzRj1C44MYEBHnHZUyF/5HTAMkH4w8aAqmVU= 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+importer2=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 1652844041136881.4932978439746; Tue, 17 May 2022 20:20:41 -0700 (PDT) Received: from localhost ([::1]:46472 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nrAEp-0000Zq-Gg for importer2@patchew.org; Tue, 17 May 2022 23:20:39 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55720) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nrA7A-0006sL-IU for qemu-devel@nongnu.org; Tue, 17 May 2022 23:12:44 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:48292) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nrA78-0004oK-Sg for qemu-devel@nongnu.org; Tue, 17 May 2022 23:12:44 -0400 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-648-PLqw90EDNYezfhaIMob34g-1; Tue, 17 May 2022 23:12:38 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id EC7092999B49; Wed, 18 May 2022 03:12:37 +0000 (UTC) Received: from localhost.localdomain (ovpn-14-27.pek2.redhat.com [10.72.14.27]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2B5EB40C1421; Wed, 18 May 2022 03:12:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1652843561; 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=A9sA/oA1jIo2YJQY9IVfyY7kEFKrX7mf4vJ2T23UPpA=; b=DnLyZw5iRiizB4XsB8Y952/dyUK53ysK5dGdIftfq7UnyAs1tYRIpC3lT4mgCMVN2wxw36 k3Xr74ZMCq9q9Mz54rXNXt2QLuM2/fzC3cVy4n/ssoJJEHu3pTFC8IEnG4N8B7RsvqQ/xW rVabfAAXQS+sruV4SdcE3VTwE+wH2ZM= X-MC-Unique: PLqw90EDNYezfhaIMob34g-1 From: Jason Wang To: jasowang@redhat.com, qemu-devel@nongnu.org, peter.maydell@linaro.org Cc: Vladislav Yaroshchuk , Akihiko Odaki , Vladislav Yaroshchuk Subject: [PULL 5/8] net/vmnet: implement bridged mode (vmnet-bridged) Date: Wed, 18 May 2022 11:12:11 +0800 Message-Id: <20220518031214.93760-6-jasowang@redhat.com> In-Reply-To: <20220518031214.93760-1-jasowang@redhat.com> References: <20220518031214.93760-1-jasowang@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 2.84 on 10.11.54.2 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+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=jasowang@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.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1652844042422100001 Content-Type: text/plain; charset="utf-8" From: Vladislav Yaroshchuk Reviewed-by: Akihiko Odaki Tested-by: Akihiko Odaki Signed-off-by: Vladislav Yaroshchuk Signed-off-by: Jason Wang --- net/vmnet-bridged.m | 137 ++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 132 insertions(+), 5 deletions(-) diff --git a/net/vmnet-bridged.m b/net/vmnet-bridged.m index 91c1a2f2c7..46d2282863 100644 --- a/net/vmnet-bridged.m +++ b/net/vmnet-bridged.m @@ -10,16 +10,143 @@ =20 #include "qemu/osdep.h" #include "qapi/qapi-types-net.h" -#include "vmnet_int.h" -#include "clients.h" -#include "qemu/error-report.h" #include "qapi/error.h" +#include "clients.h" +#include "vmnet_int.h" =20 #include =20 + +static bool validate_ifname(const char *ifname) +{ + xpc_object_t shared_if_list =3D vmnet_copy_shared_interface_list(); + bool match =3D false; + if (!xpc_array_get_count(shared_if_list)) { + goto done; + } + + match =3D !xpc_array_apply( + shared_if_list, + ^bool(size_t index, xpc_object_t value) { + return strcmp(xpc_string_get_string_ptr(value), ifname) !=3D 0; + }); + +done: + xpc_release(shared_if_list); + return match; +} + + +static char* get_valid_ifnames() +{ + xpc_object_t shared_if_list =3D vmnet_copy_shared_interface_list(); + __block char *if_list =3D NULL; + __block char *if_list_prev =3D NULL; + + if (!xpc_array_get_count(shared_if_list)) { + goto done; + } + + xpc_array_apply( + shared_if_list, + ^bool(size_t index, xpc_object_t value) { + /* build list of strings like "en0 en1 en2 " */ + if_list =3D g_strconcat(xpc_string_get_string_ptr(value), + " ", + if_list_prev, + NULL); + g_free(if_list_prev); + if_list_prev =3D if_list; + return true; + }); + +done: + xpc_release(shared_if_list); + return if_list; +} + + +static bool validate_options(const Netdev *netdev, Error **errp) +{ + const NetdevVmnetBridgedOptions *options =3D &(netdev->u.vmnet_bridged= ); + char* if_list; + + if (!validate_ifname(options->ifname)) { + if_list =3D get_valid_ifnames(); + if (if_list) { + error_setg(errp, + "unsupported ifname '%s', expected one of [ %s]", + options->ifname, + if_list); + g_free(if_list); + } else { + error_setg(errp, + "unsupported ifname '%s', no supported " + "interfaces available", + options->ifname); + } + return false; + } + +#if !defined(MAC_OS_VERSION_11_0) || \ + MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_VERSION_11_0 + if (options->has_isolated) { + error_setg(errp, + "vmnet-bridged.isolated feature is " + "unavailable: outdated vmnet.framework API"); + return false; + } +#endif + return true; +} + + +static xpc_object_t build_if_desc(const Netdev *netdev) +{ + const NetdevVmnetBridgedOptions *options =3D &(netdev->u.vmnet_bridged= ); + xpc_object_t if_desc =3D xpc_dictionary_create(NULL, NULL, 0); + + xpc_dictionary_set_uint64(if_desc, + vmnet_operation_mode_key, + VMNET_BRIDGED_MODE + ); + + xpc_dictionary_set_string(if_desc, + vmnet_shared_interface_name_key, + options->ifname); + +#if defined(MAC_OS_VERSION_11_0) && \ + MAC_OS_X_VERSION_MIN_REQUIRED >=3D MAC_OS_VERSION_11_0 + xpc_dictionary_set_bool(if_desc, + vmnet_enable_isolation_key, + options->isolated); +#endif + return if_desc; +} + + +static NetClientInfo net_vmnet_bridged_info =3D { + .type =3D NET_CLIENT_DRIVER_VMNET_BRIDGED, + .size =3D sizeof(VmnetState), + .receive =3D vmnet_receive_common, + .cleanup =3D vmnet_cleanup_common, +}; + + int net_init_vmnet_bridged(const Netdev *netdev, const char *name, NetClientState *peer, Error **errp) { - error_setg(errp, "vmnet-bridged is not implemented yet"); - return -1; + NetClientState *nc =3D qemu_new_net_client(&net_vmnet_bridged_info, + peer, "vmnet-bridged", name); + xpc_object_t if_desc; + int result =3D -1; + + if (!validate_options(netdev, errp)) { + return result; + } + + if_desc =3D build_if_desc(netdev); + result =3D vmnet_if_create(nc, if_desc, errp); + xpc_release(if_desc); + return result; } --=20 2.25.1 From nobody Fri May 3 15:00:59 2024 Delivered-To: importer2@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+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1652844201; cv=none; d=zohomail.com; s=zohoarc; b=BQbZOlekuJZdoKSYw3D6WBW7R3vqZ6h4ee7CWJrHFigZ+ARYpTMrwgOUngBDY0V8nsGplIr12iRLq47xL7NlBLBwzdnRlBN/6cmtnaBE4Gvnz2G3ghkS0W2Gc9mIjqZqZp1EZQSkXEOG/WCuoy0q0/WjKKkeKSX+fKkWoXCfjk0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1652844201; 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=wCQLNwrKEFjQQnmGQNhMwOJ3w2jvlT9L4mc1o2dgZ+s=; b=npID2iawnNQZ/dFvF6ffqU/9TwaGhxx3P0VHbsGREK8d7FAVepVXOfk+6rB5/Wlf2fF+qOH1eRN3Q51u0gb/s8bklB3Bu0O8OodftH27X9BoK+65pIDyFnNJ0VTjgrQMnfxg9+RTtM+wr1o+CPn/5WvTdFBxzwRPPhTVuDwO1xA= 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+importer2=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 1652844201463235.63110938762952; Tue, 17 May 2022 20:23:21 -0700 (PDT) Received: from localhost ([::1]:54004 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nrAHQ-0005m9-GP for importer2@patchew.org; Tue, 17 May 2022 23:23:20 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55756) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nrA7E-0006u1-BE for qemu-devel@nongnu.org; Tue, 17 May 2022 23:12:48 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:32735) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nrA7C-0004oi-R3 for qemu-devel@nongnu.org; Tue, 17 May 2022 23:12:48 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-646-3yI2tj7GNoe2P57cMdqsww-1; Tue, 17 May 2022 23:12:41 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 75251811E78; Wed, 18 May 2022 03:12:41 +0000 (UTC) Received: from localhost.localdomain (ovpn-14-27.pek2.redhat.com [10.72.14.27]) by smtp.corp.redhat.com (Postfix) with ESMTP id A5033400E114; Wed, 18 May 2022 03:12:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1652843565; 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=wCQLNwrKEFjQQnmGQNhMwOJ3w2jvlT9L4mc1o2dgZ+s=; b=SoL1sbtQ8adqoeikha04VwpHR/6ZFkRuW9EfZEH25Ue/7bq2uxklztjXlUgkAPVz3Ui6a+ SqF1BvFwYb3Mz81gf94M2xHZJXZtGoV8sRuomh+pigBi7DkYo/IuZNJvx/L2hVQciJY3mE DPRTvy6IngRlavBAfkzCvuPPfIHoG+I= X-MC-Unique: 3yI2tj7GNoe2P57cMdqsww-1 From: Jason Wang To: jasowang@redhat.com, qemu-devel@nongnu.org, peter.maydell@linaro.org Cc: Vladislav Yaroshchuk , Akihiko Odaki , Vladislav Yaroshchuk Subject: [PULL 6/8] net/vmnet: update qemu-options.hx Date: Wed, 18 May 2022 11:12:12 +0800 Message-Id: <20220518031214.93760-7-jasowang@redhat.com> In-Reply-To: <20220518031214.93760-1-jasowang@redhat.com> References: <20220518031214.93760-1-jasowang@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 2.84 on 10.11.54.2 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+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=jasowang@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.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1652844203264100001 Content-Type: text/plain; charset="utf-8" From: Vladislav Yaroshchuk Update qemu-options.hx to support vmnet networking backend. Reviewed-by: Akihiko Odaki Tested-by: Akihiko Odaki Signed-off-by: Vladislav Yaroshchuk Signed-off-by: Jason Wang --- qemu-options.hx | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/qemu-options.hx b/qemu-options.hx index b484640067..a664baaa18 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -2795,6 +2795,25 @@ DEF("netdev", HAS_ARG, QEMU_OPTION_netdev, #ifdef __linux__ "-netdev vhost-vdpa,id=3Dstr,vhostdev=3D/path/to/dev\n" " configure a vhost-vdpa network,Establish a vhost-vdpa= netdev\n" +#endif +#ifdef CONFIG_VMNET + "-netdev vmnet-host,id=3Dstr[,isolated=3Don|off][,net-uuid=3Duuid]\n" + " [,start-address=3Daddr,end-address=3Daddr,subnet-mask=3Dmask= ]\n" + " configure a vmnet network backend in host mode with I= D 'str',\n" + " isolate this interface from others with 'isolated',\n" + " configure the address range and choose a subnet mask,= \n" + " specify network UUID 'uuid' to disable DHCP and inter= act with\n" + " vmnet-host interfaces within this isolated network\n" + "-netdev vmnet-shared,id=3Dstr[,isolated=3Don|off][,nat66-prefix=3Dadd= r]\n" + " [,start-address=3Daddr,end-address=3Daddr,subnet-mask=3Dmask= ]\n" + " configure a vmnet network backend in shared mode with= ID 'str',\n" + " configure the address range and choose a subnet mask,= \n" + " set IPv6 ULA prefix (of length 64) to use for interna= l network,\n" + " isolate this interface from others with 'isolated'\n" + "-netdev vmnet-bridged,id=3Dstr,ifname=3Dname[,isolated=3Don|off]\n" + " configure a vmnet network backend in bridged mode wit= h ID 'str',\n" + " use 'ifname=3Dname' to select a physical network inte= rface to be bridged,\n" + " isolate this interface from others with 'isolated'\n" #endif "-netdev hubport,id=3Dstr,hubid=3Dn[,netdev=3Dnd]\n" " configure a hub port on the hub with ID 'n'\n", QEMU_= ARCH_ALL) @@ -2814,6 +2833,9 @@ DEF("nic", HAS_ARG, QEMU_OPTION_nic, #endif #ifdef CONFIG_POSIX "vhost-user|" +#endif +#ifdef CONFIG_VMNET + "vmnet-host|vmnet-shared|vmnet-bridged|" #endif "socket][,option][,...][mac=3Dmacaddr]\n" " initialize an on-board / default host NIC (using MAC = address\n" @@ -2836,6 +2858,9 @@ DEF("net", HAS_ARG, QEMU_OPTION_net, #endif #ifdef CONFIG_NETMAP "netmap|" +#endif +#ifdef CONFIG_VMNET + "vmnet-host|vmnet-shared|vmnet-bridged|" #endif "socket][,option][,option][,...]\n" " old way to initialize a host network interface\n" --=20 2.25.1 From nobody Fri May 3 15:00:59 2024 Delivered-To: importer2@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+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1652843904; cv=none; d=zohomail.com; s=zohoarc; b=TwD1DE80rIqDP8STyrH5W/pd8MstOBXtXNo+wVJeWjv/QJKyinFngP7TWG6OHbTJpp6cSwMgBCiQTowTKz6kgyZssoHyH5nZVUkt0ulNRMr0skH9LKPhGLkr6XbWzZ7pZ5mIq+MuOH4hSEqOhZs/cFrbG4JvIszoUuaYidlwbFc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1652843904; 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=6Zzk4iM7S3w/AIgQY5AMLppY7jPouoRwhP+CMK+JrhA=; b=Oc1Xh6SEZpbVj0GE+agohho/YnbC/oAlC0pRHz5OYvp5MSZhYNGZJGmlsq6+GewhTTO2TJUcnXcURpH799T5w2hCkKAP5aSt81h/oZLaBV5QpIlMRyrnlkUYanp6AX9BkLO3yQCteiECL7uEpGWf9aJk7mHUxTGCHnPAX7Amo+8= 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+importer2=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 1652843904332266.0248037955937; Tue, 17 May 2022 20:18:24 -0700 (PDT) Received: from localhost ([::1]:42364 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nrACc-00069M-Ti for importer2@patchew.org; Tue, 17 May 2022 23:18:22 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55772) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nrA7G-0006us-Mi for qemu-devel@nongnu.org; Tue, 17 May 2022 23:12:51 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:56335) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nrA7F-0004pG-6B for qemu-devel@nongnu.org; Tue, 17 May 2022 23:12:50 -0400 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-417-8yh7Z4e9O8-V1BAFscjKCQ-1; Tue, 17 May 2022 23:12:45 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id E7C3E3810794; Wed, 18 May 2022 03:12:44 +0000 (UTC) Received: from localhost.localdomain (ovpn-14-27.pek2.redhat.com [10.72.14.27]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1BE2E40C1421; Wed, 18 May 2022 03:12:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1652843568; 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=6Zzk4iM7S3w/AIgQY5AMLppY7jPouoRwhP+CMK+JrhA=; b=I3/vCPXWxfKfWBUHIaiqP4zgyGbslQRZcGKFg/hbPo3V+zUXna0GflLDtQvR7BMXaNsZNM VO1g8kXXpCdOLKcygzAn/6FmxCnlBVDGqNVG4fUxhiZwTLqHUOx6A7ilINoQv+WSbWb2le Xyh2IEo28H8U1HGbPjrI581zGqsH1Sc= X-MC-Unique: 8yh7Z4e9O8-V1BAFscjKCQ-1 From: Jason Wang To: jasowang@redhat.com, qemu-devel@nongnu.org, peter.maydell@linaro.org Cc: Vladislav Yaroshchuk , Akihiko Odaki , Vladislav Yaroshchuk Subject: [PULL 7/8] net/vmnet: update hmp-commands.hx Date: Wed, 18 May 2022 11:12:13 +0800 Message-Id: <20220518031214.93760-8-jasowang@redhat.com> In-Reply-To: <20220518031214.93760-1-jasowang@redhat.com> References: <20220518031214.93760-1-jasowang@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 2.84 on 10.11.54.2 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+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=jasowang@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.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1652843905695100004 Content-Type: text/plain; charset="utf-8" From: Vladislav Yaroshchuk Update HMP for supporting vmnet. Reviewed-by: Akihiko Odaki Tested-by: Akihiko Odaki Signed-off-by: Vladislav Yaroshchuk Signed-off-by: Jason Wang --- hmp-commands.hx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/hmp-commands.hx b/hmp-commands.hx index 03e6a73d1f..564f1de364 100644 --- a/hmp-commands.hx +++ b/hmp-commands.hx @@ -1269,7 +1269,11 @@ ERST { .name =3D "netdev_add", .args_type =3D "netdev:O", - .params =3D "[user|tap|socket|vde|bridge|hubport|netmap|vhost-= user],id=3Dstr[,prop=3Dvalue][,...]", + .params =3D "[user|tap|socket|vde|bridge|hubport|netmap|vhost-= user" +#ifdef CONFIG_VMNET + "|vmnet-host|vmnet-shared|vmnet-bridged" +#endif + "],id=3Dstr[,prop=3Dvalue][,...]", .help =3D "add host network device", .cmd =3D hmp_netdev_add, .command_completion =3D netdev_add_completion, --=20 2.25.1 From nobody Fri May 3 15:00:59 2024 Delivered-To: importer2@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+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1652843945; cv=none; d=zohomail.com; s=zohoarc; b=ATp9km0S6BHN+dBf7rhcy1O5tUzFvP2OlP3qZQgGn5EIk72DC+udNPy3/dJyAeAPKUl6qVu6Ru48Mc5fev+te1c+bMy/SXMyYFFtONO6VU1zh+qUBhUCr1sq03GfV4HVOANWQWYYGSx7aF9qQckocKt0zoAwwdZduJIsf8GORss= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1652843945; 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=8RbeWMxLZfEDrmmdxD4KNkE6/p5VeCBxWVZML5B9loE=; b=SpMkGJJkBQAsSZdP76fCxeeKcqssldVOLijBTrnksUz4xx3IZ6wVlrvdbeuvu3QVHZXuZzbc8u8NKIYi3cXcSkeWXMpRjvE+EuJ5As3A5rBfa+5KuMsbhNNsbSIP51zM7smwggceWMTKLJgTFoOVIXtglopFvlBD7xDbORZLM9U= 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+importer2=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 1652843945813525.3190086417112; Tue, 17 May 2022 20:19:05 -0700 (PDT) Received: from localhost ([::1]:43554 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nrADI-000704-Q7 for importer2@patchew.org; Tue, 17 May 2022 23:19:04 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55786) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nrA7K-0006vO-9W for qemu-devel@nongnu.org; Tue, 17 May 2022 23:12:54 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:30924) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nrA7I-0004pQ-PX for qemu-devel@nongnu.org; Tue, 17 May 2022 23:12:54 -0400 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-156-QJ7XoeHSPKanNkGZiHfzqw-1; Tue, 17 May 2022 23:12:48 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 165462999B46; Wed, 18 May 2022 03:12:48 +0000 (UTC) Received: from localhost.localdomain (ovpn-14-27.pek2.redhat.com [10.72.14.27]) by smtp.corp.redhat.com (Postfix) with ESMTP id A198D40C1244; Wed, 18 May 2022 03:12:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1652843571; 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=8RbeWMxLZfEDrmmdxD4KNkE6/p5VeCBxWVZML5B9loE=; b=hIHk9995EoI3D1T1nAFZJrWTOe3UIlJ5JO3fV31vGSbsYgm+nbBR5qbnIh3hAP7NuGGuv4 t0pBPIGueDrZ3ZMs0t7/ctpXyc1aw7/0zMRVkPeM9ChvW/gJC/6OCpyOy7u68a35IaLPsj pwazptAuX+iiz5EyM2g/k3axQnbW/cs= X-MC-Unique: QJ7XoeHSPKanNkGZiHfzqw-1 From: Jason Wang To: jasowang@redhat.com, qemu-devel@nongnu.org, peter.maydell@linaro.org Cc: Helge Deller , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PULL 8/8] tulip: Assign default MAC address if not specified Date: Wed, 18 May 2022 11:12:14 +0800 Message-Id: <20220518031214.93760-9-jasowang@redhat.com> In-Reply-To: <20220518031214.93760-1-jasowang@redhat.com> References: <20220518031214.93760-1-jasowang@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 2.84 on 10.11.54.2 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+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=jasowang@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.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1652843947853100003 From: Helge Deller The MAC of the tulip card is stored in the EEPROM and at startup tulip_fill_eeprom() is called to initialize the EEPROM with the MAC address given on the command line, e.g.: -device tulip,mac=3D00:11:22:33:44:55 In case the mac address was not given on the command line, tulip_fill_eeprom() initializes the MAC in EEPROM with 00:00:00:00:00:00 which breaks e.g. a HP-UX guest. Fix this problem by moving qemu_macaddr_default_if_unset() a few lines up, so that a default mac address is assigned before tulip_fill_eeprom() initializes the EEPROM. Signed-off-by: Helge Deller Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Jason Wang --- hw/net/tulip.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hw/net/tulip.c b/hw/net/tulip.c index d5b6cc5ee6..097e905bec 100644 --- a/hw/net/tulip.c +++ b/hw/net/tulip.c @@ -967,6 +967,8 @@ static void pci_tulip_realize(PCIDevice *pci_dev, Error= **errp) pci_conf =3D s->dev.config; pci_conf[PCI_INTERRUPT_PIN] =3D 1; /* interrupt pin A */ =20 + qemu_macaddr_default_if_unset(&s->c.macaddr); + s->eeprom =3D eeprom93xx_new(&pci_dev->qdev, 64); tulip_fill_eeprom(s); =20 @@ -981,8 +983,6 @@ static void pci_tulip_realize(PCIDevice *pci_dev, Error= **errp) =20 s->irq =3D pci_allocate_irq(&s->dev); =20 - qemu_macaddr_default_if_unset(&s->c.macaddr); - s->nic =3D qemu_new_nic(&net_tulip_info, &s->c, object_get_typename(OBJECT(pci_dev)), pci_dev->qdev.id, s); --=20 2.25.1