lxd/profiles_utils.go
func doProfileUpdateContainer(d *Daemon, name string, old api.ProfilePut, nodeName string, args db.ContainerArgs) error {
	if args.Node != "" && args.Node != nodeName {
		// No-op, this container does not belong to this node.
		return nil
	}

	profiles, err := d.cluster.ProfilesGet(args.Project, args.Profiles)
	if err != nil {
		return err
	}
	for i, profileName := range args.Profiles {
		if profileName == name {
			// Use the old config and devices.
			profiles[i].Config = old.Config
			profiles[i].Devices = old.Devices
			break
		}
	}

	c := containerLXCInstantiate(d.State(), args)

	c.expandConfig(profiles)
	c.expandDevices(profiles)

	return c.Update(db.ContainerArgs{
		Architecture: c.Architecture(),
		Config:       c.LocalConfig(),
		Description:  c.Description(),
		Devices:      c.LocalDevices(),
		Ephemeral:    c.IsEphemeral(),
		Profiles:     c.Profiles(),
		Project:      c.Project(),
	}, true)
}
func doProfileUpdateContainer(d *Daemon, name string, old api.ProfilePut, nodeName string, args db.ContainerArgs) error {
	if args.Node != "" && args.Node != nodeName {
		// No-op, this container does not belong to this node.
		return nil
	}

	profiles, err := d.cluster.ProfilesGet(args.Project, args.Profiles)
	if err != nil {
		return err
	}
	for i, profileName := range args.Profiles {
		if profileName == name {
			// Use the old config and devices.
			profiles[i].Config = old.Config
			profiles[i].Devices = old.Devices
			break
		}
	}

	c := containerLXCInstantiate(d.State(), args)

	c.expandConfig(profiles)
	c.expandDevices(profiles)

	return c.Update(db.ContainerArgs{
		Architecture: c.Architecture(),
		Config:       c.LocalConfig(),
		Description:  c.Description(),
		Devices:      c.LocalDevices(),
		Ephemeral:    c.IsEphemeral(),
		Profiles:     c.Profiles(),
		Project:      c.Project(),
	}, true)
}
// Profile update of a single container.