Skip to main content

org.avocado.Runtimes

Manages the lifecycle of Avocado Linux runtimes. A runtime is a versioned bundle comprising an OS image, an initramfs, and a set of extensions described by a manifest. This interface provides methods to list available runtimes, stage new runtimes from remote or local sources, activate a staged runtime, remove staged runtimes, and inspect runtime details.

Interface Definition

Types

RuntimeInfo

Basic identity of a runtime.

FieldTypeDescription
namestringRuntime name
versionstringRuntime version string

ManifestExtension

An extension declared in the runtime manifest.

FieldTypeDescription
namestringExtension name
versionstringExtension version string
imageId?stringImage digest used to verify the downloaded extension artifact

Runtime

Full description of a runtime, including its manifest metadata, constituent extensions, and activation state.

FieldTypeDescription
idstringUnique runtime identifier (hex digest)
manifestVersionintManifest schema version
builtAtstringISO 8601 timestamp of when the runtime was built
runtimeRuntimeInfoRuntime name and version
extensions[]ManifestExtensionExtensions included in this runtime
activebooltrue if this is the currently active runtime
osBuildId?stringOS image build identifier. A change in this value triggers an OS update on activation.
initramfsBuildId?stringInitramfs build identifier

Methods

List

List all available runtimes, both staged and active.

Signature: List() -> (runtimes: []Runtime)

Parameters: None.

Returns:

FieldTypeDescription
runtimes[]RuntimeArray of all known runtimes

C Example:

VarlinkObject *parameters = NULL;
VarlinkObject *reply = NULL;
long r;

varlink_object_new(&parameters);
r = varlink_connection_call(connection, "org.avocado.Runtimes.List", parameters, 0, &reply);
if (r < 0) {
fprintf(stderr, "Call failed: %s\n", varlink_error_string(-r));
varlink_object_unref(parameters);
return;
}

VarlinkArray *runtimes;
varlink_object_get_array(reply, "runtimes", &runtimes);

for (unsigned long i = 0; i < varlink_array_get_n_elements(runtimes); i++) {
VarlinkObject *rt;
varlink_array_get_object(runtimes, i, &rt);

const char *id;
bool active;
varlink_object_get_string(rt, "id", &id);
varlink_object_get_bool(rt, "active", &active);

VarlinkObject *info;
varlink_object_get_object(rt, "runtime", &info);

const char *name, *version;
varlink_object_get_string(info, "name", &name);
varlink_object_get_string(info, "version", &version);

printf("%-12s %s %s%s\n", id, name, version, active ? " [active]" : "");
}

varlink_object_unref(reply);
varlink_object_unref(parameters);

AddFromUrl

Stage a new runtime by downloading its manifest and artifacts from a TUF repository.

Signature: AddFromUrl(url: string, authToken: ?string, artifactsUrl: ?string) -> (message: string, done: bool, runtime: ?Runtime)

Parameters:

FieldTypeDescription
urlstringTUF repository URL
authToken?stringOptional bearer token for authenticated endpoints
artifactsUrl?stringOptional separate URL for artifact downloads. If omitted, artifacts are fetched from the TUF repository URL.

Returns (streaming):

FieldTypeDescription
messagestringProgress message
donebooltrue on the final reply
runtime?RuntimeThe staged runtime object, present only in the final reply

Streaming: Yes. Call with VARLINK_CALL_MORE to receive download and verification progress.

C Example:

VarlinkObject *parameters = NULL;
long r;

varlink_object_new(&parameters);
varlink_object_set_string(parameters, "url", "https://tuf.example.com/repo");
varlink_object_set_string(parameters, "authToken", "my-bearer-token");

r = varlink_connection_call(connection, "org.avocado.Runtimes.AddFromUrl",
parameters, VARLINK_CALL_MORE, NULL);
if (r < 0) {
fprintf(stderr, "Call failed: %s\n", varlink_error_string(-r));
varlink_object_unref(parameters);
return;
}

VarlinkObject *reply = NULL;
while ((r = varlink_connection_reply(connection, &reply)) >= 0) {
const char *error_name = NULL;
if (varlink_reply_is_error(reply, &error_name)) {
fprintf(stderr, "Error: %s\n", error_name);
varlink_object_unref(reply);
break;
}

const char *message;
varlink_object_get_string(reply, "message", &message);
printf("[add] %s\n", message);

bool done;
varlink_object_get_bool(reply, "done", &done);

if (done) {
VarlinkObject *runtime;
if (varlink_object_get_object(reply, "runtime", &runtime) >= 0) {
const char *id;
varlink_object_get_string(runtime, "id", &id);
printf("Staged runtime: %s\n", id);
}
}

varlink_object_unref(reply);
reply = NULL;

if (done)
break;
}

