@samitouri / QOSamiQemu / commits / 6068592e56

coverity: fix coverity issues related to confidential guest reset

Fix issues reported by Peter. Fixes: ec9bafd2ea9d12c ("i386/sev: add support for confidential guest reset") Fixes: e76c30bb13ecb9d ("hw/machine: introduce machine specific option 'x-change-vmfd-on-reset'") Reported-by: Peter Maydell <peter.maydell@linaro.org> Reviewed-by: Zhao Liu <zhao1.liu@intel.com> Signed-off-by: Ani Sinha <anisinha@redhat.com> Link: https://lore.kernel.org/r/20260311074048.61367-1-anisinha@redhat.com Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>

Ani Sinha committed Mar 11, 2026 at 13:10 UTC 6068592e5600e90645d1fb4e1c3a494f4ac2d373
2 files changed +5 -9
system/runstate.c
+5 -5
@@ -508,13 +508,13 @@ static int qemu_debug_requested(void)
508 */
509 void qemu_system_reset(ShutdownCause reason)
510 {
511 - MachineClass *mc;
512 - ResetType type;
511 + MachineClass *mc = current_machine ? MACHINE_GET_CLASS(current_machine) : NULL;
512 AccelClass *ac = ACCEL_GET_CLASS(current_accel());
513 + bool force_vmfd_change =
514 + current_machine ? current_machine->new_accel_vmfd_on_reset : false;
515 bool guest_state_rebuilt = false;
516 int ret;
516 -
517 - mc = current_machine ? MACHINE_GET_CLASS(current_machine) : NULL;
517 + ResetType type;
518
519 cpu_synchronize_all_states();
520
@@ -528,7 +528,7 @@ void qemu_system_reset(ShutdownCause reason)
528
529 if ((reason == SHUTDOWN_CAUSE_GUEST_RESET ||
530 reason == SHUTDOWN_CAUSE_HOST_QMP_SYSTEM_RESET) &&
531 - (current_machine->new_accel_vmfd_on_reset || !cpus_are_resettable())) {
531 + (force_vmfd_change || !cpus_are_resettable())) {
532 if (ac->rebuild_guest) {
533 ret = ac->rebuild_guest(current_machine);
534 if (ret < 0) {
target/i386/sev.c
-4
@@ -2011,10 +2011,6 @@ static void sev_handle_reset(Object *obj, ResetType type)
2011 SevCommonState *sev_common = SEV_COMMON(MACHINE(qdev_get_machine())->cgs);
2012 SevCommonStateClass *klass = SEV_COMMON_GET_CLASS(sev_common);
2013
2014 - if (!sev_common) {
2015 - return;
2016 - }
2017 -
2014 if (!runstate_is_running()) {
2015 return;
2016 }