Page 1 of 1

How to debug my hard disk error handler on QEMU

Posted: Thu Jul 14, 2022 11:03 am
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?

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

Posted: Thu Jul 14, 2022 5:32 pm
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.