On Thu, Nov 13, 2025 at 04:15:50PM -0500, Peter Xu wrote:
> On Fri, Oct 24, 2025 at 11:52:01AM +0800, Xiaoyao Li wrote:
> > > @@ -2781,6 +2782,11 @@ static int kvm_init(AccelState *as, MachineState
> > > *ms)
> > > kvm_supported_memory_attributes = kvm_vm_check_extension(s,
> > > KVM_CAP_MEMORY_ATTRIBUTES);
> > > kvm_guest_memfd_supported = kvm_vm_check_extension(s,
> > > KVM_CAP_GUEST_MEMFD) &&
> > > kvm_vm_check_extension(s, KVM_CAP_USER_MEMORY2);
> > > + ret = kvm_vm_check_extension(s, KVM_CAP_GUEST_MEMFD_FLAGS);
> > > + if (ret > 0)
> > > + kvm_guest_memfd_flags_supported = (uint64_t)ret;
> > > + else
> > > + kvm_guest_memfd_flags_supported = 0;
> >
> > Nit:
> > 1. QEMU's coding style always requires curly braces.
> > 2. is the (uint64_t) necessary?
> > 3. can we name it "kvm_supported_guest_memfd_flags" to make it consistent
> > with "kvm_supported_memory_attributes"?
> >
> > so how about
> >
> > kvm_supported_guest_memfd_flags = kvm_vm_check_extension(s,
> > KVM_CAP_GUEST_MEMFD_FLAGS);
> > if (kvm_supported_guest_memfd_flags < 0) {
> > kvm_supported_guest_memfd_flags = 0;
> > }
>
> Yep this looks good, I'll use it, thanks.
About naming: note that we already have different styles (both below
variables introduced by your previous commits):
static uint64_t kvm_supported_memory_attributes;
static bool kvm_guest_memfd_supported;
I personally preferred kvm_guest_memfd* as prefix, so I kept it.
--
Peter Xu