"Failed to build vmnet" for kernel 3.19
Because this answer is only for kernel 3.13, so I'd like to share a solution for the problem Failed to build vmnet
for kernel 3.19 and earlier versions. Thus this is not my actual problem and is only intended to help future readers.
Question
When I want to run VMware Workstation or VMware Player for the first time, it needs to deploy some packages at kernel level but it fails with this line of error.
Failed to build vmnet. Failed to execute the build command.
What should I do to resolve this problem?
Solution
-
Change directory into the vmware module source directory.
[1]
cd /usr/lib/vmware/modules/source
-
Untar the vmnet modules.
[1]
sudo tar -xvf vmnet.tar
-
Open
vmnet-only/driver.c
with your favorite text editor.sudo gedit vmnet-only/driver.c
-
Around line 267, change the following
[2]
if (filp && filp->f_op && filp->f_op->ioctl == VNetFileOpIoctl) { ret = VNetFileOpIoctl(filp->f_dentry->d_inode, filp, iocmd, ioarg); } return ret;
to
#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
-
Around line 1194, change the following
[2]
if (filp && filp->f_dentry) { inode = filp->f_dentry->d_inode; } err = VNetFileOpIoctl(inode, filp, iocmd, ioarg); return err;
to
#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
-
Save this file and then open file
vmnet-only/userif.c
sudo gedit vmnet-only/userif.c
-
Around line 526, change the following
[2]
return skb_copy_datagram_iovec(skb, 0, &iov, len);
to
#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
-
Save this file and then re-tar the modules.
[1]
sudo tar -uvf vmnet.tar vmnet-only
-
Delete the previous working directory.
[1]
sudo rm -r vmnet-only
Run the GUI (Workstation or Player) again and let it to build the modules.
References
[1]
: An answer from nonsleepr.[2]
: A write-up from Robert Gadsdon.
Thanks budiap for posting patch for Workstation 10! It just took me a while to figure out that you need to use that code to apply that code to a patch file. Here is the post I made to vmware workstation forums.
OKAY! I got it. Workstation 10 on Ubuntu15.04, or whatever-buntu. I tested this on Xubuntu 15.04 Kernel 3.19.0-18-generic
Created new pastie(10215458) for patch for Workstation 10.
After fresh install of Workstation 10.06 Specifically - > VMware-Workstation-Full-10.0.6-2700073.x86_64.bundle
Must be root, but you can basically copy/paste.
curl http://pastie.org/pastes/10215458/download -o /tmp/vmnet-3.19.patch_ws10
cd /usr/lib/vmware/modules/source
tar -xf vmnet.tar
patch -p0 -i /tmp/vmnet-3.19.patch_ws10
mv vmnet.tar vmnet.tar.SAVED
tar -cf vmnet.tar vmnet-only
rm -r vmnet-only
vmware-modconfig --console --install-all
if you are running vmware workstation 10, apply this patch to make it work on kernel 3.19
diff -rupN vmnet-only/driver.c vmnet-only-modified/driver.c
--- vmnet-only/driver.c 2015-01-17 09:25:58.000000000 +0800
+++ vmnet-only-modified/driver.c 2015-05-07 14:53:18.272218785 +0800
@@ -265,10 +265,17 @@ LinuxDriver_Ioctl32_Handler(unsigned int
{
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 @@ VNetFileOpUnlockedIoctl(struct file *
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 -rupN vmnet-only/netif.c vmnet-only-modified/netif.c
--- vmnet-only/netif.c 2015-01-17 09:25:58.000000000 +0800
+++ vmnet-only-modified/netif.c 2015-05-07 14:51:43.326885576 +0800
@@ -149,7 +149,7 @@ VNetNetIf_Create(char *devName, // IN:
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 -rupN vmnet-only/userif.c vmnet-only-modified/userif.c
--- vmnet-only/userif.c 2015-01-17 09:25:58.000000000 +0800
+++ vmnet-only-modified/userif.c 2015-05-07 14:52:32.095595913 +0800
@@ -523,7 +523,13 @@ VNetCopyDatagram(const struct sk_buff *s
.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
}