Compare commits

...

2 Commits

Author SHA1 Message Date
bin456789
daa835dddc
windows: 添加腾讯云、GCP virtio 驱动 2025-03-24 21:02:01 +08:00
bin456789
d603169f76
core: 添加 udevadm settle 2025-03-24 21:02:01 +08:00
4 changed files with 143 additions and 22 deletions

View File

@ -395,7 +395,7 @@ bash reinstall.sh windows \
#### The following drivers will automatic download and install as needed, without the need for manual addition
- Virtio ([Virtio][virtio-virtio][Alibaba Cloud][virtio-aliyun])
- Virtio ([Virtio][virtio-virtio], [Alibaba Cloud][virtio-aliyun], [Tencent Cloud][virtio-qcloud], [GCP][virtio-gcp])
- XEN ([~~XEN~~][xen-xen] (unsigned), [Citrix][xen-citrix], [AWS][xen-aws])
- AWS ([ENA Network Adapter][aws-ena], [NVME Storage Controller][aws-nvme])
- GCP ([gVNIC Network Adapter][gcp-gvnic], [GGA Display Adapter][gcp-gga])
@ -404,6 +404,8 @@ bash reinstall.sh windows \
[virtio-virtio]: https://fedorapeople.org/groups/virt/virtio-win/direct-downloads/
[virtio-aliyun]: https://www.alibabacloud.com/help/ecs/user-guide/install-the-virtio-driver-1
[virtio-qcloud]: https://cloud.tencent.com/document/product/213/17815#b84b2032-752c-43c4-a509-73530b8f82ff
[virtio-gcp]: https://console.cloud.google.com/storage/browser/gce-windows-drivers-public
[xen-xen]: https://xenproject.org/resources/downloads/
[xen-aws]: https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/xen-drivers-overview.html
[xen-citrix]: https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/Upgrading_PV_drivers.html#win2008-citrix-upgrade

View File

@ -395,7 +395,7 @@ bash reinstall.sh windows \
#### 以下驱动会自动按需下载安装,无需手动添加
- Virtio ([Virtio][virtio-virtio][阿里云][virtio-aliyun])
- Virtio ([Virtio][virtio-virtio], [阿里云][virtio-aliyun], [腾讯云][virtio-qcloud], [GCP][virtio-gcp])
- XEN ([~~XEN~~][xen-xen] (未签名), [Citrix][xen-citrix], [AWS][xen-aws])
- AWS ([ENA 网卡][aws-ena], [NVME 存储控制器][aws-nvme])
- GCP ([gVNIC 网卡][gcp-gvnic], [GGA 显卡][gcp-gga])
@ -404,6 +404,8 @@ bash reinstall.sh windows \
[virtio-virtio]: https://fedorapeople.org/groups/virt/virtio-win/direct-downloads/
[virtio-aliyun]: https://www.alibabacloud.com/help/ecs/user-guide/install-the-virtio-driver-1
[virtio-qcloud]: https://cloud.tencent.com/document/product/213/17815#b84b2032-752c-43c4-a509-73530b8f82ff
[virtio-gcp]: https://console.cloud.google.com/storage/browser/gce-windows-drivers-public
[xen-xen]: https://xenproject.org/resources/downloads/
[xen-aws]: https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/xen-drivers-overview.html
[xen-citrix]: https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/Upgrading_PV_drivers.html#win2008-citrix-upgrade

View File

@ -7,6 +7,13 @@ set -eE
# openeuler 需等待 udev 将网卡名从 eth0 改为 enp3s0
sleep 10
# 不知道有没有用
if command -v udevadm >/dev/null; then
# udevadm trigger
udevadm settle
elif command -v mdev >/dev/null; then
mdev -sf
fi
# 本脚本在首次进入新系统后运行
# 将 trans 阶段生成的网络配置中的网卡名(eth0) 改为正确的网卡名,也适用于以下情况

150
trans.sh
View File

