summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorXiaoyao Li <xiaoyao.li@intel.com>2025-06-25 11:55:05 +0800
committerPaolo Bonzini <pbonzini@redhat.com>2025-07-12 15:28:21 +0200
commit50fd57418c3f08f13eb964dcb49f065246f2ecbf (patch)
tree23ea9afedcf5aae64159b50e5286d02639bc1212
parentb6c5b41ba28198030ce2f2b19cf333a9129d07dc (diff)
downloadfocaccia-qemu-50fd57418c3f08f13eb964dcb49f065246f2ecbf.tar.gz
focaccia-qemu-50fd57418c3f08f13eb964dcb49f065246f2ecbf.zip
i386/tdx: Remove task->watch only when it's valid
In some case (e.g., failed to connect to QGS socket),
tdx_generate_quote_cleanup() is called with task->watch invalid. It
triggers assertion of

  qemu-system-x86_64: GLib: g_source_remove: assertion 'tag > 0' failed

Fix it by checking task->watch.

Fixes: 40da501d8989 ("i386/tdx: handle TDG.VP.VMCALL<GetQuote>")
Signed-off-by: Xiaoyao Li <xiaoyao.li@intel.com>
Reviewed-by: Zhao Liu <zhao1.liu@intel.com>
Link: https://lore.kernel.org/r/20250625035505.2770580-1-xiaoyao.li@intel.com
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
-rw-r--r--target/i386/kvm/tdx-quote-generator.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/target/i386/kvm/tdx-quote-generator.c b/target/i386/kvm/tdx-quote-generator.c
index f59715f617..dee8334b27 100644
--- a/target/i386/kvm/tdx-quote-generator.c
+++ b/target/i386/kvm/tdx-quote-generator.c
@@ -75,7 +75,9 @@ static void tdx_generate_quote_cleanup(TdxGenerateQuoteTask *task)
 {
     timer_del(&task->timer);
 
-    g_source_remove(task->watch);
+    if (task->watch) {
+        g_source_remove(task->watch);
+    }
     qio_channel_close(QIO_CHANNEL(task->sioc), NULL);
     object_unref(OBJECT(task->sioc));