Search code examples
httpqemuuefiedk2

Setting up the EFI Shell in Qemu to allow for Http requests


I am developing an UEFI App that will need to perform a GET request through http.

As a start up point, I want to make sure my setup is working properly so that the http requests can actually go through.

To that end, I spent the last few days trying to make the http command work in the EFI Shell launched inside QEMU. I can get the ping command to work properly, but calling:

http httpbin.org/get

Always returns: 

 Unable to open http protocol on `eth0` - Unsupported
 Unable to download the file `/get` on `eth0` - Unsupported

This is my startup.nsh script to configure the EFI Shell's interface:

connect
ifconfig -r eth0
ifconfig -s eth0 dhcp
ifconfig -l eth0 

These were my different attempts at invoking Qemu properly:

       -netdev user,id=mynet0,hostfwd=tcp::8080-:80 -device e1000,netdev=mynet0 \
        -netdev user,id=user.0 -device e1000,netdev=user.0 \
        -nic user,ipv6=off,model=e1000,mac=52:54:98:76:54:32 \

       

And following this guide I tried to setup a tap, albeit without luck, I'd launch qemu with the following configuration:

 -netdev tap,id=mynet0,ifname=tap0,script=no,downscript=no -device e1000,netdev=mynet0,mac=52:55:00:d1:55:01 \ 

Do you have any clue what step am I missing?

Where do you believe I could be failing in making eth0 supported?

Is the tap crucial?

Are you able to make this setup work on your side?

Update:

Very good suggestion @MiSimon, I hadn't realized that the HttpDxe driver wasn't being built with the OvmfPkg.

I have now added its INF to OvmfPkgX64.dsc and OvmfPkgX64.fdf.

Although, running drivers is displaying a duplicate entry:

0000000A D - -  1  - HttpDxe                             HttpDxe
0000000A ? - -  -  - HttpDxe                             HttpDxe

With respect to calling the http command, the error has progressed to:

Downloading 'http://httpbin.org/get'
Unable to download the file '/get' on 'eth0' - Unsupported

The debug log shows:

HttpNotify: Event - 0, EventStatus - Unsupported
Error: Could not retrieve the host address from DNS server.

Solution

  • The tool requires nearly all network drivers to be loaded.

    Make sure your image contains the following drivers:

    • SnpDxe
    • MnpDxe
    • ArpDxe
    • Ip4Dxe/Ip6Dxe
    • Dhcp4Dxe/Dhcp6Dxe
    • Udp4Dxe/Udp6Dxe
    • DnsDxe
    • TcpDxe
    • HttpDxe
    • HttpUtilitiesDxe

    All of them are can be found in EDK2 inside the NetworkPkg.