Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 0BFCBC433EF for ; Mon, 6 Dec 2021 16:44:06 +0000 (UTC) Received: from localhost ([::1]:34074 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1muH5w-0007Eb-ML for qemu-devel@archiver.kernel.org; Mon, 06 Dec 2021 11:44:04 -0500 Received: from eggs.gnu.org ([209.51.188.92]:33200) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1muH4Z-0004gd-R5 for qemu-devel@nongnu.org; Mon, 06 Dec 2021 11:42:39 -0500 Received: from [2a00:1450:4864:20::22e] (port=42508 helo=mail-lj1-x22e.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1muH4X-00074W-Kn for qemu-devel@nongnu.org; Mon, 06 Dec 2021 11:42:39 -0500 Received: by mail-lj1-x22e.google.com with SMTP id z8so22076942ljz.9 for ; Mon, 06 Dec 2021 08:42:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=RT4ivu8MH7b1ncxA9M9/3u9EaMY+YrHnvUmWLRabMB4=; b=WvRhQGFLL+VMTnnadJxtaRphhIT+Kme1G/EUAsxLeRh3o9wtX4n23mf+jXybb7Pn5l 6jgH0vFcTnzRUCp7bZk3fMxHmABCuG2ZHtLuHST34FxsLMjfLTCw7LPiygyxzJolUhxr fjXiAtaRnRIBrErpHVpwfHxLjcdZvlPI5fcwVHuq38urtaCxyOLhws292pNZ1dp0xbQy +ECd76Gqeja3t/YqY9xYWN+lwWtAnThz0Spiv/G0/3Wz+ZQ93Yhw3AzqtPr3JbJJdhzc in6Sq7/7V6KCTsBHHZniYuNmJSLSGz55EfiP+T7+ODs52JmuIo3Ius0N/gRBWbgp3ae4 uhRg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=RT4ivu8MH7b1ncxA9M9/3u9EaMY+YrHnvUmWLRabMB4=; b=joj6zu2NG3S9apkoTKRUCRYRVlT0hvqhcToeFmNgBq8Jpoi8U2FtK9Ck1KmT9CVxpP 0B2iIyaxhxPkLbwjeCc4vqTK03b4LMrDJfnVT8TDmh92mZA9UUCXQ+p0co7ekg74ECvQ 1R6ltve3rpa6kG/cMXgZhvdAM021kNKGe5c42ZAmL8U1rieWj346QfRHQogkJJZ8S16B xbOddsJToyks0MmRfC7Bwu9OH4jK3eCleAR8yUzfupK4uFcAuGaVi3SyVgAmuUKqiSL/ oYra4R6PyDoB3W5/K4Q1YuBBfozabk6WZdZd81CesqumUwGayMjZvMMezqPEzmVlzEoC 3ysw== X-Gm-Message-State: AOAM530NI0YIyJzchYOTKtSTaDhCbwslCTX0u82RRvCMJ92rprMfanmM EcSZhpbl60URCPZsIIbaRIz7X9MBPCz1xjpO X-Google-Smtp-Source: ABdhPJywuLhz3oTPPdoXxRRftxMIgQMwT0QYdTc9xsu11mfHqAANA+9sigB/NeKUkxin8CGB3R5RnQ== X-Received: by 2002:a05:651c:4c6:: with SMTP id e6mr37125658lji.505.1638808955099; Mon, 06 Dec 2021 08:42:35 -0800 (PST) Received: from UNIT-808.labs.intellij.net ([91.132.204.19]) by smtp.gmail.com with ESMTPSA id e11sm1401809lfq.65.2021.12.06.08.42.33 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 06 Dec 2021 08:42:34 -0800 (PST) From: Vladislav Yaroshchuk To: qemu-devel@nongnu.org Subject: [PATCH v6 0/6] Add vmnet.framework based network backend Date: Mon, 6 Dec 2021 19:42:16 +0300 Message-Id: <20211206164222.11027-1-yaroshchuk2000@gmail.com> X-Mailer: git-send-email 2.23.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a00:1450:4864:20::22e (failed) Received-SPF: pass client-ip=2a00:1450:4864:20::22e; envelope-from=yaroshchuk2000@gmail.com; helo=mail-lj1-x22e.google.com X-Spam_score_int: -10 X-Spam_score: -1.1 X-Spam_bar: - X-Spam_report: (-1.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, PDS_HP_HELO_NORDNS=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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: , Cc: Vladislav Yaroshchuk , jasowang@redhat.com, phillip.ennen@gmail.com, armbru@redhat.com, r.bolshakov@yadro.com, phillip@axleos.com, akihiko.odaki@gmail.com, hsp.cat7@gmail.com, hello@adns.io, eblake@redhat.com Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" macOS provides networking API for VMs called 'vmnet.framework': https://developer.apple.com/documentation/vmnet We can provide its support as the new QEMU network backends which represent three different vmnet.framework interface usage modes: * `vmnet-shared`: allows the guest to communicate with other guests in shared mode and also with external network (Internet) via NAT. Has (macOS-provided) DHCP server; subnet mask and IP range can be configured; * `vmnet-host`: allows the guest to communicate with other guests in host mode. By default has enabled DHCP as `vmnet-shared`, but providing network unique id (uuid) can make `vmnet-host` interfaces isolated from each other and also disables DHCP. * `vmnet-bridged`: bridges the guest with a physical network interface. This backends cannot work on macOS Catalina 10.15 cause we use vmnet.framework API provided only with macOS 11 and newer. Seems that it is not a problem, because QEMU guarantees to work on two most recent versions of macOS which now are Big Sur (11) and Monterey (12). Also, we have one inconvenient restriction: vmnet.framework interfaces can create only privileged user: `$ sudo qemu-system-x86_64 -nic vmnet-shared` Attempt of `vmnet-*` netdev creation being unprivileged user fails with vmnet's 'general failure'. This happens because vmnet.framework requires `com.apple.vm.networking` entitlement which is: "restricted to developers of virtualization software. To request this entitlement, contact your Apple representative." as Apple documentation says: https://developer.apple.com/documentation/bundleresources/entitlements/com_apple_vm_networking One more note: we still have quite useful but not supported 'vmnet.framework' features as creating port forwarding rules, IPv6 NAT prefix specifying and so on. Nevertheless, new backends work fine and tested within `qemu-system-x86-64` on macOS Bir Sur 11.5.2 host with such nic models: * e1000-82545em * virtio-net-pci * vmxnet3 The guests were: * macOS 10.15.7 * Ubuntu Bionic (server cloudimg) This series partially reuses patches by Phillip Tennen: https://patchew.org/QEMU/20210218134947.1860-1-phillip.ennen@gmail.com/ So I included them signed-off line into one of the commit messages and also here. v1 -> v2: Since v1 minor typos were fixed, patches rebased onto latest master, redundant changes removed (small commits squashed) v2 -> v3: - QAPI style fixes - Typos fixes in comments - `#include`'s updated to be in sync with recent master v3 -> v4: - Support vmnet interfaces isolation feature - Support vmnet-host network uuid setting feature - Refactored sources a bit v4 -> v5: - Missed 6.2 boat, now 7.0 candidate - Fix qapi netdev descriptions and styles (@subnetmask -> @subnet-mask) - Support vmnet-shared IPv6 prefix setting feature v5 -> v6 - provide detailed commit messages for commits of many changes - rename properties @dhcpstart and @dhcpend to @start-address and @end-address - improve qapi documentation about isolation features (@isolated, @net-uuid) Vladislav Yaroshchuk (6): net/vmnet: add vmnet dependency and customizable option net/vmnet: add vmnet backends to qapi/net net/vmnet: implement shared mode (vmnet-shared) net/vmnet: implement host mode (vmnet-host) net/vmnet: implement bridged mode (vmnet-bridged) net/vmnet: update qemu-options.hx meson.build | 4 + meson_options.txt | 2 + net/clients.h | 11 ++ net/meson.build | 7 + net/net.c | 10 ++ net/vmnet-bridged.m | 111 ++++++++++++ net/vmnet-common.m | 330 ++++++++++++++++++++++++++++++++++ net/vmnet-host.c | 105 +++++++++++ net/vmnet-shared.c | 92 ++++++++++ net/vmnet_int.h | 48 +++++ qapi/net.json | 132 +++++++++++++- qemu-options.hx | 25 +++ scripts/meson-buildoptions.sh | 3 + 13 files changed, 878 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 -- 2.23.0