From: Oliver Kurth Date: Thu, 13 Feb 2020 00:49:09 +0000 (-0800) Subject: FreeBSD kernel API changes with FreeBSD 13.0 (development) X-Git-Tag: stable-11.1.0~69 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7d022445fa482856df3a6fc590c1d97857a618d0;p=thirdparty%2Fopen-vm-tools.git FreeBSD kernel API changes with FreeBSD 13.0 (development) VOP_UNLOCK(): second argument "flags" has been dropped when the kernel version is >= 1300074. The timeout(9) interface has been deprecated and must be replaced with callout(9) (v2) when the kernel version >= 1300067. https://github.com/vmware/open-vm-tools/pull/398 --- diff --git a/open-vm-tools/AUTHORS b/open-vm-tools/AUTHORS index 026de07e6..814797509 100644 --- a/open-vm-tools/AUTHORS +++ b/open-vm-tools/AUTHORS @@ -53,3 +53,6 @@ Haruki Tsurumoto Fix Asianux identification MilhouseVH stop systemd-243 udev complaints - https://github.com/vmware/open-vm-tools/pull/371 +Josh Paetzel Changes to vmmemctl.ko and vmblock.ko for FreeBSD 13.0 API changes. + - https://github.com/vmware/open-vm-tools/pull/398 + diff --git a/open-vm-tools/modules/freebsd/shared/compat_vop.h b/open-vm-tools/modules/freebsd/shared/compat_vop.h index f76bba507..60ef863f3 100644 --- a/open-vm-tools/modules/freebsd/shared/compat_vop.h +++ b/open-vm-tools/modules/freebsd/shared/compat_vop.h @@ -1,5 +1,5 @@ /********************************************************* - * Copyright (C) 2008 VMware, Inc. All rights reserved. + * Copyright (C) 2008, 2020 VMware, Inc. All rights reserved. * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the @@ -47,7 +47,11 @@ #if __FreeBSD_version >= 800011 #define COMPAT_THREAD_VAR(varname, varval) #define COMPAT_VOP_LOCK(vop, flags, threadvar) VOP_LOCK((vop), (flags)) +#if __FreeBSD_version >= 1300074 +#define COMPAT_VOP_UNLOCK(vop, flags, threadvar) VOP_UNLOCK((vop)) +#else #define COMPAT_VOP_UNLOCK(vop, flags, threadvar) VOP_UNLOCK((vop), (flags)) +#endif #define compat_lockstatus(lock, threadvar) lockstatus((lock)) #define compat_lockmgr(lock, flags, randompointerparam, threadval) lockmgr((lock), (flags), (randompointerparam)) #define compat_vn_lock(vp, flags, threadval) vn_lock((vp), (flags)) diff --git a/open-vm-tools/modules/freebsd/vmblock/vnops.c b/open-vm-tools/modules/freebsd/vmblock/vnops.c index b49925c8e..6fbef7d16 100644 --- a/open-vm-tools/modules/freebsd/vmblock/vnops.c +++ b/open-vm-tools/modules/freebsd/vmblock/vnops.c @@ -1,5 +1,5 @@ /* ********************************************************** - * Copyright 2007-2014 VMware, Inc. All rights reserved. -- VMware Confidential + * Copyright 2007-2014, 2020 VMware, Inc. All rights reserved. -- VMware Confidential * **********************************************************/ /* @@ -1262,12 +1262,15 @@ struct vop_unlock_args { */ { struct vnode *vp = ap->a_vp; +#if __FreeBSD_version < 1300074 int flags = ap->a_flags; +#endif COMPAT_THREAD_VAR(td, ap->a_td); struct VMBlockNode *nn; struct vnode *lvp; int error; +#if __FreeBSD_version < 1300074 /* * If caller already holds interlock, drop it. (Per VOP_UNLOCK() API.) * Also strip LK_INTERLOCK from flags passed to lower layer. @@ -1276,9 +1279,14 @@ struct vop_unlock_args { VI_UNLOCK(vp); ap->a_flags = flags &= ~LK_INTERLOCK; } +#endif nn = VPTOVMB(vp); if (nn != NULL && (lvp = VMBVPTOLOWERVP(vp)) != NULL) { +#if __FreeBSD_version < 1300074 error = COMPAT_VOP_UNLOCK(lvp, flags, td); +#else + error = COMPAT_VOP_UNLOCK(lvp, 0, td); +#endif } else { error = vop_stdunlock(ap); } diff --git a/open-vm-tools/modules/freebsd/vmmemctl/os.c b/open-vm-tools/modules/freebsd/vmmemctl/os.c index 55cb52b6f..20ec9d005 100644 --- a/open-vm-tools/modules/freebsd/vmmemctl/os.c +++ b/open-vm-tools/modules/freebsd/vmmemctl/os.c @@ -1,5 +1,5 @@ /********************************************************* - * Copyright (C) 2000,2014,2018-2019 VMware, Inc. All rights reserved. + * Copyright (C) 2000,2014,2018-2020 VMware, Inc. All rights reserved. * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the @@ -64,7 +64,11 @@ typedef struct { /* system structures */ +#if __FreeBSD_version >= 1300067 + struct callout callout_handle; +#else struct callout_handle callout_handle; +#endif /* termination flag */ volatile int stop; @@ -678,7 +682,12 @@ vmmemctl_poll(void *data) // IN if (!t->stop) { /* invoke registered handler, rearm timer */ Balloon_QueryAndExecute(); +#if __FreeBSD_version >= 1300067 + callout_reset(&t->callout_handle, BALLOON_POLL_PERIOD * hz, vmmemctl_poll, + t); +#else t->callout_handle = timeout(vmmemctl_poll, t, BALLOON_POLL_PERIOD * hz); +#endif } } @@ -712,15 +721,23 @@ vmmemctl_init(void) } /* initialize timer state */ +#if __FreeBSD_version >= 1300067 + callout_init(&state->timer.callout_handle, 0); +#else callout_handle_init(&state->timer.callout_handle); +#endif os_pmap_init(pmap); os_balloonobject_create(); /* Set up and start polling */ - callout_handle_init(&t->callout_handle); t->stop = FALSE; +#if __FreeBSD_version >= 1300067 + callout_reset(&t->callout_handle, BALLOON_POLL_PERIOD * hz, vmmemctl_poll, + t); +#else t->callout_handle = timeout(vmmemctl_poll, t, BALLOON_POLL_PERIOD * hz); +#endif vmmemctl_init_sysctl(); @@ -759,7 +776,11 @@ vmmemctl_cleanup(void) /* Stop polling */ t->stop = TRUE; +#if __FreeBSD_version >= 1300067 + callout_drain(&t->callout_handle); +#else untimeout(vmmemctl_poll, t, t->callout_handle); +#endif os_balloonobject_delete(); os_pmap_free(pmap);