History log of /cloud-hypervisor/api_client/src/lib.rs (Results 1 – 17 of 17)
Revision Date Author Comments
# 190a11f2 10-Jun-2025 Philipp Schuster <philipp.schuster@cyberus-technology.de>

ch-remote: also pretty-print remote server errors

Remote server errors are transferred as raw HTTP body. This way,
we lose the nested structured error information.

This is an attempt to retrieve th

ch-remote: also pretty-print remote server errors

Remote server errors are transferred as raw HTTP body. This way,
we lose the nested structured error information.

This is an attempt to retrieve the errors from the HTTP response
and to align the output with the normal error output.

For example, this produces the following chain of errors. Note
that everything after level 0 was retrieved from the HTTP server
response:

```
Error: ch-remote exited with the following chain of errors:
0: http client error
1: Server responded with InternalServerError
2: Error from API
3: The disk could not be added to the VM
4: Failed to validate config
5: Identifier disk1 is not unique

Debug Info: HttpApiClient(ServerResponse(InternalServerError, Some("Error from API<br>The disk could not be added to the VM<br>Failed to validate config<br>Identifier disk1 is not unique")))
```

In case the JSON can't be parsed properly, ch-remote will print:

```
Error: ch-remote exited with the following chain of errors:
0: http client error
X: Can't get remote's error messages from JSON response: EOF while parsing a value at line 1 column 0: body=''

Debug Info: HttpApiClient(ServerResponse(InternalServerError, Some("")))
```

Signed-off-by: Philipp Schuster <philipp.schuster@cyberus-technology.de>
On-behalf-of: SAP philipp.schuster@sap.com

show more ...


# 3f3489e3 21-May-2025 Philipp Schuster <philipp.schuster@cyberus-technology.de>

misc: api_client: streamline error Display::fmt()

The changes were mostly automatically applied using the Python
script mentioned in the first commit of this series.

Signed-off-by: Philipp Schuster

misc: api_client: streamline error Display::fmt()

The changes were mostly automatically applied using the Python
script mentioned in the first commit of this series.

Signed-off-by: Philipp Schuster <philipp.schuster@cyberus-technology.de>
On-behalf-of: SAP philipp.schuster@sap.com

show more ...


# 38380198 19-May-2025 Philipp Schuster <philipp.schuster@cyberus-technology.de>

misc: api_client: streamline #[source] and Error

