* Detecting qemu from guest on arm/hvf (apple arm)
@ 2023-02-15 23:48 John-Mark Gurney
2023-02-16 10:23 ` Peter Maydell
2023-02-21 10:06 ` Daniel P. Berrangé
0 siblings, 2 replies; 4+ messages in thread
From: John-Mark Gurney @ 2023-02-15 23:48 UTC (permalink / raw)
To: qemu-arm, qemu-devel
Hello,
I was wondering what the best way to detect that FreeBSD is running
under qemu/hvf on Apple ARM? FreeBSD doesn't see the ACPI FADT table,
so I'm wondering if keying off of something like the QEMU0002 device
in ACPI is the best way? Or is there another option?
Thanks for your help.
--
John-Mark Gurney Voice: +1 415 225 5579
"All that I will do, has been done, All that I have, has not."
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Detecting qemu from guest on arm/hvf (apple arm)
2023-02-15 23:48 Detecting qemu from guest on arm/hvf (apple arm) John-Mark Gurney
@ 2023-02-16 10:23 ` Peter Maydell
2023-02-20 22:32 ` John-Mark Gurney
2023-02-21 10:06 ` Daniel P. Berrangé
1 sibling, 1 reply; 4+ messages in thread
From: Peter Maydell @ 2023-02-16 10:23 UTC (permalink / raw)
To: qemu-arm, qemu-devel
On Thu, 16 Feb 2023 at 02:05, John-Mark Gurney <jmg@funkthat.com> wrote:
>
> Hello,
>
> I was wondering what the best way to detect that FreeBSD is running
> under qemu/hvf on Apple ARM? FreeBSD doesn't see the ACPI FADT table,
> so I'm wondering if keying off of something like the QEMU0002 device
> in ACPI is the best way? Or is there another option?
I guess the question is, why do you want to know? Typically
the guest OS shouldn't care about whether it's running
on bare metal, under a hypervisor, or under emulated QEMU,
except to the extent that it wants to use specific features,
in which case the question is more "how do I query for the
existence of feature X?".
thanks
-- PMM
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Detecting qemu from guest on arm/hvf (apple arm)
2023-02-16 10:23 ` Peter Maydell
@ 2023-02-20 22:32 ` John-Mark Gurney
0 siblings, 0 replies; 4+ messages in thread
From: John-Mark Gurney @ 2023-02-20 22:32 UTC (permalink / raw)
To: qemu-devel, Peter Maydell
Hello Peter,
btw, please keep me CC'd, as I'm not subscribed to the mailing list.
> I guess the question is, why do you want to know? Typically
The main reason is that FreeBSD (and other operating systems)
adjust some of the clock periods to be longer for better
effeciency. When FreeBSD detects that it's a VM, is slows
down hz to 100 instead of 1000:
https://cgit.freebsd.org/src/tree/sys/kern/subr_param.c#n177
And in my case, if I didn't set hz to 100 manually, even an
idle machine would consume tons of host CPU, and on top of it
(I'm not sure why), it would run at a constant >1000 int/s,
compared to running hz at 100 where the int/s would drop to
around 50/s...
I'm not sure how good/bad the time counter is on ARM hardware
as I'm more familar w/ x86 time counter hardware, and I do know
that there's a large variety of quality of time counter hardware
and the expense to accessing it.
FreeBSD is using the ARM MPCore Timecounter, and it reports:
kern.timecounter.tc.ARM MPCore Timecounter.quality: 1000
kern.timecounter.tc.ARM MPCore Timecounter.frequency: 24000000
kern.timecounter.tc.ARM MPCore Timecounter.counter: 2182594876
kern.timecounter.tc.ARM MPCore Timecounter.mask: 4294967295
There isn't any other time counter hardware reported (except dummy,
but that isn't usable)...
FreeBSD has code to detect hyperv and xen, and detect VMWare through
SMBios.
> the guest OS shouldn't care about whether it's running
> on bare metal, under a hypervisor, or under emulated QEMU,
> except to the extent that it wants to use specific features,
> in which case the question is more "how do I query for the
> existence of feature X?".
Thanks for your help.
--
John-Mark Gurney Voice: +1 415 225 5579
"All that I will do, has been done, All that I have, has not."
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Detecting qemu from guest on arm/hvf (apple arm)
2023-02-15 23:48 Detecting qemu from guest on arm/hvf (apple arm) John-Mark Gurney
2023-02-16 10:23 ` Peter Maydell
@ 2023-02-21 10:06 ` Daniel P. Berrangé
1 sibling, 0 replies; 4+ messages in thread
From: Daniel P. Berrangé @ 2023-02-21 10:06 UTC (permalink / raw)
To: qemu-arm, qemu-devel
On Wed, Feb 15, 2023 at 03:48:46PM -0800, John-Mark Gurney wrote:
> Hello,
>
> I was wondering what the best way to detect that FreeBSD is running
> under qemu/hvf on Apple ARM? FreeBSD doesn't see the ACPI FADT table,
> so I'm wondering if keying off of something like the QEMU0002 device
> in ACPI is the best way? Or is there another option?
Aside from Peter's suggestion to check for actual features that
matter, if you genuinely need to detect a specific platform,
the virt-what tool is generally what I point people to. It has
loads of checks in it. It can detect QEMU on aarch64, but doesn't
distinguish KVM unless SMBIOS is present too. The 'virt' machine
type will include SMBIOS, so I expect the KVM check will probably
trigger for HVF too.
http://git.annexia.org/?p=virt-what.git;a=blob;f=virt-what.in;h=01e9acaf689416d9bff6eaca1b849dc4e798a0af;hb=HEAD#l340
This is wrong from virt-what POV, but I presume for your needs,
you'd be happy to detect *any* hypervisor as you'll want to tweak
the clock frequency for both HVF and KVM VMs
If you do come up with any tweaks to it, patches would be welcome.
With regards,
Daniel
--
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org -o- https://fstop138.berrange.com :|
|: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2023-02-21 10:07 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-02-15 23:48 Detecting qemu from guest on arm/hvf (apple arm) John-Mark Gurney
2023-02-16 10:23 ` Peter Maydell
2023-02-20 22:32 ` John-Mark Gurney
2023-02-21 10:06 ` Daniel P. Berrangé
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).