On Tue, Jan 27, 2026 at 10:47 AM Ani Sinha <[email protected]> wrote:
>
> A confidential guest reset involves closing the old virtual machine KVM file
> descriptor and opening a new one. Since its a new KVM fd, PIT needs to be
> reinitialized again. This is done with the help of a notifier which is invoked
> upon KVM vm file desciptor change during confidential guest reset process.
                                  ^^^^^^^^
will fix the above typo and also add a functional test to exercise the
changes in this patch for the next spin up.

>
> Signed-off-by: Ani Sinha <[email protected]>
> ---
>  hw/i386/kvm/i8254.c | 20 ++++++++++++++++++++
>  1 file changed, 20 insertions(+)
>
> diff --git a/hw/i386/kvm/i8254.c b/hw/i386/kvm/i8254.c
> index 255047458a..a754de0c8d 100644
> --- a/hw/i386/kvm/i8254.c
> +++ b/hw/i386/kvm/i8254.c
> @@ -52,6 +52,8 @@ struct KVMPITState {
>      LostTickPolicy lost_tick_policy;
>      bool vm_stopped;
>      int64_t kernel_clock_offset;
> +
> +    NotifierWithReturn kvmpit_vmfd_change_notifier;
>  };
>
>  struct KVMPITClass {
> @@ -203,6 +205,21 @@ static void kvm_pit_put(PITCommonState *pit)
>      }
>  }
>
> +static int kvmpit_post_vmfd_change(NotifierWithReturn *notifier,
> +                                   void *data, Error** errp)
> +{
> +    KVMPITState *s = container_of(notifier, KVMPITState,
> +                                  kvmpit_vmfd_change_notifier);
> +
> +    /* we are not interested in pre vmfd change notification */
> +    if (((VmfdChangeNotifier *)data)->pre) {
> +        return 0;
> +    }
> +
> +    do_pit_initialize(s, errp);
> +    return 0;
> +}
> +
>  static void kvm_pit_set_gate(PITCommonState *s, PITChannelState *sc, int val)
>  {
>      kvm_pit_get(s);
> @@ -292,6 +309,9 @@ static void kvm_pit_realizefn(DeviceState *dev, Error 
> **errp)
>
>      qemu_add_vm_change_state_handler(kvm_pit_vm_state_change, s);
>
> +    s->kvmpit_vmfd_change_notifier.notify = kvmpit_post_vmfd_change;
> +    kvm_vmfd_add_change_notifier(&s->kvmpit_vmfd_change_notifier);
> +
>      kpc->parent_realize(dev, errp);
>  }
>
> --
> 2.42.0
>


Reply via email to