All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] net/vmnet: Add host address options for vmnet-host
@ 2026-09-27 11:04 Tim Pambor
  2026-09-28 12:44 ` Markus Armbruster
  0 siblings, 1 reply; 2+ messages in thread
From: Tim Pambor @ 2026-09-27 11:04 UTC (permalink / raw)
  To: qemu-devel; +Cc: Jason Wang, Eric Blake, Markus Armbruster, Tim Pambor

When a vmnet-host interface is added to an isolated network via
'net-uuid', vmnet does not provide DHCP and the host side of the
bridge gets no address, so the host cannot talk to guests on that
network without manually assigning an IP address to the bridge
interface after QEMU has started.

vmnet provides the vmnet_host_ip_address_key,
vmnet_host_subnet_mask_key and vmnet_host_ipv6_address_key
properties to assign addresses to the host interface in this case.
Expose them as the 'host-ip-address', 'host-subnet-mask' and
'host-ipv6-address' options of the vmnet-host backend.

Signed-off-by: Tim Pambor <timpambor@gmail.com>
---
 net/vmnet-host.c | 35 +++++++++++++++++++++++++++++++++++
 qapi/net.json    | 15 ++++++++++++++-
 qemu-options.hx  |  6 +++++-
 3 files changed, 54 insertions(+), 2 deletions(-)

diff --git a/net/vmnet-host.c b/net/vmnet-host.c
index 49fb25c224..8ed7ee9d41 100644
--- a/net/vmnet-host.c
+++ b/net/vmnet-host.c
@@ -41,6 +41,26 @@ static bool validate_options(const Netdev *netdev, Error **errp)
         return false;
     }
 
+    if ((options->host_ip_address || options->host_subnet_mask) &&
+        !(options->host_ip_address && options->host_subnet_mask)) {
+        error_setg(errp,
+                   "'host-ip-address' and 'host-subnet-mask' "
+                   "should be provided together");
+        return false;
+    }
+
+    if (options->host_ip_address && !options->net_uuid) {
+        error_setg(errp,
+                   "'host-ip-address' requires 'net-uuid' to be specified");
+        return false;
+    }
+
+    if (options->host_ipv6_address && !options->net_uuid) {
+        error_setg(errp,
+                   "'host-ipv6-address' requires 'net-uuid' to be specified");
+        return false;
+    }
+
     return true;
 }
 
@@ -77,6 +97,21 @@ static xpc_object_t build_if_desc(const Netdev *netdev)
                                   options->subnet_mask);
     }
 
+    if (options->host_ip_address) {
+        xpc_dictionary_set_string(if_desc,
+                                  vmnet_host_ip_address_key,
+                                  options->host_ip_address);
+        xpc_dictionary_set_string(if_desc,
+                                  vmnet_host_subnet_mask_key,
+                                  options->host_subnet_mask);
+    }
+
+    if (options->host_ipv6_address) {
+        xpc_dictionary_set_string(if_desc,
+                                  vmnet_host_ipv6_address_key,
+                                  options->host_ipv6_address);
+    }
+
     return if_desc;
 }
 
diff --git a/qapi/net.json b/qapi/net.json
index b46af1fdc9..38b43d20ed 100644
--- a/qapi/net.json
+++ b/qapi/net.json
@@ -795,6 +795,16 @@
 #     is allowed only with other interfaces added to this network
 #     identified by the UUID.  Requires at least macOS Big Sur 11.0.
 #
+# @host-ip-address: The IPv4 address to set on the host side of the
+#     interface.  Only applicable when @net-uuid is also specified.
+#     Must be specified along with @host-subnet-mask.
+#
+# @host-subnet-mask: The IPv4 subnet mask to set on the host side of
+#     the interface.  Must be specified along with @host-ip-address.
+#
+# @host-ipv6-address: The IPv6 address to set on the host side of the
+#     interface.  Only applicable when @net-uuid is also specified.
+#
 # Since: 7.1
 ##
 { 'struct': 'NetdevVmnetHostOptions',
@@ -803,7 +813,10 @@
     '*end-address':   'str',
     '*subnet-mask':   'str',
     '*isolated':      'bool',
-    '*net-uuid':      'str' },
+    '*net-uuid':      'str',
+    '*host-ip-address': 'str',
+    '*host-subnet-mask': 'str',
+    '*host-ipv6-address': 'str' },
   'if': 'CONFIG_VMNET' }
 
 ##
diff --git a/qemu-options.hx b/qemu-options.hx
index 2f6863180b..9e250ad196 100644
--- a/qemu-options.hx
+++ b/qemu-options.hx
@@ -3137,11 +3137,15 @@ DEF("netdev", HAS_ARG, QEMU_OPTION_netdev,
 #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"
+    "         [,host-ip-address=addr,host-subnet-mask=mask][,host-ipv6-address=addr]\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"
+    "                vmnet-host interfaces within this isolated network,\n"
+    "                set the host-side IPv4 address and subnet mask on an\n"
+    "                isolated network with 'host-ip-address' and 'host-subnet-mask',\n"
+    "                set the host-side IPv6 address with 'host-ipv6-address'\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"

---
base-commit: efa3b9d5ac8024078225e1ab434411fdfe53b457
change-id: 20260927-vmnet-host-address-47ff5d9adcbb

Best regards,
--  
Tim Pambor <timpambor@gmail.com>



^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-09-28 12:44 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-27 11:04 [PATCH] net/vmnet: Add host address options for vmnet-host Tim Pambor
2026-09-28 12:44 ` Markus Armbruster

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.