tart run: resolve VM's IP using ARP when using --net-bridged and --vnc (#811)

This commit is contained in:
Nikolay Edigaryev
2024-05-02 18:04:26 +04:00
committed by GitHub
parent 3ff3850da2
commit 1d01bf63fb
4 changed files with 5 additions and 5 deletions
+1 -1
View File
@@ -290,7 +290,7 @@ struct Run: AsyncParsableCommand {
try await vm!.start(recovery: recovery, resume: resume)
if let vncImpl = vncImpl {
let vncURL = try await vncImpl.waitForURL()
let vncURL = try await vncImpl.waitForURL(netBridged: !netBridged.isEmpty)
if noGraphics || ProcessInfo.processInfo.environment["CI"] != nil {
print("VNC server is running at \(vncURL)")
+1 -1
View File
@@ -15,7 +15,7 @@ class FullFledgedVNC: VNC {
vnc.start()
}
func waitForURL() async throws -> URL {
func waitForURL(netBridged: Bool) async throws -> URL {
while true {
// Port is 0 shortly after start(),
// but will be initialized later
+2 -2
View File
@@ -9,9 +9,9 @@ class ScreenSharingVNC: VNC {
self.vmConfig = vmConfig
}
func waitForURL() async throws -> URL {
func waitForURL(netBridged: Bool) async throws -> URL {
let vmMACAddress = MACAddress(fromString: vmConfig.macAddress.string)!
let ip = try await IP.resolveIP(vmMACAddress, secondsToWait: 60)
let ip = try await IP.resolveIP(vmMACAddress, resolutionStrategy: netBridged ? .arp : .dhcp, secondsToWait: 60)
if let ip = ip {
return URL(string: "vnc://\(ip)")!
+1 -1
View File
@@ -1,6 +1,6 @@
import Foundation
protocol VNC {
func waitForURL() async throws -> URL
func waitForURL(netBridged: Bool) async throws -> URL
func stop() throws
}