Test AHCI ATAPI device using qemu

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
User avatar
Bonfra
Member
Member
Posts: 270
Joined: Wed Feb 19, 2020 1:08 pm
Libera.chat IRC: Bonfra
Location: Italy

Test AHCI ATAPI device using qemu

Post 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?
Regards, Bonfra.
Octocontrabass
Member
Member
Posts: 5562
Joined: Mon Mar 25, 2013 7:01 pm

Re: Test AHCI ATAPI device using qemu

Post by Octocontrabass »

Using "-cdrom" or "-drive media=cdrom" works fine for me.

What makes it seem like it isn't working for you?
User avatar
Bonfra
Member
Member
Posts: 270
Joined: Wed Feb 19, 2020 1:08 pm
Libera.chat IRC: Bonfra
Location: Italy

Re: Test AHCI ATAPI device using qemu

Post 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?
Regards, Bonfra.
Octocontrabass
Member
Member
Posts: 5562
Joined: Mon Mar 25, 2013 7:01 pm

Re: Test AHCI ATAPI device using qemu

Post 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.
User avatar
Bonfra
Member
Member
Posts: 270
Joined: Wed Feb 19, 2020 1:08 pm
Libera.chat IRC: Bonfra
Location: Italy

Re: Test AHCI ATAPI device using qemu

Post 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 :)
Regards, Bonfra.
Post Reply