varlink-io.systemd.MachineInstance,vmspawn: treat AddStorage/RemoveStorage name as opaque

The 'name' field on AddStorage and RemoveStorage was documented as
'<provider>:<volume>' and enforced via machine_storage_name_split() at
the varlink boundary. That form is only the convention machinectl
inherits from the StorageProvider routing path; the API itself only
needs a unique identifier the caller can re-use to detach the binding.

Drop the strict format check, require only a non-empty string, and
update the IDL docs to describe the field as a caller-supplied
identifier with machinectl's convention as a non-normative example.

Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org>
This commit is contained in:
Christian Brauner
2026-05-12 22:54:08 +02:00
parent 968d189414
commit 91575e3a5a
2 changed files with 4 additions and 4 deletions
@@ -29,14 +29,14 @@ static SD_VARLINK_DEFINE_METHOD(
AddStorage,
SD_VARLINK_FIELD_COMMENT("Index of the attached file descriptor for the storage volume"),
SD_VARLINK_DEFINE_INPUT(fileDescriptorIndex, SD_VARLINK_INT, 0),
SD_VARLINK_FIELD_COMMENT("Unique storage name of the form '<provider>:<volume>' identifying this binding for later removal"),
SD_VARLINK_FIELD_COMMENT("Caller-supplied identifier for this binding (any non-empty string; machinectl uses '<provider>:<volume>' from the StorageProvider, but the form is not required)"),
SD_VARLINK_DEFINE_INPUT(name, SD_VARLINK_STRING, 0),
SD_VARLINK_FIELD_COMMENT("Backend-specific configuration"),
SD_VARLINK_DEFINE_INPUT(config, SD_VARLINK_STRING, SD_VARLINK_NULLABLE));
static SD_VARLINK_DEFINE_METHOD(
RemoveStorage,
SD_VARLINK_FIELD_COMMENT("Unique storage name '<provider>:<volume>' to detach"),
SD_VARLINK_FIELD_COMMENT("Identifier of the binding to detach (as supplied to AddStorage)"),
SD_VARLINK_DEFINE_INPUT(name, SD_VARLINK_STRING, 0));
static SD_VARLINK_DEFINE_METHOD(
+2 -2
View File
@@ -197,7 +197,7 @@ static int vl_method_add_storage(sd_varlink *link, sd_json_variant *parameters,
if (r != 0)
return r;
if (machine_storage_name_split(p.name, /* ret_provider= */ NULL, /* ret_volume= */ NULL) < 0)
if (isempty(p.name))
return sd_varlink_error_invalid_parameter_name(link, "name");
if (disk_type_from_bind_volume_config(p.config) < 0)
@@ -239,7 +239,7 @@ static int vl_method_remove_storage(sd_varlink *link, sd_json_variant *parameter
if (r != 0)
return r;
if (machine_storage_name_split(p.name, /* ret_provider= */ NULL, /* ret_volume= */ NULL) < 0)
if (isempty(p.name))
return sd_varlink_error_invalid_parameter_name(link, "name");
return vmspawn_qmp_remove_block_device(ctx->bridge, link, p.name);