[PATCH] system: Fix location print in axexit notifier callback

Zhenzhong Duan posted 1 patch 11 months, 3 weeks ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20231207084609.2288573-1-zhenzhong.duan@intel.com
Maintainers: Paolo Bonzini <pbonzini@redhat.com>
system/runstate.c | 9 +++++++++
1 file changed, 9 insertions(+)
[PATCH] system: Fix location print in axexit notifier callback
Posted by Zhenzhong Duan 11 months, 3 weeks ago
Some exit notifier callbacks call error_report_err if it fails
to do the cleanup. If this happens on QEMU command line parse
stage, i.e. there is fatal error, the location printed in
error_report_err is totally unrelated to exit notifier itself.
Set location to none to avoid such confusing.

Before fix:
qemu-system-x86_64: -device intel-iommu,device-iotlb=on,x-pasid-mode=on: PASID based device IOTLB is not supported
qemu-system-x86_64: -device intel-iommu,device-iotlb=on,x-pasid-mode=on: network script /root/qemu/build/qemu-bundle/usr/local/etc/qemu-ifdown failed with status 256

After fix:
qemu-system-x86_64: -device intel-iommu,device-iotlb=on,x-pasid-mode=on: PASID based device IOTLB is not supported
qemu-system-x86_64: network script /root/qemu/build/qemu-bundle/usr/local/etc/qemu-ifdown failed with status 256

Signed-off-by: Zhenzhong Duan <zhenzhong.duan@intel.com>
---
 system/runstate.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/system/runstate.c b/system/runstate.c
index ea9d6c2a32a4..32e9e9b541aa 100644
--- a/system/runstate.c
+++ b/system/runstate.c
@@ -797,6 +797,15 @@ void qemu_remove_exit_notifier(Notifier *notify)
 
 static void qemu_run_exit_notifiers(void)
 {
+    /*
+     * Some exit notifier callbacks call error_report_err if it fails
+     * to do the cleanup. If this happens on QEMU command line parse
+     * stage, i.e. there is fatal error, the location printed in
+     * error_report_err is totally unrelated to exit notifier itself.
+     * Set location to none to avoid such confusing.
+     */
+    loc_set_none();
+
     notifier_list_notify(&exit_notifiers, NULL);
 }
 
-- 
2.34.1