pkgsrc-Changes archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

CVS commit: pkgsrc/sysutils/xe-guest-utilities



Module Name:    pkgsrc
Committed By:   sborrill
Date:           Mon Mar 31 12:26:19 UTC 2025

Modified Files:
        pkgsrc/sysutils/xe-guest-utilities: Makefile distinfo
        pkgsrc/sysutils/xe-guest-utilities/files: xenguest.sh
        pkgsrc/sysutils/xe-guest-utilities/patches: patch-xe-update-guest-attrs

Log Message:
xe-guest-utilities: Add support for FreeBSD

Add runtime detection of OS to determine how to retrieve statistics.
Support FreeBSD rc.d system.
Tested on NetBSD 10.1 and FreeBSD 14.2


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 pkgsrc/sysutils/xe-guest-utilities/Makefile
cvs rdiff -u -r1.8 -r1.9 pkgsrc/sysutils/xe-guest-utilities/distinfo
cvs rdiff -u -r1.5 -r1.6 pkgsrc/sysutils/xe-guest-utilities/files/xenguest.sh
cvs rdiff -u -r1.5 -r1.6 \
    pkgsrc/sysutils/xe-guest-utilities/patches/patch-xe-update-guest-attrs

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: pkgsrc/sysutils/xe-guest-utilities/Makefile
diff -u pkgsrc/sysutils/xe-guest-utilities/Makefile:1.17 pkgsrc/sysutils/xe-guest-utilities/Makefile:1.18
--- pkgsrc/sysutils/xe-guest-utilities/Makefile:1.17    Thu Jun  1 08:03:05 2023
+++ pkgsrc/sysutils/xe-guest-utilities/Makefile Mon Mar 31 12:26:19 2025
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.17 2023/06/01 08:03:05 sborrill Exp $
+# $NetBSD: Makefile,v 1.18 2025/03/31 12:26:19 sborrill Exp $
 #
 
 # Values from XenServer 7.0 = 7, 0, 0, 125243
