The code is perfect for real machine and virtualbox although acpi_poweroff()
is not working for QEmu(I don't know the reason!). My outw
function was wrong so it was not working fixed outw function is
void outw(uint16_t port, uint16_t value) {
asm volatile ("outw %0, %1" : : "a"(value), "Nd"(port));
}