This streamlines the code base to follow best practices for
error handling in Rust: Each error struct implements
std::error::Error (most due via this

misc: api_client: streamline #[source] and Error

This streamlines the code base to follow best practices for
error handling in Rust: Each error struct implements
std::error::Error (most due via thiserror::Error derive macro)
and sets its source accordingly.

This allows future work that nicely prints the error chains,
for example.

So far, the convention is that each error prints its
sub error as part of its Display::fmt() impl.

Signed-off-by: Philipp Schuster <philipp.schuster@cyberus-technology.de>
On-behalf-of: SAP philipp.schuster@sap.com

show more ...


# 1968805b 25-Apr-2025 Fabiano Fidêncio <fidencio@northflank.com>

api_client: Add `TooManyRequests` status code

In order to be on-pair with what's we're using from micro-http, let's
also add the proper status code here as well (as it will be used by
`ch-remote`).

api_client: Add `TooManyRequests` status code

In order to be on-pair with what's we're using from micro-http, let's
also add the proper status code here as well (as it will be used by
`ch-remote`).

Signed-off-by: Fabiano Fidêncio <fidencio@northflank.com>

show more ...


# 88a9f799 29-Sep-2024 Rob Bradford <rbradford@rivosinc.com>

misc: Adapt consistent import style formatting

Historically the Cloud Hypervisor coding style has been to ensure that
all imports are ordered and placed in a single group. Unfortunately
cargo fmt ha

misc: Adapt consistent import style formatting

Historically the Cloud Hypervisor coding style has been to ensure that
all imports are ordered and placed in a single group. Unfortunately
cargo fmt has no support for ensuring that all imports are in a single
group so if whitespace lines were added as part of the import statements
then they would only be odered correctly in the group.

By adopting "group_imports="StdExternalCrate" we can enforce a style
where imports are placed in at most three groups for std, external
crates and the crate itself. Choosing a style enforceable by the tooling
reduces the reviewer burden.

Signed-off-by: Rob Bradford <rbradford@rivosinc.com>

show more ...


# 4ad44caa 12-Sep-2024 Alyssa Ross <hi@alyssa.is>

api_client: show response body in ServerResponse

Otherwise, you just see output like "Error running command: Server
responded with an error: InternalServerError", which isn't very
helpful. The resp

api_client: show response body in ServerResponse

Otherwise, you just see output like "Error running command: Server
responded with an error: InternalServerError", which isn't very
helpful. The response body used to be include with the message, but
was removed when the Error enum was converted to thiserror.

Fixes: 5d0d56f5 ("api_client: Use thiserror for errors")
Signed-off-by: Alyssa Ross <hi@alyssa.is>

show more ...


# c3d69a9b 03-May-2024 SamrutGadde <samrut.gadde@gmail.com>

api_client: Updated error message for sending fds

Updated error message for the SocketSendFds error to be more
descriptive.

Signed-off-by: SamrutGadde <samrut.gadde@gmail.com>


# 5d0d56f5 01-May-2024 SamrutGadde <samrut.gadde@gmail.com>

api_client: Use thiserror for errors

Added thiserror crate for Error enums to the api_client package

Signed-off-by: SamrutGadde <samrut.gadde@gmail.com>


# 5e527294 14-Dec-2022 Rob Bradford <robert.bradford@intel.com>

misc: Automatically fix cargo clippy issues added in 1.65 (stable)

Signed-off-by: Rob Bradford <robert.bradford@intel.com>


# cd0208fe 28-Sep-2022 James O. D. Hunt <james.o.hunt@intel.com>

api-client: Allow response to be captured

Previously, the API response was always written to stdout, but that may
not be appropriate for all clients.

The client can now control this behaviour as th

api-client: Allow response to be captured

Previously, the API response was always written to stdout, but that may
not be appropriate for all clients.

The client can now control this behaviour as the client API returns the
response in the `Result`.

Fixes: #4703.

Signed-off-by: James O. D. Hunt <james.o.hunt@intel.com>

show more ...


# eea9bcea 28-Sep-2022 James O. D. Hunt <james.o.hunt@intel.com>

api-client: Refactor to removed hard-coded prefix

The existing API client only allows access to "VM" operations, so added
a new `simple_api_full_command_with_fds()` that allows access to "VMM"
opera

api-client: Refactor to removed hard-coded prefix

The existing API client only allows access to "VM" operations, so added
a new `simple_api_full_command_with_fds()` that allows access to "VMM"
operations too.

Also added a `simple_api_full_command()` to avoid having to specify the
file descriptors, in a similar manner to `simple_api_command()`.

Fixes: #4701.

Signed-off-by: James O. D. Hunt <james.o.hunt@intel.com>

show more ...


# 87c0791d 26-Jul-2022 Maximilian Nitsch <maximilian.nitsch@d3tn.com>

api-client: Handle body_offset is None

Handle the case `body_offset` is `None` instead of calling `unwrap()`
which leads to a panic.

Signed-off-by: Maximilian Nitsch <maximilian.nitsch@d3tn.com>


# 686e6d50 25-Jul-2022 Maximilian Nitsch <maximilian.nitsch@d3tn.com>

api-client: Break the receive loop if the VMM shuts down the socket

Breaks the receive loop of the API client when the VMM shuts down the
socket connection. A shutdown is indicated by the return val

api-client: Break the receive loop if the VMM shuts down the socket

Breaks the receive loop of the API client when the VMM shuts down the
socket connection. A shutdown is indicated by the return value 0 of the
`recv()` system call.[^1][^2] This case was not handled before, so the
API client tried infinitely to receive more bytes and did not return.

[^1]: https://linux.die.net/man/2/recv
[^2]: https://doc.rust-lang.org/std/io/trait.Read.html#tymethod.read

Signed-off-by: Maximilian Nitsch <maximilian.nitsch@d3tn.com>

show more ...


# 9af2968a 20-Jul-2021 Sebastien Boeuf <sebastien.boeuf@intel.com>

api_client: Add ability to send file descriptors

Allow the user to send a list of file descriptors along with the HTTP
request.

Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>


# 7a18e247 29-Mar-2021 Gaelan Steele <gbs@canishe.com>

api_client: use Option::map in get_header

It's more idiomatic Rust, and satisfies nightly clippy.

Signed-off-by: Gaelan Steele <gbs@canishe.com>


# 030d6046 25-Mar-2021 Rob Bradford <robert.bradford@intel.com>

api_client: Address Rust 1.51.0 clippy issue (upper_case_acroynms)

--> api_client/src/lib.rs:40:5
|
40 | OK,
| ^^ help: consider making the acronym lowercase, except the initial lett

api_client: Address Rust 1.51.0 clippy issue (upper_case_acroynms)

--> api_client/src/lib.rs:40:5
|
40 | OK,
| ^^ help: consider making the acronym lowercase, except the initial letter (notice the capitalization): `Ok`
|
= note: `-D clippy::upper-case-acronyms` implied by `-D warnings`
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#upper_case_acronyms

Signed-off-by: Rob Bradford <robert.bradford@intel.com>

show more ...


# 8de3bd72 23-Oct-2020 Rob Bradford <robert.bradford@intel.com>

ch-remote, api_client: Split HTTP/API client code into new crate

Split out the HTTP request handling code from ch-remote into a new
crate which can be used in other places where talking to the API s

ch-remote, api_client: Split HTTP/API client code into new crate

Split out the HTTP request handling code from ch-remote into a new
crate which can be used in other places where talking to the API server
by HTTP is necessary.

Signed-off-by: Rob Bradford <robert.bradford@intel.com>

show more ...