Skip to contentSkip to conversation

Net patches

GIT PULL Jason Wang 4 participants 23 messages Jan 10, 2022 – Jan 12, 2022

Subsystems (2)
lore
Share & tools
lore

Jason Wang

author
#0 lore raw

The following changes since commit df722e33d5da26ea8604500ca8f509245a0ea524:

Merge tag 'bsd-user-arm-pull-request' of gitlab.com:bsdimp/qemu into staging (2022-01-08 09:37:59 -0800)

are available in the git repository at:

https://github.com/jasowang/qemu.git tags/net-pull-request

for you to fetch changes up to 5136cc6d3b8b74f4fa572f0874656947a401330e:

net/vmnet: update MAINTAINERS list (2022-01-10 11:30:55 +0800)

----------------------------------------------------------------

----------------------------------------------------------------
Peter Foley (2):
net/tap: Set return code on failure
net: Fix uninitialized data usage

Philippe Mathieu-Daudé (1):
hw/net/vmxnet3: Log guest-triggerable errors using LOG_GUEST_ERROR

Rao Lei (1):
net/filter: Optimize filter_send to coroutine

Vladislav Yaroshchuk (7):
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
net/vmnet: update MAINTAINERS list

Zhang Chen (2):
net/colo-compare.c: Optimize compare order for performance net/colo-compare.c: Update the default value comments

 MAINTAINERS                   |   5 +
 hw/net/vmxnet3.c              |   4 +-
 meson.build                   |   4 +
 meson_options.txt             |   2 +
 net/clients.h                 |  11 ++
 net/colo-compare.c            |  28 ++--
 net/filter-mirror.c           |  66 +++++++--
 net/meson.build               |   7 +
 net/net.c                     |  10 ++
 net/tap-linux.c               |   1 +
 net/tap.c                     |   1 +
 net/vmnet-bridged.m           | 111 ++++++++++++++
 net/vmnet-common.m            | 330 ++++++++++++++++++++++++++++++++++++++++++
 net/vmnet-host.c              | 105 ++++++++++++++
 net/vmnet-shared.c            |  91 ++++++++++++
 net/vmnet_int.h               |  48 ++++++
 qapi/net.json                 | 132 ++++++++++++++++-
 qemu-options.hx               |  25 ++++
 scripts/meson-buildoptions.sh |   3 +
 19 files changed, 954 insertions(+), 30 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
author
#1 lore raw

[PULL 01/13] hw/net/vmxnet3: Log guest-triggerable errors using LOG_GUEST_ERROR

From: Philippe Mathieu-Daudé <[email protected]>

The "Interrupt Cause" register (VMXNET3_REG_ICR) is read-only. Write accesses are ignored. Log them with as LOG_GUEST_ERROR instead of aborting:

[R +0.239743] writeq 0xe0002031 0x46291a5a55460800 ERROR:hw/net/vmxnet3.c:1819:vmxnet3_io_bar1_write: code should not be reached Thread 1 "qemu-system-i38" received signal SIGABRT, Aborted. (gdb) bt

  #3  0x74c397d3 in __GI_abort () at abort.c:79
  #4  0x76d3cd4c in g_assertion_message (domain=<optimized out>, file=<optimized out>, line=<optimized out>, func=<optimized out>, message=<optimized out>) at ../glib/gtestutils.c:3223
  #5  0x76d9d45f in g_assertion_message_expr
      (domain=0x0, file=0x59fc2e53 "hw/net/vmxnet3.c", line=1819, func=0x59fc11e0 <__func__.vmxnet3_io_bar1_write> "vmxnet3_io_bar1_write", expr=<optimized out>)
      at ../glib/gtestutils.c:3249
  #6  0x57e80a3a in vmxnet3_io_bar1_write (opaque=0x62814100, addr=56, val=70, size=4) at hw/net/vmxnet3.c:1819
  #7  0x58c2d894 in memory_region_write_accessor (mr=0x62816b90, addr=56, value=0x7fff9450, size=4, shift=0, mask=4294967295, attrs=...) at softmmu/memory.c:492
  #8  0x58c2d1d2 in access_with_adjusted_size (addr=56, value=0x7fff9450, size=1, access_size_min=4, access_size_max=4, access_fn=
      0x58c2d290 <memory_region_write_accessor>, mr=0x62816b90, attrs=...) at softmmu/memory.c:554
  #9  0x58c2bae7 in memory_region_dispatch_write (mr=0x62816b90, addr=56, data=70, op=MO_8, attrs=...) at softmmu/memory.c:1504
  #10 0x58bfd034 in flatview_write_continue (fv=0x606000181700, addr=0xe0002038, attrs=..., ptr=0x7fffb9e0, len=1, addr1=56, l=1, mr=0x62816b90)
      at softmmu/physmem.c:2782
  #11 0x58beba00 in flatview_write (fv=0x606000181700, addr=0xe0002031, attrs=..., buf=0x7fffb9e0, len=8) at softmmu/physmem.c:2822
  #12 0x58beb589 in address_space_write (as=0x608000015f20, addr=0xe0002031, attrs=..., buf=0x7fffb9e0, len=8) at softmmu/physmem.c:2914
---
 hw/net/vmxnet3.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
