Date: Fri, 26 Sep 2025 05:39:45 +0000 From: Jonathan Vasquez <jon@xyinn.org> To: "freebsd-virtualization@freebsd.org" <freebsd-virtualization@freebsd.org> Subject: Re: GPU Passthrough on FreeBSD 14.3 (AMD Radeon RX 6900 XT and Windows 10 Pro) Message-ID: <AM8n1JOcrcBRv9mRgY9FL74LTqN3lwdlAuW93tNAE_e_vmiHCRebKb16zWfT0hX66CGSNPpUR-eoFetOypfmPxpTAUzWSwzdyuielSQyLWo=@xyinn.org> In-Reply-To: <INv1QRTDanPqExdkRH9g_SlRzYv6-m_Xg5SWWYjpkvkQ_RqVdS_OuVJgJvQW3ZAnhsS334kzM-0IP0rj4c6MN2WRvws2_FII5XBr1aL5Rw4=@xyinn.org> References: <6CV-OY6BcErrWRit9jSpi6fWsYBG3E_Z3u6eTLPcz6foPAZV1gQpZYaZTR7JA_1ot5RQVqrWQaLxJFySXjspIhSbBJGxmckcDQyzxhALNus=@xyinn.org> <77221679b528434788d667441d1a32a2@userve.net> <44d9286c-0866-4805-827d-5cb91511800b@tilda.center> <mOxiSfmxWrHIMEStshHuwzAKYh003kyxHWvA_NY42h2TJfzeGaYSA5ePY1WNK67MtP_quGeVkFzRTTeSf7ESI-gMBbcoxtr7DeQ24xr5Ntg=@xyinn.org> <3HATaLlOogPiMZWbxSnWPCnJC11_unXloaoQzyF8Ek01s9gZGVqnKKruZgFTrqHQBCi5xWNEzLzK37xiNdn3yCwXG8U7NfXKRmwY8_5xCLw=@xyinn.org> <7CNs3oS07TqJcWsTrJCZmDlAypBuy9yh4xr_iAgGnUOGjqAP5iRl1JMkuna8LwFSNIvphQLojKi214B4w6ef2q2IRgvjdolLwUD8KCnXaSQ=@xyinn.org> <9c53f1805e22fcf2c9eb878e0c7cc9a723c30dd8.camel@FreeBSD.org> <-rzPcOUnhEy7jFcu7cF7V_kjAVPV_2deuhv7EY-eJl536fUllXK-3SSnWq13HStABMZuphkRAysMMhDXvd_MWIlH4QaMGU-8l2nXKeOY-Eo=@xyinn.org> <INv1QRTDanPqExdkRH9g_SlRzYv6-m_Xg5SWWYjpkvkQ_RqVdS_OuVJgJvQW3ZAnhsS334kzM-0IP0rj4c6MN2WRvws2_FII5XBr1aL5Rw4=@xyinn.org>
next in thread | previous in thread | raw e-mail | index | archive | help
I'm continuing my investigation of why I don't see the "Shutting down" mess=
age when I run "shutdown -r now" but I do if I do "service vm_gaming stop".=
I'm wondering if it's actually gracefully shutting down but I just don't s=
ee my monitor update because things are happening quickly. There was 1-2 ti=
mes I did get the "shutdown -r now" to cause my vm to show me that screen, =
but it doesn't show it to me every time. So far I haven't gotten any Window=
s disk corruption or anything, but just not confident about the graceful sh=
utdown.
I implemented a "status" function to see if maybe it's some early terminati=
on logic that's causing it not to run (or exit too early), and I've also re=
placed my "sleep 10" with a proper while loop that will check the existence=
of the child pid. Once the child pid no longer exists, then execution cont=
inues in the stop function.
The script currently looks like this:
#!/bin/sh
# PROVIDE: vm_gaming
# REQUIRE: LOGIN
# KEYWORD: nojail shutdown
. /etc/rc.subr
name=3Dvm_gaming
rcvar=3Dvm_gaming_enable
vm_path=3D"/atlantis/vms/gaming"
vm_name=3D"gaming"
start_cmd=3D"${name}_start"
stop_cmd=3D"${name}_stop"
restart_cmd=3D"${name}_restart"
status_cmd=3D"${name}_status"
pidfile=3D"/var/run/${name}.child.pid"
vm_gaming_start()
{
=09echo "starting gaming vm ..."
=09daemon \
=09=09-o /var/log/${name}.log \
=09=09-p "${pidfile}" \
=09=09bhyve -AHPSw -c sockets=3D1,cores=3D16,threads=3D1 -m 32G \
=09=09-s 0,hostbridge \
=09=09-s 1,nvme,${vm_path}/disk0.img \
=09=09-s 3:0,passthru,3/0/0 \
=09=09-s 3:1,passthru,3/0/1 \
=09=09-s 13:0,passthru,13/0/0 \
=09=09-s 30,xhci,tablet \
=09=09-s 31,lpc \
=09=09-l bootrom,/usr/local/share/uefi-firmware/BHYVE_UEFI.fd,fwcfg=3Dqemu =
\
=09=09-o console=3Dstdio \
=09=09${vm_name}
}
vm_gaming_stop()
{
=09echo "stopping gaming vm ..."
=09# Send SIGTERM twice to make sure Windows listens to
=09# the ACPI shutdown signal.
=09pid=3D"$(cat ${pidfile})"
=09kill ${pid}
=09kill ${pid}
=09# Wait a bit for the guest to shutdown properly before
=09# we continue shutting down the host.
=09is_pid_running=3D"$(ps ${pid} -o pid=3D)"
=09while [ ! -z "${is_pid_running}" ]; do
=09=09is_pid_running=3D"$(ps ${pid} -o pid=3D)"
=09done
=09bhyvectl --vm=3D${vm_name} --destroy
=09echo "gaming vm stopped!"
}
vm_gaming_restart()
{
=09# NOTE: AMD users will most likely experience the famous
=09# AMD Hardware Reset Bug. This means that after you reboot
=09# the guest, you most likely won't have video out. If this
=09# happens, you'll need to restart the host. Sometimes this
=09# command will work for AMD users though. So you can try a
=09# restart and see if it works.
=09vm_gaming_stop
=09vm_gaming_start
}
vm_gaming_status()
{
=09if [ -f "${pidfile}" ]; then
=09=09echo "$(cat ${pidfile})"
=09fi
}
load_rc_config $name
: ${vm_gaming_enable:=3D"NO"}
run_rc_command "$1"
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?AM8n1JOcrcBRv9mRgY9FL74LTqN3lwdlAuW93tNAE_e_vmiHCRebKb16zWfT0hX66CGSNPpUR-eoFetOypfmPxpTAUzWSwzdyuielSQyLWo=>