@@ -15,17 +15,18 @@ VERSION=    ${XENMAJOR}.${XENMINOR}.${XENTE
 DISTNAME=      xe-guest-utilities_5.6.0-595
 CATEGORIES=    sysutils
 PKGNAME=       xe-guest-utilities-${VERSION}
-PKGREVISION=   1
+PKGREVISION=   2
 MASTER_SITES=  http://updates.vmd.citrix.com/XenServer/5.6.0/debian/pool/main/x/xe-guest-utilities/
 
 MAINTAINER=    sborrill%NetBSD.org@localhost
 HOMEPAGE=      http://www.xenserver.com/
-COMMENT=       NetBSD VM tools for Citrix XenServer
+COMMENT=       VM tools for Citrix XenServer
 LICENSE=       gnu-gpl-v2
 
 DEPENDS+=      xenstoretools-[0-9]*:../../sysutils/xenstoretools
 
 ONLY_FOR_PLATFORM+=    NetBSD-*-x86_64 NetBSD-*-i386
+ONLY_FOR_PLATFORM+=    FreeBSD-*-x86_64
 
 WRKSRC=                ${WRKDIR}/${DISTNAME:C/-[0-9]+$$//:C/_/-/}
 
@@ -34,6 +35,15 @@ SRCFILES=    xe-daemon xe-update-guest-attr
 NO_CONFIGURE=  yes
 NO_BUILD=      yes
 
+.include "../../mk/bsd.prefs.mk"
+
+RCVARSUFFIX=   ""
+.if ${OPSYS} == "FreeBSD"
+RCVARSUFFIX=   "_enable"
+.endif
+
+FILES_SUBST+=  RCVARSUFFIX=${RCVARSUFFIX}
+
 RCD_SCRIPTS=           xenguest
 SUBST_CLASSES+=                paths
 SUBST_STAGE.paths=     pre-install

Index: pkgsrc/sysutils/xe-guest-utilities/distinfo
diff -u pkgsrc/sysutils/xe-guest-utilities/distinfo:1.8 pkgsrc/sysutils/xe-guest-utilities/distinfo:1.9
--- pkgsrc/sysutils/xe-guest-utilities/distinfo:1.8     Tue Oct 26 11:20:24 2021
+++ pkgsrc/sysutils/xe-guest-utilities/distinfo Mon Mar 31 12:26:19 2025
@@ -1,7 +1,7 @@
-$NetBSD: distinfo,v 1.8 2021/10/26 11:20:24 nia Exp $
+$NetBSD: distinfo,v 1.9 2025/03/31 12:26:19 sborrill Exp $
 
 BLAKE2s (xe-guest-utilities_5.6.0-595.tar.gz) = db8ea8a8f3d693e87109ad9311c116aa5fddb50a9c0bb8462d1bdef4e4cb0ace
 SHA512 (xe-guest-utilities_5.6.0-595.tar.gz) = b34cb8afac674fe6d40fda44a03183392c690965ccfb7c708f30c53fb70770b6e3900563356bce3722f37263170dcb368a0725b6f0bb5730e78636c990394061
 Size (xe-guest-utilities_5.6.0-595.tar.gz) = 454235 bytes
 SHA1 (patch-xe-daemon) = 3107fa2e018d66a2ca37b1c2a748c65aa1be3e2f
-SHA1 (patch-xe-update-guest-attrs) = 50ef7dfc69868b939fa492cb8b01510e7dd022bc
+SHA1 (patch-xe-update-guest-attrs) = effd5f9fb94b44bb2e22c209a6629cdeb84ef146

Index: pkgsrc/sysutils/xe-guest-utilities/files/xenguest.sh
diff -u pkgsrc/sysutils/xe-guest-utilities/files/xenguest.sh:1.5 pkgsrc/sysutils/xe-guest-utilities/files/xenguest.sh:1.6
--- pkgsrc/sysutils/xe-guest-utilities/files/xenguest.sh:1.5    Mon Apr 20 08:05:30 2015
+++ pkgsrc/sysutils/xe-guest-utilities/files/xenguest.sh        Mon Mar 31 12:26:19 2025
@@ -1,6 +1,6 @@
 #!@RCD_SCRIPTS_SHELL@
 #
-# $NetBSD: xenguest.sh,v 1.5 2015/04/20 08:05:30 sborrill Exp $
+# $NetBSD: xenguest.sh,v 1.6 2025/03/31 12:26:19 sborrill Exp $
 #
 # PROVIDE: xenguest
 # REQUIRE: DAEMON
@@ -10,7 +10,7 @@
 $_rc_subr_loaded . /etc/rc.subr
 
 name="xenguest"
-rcvar=$name
+rcvar="${name}@RCVARSUFFIX@"
 command="@PREFIX@/sbin/xe-daemon"
 start_cmd="xenguest_start"
 start_precmd="xenguest_precmd"
@@ -23,7 +23,7 @@ xenguest_precmd()
 {
        XE_LINUX_DISTRIBUTION_CACHE=@VARBASE@/cache/xe-linux-distribution
        
-       if [ ! -f ${xenbus_path} ]; then
+       if [ -d "/kern" -a ! -f ${xenbus_path} ]; then
                echo "${name}: Cannot find ${xenbus_path}!"
                exit 1
        fi

Index: pkgsrc/sysutils/xe-guest-utilities/patches/patch-xe-update-guest-attrs
diff -u pkgsrc/sysutils/xe-guest-utilities/patches/patch-xe-update-guest-attrs:1.5 pkgsrc/sysutils/xe-guest-utilities/patches/patch-xe-update-guest-attrs:1.6
--- pkgsrc/sysutils/xe-guest-utilities/patches/patch-xe-update-guest-attrs:1.5  Sat Apr 25 20:53:02 2020
+++ pkgsrc/sysutils/xe-guest-utilities/patches/patch-xe-update-guest-attrs      Mon Mar 31 12:26:19 2025
@@ -1,23 +1,136 @@
-$NetBSD: patch-xe-update-guest-attrs,v 1.5 2020/04/25 20:53:02 rillig Exp $
+$NetBSD: patch-xe-update-guest-attrs,v 1.6 2025/03/31 12:26:19 sborrill Exp $
 
-Support pkgsrc and NetBSD ifconfig
+Support pkgsrc, NetBSD/FreeBSD ifconfig and FreeBSD memory stats
 
 --- xe-update-guest-attrs.orig 2010-12-20 15:34:07.000000000 +0000
-+++ xe-update-guest-attrs      2018-10-25 17:10:36.997953256 +0100
-@@ -39,7 +39,7 @@
++++ xe-update-guest-attrs      2025-03-28 12:41:56.862749000 +0000
+@@ -39,11 +39,27 @@
  
  IPADDR_RE="\([[:digit:]]\{1,3\}\.\)\{3\}[[:digit:]]\{1,3\}"
  
 -export PATH=/usr/sbin:/usr/bin:/sbin:/bin
+-XENSTORE=${XENSTORE:-xenstore}
 +export PATH=/usr/sbin:/usr/bin:/sbin:/bin:@PREFIX@/sbin:@PREFIX@/bin
- XENSTORE=${XENSTORE:-xenstore}
++XENSTORE=${XENSTORE:-@PREFIX@/bin/xenstore}
  
++CACHEROOT="@VARBASE@/cache/xenstore"
  XENSTORE_UPDATED=0
-@@ -132,50 +132,66 @@
+ 
++case `uname -s` in
++NetBSD)
++      os=netbsd
++      sysctl_balloon="machdep.xen.balloon.current"
++      ;;
++FreeBSD)
++      os=freebsd
++      sysctl_balloon="dev.xen.balloon.current"
++      ;;
++*)
++      echo "OS not supported" > /dev/stderr
++      exit 1
++      ;;
++esac
++
+ # parse command line opts
+ 
+ MEMORY_MODE=0 # do not update memory stats 
+@@ -56,7 +72,7 @@
+ 
+ xenstore_write_cached() {
+     key="$1" newval="$2"
+-    cache=/var/cache/xenstore/$key
++    cache=${CACHEROOT}/$key
+     if [ -f $cache ] ; then
+       # cache exists
+       oldval=$(cat "$cache")
+@@ -84,13 +100,13 @@
+ 
+ # If we detect a domain change then delete our cache and force a refresh
+ domid=$(xenstore-read "domid")
+-cache=/var/cache/xenstore/unique-domain-id
++cache=${CACHEROOT}/unique-domain-id
+ newval=$(xenstore-read "/local/domain/${domid}/unique-domain-id")
+ if [ -e $cache ]; then
+     oldval=$(cat "$cache")
+     if [ "$oldval" != "$newval" ]; then
+       # domain changed
+-      rm -rf /var/cache/xenstore
++      rm -rf ${CACHEROOT}
+     fi
  fi
+ mkdir -p $(dirname "$cache")
+@@ -112,7 +128,7 @@
+ }
  
