Skip to content

InvalidInput for http server on qemu #782

@m4b

Description

@m4b

I don't know if this is the right repo to post an issue, but, was playing around with hermit, copied the the simple http_server demo to a rust template, did best I could to copy qemu instructions, built the loader, and ran:

qemu-system-x86_64 -smp 1 -m 256M -device isa-debug-exit,iobase=0xf4,iosize=0x04 -kernel hermit-loader-x86_64 -initrd target/x86_64-unknown-hermit/debug/http_server -display none -serial stdio -netdev user,id=u1,hostfwd=tcp::9975-:9975 -device rtl8139,netdev=u1 --enable-kvm -cpu host
[LOADER][INFO] Loader: [0x100000 - 0x121058]
[LOADER][INFO] Found Multiboot information at 0x9500
[LOADER][WARN] Mapping 1 4KiB pages from 0x9000..0xa000 to 0x9000..0xa000
[LOADER][INFO] Found an ELF module at [0x123000 - 0x1982f68]
[LOADER][INFO] Module length: 0x185ff68
[LOADER][WARN] Mapping 4KiB pages starting from 0x123000 to frames 0x123000..0x200000
[LOADER][WARN] Mapping 2MiB pages starting from 0x200000 to frames 0x200000..0x1a00000
[LOADER][INFO] Parsing kernel from ELF at 0x123000..0x1982f68 (len = 0x185ff68 B / 25558888 B)
[LOADER][INFO] Found Hermit version 0.10.0
[LOADER][WARN] Mapping 2 2MiB pages from 0x1a00000..0x1e00000 to 0x1a00000..0x1e00000
[LOADER][INFO] Loading kernel to 0x1a00000..0x1d3f404 (len = 0x33f404 B / 3404804 B)
[LOADER][INFO] TLS is at 0x1d09a80..0x1d09b18 (len =  0x98 B / 152 B)
[LOADER][WARN] Mapping 8 4KiB pages from 0xa000..0x12000 to 0xa000..0x12000
[LOADER][INFO] boot_info = BootInfo {
    hardware_info: HardwareInfo {
        phys_addr_range: 0x0..0x0,
        serial_port_base: Some(
            0x3f8,
        ),
        device_tree: Some(
            0x120550,
        ),
    },
    load_info: LoadInfo {
        kernel_image_addr_range: 0x1a00000..0x1d3f404,
        tls_info: Some(
            TlsInfo {
                start: 0x1d09a80,
                filesz: 0x21,
                memsz: 0x98,
                align: 0x8,
            },
        ),
    },
    platform_info: Multiboot {
        command_line: Some(
            "hermit-loader-x86_64 ",
        ),
        multiboot_info_addr: 0x9500,
    },
}
[LOADER][INFO] Entering kernel at 0x1bed82c, stack at 0xa000, raw_boot_info at 0x11f008
[0][INFO] Welcome to Hermit 0.10.0
[0][INFO] Kernel starts at 0x1a00000
[0][INFO] FDT:
 / {
    compatible = "hermit,multiboot"
    #address-cells = <0x2>
    #size-cells = <0x2>

    memory@0 {
        device_type = "memory"
        reg = <0x0 0x9fc00>
    };

    memory@100000 {
        device_type = "memory"
        reg = <0x100000 0xfee0000>
    };

    chosen {
        bootargs = [104, 101, 114, 109, 105, 116, 45, 108, 111, 97, 100, 101, 114, 45, 120, 56, 54, 95, 54, 52, 32, 0]
    };
};

[0][INFO] BSS starts at 0x1d3e440
[0][INFO] tls_info = Some(
    TlsInfo {
        start: 0x1d09a80,
        filesz: 0x21,
        memsz: 0x98,
        align: 0x8,
    },
)
[0][INFO] Total memory size: 225 MiB
[0][INFO] Kernel region: 0x1a00000..0x1e00000
[0][INFO] Minimum memory size: 34
[0][INFO] Heap: size 170 MB, start address 0x1e00000
[0][INFO] Heap is located at 0x1e00000..0xc800000 (0 Bytes unmapped)
[0][INFO] Physical memory free list:
         0xc800000..         0xffe0000 (len =          0x37e0000, pages =            14304)
