Skip to content

Commit

Permalink
Moved the swagger/firecracker.yaml definition to the
Browse files Browse the repository at this point in the history
refactor: move api_server as a module inside firecracke

Signed-off-by: Matias Teragni <[email protected]>
  • Loading branch information
MatiasT authored and roypat committed Jan 19, 2024
1 parent 5bc3751 commit 6414a07
Show file tree
Hide file tree
Showing 18 changed files with 26 additions and 30 deletions.
4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 92,7 @@ Firecracker's overall architecture is described in

Firecracker consists of a single micro Virtual Machine Manager process that
exposes an API endpoint to the host once started. The API is
[specified in OpenAPI format](
src/firecracker/src/api_server/swagger/firecracker.yaml
). Read more
[specified in OpenAPI format](src/firecracker/swagger/firecracker.yaml). Read more
about it in the [API docs](docs/api_requests).

The **API endpoint** can be used to:
Expand Down
4 changes: 1 addition & 3 deletions SPECIFICATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 19,7 @@ enough RAM, etc.), customers can rely on the following:
they are logged<sup>2</sup> by the Firecracker process.
1. **API Stability:** The API socket is always available and the API conforms
to the in-tree
[Open API specification](
src/firecracker/src/api_server/swagger/firecracker.yaml
). API failures
[Open API specification](src/firecracker/swagger/firecracker.yaml). API failures
are logged in the Firecracker log.
1. **Overhead:** For a Firecracker virtual machine manager running a microVM
with `1 CPUs and 128 MiB of RAM`, and a guest OS with the Firecracker-tuned
Expand Down
2 changes: 1 addition & 1 deletion docs/api_requests/actions.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 4,7 @@ Firecracker microVMs can execute actions that can be triggered via `PUT`
requests on the `/actions` resource.

Details about the required fields can be found in the
[swagger definition](../../src/firecracker/src/api_server/swagger/firecracker.yaml).
[swagger definition](../../src/firecracker/swagger/firecracker.yaml).

## InstanceStart

Expand Down
2 changes: 1 addition & 1 deletion docs/api_requests/patch-network-interface.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 58,7 @@ Accept: application/json
```

The full specification of the data structures available for this call can be
found in our [OpenAPI spec](../../src/firecracker/src/api_server/swagger/firecracker.yaml).
found in our [OpenAPI spec](../../src/firecracker/swagger/firecracker.yaml).

**Note**: The data provided for the update is merged with the existing data.
In the above example, the RX rate limit is updated, but the TX rate limit
Expand Down
6 changes: 3 additions & 3 deletions docs/device-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 34,7 @@ a call to one of the [API Endpoints](#api-endpoints) will fail with a
## Input Schema

All input schema fields can be found in the [Swagger](https://swagger.io)
specification: [firecracker.yaml](./../src/firecracker/src/api_server/swagger/firecracker.yaml).
specification: [firecracker.yaml](./../src/firecracker/swagger/firecracker.yaml).

| Schema | Property | keyboard | serial console | virtio-block | vhost-user-block | virtio-net | virtio-vsock | virtio-rng |
|----------------------------|-----------------------| :------: | :------------: | :----------: | :--------------: | :-----------: | :----------: | :--------: |
Expand Down Expand Up @@ -108,7 108,7 @@ virtio-net, virtio-block and virtio-rng devices.
## Output Schema

All output schema fields can be found in the [Swagger](https://swagger.io)
specification: [firecracker.yaml](./../src/firecracker/src/api_server/swagger/firecracker.yaml).
specification: [firecracker.yaml](./../src/firecracker/swagger/firecracker.yaml).

| Schema | Property | keyboard | serial console | virtio-block | vhost-user-block | virtio-net | virtio-vsock |
| ---------------------- | ----------------- | :------: | :------------: | :----------: | :--------------: | :--------: | :----------: |
Expand All @@ -126,7 126,7 @@ specification: [firecracker.yaml](./../src/firecracker/src/api_server/swagger/fi
## Instance Actions

All instance actions can be found in the [Swagger](https://swagger.io)
specification: [firecracker.yaml](./../src/firecracker/src/api_server/swagger/firecracker.yaml).
specification: [firecracker.yaml](./../src/firecracker/swagger/firecracker.yaml).

| Action | keyboard | serial console | virtio-block | vhost-user-block | virtio-net | virtio-vsock |
| ---------------- | :------: | :------------: | :----------: | :--------------: | :--------: | :----------: |
Expand Down
2 changes: 1 addition & 1 deletion docs/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 277,7 @@ optional. This configuration method will also start the microVM, as such you
need to specify all desired pre-boot configurable resources in the JSON. The
names of the resources can be seen in
[`firecracker.yaml`]
(../src/firecracker/src/api_server/swagger/firecracker.yaml) and the
(../src/firecracker/swagger/firecracker.yaml) and the
names of their fields are the same that are used in the API requests.

An example of configuration file is provided:
Expand Down
2 changes: 1 addition & 1 deletion docs/logger.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 37,7 @@ curl --unix-socket /tmp/firecracker.socket -i \
```

