Page 1 of 1

Test AHCI ATAPI device using qemu

Posted: Tue Dec 13, 2022 4:21 pm
by Bonfra
I have a fully working AHCI SATA driver that reads a disk connected to qemu with the following flags:

Code: Select all

-M q35 -drive file=./OS.img,index=0,media=disk,format=raw
Now I want to implement SCSI, hence I need an ATAPI device. I tried with -cdrom and many other flags but the ahci driver doesn't find the atapi device. What is the exact combination of flags needed to make an atapi device pop out in the ahci interface using qemu?

Re: Test AHCI ATAPI device using qemu

Posted: Tue Dec 13, 2022 8:04 pm
by Octocontrabass
Using "-cdrom" or "-drive media=cdrom" works fine for me.

What makes it seem like it isn't working for you?

Re: Test AHCI ATAPI device using qemu

Posted: Wed Dec 14, 2022 1:55 am
by Bonfra
Octocontrabass wrote:What makes it seem like it isn't working for you?
after resetting the AHCI controller and probing the ports none of them contains an ATAPI device using -cdrom, now I tested with

Code: Select all

-drive file=./os.iso,index=1,media=cdrom,format=raw
and it seems to be working; now two(?) ATAPI devices pop out after the enumeration.
I'm not sure why the simplest form -cdrom isn't working but I'm not as worried about that as the fact that two ATAPI are present. how do I discern which one is mine?

Re: Test AHCI ATAPI device using qemu

Posted: Wed Dec 14, 2022 3:20 am
by Octocontrabass
Bonfra wrote:after resetting the AHCI controller and probing the ports none of them contains an ATAPI device using -cdrom
It sounds like there's a bug in your AHCI driver. Linux has no problem finding the optical drive when using "-cdrom".
Bonfra wrote:how do I discern which one is mine?
Your drive will be the one with your disc in it. The default optical drive will be empty unless you use "-hdc" or "-cdrom" or "-device index=2" or "-nodefaults" to override it.

Re: Test AHCI ATAPI device using qemu

Posted: Wed Dec 14, 2022 6:55 am
by Bonfra
Well I updated qemu and now it works with -cdrom, maybe it was a buggy version, I also don't have the empty disk problem anymore using index=2 as you suggested. Thanks a lot :)