Skip to content
This repository has been archived by the owner on Jan 1, 2021. It is now read-only.

Commit

Permalink
Merge pull request #747 from frapposelli/vmware-support
Browse files Browse the repository at this point in the history
Proper VMware support
  • Loading branch information
tianon committed Apr 17, 2015
2 parents a270c71 + e883254 commit a142bc9
Show file tree
Hide file tree
Showing 7 changed files with 129 additions and 2 deletions.
50 changes: 49 additions & 1 deletion Dockerfile
Expand Up @@ -62,7 +62,8 @@ ENV TCZ_DEPS iptables \
xz liblzma \
git expat2 libiconv libidn libgpg-error libgcrypt libssh2 \
nfs-utils tcp_wrappers portmap rpcbind libtirpc \
curl ntpclient
curl ntpclient \
procps glib2 libtirpc libffi fuse

# Make the ROOTFS
RUN mkdir -p $ROOTFS
Expand Down Expand Up @@ -150,6 +151,53 @@ RUN mkdir -p /vboxguest && \
mkdir -p $ROOTFS/sbin && \
cp x86/lib/VBoxGuestAdditions/mount.vboxsf $ROOTFS/sbin/

# Build VMware Tools
ENV OVT_VERSION 9.4.6-1770165

# Download and prepare ovt source
RUN mkdir -p /vmtoolsd/open-vm-tools \
&& curl -L http://downloads.sourceforge.net/open-vm-tools/open-vm-tools-$OVT_VERSION.tar.gz \
| tar -xzC /vmtoolsd/open-vm-tools --strip-components 1

# Apply patches to make open-vm-tools compile with a recent 3.18.x kernel and
# a network script that knows how to plumb/unplumb nics on a busybox system,
# this will be removed once a new ovt version is released.
RUN cd /vmtoolsd && \
curl -L -o open-vm-tools-3.x.x-patches.patch https://gist.github.com/frapposelli/5506651fa6f3d25d5760/raw/475f8fb2193549c10a477d506de40639b04fa2a7/open-vm-tools-3.x.x-patches.patch &&\
patch -p1 < open-vm-tools-3.x.x-patches.patch && rm open-vm-tools-3.x.x-patches.patch

RUN dpkg --add-architecture i386 && apt-get update && apt-get install -y libfuse2 libtool autoconf \
libglib2.0-dev libdumbnet-dev:i386 \
libdumbnet1:i386 libfuse2:i386 libfuse-dev \
libglib2.0-0:i386 libtirpc-dev libtirpc1:i386

# Horrible Hack
RUN ln -s /lib/i386-linux-gnu/libglib-2.0.so.0.3200.4 /lib/i386-linux-gnu/libglib-2.0.so &&\
ln -s /lib/i386-linux-gnu/libtirpc.so.1.0.10 /lib/i386-linux-gnu/libtirpc.so &&\
ln -s /usr/lib/i386-linux-gnu/libgthread-2.0.so.0 /usr/lib/i386-linux-gnu/libgthread-2.0.so &&\
ln -s /usr/lib/i386-linux-gnu/libgmodule-2.0.so.0 /usr/lib/i386-linux-gnu/libgmodule-2.0.so &&\
ln -s /usr/lib/i386-linux-gnu/libgobject-2.0.so.0 /usr/lib/i386-linux-gnu/libgobject-2.0.so &&\
ln -s /lib/i386-linux-gnu/libfuse.so.2 /lib/i386-linux-gnu/libfuse.so

# Compile open-vm-tools
RUN cd /vmtoolsd/open-vm-tools && autoreconf -i &&\
CC="gcc -m32" CXX="g++ -m32" ./configure --host=i486-pc-linux-gnu --build=i486-pc-linux-gnu \
--without-kernel-modules --without-pam --without-procps --without-x --without-icu &&\
make CC="gcc -m32" CXX="g++ -m32" LIBS="-ltirpc" CFLAGS="-Wno-implicit-function-declaration" &&\
make DESTDIR=$ROOTFS install

# Download and compile libdnet as open-vm-tools rely on it.
ENV LIBDNET libdnet-1.11

RUN mkdir -p /vmtoolsd/${LIBDNET} &&\
curl -L http://sourceforge.net/projects/libdnet/files/libdnet/${LIBDNET}/${LIBDNET}.tar.gz \
| tar -xzC /vmtoolsd/${LIBDNET} --strip-components 1 &&\
cd /vmtoolsd/${LIBDNET} && ./configure --build=i486-pc-linux-gnu &&\
make CC="gcc -m32" CXX="g++ -m32" &&\
make install && make DESTDIR=$ROOTFS install

RUN cd $ROOTFS && cd usr/local/lib && ln -s libdnet.1 libdumbnet.so.1

# Make sure that all the modules we might have added are recognized (especially VBox guest additions)
RUN depmod -a -b $ROOTFS $KERNEL_VERSION-tinycore64

