VMware Communities
Uli_Zappe
Contributor
Contributor

System clock of guest OS deviates after suspension or sleep

Hi all,

whenever I suspend my virtual machine or put my Mac to sleep, the system clock of my virtual machine "stands still", i.e. after coming to life again, the clock continues from where it was before the sleep/suspension, not taking into account the time in between.

Now, the guest OS I'm using is OPENSTEP which is unsupported. Do other people experience the same issue with supported guest OSes?

If not, what is the mechanism that takes care of the correct clock? Is some information sent to one of the VM tools for the guest OS, or how is the correct time taken care of?

Thanks for any insight!

0 Kudos
16 Replies
admin
Immortal
Immortal

Not having played around with this, this is the behavior I'd expect from a VM without tools. The guest should have no knowledge of being suspended, it has to be told by an outside source that time has passed - e.g. NTP or VMware Tools.

http://www.vmware.com/pdf/vmware_timekeeping.pdf

0 Kudos
admin
Immortal
Immortal

OK, having re-read the white paper, from page 14 (emphasis mine):

It is normal for a guest's clock to be behind real time[/i] whenever the virtual machine is stopped for a while and then continues running; in particular, after a suspend/resume[/i], snapshot, disk shrink, or VMotion operation. These are the main cases that VMware Tools time synchronization is meant to handle.

Uli_Zappe
Contributor
Contributor

It is normal for a guest's clock to be behind real

time[/i] whenever the virtual machine is stopped for

a while and then continues running; in particular,

after a suspend/resume[/i], snapshot, disk shrink,

or VMotion operation. These are the main cases that

VMware Tools time synchronization is meant to handle.

Ah, I see. Thanks for pointing me to that doc!

Now, the obvious question is if there is some sample code available for the time synchronization tool (preferably for Linux/Unix), as it seems that I'll have to port this to OPENSTEP.

Generally speaking, does someone know how the virtual machine communicates with the VMware tools (which, as I understand it, are programs running inside[/i] the guest OS)? Is it via TCP/IP, or how does this work?

0 Kudos
admin
Immortal
Immortal

You're right - VMware tools are programs running inside the guest and tell the guest about the virtualized environment in various ways. For example, the VGA driver tells the guest when the window has been resized so the guest can change resolution.

Someone posted some reverse-engineering of how this works, I don't know if there's an official API. You might try VMware's Community Source.

http://chitchat.at.infoseek.co.jp/vmware/backdoor.html

(Edited for grammar)

0 Kudos
rcardona2k
Immortal
Immortal

Ah the wonder works of Ken Kato. Smiley Happy

You may want to look at building the VMware Tools, particularly from the FreeBSD distribution-- given it's heritage ties to OpenStep/Darwin. I think you'll have much better luck than investigating undocumented APIs.

0 Kudos
Uli_Zappe
Contributor
Contributor

Someone posted some reverse-engineering of how this works,

Ah, very interesting link - thanks! Looks like heavy stuff, though, and not easy to port. I'll have a look, in any case.

What I find interesting is that from the description of the (reverse engineered) API, it's always the client side/the tools that initiate communication. Obviously, the optimal solution for my problem would be for the virtual machine[/i] to send information to the client side/the tools that the client just woke up from sleep/suspension and therefore needs time synchronisation, because otherwise you end up polling for the correct time in unnecessarily short intervals. Interestingly, this actually seems to be what the VMware tools do with respect to time synchronisation, as the VMware PDF you pointed me to says on page 14:

"The VMware Tools time synchronization daemon is quite simple and has a few limitations. The daemon checks the guest clock only once per minute[/b]." \[emphasis is mine]

The only contradicting information is that you said that "the VGA driver tells the guest when the window has been resized" which suggests that communication can be initiated by the host side, too.

I don't know if there's an official API.

Judging from my short googling, it seems there isn't. Smiley Sad I find this hard to understand - wouldn't it be in VMware's best interest to encourage the creation of tools for as many OSes as possible?

You might try VMware's Community Source.

I'm afraid that being just an individual, they won't let me in ... Smiley Sad

0 Kudos
Uli_Zappe
Contributor
Contributor

You may want to look at building the VMware Tools,

particularly from the FreeBSD distribution-- given

it's heritage ties to OpenStep/Darwin.

