How to debug my hard disk error handler on 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
theflysong
Member
Member
Posts: 27
Joined: Wed Jun 29, 2022 2:17 am
Libera.chat IRC: theflysong

How to debug my hard disk error handler on QEMU

Post by theflysong »

I write a hard disk error handler in order to take right actions when the hard disk set the ERR bit to 1.
But I don't know how to reproduce this situation in QEMU.
Is there any way to reproduce it?
I'm a new man to develop operating system.
Octocontrabass
Member
Member
Posts: 5563
Joined: Mon Mar 25, 2013 7:01 pm

Re: How to debug my hard disk error handler on QEMU

Post by Octocontrabass »

As far as I know, QEMU only reports errors on invalid commands. If you want to test your error handlers with different types of errors, you'll have to find another way.

If your driver is modular enough, you can add an interposer between it and the HBA I/O and inject fake errors that way.

You can run your driver under a debugger and use the debugger to overwrite the drive's actual response with an error response.

You can try your driver with a broken hard drive. It probably won't test all of your error handlers, but I'm sure it'll be fun.
Post Reply