Expand Down
2 changes: 1 addition & 1 deletion kernel_config
Expand Up @@ -1532,7 +1532,7 @@ CONFIG_TIFM_7XX1=m
# CONFIG_SENSORS_APDS990X is not set
# CONFIG_HMC6352 is not set
# CONFIG_DS1682 is not set
# CONFIG_VMWARE_BALLOON is not set
CONFIG_VMWARE_BALLOON=m
# CONFIG_BMP085_I2C is not set
# CONFIG_USB_SWITCH_FSA9480 is not set
# CONFIG_SRAM is not set
Expand Down
3 changes: 3 additions & 0 deletions rootfs/rootfs/bootscript.sh
Expand Up @@ -82,3 +82,6 @@ fi
if modprobe hv_utils &> /dev/null; then
/usr/sbin/hv_kvp_daemon
fi

# Launch vmware-tools
/etc/rc.d/vmtoolsd
31 changes: 31 additions & 0 deletions rootfs/rootfs/etc/rc.d/automount
Expand Up @@ -34,6 +34,37 @@ if [ ! -n "$BOOT2DOCKER_DATA" ]; then
mkfs.ext4 -L $LABEL $BOOT2DOCKER_DATA
swapon "${UNPARTITIONED_HD}2"
fi

DISK_VENDOR=$(cat /sys/class/block/$(basename $UNPARTITIONED_HD /dev/)/device/vendor /sys/class/block/$(basename $UNPARTITIONED_HD /dev/)/device/model | tr -d "\n")
# Test if disk is "VMware, VMware Virtual S" and empty.
if [ "$DISK_VENDOR" = "VMware, VMware Virtual S" ] || [ "$DISK_VENDOR" = "VMware Virtual disk " ]; then
# Check whether the disk has any known partitions on it
blkid -o device $UNPARTITIONED_HD
if [ $? == 2 ]; then
# As there are no partitions, let's make sure the disk is empty for real
dd if=$UNPARTITIONED_HD of=device_test_file bs=1k count=256 > /dev/null 2>&1
NON_NUL=$(<device_test_file tr -d '\0\n' | wc -c)
if [ $NON_NUL == 0 ]; then
# Create the partition, format it and then mount it
echo "NEW VMware boot2docker managed disk image ($UNPARTITIONED_HD): formatting it for use"
echo "NEW VMware boot2docker managed disk image ($UNPARTITIONED_HD): formatting it for use" > /home/docker/log.log

# Add a swap partition (so Docker doesn't complain about it missing)
(echo n; echo p; echo 2; echo ; echo +1000M ; echo w) | fdisk $UNPARTITIONED_HD
(echo t; echo 82) | fdisk $UNPARTITIONED_HD
mkswap "${UNPARTITIONED_HD}2"
# Add the data partition
(echo n; echo p; echo 1; echo ; echo ; echo w) | fdisk $UNPARTITIONED_HD
BOOT2DOCKER_DATA=`echo "${UNPARTITIONED_HD}1"`
mkfs.ext4 -L $LABEL $BOOT2DOCKER_DATA
swapon "${UNPARTITIONED_HD}2"
else
echo "Disk unpartitioned but something is there... not doing anything"
fi
else
echo "Partition table found on disk, not doing anything"
fi
fi
else
# Pick the first ext4 as a fallback
# TODO: mount all Linux partitions and look for a /var/lib/docker...
Expand Down
5 changes: 5 additions & 0 deletions rootfs/rootfs/etc/rc.d/vmtoolsd
@@ -0,0 +1,5 @@
#!/bin/sh

# vmtoolsd will start only if it can connect to the vmx backdoor, will
# quit immediately if not running on a VMware-based system.
/usr/local/bin/vmtoolsd --background /var/run/vmtoolsd.pid
32 changes: 32 additions & 0 deletions rootfs/rootfs/sbin/shutdown
@@ -0,0 +1,32 @@
#!/bin/sh

usage()
{
echo 'Usage: shutdown [-rh] time
-r: reboot after shutdown.
-h: halt after shutdown.
** the "time" argument is mandatory! (try "now") **' >&2
exit 1
}

case $1 in
-r) CMD="/bin/busybox reboot"
;;
-h) CMD="/bin/busybox poweroff"
;;
*) usage
;;
esac

shift

case $1 in
now|+0) DELAY=""
;;
+[0-9]*) DELAY=$(($1 * 60))
;;
*) usage
;;
esac

${CMD}${DELAY:+ -d $DELAY}
8 changes: 8 additions & 0 deletions rootfs/rootfs/usr/local/bin/lsb_release
@@ -0,0 +1,8 @@
#!/bin/sh
# just to make open-vm-tools happy, nad fake output
# of lsb_release -sd
. /etc/os-release
echo $PRETTY_NAME

exit 0

0 comments on commit a142bc9

Please sign in to comment.