@ -5136,6 +5136,8 @@ get_cloud_vendor() {
echo huawei
elif is_dmi_contains 'Alibaba Cloud'; then
echo aliyun
elif is_dmi_contains 'Tencent Cloud'; then
echo qcloud
fi
}
@ -5418,9 +5420,25 @@ install_windows() {
if is_virt_contains virtio; then
if [ "$vendor" = aliyun ] && is_nt_ver_ge 6.1 && [ "$arch_wim" = x86_64 ]; then
add_driver_aliyun_virtio
# 未测试是否需要专用驱动
elif [ "$vendor" = qcloud ] && is_nt_ver_ge 6.1 && [ "$arch_wim" = x86_64 ]; then
add_driver_qcloud_virtio
# 未测试是否需要专用驱动
elif false && [ "$vendor" = huawei ] && is_nt_ver_ge 6.0 && { [ "$arch_wim" = x86 ] || [ "$arch_wim" = x86_64 ]; }; then
add_driver_huawei_virtio
# gcp 官方驱动不全,需要用公版补全
elif [ "$vendor" = gcp ] && [ "$nt_ver" = 6.1 ] && [ "$arch_wim" = x86_64 ]; then
add_driver_gcp_virtio_win6_1_sha1_x64
add_driver_generic_virtio \( -iname viorng.inf -or -iname balloon.inf \)
elif [ "$vendor" = gcp ] && is_nt_ver_ge 6.2 && [ "$arch_wim" = x86 ]; then
add_driver_gcp_virtio
add_driver_generic_virtio \( -iname viorng.inf -or -iname pvpanic.inf \)
elif [ "$vendor" = gcp ] && is_nt_ver_ge 6.2 && [ "$arch_wim" = x86_64 ]; then
add_driver_gcp_virtio
add_driver_generic_virtio -iname viorng.inf
else
# 兜底
add_driver_generic_virtio
@ -5753,7 +5771,7 @@ EOF
mount -o ro $drv/virtio.iso $drv/virtio
# -not -ipath "*/balloon/*"
cp_drivers $drv/virtio -ipath "*/$virtio_sys/$arch/*"
cp_drivers $drv/virtio -ipath "*/$virtio_sys/$arch/*" "$@"
else
# coreutils 的 cp mv rm 才有 -v 参数
apk add 7zip file coreutils
@ -5799,10 +5817,54 @@ EOF
mv -v "$file" "$new_file"
done
)
cp_drivers $drv/virtio
cp_drivers $drv/virtio "$@"
fi
}
add_driver_qcloud_virtio() {
info "Add drivers: QCloud virtio"
# 测试版?
# https://mirrors.tencent.com/install/cts/windows/Drivers.zip
apk add 7zip
download https://mirrors.tencent.com/install/windows/virtio_64_1.0.9.exe $drv/virtio.exe
exclude='$*' # 排除 $PLUGINSDIR
override=u # A(u)to rename all
7z x $drv/virtio.exe -o$drv/qcloud/ -ao$override -x!$exclude
# balloon 6.2
# balloon_1 6.1
# netkvm 10.0
# netkvm_1 6.1
# netkvm_2 6.3
# viostor 10.0
# viostor_1 6.1
# viostor_2 6.2
drivers=$(
case "$nt_ver" in
6.1) echo balloon_1 netkvm_1 viostor_1 ;; # sha1
6.2) echo balloon netkvm_1 viostor_2 ;;
6.3) echo balloon netkvm_2 viostor_2 ;;
*) echo balloon netkvm viostor ;;
esac
)
for old_name in $drivers; do
part=${old_name%%_*}
if ! [ "$old_name" = "$part" ]; then
find $drv/qcloud/$part -type f -iname "$old_name.*" | while read -r file; do
ext="${file##*.}"
mv -v "$file" "$drv/qcloud/$part/$part.$ext"
done
fi
cp_drivers $drv/qcloud/$part/$part.inf
done
}
add_driver_huawei_virtio() {
info "Add drivers: Huawei virtio"
@ -5887,35 +5949,83 @@ EOF
fi
}
# gcp
# x86 x86_64 arm64 都有
add_driver_gcp() {
info "Add drivers: GCP"
# gcp virtio win7 x64
# 缺 balloon viorng
add_driver_gcp_virtio_win6_1_sha1_x64() {
info "Add drivers: GCP virtio win6.1 sha1 x64"
mkdir -p $drv/gce/win6.1sha1
for file in \
WdfCoInstaller01009.dll WdfCoInstaller01011.dll \
netkvm.inf netkvm.cat netkvm.sys netkvmco.dll \
nvme.inf nvme64.cat nvme.sys \
pvpanic.inf pvpanic.sys pvpanic.cat \
vioscsi.inf vioscsi.sys vioscsi.cat; do
download https://storage.googleapis.com/gce-windows-drivers-public/win6.1sha1/$file $drv/gce/win6.1sha1/$file
done
cp_drivers $drv/gce/win6.1sha1
}
# gcp virtio win8+
# x86 缺 viorng pvpanic
# x64 缺 viorng
# https://github.com/GoogleCloudPlatform/compute-image-tools/tree/master/daisy_workflows/image_build/windows
# 官方是从 https://console.cloud.google.com/storage/browser/gce-windows-drivers-public 下载驱动,安装系统后再 googet 更新驱动
# 我们一步到位从 googet 下载驱动
add_driver_gcp_virtio() {
info "Add drivers: GCP virtio"
mkdir -p $drv/gce
gce_repo=https://packages.cloud.google.com/yuck
download $gce_repo/repos/google-compute-engine-stable/index /tmp/gce.json
for name in gvnic gga; do
# gvnic 没有 arm64
if [ "$name" = gvnic ] && [ "$arch_wim" = arm64 ]; then
download $gce_repo/repos/google-compute-engine-stable/index $drv/gce/gce.json
for part in balloon netkvm pvpanic vioscsi; do
# gcp 提供的 pvpanic 没有 x86 驱动
if [ "$part" = pvpanic ] && [ "$arch_wim" = x86 ]; then
continue
fi
mkdir -p $drv/gce/$name
link=$(grep -o "/pool/.*-google-compute-engine-driver-$name.*\.goo" /tmp/gce.json)
wget $gce_repo$link -O- | tar xz -C $drv/gce/$name
mkdir -p $drv/gce/$part
link=$(grep -o "/pool/.*-google-compute-engine-driver-$part.*\.goo" $drv/gce/gce.json)
wget $gce_repo$link -O- | tar xz -C $drv/gce/$part
# 没有 win6.0 文件夹
# 但 inf 没限制
# TODO: 测试是否可用
[ "$arch_wim" = x86 ] && suffix=-32 || suffix=
cp_drivers $drv/gce/$part -ipath "*/win$nt_ver$suffix/*"
done
}
# gcp
# x86 x86_64 arm64 都有
# win7 驱动是 sha256 签名
add_driver_gcp() {
info "Add drivers: GCP"
# https://packages.cloud.google.com/yuck/repos/google-compute-engine-stable/index
# https://packages.cloud.google.com/yuck/repos/google-compute-engine-driver-gvnic-gq-stable/index
# 官方镜像的 gvnic 是从 gvnic-gq-stable 获取的,版本低一点,但更稳定?
mkdir -p $drv/gce
gce_repo=https://packages.cloud.google.com/yuck
download $gce_repo/repos/google-compute-engine-stable/index $drv/gce/gce.json
for part in gvnic gga; do
# gvnic 没有 arm64
if [ "$part" = gvnic ] && [ "$arch_wim" = arm64 ]; then
continue
fi
mkdir -p $drv/gce/$part
link=$(grep -o "/pool/.*-google-compute-engine-driver-$part.*\.goo" $drv/gce/gce.json)
wget $gce_repo$link -O- | tar xz -C $drv/gce/$part
# inf 不限版本6.0 能装 6.1 的驱动但用不了
if false; then
for suffix in '' '-32'; do
if [ -d "$drv/gce/$name/win6.1$suffix" ]; then
cp -r "$drv/gce/$name/win6.1$suffix" "$drv/gce/$name/win6.0$suffix"
if [ -d "$drv/gce/$part/win6.1$suffix" ]; then
cp -r "$drv/gce/$part/win6.1$suffix" "$drv/gce/$part/win6.0$suffix"
fi
done
fi
case "$name" in
case "$part" in
gvnic)
[ "$arch_wim" = x86 ] && suffix=-32 || suffix=
cp_drivers $drv/gce/gvnic -ipath "*/win$nt_ver$suffix/*"