varlink_object_unref(parameters);

AddFromManifest

Stage a new runtime from a local manifest file. The manifest references artifacts that must already be present on the local filesystem or accessible via the paths declared in the manifest.

Signature: AddFromManifest(manifestPath: string) -> (message: string, done: bool, runtime: ?Runtime)

Parameters:

FieldTypeDescription
manifestPathstringAbsolute path to the local manifest file

Returns (streaming):

FieldTypeDescription
messagestringProgress message
donebooltrue on the final reply
runtime?RuntimeThe staged runtime object, present only in the final reply

Streaming: Yes. Call with VARLINK_CALL_MORE to receive progress updates.

C Example:

VarlinkObject *parameters = NULL;
long r;

varlink_object_new(&parameters);
varlink_object_set_string(parameters, "manifestPath", "/tmp/runtime-manifest.json");

r = varlink_connection_call(connection, "org.avocado.Runtimes.AddFromManifest",
parameters, VARLINK_CALL_MORE, NULL);
if (r < 0) {
fprintf(stderr, "Call failed: %s\n", varlink_error_string(-r));
varlink_object_unref(parameters);
return;
}

VarlinkObject *reply = NULL;
while ((r = varlink_connection_reply(connection, &reply)) >= 0) {
const char *message;
varlink_object_get_string(reply, "message", &message);
printf("[add-manifest] %s\n", message);

bool done;
varlink_object_get_bool(reply, "done", &done);

if (done) {
VarlinkObject *runtime;
if (varlink_object_get_object(reply, "runtime", &runtime) >= 0) {
const char *id;
varlink_object_get_string(runtime, "id", &id);
printf("Staged runtime: %s\n", id);
}
}

varlink_object_unref(reply);
reply = NULL;

if (done)
break;
}

varlink_object_unref(parameters);

Remove

Remove a staged runtime by its ID or an unambiguous ID prefix.

Signature: Remove(id: string) -> ()

Parameters:

FieldTypeDescription
idstringRuntime ID or unique prefix

Returns: Empty on success.

C Example:

VarlinkObject *parameters = NULL;
VarlinkObject *reply = NULL;
long r;

varlink_object_new(&parameters);
varlink_object_set_string(parameters, "id", "a1b2c3");

r = varlink_connection_call(connection, "org.avocado.Runtimes.Remove", parameters, 0, &reply);
if (r < 0) {
fprintf(stderr, "Call failed: %s\n", varlink_error_string(-r));
varlink_object_unref(parameters);
return;
}

const char *error_name = NULL;
if (varlink_reply_is_error(reply, &error_name)) {
fprintf(stderr, "Error: %s\n", error_name);

/* Check for ambiguous ID */
VarlinkArray *candidates;
if (varlink_object_get_array(reply, "candidates", &candidates) >= 0) {
fprintf(stderr, "Matching runtimes:\n");
for (unsigned long i = 0; i < varlink_array_get_n_elements(candidates); i++) {
const char *candidate;
varlink_array_get_string(candidates, i, &candidate);
fprintf(stderr, " %s\n", candidate);
}
}
} else {
printf("Runtime removed.\n");
}

varlink_object_unref(reply);
varlink_object_unref(parameters);

Activate

Activate a staged runtime. If the runtime's osBuildId differs from the currently running OS, this triggers an OS update (writing the new OS image to the inactive partition and configuring the bootloader). A reboot is required to complete the update.

Signature: Activate(id: string) -> (message: string, done: bool, runtime: ?Runtime)

Parameters:

FieldTypeDescription
idstringRuntime ID or unique prefix

Returns (streaming):

FieldTypeDescription
messagestringProgress message (e.g., writing OS image, enabling extensions)
donebooltrue on the final reply
runtime?RuntimeThe activated runtime object, present only in the final reply

Streaming: Yes. Call with VARLINK_CALL_MORE to receive progress updates. This is especially useful during OS updates, which may take significant time.

C Example:

VarlinkObject *parameters = NULL;
long r;

varlink_object_new(&parameters);
varlink_object_set_string(parameters, "id", "a1b2c3");

r = varlink_connection_call(connection, "org.avocado.Runtimes.Activate",
parameters, VARLINK_CALL_MORE, NULL);
if (r < 0) {
fprintf(stderr, "Call failed: %s\n", varlink_error_string(-r));
varlink_object_unref(parameters);
return;
}

