diff options
-rw-r--r-- | .SRCINFO | 52 | ||||
-rw-r--r-- | PKGBUILD | 69 | ||||
-rwxr-xr-x | common-functions.sh | 163 | ||||
-rw-r--r-- | vmci-10.0.4-3.14.patch | 23 | ||||
-rw-r--r-- | vmci-10.0.6-3.19.patch | 27 | ||||
-rw-r--r-- | vmci-10.0.6-4.0.patch | 16 | ||||
-rw-r--r-- | vmmon-10.0.4-3.14.patch | 11 | ||||
-rw-r--r-- | vmmon-10.0.5-3.14.patch | 14 | ||||
-rw-r--r-- | vmnet-10.0.1-3.13.patch | 21 | ||||
-rw-r--r-- | vmnet-10.0.4-3.14.patch | 11 | ||||
-rw-r--r-- | vmnet-10.0.5-3.17.patch | 12 | ||||
-rw-r--r-- | vmnet-11.1.0-3.19.patch | 58 | ||||
-rwxr-xr-x | vmware-patch | 269 | ||||
-rw-r--r-- | vmware-patch.install | 52 | ||||
-rwxr-xr-x | vmware-unpatch | 61 | ||||
-rw-r--r-- | vmware-usbarbitrator.service | 12 | ||||
-rw-r--r-- | vmware-workstation.service | 12 | ||||
-rw-r--r-- | vmware.service | 14 | ||||
-rw-r--r-- | vsock-10.0.4-3.14.patch | 23 | ||||
-rw-r--r-- | vsock-10.0.6-3.15.patch | 33 | ||||
-rw-r--r-- | vsock-10.0.6-3.19.patch | 53 |
21 files changed, 1006 insertions, 0 deletions
diff --git a/.SRCINFO b/.SRCINFO new file mode 100644 index 000000000000..1c7412ee4a6b --- /dev/null +++ b/.SRCINFO @@ -0,0 +1,52 @@ +pkgbase = vmware-patch + pkgdesc = A post-install configuration solution for VMware Workstation and Player (Plus and Pro) + pkgver = 11.1.0 + pkgrel = 5 + url = https://wiki.archlinux.org/index.php/VMware#Configuration + install = vmware-patch.install + arch = i686 + arch = x86_64 + license = GPL + depends = fuse + depends = gtkmm + depends = linux-headers + options = !emptydirs + source = vmware-patch + source = vmware-unpatch + source = common-functions.sh + source = vmware.service + source = vmware-usbarbitrator.service + source = vmware-workstation.service + source = vmnet-11.1.0-3.19.patch + source = vmci-10.0.6-4.0.patch + source = vmci-10.0.6-3.19.patch + source = vsock-10.0.6-3.15.patch + source = vsock-10.0.6-3.19.patch + source = vmmon-10.0.5-3.14.patch + source = vmnet-10.0.5-3.17.patch + source = vmci-10.0.4-3.14.patch + source = vmmon-10.0.4-3.14.patch + source = vmnet-10.0.4-3.14.patch + source = vsock-10.0.4-3.14.patch + source = vmnet-10.0.1-3.13.patch + md5sums = 2704cbc8b571d60e37ba3837638ccaef + md5sums = ba054b375308442d43a408dbae5e9401 + md5sums = e86bf4634661c8eb48823b4c69388bfc + md5sums = c12e765985b324585a548718a6ac9b43 + md5sums = ea3817fb7952932707bfedcf33a70697 + md5sums = 56f7f642683e54250372bb57faaf4e95 + md5sums = 350679df90d266fe7dd343922622c39e + md5sums = d5ba75849a3946851506ecbaa9ff3bb5 + md5sums = 0a8dbce269c7ac34a63453435a4a9fad + md5sums = 1893542f8144aa0bb96f5433b9c34158 + md5sums = 2dbd8389e1a275ea734dcedba8510df1 + md5sums = 298e1b59a9e729525cc3fa9d06f127eb + md5sums = 43dee79cc5f5980372e16a20962b3105 + md5sums = 0d7c84c3b611bedce3303c24aa666c64 + md5sums = 4eca49060d2373c259a0c045520de9f9 + md5sums = acd25c0daccb62af8abf750e6369ae25 + md5sums = 86a889febd9bdf88e458244195d604a4 + md5sums = d980b5092aeee55edc6dbafb843d886f + +pkgname = vmware-patch + diff --git a/PKGBUILD b/PKGBUILD new file mode 100644 index 000000000000..08bc368b0313 --- /dev/null +++ b/PKGBUILD @@ -0,0 +1,69 @@ +# Maintainer: Det <nimetonmaili g-mail> +# Contributors: Igor Duarte Cardoso, haagch, Olivier Médoc + +pkgname=vmware-patch +pkgver=11.1.0 +pkgrel=5 +pkgdesc="A post-install configuration solution for VMware Workstation and Player (Plus and Pro)" +arch=('i686' 'x86_64') +url="https://wiki.archlinux.org/index.php/VMware#Configuration" +license=('GPL') +depends=('fuse' 'gtkmm' 'linux-headers') +options=('!emptydirs') +install=$pkgname.install +source=('vmware-patch' 'vmware-unpatch' 'common-functions.sh' 'vmware.service' 'vmware-usbarbitrator.service' 'vmware-workstation.service' + # Workstation 11.1.0 / Player (Pro) 7.1.0 + 'vmnet-11.1.0-3.19.patch' + # Workstation 10.0.6 / Player (Plus) 6.0.6 + 'vmci-10.0.6-4.0.patch' + 'vmci-10.0.6-3.19.patch' + 'vsock-10.0.6-3.15.patch' + 'vsock-10.0.6-3.19.patch' + # Workstation 10.0.5 / Player (Plus) 6.0.5 + 'vmmon-10.0.5-3.14.patch' + 'vmnet-10.0.5-3.17.patch' + # Workstation 10.0.4 / Player (Plus) 6.0.4 + 'vmci-10.0.4-3.14.patch' + 'vmmon-10.0.4-3.14.patch' + 'vmnet-10.0.4-3.14.patch' + 'vsock-10.0.4-3.14.patch' + # Workstation 10.0.1 / Player (Plus) 6.0.1 + 'vmnet-10.0.1-3.13.patch') + +package() { + # Patch scripts + install -Dm755 vmware-patch "$pkgdir"/usr/bin/vmware-patch + install -m755 vmware-unpatch "$pkgdir"/usr/bin/ + + # Common functions + install -Dm755 common-functions.sh "$pkgdir"/usr/share/vmware-patch/common-functions.sh + + # Patches + install -d "$pkgdir"/usr/lib/vmware/modules/patches/ + install -m644 *.patch "$pkgdir"/usr/lib/vmware/modules/patches/ + + # Services + install -Dm644 vmware.service "$pkgdir"/usr/lib/systemd/system/vmware.service + install -m644 vmware-usbarbitrator.service "$pkgdir"/usr/lib/systemd/system/ + install -m644 vmware-workstation.service "$pkgdir"/usr/lib/systemd/system/ +} + +# Generated using 'updpkgsums' +md5sums=('2704cbc8b571d60e37ba3837638ccaef' + 'ba054b375308442d43a408dbae5e9401' + 'e86bf4634661c8eb48823b4c69388bfc' + 'c12e765985b324585a548718a6ac9b43' + 'ea3817fb7952932707bfedcf33a70697' + '56f7f642683e54250372bb57faaf4e95' + '350679df90d266fe7dd343922622c39e' + 'd5ba75849a3946851506ecbaa9ff3bb5' + '0a8dbce269c7ac34a63453435a4a9fad' + '1893542f8144aa0bb96f5433b9c34158' + '2dbd8389e1a275ea734dcedba8510df1' + '298e1b59a9e729525cc3fa9d06f127eb' + '43dee79cc5f5980372e16a20962b3105' + '0d7c84c3b611bedce3303c24aa666c64' + '4eca49060d2373c259a0c045520de9f9' + 'acd25c0daccb62af8abf750e6369ae25' + '86a889febd9bdf88e458244195d604a4' + 'd980b5092aeee55edc6dbafb843d886f') diff --git a/common-functions.sh b/common-functions.sh new file mode 100755 index 000000000000..37d9102c3a23 --- /dev/null +++ b/common-functions.sh @@ -0,0 +1,163 @@ +#!/bin/bash + +# Some colored makepkg-like functions +msg() { + printf "${green}==>${bold} $1${all_off}\n" +} + +msg_yellow() { + printf "${yellow}==>${bold} $1${all_off}\n" +} + +msg2() { + printf "${blue} ->${bold} $1${all_off}\n" +} + +msg2_yellow() { + printf "${yellow} ->${bold} $1${all_off}\n" +} + +read_msg2() { + read -p "${blue} ->${bold} $1${all_off}" +} + +msg3() { + printf "${yellow} ->${bold} $1${all_off}\n" +} + +error() { + printf "${red}==> error:${bold} $1${all_off}\n" +} + +error2() { + printf "${red} *${bold} $1${all_off}\n" +} + +# Colors +all_off="$(tput sgr0)" +bold="${all_off}$(tput bold)" +blue="${bold}$(tput setaf 4)" +green="${bold}$(tput setaf 2)" +red="${bold}$(tput setaf 1)" +yellow="${bold}$(tput setaf 3)" + +# Version information +print_version() { + echo "$(basename $0) $(pacman -Q vmware-patch | cut -d ' ' -f2)" + echo "Copyright (c) 2013-2015 Nobody" + echo + echo "THIS SCRIPT IS PROVIDED AS-IS FOR ANY PURPOSE WHATSOEVER. YOU ARE FREE TO SHARE IT, MODIFY IT," + echo "TAKE CREDIT OF IT, AND SELL IT ON THE STREETS." + echo + echo "FIGHT THE POWER." +} + +# Make sure we are root +root_check() { + if (( $EUID != 0 )); then + error "This script needs to be run as root." + exit 1 + fi +} + +# Is a VMware product installed? +vmware_check() { + if [[ ! -f /usr/bin/vmware-installer ]]; then + error "No VMware product found. Exiting.." + exit 1 + fi +} + +# Product name +set_product_name() { + ver=$(vmware-installer -l |& grep -Po "(player|workstation) *\K(\d+\.){2}\d+") + if vmware-installer -l |& grep -q "workstation"; then + name="VMware Workstation" + else + name="VMware Player (Plus)" + fi +} + +# Select kernel from menu +menu() { + # Don't show previous menu + clear + + # Menu + echo "Select kernels for which to build modules (leave empty for current kernel):" + for i in ${!kernels_all[@]}; do + printf "%3d%s) %s\n" "$((i+1))" "${choices[i]:- }" "${kernels_all[i]}" + done +} + +# Wrapper function +list_kernels() { + # Wait for Enter + while menu && read -rp "Press Enter when done: " num && [[ $num ]]; do + # Select correct item + (( num -- )) + + # Set plus mark (+) + if [[ ${choices[num]} ]]; then + choices[num]="" + else + choices[num]="+" + fi + done + + # Chosen kernels + for i in ${!kernels_all[@]}; do + if [[ ${choices[i]} ]]; then + kernels+=("${kernels_all[i]}") + fi + done +} + +# Compile leftover module locations +remove_leftover_module_dirs() { + for i in /usr/lib/modules/*; do + if [[ $(ls "$i") = misc ]]; then + misc+=("$i") + fi + done + + # Remove them + if [[ $misc ]]; then + msg_yellow "Removing leftover module location.." + for i in ${misc[@]}; do + msg2 "$i/" + rm -r "$i" + done + fi +} + +# Remove old backups +# ls: supports multiple arguments as opppsed to [ -d ] +remove_old_backups() { + if ls -d source-*.*/ 2>/dev/null | grep -qv "$ver/"; then + msg_yellow "Cleaning up old backups.." + # Print full paths + for i in $(readlink -f source-*.*/ | grep -v "$ver"); do + msg2 "$i/" + rm -r "$i" + done + fi +} + +# Patch function +patch_sources() { + if [[ $verbose ]]; then + msg3 "Patching.." + patch -p0 -f -i "../$patch" + else + patch -p0 -s -f -i "../$patch" + fi +} + +# Print vmware-modconfig-*.logs and exit +print_logs() { + for log in /tmp/vmware-root/vmware-modconfig-*.log; do + error2 "$log" + done + exit 1 +} diff --git a/vmci-10.0.4-3.14.patch b/vmci-10.0.4-3.14.patch new file mode 100644 index 000000000000..d5dd274df669 --- /dev/null +++ b/vmci-10.0.4-3.14.patch @@ -0,0 +1,23 @@ +diff -rupN vmci-only/shared/vm_assert.h vmci-only/shared/vm_assert.h +--- vmci-only/shared/vm_assert.h 2014-03-31 18:49:14.841009422 +0100 ++++ vmci-only/shared/vm_assert.h 2014-03-31 18:49:21.385009439 +0100 +@@ -256,6 +256,7 @@ void WarningThrottled(uint32 *count, con + __FILE__, __LINE__, __FUNCTION__, \ + _fix)) + #else ++ #undef DEPRECATED /* in <linux/printk.h> since 3.14.0 */ + #define DEPRECATED(_fix) do {} while (0) + #endif + +diff -rupN vmci-only/linux/driver.c vmci-only/linux/driver.c +--- vmci-only/linux/driver.c 2014-03-31 18:49:14.840009422 +0100 ++++ vmci-only/linux/driver.c 2014-03-31 18:49:21.385009439 +0100 +@@ -737,7 +737,7 @@ LinuxDriver_Ioctl(struct inode *inode, + goto init_release; + } + +- user = current_uid(); ++ user = from_kuid(current_user_ns(), current_uid()); + retval = VMCIContext_InitContext(initBlock.cid, initBlock.flags, + 0 /* Unused */, vmciLinux->userVersion, + &user, &vmciLinux->context); diff --git a/vmci-10.0.6-3.19.patch b/vmci-10.0.6-3.19.patch new file mode 100644 index 000000000000..bc156d12f264 --- /dev/null +++ b/vmci-10.0.6-3.19.patch @@ -0,0 +1,27 @@ +diff --git vmci-only/linux/vmciKernelIf.c vmci-only/linux/vmciKernelIf.c +index a51bef8..8143425 100644 +--- vmci-only/linux/vmciKernelIf.c ++++ vmci-only/linux/vmciKernelIf.c +@@ -40,7 +40,7 @@ + #include <linux/socket.h> /* For memcpy_{to,from}iovec(). */ + #include <linux/vmalloc.h> + #include <linux/wait.h> +- ++#include <linux/skbuff.h> + #include "compat_highmem.h" + #include "compat_interrupt.h" + #include "compat_mm.h" +@@ -1300,11 +1300,11 @@ __VMCIMemcpyFromQueue(void *dest, // OUT: + } + + if (isIovec) { +- struct iovec *iov = (struct iovec *)dest; ++ struct msghdr *msg = dest; + int err; + + /* The iovec will track bytesCopied internally. */ +- err = memcpy_toiovec(iov, (uint8 *)va + pageOffset, toCopy); ++ err = memcpy_to_msg(msg, (uint8 *)va + pageOffset, toCopy); + if (err != 0) { + if (!kernelIf->isDataMapped) { + kunmap(kernelIf->page[pageIndex]); diff --git a/vmci-10.0.6-4.0.patch b/vmci-10.0.6-4.0.patch new file mode 100644 index 000000000000..e217bb0d7ecf --- /dev/null +++ b/vmci-10.0.6-4.0.patch @@ -0,0 +1,16 @@ +--- vmci-only/linux/vmciKernelIf.c 2015-05-06 08:58:06.000000000 +0200 ++++ vmci-only/linux/vmciKernelIf.c 2015-05-06 08:58:51.365854540 +0200 +@@ -1227,11 +1227,11 @@ + } + + if (isIovec) { +- struct iovec *iov = (struct iovec *)src; ++ struct msghdr *msg = src; + int err; + + /* The iovec will track bytesCopied internally. */ +- err = memcpy_fromiovec((uint8 *)va + pageOffset, iov, toCopy); ++ err = memcpy_from_msg((uint8 *)va + pageOffset, msg, toCopy); + if (err != 0) { + if (!kernelIf->isDataMapped) { + kunmap(kernelIf->page[pageIndex]); diff --git a/vmmon-10.0.4-3.14.patch b/vmmon-10.0.4-3.14.patch new file mode 100644 index 000000000000..22977ff51b55 --- /dev/null +++ b/vmmon-10.0.4-3.14.patch @@ -0,0 +1,11 @@ +diff -rupN vmmon-only/include/vm_assert.h vmmon-only/include/vm_assert.h +--- vmmon-only/include/vm_assert.h 2014-03-31 18:49:14.835009422 +0100 ++++ vmmon-only/include/vm_assert.h 2014-03-31 18:49:21.380009439 +0100 +@@ -256,6 +256,7 @@ void WarningThrottled(uint32 *count, con + __FILE__, __LINE__, __FUNCTION__, \ + _fix)) + #else ++ #undef DEPRECATED /* in <linux/printk.h> since 3.14.0 */ + #define DEPRECATED(_fix) do {} while (0) + #endif + diff --git a/vmmon-10.0.5-3.14.patch b/vmmon-10.0.5-3.14.patch new file mode 100644 index 000000000000..681690396436 --- /dev/null +++ b/vmmon-10.0.5-3.14.patch @@ -0,0 +1,14 @@ +diff -rupN vmmon-only/linux/driver.c vmmon-only/linux/driver.c +--- vmmon-only/linux/driver.c 2014-03-31 18:49:14.834009422 +0100 ++++ vmmon-only/linux/driver.c 2014-03-31 18:49:21.379009439 +0100 +@@ -1338,7 +1338,9 @@ LinuxDriverReadTSC(void *data, // OUT: + *----------------------------------------------------------------------------- + */ + +-__attribute__((always_inline)) static Bool ++#include <linux/compiler-gcc.h> ++ ++__always_inline static Bool + LinuxDriverSyncReadTSCs(uint64 *delta) // OUT: TSC max - TSC min + { + TSCDelta tscDelta; diff --git a/vmnet-10.0.1-3.13.patch b/vmnet-10.0.1-3.13.patch new file mode 100644 index 000000000000..03964ad2055e --- /dev/null +++ b/vmnet-10.0.1-3.13.patch @@ -0,0 +1,21 @@ +diff -u vmnet-only.a/filter.c vmnet-only/filter.c +--- vmnet-only.a/filter.c 2014-04-02 21:34:26.935944394 +0300 ++++ vmnet-only/filter.c 2013-10-18 22:11:55.000000000 +0300 +@@ -203,7 +203,7 @@ + #endif + + static unsigned int +-VNetFilterHookFn(unsigned int hooknum, // IN: ++VNetFilterHookFn(const struct nf_hook_ops *ops, // IN: + #ifdef VMW_NFHOOK_USES_SKB + struct sk_buff *skb, // IN: + #else +@@ -252,7 +252,7 @@ + + /* When the host transmits, hooknum is VMW_NF_INET_POST_ROUTING. */ + /* When the host receives, hooknum is VMW_NF_INET_LOCAL_IN. */ +- transmit = (hooknum == VMW_NF_INET_POST_ROUTING); ++ transmit = (ops->hooknum == VMW_NF_INET_POST_ROUTING); + + packetHeader = compat_skb_network_header(skb); + ip = (struct iphdr*)packetHeader; diff --git a/vmnet-10.0.4-3.14.patch b/vmnet-10.0.4-3.14.patch new file mode 100644 index 000000000000..0217b0773dbc --- /dev/null +++ b/vmnet-10.0.4-3.14.patch @@ -0,0 +1,11 @@ +diff -rupN vmnet-only.a/vm_assert.h vmnet-only/vm_assert.h +--- vmnet-only.a/vm_assert.h 2014-03-31 18:49:14.845009422 +0100 ++++ vmnet-only/vm_assert.h 2014-03-31 18:49:21.390009439 +0100 +@@ -256,6 +256,7 @@ void WarningThrottled(uint32 *count, con + __FILE__, __LINE__, __FUNCTION__, \ + _fix)) + #else ++ #undef DEPRECATED /* in <linux/printk.h> since 3.14.0 */ + #define DEPRECATED(_fix) do {} while (0) + #endif + diff --git a/vmnet-10.0.5-3.17.patch b/vmnet-10.0.5-3.17.patch new file mode 100644 index 000000000000..b3f63a0c163d --- /dev/null +++ b/vmnet-10.0.5-3.17.patch @@ -0,0 +1,12 @@ +diff -ur vmnet-only.a/netif.c vmnet-only/netif.c +--- vmnet-only.a/netif.c 2014-10-10 03:23:08.585920012 +0300 ++++ vmnet-only/netif.c 2014-10-10 03:23:09.245920008 +0300 +@@ -149,7 +149,7 @@ + memcpy(deviceName, devName, sizeof deviceName); + NULL_TERMINATE_STRING(deviceName); + +- dev = alloc_netdev(sizeof *netIf, deviceName, VNetNetIfSetup); ++ dev = alloc_netdev(sizeof *netIf, deviceName, NET_NAME_UNKNOWN, VNetNetIfSetup); + if (!dev) { + retval = -ENOMEM; + goto out; diff --git a/vmnet-11.1.0-3.19.patch b/vmnet-11.1.0-3.19.patch new file mode 100644 index 000000000000..6e71e9451d8b --- /dev/null +++ b/vmnet-11.1.0-3.19.patch @@ -0,0 +1,58 @@ +diff -ur vmnet-only.a/driver.c vmnet-only/driver.c +--- vmnet-only.a/driver.c 2014-11-20 20:13:56.000000000 -0500 ++++ vmnet-only/driver.c 2015-02-09 15:40:10.916640592 -0500 +@@ -265,10 +265,17 @@ + { + int ret = -ENOTTY; + ++#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 19, 0) + if (filp && filp->f_op && filp->f_op->ioctl == VNetFileOpIoctl) { + ret = VNetFileOpIoctl(filp->f_dentry->d_inode, filp, iocmd, ioarg); + } + return ret; ++#else ++ if (filp && filp->f_op && filp->f_op->ioctl == VNetFileOpIoctl) { ++ ret = VNetFileOpIoctl(filp->f_path.dentry->d_inode, filp, iocmd, ioarg); ++ } ++ return ret; ++#endif + } + + +@@ -1191,11 +1198,19 @@ + struct inode *inode = NULL; + long err; + ++#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 19, 0) + if (filp && filp->f_dentry) { + inode = filp->f_dentry->d_inode; + } + err = VNetFileOpIoctl(inode, filp, iocmd, ioarg); + return err; ++#else ++ if (filp && filp->f_path.dentry) { ++ inode = filp->f_path.dentry->d_inode; ++ } ++ err = VNetFileOpIoctl(inode, filp, iocmd, ioarg); ++ return err; ++#endif + } + #endif + +diff -ur vmnet-only.a/userif.c vmnet-only/userif.c +--- vmnet-only.a/userif.c 2014-11-20 20:13:56.000000000 -0500 ++++ vmnet-only/userif.c 2015-02-09 15:41:02.150847338 -0500 +@@ -523,7 +523,13 @@ + .iov_base = buf, + .iov_len = len, + }; ++#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 19, 0) + return skb_copy_datagram_iovec(skb, 0, &iov, len); ++#else ++ struct iov_iter to; ++ iov_iter_init(&to, READ, &iov, 1, len); ++ return skb_copy_datagram_iter(skb, 0, &to, len); ++#endif + } + + diff --git a/vmware-patch b/vmware-patch new file mode 100755 index 000000000000..2375cbc01318 --- /dev/null +++ b/vmware-patch @@ -0,0 +1,269 @@ +#!/bin/bash -e + +# Source common functions +. /usr/share/vmware-patch/common-functions.sh + +# Help message +usage() { + echo "Usage: $(basename $0) [-f|-v|-V|-h]" + echo "Automate the compilation of VMware modules for Arch Linux." + echo + echo "Available options:" + echo " -a, --all Build for all kernels" + echo " -f, --force Force reinstallation, even if modules are already built" + echo " -k, --kernel Select which kernel(s) to build to from menu" + echo " -v, --verbose Use verbose output in patching and vmware-modconfig" + echo " -V, --version Print version information" + echo " -h, --help Print this help" +} + +# Flags +while [[ $1 ]]; do + # Can't change $1 + opt=$1 + + # Parse current one + while [[ $opt != - ]]; do + # Define actions + case $opt in + -a* | --all-kernels) all=1 ;; + -f* | --force) force=1 ;; + -k* | --kernel) kernel=1 ;; + -v* | --verbose) verbose=1 ;; + -V* | --version) print_version; exit 0 ;; + -h* | --help) usage; exit 0 ;; + -*) echo "$(basename $0): error: bad argument: $opt" + echo + usage $1; exit 0 ;; + *) break ;; + esac + + # Support single dash (vmware-patch -fv) + # ${opt#-:[*]}: Remove first match + nextopt=${opt#-[afkv]} + if [[ $opt != $nextopt ]]; then + # Multiple short flags + opt=-$nextopt + else + # Long form (--force/--verbose) + break + fi + done + shift +done + +# Make sure we are root +root_check + +# Is a VMware product installed? +vmware_check + +# Product name +set_product_name + +# Make sure vmware.service includes our USB Arbitrator service +if ! grep -q "usbarbitrator" /usr/lib/systemd/system/vmware.service; then + msg "Updating vmware.service.." + sed '/Description/a Requires=vmware-usbarbitrator.service\nBefore=vmware-usbarbitrator.service' \ + -i /usr/lib/systemd/system/vmware.service +fi + +# Use VMware's bundled libcurl.so.4 to prevent crashes at startup/checking for updates +for script in vmware vmplayer; do + if [[ -f /usr/bin/$script ]]; then + if ! grep -q "libcurl" /usr/bin/$script; then + sed '/$vmmon/a\ export LD_LIBRARY_PATH=/usr/lib/vmware/lib/libcurl.so.4' \ + -i /usr/bin/$script + fi + fi +done + +# Make sure there's a version in /etc/arch-release for Workstation 9 / Player 5 +# https://wiki.archlinux.org/index.php?title=VMware&oldid=274532#2.29_The_vmware-usbarbitrator_binary_is_segfaulting +if [[ $ver = 9.* ]] || [[ $ver = 5.* ]]; then + if [[ ! $(cat /etc/arch-release) ]]; then + msg "Updating /etc/arch-release.." + curl -s https://www.archlinux.org/releng/releases/ | grep -Pom1 'for \K[^"]*' > /etc/arch-release + fi +fi + +# Fix VMCI/VSOCK loading for Workstation 10 / Player (Plus) 6 and earlier +if [[ $ver != 11.* ]] && [[ $ver != 7.* ]]; then + if grep -q '$vsock_alias' /etc/init.d/vmware; then + sed -e 's/mod=$(vmwareRealModName $vmci $vmci_alias)/mod=vmci/' \ + -e 's/mod=$(vmwareRealModName $vsock $vsock_alias)/mod=vsock/' \ + -i /etc/init.d/vmware + fi +else + if grep -q 'mod=vmci' /etc/init.d/vmware; then + # Revert the tweak for Workstation 11 / Player (Pro) 7 + sed -e 's/mod=vmci/mod=$(vmwareRealModName $vmci $vmci_alias)/' \ + -e 's/mod=vsock/mod=$(vmwareRealModName $vsock $vsock_alias)/' \ + -i /etc/init.d/vmware + fi +fi + +# Remove leftover module locations +remove_leftover_module_dirs +cd /usr/lib/vmware/modules/ + +# Remove old backups +remove_old_backups + +# Available kernels +kernels_all=($(cat /usr/lib/modules/extramodules-*/version)) + +# Kernel(s) to build to +if [[ ! $all ]]; then + if [[ ! $kernel ]]; then + kernels=$(uname -r) + else + list_kernels + fi +else + kernels=${kernels_all[@]} +fi + +# Build for however many kernels specified +for kernel in ${kernels[@]}; do + # Make sure the directory exists + if [[ ! -d /usr/lib/modules/$kernel/ ]]; then + error "/usr/lib/modules/$kernel/ not found. Exiting.." + exit 1 + fi + + # Support the '-f' flag + # 1) Have we already built (vmnet is built last)? + # 2) Don't check this until we've removed the leftovers + if [[ ! $force ]] && [[ -f /usr/lib/modules/$kernel/misc/vmnet.ko ]]; then + if [[ $verbose ]]; then + msg "Verifying current state.." + fi + error "VMware modules already installed (use '-f' to override). Exiting.." + exit 1 + fi + + # Unload conflicting in-kernel modules in less than Workstation 11 / Player (Pro) 7 + if [[ $ver != 11.* ]] && [[ $ver != 7.* ]]; then + rmmod "vsock" "vmw_vsock_vmci_transport" "vmw_vmci" 2>/dev/null || true + else + modprobe "vsock" "vmw_vsock_vmci_transport" "vmw_vmci" 2>/dev/null || true + fi + + # Detect applicable patches (/usr/lib/vmware/modules/patches/[mod]-[ver]-[kernel].patch) + unset patches + for patch in patches/*; do + # Some variables + ver_patch=$(echo $patch | cut -d "-" -f2) + kernel_patch=$(echo $patch | grep -Po ".*-\K\d+\.\d+") + kernel_major=$(echo $kernel | cut -d "." -f-2) + + # Sync VMware Player (Plus) version by incrementing by 4 + ver2=$ver + if [[ $name =~ Player ]]; then + major=$(( ${ver/.*} + 4 )) + ver2=$major.${ver#*.} + fi + + # Is product version not lower and kernel version not higher in patch name? + if (( $(vercmp "$ver_patch" "$ver2") >= 0 )) && (( $(vercmp "$kernel_patch" "$kernel_major") <= 0 )); then + patches+=("$patch") + fi + done + + # Patch + # 1) Make sure we can build + # 2) &>/dev/null: hide all output (STDIN/STDERR) + msg "Patching $name v$ver for kernel $kernel.." + if [[ $patches ]]; then + # Create a backup/Revert + if [[ ! -d source-$ver ]]; then + msg2_yellow "Backing up.." + cp -r source/ "source-$ver/" + else + # Get the original sources from the backup (invalidate the need for 'vmware-unpatch') + cp "source-$ver/"* source/ + fi + + # cd in place + cd source + + # Loop modules that require patching (vmci, vmmon, vmnet and/or vsock) + # sort -u: prevent duplicate entries + for mod in $(echo ${patches[@]} | grep -Po "s/\K[^-]*" | sort -u); do + # Print name + msg2 "[$mod]" + + # Untar + if [[ $verbose ]]; then + msg3 "Extracting archives.." + fi + tar -xf "$mod.tar" + + # Loop through applicable patches + # printf '%s\n': print ${patches[@]} in separate lines for grepping + for patch in $(printf '%s\n' "${patches[@]}" | grep "$mod"); do + # Patch + if ! patch_sources; then + error "Failed to apply '$(basename "$patch")'" + read_msg2 "Continue? (Y/n) " + if [[ $REPLY != [Yy] ]]; then + # Revert + msg "Reverting.." + cd .. + rm -r source/ + mv "source-$ver/" source/ + + # Exit + msg2 "Done." + exit 1 + fi + fi + done + + # Tar patched modules + if [[ $verbose ]]; then + msg3 "Recreating archives.." + fi + tar -cf "$mod.tar" "$mod-only" + + # Leftovers + rm -r "$mod-only" + done + + # Return + cd .. + else + msg2 "No patching required.." + fi + + # Install + msg "Installing modules.." + if [[ $verbose ]]; then + # Run vmware-modconfig + if ! vmware-modconfig --console --install-all -k "$kernel"; then + # See logs + if ls /tmp/vmware-root/vmware-modconfig-*.log &>/dev/null; then + error "Unable to build. See:" + print_logs + else + error "Unable to build. See logs in /tmp/vmware-root/" + fi + else + msg2 "Done." + fi + else + # Run vmware-modconfig + if ! vmware-modconfig --console --install-all -k "$kernel" &>/dev/null; then + # See logs + if ls /tmp/vmware-root/vmware-modconfig-*.log &>/dev/null; then + error "Unable to build. Re-run with '-v' (--verbose) or see:" + print_logs + else + error "Unable to build. See logs in /tmp/vmware-root/" + fi + else + msg2 "Done." + fi + fi +done diff --git a/vmware-patch.install b/vmware-patch.install new file mode 100644 index 000000000000..e8d1b4876cae --- /dev/null +++ b/vmware-patch.install @@ -0,0 +1,52 @@ +# Colored makepkg-like functions +msg_blue() { + printf "${blue}==>${bold} $1${all_off}\n" +} + +note_blue() { + printf "${blue}==>${yellow} Note $1)${bold} $2${all_off}\n" +} + +note_green() { + printf "${green}==>${yellow} Note:${bold} $1${all_off}\n" +} + +all_off="$(tput sgr0)" +bold="${all_off}$(tput bold)" +blue="${bold}$(tput setaf 4)" +green="${bold}$(tput setaf 2)" +yellow="${bold}$(tput setaf 3)" + +_common() { + vmware-patch + + echo + note_blue 1 "Enabling the main service is *required* to automatically load modules on boot: + # systemctl enable vmware" + note_blue 2 "To patch VMware sources in the future, re-run the script 'vmware-patch' as root. + Changes can be reverted with 'vmware-unpatch' (only required to apply other + patching methods)." + note_blue 3 "For further reading see the relevant sections in the Wiki: + https://wiki.archlinux.org/index.php/Vmware#Tips_and_tricks + https://wiki.archlinux.org/index.php/Vmware#Troubleshooting" + echo +} + +post_install() { + msg_blue "Running 'vmware-patch' for the first time.." + + _common +} + +post_upgrade() { + msg_blue "Re-running 'vmware-patch'.." + + _common +} + +post_remove() { + if [[ -d /usr/lib/vmware/modules/source-* ]]; then + echo + note_green "Left '$(ls -d /usr/lib/vmware/modules/source-*/)' as backup.\n" + fi +}
\ No newline at end of file diff --git a/vmware-unpatch b/vmware-unpatch new file mode 100755 index 000000000000..6180bc2352a8 --- /dev/null +++ b/vmware-unpatch @@ -0,0 +1,61 @@ +#!/bin/bash -e + +# Source common functions +. /usr/share/vmware-patch/common-functions.sh + +# Help message +usage() { + echo "Usage: $(basename $0) [-v/-V|-h]" + echo "Revert the VMware modules sources." + echo + echo "Available options:" + echo " -v, -V, --version Print version information" + echo " -h, --help Print this help" +} + +# Flags +while [[ $1 ]]; do + # Define actions + case "$1" in + -v | -V | --version) print_version; exit 0 ;; + -h | --help) usage; exit 0 ;; + -*) echo "$(basename $0): error: bad argument: $1" + echo + usage $1; exit 0 ;; + *) break ;; + esac + shift +done + +# Make sure we are root +root_check + +# Is a VMware product installed? +vmware_check + +# Product name +set_product_name + +# Remove leftover module locations +remove_leftover_module_dirs + +cd /usr/lib/vmware/modules/ + +# Remove old backups +remove_old_backups + +# Revert +cd /usr/lib/vmware/modules/ +if [[ -d source-$ver ]]; then + msg "Reverting $name v$ver module sources.." + msg2 "Removing $(readlink -f source)/" + rm -r source/ + + msg2 "Renaming backup: $(readlink -f source-$ver)/ -> $(readlink -f source)/" + mv "source-$ver/" source/ + + msg3 "Done." +else # Nothing found + error "No backups found." + exit +fi diff --git a/vmware-usbarbitrator.service b/vmware-usbarbitrator.service new file mode 100644 index 000000000000..0877c90cb217 --- /dev/null +++ b/vmware-usbarbitrator.service @@ -0,0 +1,12 @@ +[Unit] +Description=VMware USB Arbitrator +Requires=vmware.service +After=vmware.service + +[Service] +ExecStart=/usr/bin/vmware-usbarbitrator +ExecStop=/usr/bin/vmware-usbarbitrator --kill +RemainAfterExit=yes + +[Install] +WantedBy=multi-user.target diff --git a/vmware-workstation.service b/vmware-workstation.service new file mode 100644 index 000000000000..ff4bd26bbd5b --- /dev/null +++ b/vmware-workstation.service @@ -0,0 +1,12 @@ +[Unit] +Description=VMware Workstation Server daemon +Requires=vmware.service +After=vmware.service + +[Service] +ExecStart=/etc/init.d/vmware-workstation-server start +ExecStop=/etc/init.d/vmware-workstation-server stop +RemainAfterExit=yes + +[Install] +WantedBy=multi-user.target diff --git a/vmware.service b/vmware.service new file mode 100644 index 000000000000..2078e744cb76 --- /dev/null +++ b/vmware.service @@ -0,0 +1,14 @@ +[Unit] +Description=VMware daemon +Requires=vmware-usbarbitrator.service +Before=vmware-usbarbitrator.service +After=network.target + +[Service] +ExecStart=/etc/init.d/vmware start +ExecStop=/etc/init.d/vmware stop +PIDFile=/var/lock/subsys/vmware +RemainAfterExit=yes + +[Install] +WantedBy=multi-user.target diff --git a/vsock-10.0.4-3.14.patch b/vsock-10.0.4-3.14.patch new file mode 100644 index 000000000000..10f71901acc5 --- /dev/null +++ b/vsock-10.0.4-3.14.patch @@ -0,0 +1,23 @@ +diff -rupN vsock-only/shared/vm_assert.h vsock-only/shared/vm_assert.h +--- vsock-only/shared/vm_assert.h 2014-03-31 18:49:14.839009422 +0100 ++++ vsock-only/shared/vm_assert.h 2014-03-31 18:49:21.382009439 +0100 +@@ -256,6 +256,7 @@ void WarningThrottled(uint32 *count, con + __FILE__, __LINE__, __FUNCTION__, \ + _fix)) + #else ++ #undef DEPRECATED /* in <linux/printk.h> since 3.14.0 */ + #define DEPRECATED(_fix) do {} while (0) + #endif + +diff -rupN vsock-only/linux/af_vsock.c vsock-only/linux/af_vsock.c +--- vsock-only/linux/af_vsock.c 2014-03-31 18:49:14.837009422 +0100 ++++ vsock-only/linux/af_vsock.c 2014-03-31 18:49:21.381009439 +0100 +@@ -2869,7 +2869,7 @@ __VSockVmciCreate(struct net *net, + vsk->connectTimeout = psk->connectTimeout; + } else { + vsk->trusted = capable(CAP_NET_ADMIN); +- vsk->owner = current_uid(); ++ vsk->owner = from_kuid(current_user_ns(), current_uid()); + vsk->queuePairSize = VSOCK_DEFAULT_QP_SIZE; + vsk->queuePairMinSize = VSOCK_DEFAULT_QP_SIZE_MIN; + vsk->queuePairMaxSize = VSOCK_DEFAULT_QP_SIZE_MAX; diff --git a/vsock-10.0.6-3.15.patch b/vsock-10.0.6-3.15.patch new file mode 100644 index 000000000000..57f4f61b2790 --- /dev/null +++ b/vsock-10.0.6-3.15.patch @@ -0,0 +1,33 @@ +diff -rupN vsock-only/linux/notify.c vsock-only/linux/notify.c +--- vsock-only/linux/notify.c 2014-04-15 03:11:41.000000000 +0530 ++++ vsock-only/linux/notify.c 2014-05-27 21:36:56.713291909 +0530 +@@ -516,7 +516,7 @@ VSockVmciHandleWrote(struct sock *sk, + PKT_FIELD(vsk, sentWaitingRead) = FALSE; + #endif + +- sk->sk_data_ready(sk, 0); ++ sk->sk_data_ready(sk); + } + + +diff -rupN vsock-only/linux/notifyQState.c vsock-only/linux/notifyQState.c +--- vsock-only/linux/notifyQState.c 2014-04-15 03:11:41.000000000 +0530 ++++ vsock-only/linux/notifyQState.c 2014-05-27 21:38:52.561286734 +0530 +@@ -164,7 +164,7 @@ VSockVmciHandleWrote(struct sock *sk, + struct sockaddr_vm *dst, // IN: unused + struct sockaddr_vm *src) // IN: unused + { +- sk->sk_data_ready(sk, 0); ++ sk->sk_data_ready(sk); + } + + +@@ -566,7 +566,7 @@ VSockVmciNotifyPktRecvPostDequeue(struct + } + + /* See the comment in VSockVmciNotifyPktSendPostEnqueue */ +- sk->sk_data_ready(sk, 0); ++ sk->sk_data_ready(sk); + } + + return err; diff --git a/vsock-10.0.6-3.19.patch b/vsock-10.0.6-3.19.patch new file mode 100644 index 000000000000..f024b8fce002 --- /dev/null +++ b/vsock-10.0.6-3.19.patch @@ -0,0 +1,53 @@ +diff --git vsock-only/linux/af_vsock.c vsock-only/linux/af_vsock.c +index 4d0c6c3..1c29976 100644 +--- vsock-only/linux/af_vsock.c ++++ vsock-only/linux/af_vsock.c +@@ -4285,7 +4285,7 @@ VSockVmciDgramSendmsg(struct kiocb *kiocb, // UNUSED + goto out; + } + +- memcpy_fromiovec(VMCI_DG_PAYLOAD(dg), msg->msg_iov, len); ++ memcpy_fromiovec(VMCI_DG_PAYLOAD(dg), &msg->msg_iter.iov, len); + + dg->dst = VMCI_MAKE_HANDLE(remoteAddr->svm_cid, remoteAddr->svm_port); + dg->src = VMCI_MAKE_HANDLE(vsk->localAddr.svm_cid, vsk->localAddr.svm_port); +@@ -4645,7 +4645,7 @@ VSockVmciStreamSendmsg(struct kiocb *kiocb, // UNUSED + * able to send. + */ + +- written = vmci_qpair_enquev(vsk->qpair, msg->msg_iov, ++ written = vmci_qpair_enquev(vsk->qpair, &msg->msg_iter.iov, + len - totalWritten, 0); + if (written < 0) { + err = -ENOMEM; +@@ -4704,6 +4704,7 @@ VSockVmciDgramRecvmsg(struct kiocb *kiocb, // UNUSED + VMCIDatagram *dg; + size_t payloadLen; + struct sk_buff *skb; ++ struct iov_iter to; + + sk = sock->sk; + noblock = flags & MSG_DONTWAIT; +@@ -4742,7 +4743,9 @@ VSockVmciDgramRecvmsg(struct kiocb *kiocb, // UNUSED + } + + /* Place the datagram payload in the user's iovec. */ +- err = skb_copy_datagram_iovec(skb, sizeof *dg, msg->msg_iov, payloadLen); ++ // err = skb_copy_datagram_iovec(skb, sizeof *dg, msg->msg_iter, payloadLen); ++ iov_iter_init(&to, READ, &msg->msg_iter.iov, 1, payloadLen); ++ err = skb_copy_datagram_iter(skb, 0, &to, payloadLen); + if (err) { + goto out; + } +@@ -4888,9 +4891,9 @@ VSockVmciStreamRecvmsg(struct kiocb *kiocb, // UNUSED + } + + if (flags & MSG_PEEK) { +- read = vmci_qpair_peekv(vsk->qpair, msg->msg_iov, len - copied, 0); ++ read = vmci_qpair_peekv(vsk->qpair, &msg->msg_iter.iov, len - copied, 0); + } else { +- read = vmci_qpair_dequev(vsk->qpair, msg->msg_iov, len - copied, 0); ++ read = vmci_qpair_dequev(vsk->qpair, &msg->msg_iter.iov, len - copied, 0); + } + + if (read < 0) { |