-
Notifications
You must be signed in to change notification settings - Fork 585
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
Run qemu-guest-agent to keep time in sync with host? #355
Comments
I would like to be be able to do this so shutdowns are communicated properly and various stats are provided. I've had success installing the qemu-guest-agent in a k3os image running on proxmox, by adding this to the cloud-config file.
I am not sure how lima is communicating with qemu but if the device port path is known I can try it out. |
Im putting a little time towards trying some things with QEMU, I will update the thread if I figure anything out! |
@AkihiroSuda - I looked into this and noticed a few things:
I'm happy to implement support for setting the clock but am not sure what the best way to go about it is within the design of this project. Should we implement settimeofday in the lima guest agent with a signal from the host agent? -- this removes the need for Alternatively, we can enable the qemu-guest-agent: diff --git a/pkg/qemu/qemu.go b/pkg/qemu/qemu.go
index 71d633b..03a9c7f 100644
--- a/pkg/qemu/qemu.go
+++ b/pkg/qemu/qemu.go
@@ -345,6 +345,17 @@ func Cmdline(cfg Config) (string, []string, error) {
args = append(args, "-chardev", fmt.Sprintf("socket,id=%s,path=%s,server=on,wait=off,logfile=%s", serialChardev, serialSock, serialLog))
args = append(args, "-serial", "chardev:"+serialChardev)
+ // QEMU Guest Agent
+ qgaSock := filepath.Join(cfg.InstanceDir, filenames.QemuGuestAgentSock)
+ if err := os.RemoveAll(qgaSock); err != nil {
+ return "", nil, err
+ }
+
+ const qgaChardev = "char-qga"
+ args = append(args, "-chardev", fmt.Sprintf("socket,id=%s,path=%s,server=on,wait=off", qgaChardev, qgaSock))
+ args = append(args, "-device", "virtio-serial")
+ args = append(args, "-device", fmt.Sprintf("virtserialport,chardev=%s,name=org.qemu.guest_agent.0", qgaChardev))
+
// We also want to enable vsock and virtfs here, but QEMU does not support vsock and virtfs for macOS hosts
// QMP
diff --git a/pkg/store/filenames/filenames.go b/pkg/store/filenames/filenames.go
index 358b6ac..ca26b5f 100644
--- a/pkg/store/filenames/filenames.go
+++ b/pkg/store/filenames/filenames.go
@@ -33,6 +33,7 @@ const (
SerialSock = "serial.sock"
SSHSock = "ssh.sock"
GuestAgentSock = "ga.sock"
+ QemuGuestAgentSock = "qga.sock"
HostAgentPID = "ha.pid"
HostAgentSock = "ha.sock"
HostAgentStdoutLog = "ha.stdout.log" This enables us to use the existing guest-set-time command, but we still need some mechanism to detect resumes and invoke said command from the host agent. I tried using timesyncd, but if the drift is too long, the clock is (seemingly) never corrected. Happy to go down either path -- just looking for some guidance on your preference for implementation. Thank you! |
SGTM, thanks |
Looks like this got closed with #490 |
Hello @jandubois, On a second thought, current mechanism, even if we set delta to 1 sec, still has precision of 1 sec. Would it make sense to modify the logic to use millisecond precision when syncing time? |
Seems like it is not working for me: #1307 |
There has been a question about containers falling behind in time when the host has been suspended: rancher-sandbox/rancher-desktop#836
I believe this would be fixed by installing the
qemu-guest-agent
, but haven't tested it (because I'm not sure how to set it up, but I've only looked at Alpine so far).The text was updated successfully, but these errors were encountered: