Skip to content
This repository was archived by the owner on May 12, 2021. It is now read-only.

kernel: enable RTC on x86_64#260

Closed
bergwolf wants to merge 1 commit into
kata-containers:masterfrom
bergwolf:x86_rtc
Closed

kernel: enable RTC on x86_64#260
bergwolf wants to merge 1 commit into
kata-containers:masterfrom
bergwolf:x86_rtc

Conversation

@bergwolf
Copy link
Copy Markdown
Member

It is already enabled on ARM and powerpc. We should provide RTC
so that guest can access the hw clock.

Fixes: #259

Signed-off-by: Peng Tao bergwolf@gmail.com

bergwolf added a commit to bergwolf/kata-agent that referenced this pull request Nov 29, 2018
The two might differ due to vm templating. We need to fix the
drift by setting system clock from hardware clock since kvmclock
should be trusted.

Depends-on: github.com/kata-containers/packaging#260
Fixes: kata-containers#422

Signed-off-by: Peng Tao <bergwolf@gmail.com>
Copy link
Copy Markdown
Contributor

@grahamwhaley grahamwhaley left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@grahamwhaley
Copy link
Copy Markdown
Contributor

out of interest, I'm going to ask the NEMU folks what they do here, if anything, just in case there is an alternative route to the same end :-)
/cc @sameo @rbradford

@grahamwhaley
Copy link
Copy Markdown
Contributor

/test

Comment thread kernel/configs/x86_64_kata_kvm_4.14.x Outdated
# CONFIG_CPU_SUP_AMD is not set
# CONFIG_CPU_SUP_CENTAUR is not set
CONFIG_HPET_TIMER=y
CONFIG_HPET_EMULATE_RTC=y
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this one needed? Are we expecting the kernel to emulate an RTC based on HPET?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It comes when I selected CONFIG_RTC_CLASS. Looking closer, CONFIG_RTC_DRV_CMOS and HPET_TIMER automatically enables this feature.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm concerned that having those enabled might fail the kernel from booting properly if they do expect HPET or CMOS to be emulated, which is not the case for NEMU.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm, I think you are right. We don't need CONFIG_RTC_DRV_CMOS, nor CONFIG_RTC_NVMEM. I've dropped both of them from the patch.

bergwolf added a commit to bergwolf/kata-agent that referenced this pull request Nov 29, 2018
The two might differ due to vm templating. We need to fix the
drift by setting system clock from hardware clock since kvmclock
should be trusted.

Depends-on: github.com/kata-containers/packaging#260
Depends-on: github.com/kata-containers/osbuilder#213
Fixes: kata-containers#422

Signed-off-by: Peng Tao <bergwolf@gmail.com>
It is already enabled on ARM and powerpc. We should provide RTC
so that guest can access the hw clock.

Fixes: kata-containers#259

Signed-off-by: Peng Tao <bergwolf@gmail.com>
@rbradford
Copy link
Copy Markdown

We have no emulated RTC on the NEMU virt platform so this won't work (and it's pretty inaccurate as the RTC is only really accurate to the second.)

The correct solution it to use PTP between the guest and host. Here is the RHEL bug about this feature: https://bugzilla.redhat.com/show_bug.cgi?id=1379822 which explains a lot more details and how to synchronise the guest real world time to the host.

@bergwolf
Copy link
Copy Markdown
Member Author

@rbradford Is PTP_1588_CLOCK_KVM available on other platforms? I see it depends on x86 so it cannot work for other platforms (ARM, powerpc etc) we support in Kata Containers right now.

OTOH, I do agree it is a better solution than RTC. But do you mean NUMU has dropped RTC completely? Is there plan for NUME to support other platforms?

@rbradford
Copy link
Copy Markdown

@bergwolf NEMU aims to have no emulated hardware, including the RTC. NEMU does support aarch64 although I believe that is not currently enabled with Kata.

If you don't want to use PTP a simpler solution might be just to send the host time from the host to the guest via the agent. That will give you similar accuracy as the RTC.

@bergwolf
Copy link
Copy Markdown
Member Author

@rbradford PTP_1588_CLOCK_KVM is not available on NEMU with aarch64, right? Or is there a equivalent one?

Another problem with ptp_kvm is that it needs user space daemons to work with (ntpd, chrony etc.) and that is not available with initrd where vm templating relies on. And the clock sync is mainly required by vm templating.

@jodh-intel
Copy link
Copy Markdown

Ping @bergwolf and @rbradford.

Also, cc @alicefr in case os390 also needs to be updated for this.

@rbradford
Copy link
Copy Markdown

I think the best solution is to send the time from the host to the agent and have the agent set the time. This would then not require any kernel changes / would work on all architectures.

@jodh-intel
Copy link
Copy Markdown

That's a great idea - gRPC it! ;)

@jodh-intel
Copy link
Copy Markdown

although we'd need something to adjust the time for the wire delay I guess.

@rbradford
Copy link
Copy Markdown

@jodh-intel the PC RTC only has an accuracy to the second so I don't think you should put too much effort into time adjustment.

@bergwolf
Copy link
Copy Markdown
Member Author

bergwolf commented Dec 4, 2018

Let's pursue grpc based solution. See kata-containers/agent#425

@bergwolf bergwolf closed this Dec 4, 2018
jcvenegas pushed a commit that referenced this pull request Jul 2, 2019
builder: Pass the DEBUG flag when using docker
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants