Unregister legacy backdoor in X11 UI class destructor.
The legacy backdoor copy paste (used by ESX) is registered in
an Init function of the X11 UI class. We should only unregister
the legacy copy paste when this class is destructed.
Up to now, were were doing it as a side effect of resetting
dndcp version 3 and higher in response to a reset signal from
the plugin framework. This would cause the backdoor copypaste
code to unregister at reset without being registered once again
because the registration only happened in Init.
Recent code changes to allow hgfs to function over
multiple transport (backdoor, vmci) introduced some asserts
and channel switching logic which was broken.
When Shared folders are disabled there are no channels
present and this lead to few problems:
a) Each channel has allocator functions that allocates memory
in the form it requires. When there are no channels - it panics. Bad.
b) Earlier when channel connection failed we would try to re-establish
connection in send. We can't do that now since each send relies on its
allocator functions to do the right thing.
c) Don't bail out when you do not find any channel, since user can enable
shared folder any point in time and expects it to work.
MS does not like us distribute their KB code in our open source
products so fiolter it out before packaging - we do not ship
Win32 in open-vm-tools anyway.
Payload size must be at least siZeof HgfsReply.
HgfsServer returns payload size 0 on error for obsolete HGFS versions.
Fixing to return at least header size.
Only enter gtk_main_iteration when Tools app main loop is active.
If vmtoolsd mainloop is, or becomes, inactive, we need to stop issuing
pointer grab clipboard checks. It was advised the way to do this was
to look at the main loop field of the tools app context and see if it
is active, and only enter gtk_main_iteration() if so.
VMware, Inc [Tue, 24 Aug 2010 18:46:07 +0000 (11:46 -0700)]
Check for return value from VMCIMemcpy in Enqueue/Dequeue.
The EnqueueLocked() and DequeueLocked() functions were not checking for the
return code from the platform specific VMCIMemcpy funtions. Because of the
they were returning success, despite the mem copy failing.
Fix: Check for the return value of VMCIMemcpy funtions and update the
produceTail/consumeHead pointers only if mem copy succeeds. Also return
error code if mem copy fails.
VMware, Inc [Tue, 24 Aug 2010 18:45:41 +0000 (11:45 -0700)]
Fix VMCI guest driver compile use of (un)lock_kernel
A recent change introduced the use of (un)lock_kernel in the
VMCI guest driver. We need to include linux/smp_lock.h to get
the definition on certain kernels. This change adds that.
VMware, Inc [Tue, 24 Aug 2010 18:45:10 +0000 (11:45 -0700)]
Add a monotonic glib timer to Tools.
While investigating bug 600636, I noticed that glib timers sometimes would
get into a funny state where they'd ask the main loop to sleep for a very
short time, even though they weren't ready to be fired. I couldn't figure
out why they were doing that, but anyway, we can't easily modify glib.
Instead, add a new timer, based on a monotonic clock, to use in preference
to the glib timer. This is more important for quick firing timers such as
the RPC loop or the C&P pointer poll than it is for coarser-grained timers
such as the guest info gather loop.
Along with it, change the rpcin library and the dnd plugin to use the new
timer in place of the glib one, and avoid re-creating the timer on every
iteration of the rpcin loop - do it only when the delay has changed.
I was only able to reproduce the original issue on a 32-bit Win XP VM. I
tried a 64-bit Win 7 VM and a 64-bit Linux VM, and both seemed to behave
fine.
VMware, Inc [Tue, 24 Aug 2010 18:44:49 +0000 (11:44 -0700)]
Channel abstraction for Mac OS.
In preparation for Hgfs over vmci, let's abstract
the channel for Mac OS i.e remove all the assumptions
of backdoor so that it can transparently over both backdoor
and vmci.
VMware, Inc [Tue, 24 Aug 2010 18:44:34 +0000 (11:44 -0700)]
Fixing reporting reply size for obsolete (V1 and V2) HGFS protocol versions.
HGFS V1 and V2 protocol structures do not have a separate header.
The reply size must be just sizeof reply structure, should not add
size of the header to calculate total reply size.
VMware, Inc [Tue, 24 Aug 2010 18:44:10 +0000 (11:44 -0700)]
Get vmci module to work on 2.6.36-rc1
vmci had no idea that ioctl is going away, and that for supporting
32bit apps on 64bit hosts it should provide compat_ioctl. Even
for devel-only functionality. Fixed.
We enforce the maximum size of resourcePoolPath on both ends of guestlib wire
protocol (both versions 2 and 3). We handle larger buffers by not sending
them in the existing protocols.
This change is also a minor revision to the guestlib v3 protocol (host side
only) to add another field to the v3 layout to send the larger
resourcePoolPath buffer as a byte array. The guest client side is omitted
here.
VMware, Inc [Tue, 24 Aug 2010 18:32:07 +0000 (11:32 -0700)]
Null Pointer Check
1. Modified all exported functions to validate the input parameter for
non-null.
2. Modified VMCIQPair_Detach to return a result (instead of void) based
on success/failure of the detach operation.
3. Bumped the guest driver version.
Note: Functions calling VMCIQPair_Detach (like vsock module) should probably
start checking the result now. However, this would most likely not affect
existing calls.
VMware, Inc [Tue, 24 Aug 2010 18:31:44 +0000 (11:31 -0700)]
Fix some escaping issues with HGFS file path names
Fix the following:
- HGFS clients call HgfsEscape_Undo twice for each name
- HGFS server incorrectly calls HgfsEscape_Undo on names
returned to clients as part of a directory listing.
- HGFS escaping code has an assert inappropriately placed
- Fix HGFS server from unescaping share names which cannot
have been escaped. They should only be escaped if required
by a client.
VMware, Inc [Tue, 24 Aug 2010 18:29:58 +0000 (11:29 -0700)]
Autodetect glibc version in vm_basic_defs.h
For a long time, we have been passing GLIBC_VERSION_NN
macros via compiler command line.
These options can be autodetected without too much
work. The header <features.h> provides full version
information, provided we skip this header for kernel
compiles. This makes it a lot easier to upgrade
glibc versions...
VMware, Inc [Tue, 24 Aug 2010 18:28:15 +0000 (11:28 -0700)]
Fix renames on non-Windows hosts
The check if the target file exists and the rename was not to
replace an existing target was badly coded.
The logic left the status field incorrectly set to file not found
which was fine for not replacing the target but then the rename
was missed due to a check on the status being successful for the
existance check.
VMware, Inc [Tue, 24 Aug 2010 18:27:16 +0000 (11:27 -0700)]
GuestInfo: DiskInfo: Skip lib/wiper and call Win32 APIs directly.
Rather than deal with the wiper library and its filters, this change
instead makes Win32's GuestInfo_GetDiskInfo call directly against Win32
volume management APIs. POSIX guests will (for now) continue to use the
wiper library.
VMware, Inc [Tue, 24 Aug 2010 18:25:19 +0000 (11:25 -0700)]
Update the Hgfs server interface for tools
The Hgfs server interface was redone to work with multiple transports
however the tools side was left fudged.
Now upgrade the tools side interfaces into the Hgfs server.
The server interface is now hidden within the HgfsServerManager library.
The tools clients of the HGFS server now use the HgfsServerManager
interfaces directly:
HgfsServerManager_DataInit
HgfsServerManager_Register
HgfsServerManager_Unregister
HgfsServerManager_ProcessPacket
An HgfsServerManager guest is now built into the hgfs library with the server
and other related HGFS library code. The Hgfs server guest does not do any
RPC handling now as the library would have required building with both RPC
libraries and as such the RPC registering and callbacks are pushed back into
the caller.
At some future point when only one RPC library is used and all callers are built
in the same way, the HGFS RPC calls can be pushed back into the
HGfsServerManagerGuest to remove duplication of code.
VMware, Inc [Tue, 24 Aug 2010 18:24:28 +0000 (11:24 -0700)]
Use dentry with valid d_count
When we do getattr on a file, let's use dentry with a valid
d_count. This matters when you have more than one dentry for
an inode. You want to use dentry with valid d_count.
VMware, Inc [Tue, 24 Aug 2010 18:20:35 +0000 (11:20 -0700)]
Fail entire operation in case of an error while reading agruments.
In the function ReadArgsFromAddressSpaceFile we should fail the entire
operation instead of just breaking while comparing offsets. Otherwise,
we might get a DynBufArray with some elements having a NULL for the
buffer. This may lead to a NULL pointer dereference in
ExtractCommandLineFromAddressSpaceFile.