VarlinkObject *reply = NULL;
while ((r = varlink_connection_reply(connection, &reply)) >= 0) {
const char *error_name = NULL;
if (varlink_reply_is_error(reply, &error_name)) {
fprintf(stderr, "Activation error: %s\n", error_name);
const char *reason;
if (varlink_object_get_string(reply, "reason", &reason) >= 0) {
fprintf(stderr, "Reason: %s\n", reason);
}
varlink_object_unref(reply);
break;
}

const char *message;
varlink_object_get_string(reply, "message", &message);
printf("[activate] %s\n", message);

bool done;
varlink_object_get_bool(reply, "done", &done);

if (done) {
VarlinkObject *runtime;
if (varlink_object_get_object(reply, "runtime", &runtime) >= 0) {
const char *id;
varlink_object_get_string(runtime, "id", &id);
printf("Activated runtime: %s\n", id);
}
}

varlink_object_unref(reply);
reply = NULL;

if (done)
break;
}

varlink_object_unref(parameters);

Inspect

Inspect the details of a specific runtime. If id is omitted, the currently active runtime is inspected.

Signature: Inspect(id: ?string) -> (runtime: Runtime)

Parameters:

FieldTypeDescription
id?stringRuntime ID or unique prefix. Omit to inspect the active runtime.

Returns:

FieldTypeDescription
runtimeRuntimeThe full runtime object

C Example:

VarlinkObject *parameters = NULL;
VarlinkObject *reply = NULL;
long r;

/* Omit "id" to inspect the active runtime */
varlink_object_new(&parameters);

r = varlink_connection_call(connection, "org.avocado.Runtimes.Inspect", parameters, 0, &reply);
if (r < 0) {
fprintf(stderr, "Call failed: %s\n", varlink_error_string(-r));
varlink_object_unref(parameters);
return;
}

const char *error_name = NULL;
if (varlink_reply_is_error(reply, &error_name)) {
fprintf(stderr, "Error: %s\n", error_name);
varlink_object_unref(reply);
varlink_object_unref(parameters);
return;
}

VarlinkObject *runtime;
varlink_object_get_object(reply, "runtime", &runtime);

const char *id, *built_at;
bool active;
varlink_object_get_string(runtime, "id", &id);
varlink_object_get_string(runtime, "builtAt", &built_at);
varlink_object_get_bool(runtime, "active", &active);

VarlinkObject *info;
varlink_object_get_object(runtime, "runtime", &info);

const char *name, *version;
varlink_object_get_string(info, "name", &name);
varlink_object_get_string(info, "version", &version);

printf("Runtime: %s %s\n", name, version);
printf("ID: %s\n", id);
printf("Built: %s\n", built_at);
printf("Active: %s\n", active ? "yes" : "no");

VarlinkArray *extensions;
varlink_object_get_array(runtime, "extensions", &extensions);
printf("Extensions:\n");
for (unsigned long i = 0; i < varlink_array_get_n_elements(extensions); i++) {
VarlinkObject *ext;
varlink_array_get_object(extensions, i, &ext);

const char *ext_name, *ext_version;
varlink_object_get_string(ext, "name", &ext_name);
varlink_object_get_string(ext, "version", &ext_version);
printf(" %s %s\n", ext_name, ext_version);
}

varlink_object_unref(reply);
varlink_object_unref(parameters);

Errors

RuntimeNotFound

Returned when the specified runtime ID does not match any known runtime.

ParameterTypeDescription
idstringThe ID that was not found

Trigger: Passing an unknown ID to Remove, Activate, or Inspect.

AmbiguousRuntimeId

Returned when the specified ID prefix matches more than one runtime. The response includes the list of matching candidate IDs so the caller can present them to the user or retry with a longer prefix.

ParameterTypeDescription
idstringThe ambiguous prefix
candidates[]stringFull IDs of all matching runtimes

Trigger: Passing a short ID prefix to Remove, Activate, or Inspect that matches multiple runtimes.

RemoveActiveRuntime

Returned when attempting to remove the currently active runtime. The active runtime cannot be removed.

Parameters: None.

Trigger: Calling Remove with the ID of the active runtime.

StagingFailed

Returned when staging a new runtime fails during download, verification, or installation.

ParameterTypeDescription
reasonstringHuman-readable failure description

Trigger: TUF metadata verification failure, artifact download error, disk space exhaustion, or corrupt manifest in AddFromUrl or AddFromManifest.

UpdateFailed

Returned when the OS update triggered by Activate fails.

ParameterTypeDescription
reasonstringHuman-readable failure description

Trigger: OS image write failure, bootloader configuration error, or extension enable/merge failure during Activate.