Replies: 1 comment
-
|
Fix implemented in #717, will be out in the next beta |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Environment
Problem description
I am experiencing a reproducible bridged-networking problem when running a virtual
machine in VirtualBuddy.
The bridged network works normally when the VM is initially started. The guest obtains
a valid IP address from the LAN DHCP server and can access the local network.
However, if I unplug the host’s physical Ethernet cable, leave it disconnected for some
time, and then reconnect it, the host network recovers but the VM network does not.
The guest can no longer obtain a DHCP lease. Renewing DHCP inside the guest does not
resolve the problem. It eventually assigns itself a link-local address in the following
range:
169.254.240.x
Once this happens, the guest appears unable to recover the previous LAN address, or
obtain any valid DHCP address, even though the host Ethernet connection is working
normally again.
Steps to reproduce
interface.
For a macOS guest, I tried renewing DHCP using the network settings and commands
similar to:
sudo ipconfig set en0 NONE
sudo ipconfig set en0 DHCP
Actual behavior
VZVirtualMachine instance and network attachment.
Expected behavior
After the host Ethernet link becomes active again, VirtualBuddy should reconnect the
bridged network attachment automatically.
The guest should then be able to send DHCP Discover packets to the physical network and
obtain a valid DHCP lease without requiring VirtualBuddy or the VM to be completely
restarted.
Suspected cause
My current hypothesis is that the host-side VZBridgedNetworkDeviceAttachment is
disconnected when the physical Ethernet link goes down and is not recreated after the
link comes back.
Apple’s documentation states that the attachment of a running VZNetworkDevice may
change at any time depending on the host network state:
VZNetworkDevice.attachment
(https://developer.apple.com/documentation/virtualization/vznetworkdevice/attachment)
attachmentWasDisconnectedWithError
(https://developer.apple.com/documentation/virtualization/vzvirtualmachinedelegate/virtualmachine%28_%3Anetworkdevice%3Aattachmentwasdisconnectedwitherror%3A%29)
According to the documentation, when an attachment fails, Virtualization.framework may
set networkDevice.attachment to nil and notify the application through:
virtualMachine(
_:networkDevice:attachmentWasDisconnectedWithError:
)
VirtualBuddy currently implements this delegate method, but its body is empty:
public nonisolated func virtualMachine(
_ virtualMachine: VZVirtualMachine,
networkDevice: VZNetworkDevice,
attachmentWasDisconnectedWithError error: Error
) {
}
Source:
VMInstance.swift, lines 508–510
(
VirtualBuddy/VirtualCore/Source/Virtualization/VMInstance.swift
Lines 508 to 510 in 943b3c0
If the cable disconnection causes this callback to be invoked, the network attachment
may remain nil because VirtualBuddy does not currently log the error or attempt to
reconnect it.
This would explain why DHCP renewal inside the guest cannot work: the guest network
interface still exists, but DHCP broadcasts can no longer reach the host’s physical
network.
Additional observation about “Automatic” bridging
VirtualBuddy appears to resolve the “Automatic” bridge interface only when creating the
VM configuration. It selects the first available bridged interface:
guard identifier != VBNetworkDeviceInterface.automatic.id else {
return try VZBridgedNetworkInterface.networkInterfaces.first.require(...)
}
Source:
VirtualMachineConfigurationHelper.swift, lines 140–159
(
VirtualBuddy/VirtualCore/Source/Virtualization/Helpers/VirtualMachineConfigurationHelper.swift
Lines 140 to 159 in 943b3c0
This does not appear to provide dynamic failover or re-evaluation when the physical
network changes. For example, if Ethernet goes down and Wi-Fi becomes the default
route, the existing bridge attachment may remain associated with the unavailable
Ethernet interface.
Possible ways to confirm the cause
DHCP and ARP traffic can be captured simultaneously in the guest and on the host.
Inside the guest:
sudo tcpdump -eni en0 '(udp port 67 or 68) or arp'
On the host’s physical Ethernet interface:
sudo tcpdump -eni enX '(udp port 67 or 68) or arp'
Possible interpretations:
DHCP Discover is visible in the guest but not on the host Ethernet interface: the
VirtualBuddy/Virtualization.framework bridge attachment is probably disconnected.
DHCP Discover reaches the host interface, but no DHCP Offer is returned: the problem
may be in the router, switch, DHCP server, port security, DHCP snooping, or MAC-
address policy.
The host receives a DHCP Offer, but the guest does not: the return path through the
bridge or a host network filter may be broken.
No DHCP Discover is generated inside the guest: the problem is more likely in the
guest network service or virtual NIC state.
It may also help if VirtualBuddy logs the attachmentWasDisconnectedWithError error and
the value of networkDevice.attachment before and after the physical link interruption.
Suggested workarounds
The following workarounds may help:
created.
Possible application-level fix
A possible VirtualBuddy fix would be to:
Conceptually:
let interfaces = VZBridgedNetworkInterface.networkInterfaces
guard let interface = interfaces.first(where: {
$0.identifier == configuredInterfaceIdentifier
}) else {
// Wait for the interface to become available and retry.
return
}
let newAttachment = VZBridgedNetworkDeviceAttachment(
interface: interface
)
networkDevice.attachment = newAttachment
The reconnection should use a newly resolved interface object instead of reusing the
attachment or interface object that existed before the physical link went down.
Could you confirm whether this behavior is expected from Virtualization.framework, and
whether VirtualBuddy is expected to recreate the bridge attachment after receiving
attachmentWasDisconnectedWithError?
Beta Was this translation helpful? Give feedback.
All reactions