+ xenstore_list_interfaces_cached() {
+-    topdir=/var/cache/xenstore/attr
++    topdir=${CACHEROOT}/attr
+     if [ -d $topdir ] ; then
+       cd $topdir 
+       for dir in * ; do 
+@@ -121,61 +137,113 @@
+     fi
+ }
+ 
++# Memory needs to be reported in kB
++# NetBSD:
++# cat /proc/meminfo
++#        total:    used:    free:  shared: buffers: cached:
++#Mem:  16616656896 4481732608 12134924288        0 4078817280 4106203136
++#Swap: 1073737728        0 1073737728
++#MemTotal:  16227204 kB
++#MemFree:   11850512 kB
++#MemShared:        0 kB
++#Buffers:   11850512 kB
++#Cached:     4009964 kB
++#SwapTotal:  1048572 kB
++#SwapFree:   1048572 kB
++
++# FreeBSD:
++# Inspired by https://github.com/ocochard/myscripts/blob/master/FreeBSD/freebsd-memory.sh
++
+ if [ $MEMORY_MODE -eq 1 ] ; then
+-    # Update the memory information
+-    eval $(cat /proc/meminfo | \
+-      sed -n -e 's/MemTotal\: *\([0-9]*\)[^$]*/memtotal=\1/gp;' \
+-        -e 's/MemFree\: *\([0-9]*\)[^$]*/memfree=\1/gp;')
+-    
+-    xenstore_write_cached "data/meminfo_total" "${memtotal}"
+-    xenstore_write_cached "data/meminfo_free" "${memfree}"
++      # Update the memory information
++      case "$os" in
++      netbsd)
++              eval $(cat /proc/meminfo | \
++              sed -n -e 's/MemTotal\: *\([0-9]*\)[^$]*/memtotal=\1/gp;' \
++              -e 's/MemFree\: *\([0-9]*\)[^$]*/memfree=\1/gp;')
++              ;;
++      freebsd)
++              memtotal=`sysctl -n hw.physmem`
++              memtotal=$(($memtotal/1024))
++              pagesize=`sysctl -n hw.pagesize`
++              freepages=`sysctl -n vm.stats.vm.v_free_count`
++              memfree=$(($freepages*$pagesize))
++              ;;
++      esac
++      xenstore_write_cached "data/meminfo_total" "${memtotal}"
++      xenstore_write_cached "data/meminfo_free" "${memfree}"
+ fi
+ 
+ 
++#NetBSD 7 and earlier:
++#
++#xennet0: flags=8863<UP,BROADCAST,NOTRAILERS,RUNNING,SIMPLEX,MULTICAST> mtu 1500
++#     capabilities=2800<TCP4CSUM_Tx,UDP4CSUM_Tx>
++#     enabled=0
++#     address: 0e:7e:86:20:7b:82
++#     inet 192.168.1.109 netmask 0xffffff00 broadcast 192.168.1.255
++#     inet alias 10.20.30.40 netmask 0xffffff00 broadcast 10.20.30.255
++#     inet6 fe80::c7e:86ff:fe20:7b82%xennet0 prefixlen 64 scopeid 0x1
++#lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> mtu 33184
++#     inet 127.0.0.1 netmask 0xff000000
++#     inet6 ::1 prefixlen 128
++#     inet6 fe80::1%lo0 prefixlen 64 scopeid 0x2
  
