Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

timesync: Fix automatic vsock device creation #191

Merged
merged 1 commit into from
Sep 24, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions pkg/vf/vm.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,17 @@ func (cfg *VirtualMachineConfiguration) toVz() (*vz.VirtualMachineConfiguration,
return nil, err
}
}
if cfg.config.Timesync != nil && cfg.config.Timesync.VsockPort != 0 {
// automatically add the vsock device we'll need for communication over VsockPort
vsockDev := VirtioVsock{
Port: cfg.config.Timesync.VsockPort,
Listen: false,
}
anjannath marked this conversation as resolved.
Show resolved Hide resolved
if err := vsockDev.AddToVirtualMachineConfig(cfg); err != nil {
return nil, err
}
}

cfg.SetStorageDevicesVirtualMachineConfiguration(cfg.storageDevicesConfiguration)
cfg.SetDirectorySharingDevicesVirtualMachineConfiguration(cfg.directorySharingDevicesConfiguration)
cfg.SetPointingDevicesVirtualMachineConfiguration(cfg.pointingDevicesConfiguration)
Expand All @@ -115,17 +126,6 @@ func (cfg *VirtualMachineConfiguration) toVz() (*vz.VirtualMachineConfiguration,
// https://developer.apple.com/documentation/virtualization/vzvirtiosocketdeviceconfiguration?language=objc
cfg.SetSocketDevicesVirtualMachineConfiguration(cfg.socketDevicesConfiguration)

if cfg.config.Timesync != nil && cfg.config.Timesync.VsockPort != 0 {
// automatically add the vsock device we'll need for communication over VsockPort
vsockDev := VirtioVsock{
Port: cfg.config.Timesync.VsockPort,
Listen: false,
}
if err := vsockDev.AddToVirtualMachineConfig(cfg); err != nil {
return nil, err
}
}

valid, err := cfg.Validate()
if err != nil {
return nil, err
Expand Down