diff --git a/packages/pve-common/autobuild.sh b/packages/pve-common/autobuild.sh new file mode 100644 index 0000000..02f0ba2 --- /dev/null +++ b/packages/pve-common/autobuild.sh @@ -0,0 +1,10 @@ +#!/bin/bash +SCRIPT_DIR=$(cd $(dirname ${BASH_SOURCE[0]}); pwd) +PKGNAME=$(basename $SCRIPT_DIR) + +echo "This is $PKGNAME build scripts" + +source $SCRIPT_DIR/../common.sh + +cd $SCRIPT_DIR/$PKGNAME +exec_build_make diff --git a/packages/pve-common/patches/pxcloud/001-add-pxcloud.patch b/packages/pve-common/patches/pxcloud/001-add-pxcloud.patch new file mode 100644 index 0000000..e6235ac --- /dev/null +++ b/packages/pve-common/patches/pxcloud/001-add-pxcloud.patch @@ -0,0 +1,151 @@ +diff --git a/src/Makefile b/src/Makefile +index 2d8bdc4..3facba9 100644 +--- a/src/Makefile ++++ b/src/Makefile +@@ -42,6 +42,8 @@ install: $(addprefix PVE/,${LIB_SOURCES}) + install -d -m 0755 ${DESTDIR}${PERLDIR}/PVE + install -d -m 0755 ${DESTDIR}${PERLDIR}/PVE/Job + for i in ${LIB_SOURCES}; do install -D -m 0644 PVE/$$i ${DESTDIR}${PERLDIR}/PVE/$$i; done ++ install -d -m 0755 ${DESTDIR}/usr/bin/ ++ install -D -m 0755 bin/parse_arm_cpu_name ${DESTDIR}/usr/bin/ + + + .PHONY: clean +diff --git a/src/PVE/ProcFSTools.pm b/src/PVE/ProcFSTools.pm +index 3826fcc..4008149 100644 +--- a/src/PVE/ProcFSTools.pm ++++ b/src/PVE/ProcFSTools.pm +@@ -10,7 +10,7 @@ use POSIX; + use Socket qw(PF_INET PF_INET6 SOCK_DGRAM IPPROTO_IP); + use Time::HiRes qw (gettimeofday); + +-use PVE::Tools; ++use PVE::Tools qw(get_host_arch); + + use constant IFF_UP => 1; + use constant IFNAMSIZ => 16; +@@ -57,6 +57,21 @@ sub read_cpuinfo { + } + } + ++ my $arch = get_host_arch(); ++ if ($arch eq 'aarch64' && $res->{model} eq 'unknown'){ ++ my $cpuinfo = "/tmp/cpu_model"; ++ my $cpu_model; ++ if (-e $cpuinfo) { ++ open my $fh, "<", $cpuinfo; ++ while (my $line = <$fh>) { ++ chomp $line; ++ $cpu_model .= $line; ++ } ++ close $fh; ++ $res->{model} = $cpu_model; ++ } ++ } ++ + # Hardware Virtual Machine (Intel VT / AMD-V) + $res->{hvm} = $res->{flags} =~ m/\s(vmx|svm)\s/; + +diff --git a/src/PVE/SysFSTools.pm b/src/PVE/SysFSTools.pm +index cf9854b..8b09744 100644 +--- a/src/PVE/SysFSTools.pm ++++ b/src/PVE/SysFSTools.pm +@@ -91,6 +91,10 @@ sub lspci { + my $vendor = file_read_firstline("$devdir/vendor"); + my $device = file_read_firstline("$devdir/device"); + my $class = file_read_firstline("$devdir/class"); ++ my $driver_inuse = `lspci -ks $fullid|grep 'in use'|cut -d ":" -f2`; ++ my $driver = `lspci -ks $fullid|grep 'Kernel modules'|cut -d ":" -f2`; ++ chomp($driver_inuse); ++ chomp($driver); + + my $res = { + id => $id, +@@ -134,6 +138,8 @@ sub lspci { + $res->{subsystem_device} = $sub_device if defined($sub_device); + $res->{subsystem_vendor_name} = $sub_vendor_name if defined($sub_vendor_name); + $res->{subsystem_device_name} = $sub_device_name if defined($sub_device_name); ++ $res->{driver_inuse} = $driver_inuse; ++ $res->{driver} = $driver; + } + + push @$devices, $res; +@@ -460,5 +466,69 @@ sub scan_usb { + + return $devlist; + } ++sub pcitool { ++ my ($pciid,$options,$driver) = @_; ++ ++ my $basedir = "$pcisysfs/devices/$pciid"; ++ ++ die "Cannot find $pciid device!\n" if !-d $basedir; ++ ++ if ( $options eq 'bind' ){ ++ if (!defined $driver) { ++ $driver = 'vfio-pci'; ++ } ++ if (!-d "/sys/bus/pci/drivers/$driver") { ++ system("/bin/modprobe $driver >/dev/null 2>/dev/null"); ++ } ++ die "Cannot find $driver module!\n" if !-d "/sys/bus/pci/drivers/$driver"; ++ die "Cannot bind $driver when device is bind\n" if -d "/sys/bus/pci/device/$pciid/driver"; ++ file_write("/sys/bus/pci/drivers/$driver/bind",$pciid); ++ } elsif ( $options eq 'unbind' ){ ++ file_write("$basedir/driver/unbind",$pciid); ++ } elsif ( $options eq 'reset' ){ ++ file_write("$basedir/remove","1"); ++ if ( -f "/sys/bus/pci/device/$pciid/reset" ){ ++ file_write("/sys/bus/pci/device/$pciid/reset","1"); ++ }else{ ++ file_write("/sys/bus/pci/rescan","1"); ++ } ++ } ++} ++ ++sub pciprobe { ++ my ($pciid,$blacklist,$driver,$clean) = @_; ++ ++ $blacklist = 0 if ! defined $blacklist; ++ ++ my $basedir = "/etc/modules-load.d/"; ++ my $blacklistdir = "/etc/modprobe.d/"; ++ ++ die "OS ERROR!\n" if !-d $basedir; ++ die "OS ERROR!\n" if !-d $blacklistdir; ++ ++ if (defined $clean && $clean ){ ++ system("rm -rf $blacklistdir/$pciid*.conf"); ++ system("rm -rf $basedir/$pciid*.conf"); ++ return "ok"; ++ } ++ ++ if (! $blacklist ) { ++ if (!defined $driver) { ++ $driver = 'vfio-pci'; ++ } ++ if (!-d "/sys/bus/pci/drivers/$driver") { ++ system("/bin/modprobe $driver >/dev/null 2>/dev/null"); ++ } ++ die "Cannot find $driver module!\n" if !-d "/sys/bus/pci/drivers/$driver"; ++ system("rm $basedir/$pciid.conf") if -f "$basedir/$pciid.conf"; ++ my $str = "options vfio-pci ids=$pciid"; ++ file_write("$basedir/$pciid.conf",$str); ++ } else { ++ system("rm $blacklistdir/$pciid-$driver-blacklist.conf") if -f "$blacklistdir/$pciid-$driver-blacklist.conf"; ++ my $str = "blacklist $driver"; ++ file_write("/etc/modprobe.d/$pciid-$driver-blacklist.conf",$str); ++ } ++ ++} + + 1; +diff --git a/src/bin/parse_arm_cpu_name b/src/bin/parse_arm_cpu_name +new file mode 100755 +index 0000000..a8f3c04 +--- /dev/null ++++ b/src/bin/parse_arm_cpu_name +@@ -0,0 +1,2 @@ ++#!/bin/bash ++lscpu | grep "BIOS Model name" | cut -d ":" -f 2|sed s/^[[:space:]]*// > /tmp/cpu_model +\ No newline at end of file diff --git a/packages/pve-common/series b/packages/pve-common/series index 5ee3520..de32d96 100644 --- a/packages/pve-common/series +++ b/packages/pve-common/series @@ -1,2 +1,3 @@ patches/001-add-for-port.patch patches/changelog/001-add-changlog.patch +patches/pxcloud/001-add-pxcloud.patch