--
 -# e.g.
 -# $ ip addr show
 -# 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue 
@@ -32,11 +145,29 @@ Support pkgsrc and NetBSD ifconfig
 -#        valid_lft forever preferred_lft forever
 -# 3: sit0: <NOARP> mtu 1480 qdisc noop 
 -#     link/sit 0.0.0.0 brd 0.0.0.0
--
++#NetBSD 8 and later:
++#
++#xennet0: flags=0x8863<UP,BROADCAST,NOTRAILERS,RUNNING,SIMPLEX,MULTICAST> mtu 1500
++#     capabilities=2800<TCP4CSUM_Tx,UDP4CSUM_Tx>
++#     enabled=0ec_capabilities=1<VLAN_MTU>
++#     ec_enabled=0
++#     address: 5e:a4:a1:fc:eb:70
++#     inet 192.168.1.17/24 broadcast 192.168.1.255 flags 0x0
++#     inet 10.20.30.40/16 broadcast 10.20.255.255 flags 0x0
++#     inet6 fe80::5ca4:a1ff:fefc:eb70%xennet0/64 flags 0x0 scopeid 0x1
+ 
 -#eval $(ip addr show | \
 -#       sed -n -e 's/^[[:digit:]]*: \([a-z0-9]*\): .*/ifs="\$ifs \1"; current="\1"; /gp;' \
 -#           -e 's/^[[:space:]]\{4\}inet \('${IPADDR_RE}'\)\/.*/eval inet_\${current}="\1"; /gp;')
--
++#FreeBSD 14:
++#xn0: flags=1008843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST,LOWER_UP> metric 0 mtu 1500
++#        options=503<RXCSUM,TXCSUM,TSO4,LRO>
++#        ether 96:fe:50:f8:b9:e6
++#        inet 192.168.1.81 netmask 0xffffff00 broadcast 192.168.1.255
++#        media: Ethernet manual
++#        status: active
++#        nd6 options=29<PERFORMNUD,IFDISABLED,AUTO_LINKLOCAL>
+ 
 -# e.g.
 -# eth0      Link encap:Ethernet  HWaddr 00:13:20:95:E8:74  
 -#           inet addr:172.31.0.57  Bcast:172.31.15.255  Mask:255.255.240.0
@@ -56,43 +187,17 @@ Support pkgsrc and NetBSD ifconfig
 -#           TX packets:32928 errors:0 dropped:0 overruns:0 carrier:0
 -#           collisions:0 txqueuelen:0 
 -#           RX bytes:3604609 (3.4 MiB)  TX bytes:3604609 (3.4 MiB)
