On Fri, 14 Jan 2022 13:28:19 +0100 Janosch Frank <frankja@xxxxxxxxxxxxx> wrote: > On 1/14/22 12:18, Claudio Imbrenda wrote: > > On Fri, 14 Jan 2022 10:02:41 +0000 > > Janosch Frank <frankja@xxxxxxxxxxxxx> wrote: > > > >> This patch will likely (in parts) be replaced by Pierre's patch from > >> his topology test series. > >> > >> Signed-off-by: Janosch Frank <frankja@xxxxxxxxxxxxx> > > > > Reviewed-by: Claudio Imbrenda <imbrenda@xxxxxxxxxxxxx> > > > > although I think there is some room for improvement, but nothing too > > serious, I'll probably fix it myself later > > I think I should add this to clean up the checks in the following patches: > > bool vm_is_qemu(void) > { > return vm_is_kvm() || vm_is_tcg(); > } > > That of course also isn't a 100% correct, we could have KVM + non-QEMU > but I'll cross that bridge when I get there. > > And as I already mentioned in Pierre's patch, the STSI values are a bit > of a mystery to me since AFAIK we store KVM/Linux even if we run under TCG. I was actually thinking of a generic detection function that will call STSI only once and set all the necessary flags. then the various vm_is_* functions can become something like this: bool vm_is_${TYPE}() { if (vm_type == VM_TYPE_NOT_INITIALIZED) do_vm_detection(); return vm_type == VM_${TYPE}; } and then have all the magic hidden in the one do_vm_detection, which will call STSI once and try to find out what we are running on.