@@ -21,12 +21,28 @@
static bool validate_options(const Netdev *netdev, Error **errp)
{
const NetdevVmnetHostOptions *options = &(netdev->u.vmnet_host);
- QemuUUID net_uuid;
- if (options->net_uuid &&
- qemu_uuid_parse(options->net_uuid, &net_uuid) < 0) {
- error_setg(errp, "Invalid UUID provided in 'net-uuid'");
- return false;
+ if (__builtin_available(macOS 11, *)) {
+ QemuUUID net_uuid;
+ if (options->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->net_uuid) {
+ error_setg(errp,
+ "vmnet-host.net-uuid feature is "
+ "unavailable: outdated vmnet.framework API");
+ return false;
+ }
}
if ((options->start_address ||
@@ -53,16 +69,18 @@ static xpc_object_t build_if_desc(const Netdev *netdev)
vmnet_operation_mode_key,
VMNET_HOST_MODE);
- xpc_dictionary_set_bool(if_desc,
- vmnet_enable_isolation_key,
- options->isolated);
-
- QemuUUID net_uuid;
- if (options->net_uuid) {
- qemu_uuid_parse(options->net_uuid, &net_uuid);
- xpc_dictionary_set_uuid(if_desc,
- vmnet_network_identifier_key,
- net_uuid.data);
+ if (__builtin_available(macOS 11, *)) {
+ xpc_dictionary_set_bool(if_desc,
+ vmnet_enable_isolation_key,
+ options->isolated);
+
+ QemuUUID net_uuid;
+ if (options->net_uuid) {
+ qemu_uuid_parse(options->net_uuid, &net_uuid);
+ xpc_dictionary_set_uuid(if_desc,
+ vmnet_network_identifier_key,
+ net_uuid.data);
+ }
}
if (options->start_address) {
@@ -21,6 +21,17 @@ static bool validate_options(const Netdev *netdev, Error **errp)
{
const NetdevVmnetSharedOptions *options = &(netdev->u.vmnet_shared);
+ if (__builtin_available(macOS 11, *)) {
+ /* clang requires a true branch */
+ } else {
+ if (options->has_isolated) {
+ error_setg(errp,
+ "vmnet-shared.isolated feature is "
+ "unavailable: outdated vmnet.framework API");
+ return false;
+ }
+ }
+
if ((options->start_address ||
options->end_address ||
options->subnet_mask) &&
@@ -66,11 +77,13 @@ static xpc_object_t build_if_desc(const Netdev *netdev)
options->subnet_mask);
}
- xpc_dictionary_set_bool(
- if_desc,
- vmnet_enable_isolation_key,
- options->isolated
- );
+ if (__builtin_available(macOS 11, *)) {
+ xpc_dictionary_set_bool(
+ if_desc,
+ vmnet_enable_isolation_key,
+ options->isolated
+ );
+ }
return if_desc;
}
@@ -88,6 +88,16 @@ static bool validate_options(const Netdev *netdev, Error **errp)
return false;
}
+ if (__builtin_available(macOS 11, *)) {
+ /* clang requires a true branch */
+ } else {
+ if (options->has_isolated) {
+ error_setg(errp,
+ "vmnet-bridged.isolated feature is "
+ "unavailable: outdated vmnet.framework API");
+ return false;
+ }
+ }
return true;
}
@@ -106,9 +116,11 @@ static xpc_object_t build_if_desc(const Netdev *netdev)
vmnet_shared_interface_name_key,
options->ifname);
- xpc_dictionary_set_bool(if_desc,
- vmnet_enable_isolation_key,
- options->isolated);
+ if (__builtin_available(macOS 11, *)) {
+ xpc_dictionary_set_bool(if_desc,
+ vmnet_enable_isolation_key,
+ options->isolated);
+ }
return if_desc;
}
Some options require macOS 11 or newer APIs. Instead of crashing (target version not set) or failing to compile (target version set), we will just return an error when the user tries to use the option. Signed-off-by: Joelle van Dyne <j@getutm.app> --- net/vmnet-host.c | 48 +++++++++++++++++++++++++++++++-------------- net/vmnet-shared.c | 23 +++++++++++++++++----- net/vmnet-bridged.m | 18 ++++++++++++++--- 3 files changed, 66 insertions(+), 23 deletions(-)