Details about the required and optional fields can be found in the
[swagger definition](../src/firecracker/src/api_server/swagger/firecracker.yaml).
[swagger definition](../src/firecracker/swagger/firecracker.yaml).

## Using command line parameters for configuration

Expand Down
2 changes: 1 addition & 1 deletion docs/metrics.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 43,7 @@ curl --unix-socket /tmp/firecracker.socket -i \
```

Details about this configuration can be found in the
[swagger definition](../src/firecracker/src/api_server/swagger/firecracker.yaml).
[swagger definition](../src/firecracker/swagger/firecracker.yaml).

The metrics are written to the `metrics_path` in JSON format.

Expand Down
2 changes: 1 addition & 1 deletion docs/mmds/mmds-design.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 116,7 @@ a reply.

Somewhat confusingly, this is the name of the component which taps the device
model. It has a user-configured IPv4 address (see
[Firecracker MMDS configuration API](../../src/firecracker/src/api_server/swagger/firecracker.yaml))
[Firecracker MMDS configuration API](../../src/firecracker/swagger/firecracker.yaml))
and MAC (`06:01:23:45:67:01`) addresses. The latter is also used to respond to
ARP requests.
For every frame coming from the guest, the following steps take place:
Expand Down
10 changes: 5 additions & 5 deletions docs/mmds/mmds-user-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 14,11 @@ achieved in two steps:

1. Attach one (or more) network interfaces through an HTTP `PUT` request to
`/network-interfaces/${MMDS_NET_IF}`. The full network configuration API
can be found in the [firecracker swagger file](../../src/firecracker/src/api_server/swagger/firecracker.yaml).
can be found in the [firecracker swagger file](../../src/firecracker/swagger/firecracker.yaml).
1. Configure MMDS through an HTTP `PUT` request to `/mmds/config` resource and
include the IDs of the network interfaces that should allow forwarding requests
to MMDS in the `network_interfaces` list. The complete MMDS API is described in
the [firecracker swagger file](../../src/firecracker/src/api_server/swagger/firecracker.yaml).
the [firecracker swagger file](../../src/firecracker/swagger/firecracker.yaml).

### Examples

Expand Down Expand Up @@ -114,7 114,7 @@ issued. This request must have a payload with metadata structured in
metadata, a subsequent HTTP `PUT` request to the `/mmds` resource must be
issued, using as a payload the new metadata. A complete description of
metadata insertion firecracker API can be found in the
[firecracker swagger file](../../src/firecracker/src/api_server/swagger/firecracker.yaml).
[firecracker swagger file](../../src/firecracker/swagger/firecracker.yaml).

An example of an API request for inserting metadata is provided below:

Expand Down Expand Up @@ -149,7 149,7 @@ To partially update existing metadata, an HTTP `PATCH` request to the `/mmds`
resource has to be issued, using as a payload the metadata patch, as
[JSON Merge Patch](https://tools.ietf.org/html/rfc7396) functionality
describes. A complete description of updating metadata Firecracker API can be
found in the [firecracker swagger file](../../src/firecracker/src/api_server/swagger/firecracker.yaml).
found in the [firecracker swagger file](../../src/firecracker/swagger/firecracker.yaml).

An example API for how to update existing metadata is offered below:

Expand Down Expand Up @@ -190,7 190,7 @@ To retrieve existing MMDS metadata from host operating system, an HTTP `GET`
request to the `/mmds` resource must be issued. The HTTP response returns the
existing metadata, as a JSON formatted text. A complete description of
retrieving metadata Firecracker API can be found in the
[firecracker swagger file](../../src/firecracker/src/api_server/swagger/firecracker.yaml).
[firecracker swagger file](../../src/firecracker/swagger/firecracker.yaml).

Below you can see how to retrieve metadata from the host:

Expand Down
4 changes: 2 additions & 2 deletions docs/snapshotting/snapshot-support.md
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 270,7 @@ curl --unix-socket /tmp/firecracker.socket -i \
```

Details about the required and optional fields can be found in the
[swagger definition](../../src/firecracker/src/api_server/swagger/firecracker.yaml).
[swagger definition](../../src/firecracker/swagger/firecracker.yaml).

