Peter Xu <[email protected]> writes:
> On Tue, Jan 30, 2024 at 10:18:07AM +0000, Peter Maydell wrote:
>> On Mon, 29 Jan 2024 at 23:31, Fabiano Rosas <[email protected]> wrote:
>> >
>> > Fabiano Rosas <[email protected]> writes:
>> >
>> > > Peter Xu <[email protected]> writes:
>> > >
>> > >> On Fri, Jan 26, 2024 at 11:54:32AM -0300, Fabiano Rosas wrote:
>> > > The issue that occurs to me now is that 'cpu host' will not work with
>> > > TCG. We might actually need to go poking /dev/kvm for this to work.
>> >
>> > Nevermind this last part. There's not going to be a scenario where we
>> > build with CONFIG_KVM, but run in an environment that does not support
>> > KVM.
>>
>> Yes, there is. We'll build with CONFIG_KVM on any aarch64 host,
>> but that doesn't imply that the user running the build and
>> test has permissions for /dev/kvm.
>
> I'm actually pretty confused on why this would be a problem even for
> neoverse-n1: can we just try to use KVM, if it fails then use TCG?
> Something like:
>
> (construct qemu cmdline)
> ..
> #ifdef CONFIG_KVM
> "-accel kvm "
> #endif
> "-accel tcg "
> ..
>
> ?
> IIUC if we specify two "-accel", we'll try the first, then if failed then
> the 2nd?
Aside from '-cpu max', there's no -accel and -cpu combination that works
on all of:
x86_64 host - TCG-only
aarch64 host - KVM & TCG
aarch64 host with --disable-tcg - KVM-only
aarch64 host without access to /dev/kvm - TCG-only
And the cpus are:
host - KVM-only
neoverse-n1 - TCG-only
We'll need something like:
/* covers aarch64 host with --disable-tcg */
if (qtest_has_accel("kvm") && !qtest_has_accel("tcg")) {
if (open("/dev/kvm", O_RDONLY) < 0) {
g_test_skip()
} else {
"-accel kvm -cpu host"
}
}
/* covers x86_64 host */
if (!qtest_has_accel("kvm") && qtest_has_accel("tcg")) {
"-accel tcg -cpu neoverse-n1"
}
/* covers aarch64 host */
if (qtest_has_accel("kvm") && qtest_has_accel("tcg")) {
if (open("/dev/kvm", O_RDONLY) < 0) {
"-accel tcg -cpu neoverse-n1"
} else {
"-accel kvm -cpu host"
}
}