--
--eval $(/sbin/ifconfig | \
--        sed -n -e '/^[0-9a-z][0-9a-z]*\:/,/^$/d' \
--               -e 's/^\([0-9a-z][0-9a-z]*\) .*/ifs="\$ifs \1"; current="\1"; /gp;' \
--               -e 's/  *inet addr:\('$IPADDR_RE'\) .*/eval inet_\${current}="\1"; /gp;')
-+#NetBSD 7 and earlier:
-+#
-+#xennet0: flags=8863<UP,BROADCAST,NOTRAILERS,RUNNING,SIMPLEX,MULTICAST> mtu 1500
-+#     capabilities=2800<TCP4CSUM_Tx,UDP4CSUM_Tx>
-+#     enabled=0
-+#     address: 0e:7e:86:20:7b:82
-+#     inet 192.168.1.109 netmask 0xffffff00 broadcast 192.168.1.255
-+#     inet alias 10.20.30.40 netmask 0xffffff00 broadcast 10.20.30.255
-+#     inet6 fe80::c7e:86ff:fe20:7b82%xennet0 prefixlen 64 scopeid 0x1
-+#lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> mtu 33184
-+#     inet 127.0.0.1 netmask 0xff000000
-+#     inet6 ::1 prefixlen 128
-+#     inet6 fe80::1%lo0 prefixlen 64 scopeid 0x2
-+
-+#NetBSD 8 and later:
-+#
-+#xennet0: flags=0x8863<UP,BROADCAST,NOTRAILERS,RUNNING,SIMPLEX,MULTICAST> mtu 1500
-+#     capabilities=2800<TCP4CSUM_Tx,UDP4CSUM_Tx>
-+#     enabled=0ec_capabilities=1<VLAN_MTU>
-+#     ec_enabled=0
-+#     address: 5e:a4:a1:fc:eb:70
-+#     inet 192.168.1.17/24 broadcast 192.168.1.255 flags 0x0
-+#     inet 10.20.30.40/16 broadcast 10.20.255.255 flags 0x0
-+#     inet6 fe80::5ca4:a1ff:fefc:eb70%xennet0/64 flags 0x0 scopeid 0x1
-+
 +# Original:
 +#
 +#/sbin/ifconfig | \
 +#        sed -n -e '/^[0-9a-z][0-9a-z]*\:/,/^$/d' \
 +#               -e 's/^\([0-9a-z][0-9a-z]*\) .*/ifs="\$ifs \1"; current="\1"; /gp;' \
 +#               -e 's/  *inet \('$IPADDR_RE'\) .*/eval inet_\${current}="\1"; /gp;'
-+
+ 
+-eval $(/sbin/ifconfig | \
+-        sed -n -e '/^[0-9a-z][0-9a-z]*\:/,/^$/d' \
+-               -e 's/^\([0-9a-z][0-9a-z]*\) .*/ifs="\$ifs \1"; current="\1"; /gp;' \
+-               -e 's/  *inet addr:\('$IPADDR_RE'\) .*/eval inet_\${current}="\1"; /gp;')
 +eval $(/sbin/ifconfig -a | \
 +      awk '{
 +              if ($0~"^[a-z][a-z0-9]*[0-9]:") {
@@ -124,21 +229,21 @@ Support pkgsrc and NetBSD ifconfig
  
  # network
  for if in $ifs ; do
-@@ -206,16 +222,18 @@
+@@ -206,16 +274,18 @@
  fi
  
  # whether I support ballooning or not
 -xenstore_write_cached "control/feature-balloon" "1"
--
--# whether I support ballooning or not
--xenstore_write_cached "control/feature-balloon" "1"
-+sysctl -n machdep.xen.balloon.current > /dev/null 2>&1
++sysctl -n $sysctl_balloon > /dev/null 2>&1
 +if [ "$?" = 0 ]; then
 +      xenstore_write_cached "control/feature-balloon" "1"
 +else
 +      xenstore_write_cached "control/feature-balloon" "0"
 +fi
  
+-# whether I support ballooning or not
+-xenstore_write_cached "control/feature-balloon" "1"
+-
  # build time addons
 -xenstore_write_cached "attr/PVAddons/MajorVersion" "5"
 -xenstore_write_cached "attr/PVAddons/MinorVersion" "6"



Home | Main Index | Thread Index | Old Index