Closed BJhutti closed 8 months ago
@Opsine02 , please also use coding style formatting for the Expected behavior section.
Updated
@Opsine02 , thanks, 5HP.
So running with -W
causes the same error to occur?
using -W
should basically default to the command you listed
Yes, it does not work with -W
Adding you @antoineco. Maybe you can do some checks. Installing WSL on my PC is usually a hassle :sweat:
@BJhutti Windows 10 doesn't have nested virtualization enabled in WSL2, only Windows 11 does.
But any idea why it doesn't work with -W
either? I wasn't expecting it to work with kvm
anyways
@craciunoiuc I remember we had another issue open regarding the detection logic trying to be smart, and failing at correctly being able to determine whether userspace or KVM should be used. I'm not sure where that issue is unfortunately.
Yeah, I also remember something related to that, but it was more in the kvm
direction. Right now it goes as deep as communicating with kvm
to see if it reports issues.
Here the error reported gives me a hunch that /dev/kvm
exists but is not actually a device, but a regular file, or something else:
file = hostDev("kvm")
if pathExists(file) {
if kvmFile, err := os.Stat(file); err == nil &&
kvmFile.Mode()&os.ModeCharDevice != 0 {
// Send ioctl for KVM_GET_API_VERSION
file, err := os.Open(file)
if err != nil {
return PlatformUnknown, SystemUnknown, fmt.Errorf("could not open kvm device: %w", err)
}
defer file.Close()
// [...]
You can see here that the path is first checked if it exists, then it is checked if it is a char device. If both true then it tries to open it to write to the device, and that is when it fails.
Ah yes, I know why this happens with -W
also, here is a snippet:
if opts.platform == "" {
opts.platform, _, err = platform.Detect(ctx)
if err != nil {
return fmt.Errorf("could not get host platform: %w", err)
}
}
Basically if the platform is not specified it will try to autodetect, and that is when it fails.
@BJhutti you probably ran kraft run -W
with no target and it tried to autodetect what to run.
We have 3 options:
qemu
when -W
is specified (only one with no-acceleration options)/dev/kvm
file exists in WSL Win10, but can't be opened.@antoineco what do you think
I'd say we should add a check on the file type of the device, to allow other checks to be performed in case the file is not a device?
There are checks already, you can see that it checks if the file is a charDevice
, which somehow it passes
@antoineco can you check if this still happens? :pray:
I unfortunately don't have access to Windows 10, but on Windows 11 both modes work:
% kraft run
W specification in Kraftfile (v0.5) version is not latest (v0.6)
W specification in Kraftfile (v0.5) version is not latest (v0.6)
o. .o _ _ __ _
Oo Oo ___ (_) | __ __ __ _ ' _) :_
oO oO ' _ `| | |/ / _)' _` | |_| _)
oOo oOO| | | | | (| | | (_) | _) :_
OoOoO ._, ._:_:_,\_._, .__,_:_, \___)
Telesto 0.16.2~86710f6
Hello world!
Arguments: "/home/acotten/git/unikraft/app-helloworld/.unikraft/build/helloworld_qemu-x86_64"
% kraft run --disable-acceleration
W specification in Kraftfile (v0.5) version is not latest (v0.6)
W specification in Kraftfile (v0.5) version is not latest (v0.6)
o. .o _ _ __ _
Oo Oo ___ (_) | __ __ __ _ ' _) :_
oO oO ' _ `| | |/ / _)' _` | |_| _)
oOo oOO| | | | | (| | | (_) | _) :_
OoOoO ._, ._:_:_,\_._, .__,_:_, \___)
Telesto 0.16.2~86710f6
Hello world!
Arguments: "/home/acotten/git/unikraft/app-helloworld/.unikraft/build/helloworld_qemu-x86_64"
With nestedVirtualization=false
(notice the warning "using hardware emulation"):
% kraft run
W using hardware emulation
W specification in Kraftfile (v0.5) version is not latest (v0.6)
W specification in Kraftfile (v0.5) version is not latest (v0.6)
o. .o _ _ __ _
Oo Oo ___ (_) | __ __ __ _ ' _) :_
oO oO ' _ `| | |/ / _)' _` | |_| _)
oOo oOO| | | | | (| | | (_) | _) :_
OoOoO ._, ._:_:_,\_._, .__,_:_, \___)
Telesto 0.16.2~86710f6
Hello world!
Arguments: "/home/acotten/git/unikraft/app-helloworld/.unikraft/build/helloworld_qemu-x86_64"
% kraft run --disable-acceleration
W using hardware emulation
W specification in Kraftfile (v0.5) version is not latest (v0.6)
W specification in Kraftfile (v0.5) version is not latest (v0.6)
o. .o _ _ __ _
Oo Oo ___ (_) | __ __ __ _ ' _) :_
oO oO ' _ `| | |/ / _)' _` | |_| _)
oOo oOO| | | | | (| | | (_) | _) :_
OoOoO ._, ._:_:_,\_._, .__,_:_, \___)
Telesto 0.16.2~86710f6
Hello world!
Arguments: "/home/acotten/git/unikraft/app-helloworld/.unikraft/build/helloworld_qemu-x86_64"
Considering the issue resolved. Feel free to reopen if this is not the case on the latest released version of KraftKit.
Describe the bug
On WSL, Ubuntu version 22.04, Windows 10, the following error occurs when
kraft run
is ran afterkraft build
in the /helloworld folder:could not open kvm device: open /dev/kvm: no such device
note2: did not work with -W
note: the application still runs correctly when using the command:
/usr/bin/qemu-system-x86_64 -kernel build/helloworld_qemu-x86_64 -nographic
Steps to reproduce
kraft build
kraft run
Expected behavior
The console should print:
Which architectures were you using or does this bug affect?
x86_64
Which operating system were you using or does this bug affect?
windows
Relevant log output