*Note*: If the files indicated by `snapshot_path` and `mem_file_path` don't
exist at the specified paths, then they will be created right before generating
Expand Down Expand Up @@ -446,7 446,7 @@ curl --unix-socket /tmp/firecracker.socket -i \
```

Details about the required and optional fields can be found in the
[swagger definition](../../src/firecracker/src/api_server/swagger/firecracker.yaml).
[swagger definition](../../src/firecracker/swagger/firecracker.yaml).

**Prerequisites**: A full memory snapshot and a microVM state file **must** be
provided. The disk backing files, network interfaces backing TAPs and/or vsock
Expand Down
2 changes: 1 addition & 1 deletion src/firecracker/src/api_server/request/balloon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 51,8 @@ pub(crate) fn parse_patch_balloon(

#[cfg(test)]
mod tests {
use crate::api_server::parsed_request::tests::vmm_action_from_request;
use super::*;
use crate::api_server::parsed_request::tests::vmm_action_from_request;

#[test]
fn test_parse_get_balloon_request() {
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions src/vmm/src/logger/logging.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 16,7 @@ use utils::time::LocalTime;
use super::metrics::{IncMetric, METRICS};

/// Default level filter for logger matching the swagger specification
/// (`src/api_server/swagger/firecracker.yaml`).
/// (`src/firecracker/swagger/firecracker.yaml`).
pub const DEFAULT_LEVEL: log::LevelFilter = log::LevelFilter::Info;
/// Default instance id.
pub const DEFAULT_INSTANCE_ID: &str = "anonymous-instance";
Expand All @@ -25,7 25,7 @@ pub static INSTANCE_ID: OnceLock<String> = OnceLock::new();

/// The logger.
///
/// Default values matching the swagger specification (`src/api_server/swagger/firecracker.yaml`).
/// Default values matching the swagger specification (`src/firecracker/swagger/firecracker.yaml`).
pub static LOGGER: Logger = Logger(Mutex::new(LoggerConfiguration {
target: None,
filter: LogFilter { module: None },
Expand Down
2 changes: 1 addition & 1 deletion tests/integration_tests/style/test_swagger.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 18,5 @@ def test_firecracker_swagger():
"""
Test that Firecracker swagger specification is valid.
"""
swagger_spec = Path("../src/firecracker/src/api_server/swagger/firecracker.yaml")
swagger_spec = Path("../src/firecracker/swagger/firecracker.yaml")
validate_swagger(swagger_spec)
2 changes: 1 addition & 1 deletion tools/bump-version.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 32,7 @@ prev_ver=$(get_swagger_version)
say "Updating from $prev_ver to $version ..."
# Update version in files.
files_to_change=(
"$FC_ROOT_DIR/src/api_server/swagger/firecracker.yaml"
"$FC_ROOT_DIR/src/firecracker/swagger/firecracker.yaml"
"$FC_ROOT_DIR/src/firecracker/Cargo.toml"
"$FC_ROOT_DIR/src/jailer/Cargo.toml"
"$FC_ROOT_DIR/src/rebase-snap/Cargo.toml"
Expand Down
2 changes: 1 addition & 1 deletion tools/functions
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 103,7 @@ get_user_confirmation() {

# Get version from the swagger file
function get_swagger_version {
local file=${1:-"$FC_ROOT_DIR/src/api_server/swagger/firecracker.yaml"}
local file=${1:-"$FC_ROOT_DIR/src/firecracker/swagger/firecracker.yaml"}
grep -oP 'version: \K.*' "$file"
}

Expand Down
4 changes: 2 additions & 2 deletions tools/release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 161,8 @@ done
cp -v "resources/seccomp/$CARGO_TARGET.json" "$RELEASE_DIR/seccomp-filter-$SUFFIX.json"
# Copy over arch independent assets
cp -v -t "$RELEASE_DIR" LICENSE NOTICE THIRD-PARTY
check_swagger_artifact src/api_server/swagger/firecracker.yaml "$VERSION"
cp -v src/api_server/swagger/firecracker.yaml "$RELEASE_DIR/firecracker_spec-$VERSION.yaml"
check_swagger_artifact src/firecracker/swagger/firecracker.yaml "$VERSION"
cp -v src/firecracker/swagger/firecracker.yaml "$RELEASE_DIR/firecracker_spec-$VERSION.yaml"

CPU_TEMPLATES=(c3 t2 t2s t2cl t2a v1n1)
for template in "${CPU_TEMPLATES[@]}"; do
Expand Down

0 comments on commit 6414a07

Please sign in to comment.