Do you speak of the code that etung linked to, or is there an "official" source distribution of the VMware Tools for FreeBSD (which would indeed most probably compile successfully on Mac OS X, but I'm not so sure about OPENSTEP which forked from an earlier BSD version)???

I think you'll have much better luck than investigating

undocumented APIs.

Certainly.

0 Kudos
admin
Immortal
Immortal

I don't have any special insight as to how the tools work, it could be 100% guest-initiated for all I know. However, resizing feels responsive, and having the guest poll for something as infrequent as resizing seems silly. The paper might be out of date, note the copyright at the end is 1998-2005. Sorry for not realizing CS was for businesses only, I heard of it but didn't know the details.

rcardona2k might be talking about simply looking at the source included with the freebsd (or linux) tools - a quick glance shows some in vmware-tools-distrib/lib/modules/source. No idea if this is actually useful or if it's what he's talking about.

0 Kudos
Uli_Zappe
Contributor
Contributor

rcardona2k might be talking about simply looking at

the source included with the freebsd (or linux) tools

- a quick glance shows some in

vmware-tools-distrib/lib/modules/source.

Sorry, I'm not sure what you are referring to. What path are you talking about here? Do you have a complete URL?

0 Kudos
rcardona2k
Immortal
Immortal

>> rcardona2k might be talking about simply looking at the source included with the freebsd (or linux) tools

>> - a quick glance shows some in vmware-tools-distrib/lib/modules/source.

>Sorry, I'm not sure what you are referring to. What path are you talking about here? Do you have a complete URL?

Yes, this is what i'm talking about. No URL necessary, it's right in your copy of Fusion, in the vmware-freebsd-tools.tar.gz tarball at /Library/Application\ Support/VMware\ Fusion/isoimages/freebsd.iso

Uli_Zappe
Contributor
Contributor

Yes, this is what i'm talking about. No URL

necessary, it's right in your copy of Fusion, in the

vmware-freebsd-tools.tar.gz tarball at

/Library/Application\ Support/VMware\

Fusion/isoimages/freebsd.iso

Ah, thanks a lot! I'll have a look at it.

0 Kudos
Uli_Zappe
Contributor
Contributor

I now had a look, and unfortunately, all the relevant tools are binary only, no source. Smiley Sad

The docs make clear, however, that this would do what I'd need:

"The VMware Tools Service performs various duties within the guest operating system, such as:

Passing messages from the host operating system or ESX Server to the guest operating system."

God only knows why VMware does not open the source for these tools. It would only help them sell more virtual machines. Oh well ... Smiley Sad

0 Kudos
rcardona2k
Immortal
Immortal

>I now had a look, and unfortunately, all the relevant tools are binary only, no source.

There are some driver sources but I agree probably not what you're looking folder, e.g.

FreeBSD:

tar tvfz vmware-freebsd-tools.tar.gz |grep source

-rrr-- root/root 40960 2006-12-15 02:46:13 vmware-tools-distrib/lib/modules/source/vmmemctl.tar

Linux:

tar tvfz VMwareTools-e.x.p-36674.tar.gz | grep source

-rrr-- root/root 194560 2006-12-15 02:23:15 vmware-tools-distrib/lib/modules/source/vmblock.tar

-rrr-- root/root 81920 2006-12-15 02:23:25 vmware-tools-distrib/lib/modules/source/vmmemctl.tar

-rrr-- root/root 92160 2006-12-15 02:23:40 vmware-tools-distrib/lib/modules/source/vmdesched.tar

-rrr-- root/root 245760 2006-12-15 02:23:44 vmware-tools-distrib/lib/modules/source/vmxnet.tar

-rrr-- root/root 409600 2006-12-15 02:23:54 vmware-tools-distrib/lib/modules/source/crosstalk.tar

-rrr-- root/root 634880 2006-12-15 02:24:01 vmware-tools-distrib/lib/modules/source/vmhgfs.tar

Some of these modules are recognizable: vmxnet is the accelerated network driver, vmhfgs are shared folders support. I'm not sure what the others are. If anything, the include files (.h's) in these files may be interesting.

0 Kudos
Uli_Zappe
Contributor
Contributor

I now had a look, and unfortunately, all the

relevant tools are binary only, no source.

There are some driver sources but I agree probably

not what you're looking folder

Yep, that's what I meant with "not relevant" ... Smiley Wink

FreeBSD:

Linux:

Ah, so there's a lot more Linux sources! I'll have another look, though I doubt it will be successful ...

0 Kudos
Uli_Zappe
Contributor
Contributor

OK, so if any, then the code in vmhgfs-only is the relevant one:

/*

  • backdoor.c --

*

  • First layer of the internal communication channel between guest

  • applications and vmware

*

  • This is the backdoor. By using special ports of the virtual I/O space,

  • and the virtual CPU registers, a guest application can send a

  • synchroneous basic request to vmware, and vmware can reply to it.

*/[/code]

Unfortunately, the guest->host direction seems to be better documented and easier to realize than the host->guest direction I'd need.

And even if it were documented as well, these are only library modules in a larger context that isn't documented, and then there's Linux kernel code involved. So porting that kind of code, if possible at all with the information provided, would certainly not be a weekend project ... Smiley Sad

0 Kudos
Uli_Zappe
Contributor
Contributor

After looking further at what little code is available, I don't think it makes much sense to try and port this proprietary code to OPENSTEP myself. Without proper documentation and an official API, there's no guarantee things won't break with the next update of Fusion, and if possible at all, the port would be quite a lot of effort.

Additionally, so far I don't even know if Fusion will inform the guest OS when the Mac[/i] awoke from sleep (it should because of the system clock issue, but I don't know if it actually does).

So, I've decided to go an open and transparent route via a network connection. I will only be able to implement this once bridged networking between the guest OS and the host works, but it should be comparatively easy to implement in the following way:

In OPENSTEP, there will be a small daemon that listens to a network port and performs an "rdate " command if told via that port. In Mac OS X, a corresponding signal is sent to this port from two programs:

1. a small daemon running on Mac OS X and sending the signal each times Mac OS X awakes from sleep (something it can learn from the event loop)

2. A launchctl.plist entry that watches the Fusion virtual machine log and config files for changes that indicate a return from suspension

This should do what I need in a completely transparent, non-proprietary manner.

Still, I really feel that VMware should make the tools API public.

0 Kudos