diff --git a/src/machine/machine-varlink.c b/src/machine/machine-varlink.c index 60792d76b1d..968da3cfb59 100644 --- a/src/machine/machine-varlink.c +++ b/src/machine/machine-varlink.c @@ -153,6 +153,8 @@ int vl_method_register(Varlink *link, JsonVariant *parameters, VarlinkMethodFlag } r = machine_link(manager, machine); + if (r == -EEXIST) + return varlink_error(link, "io.systemd.Machine.MachineExists", NULL); if (r < 0) return r; diff --git a/src/shared/varlink-io.systemd.Machine.c b/src/shared/varlink-io.systemd.Machine.c index 66754920763..2d25a345d79 100644 --- a/src/shared/varlink-io.systemd.Machine.c +++ b/src/shared/varlink-io.systemd.Machine.c @@ -16,7 +16,10 @@ static VARLINK_DEFINE_METHOD( VARLINK_DEFINE_INPUT(sshAddress, VARLINK_STRING, VARLINK_NULLABLE), VARLINK_DEFINE_INPUT(sshPrivateKeyPath, VARLINK_STRING, VARLINK_NULLABLE)); +static VARLINK_DEFINE_ERROR(MachineExists); + VARLINK_DEFINE_INTERFACE( io_systemd_Machine, "io.systemd.Machine", - &vl_method_Register); + &vl_method_Register, + &vl_error_MachineExists); diff --git a/src/vmspawn/vmspawn-register.c b/src/vmspawn/vmspawn-register.c index ed70df5fb83..42650b82c00 100644 --- a/src/vmspawn/vmspawn-register.c +++ b/src/vmspawn/vmspawn-register.c @@ -58,7 +58,6 @@ int register_machine( if (r < 0) return log_error_errno(r, "Failed to connect to machined on /run/systemd/machine/io.systemd.Machine: %m"); - return varlink_callb_and_log(vl, "io.systemd.Machine.Register", NULL,