[PATCH rfcv4 11/13] qemu: Avoid duplicate FakeReboot for secure guest

Zhenzhong Duan posted 13 patches 6 months, 2 weeks ago
There is a newer version of this series
[PATCH rfcv4 11/13] qemu: Avoid duplicate FakeReboot for secure guest
Posted by Zhenzhong Duan 6 months, 2 weeks ago
For secure guest, FakeReboot kills original QEMU instance and
create new one. During this process, QEMU send SHUTDOWN event
with "host-signal" reason which can trigger another FakeReboot.

Check if a FakeReboot is ongoing and bypass "host-signal"
processing which is originally come from FakeReboot.

Signed-off-by: Zhenzhong Duan <zhenzhong.duan@intel.com>
---
 src/qemu/qemu_monitor.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c
index 7f7053054f..3aadd89aec 100644
--- a/src/qemu/qemu_monitor.c
+++ b/src/qemu/qemu_monitor.c
@@ -1075,6 +1075,16 @@ qemuMonitorEmitShutdown(qemuMonitor *mon, virTristateBool guest,
      * with it here. */
     if (vm->def->sec &&
         vm->def->sec->sectype == VIR_DOMAIN_LAUNCH_SECURITY_TDX) {
+        qemuDomainObjPrivate *priv = vm->privateData;
+
+        /* For secure guest, FakeReboot kills original QEMU instance and
+         * create new one. During this process, QEMU send SHUTDOWN event
+         * with "host-signal" reason which can trigger another FakeReboot.
+         * Check if a FakeReboot is ongoing and bypass "host-signal"
+         * processing which is originally come from FakeReboot. */
+        if (priv->fakeReboot && STREQ_NULLABLE(reason, "host-signal"))
+            return;
+
         if ((STREQ_NULLABLE(reason, "guest-shutdown") &&
              vm->def->onPoweroff == VIR_DOMAIN_LIFECYCLE_ACTION_RESTART) ||
             (STREQ_NULLABLE(reason, "guest-reset") &&
-- 
2.34.1
Re: [PATCH rfcv4 11/13] qemu: Avoid duplicate FakeReboot for secure guest
Posted by Daniel P. Berrangé 6 months ago
On Fri, May 24, 2024 at 02:21:26PM +0800, Zhenzhong Duan wrote:
> For secure guest, FakeReboot kills original QEMU instance and
> create new one. During this process, QEMU send SHUTDOWN event
> with "host-signal" reason which can trigger another FakeReboot.
> 
> Check if a FakeReboot is ongoing and bypass "host-signal"
> processing which is originally come from FakeReboot.
> 
> Signed-off-by: Zhenzhong Duan <zhenzhong.duan@intel.com>
> ---
>  src/qemu/qemu_monitor.c | 10 ++++++++++
>  1 file changed, 10 insertions(+)

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>


With regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|