[0][INFO] Virtual memory free list:
         0xc800000..    0x800000000000 (len =     0x7ffff3800000, pages =      34359687168)
[0][INFO] bootargs = hermit-loader-x86_64
[0][INFO]
[0][INFO] ========================== CPU INFORMATION ===========================
[0][INFO] Model:                   11th Gen Intel(R) Core(TM) i7-1165G7 @ 2.80GHz
[0][INFO] Frequency:               2800 MHz (from CpuId Tsc Info)
[0][INFO] SpeedStep Technology:    Not Available
[0][INFO] Features:                MMX SSE SSE2 SSE3 SSSE3 SSE4.1 SSE4.2 AVX AESNI RDRAND FMA MOVBE MCE FXSR XSAVE VMX RDTSCP CLFLUSH TSC-DEADLINE X2APIC HYPERVISOR AVX2 AVX512F AVX512DQ AVX512IFMA AVX512CD AVX512BW AVX512VL BMI1 BMI2 PKU FSGSBASE RDSEED
[0][INFO] Physical Address Width:  39 bits
[0][INFO] Linear Address Width:    48 bits
[0][INFO] Supports 1GiB Pages:     Yes
[0][INFO] ======================================================================
[0][INFO]
[0][INFO] Hermit booted on 2025-08-12 4:45:26.789751 +00:00:00
[0][INFO] Found MP config at 0xf66f0
[0][INFO] System uses Multiprocessing Specification 1.4
[0][INFO] MP features 1: 0
[0][INFO] Virtual-Wire mode implemented
[0][INFO] Found IOAPIC at 0x0xfec00000
[0][INFO] IOAPIC v17 has 24 entries
[0][INFO]
[0][INFO] ===================== MULTIPROCESSOR INFORMATION =====================
[0][INFO] APIC in use:             x2APIC
[0][INFO] Initialized CPUs:        1
[0][INFO] ======================================================================
[0][INFO]
[0][INFO] Compiled with PCI support
[0][INFO]
[0][INFO] ======================== PCI BUS INFORMATION =========================
[0][INFO] 00:00 Unknown Class [0600]: Unknown Vendor Unknown Device [8086:1237]
[0][INFO] 00:01 Unknown Class [0601]: Unknown Vendor Unknown Device [8086:7000]
[0][INFO] 00:02 Unknown Class [0300]: Unknown Vendor Unknown Device [1234:1111], BAR0 Memory32 { address: 0xFD000000, size: 0x1000000, prefetchable: true }, BAR2 Memory32 { address: 0xFEBD0000, size: 0x1000, prefetchable: false }
[0][INFO] 00:03 Unknown Class [0200]: Unknown Vendor Unknown Device [10EC:8139], IRQ 11, BAR0 IO { port: 0xC000 }, BAR1 Memory32 { address: 0xFEBD1000, size: 0x100, prefetchable: false }
[0][INFO] ======================================================================
[0][INFO]
[0][INFO] Hermit is running on common system!
[0][INFO] Try to initialize network!
[0][INFO] Try to initialize uhyve filesystem
[0][INFO] Jumping into application

thread 'main' panicked at src/main.rs:15:58:
called `Result::unwrap()` on an `Err` value: Kind(InvalidInput)
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Number of interrupts
[0][FPU]: 1
exit status -1

line 15 is just copied from the simple http server example:

#[cfg(target_os = "hermit")]
use hermit as _;

fn handle_request(request: tiny_http::Request) {
    eprintln!("{request:?}");

    let now_utc = time::OffsetDateTime::now_utc();
    let text = format!("Hello from Hermit! 🦀\nThe current date and time in UTC is {now_utc}.");
    let response = tiny_http::Response::from_string(text);

    request.respond(response).unwrap();
}

fn main() {
    let server = tiny_http::Server::http("0.0.0.0:9975").unwrap();
    eprintln!("Now listening on port 9975");

    for request in server.incoming_requests() {
        handle_request(request);

        if cfg!(feature = "ci") {
            break;
        }
    }
}

did I mess up the QEMU command somehow or?

I also have the same error if i run it through uhvye, but my understanding is that probably doesn't work? (would be great if it did :D )

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions