SimonSapin / qemu-fw-cfg-rs

A Rust library for reading QEMU fw_cfg

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

qemu-fw-cfg-rs

Crates.io License-MIT License-Apache docs.rs

A Rust library for reading fw_cfg from QEMU.

Usage

Add the following to your Cargo.toml:

[dependencies]
qemu-fw-cfg = "0.1"

To use qemu-fw-cfg without alloc, you can use this instead:

[dependencies]
qemu-fw-cfg = { version = "0.1", default-features = false }

Examples

use qemu_fw_cfg::FwCfg;

// Verify that we are inside QEMU.
if running_in_qemu() {
    // Create a new `FwCfg` instance.
    let fw_cfg = unsafe { FwCfg::new().unwrap() };
    // Retrieve information of a file.
    let file = fw_cfg.find_file("etc/igd-opregion").unwrap();
    // Read data from the file.
    let data = fw_cfg.read_file(&file);
}

Rust support

Currently, qemu-fw-cfg required nightly compiler to build.

License

This project is licensed under either of Apache License, Version 2.0 or MIT license at your option.

About

A Rust library for reading QEMU fw_cfg

License:Apache License 2.0


Languages

Language:Rust 92.4%Language:Shell 4.5%Language:Assembly 3.2%