99 Commits

Author SHA1 Message Date
Changyuan Lyu
7975fe0e59 micro_http: fix doctest socket conflicts
Doctests in `lib.rs` and `server.rs` were both using the same hardcoded
socket path `/tmp/example.sock`. When running tests in parallel, this
caused conflicts and sporadic failures with `AddrInUse`.

Fix this by using unique socket paths for each doctest.

Assisted-by: Antigravity:Gemini-3.5-Flash
Signed-off-by: Changyuan Lyu <changyuanl@google.com>
2026-07-31 12:28:23 +01:00
Stepan Rabotkin
f2d91703a1 feat: add support for the 409 Conflict status code
Add a Conflict variant to the StatusCode enum so that responses can
report the 409 status code, and map it to its raw representation.

Signed-off-by: Stepan Rabotkin <epicstyt@gmail.com>
2026-07-30 09:00:59 +01:00
Ilias Stamatis
876f3feccc Add support for the HTTP DELETE method
Add a Delete variant to the Method enum to support DELETE requests.
Reject DELETE requests with a body (same as GET requests).

Signed-off-by: Ilias Stamatis <ilstam@amazon.com>
2026-04-09 12:12:30 +01:00
Ilias Stamatis
9228ffdcc5 chore: Update coverage due to rust-vmm-ci change
Signed-off-by: Ilias Stamatis <ilstam@amazon.com>
2026-04-08 16:30:15 +01:00
dependabot[bot]
4c23e4802b build(deps): bump rust-vmm-ci from 042b206 to 112dd9f
Bumps [rust-vmm-ci](https://github.com/rust-vmm/rust-vmm-ci) from `042b206` to `112dd9f`.
- [Commits](042b2063b2...112dd9ffb2)

---
updated-dependencies:
- dependency-name: rust-vmm-ci
  dependency-version: 112dd9ffb22aa44d147b8e46a0d1cf02d341a708
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-04-08 16:30:15 +01:00
Egor Lazarchuk
5c2254d6cf chore: fix lifetime related warning
Specify a hidden lifetime to remove a warning message.

Signed-off-by: Egor Lazarchuk <yegorlz@amazon.co.uk>
2025-11-20 15:34:06 +00:00
Egor Lazarchuk
87d0d801a4 chore: update vmm-sys-util to 0.15.0
update vmm-sys-util to 0.15.0

Signed-off-by: Egor Lazarchuk <yegorlz@amazon.co.uk>
2025-11-20 15:34:06 +00:00
Egor Lazarchuk
936b18fce6 chore: fix doc comments
Signed-off-by: Egor Lazarchuk <yegorlz@amazon.co.uk>
2025-11-04 10:32:15 +00:00
dependabot[bot]
9e748fd2d9 Bump rust-vmm-ci from fc4584d to 042b206
Bumps [rust-vmm-ci](https://github.com/rust-vmm/rust-vmm-ci) from `fc4584d` to `042b206`.
- [Commits](fc4584d8b8...042b2063b2)

---
updated-dependencies:
- dependency-name: rust-vmm-ci
  dependency-version: 042b2063b276a7593aeee24e8ca4f8eef2c8ac7e
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-11-04 10:32:15 +00:00
dependabot[bot]
3248ceeae4 Bump rust-vmm-ci from aa2f8a9 to fc4584d
Bumps [rust-vmm-ci](https://github.com/rust-vmm/rust-vmm-ci) from `aa2f8a9` to `fc4584d`.
- [Commits](aa2f8a90e4...fc4584d8b8)

---
updated-dependencies:
- dependency-name: rust-vmm-ci
  dependency-version: fc4584d8b805be4e8193d43d9ba6519f9a0f43a5
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-09-02 13:12:52 -04:00
Takahiro Itazuri
98d85677ba feat: Allow to set custom headers in response
EC2 IMDS includes X-Aws-Ec2-Metadata-Token-Ttl-Seconds header in the
response to PUT /latest/api/token. To enable Firecracker MMDS to behave
compatibly with EC2 IMDS, allow to set custom headers in HTTP response.

Signed-off-by: Takahiro Itazuri <itazur@amazon.com>
2025-07-23 11:13:45 +01:00
dependabot[bot]
11cc5da16a Bump rust-vmm-ci from c3ef897 to aa2f8a9
Bumps [rust-vmm-ci](https://github.com/rust-vmm/rust-vmm-ci) from `c3ef897` to `aa2f8a9`.
- [Commits](c3ef897738...aa2f8a90e4)

---
updated-dependencies:
- dependency-name: rust-vmm-ci
  dependency-version: aa2f8a90e46533de8a58f19cd0c417de856d4437
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-07-02 09:45:47 +02:00
Babis Chalios
bf50989160 chore: update vmm-sys-util to 0.14.0
This version updates FamStruct types and we need it in Firecracker.

Signed-off-by: Babis Chalios <bchalios@amazon.es>
2025-05-30 17:15:01 +02:00
Fabiano Fidêncio
4f621532e8 response: Add "TooManyRequests" status code
The addition of the "TooManyRequests" status code is in order to notify
users when an operation is still pending, and this seems to be the best
fit we can have for now.

On the Cloud Hypervisor side we'll use it, for instance, for the case
when a caller tries to offline a vCPU but the previous offline operation
is still pending, leaving at least a chance for the caller to analyse
the error and decide whether they want to retry the operation or not.

TooManyRequests: https://datatracker.ietf.org/doc/html/rfc6585#section-4

Signed-off-by: Fabiano Fidêncio <fidencio@northflank.com>
2025-04-25 13:11:52 +01:00
dependabot[bot]
e854e50bc0 Bump rust-vmm-ci from 2d733b0 to c3ef897
Bumps [rust-vmm-ci](https://github.com/rust-vmm/rust-vmm-ci) from `2d733b0` to `c3ef897`.
- [Commits](2d733b05f0...c3ef897738)

---
updated-dependencies:
- dependency-name: rust-vmm-ci
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-04-02 09:50:03 +01:00
dependabot[bot]
18f5b6f5f5 Bump rust-vmm-ci from 09aef99 to 2d733b0
Bumps [rust-vmm-ci](https://github.com/rust-vmm/rust-vmm-ci) from `09aef99` to `2d733b0`.
- [Commits](09aef997d8...2d733b05f0)

---
updated-dependencies:
- dependency-name: rust-vmm-ci
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-03-03 09:55:10 +00:00
Patrick Roy
ef96f623c4 chore: update coverage
Signed-off-by: Patrick Roy <roypat@amazon.co.uk>
2025-01-14 12:31:04 +00:00
Patrick Roy
f6e139f591 fix: appease clippy
Signed-off-by: Patrick Roy <roypat@amazon.co.uk>
2025-01-14 12:31:04 +00:00
dependabot[bot]
88348257d1 Bump rust-vmm-ci from 5e818dc to 09aef99
Bumps [rust-vmm-ci](https://github.com/rust-vmm/rust-vmm-ci) from `5e818dc` to `09aef99`.
- [Commits](5e818dc729...09aef997d8)

---
updated-dependencies:
- dependency-name: rust-vmm-ci
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-01-14 12:31:04 +00:00
dependabot[bot]
8182cd5523 Bump rust-vmm-ci from 7606478 to 5e818dc
Bumps [rust-vmm-ci](https://github.com/rust-vmm/rust-vmm-ci) from `7606478` to `5e818dc`.
- [Commits](7606478202...5e818dc729)

---
updated-dependencies:
- dependency-name: rust-vmm-ci
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-09-02 17:17:11 +01:00
Patrick Roy
ef43cef716 chore: appease clippy
Fix clippy lints now triggered due to upgraded rust toolchain

Signed-off-by: Patrick Roy <roypat@amazon.co.uk>
2024-02-22 11:41:58 +00:00
dependabot[bot]
ca770460cc Bump rust-vmm-ci from 665f31f to 7606478
Bumps [rust-vmm-ci](https://github.com/rust-vmm/rust-vmm-ci) from `665f31f` to `7606478`.
- [Commits](665f31f4b4...7606478202)

---
updated-dependencies:
- dependency-name: rust-vmm-ci
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-02-22 11:41:58 +00:00
Takahiro Itazuri
7e2684d779 fix: Always set Content-Length field in non-100/204 responses
The client may wait for the server to close the connection or for
timeout to occur in some cases. This commit changes it to always set
Content-Length field in non-100/204 responses regardless of whether
the body is empty. Although it doesn't cover all the patterns where
the response must not set it, users can remove it by calling
`set_content_length(None)`.

Signed-off-by: Takahiro Itazuri <itazur@amazon.com>
2024-02-21 13:18:09 +00:00
Patrick Roy
e75dfa1eee Update vmm-sys-util to 0.12.0
The update brings a fix for a security vulnerability behind
feature-gated code not used by micro-http (the `with-serde` feature),
see GHSA-875g-mfp6-g7f9

Signed-off-by: Patrick Roy <roypat@amazon.co.uk>
2024-01-02 17:07:08 +00:00
Jonathan Woollett-Light
a4d632f2c5 Update code coverage
Signed-off-by: Jonathan Woollett-Light <jcawl@amazon.co.uk>
2023-09-20 14:31:34 +01:00
dependabot[bot]
805996140d Bump rust-vmm-ci from 607c775 to 665f31f
Bumps [rust-vmm-ci](https://github.com/rust-vmm/rust-vmm-ci) from `607c775` to `665f31f`.
- [Commits](607c775dde...665f31f4b4)

---
updated-dependencies:
- dependency-name: rust-vmm-ci
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-09-20 14:31:34 +01:00
Jonathan Woollett-Light
925ce3ec03 Dependabot
Adds dependabot configuration to update rust-vmm-ci submodule.

Signed-off-by: Jonathan Woollett-Light <jcawl@amazon.co.uk>
2023-09-20 14:13:56 +01:00
Egor Lazarchuk
0d0fdcd50e chore(coverage): adjusted coverage
Signed-off-by: Egor Lazarchuk <yegorlz@amazon.co.uk>
2023-08-24 17:56:59 +01:00
acatangiu
73f37d0797 Impl PartialEq on ServerError for tests
Co-authored-by: acatangiu <adrian@parity.io>
Signed-off-by: Egor Lazarchuk <yegorlz@amazon.co.uk>
2023-08-24 17:56:59 +01:00
acatangiu
3c5d9407d3 Add kill switch functionality
Added shutdown event-fd acting as a kill switch actionable from
outside the micro-http server.

Needed to be able to break out of the inner epoll_wait on demand.

This can be used to signal the micro-http server running on a
dedicated thread that it needs to shut down.

Co-authored-by: acatangiu <adrian.catangiu@gmail.com>
Signed-off-by: Egor Lazarchuk <yegorlz@amazon.co.uk>
2023-08-24 17:56:59 +01:00
Patrick Roy
b538bf89e5 Update rust-vmm-ci submodule
We need to pick an increase in the default timeout due to an epoll_wait
regression in linux. See rust-vmm/rust-vmm-ci@dbb2e7f

Signed-off-by: Patrick Roy <roypat@amazon.co.uk>
2023-01-27 09:51:25 +02:00
Jonathan
fbef706e28 Update to Rust 2021 edition
Signed-off-by: Jonathan Woollett-Light <jcawl@amazon.co.uk>
2023-01-11 11:27:26 +02:00
Patrick Roy
4b18a043e9 Update rust-vmm/vmm-sys-util and use caret reqs
vmm-sys-util 0.9.0 -> 0.11.0

See https://github.com/rust-vmm/community/issues/136

Signed-off-by: Patrick Roy <roypat@amazon.co.uk>
2022-11-22 16:39:06 +01:00
Patrick Roy
c37a727685 Rename coverage_config.json
The new rust-vmm-ci differentiates between aarch and x86_64 coverage

Signed-off-by: Patrick Roy <roypat@amazon.co.uk>
2022-11-22 12:15:22 +02:00
Patrick Roy
43d5a1d4b0 Clear all clippy warnings
Additionally, HttpServer::new_from_fd has been marked as unsafe,
since the correctness of the unsafe call within the function
relies on the caller upholding an invariant

Signed-off-by: Patrick Roy <roypat@amazon.co.uk>
2022-11-22 12:15:22 +02:00
Patrick Roy
d2caafab0e Run cargo fmt
The CI requirements for formatting have changed over the past 3 years

Signed-off-by: Patrick Roy <roypat@amazon.co.uk>
2022-11-22 12:15:22 +02:00
Patrick Roy
f3e710ce26 updated rust-vmm-ci
7af2e16 add support for specifying the agent queue
e2e2918 generate pipeline: support for FW unknown keys
b0edd17 autogenerate_pipeline: use dictionary instead of self
edd221a don't allow undocumented unsafe blocks
5f36cc9 fix whitespace problems in autogenerate script
2eab275 allow the timeout to be overwritten in input
1401bad fix test benchmark
258161e update README with latest version
6fbd7c7 fix test commit format
b3ed1c9 update to container version 16
99fe2eb Relax 50/72 rule for more descriptive titles
ee6be8c make coverage test less sensitive to changes
d216a46 Update to rustvmm/dev:v15 with Rust 1.58.1
d023262 Use v14 container image with Rust 1.54
b6858b2 run `cargo audit` with `--deny warnings` enabled
aee82cf Add @gsserge to CODEOWNERS
b037be3 update test_coverage to allow running it on crates
7931077 Assert no spaces in crate features JSON
68d4dbf Check formatting of code examples in doc comments
7f22582 update container version to v13
ce13bfb Make build warnings fatal, again
472dea0 Document default timeout for pipeline step
f67ef4c Update README.md
dd754bb Add timeout for Buildkite steps
e58c6f6 Remove static pipeline
6e1bdaa Make build warnings fatal
ae7db2d Rename master to main
1311bfa Update clippy test command
d7ca3dc Add help option for scripts
8901e77 Leftovers from #79
555474a Add script to run tests locally
cd3d97f Allow skipping tests when generating the pipeline
cc6ed99 Format integration tests code
ba2f45c make the test description configurable
877d1fb Update README.md
b47488a Autogenerate pipeline fron json config file
a00c7d2 Update the pipeline steps that run the tests
0b9d283 Create local rust crate and update config path
7693628 Update commit format test to work locally
d2ab3c0 use the latest docker plugin version
9f7b0d9 check commit authors for each commit
6591890 use rust-vmm-container v12
24d66cd update clippy check
ebc7016 exclude dependabot from the 50/72 commit rule
63fdf0f update rust-vmm-container
98a26fe Typo fix in README.md
631c82a mount tmp in test pipelines
03fcf08 don't run commit test for repos specified with git
3b7377c fixed typo in readme
c9430ee add gitignore file
e1108f1 buildkite: re-enable cargo audit test
02004b5 Add a flag that saves the coverage output dir
97025bd buildkite: Skip lines should be shorter than 70 chars
c83003c buildkite: Skip cargo audit check temporarily
c8cf2b7 buildkite: Fix audit label indentation
b3acb30 Fixes: https://github.com/rust-vmm/rust-vmm-ci/issues/8
bedc32b Add --workspace flag to cargo check too
3ea5f2b improve a bit error messages for commit test
cd90a63 Add support for workspace tests
9dd386c readme update: cosmetic changes
265df53 Coverage test: keep stdin open
2d3bb05 add myself to codeowners
e58ea74 Fix kcov_ouput_dir typo in test_coverage.py
d62d781 fix buildkite typos in readme
0fc8ced refactor test_benchmark.py
741b894 checkout to PR branch before finishing test_bench
645a5c3 test_bench: don't crash when no bench on master
bd32544 Fetch origin in benchmark test
35beb91 Fix commit message test
53427aa benchmarks: add test that can run at every PR
abd2c90 Add test for commit message format
fe859f4 Update container image to v6
75d7254 run cargo check on all features
7e3f307 skip coverage-arm test
cd7096e Enable rust-vmm coverage test in CI

Signed-off-by: Patrick Roy <roypat@amazon.co.uk>
2022-11-22 12:15:22 +02:00
Jonathan Woollett-Light
863b0370ba Clarifying unix-like support
Added `build.rs` to  produce a compile error when attempting to build on a
non-Unix-like system, and clarified support in `readme.md`.

Signed-off-by: Jonathan Woollett-Light <jcawl@amazon.co.uk>
2022-06-13 09:39:48 +03:00
Sebastien Boeuf
a730d86940 Receive multiple file descriptors with a Request
Extending the existing code to support receiving more than one file
descriptor per request. The micro-http crate might be used in a context
where multiple file descriptors are associated with one request, hence
the need to update the micro-http crate.

A concrete example from Cloud Hypervisor is to be able to pass multiple
TAP file descriptors at once when adding a new network interface. This
way it can hotplug a multiqueue device.

Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
2022-01-28 19:30:22 +02:00
George Pisaltu
0a58eb1ece added support for Deprecation header
This commit adds support for the `Deprecation` HTTP header based on
https://tools.ietf.org/id/draft-dalal-deprecation-header-03.html .
Users can set this header in a `Response` to send a
"Deprecation: true" header field back to the requester, signaling
that the resource accessed has been deprecated.

Signed-off-by: George Pisaltu <gpl@amazon.com>
2021-10-19 20:37:52 +03:00
AlexandruCihodaru
36e59a083e Updated coverage
Signed-off-by: AlexandruCihodaru <cihodar@amazon.com>
2021-09-03 13:56:22 +03:00
AlexandruCihodaru
51923caf61 Add optional limit on request size
Signed-off-by: AlexandruCihodaru <cihodar@amazon.com>
2021-09-03 13:56:22 +03:00
AlexandruCihodaru
ba4e5a0917 Added payload too large response
Signed-off-by: AlexandruCihodaru <cihodar@amazon.com>
Suggested-by: George Pisaltu <gpl@amazon.com>
2021-09-03 13:56:22 +03:00
Luminita Voicu
c1a38b507c response: add Unauthorized status code
Signed-off-by: Luminita Voicu <lumivo@amazon.com>
2021-08-09 17:18:31 +03:00
Sebastien Boeuf
9517a30037 Retrieve the optional file associated with a Request
The sever is now able to get any optional file descriptor that might
have been sent over with the bytes related to a request. This patch
leverages this ability by extending the Request structure with an
optional File, which might have been received from the byte stream.

With the Request containing an optional File, we give the consumers of
this crate the possibility to receive a file descriptor associated with
the HTTP request.

Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
2021-07-14 16:42:48 +03:00
Sebastien Boeuf
3c4cc3aa91 Expect stream to implement ScmSocket trait
The stream used by the Connection structure is expected to implement
both Read and Write traits. Since we want the server to be able to
receive file descriptors through control messages mechanism, this patch
extends the expectations regarding the stream by adding ScmSocket to the
list of traits.

Since the stream is a UnixStream structure, and since vmm-sys-util
already provides an ScmSocket implementation for UnixStream, extending
the list of traits is very straightforward.

Relying on the newly added trait, the server now reads incoming bytes
through recv_with_fd() function, which replaces the former call to
read(). This change has no intent of modifying the former behavior from
the read(), which is why the returned Option<File> is ignored for now.

Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
2021-07-14 16:42:48 +03:00
Luminita Voicu
81a3c71efb increase coverage
Signed-off-by: Luminita Voicu <lumivo@amazon.com>
2021-07-09 11:32:22 +03:00
Luminita Voicu
03c7869d43 add custom headers support
Signed-off-by: Luminita Voicu <lumivo@amazon.com>
2021-07-09 11:32:22 +03:00
Luminita Voicu
eb8b8cb53d Add optional limit on request size
Signed-off-by: Luminita Voicu <lumivo@amazon.com>
2021-07-09 11:32:22 +03:00
Luminita Voicu
7f3a14f16f forbid GET requests with body content
Signed-off-by: Luminita Voicu <lumivo@amazon.com>
2021-07-09 11:32:22 +03:00