@samitouri / QOSamiQemu / commits / e76c30bb13

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 <anisinha@redhat.com> Link: https://lore.kernel.org/r/20260225035000.385950-33-anisinha@redhat.com Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>

Ani Sinha committed Feb 25, 2026 at 09:19 UTC e76c30bb13ecb9dc716fa629954bfb6253056ce2
3 files changed +31 -3
hw/core/machine.c
+22
@@ -435,6 +435,21 @@ static void machine_set_dump_guest_core(Object *obj, bool value, Error **errp)
435 ms->dump_guest_core = value;
436 }
437
438 +static bool machine_get_new_accel_vmfd_on_reset(Object *obj, Error **errp)
439 +{
440 + MachineState *ms = MACHINE(obj);
441 +
442 + return ms->new_accel_vmfd_on_reset;
443 +}
444 +
445 +static void machine_set_new_accel_vmfd_on_reset(Object *obj,
446 + bool value, Error **errp)
447 +{
448 + MachineState *ms = MACHINE(obj);
449 +
450 + ms->new_accel_vmfd_on_reset = value;
451 +}
452 +
453 static bool machine_get_mem_merge(Object *obj, Error **errp)
454 {
455 MachineState *ms = MACHINE(obj);
@@ -1183,6 +1198,13 @@ static void machine_class_init(ObjectClass *oc, const void *data)
1198 object_class_property_set_description(oc, "dump-guest-core",
1199 "Include guest memory in a core dump");
1200
1201 + object_class_property_add_bool(oc, "x-change-vmfd-on-reset",
1202 + machine_get_new_accel_vmfd_on_reset,
1203 + machine_set_new_accel_vmfd_on_reset);
1204 + object_class_property_set_description(oc, "x-change-vmfd-on-reset",
1205 + "Set on/off to enable/disable generating new accelerator guest handle "
1206 + "on guest reset. Default: off (used only for testing/debugging).");
1207 +
1208 object_class_property_add_bool(oc, "mem-merge",
1209 machine_get_mem_merge, machine_set_mem_merge);
1210 object_class_property_set_description(oc, "mem-merge",
include/hw/core/boards.h
+6
@@ -448,6 +448,12 @@ struct MachineState {
448 struct NVDIMMState *nvdimms_state;
449 struct NumaState *numa_state;
450 bool acpi_spcr_enabled;
451 + /*
452 + * Whether to change virtual machine accelerator handle upon
453 + * reset or not. Used only for debugging and testing purpose.
454 + * Set to false by default for all regular use.
455 + */
456 + bool new_accel_vmfd_on_reset;
457 };
458
459 /*
system/runstate.c
+3 -3
@@ -526,9 +526,9 @@ void qemu_system_reset(ShutdownCause reason)
526 type = RESET_TYPE_COLD;
527 }
528
529 - if (!cpus_are_resettable() &&
530 - (reason == SHUTDOWN_CAUSE_GUEST_RESET ||
531 - reason == SHUTDOWN_CAUSE_HOST_QMP_SYSTEM_RESET)) {
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())) {
532 if (ac->rebuild_guest) {
533 ret = ac->rebuild_guest(current_machine);
534 if (ret < 0) {