From: Ani Sinha Date: Wed, 25 Feb 2026 03:49:37 +0000 (+0530) Subject: hw/machine: introduce machine specific option 'x-change-vmfd-on-reset' X-Git-Tag: v11.0.0-rc0~43^2~29 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e76c30bb13ecb9dc716fa629954bfb6253056ce2;p=thirdparty%2Fqemu.git hw/machine: introduce machine specific option 'x-change-vmfd-on-reset' A new machine specific option 'x-change-vmfd-on-reset' is introduced for debugging and testing only (hence the 'x-' prefix). This option when enabled will force KVM VM file descriptor to be changed upon guest reset like in the case of confidential guests. This can be used to exercise the code changes that are specific for confidential guests on non-confidential guests as well (except changes that require hardware support for confidential guests). A new functional test has been added in the next patch that uses this new parameter to test the VM file descriptor changes. Signed-off-by: Ani Sinha Link: https://lore.kernel.org/r/20260225035000.385950-33-anisinha@redhat.com Signed-off-by: Paolo Bonzini --- diff --git a/hw/core/machine.c b/hw/core/machine.c index d4ef620c178..eae1f6be8d5 100644 --- a/hw/core/machine.c +++ b/hw/core/machine.c @@ -435,6 +435,21 @@ static void machine_set_dump_guest_core(Object *obj, bool value, Error **errp) ms->dump_guest_core = value; } +static bool machine_get_new_accel_vmfd_on_reset(Object *obj, Error **errp) +{ + MachineState *ms = MACHINE(obj); + + return ms->new_accel_vmfd_on_reset; +} + +static void machine_set_new_accel_vmfd_on_reset(Object *obj, + bool value, Error **errp) +{ + MachineState *ms = MACHINE(obj); + + ms->new_accel_vmfd_on_reset = value; +} + static bool machine_get_mem_merge(Object *obj, Error **errp) { MachineState *ms = MACHINE(obj); @@ -1183,6 +1198,13 @@ static void machine_class_init(ObjectClass *oc, const void *data) object_class_property_set_description(oc, "dump-guest-core", "Include guest memory in a core dump"); + object_class_property_add_bool(oc, "x-change-vmfd-on-reset", + machine_get_new_accel_vmfd_on_reset, + machine_set_new_accel_vmfd_on_reset); + object_class_property_set_description(oc, "x-change-vmfd-on-reset", + "Set on/off to enable/disable generating new accelerator guest handle " + "on guest reset. Default: off (used only for testing/debugging)."); + object_class_property_add_bool(oc, "mem-merge", machine_get_mem_merge, machine_set_mem_merge); object_class_property_set_description(oc, "mem-merge", diff --git a/include/hw/core/boards.h b/include/hw/core/boards.h index edbe8d03e56..12b21493789 100644 --- a/include/hw/core/boards.h +++ b/include/hw/core/boards.h @@ -448,6 +448,12 @@ struct MachineState { struct NVDIMMState *nvdimms_state; struct NumaState *numa_state; bool acpi_spcr_enabled; + /* + * Whether to change virtual machine accelerator handle upon + * reset or not. Used only for debugging and testing purpose. + * Set to false by default for all regular use. + */ + bool new_accel_vmfd_on_reset; }; /* diff --git a/system/runstate.c b/system/runstate.c index e7b50e6a3b1..eca722b43c6 100644 --- a/system/runstate.c +++ b/system/runstate.c @@ -526,9 +526,9 @@ void qemu_system_reset(ShutdownCause reason) type = RESET_TYPE_COLD; } - if (!cpus_are_resettable() && - (reason == SHUTDOWN_CAUSE_GUEST_RESET || - reason == SHUTDOWN_CAUSE_HOST_QMP_SYSTEM_RESET)) { + if ((reason == SHUTDOWN_CAUSE_GUEST_RESET || + reason == SHUTDOWN_CAUSE_HOST_QMP_SYSTEM_RESET) && + (current_machine->new_accel_vmfd_on_reset || !cpus_are_resettable())) { if (ac->rebuild_guest) { ret = ac->rebuild_guest(current_machine); if (ret < 0) {