diff --git a/lxd/instance/drivers/driver_qemu.go b/lxd/instance/drivers/driver_qemu.go index f86f6ec6a031..4d9d3efcac83 100644 --- a/lxd/instance/drivers/driver_qemu.go +++ b/lxd/instance/drivers/driver_qemu.go @@ -7777,11 +7777,17 @@ func (d *qemu) Render(options ...func(response any) error) (state any, etag any, etag := []any{d.expiryDate} snapState := api.InstanceSnapshot{ - CreatedAt: d.creationDate, + Name: strings.SplitN(d.name, "/", 2)[1], + Architecture: d.architectureName, + Profiles: profileNames, + Config: d.localConfig, ExpandedConfig: d.expandedConfig, + Devices: d.localDevices.CloneNative(), ExpandedDevices: d.expandedDevices.CloneNative(), + CreatedAt: d.creationDate, LastUsedAt: d.lastUsedDate, - Name: strings.SplitN(d.name, "/", 2)[1], + ExpiresAt: d.expiryDate, + Ephemeral: d.ephemeral, Stateful: d.stateful, // Default to uninitialised/error state (0 means no CoW usage). @@ -7789,13 +7795,6 @@ func (d *qemu) Render(options ...func(response any) error) (state any, etag any, Size: -1, } - snapState.Architecture = d.architectureName - snapState.Config = d.localConfig - snapState.Devices = d.localDevices.CloneNative() - snapState.Ephemeral = d.ephemeral - snapState.Profiles = profileNames - snapState.ExpiresAt = d.expiryDate - for _, option := range options { err := option(&snapState) if err != nil { @@ -7810,9 +7809,19 @@ func (d *qemu) Render(options ...func(response any) error) (state any, etag any, etag = []any{d.architecture, d.localConfig, d.localDevices, d.ephemeral, d.profiles} instState := api.Instance{ + Name: d.name, + Description: d.description, + Architecture: d.architectureName, + Profiles: profileNames, + Config: d.localConfig, ExpandedConfig: d.expandedConfig, + Devices: d.localDevices.CloneNative(), ExpandedDevices: d.expandedDevices.CloneNative(), - Name: d.name, + CreatedAt: d.creationDate, + LastUsedAt: d.lastUsedDate, + Ephemeral: d.ephemeral, + Stateful: d.stateful, + Project: d.project.Name, Location: d.node, Type: d.Type().String(), StatusCode: api.Error, // Default to error status for remote instances that are unreachable. @@ -7825,17 +7834,6 @@ func (d *qemu) Render(options ...func(response any) error) (state any, etag any, instState.Status = instState.StatusCode.String() - instState.Description = d.description - instState.Architecture = d.architectureName - instState.Config = d.localConfig - instState.CreatedAt = d.creationDate - instState.Devices = d.localDevices.CloneNative() - instState.Ephemeral = d.ephemeral - instState.LastUsedAt = d.lastUsedDate - instState.Profiles = profileNames - instState.Stateful = d.stateful - instState.Project = d.project.Name - for _, option := range options { err := option(&instState) if err != nil {