From: Christian Brauner Date: Fri, 8 May 2026 08:42:55 +0000 (+0200) Subject: shared/varlink-io.systemd.MachineInstance: add ReplaceStorage method X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3063448b51b4fcfcdd51f015db9260292ce70fab;p=thirdparty%2Fsystemd.git shared/varlink-io.systemd.MachineInstance: add ReplaceStorage method Define the IDL for io.systemd.MachineInstance.ReplaceStorage, a runtime hot-swap of an already-attached storage volume's backing file. The signature mirrors AddStorage minus the 'config' field because the device frontend (virtio-blk, virtio-scsi, nvme, scsi-cd) does not change — only the backing file behind it. The implementation lives in vmspawn (next commit) and uses QMP blockdev-reopen to swap the file child of the existing format node. The reused error vocabulary (NoSuchStorage, StorageImmutable, NotConnected, plus the generic errno path) covers every failure mode; no new errors are added. Signed-off-by: Christian Brauner (Amutable) --- diff --git a/src/shared/varlink-io.systemd.MachineInstance.c b/src/shared/varlink-io.systemd.MachineInstance.c index 66304027098..b496ea565c4 100644 --- a/src/shared/varlink-io.systemd.MachineInstance.c +++ b/src/shared/varlink-io.systemd.MachineInstance.c @@ -39,6 +39,13 @@ static SD_VARLINK_DEFINE_METHOD( SD_VARLINK_FIELD_COMMENT("Unique storage name ':' to detach"), SD_VARLINK_DEFINE_INPUT(name, SD_VARLINK_STRING, 0)); +static SD_VARLINK_DEFINE_METHOD( + ReplaceStorage, + SD_VARLINK_FIELD_COMMENT("Index of the attached file descriptor for the new backing storage"), + SD_VARLINK_DEFINE_INPUT(fileDescriptorIndex, SD_VARLINK_INT, 0), + SD_VARLINK_FIELD_COMMENT("Identifier of the existing binding whose backing is being replaced (as supplied to AddStorage)"), + SD_VARLINK_DEFINE_INPUT(name, SD_VARLINK_STRING, 0)); + static SD_VARLINK_DEFINE_ERROR(NotConnected); static SD_VARLINK_DEFINE_ERROR(NotSupported); static SD_VARLINK_DEFINE_ERROR(NoSuchStorage); @@ -68,6 +75,8 @@ SD_VARLINK_DEFINE_INTERFACE( &vl_method_AddStorage, SD_VARLINK_SYMBOL_COMMENT("Detach a previously-attached storage volume from the running machine"), &vl_method_RemoveStorage, + SD_VARLINK_SYMBOL_COMMENT("Replace the backing of a previously-attached storage volume in place"), + &vl_method_ReplaceStorage, SD_VARLINK_SYMBOL_COMMENT("The connection to the machine backend is not available"), &vl_error_NotConnected, SD_VARLINK_SYMBOL_COMMENT("The requested operation is not supported"),