Skip to content

Commit db63999

Browse files
cfergeaupraveenkumar
authored andcommitted
vfkit: Enable timesync
On macOS, after a host suspend, the guest clock will be out of sync. vfkit has a --timesync feature, which resyncs the guest clock when the host comes out of sleep. This commit makes use of it.
1 parent a3aca7b commit db63999

3 files changed

Lines changed: 18 additions & 0 deletions

File tree

pkg/crc/constants/constants_darwin.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ const (
1111
PodmanRemoteExecutableName = "podman"
1212
TrayExecutableName = "Red Hat OpenShift Local.app"
1313
DaemonAgentLabel = "com.redhat.crc.daemon"
14+
QemuGuestAgentPort = 1234
1415
)
1516

1617
var (

pkg/crc/machine/vfkit/driver_darwin.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ func CreateHost(machineConfig config.MachineConfig) *vfkit.Driver {
2626
vfDriver.VsockPath = constants.TapSocketPath
2727
vfDriver.DaemonVsockPort = constants.DaemonVsockPort
2828

29+
vfDriver.QemuGAVsockPort = constants.QemuGuestAgentPort
30+
2931
vfDriver.SharedDirs = configureShareDirs(machineConfig)
3032

3133
return vfDriver

pkg/drivers/vfkit/driver_darwin.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ type Driver struct {
5050

5151
VsockPath string
5252
DaemonVsockPort uint
53+
QemuGAVsockPort uint
5354
}
5455

5556
func NewDriver(hostName, storePath string) *Driver {
@@ -255,6 +256,20 @@ func (d *Driver) Start() error {
255256
return err
256257
}
257258

259+
// when loading a VM created by a crc version predating this commit,
260+
// d.QemuGAVsockPort will be missing from ~/.crc/machines/crc/config.json
261+
// In such a case, assume the VM will not support time sync
262+
if d.QemuGAVsockPort != 0 {
263+
timesync, err := client.TimeSyncNew(d.QemuGAVsockPort)
264+
if err != nil {
265+
return err
266+
}
267+
err = vm.AddDevice(timesync)
268+
if err != nil {
269+
return err
270+
}
271+
}
272+
258273
args, err := vm.ToCmdLine()
259274
if err != nil {
260275
return err

0 commit comments

Comments
 (0)