hw/net/vmxnet3.c +3 -1
index f65af4e..0b7acf7 100644
@@ -1816,7 +1816,9 @@ vmxnet3_io_bar1_write(void *opaque,
     case VMXNET3_REG_ICR:
         VMW_CBPRN("Write BAR1 [VMXNET3_REG_ICR] = %" PRIx64 ", size %d",
                   val, size);
-        g_assert_not_reached();
+        qemu_log_mask(LOG_GUEST_ERROR,
+                      "%s: write to read-only register VMXNET3_REG_ICR\n",
+                      TYPE_VMXNET3);
         break;
 
     /* Event Cause Register */
Signature · 1 line
2.7.4
author
#2 lore raw

[PULL 02/13] net/tap: Set return code on failure

In reply to Jason Wang

From: Peter Foley <[email protected]>

Match the other error handling in this function.

Fixes e7b347d0bf6 ("net: detect errors from probing vnet hdr flag for TAP devices")
---
 net/tap.c | 1 +
 1 file changed, 1 insertion(+)
net/tap.c +1 -0
index f716be3..c5cbeaa 100644
@@ -900,6 +900,7 @@ int net_init_tap(const Netdev *netdev, const char *name,
             if (i == 0) {
                 vnet_hdr = tap_probe_vnet_hdr(fd, errp);
                 if (vnet_hdr < 0) {
+                    ret = -1;
                     goto free_fail;
                 }
             } else if (vnet_hdr != tap_probe_vnet_hdr(fd, NULL)) {
Signature · 1 line
2.7.4
author
#3 lore raw

[PULL 05/13] net/colo-compare.c: Update the default value comments

In reply to Jason Wang

From: Zhang Chen <[email protected]>

Make the comments consistent with the REGULAR_PACKET_CHECK_MS.

---
 net/colo-compare.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/colo-compare.c +1 -1
index 216de5a..62554b5 100644
@@ -1267,7 +1267,7 @@ static void colo_compare_complete(UserCreatable *uc, Error **errp)
     }
 
     if (!s->expired_scan_cycle) {
-        /* Set default value to 3000 MS */
+        /* Set default value to 1000 MS */
         s->expired_scan_cycle = REGULAR_PACKET_CHECK_MS;
     }
 
Signature · 1 line
2.7.4
author
#4 lore raw

[PULL 12/13] net/vmnet: update qemu-options.hx

In reply to Jason Wang

From: Vladislav Yaroshchuk <[email protected]>

---
 qemu-options.hx | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)
qemu-options.hx +25 -0
index ec90505..81dd34f 100644
@@ -2733,6 +2733,25 @@ DEF("netdev", HAS_ARG, QEMU_OPTION_netdev,
     "-netdev vhost-vdpa,id=str,vhostdev=/path/to/dev\n"
     "                configure a vhost-vdpa network,Establish a vhost-vdpa netdev\n"
 #endif
+#ifdef CONFIG_VMNET
+    "-netdev vmnet-host,id=str[,isolated=on|off][,net-uuid=uuid]\n"
+    "         [,start-address=addr,end-address=addr,subnet-mask=mask]\n"
+    "                configure a vmnet network backend in host mode with ID '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 interact with\n"
+    "                vmnet-host interfaces within this isolated network\n"
+    "-netdev vmnet-shared,id=str[,isolated=on|off][,nat66-prefix=addr]\n"
+    "         [,start-address=addr,end-address=addr,subnet-mask=mask]\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 internal network,\n"
+    "                isolate this interface from others with 'isolated'\n"
+    "-netdev vmnet-bridged,id=str,ifname=name[,isolated=on|off]\n"
+    "                configure a vmnet network backend in bridged mode with ID 'str',\n"
+    "                use 'ifname=name' to select a physical network interface to be bridged,\n"
+    "                isolate this interface from others with 'isolated'\n"
+#endif
     "-netdev hubport,id=str,hubid=n[,netdev=nd]\n"
     "                configure a hub port on the hub with ID 'n'\n", QEMU_ARCH_ALL)
 DEF("nic", HAS_ARG, QEMU_OPTION_nic,
@@ -2752,6 +2771,9 @@ DEF("nic", HAS_ARG, QEMU_OPTION_nic,
 #ifdef CONFIG_POSIX
     "vhost-user|"
 #endif
+#ifdef CONFIG_VMNET
+    "vmnet-host|vmnet-shared|vmnet-bridged|"
+#endif
     "socket][,option][,...][mac=macaddr]\n"
     "                initialize an on-board / default host NIC (using MAC address\n"
     "                macaddr) and connect it to the given host network backend\n"
@@ -2774,6 +2796,9 @@ DEF("net", HAS_ARG, QEMU_OPTION_net,
 #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"
     "                (use the -netdev option if possible instead)\n", QEMU_ARCH_ALL)
Signature · 1 line
2.7.4
author
#5 lore raw

[PULL 03/13] net: Fix uninitialized data usage

In reply to Jason Wang

From: Peter Foley <[email protected]>

e.g.
1109 15:16:20.151506 Uninitialized bytes in ioctl_common_pre at offset 0 inside [0x7ffc516af9b8, 4)
1109 15:16:20.151659 ==588974==WARNING: MemorySanitizer: use-of-uninitialized-value

 1109 15:16:20.312923     #0 0x5639b88acb21 in tap_probe_vnet_hdr_len third_party/qemu/net/tap-linux.c:183:9
 1109 15:16:20.312952     #1 0x5639b88afd66 in net_tap_fd_init third_party/qemu/net/tap.c:409:9
 1109 15:16:20.312954     #2 0x5639b88b2d1b in net_init_tap_one third_party/qemu/net/tap.c:681:19
 1109 15:16:20.312956     #3 0x5639b88b16a8 in net_init_tap third_party/qemu/net/tap.c:912:13
 1109 15:16:20.312957     #4 0x5639b8890175 in net_client_init1 third_party/qemu/net/net.c:1110:9
 1109 15:16:20.312958     #5 0x5639b888f912 in net_client_init third_party/qemu/net/net.c:1208:15
 1109 15:16:20.312960     #6 0x5639b8894aa5 in net_param_nic third_party/qemu/net/net.c:1588:11
 1109 15:16:20.312961     #7 0x5639b900cd18 in qemu_opts_foreach third_party/qemu/util/qemu-option.c:1135:14
 1109 15:16:20.312962     #8 0x5639b889393c in net_init_clients third_party/qemu/net/net.c:1612:9
 1109 15:16:20.312964     #9 0x5639b717aaf3 in qemu_create_late_backends third_party/qemu/softmmu/vl.c:1962:5
 1109 15:16:20.312965     #10 0x5639b717aaf3 in qemu_init third_party/qemu/softmmu/vl.c:3694:5
 1109 15:16:20.312967     #11 0x5639b71083b8 in main third_party/qemu/softmmu/main.c:49:5
 1109 15:16:20.312968     #12 0x7f464de1d8d2 in __libc_start_main (/usr/grte/v5/lib64/libc.so.6+0x628d2)
 1109 15:16:20.312969     #13 0x5639b6bbd389 in _start /usr/grte/v5/debug-src/src/csu/../sysdeps/x86_64/start.S:120
 1109 15:16:20.312970
 1109 15:16:20.312975   Uninitialized value was stored to memory at
 1109 15:16:20.313393     #0 0x5639b88acbee in tap_probe_vnet_hdr_len third_party/qemu/net/tap-linux.c
 1109 15:16:20.313396     #1 0x5639b88afd66 in net_tap_fd_init third_party/qemu/net/tap.c:409:9
 1109 15:16:20.313398     #2 0x5639b88b2d1b in net_init_tap_one third_party/qemu/net/tap.c:681:19
 1109 15:16:20.313399     #3 0x5639b88b16a8 in net_init_tap third_party/qemu/net/tap.c:912:13
 1109 15:16:20.313400     #4 0x5639b8890175 in net_client_init1 third_party/qemu/net/net.c:1110:9
 1109 15:16:20.313401     #5 0x5639b888f912 in net_client_init third_party/qemu/net/net.c:1208:15
 1109 15:16:20.313403     #6 0x5639b8894aa5 in net_param_nic third_party/qemu/net/net.c:1588:11
 1109 15:16:20.313404     #7 0x5639b900cd18 in qemu_opts_foreach third_party/qemu/util/qemu-option.c:1135:14
 1109 15:16:20.313405     #8 0x5639b889393c in net_init_clients third_party/qemu/net/net.c:1612:9
 1109 15:16:20.313407     #9 0x5639b717aaf3 in qemu_create_late_backends third_party/qemu/softmmu/vl.c:1962:5
 1109 15:16:20.313408     #10 0x5639b717aaf3 in qemu_init third_party/qemu/softmmu/vl.c:3694:5
 1109 15:16:20.313409     #11 0x5639b71083b8 in main third_party/qemu/softmmu/main.c:49:5
 1109 15:16:20.313410     #12 0x7f464de1d8d2 in __libc_start_main (/usr/grte/v5/lib64/libc.so.6+0x628d2)
 1109 15:16:20.313412     #13 0x5639b6bbd389 in _start /usr/grte/v5/debug-src/src/csu/../sysdeps/x86_64/start.S:120
 1109 15:16:20.313413
 1109 15:16:20.313417   Uninitialized value was stored to memory at
 1109 15:16:20.313791     #0 0x5639b88affbd in net_tap_fd_init third_party/qemu/net/tap.c:400:26
 1109 15:16:20.313826     #1 0x5639b88b2d1b in net_init_tap_one third_party/qemu/net/tap.c:681:19
 1109 15:16:20.313829     #2 0x5639b88b16a8 in net_init_tap third_party/qemu/net/tap.c:912:13
 1109 15:16:20.313831     #3 0x5639b8890175 in net_client_init1 third_party/qemu/net/net.c:1110:9
 1109 15:16:20.313836     #4 0x5639b888f912 in net_client_init third_party/qemu/net/net.c:1208:15
 1109 15:16:20.313838     #5 0x5639b8894aa5 in net_param_nic third_party/qemu/net/net.c:1588:11
 1109 15:16:20.313839     #6 0x5639b900cd18 in qemu_opts_foreach third_party/qemu/util/qemu-option.c:1135:14
 1109 15:16:20.313841     #7 0x5639b889393c in net_init_clients third_party/qemu/net/net.c:1612:9
 1109 15:16:20.313843     #8 0x5639b717aaf3 in qemu_create_late_backends third_party/qemu/softmmu/vl.c:1962:5
 1109 15:16:20.313844     #9 0x5639b717aaf3 in qemu_init third_party/qemu/softmmu/vl.c:3694:5
 1109 15:16:20.313845     #10 0x5639b71083b8 in main third_party/qemu/softmmu/main.c:49:5
 1109 15:16:20.313846     #11 0x7f464de1d8d2 in __libc_start_main (/usr/grte/v5/lib64/libc.so.6+0x628d2)
 1109 15:16:20.313847     #12 0x5639b6bbd389 in _start /usr/grte/v5/debug-src/src/csu/../sysdeps/x86_64/start.S:120

1109 15:16:20.313849
1109 15:16:20.313851 Uninitialized value was created by an allocation of 'ifr' in the stack frame of function 'tap_probe_vnet_hdr'
1109 15:16:20.313855 #0 0x5639b88ac680 in tap_probe_vnet_hdr third_party/qemu/net/tap-linux.c:151
1109 15:16:20.313856
1109 15:16:20.313878 SUMMARY: MemorySanitizer: use-of-uninitialized-value third_party/qemu/net/tap-linux.c:183:9 in tap_probe_vnet_hdr_len

Fixes dc69004c7d8 ("net: move tap_probe_vnet_hdr() to tap-linux.c")
---
 net/tap-linux.c | 1 +
 1 file changed, 1 insertion(+)
net/tap-linux.c +1 -0
index 9584769..5e70b93 100644
@@ -150,6 +150,7 @@ void tap_set_sndbuf(int fd, const NetdevTapOptions *tap, Error **errp)
 int tap_probe_vnet_hdr(int fd, Error **errp)
 {
     struct ifreq ifr;
+    memset(&ifr, 0, sizeof(ifr));
 
     if (ioctl(fd, TUNGETIFF, &ifr) != 0) {
         /* TUNGETIFF is available since kernel v2.6.27 */
Signature · 1 line
2.7.4
author
#6 lore raw

[PULL 04/13] net/colo-compare.c: Optimize compare order for performance

In reply to Jason Wang

From: Zhang Chen <[email protected]>

COLO-compare use the glib function g_queue_find_custom to dump another VM's networking packet to compare. But this function always start find from the queue->head(here is the newest packet), It will reduce the success rate of comparison. So this patch reversed the order of the queues for performance.

---
 net/colo-compare.c | 26 +++++++++++++-------------
 1 file changed, 13 insertions(+), 13 deletions(-)
net/colo-compare.c +13 -13
index b966e7e..216de5a 100644
@@ -197,7 +197,7 @@ static void colo_compare_inconsistency_notify(CompareState *s)
 /* Use restricted to colo_insert_packet() */
 static gint seq_sorter(Packet *a, Packet *b, gpointer data)
 {
-    return a->tcp_seq - b->tcp_seq;
+    return b->tcp_seq - a->tcp_seq;
 }
 
 static void fill_pkt_tcp_info(void *data, uint32_t *max_ack)
@@ -421,13 +421,13 @@ pri:
     if (g_queue_is_empty(&conn->primary_list)) {
         return;
     }
-    ppkt = g_queue_pop_head(&conn->primary_list);
+    ppkt = g_queue_pop_tail(&conn->primary_list);
 sec:
     if (g_queue_is_empty(&conn->secondary_list)) {
-        g_queue_push_head(&conn->primary_list, ppkt);
+        g_queue_push_tail(&conn->primary_list, ppkt);
         return;
     }
-    spkt = g_queue_pop_head(&conn->secondary_list);
+    spkt = g_queue_pop_tail(&conn->secondary_list);
 
     if (ppkt->tcp_seq == ppkt->seq_end) {
         colo_release_primary_pkt(s, ppkt);
@@ -458,7 +458,7 @@ sec:
             }
         }
         if (!ppkt) {
-            g_queue_push_head(&conn->secondary_list, spkt);
+            g_queue_push_tail(&conn->secondary_list, spkt);
             goto pri;
         }
     }
@@ -477,7 +477,7 @@ sec:
         if (mark == COLO_COMPARE_FREE_PRIMARY) {
             conn->compare_seq = ppkt->seq_end;
             colo_release_primary_pkt(s, ppkt);
-            g_queue_push_head(&conn->secondary_list, spkt);
+            g_queue_push_tail(&conn->secondary_list, spkt);
             goto pri;
         } else if (mark == COLO_COMPARE_FREE_SECONDARY) {
             conn->compare_seq = spkt->seq_end;
@@ -490,8 +490,8 @@ sec:
             goto pri;
         }
     } else {
-        g_queue_push_head(&conn->primary_list, ppkt);
-        g_queue_push_head(&conn->secondary_list, spkt);
+        g_queue_push_tail(&conn->primary_list, ppkt);
+        g_queue_push_tail(&conn->secondary_list, spkt);
 
 #ifdef DEBUG_COLO_PACKETS
         qemu_hexdump(stderr, "colo-compare ppkt", ppkt->data, ppkt->size);
@@ -673,7 +673,7 @@ static void colo_compare_packet(CompareState *s, Connection *conn,
 
     while (!g_queue_is_empty(&conn->primary_list) &&
            !g_queue_is_empty(&conn->secondary_list)) {
-        pkt = g_queue_pop_head(&conn->primary_list);
+        pkt = g_queue_pop_tail(&conn->primary_list);
         result = g_queue_find_custom(&conn->secondary_list,
                  pkt, (GCompareFunc)HandlePacket);
 
@@ -689,7 +689,7 @@ static void colo_compare_packet(CompareState *s, Connection *conn,
              * timeout, it will trigger a checkpoint request.
              */
             trace_colo_compare_main("packet different");
-            g_queue_push_head(&conn->primary_list, pkt);
+            g_queue_push_tail(&conn->primary_list, pkt);
 
             colo_compare_inconsistency_notify(s);
             break;
@@ -819,7 +819,7 @@ static int compare_chr_send(CompareState *s,
         entry->buf = g_malloc(size);
         memcpy(entry->buf, buf, size);
     }
-    g_queue_push_head(&sendco->send_list, entry);
+    g_queue_push_tail(&sendco->send_list, entry);
 
     if (sendco->done) {
         sendco->co = qemu_coroutine_create(_compare_chr_send, sendco);
@@ -1347,7 +1347,7 @@ static void colo_flush_packets(void *opaque, void *user_data)
     Packet *pkt = NULL;
 
     while (!g_queue_is_empty(&conn->primary_list)) {
-        pkt = g_queue_pop_head(&conn->primary_list);
+        pkt = g_queue_pop_tail(&conn->primary_list);
         compare_chr_send(s,
                          pkt->data,
                          pkt->size,
@@ -1357,7 +1357,7 @@ static void colo_flush_packets(void *opaque, void *user_data)
         packet_destroy_partial(pkt, NULL);
     }
     while (!g_queue_is_empty(&conn->secondary_list)) {
-        pkt = g_queue_pop_head(&conn->secondary_list);
+        pkt = g_queue_pop_tail(&conn->secondary_list);
         packet_destroy(pkt, NULL);
     }
 }
Signature · 1 line
2.7.4
author
#7 lore raw

[PULL 10/13] net/vmnet: implement host mode (vmnet-host)

In reply to Jason Wang

From: Vladislav Yaroshchuk <[email protected]>

---
 net/vmnet-host.c | 93 ++++++++++++++++++++++++++++++++++++++++++++++++++++----
 1 file changed, 87 insertions(+), 6 deletions(-)
net/vmnet-host.c +87 -6
index 4a5ef99..9c2e760 100644
@@ -9,16 +9,97 @@
  */
 
 #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"
 
 #include <vmnet/vmnet.h>
 
+typedef struct VmnetHostState {
+  VmnetCommonState cs;
+  QemuUUID network_uuid;
+} VmnetHostState;
+
+static xpc_object_t create_if_desc(const Netdev *netdev,
+                                   NetClientState *nc,
+                                   Error **errp)
+{
+    const NetdevVmnetHostOptions *options = &(netdev->u.vmnet_host);
+    VmnetCommonState *cs = DO_UPCAST(VmnetCommonState, nc, nc);
+    VmnetHostState *hs = DO_UPCAST(VmnetHostState, cs, cs);
+
+    xpc_object_t if_desc = xpc_dictionary_create(NULL, NULL, 0);
+
+    xpc_dictionary_set_uint64(
+        if_desc,
+        vmnet_operation_mode_key,
+        VMNET_HOST_MODE
+    );
+
+    xpc_dictionary_set_bool(
+        if_desc,
+        vmnet_enable_isolation_key,
+        options->isolated
+    );
+
+    if (options->has_net_uuid) {
+        if (qemu_uuid_parse(options->net_uuid, &hs->network_uuid) < 0) {
+            error_setg(errp, "Invalid UUID provided in 'net-uuid'");
+        }
+
+        xpc_dictionary_set_uuid(
+            if_desc,
+            vmnet_network_identifier_key,
+            hs->network_uuid.data
+        );
+    }
+
+    if (options->has_start_address ||
+        options->has_end_address ||
+        options->has_subnet_mask) {
+
+        if (options->has_start_address &&
+            options->has_end_address &&
+            options->has_subnet_mask) {
+
+            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);
+        } else {
+            error_setg(
+                errp,
+                "'start-address', 'end-address', 'subnet_mask' "
+                "should be provided together"
+            );
+        }
+    }
+
+    return if_desc;
+}
+
+static NetClientInfo net_vmnet_host_info = {
+    .type = NET_CLIENT_DRIVER_VMNET_HOST,
+    .size = sizeof(VmnetHostState),
+    .receive = vmnet_receive_common,
+    .cleanup = 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;
+    xpc_object_t if_desc;
+
+    nc = qemu_new_net_client(&net_vmnet_host_info,
+                             peer, "vmnet-host", name);
+    if_desc = create_if_desc(netdev, nc, errp);
+    return vmnet_if_create(nc, if_desc, errp, NULL);
 }
Signature · 1 line
2.7.4
author
#8 lore raw

[PULL 06/13] net/filter: Optimize filter_send to coroutine

In reply to Jason Wang

From: Rao Lei <[email protected]>

This patch is to improve the logic of QEMU main thread sleep code in qemu_chr_write_buffer() where it can be blocked and can't run other coroutines during COLO IO stress test.

Our approach is to put filter_send() in a coroutine. In this way, filter_send() will call qemu_coroutine_yield() in qemu_co_sleep_ns(), so that it can be scheduled out and QEMU main thread has opportunity to run other tasks.

---
 net/filter-mirror.c | 66 ++++++++++++++++++++++++++++++++++++++++++-----------
 1 file changed, 53 insertions(+), 13 deletions(-)
net/filter-mirror.c +53 -13
index f20240c..34a63b5 100644
@@ -20,6 +20,7 @@
 #include "chardev/char-fe.h"
 #include "qemu/iov.h"
 #include "qemu/sockets.h"
+#include "block/aio-wait.h"
 
 #define TYPE_FILTER_MIRROR "filter-mirror"
 typedef struct MirrorState MirrorState;
@@ -42,20 +43,21 @@ struct MirrorState {
     bool vnet_hdr;
 };
 
-static int filter_send(MirrorState *s,
-                       const struct iovec *iov,
-                       int iovcnt)
+typedef struct FilterSendCo {
+    MirrorState *s;
+    char *buf;
+    ssize_t size;
+    bool done;
+    int ret;
+} FilterSendCo;
+
+static int _filter_send(MirrorState *s,
+                       char *buf,
+                       ssize_t size)
 {
     NetFilterState *nf = NETFILTER(s);
     int ret = 0;
-    ssize_t size = 0;
     uint32_t len = 0;
-    char *buf;
-
-    size = iov_size(iov, iovcnt);
-    if (!size) {
-        return 0;
-    }
 
     len = htonl(size);
     ret = qemu_chr_fe_write_all(&s->chr_out, (uint8_t *)&len, sizeof(len));
@@ -80,10 +82,7 @@ static int filter_send(MirrorState *s,
         }
     }
 
-    buf = g_malloc(size);
-    iov_to_buf(iov, iovcnt, 0, buf, size);
     ret = qemu_chr_fe_write_all(&s->chr_out, (uint8_t *)buf, size);
-    g_free(buf);
     if (ret != size) {
         goto err;
     }
@@ -94,6 +93,47 @@ err:
     return ret < 0 ? ret : -EIO;
 }
 
+static void coroutine_fn filter_send_co(void *opaque)
+{
+    FilterSendCo *data = opaque;
+
+    data->ret = _filter_send(data->s, data->buf, data->size);
+    data->done = true;
+    g_free(data->buf);
+    aio_wait_kick();
+}
+
+static int filter_send(MirrorState *s,
+                       const struct iovec *iov,
+                       int iovcnt)
+{
+    ssize_t size = iov_size(iov, iovcnt);
+    char *buf = NULL;
+
+    if (!size) {
+        return 0;
+    }
+
+    buf = g_malloc(size);
+    iov_to_buf(iov, iovcnt, 0, buf, size);
+
+    FilterSendCo data = {
+        .s = s,
+        .size = size,
+        .buf = buf,
+        .ret = 0,
+    };
+
+    Coroutine *co = qemu_coroutine_create(filter_send_co, &data);
+    qemu_coroutine_enter(co);
+
+    while (!data.done) {
+        aio_poll(qemu_get_aio_context(), true);
+    }
+
+    return data.ret;
+}
+
 static void redirector_to_filter(NetFilterState *nf,
                                  const uint8_t *buf,
                                  int len)
Signature · 1 line
2.7.4
author
#9 lore raw

[PULL 09/13] net/vmnet: implement shared mode (vmnet-shared)

In reply to Jason Wang

From: Vladislav Yaroshchuk <[email protected]>

Interaction with vmnet.framework in different modes differs only on configuration stage, so we can create common send, receive, etc. procedures and reuse them.

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 enough performance having .receive() implemented only.

Also, there is no way to unsubscribe from vmnet packages receiving except registering and unregistering event callback or simply drop packages just ignoring and not processing them when related flag is set. Here we do using the second way.

---
 net/vmnet-common.m | 311 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 net/vmnet-shared.c |  74 ++++++++++++-
 net/vmnet_int.h    |  23 ++++
 3 files changed, 404 insertions(+), 4 deletions(-)
net/vmnet-common.m +311 -0
index f949eb6..6d474af 100644
@@ -10,6 +10,8 @@
  */
 
 #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,312 @@
 #include "qapi/error.h"
 
 #include <vmnet/vmnet.h>
+#include <dispatch/dispatch.h>
+
+#ifdef DEBUG
+#define D(x) x
+#define D_LOG(...) qemu_log(__VA_ARGS__)
+#else
+#define D(x) do { } while (0)
+#define D_LOG(...) do { } while (0)
+#endif
+
+typedef struct vmpktdesc vmpktdesc_t;
+typedef struct iovec iovec_t;
+
+static void vmnet_set_send_enabled(VmnetCommonState *s, bool enable)
+{
+    s->send_enabled = enable;
+}
+
+
+static void vmnet_send_completed(NetClientState *nc, ssize_t len)
+{
+    VmnetCommonState *s = DO_UPCAST(VmnetCommonState, nc, nc);
+    vmnet_set_send_enabled(s, true);
+}
+
+
+static void vmnet_send(NetClientState *nc,
+                       interface_event_t event_id,
+                       xpc_object_t event)
+{
+    assert(event_id == VMNET_INTERFACE_PACKETS_AVAILABLE);
+
+    VmnetCommonState *s;
+    uint64_t packets_available;
+
+    struct iovec *iov;
+    struct vmpktdesc *packets;
+    int pkt_cnt;
+    int i;
+
+    vmnet_return_t if_status;
+    ssize_t size;
+
+    s = DO_UPCAST(VmnetCommonState, nc, nc);
+
+    packets_available = xpc_dictionary_get_uint64(
+        event,
+        vmnet_estimated_packets_available_key
+    );
+
+    pkt_cnt = (packets_available < VMNET_PACKETS_LIMIT) ?
+              packets_available :
+              VMNET_PACKETS_LIMIT;
+
+
+    iov = s->iov_buf;
+    packets = s->packets_buf;
+
+    for (i = 0; i < pkt_cnt; ++i) {
+        packets[i].vm_pkt_size = s->max_packet_size;
+        packets[i].vm_pkt_iovcnt = 1;
+        packets[i].vm_flags = 0;
+    }
+
+    if_status = vmnet_read(s->vmnet_if, packets, &pkt_cnt);
+    if (if_status != VMNET_SUCCESS) {
+        error_printf("vmnet: read failed: %s\n",
+                     vmnet_status_map_str(if_status));
+    }
+    qemu_mutex_lock_iothread();
+    for (i = 0; i < pkt_cnt; ++i) {
+        size = qemu_send_packet_async(nc,
+                                      iov[i].iov_base,
+                                      packets[i].vm_pkt_size,
+                                      vmnet_send_completed);
+        if (size == 0) {
+            vmnet_set_send_enabled(s, false);
+        } else if (size < 0) {
+            break;
+        }
+    }
+    qemu_mutex_unlock_iothread();
+
+}
+
+
+static void vmnet_register_event_callback(VmnetCommonState *s)
+{
+    dispatch_queue_t avail_pkt_q = dispatch_queue_create(
+        "org.qemu.vmnet.if_queue",
+        DISPATCH_QUEUE_SERIAL
+    );
+
+    vmnet_interface_set_event_callback(
+        s->vmnet_if,
+        VMNET_INTERFACE_PACKETS_AVAILABLE,
+        avail_pkt_q,
+        ^(interface_event_t event_id, xpc_object_t event) {
+          if (s->send_enabled) {
+              vmnet_send(&s->nc, event_id, event);
+          }
+        });
+}
+
+
+static void vmnet_bufs_init(VmnetCommonState *s)
+{
+    int i;
+    struct vmpktdesc *packets;
+    struct iovec *iov;
+
+    packets = s->packets_buf;
+    iov = s->iov_buf;
+
+    for (i = 0; i < VMNET_PACKETS_LIMIT; ++i) {
+        iov[i].iov_len = s->max_packet_size;
+        iov[i].iov_base = g_malloc0(iov[i].iov_len);
+        packets[i].vm_pkt_iov = iov + i;
+    }
+}
+
+
+const char *vmnet_status_map_str(vmnet_return_t status)
+{
+    switch (status) {
+    case VMNET_SUCCESS:
+        return "success";
+    case VMNET_FAILURE:
+        return "general failure";
+    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";
+    case VMNET_SHARING_SERVICE_BUSY:
+        return "conflict, sharing service is in use";
+    default:
+        return "unknown vmnet error";
+    }
+}
+
+
+int vmnet_if_create(NetClientState *nc,
+                    xpc_object_t if_desc,
+                    Error **errp,
+                    void (*completion_callback)(xpc_object_t interface_param))
+{
+    VmnetCommonState *s;
+
+    dispatch_queue_t if_create_q;
+    dispatch_semaphore_t if_created_sem;
+
+    __block vmnet_return_t if_status;
+
+    if_create_q = dispatch_queue_create("org.qemu.vmnet.create",
+                                        DISPATCH_QUEUE_SERIAL);
+    if_created_sem = dispatch_semaphore_create(0);
+
+    xpc_dictionary_set_bool(
+        if_desc,
+        vmnet_allocate_mac_address_key,
+        false
+    );
+
+    D(D_LOG("vmnet.start.interface_desc:\n");
+    xpc_dictionary_apply(if_desc,
+                         ^bool(const char *k, xpc_object_t v) {
+                           char *desc = xpc_copy_description(v);
+                           D_LOG("  %s=%s\n", k, desc);
+                           free(desc);
+                           return true;
+                         }));
+
+    s = DO_UPCAST(VmnetCommonState, nc, nc);
+    s->vmnet_if = vmnet_start_interface(
+        if_desc,
+        if_create_q,
+        ^(vmnet_return_t status, xpc_object_t interface_param) {
+          if_status = status;
+          if (status != VMNET_SUCCESS || !interface_param) {
+              dispatch_semaphore_signal(if_created_sem);
+              return;
+          }
+
+          D(D_LOG("vmnet.start.interface_param:\n");
+                xpc_dictionary_apply(interface_param,
+                                     ^bool(const char *k, xpc_object_t v) {
+                                       char *desc = xpc_copy_description(v);
+                                       D_LOG("  %s=%s\n", k, desc);
+                                       free(desc);
+                                       return true;
+                                     }));
+
+          s->mtu = xpc_dictionary_get_uint64(
+              interface_param,
+              vmnet_mtu_key);
+          s->max_packet_size = xpc_dictionary_get_uint64(
+              interface_param,
+              vmnet_max_packet_size_key);
+
+          if (completion_callback) {
+              completion_callback(interface_param);
+          }
+          dispatch_semaphore_signal(if_created_sem);
+        });
+
+    if (s->vmnet_if == NULL) {
+        error_setg(errp, "unable to create interface with requested params");
+        return -1;
+    }
+
+    dispatch_semaphore_wait(if_created_sem, DISPATCH_TIME_FOREVER);
+    dispatch_release(if_create_q);
+
+    if (if_status != VMNET_SUCCESS) {
+        error_setg(errp,
+                   "cannot create vmnet interface: %s",
+                   vmnet_status_map_str(if_status));
+        return -1;
+    }
+
+    vmnet_register_event_callback(s);
+    vmnet_bufs_init(s);
+    vmnet_set_send_enabled(s, true);
+
+    return 0;
+}
+
+
+ssize_t vmnet_receive_common(NetClientState *nc,
+                             const uint8_t *buf,
+                             size_t size)
+{
+    VmnetCommonState *s;
+    vmpktdesc_t packet;
+    iovec_t iov;
+    int pkt_cnt;
+    vmnet_return_t if_status;
+
+    s = DO_UPCAST(VmnetCommonState, nc, nc);
+
+    if (size > s->max_packet_size) {
+        warn_report("vmnet: packet is too big, %zu > %llu\n",
+                    packet.vm_pkt_size,
+                    s->max_packet_size);
+        return -1;
+    }
+
+    iov.iov_base = (char *) buf;
+    iov.iov_len = size;
+
+    packet.vm_pkt_iovcnt = 1;
+    packet.vm_flags = 0;
+    packet.vm_pkt_size = size;
+    packet.vm_pkt_iov = &iov;
+
+    pkt_cnt = 1;
+    if_status = vmnet_write(s->vmnet_if, &packet, &pkt_cnt);
+
+    if (if_status != VMNET_SUCCESS) {
+        error_report("vmnet: write error: %s\n",
+                     vmnet_status_map_str(if_status));
+    }
+
+    if (if_status == VMNET_SUCCESS && pkt_cnt) {
+        return size;
+    }
+    return 0;
+}
+
+
+void vmnet_cleanup_common(NetClientState *nc)
+{
+    VmnetCommonState *s;
+    dispatch_queue_t if_destroy_q;
+
+    s = DO_UPCAST(VmnetCommonState, nc, nc);
+
+    qemu_purge_queued_packets(nc);
+    vmnet_set_send_enabled(s, false);
+
+    if (s->vmnet_if == NULL) {
+        return;
+    }
+
+    if_destroy_q = dispatch_queue_create(
+        "org.qemu.vmnet.destroy",
+        DISPATCH_QUEUE_SERIAL
+    );
+
+    vmnet_stop_interface(
+        s->vmnet_if,
+        if_destroy_q,
+        ^(vmnet_return_t status) {
+        });
+
+    for (int i = 0; i < VMNET_PACKETS_LIMIT; ++i) {
+        g_free(s->iov_buf[i].iov_base);
+    }
+}
net/vmnet-shared.c +70 -4

86 lines not on this page · raw message

net/vmnet_int.h +23 -0
index c598225..3979fe4 100644
@@ -16,10 +16,33 @@
 
 #include <vmnet/vmnet.h>
 
+#define VMNET_PACKETS_LIMIT 50
+
 typedef struct VmnetCommonState {
   NetClientState nc;
+  interface_ref vmnet_if;
+
+  bool send_enabled;
+
+  uint64_t mtu;
+  uint64_t max_packet_size;
+
+  struct vmpktdesc packets_buf[VMNET_PACKETS_LIMIT];
+  struct iovec iov_buf[VMNET_PACKETS_LIMIT];
 
 } VmnetCommonState;
 
+const char *vmnet_status_map_str(vmnet_return_t status);
+
+int vmnet_if_create(NetClientState *nc,
+                    xpc_object_t if_desc,
+                    Error **errp,
+                    void (*completion_callback)(xpc_object_t interface_param));
+
+ssize_t vmnet_receive_common(NetClientState *nc,
+                             const uint8_t *buf,
+                             size_t size);
+
+void vmnet_cleanup_common(NetClientState *nc);
 
 #endif /* VMNET_INT_H */
Signature · 1 line
2.7.4
author
#10 lore raw

[PULL 11/13] net/vmnet: implement bridged mode (vmnet-bridged)

In reply to Jason Wang

From: Vladislav Yaroshchuk <[email protected]>

---
 net/vmnet-bridged.m | 98 +++++++++++++++++++++++++++++++++++++++++++++++++----
 1 file changed, 92 insertions(+), 6 deletions(-)
net/vmnet-bridged.m +92 -6
index 4e42a90..3c9da9d 100644
@@ -10,16 +10,102 @@
 
 #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"
 
 #include <vmnet/vmnet.h>
 
+typedef struct VmnetBridgedState {
+  VmnetCommonState cs;
+} VmnetBridgedState;
+
+static bool validate_ifname(const char *ifname)
+{
+    xpc_object_t shared_if_list = vmnet_copy_shared_interface_list();
+    __block bool match = false;
+
+    xpc_array_apply(
+        shared_if_list,
+        ^bool(size_t index, xpc_object_t value) {
+          if (strcmp(xpc_string_get_string_ptr(value), ifname) == 0) {
+              match = true;
+              return false;
+          }
+          return true;
+        });
+
+    return match;
+}
+
+static const char *get_valid_ifnames(void)
+{
+    xpc_object_t shared_if_list = vmnet_copy_shared_interface_list();
+    __block char *if_list = NULL;
+
+    xpc_array_apply(
+        shared_if_list,
+        ^bool(size_t index, xpc_object_t value) {
+          if_list = g_strconcat(xpc_string_get_string_ptr(value),
+                                " ",
+                                if_list,
+                                NULL);
+          return true;
+        });
+
+    if (if_list) {
+        return if_list;
+    }
+    return "[no interfaces]";
+}
+
+static xpc_object_t create_if_desc(const Netdev *netdev, Error **errp)
+{
+    const NetdevVmnetBridgedOptions *options = &(netdev->u.vmnet_bridged);
+    xpc_object_t if_desc = xpc_dictionary_create(NULL, NULL, 0);
+
+    xpc_dictionary_set_uint64(
+        if_desc,
+        vmnet_operation_mode_key,
+        VMNET_BRIDGED_MODE
+    );
+
+    xpc_dictionary_set_bool(
+        if_desc,
+        vmnet_enable_isolation_key,
+        options->isolated
+    );
+
+    if (validate_ifname(options->ifname)) {
+        xpc_dictionary_set_string(if_desc,
+                                  vmnet_shared_interface_name_key,
+                                  options->ifname);
+    } else {
+        return NULL;
+    }
+    return if_desc;
+}
+
+static NetClientInfo net_vmnet_bridged_info = {
+    .type = NET_CLIENT_DRIVER_VMNET_BRIDGED,
+    .size = sizeof(VmnetBridgedState),
+    .receive = vmnet_receive_common,
+    .cleanup = 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 = qemu_new_net_client(&net_vmnet_bridged_info,
+                                             peer, "vmnet-bridged", name);
+    xpc_object_t if_desc = create_if_desc(netdev, errp);;
+
+    if (!if_desc) {
+        error_setg(errp,
+                   "unsupported ifname, should be one of: %s",
+                   get_valid_ifnames());
+        return -1;
+    }
+
+    return vmnet_if_create(nc, if_desc, errp, NULL);
+}
\ No newline at end of file
Signature · 1 line
2.7.4
author
#11 lore raw

[PULL 13/13] net/vmnet: update MAINTAINERS list

In reply to Jason Wang

From: Vladislav Yaroshchuk <[email protected]>

---
 MAINTAINERS | 5 +++++
 1 file changed, 5 insertions(+)
MAINTAINERS +5 -0
index c98a61c..638d129 100644
@@ -2641,6 +2641,11 @@ W: http://info.iet.unipi.it/~luigi/netmap/
 S: Maintained
 F: net/netmap.c
 
+Apple vmnet network backends
+M: Vladislav Yaroshchuk <[email protected]>
+S: Maintained
+F: net/vmnet*
+
 Host Memory Backends
 M: David Hildenbrand <[email protected]>
 M: Igor Mammedov <[email protected]>
Signature · 1 line
2.7.4
author
#12 lore raw

[PULL 07/13] net/vmnet: add vmnet dependency and customizable option

In reply to Jason Wang

From: Vladislav Yaroshchuk <[email protected]>

---
 meson.build                   | 4 ++++
 meson_options.txt             | 2 ++
 scripts/meson-buildoptions.sh | 3 +++
 3 files changed, 9 insertions(+)
meson.build +4 -0
index c1b1db1..1a381ee 100644
@@ -496,6 +496,8 @@ if cocoa.found() and get_option('gtk').enabled()
   error('Cocoa and GTK+ cannot be enabled at the same time')
 endif
 
+vmnet = dependency('appleframeworks', modules: 'vmnet', required: get_option('vmnet'))
+
 seccomp = not_found
 if not get_option('seccomp').auto() or have_system or have_tools
   seccomp = dependency('libseccomp', version: '>=2.3.0',
@@ -1492,6 +1494,7 @@ config_host_data.set('CONFIG_SECCOMP', seccomp.found())
 config_host_data.set('CONFIG_SNAPPY', snappy.found())
 config_host_data.set('CONFIG_USB_LIBUSB', libusb.found())
 config_host_data.set('CONFIG_VDE', vde.found())
+config_host_data.set('CONFIG_VMNET', vmnet.found())
 config_host_data.set('CONFIG_VHOST_USER_BLK_SERVER', have_vhost_user_blk_server)
 config_host_data.set('CONFIG_VNC', vnc.found())
 config_host_data.set('CONFIG_VNC_JPEG', jpeg.found())
@@ -3441,6 +3444,7 @@ endif
 summary_info += {'JACK support':      jack}
 summary_info += {'brlapi support':    brlapi}
 summary_info += {'vde support':       vde}
+summary_info += {'vmnet.framework support': vmnet}
 summary_info += {'netmap support':    have_netmap}
 summary_info += {'l2tpv3 support':    have_l2tpv3}
 summary_info += {'Linux AIO support': libaio}
meson_options.txt +2 -0
index 921967e..701e138 100644
@@ -151,6 +151,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('vnc', type : 'feature', value : 'auto',
scripts/meson-buildoptions.sh +3 -0
index 50bd7be..cdcece4 100644
@@ -84,6 +84,7 @@ meson_options_help() {
   printf "%s\n" '  u2f             U2F emulation support'
   printf "%s\n" '  usb-redir       libusbredir support'
   printf "%s\n" '  vde             vde network 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" '  virglrenderer   virgl rendering support'
@@ -248,6 +249,8 @@ _meson_option_parse() {
     --disable-usb-redir) printf "%s" -Dusb_redir=disabled ;;
     --enable-vde) printf "%s" -Dvde=enabled ;;
     --disable-vde) printf "%s" -Dvde=disabled ;;
+    --enable-vmnet) printf "%s" -Dvmnet=enabled ;;
+    --disable-vmnet) printf "%s" -Dvmnet=disabled ;;
     --enable-vhost-user-blk-server) printf "%s" -Dvhost_user_blk_server=enabled ;;
     --disable-vhost-user-blk-server) printf "%s" -Dvhost_user_blk_server=disabled ;;
     --enable-virglrenderer) printf "%s" -Dvirglrenderer=enabled ;;
Signature · 1 line
2.7.4
author
#13 lore raw

[PULL 08/13] net/vmnet: add vmnet backends to qapi/net

In reply to Jason Wang

From: Vladislav Yaroshchuk <[email protected]>

The vmnet framework is an API for virtual machines to read and write packets.

The API allows a Guest OS interface to be in host mode or shared mode. Interfaces in host mode can communicate with the native host system and other interfaces running in host mode. In shared mode, the network interface can send and receive packets to the Internet, the native host, and other interfaces running in sharing mode.

Create separate netdevs for each vmnet operating mode:

- vmnet-host
- vmnet-shared
- vmnet-bridged

---
 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       | 132 +++++++++++++++++++++++++++++++++++++++++++++++++++-
 9 files changed, 276 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
net/clients.h +11 -0
index 92f9b59..c915778 100644
@@ -63,4 +63,15 @@ int net_init_vhost_user(const Netdev *netdev, const char *name,
 
 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 */
net/meson.build +7 -0
index 847bc2a..00a88c4 100644
@@ -42,4 +42,11 @@ softmmu_ss.add(when: 'CONFIG_POSIX', if_true: files(tap_posix))
 softmmu_ss.add(when: 'CONFIG_WIN32', if_true: files('tap-win32.c'))
 softmmu_ss.add(when: 'CONFIG_VHOST_NET_VDPA', if_true: files('vhost-vdpa.c'))
 
+vmnet_files = files(
+  'vmnet-common.m',
+  'vmnet-bridged.m',
+  'vmnet-host.c',
+  'vmnet-shared.c'
+)
+softmmu_ss.add(when: vmnet, if_true: vmnet_files)
 subdir('can')
net/net.c +10 -0
index f0d14db..1dbb64b 100644
@@ -1021,6 +1021,11 @@ static int (* const net_client_init_fun[NET_CLIENT_DRIVER__MAX])(
 #ifdef CONFIG_L2TPV3
         [NET_CLIENT_DRIVER_L2TPV3]    = net_init_l2tpv3,
 #endif
+#ifdef CONFIG_VMNET
+        [NET_CLIENT_DRIVER_VMNET_HOST] = net_init_vmnet_host,
+        [NET_CLIENT_DRIVER_VMNET_SHARED] = net_init_vmnet_shared,
+        [NET_CLIENT_DRIVER_VMNET_BRIDGED] = net_init_vmnet_bridged,
+#endif /* CONFIG_VMNET */
 };
 
 
@@ -1107,6 +1112,11 @@ void show_netdevs(void)
 #ifdef CONFIG_VHOST_VDPA
         "vhost-vdpa",
 #endif
+#ifdef CONFIG_VMNET
+        "vmnet-host",
+        "vmnet-shared",
+        "vmnet-bridged",
+#endif
     };
 
     qemu_printf("Available netdev backend types:\n");
net/vmnet-bridged.m new file +25 -0
new file mode 100644
index 0000000..4e42a90
@@ -0,0 +1,25 @@
+/*
+ * vmnet-bridged.m
+ *
+ * Copyright(c) 2021 Vladislav Yaroshchuk <[email protected]>
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
+ * 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 <vmnet/vmnet.h>
+
+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;
+}
net/vmnet-common.m new file +19 -0
new file mode 100644
index 0000000..f949eb6
@@ -0,0 +1,19 @@
+/*
+ * vmnet-common.m - network client wrapper for Apple vmnet.framework
+ *
+ * Copyright(c) 2021 Vladislav Yaroshchuk <[email protected]>
+ * Copyright(c) 2021 Phillip Tennen <[email protected]>
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
+ * 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 <vmnet/vmnet.h>
net/vmnet-host.c new file +24 -0
new file mode 100644
index 0000000..4a5ef99
@@ -0,0 +1,24 @@
+/*
+ * vmnet-host.c
+ *
+ * Copyright(c) 2021 Vladislav Yaroshchuk <[email protected]>
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
+ * 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 <vmnet/vmnet.h>
+
+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;
+}
net/vmnet-shared.c new file +25 -0
new file mode 100644
index 0000000..f8c4a4f
@@ -0,0 +1,25 @@
+/*
+ * vmnet-shared.c
+ *
+ * Copyright(c) 2021 Vladislav Yaroshchuk <[email protected]>
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
+ * 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 <vmnet/vmnet.h>
+
+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;
+}
net/vmnet_int.h new file +25 -0
new file mode 100644
index 0000000..c598225
@@ -0,0 +1,25 @@
+/*
+ * vmnet_int.h
+ *
+ * Copyright(c) 2021 Vladislav Yaroshchuk <[email protected]>
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
+ * 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 <vmnet/vmnet.h>
+
+typedef struct VmnetCommonState {
+  NetClientState nc;
+
+} VmnetCommonState;
+
+
+#endif /* VMNET_INT_H */
qapi/net.json +130 -2

159 lines not on this page · raw message

Signature · 1 line
2.7.4
#14 lore raw
In reply to Jason Wang
Quoted 9 lines · Jason Wang

The following changes since commit df722e33d5da26ea8604500ca8f509245a0ea524:

Merge tag 'bsd-user-arm-pull-request' of gitlab.com:bsdimp/qemu into staging (2022-01-08 09:37:59 -0800)

are available in the git repository at:

https://github.com/jasowang/qemu.git tags/net-pull-request

Quoted 7 lines

for you to fetch changes up to 5136cc6d3b8b74f4fa572f0874656947a401330e:

net/vmnet: update MAINTAINERS list (2022-01-10 11:30:55 +0800)

----------------------------------------------------------------

----------------------------------------------------------------

Fails to build on OSX Catalina:

../../net/vmnet-common.m:165:10: error: use of undeclared identifier 'VMNET_SHARING_SERVICE_BUSY'

    case VMNET_SHARING_SERVICE_BUSY:
         ^

This constant only got added in macOS 11.0. I guess that technically our supported-platforms policy only requires us to support 11 (Big Sur) and 12 (Monterey) at this point, but it would be nice to still be able to build on Catalina (10.15).

(Personally I would like Catalina still to work at least for a little while, because my x86 Mac is old enough that it is not supported by Big Sur. I'll have to dump it once Apple stops doing security support for Catalina, but they haven't done that quite yet.)

-- PMM

author
#15 lore raw
Quoted 23 lines · Peter Maydell
Quoted 9 lines · Jason Wang

The following changes since commit df722e33d5da26ea8604500ca8f509245a0ea524:

Merge tag 'bsd-user-arm-pull-request' of gitlab.com:bsdimp/qemu into staging (2022-01-08 09:37:59 -0800)

are available in the git repository at:

https://github.com/jasowang/qemu.git tags/net-pull-request

Quoted 7 lines

for you to fetch changes up to 5136cc6d3b8b74f4fa572f0874656947a401330e:

net/vmnet: update MAINTAINERS list (2022-01-10 11:30:55 +0800)

----------------------------------------------------------------

----------------------------------------------------------------

Fails to build on OSX Catalina:

../../net/vmnet-common.m:165:10: error: use of undeclared identifier 'VMNET_SHARING_SERVICE_BUSY'

Quoted 7 lines
    case VMNET_SHARING_SERVICE_BUSY:
         ^

This constant only got added in macOS 11.0. I guess that technically our supported-platforms policy only requires us to support 11 (Big Sur) and 12 (Monterey) at this point, but it would be nice to still be able to build on Catalina (10.15).

Yes, it was only supported by the vmnet framework starting from Catalyst according to
https://developer.apple.com/documentation/vmnet?language=objc.

Quoted 5 lines

(Personally I would like Catalina still to work at least for a little while, because my x86 Mac is old enough that it is not supported by Big Sur. I'll have to dump it once Apple stops doing security support for Catalina, but they haven't done that quite yet.)

Sure, Vladislav please fix this and send a new version.

Thanks

Quoted 3 lines

-- PMM

#16 lore raw

вт, 11 янв. 2022 г., 5:10 AM Jason Wang <[email protected]>:

Quoted 9 lines
Quoted 4 lines · Peter Maydell
Quoted 2 lines · Jason Wang

The following changes since commit

df722e33d5da26ea8604500ca8f509245a0ea524:

Quoted 2 lines
Quoted 2 lines

Merge tag 'bsd-user-arm-pull-request' of gitlab.com:bsdimp/qemu

Quoted 27 lines

into staging (2022-01-08 09:37:59 -0800)

Quoted 6 lines
Quoted 6 lines

are available in the git repository at:

https://github.com/jasowang/qemu.git tags/net-pull-request

for you to fetch changes up to

5136cc6d3b8b74f4fa572f0874656947a401330e:

Quoted 18 lines
Quoted 6 lines

net/vmnet: update MAINTAINERS list (2022-01-10 11:30:55 +0800)

----------------------------------------------------------------

----------------------------------------------------------------

Fails to build on OSX Catalina:

../../net/vmnet-common.m:165:10: error: use of undeclared identifier 'VMNET_SHARING_SERVICE_BUSY'

    case VMNET_SHARING_SERVICE_BUSY:
         ^

This constant only got added in macOS 11.0. I guess that technically our supported-platforms policy only requires us to support 11 (Big Sur) and 12 (Monterey) at this point, but it would be nice to still be able to build on Catalina (10.15).

Yes, it was only supported by the vmnet framework starting from

Quoted 4 lines

Catalyst according to
https://developer.apple.com/documentation/vmnet?language=objc.

Yes, there are some symbols from macOS >= 11.0 new backend uses, not only this one, ex. vmnet_enable_isolation_key:
https://developer.apple.com/documentation/vmnet/vmnet_enable_isolation_key

Quoted 7 lines
Quoted 5 lines

(Personally I would like Catalina still to work at least for a little while, because my x86 Mac is old enough that it is not supported by Big Sur. I'll have to dump it once Apple stops doing security support for Catalina, but they haven't done that quite yet.)

Sure, broken builds on old macOSes are bad. For this case I think it's enough to disable vmnet for macOS < 11.0 with a probe while configure build step. Especially given that Apple supports ~three latest macOS versions, support for Catalina is expected to end in 2022, when QEMU releases 7.0.

If this workaround is not suitable and it's required to support vmnet in Catalina 10.15 with a subset of available features, it can be done. But I'll be ready to handle this in approximately two-three weeks only.

Quoted 3 lines

Sure, Vladislav please fix this and send a new version.

Quick fix as described above is available in v10:
https://patchew.org/QEMU/[email protected]/

Quoted 8 lines

Thanks

Quoted 3 lines

-- PMM

Signature · 3 lines
Best Regards,

Vladislav Yaroshchuk
author
#17 lore raw
Quoted 61 lines · Vladislav Yaroshchuk

вт, 11 янв. 2022 г., 5:10 AM Jason Wang <[email protected]>:

    On Tue, Jan 11, 2022 at 12:49 AM Peter Maydell
    <[email protected]> wrote:
    >
    > On Mon, 10 Jan 2022 at 03:40, Jason Wang <[email protected]>
    wrote:
    > >
    > > The following changes since commit
    df722e33d5da26ea8604500ca8f509245a0ea524:
    > >
    > >   Merge tag 'bsd-user-arm-pull-request' of
    gitlab.com:bsdimp/qemu into staging (2022-01-08 09:37:59 -0800)
    > >
    > > are available in the git repository at:
    > >
    > > https://github.com/jasowang/qemu.git tags/net-pull-request
    > >
    > > for you to fetch changes up to
    5136cc6d3b8b74f4fa572f0874656947a401330e:
    > >
    > >   net/vmnet: update MAINTAINERS list (2022-01-10 11:30:55 +0800)
    > >
    > > ----------------------------------------------------------------
    > >
    > > ----------------------------------------------------------------
    >
    > Fails to build on OSX Catalina:
    >
    > ../../net/vmnet-common.m:165:10: error: use of undeclared identifier
    > 'VMNET_SHARING_SERVICE_BUSY'
    >     case VMNET_SHARING_SERVICE_BUSY:
    >          ^
    >
    > This constant only got added in macOS 11.0. I guess that technically
    > our supported-platforms policy only requires us to support 11
    (Big Sur)
    > and 12 (Monterey) at this point, but it would be nice to still
    be able
    > to build on Catalina (10.15).

    Yes, it was only supported by the vmnet framework starting from
    Catalyst according to
    https://developer.apple.com/documentation/vmnet?language=objc.

Yes, there are some symbols from macOS >= 11.0 new backend uses, not only this one, ex. vmnet_enable_isolation_key:
https://developer.apple.com/documentation/vmnet/vmnet_enable_isolation_key

Quoted 2 lines

(Personally I would like Catalina still to work at least for a

little
> while, because my x86 Mac is old enough that it is not supported by > Big Sur. I'll have to dump it once Apple stops doing security support
> for Catalina, but they haven't done that quite yet.)

Quoted 5 lines

Sure, broken builds on old macOSes are bad. For this case I think it's enough to disable vmnet for macOS < 11.0 with a probe while configure build step. Especially given that Apple supports ~three latest macOS versions, support for Catalina is expected to end in 2022, when QEMU releases 7.0.

That should be fine.

Quoted 10 lines

If this workaround is not suitable and it's required to support vmnet in Catalina 10.15 with a subset of available features, it can be done. But I'll be ready to handle this in approximately two-three weeks only.

Sure, Vladislav please fix this and send a new version.

Quick fix as described above is available in v10:
https://patchew.org/QEMU/[email protected]/

Have you got chance to test that for macOS < 11.0?

Thanks

Quoted 13 lines
    Thanks

    >
    > -- PMM
    >
Signature · 3 lines
Best Regards,

Vladislav Yaroshchuk
#18 lore raw

ср, 12 янв. 2022 г., 8:39 AM Jason Wang <[email protected]>:

Quoted 84 lines · Vladislav Yaroshchuk
Quoted 24 lines

вт, 11 янв. 2022 г., 5:10 AM Jason Wang <[email protected]>:

    On Tue, Jan 11, 2022 at 12:49 AM Peter Maydell
    <[email protected]> wrote:
    >
    > On Mon, 10 Jan 2022 at 03:40, Jason Wang <[email protected]>
    wrote:
    > >
    > > The following changes since commit
    df722e33d5da26ea8604500ca8f509245a0ea524:
    > >
    > >   Merge tag 'bsd-user-arm-pull-request' of
    gitlab.com:bsdimp/qemu into staging (2022-01-08 09:37:59 -0800)
    > >
    > > are available in the git repository at:
    > >
    > > https://github.com/jasowang/qemu.git tags/net-pull-request
    > >
    > > for you to fetch changes up to
    5136cc6d3b8b74f4fa572f0874656947a401330e:
    > >
    > >   net/vmnet: update MAINTAINERS list (2022-01-10 11:30:55 +0800)
Quoted 8 lines
    > >
    > > ----------------------------------------------------------------
    > >
    > > ----------------------------------------------------------------
    >
    > Fails to build on OSX Catalina:
    >
    > ../../net/vmnet-common.m:165:10: error: use of undeclared

identifier

Quoted 5 lines
Quoted 5 lines

'VMNET_SHARING_SERVICE_BUSY'

    case VMNET_SHARING_SERVICE_BUSY:
         ^

This constant only got added in macOS 11.0. I guess that

technically

Quoted 6 lines
Quoted 1 line

our supported-platforms policy only requires us to support 11

(Big Sur)
> and 12 (Monterey) at this point, but it would be nice to still be able
> to build on Catalina (10.15).

Quoted 8 lines

Yes, it was only supported by the vmnet framework starting from Catalyst according to
https://developer.apple.com/documentation/vmnet?language=objc.

Yes, there are some symbols from macOS >= 11.0 new backend uses, not only this one, ex. vmnet_enable_isolation_key:

https://developer.apple.com/documentation/vmnet/vmnet_enable_isolation_key

Quoted 10 lines
Quoted 3 lines

(Personally I would like Catalina still to work at least for a

little
> while, because my x86 Mac is old enough that it is not supported by > Big Sur. I'll have to dump it once Apple stops doing security support
> for Catalina, but they haven't done that quite yet.)

Quoted 5 lines

Sure, broken builds on old macOSes are bad. For this case I think it's enough to disable vmnet for macOS < 11.0 with a probe while configure build step. Especially given that Apple supports ~three latest macOS versions, support for Catalina is expected to end in 2022, when QEMU releases 7.0.

That should be fine.

Quoted 8 lines

If this workaround is not suitable and it's required to support vmnet in Catalina 10.15 with a subset of available features, it can be done. But I'll be ready to handle this in approximately two-three weeks only.

Sure, Vladislav please fix this and send a new version.

Quoted 7 lines
Quoted 2 lines

Quick fix as described above is available in v10:

https://patchew.org/QEMU/[email protected]/

Have you got chance to test that for macOS < 11.0?

Yes, tested on Catalina 10.15.Works as expected.

Thanks

Quoted 19 lines
Quoted 15 lines

    Thanks

    >
    > -- PMM
    >

--
Best Regards,

Vladislav Yaroshchuk

#20 lore raw
In reply to Jason Wang
Quoted 63 lines · Jason Wang
Quoted 61 lines · Vladislav Yaroshchuk

вт, 11 янв. 2022 г., 5:10 AM Jason Wang <[email protected]>:

    On Tue, Jan 11, 2022 at 12:49 AM Peter Maydell
    <[email protected]> wrote:
    >
    > On Mon, 10 Jan 2022 at 03:40, Jason Wang <[email protected]>
    wrote:
    > >
    > > The following changes since commit
    df722e33d5da26ea8604500ca8f509245a0ea524:
    > >
    > >   Merge tag 'bsd-user-arm-pull-request' of
    gitlab.com:bsdimp/qemu into staging (2022-01-08 09:37:59 -0800)
    > >
    > > are available in the git repository at:
    > >
    > > https://github.com/jasowang/qemu.git tags/net-pull-request
    > >
    > > for you to fetch changes up to
    5136cc6d3b8b74f4fa572f0874656947a401330e:
    > >
    > >   net/vmnet: update MAINTAINERS list (2022-01-10 11:30:55 +0800)
    > >
    > > ----------------------------------------------------------------
    > >
    > > ----------------------------------------------------------------
    >
    > Fails to build on OSX Catalina:
    >
    > ../../net/vmnet-common.m:165:10: error: use of undeclared identifier
    > 'VMNET_SHARING_SERVICE_BUSY'
    >     case VMNET_SHARING_SERVICE_BUSY:
    >          ^
    >
    > This constant only got added in macOS 11.0. I guess that technically
    > our supported-platforms policy only requires us to support 11
    (Big Sur)
    > and 12 (Monterey) at this point, but it would be nice to still
    be able
    > to build on Catalina (10.15).

    Yes, it was only supported by the vmnet framework starting from
    Catalyst according to
    https://developer.apple.com/documentation/vmnet?language=objc.

Yes, there are some symbols from macOS >= 11.0 new backend uses, not only this one, ex. vmnet_enable_isolation_key:
https://developer.apple.com/documentation/vmnet/vmnet_enable_isolation_key

Quoted 2 lines

(Personally I would like Catalina still to work at least for a

little
> while, because my x86 Mac is old enough that it is not supported by > Big Sur. I'll have to dump it once Apple stops doing security support
> for Catalina, but they haven't done that quite yet.)

Quoted 9 lines
Quoted 5 lines

Sure, broken builds on old macOSes are bad. For this case I think it's enough to disable vmnet for macOS < 11.0 with a probe while configure build step. Especially given that Apple supports ~three latest macOS versions, support for Catalina is expected to end in 2022, when QEMU releases 7.0.

That should be fine.

I agree with Peter on this,

There's a lot of hardware running with Catalina. I think it's useful to support it a little longer.

Regards,
Roman

Quoted 33 lines
Quoted 11 lines

If this workaround is not suitable and it's required to support vmnet in Catalina 10.15 with a subset of available features, it can be done. But I'll be ready to handle this in approximately two-three weeks only.

Sure, Vladislav please fix this and send a new version.

Quick fix as described above is available in v10:
https://patchew.org/QEMU/[email protected]/

Have you got chance to test that for macOS < 11.0?

Thanks

Quoted 13 lines
    Thanks

    >
    > -- PMM
    >
Signature · 3 lines
Best Regards,

Vladislav Yaroshchuk
author
#19 lore raw
In reply to Vladislav Yaroshchuk
Quoted 86 lines · Vladislav Yaroshchuk

ср, 12 янв. 2022 г., 8:39 AM Jason Wang <[email protected]>:

Quoted 82 lines · Vladislav Yaroshchuk
Quoted 61 lines

вт, 11 янв. 2022 г., 5:10 AM Jason Wang <[email protected]>:

    On Tue, Jan 11, 2022 at 12:49 AM Peter Maydell
    <[email protected]> wrote:
    >
    > On Mon, 10 Jan 2022 at 03:40, Jason Wang <[email protected]>
    wrote:
    > >
    > > The following changes since commit
    df722e33d5da26ea8604500ca8f509245a0ea524:
    > >
    > >   Merge tag 'bsd-user-arm-pull-request' of
    gitlab.com:bsdimp/qemu into staging (2022-01-08 09:37:59 -0800)
    > >
    > > are available in the git repository at:
    > >
    > > https://github.com/jasowang/qemu.git tags/net-pull-request
    > >
    > > for you to fetch changes up to
    5136cc6d3b8b74f4fa572f0874656947a401330e:
    > >
    > >   net/vmnet: update MAINTAINERS list (2022-01-10 11:30:55 +0800)
    > >
    > > ----------------------------------------------------------------
    > >
    > > ----------------------------------------------------------------
    >
    > Fails to build on OSX Catalina:
    >
    > ../../net/vmnet-common.m:165:10: error: use of undeclared identifier
    > 'VMNET_SHARING_SERVICE_BUSY'
    >     case VMNET_SHARING_SERVICE_BUSY:
    >          ^
    >
    > This constant only got added in macOS 11.0. I guess that technically
    > our supported-platforms policy only requires us to support 11
    (Big Sur)
    > and 12 (Monterey) at this point, but it would be nice to still
    be able
    > to build on Catalina (10.15).

    Yes, it was only supported by the vmnet framework starting from
    Catalyst according to
    https://developer.apple.com/documentation/vmnet?language=objc.

Yes, there are some symbols from macOS >= 11.0 new backend uses, not only this one, ex. vmnet_enable_isolation_key:
https://developer.apple.com/documentation/vmnet/vmnet_enable_isolation_key

Quoted 2 lines

(Personally I would like Catalina still to work at least for a

little
> while, because my x86 Mac is old enough that it is not supported by > Big Sur. I'll have to dump it once Apple stops doing security support
> for Catalina, but they haven't done that quite yet.)

Quoted 5 lines

Sure, broken builds on old macOSes are bad. For this case I think it's enough to disable vmnet for macOS < 11.0 with a probe while configure build step. Especially given that Apple supports ~three latest macOS versions, support for Catalina is expected to end in 2022, when QEMU releases 7.0.

That should be fine.

Quoted 8 lines

If this workaround is not suitable and it's required to support vmnet in Catalina 10.15 with a subset of available features, it can be done. But I'll be ready to handle this in approximately two-three weeks only.

Sure, Vladislav please fix this and send a new version.

Quoted 8 lines
Quoted 5 lines
Quoted 2 lines

Quick fix as described above is available in v10:
https://patchew.org/QEMU/[email protected]/

Have you got chance to test that for macOS < 11.0?

Yes, tested on Catalina 10.15.Works as expected.

Cool.

Thanks

Quoted 20 lines
Quoted 20 lines

Thanks

Quoted 13 lines
    Thanks

    >
    > -- PMM
    >

--
Best Regards,

Vladislav Yaroshchuk

author
#21 lore raw
In reply to Roman Bolshakov
Quoted 72 lines · Roman Bolshakov
Quoted 70 lines · Jason Wang
Quoted 66 lines · Vladislav Yaroshchuk

вт, 11 янв. 2022 г., 5:10 AM Jason Wang <[email protected]>:

    On Tue, Jan 11, 2022 at 12:49 AM Peter Maydell
    <[email protected]> wrote:
    >
    > On Mon, 10 Jan 2022 at 03:40, Jason Wang <[email protected]>
    wrote:
    > >
    > > The following changes since commit
    df722e33d5da26ea8604500ca8f509245a0ea524:
    > >
    > >   Merge tag 'bsd-user-arm-pull-request' of
    gitlab.com:bsdimp/qemu into staging (2022-01-08 09:37:59 -0800)
    > >
    > > are available in the git repository at:
    > >
    > > https://github.com/jasowang/qemu.git tags/net-pull-request
    > >
    > > for you to fetch changes up to
    5136cc6d3b8b74f4fa572f0874656947a401330e:
    > >
    > >   net/vmnet: update MAINTAINERS list (2022-01-10 11:30:55 +0800)
    > >
    > > ----------------------------------------------------------------
    > >
    > > ----------------------------------------------------------------
    >
    > Fails to build on OSX Catalina:
    >
    > ../../net/vmnet-common.m:165:10: error: use of undeclared identifier
    > 'VMNET_SHARING_SERVICE_BUSY'
    >     case VMNET_SHARING_SERVICE_BUSY:
    >          ^
    >
    > This constant only got added in macOS 11.0. I guess that technically
    > our supported-platforms policy only requires us to support 11
    (Big Sur)
    > and 12 (Monterey) at this point, but it would be nice to still
    be able
    > to build on Catalina (10.15).

    Yes, it was only supported by the vmnet framework starting from
    Catalyst according to
    https://developer.apple.com/documentation/vmnet?language=objc.

Yes, there are some symbols from macOS >= 11.0 new backend uses, not only this one, ex. vmnet_enable_isolation_key:
https://developer.apple.com/documentation/vmnet/vmnet_enable_isolation_key

Quoted 2 lines

(Personally I would like Catalina still to work at least for a

little
> while, because my x86 Mac is old enough that it is not supported by > Big Sur. I'll have to dump it once Apple stops doing security support
> for Catalina, but they haven't done that quite yet.)

Sure, broken builds on old macOSes are bad. For this case I think it's enough to disable vmnet for macOS < 11.0 with a probe while configure build step. Especially given that Apple supports ~three latest macOS versions, support for Catalina is expected to end in 2022, when QEMU releases 7.0.

Quoted 7 lines
Quoted 2 lines

That should be fine.

I agree with Peter on this,

There's a lot of hardware running with Catalina. I think it's useful to support it a little longer.

Right and Vladislav have disabled vmnet on the old versions.

Thanks

Quoted 38 lines

Regards,
Roman

Quoted 33 lines
Quoted 11 lines

If this workaround is not suitable and it's required to support vmnet in Catalina 10.15 with a subset of available features, it can be done. But I'll be ready to handle this in approximately two-three weeks only.

Sure, Vladislav please fix this and send a new version.

Quick fix as described above is available in v10:
https://patchew.org/QEMU/[email protected]/

Have you got chance to test that for macOS < 11.0?

Thanks

Quoted 13 lines
    Thanks

    >
    > -- PMM
    >

--
Best Regards,

Vladislav Yaroshchuk

#22 lore raw

ср, 12 янв. 2022 г. в 10:51, Jason Wang <[email protected]>:

Quoted 83 lines · Roman Bolshakov
Quoted 20 lines · Jason Wang
Quoted 18 lines · Vladislav Yaroshchuk
Quoted 16 lines

вт, 11 янв. 2022 г., 5:10 AM Jason Wang <[email protected]>:

    On Tue, Jan 11, 2022 at 12:49 AM Peter Maydell
    <[email protected]> wrote:
    >
    > On Mon, 10 Jan 2022 at 03:40, Jason Wang <[email protected]>
    wrote:
    > >
    > > The following changes since commit
    df722e33d5da26ea8604500ca8f509245a0ea524:
    > >
    > >   Merge tag 'bsd-user-arm-pull-request' of
    gitlab.com:bsdimp/qemu into staging (2022-01-08 09:37:59 -0800)
    > >
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 5 lines
Quoted 5 lines

are available in the git repository at:

https://github.com/jasowang/qemu.git tags/net-pull-request

for you to fetch changes up to

    5136cc6d3b8b74f4fa572f0874656947a401330e:
    > >
    > >   net/vmnet: update MAINTAINERS list (2022-01-10 11:30:55

+0800)

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

----------------------------------------------------------------

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

----------------------------------------------------------------

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

Fails to build on OSX Catalina:

../../net/vmnet-common.m:165:10: error: use of undeclared

identifier

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

'VMNET_SHARING_SERVICE_BUSY'

    case VMNET_SHARING_SERVICE_BUSY:
         ^

This constant only got added in macOS 11.0. I guess that

technically

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 1 line

our supported-platforms policy only requires us to support 11

(Big Sur)
> and 12 (Monterey) at this point, but it would be nice to still be able
> to build on Catalina (10.15).

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

Yes, it was only supported by the vmnet framework starting from Catalyst according to
https://developer.apple.com/documentation/vmnet?language=objc.

Yes, there are some symbols from macOS >= 11.0 new backend uses, not only this one, ex. vmnet_enable_isolation_key:

https://developer.apple.com/documentation/vmnet/vmnet_enable_isolation_key

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 3 lines

(Personally I would like Catalina still to work at least for a

little
> while, because my x86 Mac is old enough that it is not

supported by

Quoted 15 lines
Quoted 14 lines
Quoted 10 lines
Quoted 1 line

Big Sur. I'll have to dump it once Apple stops doing security

support
> for Catalina, but they haven't done that quite yet.)

Sure, broken builds on old macOSes are bad. For this case I think it's enough to disable vmnet for macOS < 11.0 with a probe while configure build step. Especially given that Apple supports ~three latest macOS versions, support for Catalina is expected to end in 2022, when QEMU releases 7.0.

That should be fine.

Quoted 10 lines
Quoted 4 lines

I agree with Peter on this,

There's a lot of hardware running with Catalina. I think it's useful to support it a little longer.

Right and Vladislav have disabled vmnet on the old versions.

Thanks

Roman requested vmnet support for Catalina (10.15) also:
https://patchew.org/QEMU/[email protected]/

After some thought I also found it important to support 10.15. I've found a free hour to update patches and submit as v11 (still not displayed on Patchew for some reason).

Tested on Catalina 10.15 and Big Sur 11.5.
Built with no errors under Ubuntu 20.04 5.4.0-94-generic.

Quoted 43 lines
Quoted 8 lines

Regards,
Roman

Quoted 4 lines
Quoted 4 lines

If this workaround is not suitable and it's required to support vmnet in Catalina 10.15 with a subset of available features, it can be

done.

Quoted 1 line
Quoted 1 line
Quoted 1 line

But I'll be ready to handle this in approximately two-three weeks

only.

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

Sure, Vladislav please fix this and send a new version.

Quick fix as described above is available in v10:

https://patchew.org/QEMU/[email protected]/

Quoted 23 lines
Quoted 22 lines

Have you got chance to test that for macOS < 11.0?

Thanks

Quoted 13 lines
    Thanks

    >
    > -- PMM
    >

--
Best Regards,

Vladislav Yaroshchuk

Signature · 3 lines
Best Regards,

Vladislav Yaroshchuk