[lxc-devel] [lxd/master] Project: Rename Prefix() to Instance()

tomponline on Github lxc-bot at linuxcontainers.org
Wed Mar 4 08:41:40 UTC 2020


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 338 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20200304/f8c02650/attachment-0001.bin>
-------------- next part --------------
From 6bb1303ee0e03e6b72fff063d286f5e0e418d16c Mon Sep 17 00:00:00 2001
From: Thomas Parrott <thomas.parrott at canonical.com>
Date: Wed, 4 Mar 2020 08:19:14 +0000
Subject: [PATCH 1/3] lxd/project/project: Renames Prefix() to Instance()

This is to indicate that this prefix function should only be used with instance names or objects that follow the same project prefix logic as instance names.

This is for legacy project prefixes, where the "default" project did not have a prefix.

Signed-off-by: Thomas Parrott <thomas.parrott at canonical.com>
---
 lxd/project/project.go | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/lxd/project/project.go b/lxd/project/project.go
index d79e259ba5..89882a526c 100644
--- a/lxd/project/project.go
+++ b/lxd/project/project.go
@@ -11,12 +11,13 @@ const Default = "default"
 // separator is used to delimit the project name from the suffix.
 const separator = "_"
 
-// Prefix Add the "<project>_" prefix when the given project name is not "default".
-func Prefix(project string, suffix string) string {
-	if project != Default {
-		suffix = fmt.Sprintf("%s%s%s", project, separator, suffix)
+// Instance Adds the "<project>_" prefix to instance name when the given project name is not "default".
+func Instance(projectName string, instanceName string) string {
+	if projectName != Default {
+		return fmt.Sprintf("%s%s%s", projectName, separator, instanceName)
 	}
-	return suffix
+
+	return instanceName
 }
 
 // InstanceParts takes a project prefixed Instance name string and returns the project and instance name.

From 170adb188e9ada1a7f0566222bacb0c530dda87c Mon Sep 17 00:00:00 2001
From: Thomas Parrott <thomas.parrott at canonical.com>
Date: Wed, 4 Mar 2020 08:22:15 +0000
Subject: [PATCH 2/3] lxd: project.Instance() usage

Signed-off-by: Thomas Parrott <thomas.parrott at canonical.com>
---
 lxd/api_internal.go                      |  2 +-
 lxd/apparmor/apparmor.go                 |  6 +--
 lxd/backup.go                            |  4 +-
 lxd/backup/backup.go                     | 10 ++--
 lxd/container_backup.go                  |  2 +-
 lxd/container_logs.go                    |  2 +-
 lxd/container_post.go                    |  2 +-
 lxd/device/disk.go                       |  2 +-
 lxd/device/proxy.go                      |  2 +-
 lxd/devlxd.go                            |  2 +-
 lxd/dnsmasq/dnsmasq.go                   |  6 +--
 lxd/firewall/drivers/drivers_nftables.go |  2 +-
 lxd/firewall/drivers/drivers_xtables.go  |  2 +-
 lxd/instance/drivers/driver_lxc.go       | 38 +++++++-------
 lxd/instance/drivers/driver_qemu.go      | 26 +++++-----
 lxd/logging.go                           |  2 +-
 lxd/network/network_utils.go             |  6 +--
 lxd/patches_utils.go                     |  2 +-
 lxd/project/project_test.go              |  8 +--
 lxd/storage/backend_lxd.go               | 64 ++++++++++++------------
 lxd/storage/storage.go                   |  8 +--
 21 files changed, 99 insertions(+), 99 deletions(-)

diff --git a/lxd/api_internal.go b/lxd/api_internal.go
index 812fa6d819..78d09e9eb9 100644
--- a/lxd/api_internal.go
+++ b/lxd/api_internal.go
@@ -731,7 +731,7 @@ func internalImport(d *Daemon, r *http.Request) response.Response {
 		// Recreate missing mountpoints and symlinks.
 		snapshotMountPoint := storagePools.GetSnapshotMountPoint(projectName, backupConf.Pool.Name, snap.Name)
 		sourceName, _, _ := shared.InstanceGetParentAndSnapshotName(snap.Name)
-		sourceName = project.Prefix(projectName, sourceName)
+		sourceName = project.Instance(projectName, sourceName)
 		snapshotMntPointSymlinkTarget := shared.VarPath("storage-pools", backupConf.Pool.Name, "containers-snapshots", sourceName)
 		snapshotMntPointSymlink := shared.VarPath("snapshots", sourceName)
 		err = storagePools.CreateSnapshotMountpoint(snapshotMountPoint, snapshotMntPointSymlinkTarget, snapshotMntPointSymlink)
diff --git a/lxd/apparmor/apparmor.go b/lxd/apparmor/apparmor.go
index 54533e325f..3c395baebd 100644
--- a/lxd/apparmor/apparmor.go
+++ b/lxd/apparmor/apparmor.go
@@ -524,7 +524,7 @@ func Namespace(c instance) string {
 	 */
 	lxddir := strings.Replace(strings.Trim(shared.VarPath(""), "/"), "/", "-", -1)
 	lxddir = mkApparmorName(lxddir)
-	name := project.Prefix(c.Project(), c.Name())
+	name := project.Instance(c.Project(), c.Name())
 	return fmt.Sprintf("lxd-%s_<%s>", name, lxddir)
 }
 
@@ -532,12 +532,12 @@ func Namespace(c instance) string {
 func ProfileFull(c instance) string {
 	lxddir := shared.VarPath("")
 	lxddir = mkApparmorName(lxddir)
-	name := project.Prefix(c.Project(), c.Name())
+	name := project.Instance(c.Project(), c.Name())
 	return fmt.Sprintf("lxd-%s_<%s>", name, lxddir)
 }
 
 func profileShort(c instance) string {
-	name := project.Prefix(c.Project(), c.Name())
+	name := project.Instance(c.Project(), c.Name())
 	return fmt.Sprintf("lxd-%s", name)
 }
 
diff --git a/lxd/backup.go b/lxd/backup.go
index 2cabb0dbd8..8aa9e904dc 100644
--- a/lxd/backup.go
+++ b/lxd/backup.go
@@ -137,7 +137,7 @@ func backupCreateTarball(s *state.State, path string, b backup.Backup, c instanc
 	}
 
 	// Create the target path if needed
-	backupsPath := shared.VarPath("backups", project.Prefix(c.Project(), c.Name()))
+	backupsPath := shared.VarPath("backups", project.Instance(c.Project(), c.Name()))
 	if !shared.PathExists(backupsPath) {
 		err := os.MkdirAll(backupsPath, 0700)
 		if err != nil {
@@ -146,7 +146,7 @@ func backupCreateTarball(s *state.State, path string, b backup.Backup, c instanc
 	}
 
 	// Create the tarball
-	backupPath := shared.VarPath("backups", project.Prefix(c.Project(), b.Name()))
+	backupPath := shared.VarPath("backups", project.Instance(c.Project(), b.Name()))
 	success := false
 	defer func() {
 		if success {
diff --git a/lxd/backup/backup.go b/lxd/backup/backup.go
index cd514bf04f..440e8fdb4d 100644
--- a/lxd/backup/backup.go
+++ b/lxd/backup/backup.go
@@ -163,11 +163,11 @@ func (b *Backup) OptimizedStorage() bool {
 
 // Rename renames a container backup
 func (b *Backup) Rename(newName string) error {
-	oldBackupPath := shared.VarPath("backups", project.Prefix(b.instance.Project(), b.name))
-	newBackupPath := shared.VarPath("backups", project.Prefix(b.instance.Project(), newName))
+	oldBackupPath := shared.VarPath("backups", project.Instance(b.instance.Project(), b.name))
+	newBackupPath := shared.VarPath("backups", project.Instance(b.instance.Project(), newName))
 
 	// Create the new backup path
-	backupsPath := shared.VarPath("backups", project.Prefix(b.instance.Project(), b.instance.Name()))
+	backupsPath := shared.VarPath("backups", project.Instance(b.instance.Project(), b.instance.Name()))
 	if !shared.PathExists(backupsPath) {
 		err := os.MkdirAll(backupsPath, 0700)
 		if err != nil {
@@ -218,7 +218,7 @@ func (b *Backup) Render() *api.InstanceBackup {
 
 // DoBackupDelete deletes a backup.
 func DoBackupDelete(s *state.State, projectName, backupName, containerName string) error {
-	backupPath := shared.VarPath("backups", project.Prefix(projectName, backupName))
+	backupPath := shared.VarPath("backups", project.Instance(projectName, backupName))
 
 	// Delete the on-disk data
 	if shared.PathExists(backupPath) {
@@ -229,7 +229,7 @@ func DoBackupDelete(s *state.State, projectName, backupName, containerName strin
 	}
 
 	// Check if we can remove the container directory
-	backupsPath := shared.VarPath("backups", project.Prefix(projectName, containerName))
+	backupsPath := shared.VarPath("backups", project.Instance(projectName, containerName))
 	empty, _ := shared.PathIsEmpty(backupsPath)
 	if empty {
 		err := os.Remove(backupsPath)
diff --git a/lxd/container_backup.go b/lxd/container_backup.go
index d70fc3e9e0..db052da76b 100644
--- a/lxd/container_backup.go
+++ b/lxd/container_backup.go
@@ -351,7 +351,7 @@ func containerBackupExportGet(d *Daemon, r *http.Request) response.Response {
 	}
 
 	ent := response.FileResponseEntry{
-		Path: shared.VarPath("backups", project.Prefix(proj, backup.Name())),
+		Path: shared.VarPath("backups", project.Instance(proj, backup.Name())),
 	}
 
 	return response.FileResponse(r, []response.FileResponseEntry{ent}, nil, false)
diff --git a/lxd/container_logs.go b/lxd/container_logs.go
index 6b6e505429..5edac53ff3 100644
--- a/lxd/container_logs.go
+++ b/lxd/container_logs.go
@@ -130,7 +130,7 @@ func containerLogGet(d *Daemon, r *http.Request) response.Response {
 	}
 
 	ent := response.FileResponseEntry{
-		Path:     shared.LogPath(project.Prefix(projectName, name), file),
+		Path:     shared.LogPath(project.Instance(projectName, name), file),
 		Filename: file,
 	}
 
diff --git a/lxd/container_post.go b/lxd/container_post.go
index c1adad940c..7387fdf101 100644
--- a/lxd/container_post.go
+++ b/lxd/container_post.go
@@ -429,7 +429,7 @@ func containerPostClusteringMigrateWithCeph(d *Daemon, c instance.Instance, proj
 		}
 
 		args := migration.VolumeSourceArgs{
-			Data: project.Prefix(projectName, newName),
+			Data: project.Instance(projectName, newName),
 		}
 
 		// Trigger a rename in the Ceph driver.
diff --git a/lxd/device/disk.go b/lxd/device/disk.go
index fc6ea1117c..7b8dc60c19 100644
--- a/lxd/device/disk.go
+++ b/lxd/device/disk.go
@@ -1106,7 +1106,7 @@ func (d *disk) postStop() error {
 		go func() {
 			err := diskCephRbdUnmap(v["ceph_rbd"])
 			if err != nil {
-				logger.Errorf("Failed to unmap RBD volume '%s' for '%s': %v", v["ceph_rbd"], project.Prefix(d.inst.Project(), d.inst.Name()), err)
+				logger.Errorf("Failed to unmap RBD volume '%s' for '%s': %v", v["ceph_rbd"], project.Instance(d.inst.Project(), d.inst.Name()), err)
 			}
 		}()
 	}
diff --git a/lxd/device/proxy.go b/lxd/device/proxy.go
index d165845a80..6b509aa38d 100644
--- a/lxd/device/proxy.go
+++ b/lxd/device/proxy.go
@@ -333,7 +333,7 @@ func (d *proxy) rewriteHostAddr(addr string) string {
 }
 
 func (d *proxy) setupProxyProcInfo() (*proxyProcInfo, error) {
-	cname := project.Prefix(d.inst.Project(), d.inst.Name())
+	cname := project.Instance(d.inst.Project(), d.inst.Name())
 	cc, err := liblxc.NewContainer(cname, d.state.OS.LxcPath)
 	if err != nil {
 		return nil, err
diff --git a/lxd/devlxd.go b/lxd/devlxd.go
index 2414a22646..31333b5b09 100644
--- a/lxd/devlxd.go
+++ b/lxd/devlxd.go
@@ -122,7 +122,7 @@ var devlxdEventsGet = devLxdHandler{"/1.0/events", func(d *Daemon, c instance.In
 		return &devLxdResponse{"internal server error", http.StatusInternalServerError, "raw"}
 	}
 
-	logger.Debugf("New container event listener for '%s': %s", project.Prefix(c.Project(), c.Name()), listener.ID())
+	logger.Debugf("New container event listener for '%s': %s", project.Instance(c.Project(), c.Name()), listener.ID())
 
 	// Create a cancellable context from the request context. Once the request has been upgraded
 	// to a websocket the request's context doesn't appear to be cancelled when the client
diff --git a/lxd/dnsmasq/dnsmasq.go b/lxd/dnsmasq/dnsmasq.go
index 484623a6ed..a853fe967d 100644
--- a/lxd/dnsmasq/dnsmasq.go
+++ b/lxd/dnsmasq/dnsmasq.go
@@ -48,7 +48,7 @@ func UpdateStaticEntry(network string, projectName string, instanceName string,
 		return nil
 	}
 
-	err := ioutil.WriteFile(shared.VarPath("networks", network, "dnsmasq.hosts", project.Prefix(projectName, instanceName)), []byte(line+"\n"), 0644)
+	err := ioutil.WriteFile(shared.VarPath("networks", network, "dnsmasq.hosts", project.Instance(projectName, instanceName)), []byte(line+"\n"), 0644)
 	if err != nil {
 		return err
 	}
@@ -58,7 +58,7 @@ func UpdateStaticEntry(network string, projectName string, instanceName string,
 
 // RemoveStaticEntry removes a single dhcp-host line for a network/instance combination.
 func RemoveStaticEntry(network string, projectName string, instanceName string) error {
-	err := os.Remove(shared.VarPath("networks", network, "dnsmasq.hosts", project.Prefix(projectName, instanceName)))
+	err := os.Remove(shared.VarPath("networks", network, "dnsmasq.hosts", project.Instance(projectName, instanceName)))
 	if err != nil && !os.IsNotExist(err) {
 		return err
 	}
@@ -115,7 +115,7 @@ func GetVersion() (*version.DottedVersion, error) {
 func DHCPStaticIPs(network, projectName, instanceName string) (DHCPAllocation, DHCPAllocation, error) {
 	var IPv4, IPv6 DHCPAllocation
 
-	file, err := os.Open(shared.VarPath("networks", network, "dnsmasq.hosts", project.Prefix(projectName, instanceName)))
+	file, err := os.Open(shared.VarPath("networks", network, "dnsmasq.hosts", project.Instance(projectName, instanceName)))
 	if err != nil {
 		return IPv4, IPv6, err
 	}
diff --git a/lxd/firewall/drivers/drivers_nftables.go b/lxd/firewall/drivers/drivers_nftables.go
index 60b144ef6e..59309820ba 100644
--- a/lxd/firewall/drivers/drivers_nftables.go
+++ b/lxd/firewall/drivers/drivers_nftables.go
@@ -242,7 +242,7 @@ func (d Nftables) NetworkClear(networkName string, ipVersion uint) error {
 
 //instanceDeviceLabel returns the unique label used for instance device chains.
 func (d Nftables) instanceDeviceLabel(projectName, instanceName, deviceName string) string {
-	return fmt.Sprintf("%s%s%s", project.Prefix(projectName, instanceName), nftablesChainSeparator, deviceName)
+	return fmt.Sprintf("%s%s%s", project.Instance(projectName, instanceName), nftablesChainSeparator, deviceName)
 }
 
 // InstanceSetupBridgeFilter sets up the filter rules to apply bridged device IP filtering.
diff --git a/lxd/firewall/drivers/drivers_xtables.go b/lxd/firewall/drivers/drivers_xtables.go
index 321bdcd29f..1e3a2b741f 100644
--- a/lxd/firewall/drivers/drivers_xtables.go
+++ b/lxd/firewall/drivers/drivers_xtables.go
@@ -250,7 +250,7 @@ func (d Xtables) NetworkClear(networkName string, ipVersion uint) error {
 
 //instanceDeviceIPTablesComment returns the iptables comment that is added to each instance device related rule.
 func (d Xtables) instanceDeviceIPTablesComment(projectName, instanceName, deviceName string) string {
-	return fmt.Sprintf("LXD container %s (%s)", project.Prefix(projectName, instanceName), deviceName)
+	return fmt.Sprintf("LXD container %s (%s)", project.Instance(projectName, instanceName), deviceName)
 }
 
 // InstanceSetupBridgeFilter sets up the filter rules to apply bridged device IP filtering.
diff --git a/lxd/instance/drivers/driver_lxc.go b/lxd/instance/drivers/driver_lxc.go
index bd9cf0a440..79a5aacb27 100644
--- a/lxd/instance/drivers/driver_lxc.go
+++ b/lxd/instance/drivers/driver_lxc.go
@@ -684,7 +684,7 @@ func (c *lxc) initLXC(config bool) error {
 	}
 
 	// Load the go-lxc struct
-	cname := project.Prefix(c.Project(), c.Name())
+	cname := project.Instance(c.Project(), c.Name())
 	cc, err := liblxc.NewContainer(cname, c.state.OS.LxcPath)
 	if err != nil {
 		return err
@@ -1612,7 +1612,7 @@ func (c *lxc) deviceDetachNIC(configCopy map[string]string, netIF []deviceConfig
 	// If container is running, perform live detach of interface back to host.
 	if stopHookNetnsPath == "" {
 		// For some reason, having network config confuses detach, so get our own go-lxc struct.
-		cname := project.Prefix(c.Project(), c.Name())
+		cname := project.Instance(c.Project(), c.Name())
 		cc, err := liblxc.NewContainer(cname, c.state.OS.LxcPath)
 		if err != nil {
 			return err
@@ -2354,7 +2354,7 @@ func (c *lxc) Start(stateful bool) error {
 		}
 	}
 
-	name := project.Prefix(c.Project(), c.name)
+	name := project.Instance(c.Project(), c.name)
 
 	// Start the LXC container
 	_, err = shared.RunCommand(
@@ -5477,7 +5477,7 @@ func (c *lxc) Console() (*os.File, chan error, error) {
 	args := []string{
 		c.state.OS.ExecPath,
 		"forkconsole",
-		project.Prefix(c.Project(), c.Name()),
+		project.Instance(c.Project(), c.Name()),
 		c.state.OS.LxcPath,
 		filepath.Join(c.LogPath(), "lxc.conf"),
 		"tty=0",
@@ -5551,7 +5551,7 @@ func (c *lxc) Exec(req api.InstanceExecPost, stdin *os.File, stdout *os.File, st
 	}
 
 	// Prepare the subcommand
-	cname := project.Prefix(c.Project(), c.Name())
+	cname := project.Instance(c.Project(), c.Name())
 	args := []string{
 		c.state.OS.ExecPath,
 		"forkexec",
@@ -5990,7 +5990,7 @@ func (c *lxc) insertMountLXD(source, target, fstype string, flags int, mntnsPID
 }
 
 func (c *lxc) insertMountLXC(source, target, fstype string, flags int) error {
-	cname := project.Prefix(c.Project(), c.Name())
+	cname := project.Instance(c.Project(), c.Name())
 	configPath := filepath.Join(c.LogPath(), "lxc.conf")
 	if fstype == "" {
 		fstype = "none"
@@ -6026,7 +6026,7 @@ func (c *lxc) removeMount(mount string) error {
 
 	if c.state.OS.LXCFeatures["mount_injection_file"] {
 		configPath := filepath.Join(c.LogPath(), "lxc.conf")
-		cname := project.Prefix(c.Project(), c.Name())
+		cname := project.Instance(c.Project(), c.Name())
 
 		if !strings.HasPrefix(mount, "/") {
 			mount = "/" + mount
@@ -6170,7 +6170,7 @@ func (c *lxc) FillNetworkDevice(name string, m deviceConfig.Device) (deviceConfi
 		}
 
 		// Attempt to include all existing interfaces
-		cname := project.Prefix(c.Project(), c.Name())
+		cname := project.Instance(c.Project(), c.Name())
 		cc, err := liblxc.NewContainer(cname, c.state.OS.LxcPath)
 		if err == nil {
 			defer cc.Release()
@@ -6552,19 +6552,19 @@ func (c *lxc) Path() string {
 
 // DevicesPath devices path.
 func (c *lxc) DevicesPath() string {
-	name := project.Prefix(c.Project(), c.Name())
+	name := project.Instance(c.Project(), c.Name())
 	return shared.VarPath("devices", name)
 }
 
 // ShmountsPath shared mounts path.
 func (c *lxc) ShmountsPath() string {
-	name := project.Prefix(c.Project(), c.Name())
+	name := project.Instance(c.Project(), c.Name())
 	return shared.VarPath("shmounts", name)
 }
 
 // LogPath log path.
 func (c *lxc) LogPath() string {
-	name := project.Prefix(c.Project(), c.Name())
+	name := project.Instance(c.Project(), c.Name())
 	return shared.LogPath(name)
 }
 
@@ -6727,20 +6727,20 @@ func (c *lxc) maasUpdate(oldDevices map[string]map[string]string) error {
 		return fmt.Errorf("Can't perform the operation because MAAS is currently unavailable")
 	}
 
-	exists, err := c.state.MAAS.DefinedContainer(project.Prefix(c.project, c.name))
+	exists, err := c.state.MAAS.DefinedContainer(project.Instance(c.project, c.name))
 	if err != nil {
 		return err
 	}
 
 	if exists {
 		if len(interfaces) == 0 && len(oldInterfaces) > 0 {
-			return c.state.MAAS.DeleteContainer(project.Prefix(c.project, c.name))
+			return c.state.MAAS.DeleteContainer(project.Instance(c.project, c.name))
 		}
 
-		return c.state.MAAS.UpdateContainer(project.Prefix(c.project, c.name), interfaces)
+		return c.state.MAAS.UpdateContainer(project.Instance(c.project, c.name), interfaces)
 	}
 
-	return c.state.MAAS.CreateContainer(project.Prefix(c.project, c.name), interfaces)
+	return c.state.MAAS.CreateContainer(project.Instance(c.project, c.name), interfaces)
 }
 
 func (c *lxc) maasRename(newName string) error {
@@ -6766,7 +6766,7 @@ func (c *lxc) maasRename(newName string) error {
 		return fmt.Errorf("Can't perform the operation because MAAS is currently unavailable")
 	}
 
-	exists, err := c.state.MAAS.DefinedContainer(project.Prefix(c.project, c.name))
+	exists, err := c.state.MAAS.DefinedContainer(project.Instance(c.project, c.name))
 	if err != nil {
 		return err
 	}
@@ -6775,7 +6775,7 @@ func (c *lxc) maasRename(newName string) error {
 		return c.maasUpdate(nil)
 	}
 
-	return c.state.MAAS.RenameContainer(project.Prefix(c.project, c.name), project.Prefix(c.project, newName))
+	return c.state.MAAS.RenameContainer(project.Instance(c.project, c.name), project.Instance(c.project, newName))
 }
 
 func (c *lxc) maasDelete() error {
@@ -6801,7 +6801,7 @@ func (c *lxc) maasDelete() error {
 		return fmt.Errorf("Can't perform the operation because MAAS is currently unavailable")
 	}
 
-	exists, err := c.state.MAAS.DefinedContainer(project.Prefix(c.project, c.name))
+	exists, err := c.state.MAAS.DefinedContainer(project.Instance(c.project, c.name))
 	if err != nil {
 		return err
 	}
@@ -6810,7 +6810,7 @@ func (c *lxc) maasDelete() error {
 		return nil
 	}
 
-	return c.state.MAAS.DeleteContainer(project.Prefix(c.project, c.name))
+	return c.state.MAAS.DeleteContainer(project.Instance(c.project, c.name))
 }
 
 func (c *lxc) cgroup(cc *liblxc.Container) (*cgroup.CGroup, error) {
diff --git a/lxd/instance/drivers/driver_qemu.go b/lxd/instance/drivers/driver_qemu.go
index e33e57253d..c2186dc9fe 100644
--- a/lxd/instance/drivers/driver_qemu.go
+++ b/lxd/instance/drivers/driver_qemu.go
@@ -366,7 +366,7 @@ func (vm *qemu) getMonitorEventHandler() func(event string, data map[string]inte
 
 			err = inst.(*qemu).OnStop(target)
 			if err != nil {
-				logger.Errorf("Failed to cleanly stop instance '%s': %v", project.Prefix(inst.Project(), inst.Name()), err)
+				logger.Errorf("Failed to cleanly stop instance '%s': %v", project.Instance(inst.Project(), inst.Name()), err)
 				return
 			}
 		}
@@ -3631,19 +3631,19 @@ func (vm *qemu) Path() string {
 
 // DevicesPath returns the instance's devices path.
 func (vm *qemu) DevicesPath() string {
-	name := project.Prefix(vm.Project(), vm.Name())
+	name := project.Instance(vm.Project(), vm.Name())
 	return shared.VarPath("devices", name)
 }
 
 // ShmountsPath returns the instance's shared mounts path.
 func (vm *qemu) ShmountsPath() string {
-	name := project.Prefix(vm.Project(), vm.Name())
+	name := project.Instance(vm.Project(), vm.Name())
 	return shared.VarPath("shmounts", name)
 }
 
 // LogPath returns the instance's log path.
 func (vm *qemu) LogPath() string {
-	name := project.Prefix(vm.Project(), vm.Name())
+	name := project.Instance(vm.Project(), vm.Name())
 	return shared.LogPath(name)
 }
 
@@ -3847,7 +3847,7 @@ func (vm *qemu) maasRename(newName string) error {
 		return fmt.Errorf("Can't perform the operation because MAAS is currently unavailable")
 	}
 
-	exists, err := vm.state.MAAS.DefinedContainer(project.Prefix(vm.project, vm.name))
+	exists, err := vm.state.MAAS.DefinedContainer(project.Instance(vm.project, vm.name))
 	if err != nil {
 		return err
 	}
@@ -3856,7 +3856,7 @@ func (vm *qemu) maasRename(newName string) error {
 		return vm.maasUpdate(nil)
 	}
 
-	return vm.state.MAAS.RenameContainer(project.Prefix(vm.project, vm.name), project.Prefix(vm.project, newName))
+	return vm.state.MAAS.RenameContainer(project.Instance(vm.project, vm.name), project.Instance(vm.project, newName))
 }
 
 func (vm *qemu) maasDelete() error {
@@ -3882,7 +3882,7 @@ func (vm *qemu) maasDelete() error {
 		return fmt.Errorf("Can't perform the operation because MAAS is currently unavailable")
 	}
 
-	exists, err := vm.state.MAAS.DefinedContainer(project.Prefix(vm.project, vm.name))
+	exists, err := vm.state.MAAS.DefinedContainer(project.Instance(vm.project, vm.name))
 	if err != nil {
 		return err
 	}
@@ -3891,7 +3891,7 @@ func (vm *qemu) maasDelete() error {
 		return nil
 	}
 
-	return vm.state.MAAS.DeleteContainer(project.Prefix(vm.project, vm.name))
+	return vm.state.MAAS.DeleteContainer(project.Instance(vm.project, vm.name))
 }
 
 func (vm *qemu) maasUpdate(oldDevices map[string]map[string]string) error {
@@ -3928,20 +3928,20 @@ func (vm *qemu) maasUpdate(oldDevices map[string]map[string]string) error {
 		return fmt.Errorf("Can't perform the operation because MAAS is currently unavailable")
 	}
 
-	exists, err := vm.state.MAAS.DefinedContainer(project.Prefix(vm.project, vm.name))
+	exists, err := vm.state.MAAS.DefinedContainer(project.Instance(vm.project, vm.name))
 	if err != nil {
 		return err
 	}
 
 	if exists {
 		if len(interfaces) == 0 && len(oldInterfaces) > 0 {
-			return vm.state.MAAS.DeleteContainer(project.Prefix(vm.project, vm.name))
+			return vm.state.MAAS.DeleteContainer(project.Instance(vm.project, vm.name))
 		}
 
-		return vm.state.MAAS.UpdateContainer(project.Prefix(vm.project, vm.name), interfaces)
+		return vm.state.MAAS.UpdateContainer(project.Instance(vm.project, vm.name), interfaces)
 	}
 
-	return vm.state.MAAS.CreateContainer(project.Prefix(vm.project, vm.name), interfaces)
+	return vm.state.MAAS.CreateContainer(project.Instance(vm.project, vm.name), interfaces)
 }
 
 // UpdateBackupFile writes the instance's backup.yaml file to storage.
@@ -4050,7 +4050,7 @@ func (vm *qemu) cpuTopology(limit string) (int, int, int, map[uint64]uint64, err
 		nrCores = countCores
 		nrThreads = countThreads
 	} else {
-		logger.Warnf("Instance '%s' uses a CPU pinning profile which doesn't match hardware layout", project.Prefix(vm.Project(), vm.Name()))
+		logger.Warnf("Instance '%s' uses a CPU pinning profile which doesn't match hardware layout", project.Instance(vm.Project(), vm.Name()))
 
 		// Fallback on pretending everything are cores.
 		nrSockets = 1
diff --git a/lxd/logging.go b/lxd/logging.go
index c2971186db..6b8d5f1918 100644
--- a/lxd/logging.go
+++ b/lxd/logging.go
@@ -61,7 +61,7 @@ func expireLogs(ctx context.Context, state *state.State) error {
 	// Build the expected names.
 	names := []string{}
 	for _, inst := range instances {
-		names = append(names, project.Prefix(inst.Project(), inst.Name()))
+		names = append(names, project.Instance(inst.Project(), inst.Name()))
 	}
 
 	newestFile := func(path string, dir os.FileInfo) time.Time {
diff --git a/lxd/network/network_utils.go b/lxd/network/network_utils.go
index 2d0f8fa7bc..f7a1730cf2 100644
--- a/lxd/network/network_utils.go
+++ b/lxd/network/network_utils.go
@@ -315,14 +315,14 @@ func UpdateDNSMasqStatic(s *state.State, networkName string) error {
 			// Look for duplicates
 			duplicate := false
 			for iIdx, i := range entries {
-				if project.Prefix(entry[1], entry[2]) == project.Prefix(i[1], i[2]) {
+				if project.Instance(entry[1], entry[2]) == project.Instance(i[1], i[2]) {
 					// Skip ourselves
 					continue
 				}
 
 				if entry[0] == i[0] {
 					// Find broken configurations
-					logger.Errorf("Duplicate MAC detected: %s and %s", project.Prefix(entry[1], entry[2]), project.Prefix(i[1], i[2]))
+					logger.Errorf("Duplicate MAC detected: %s and %s", project.Instance(entry[1], entry[2]), project.Instance(i[1], i[2]))
 				}
 
 				if i[3] == "" && i[4] == "" {
@@ -336,7 +336,7 @@ func UpdateDNSMasqStatic(s *state.State, networkName string) error {
 						duplicate = true
 					} else {
 						line = fmt.Sprintf("%s,%s", line, i[0])
-						logger.Debugf("Found containers with duplicate IPv4/IPv6: %s and %s", project.Prefix(entry[1], entry[2]), project.Prefix(i[1], i[2]))
+						logger.Debugf("Found containers with duplicate IPv4/IPv6: %s and %s", project.Instance(entry[1], entry[2]), project.Instance(i[1], i[2]))
 					}
 				}
 			}
diff --git a/lxd/patches_utils.go b/lxd/patches_utils.go
index 41182c8016..c66ad692fd 100644
--- a/lxd/patches_utils.go
+++ b/lxd/patches_utils.go
@@ -200,7 +200,7 @@ func lvmNameToLVName(containerName string) string {
 }
 
 func lvmDevPath(projectName, lvmPool string, volumeType string, lvmVolume string) string {
-	lvmVolume = project.Prefix(projectName, lvmVolume)
+	lvmVolume = project.Instance(projectName, lvmVolume)
 	if volumeType == "" {
 		return fmt.Sprintf("/dev/%s/%s", lvmPool, lvmVolume)
 	}
diff --git a/lxd/project/project_test.go b/lxd/project/project_test.go
index 5b2e280c9f..b6b5b6c96c 100644
--- a/lxd/project/project_test.go
+++ b/lxd/project/project_test.go
@@ -7,10 +7,10 @@ import (
 )
 
 func ExamplePrefix() {
-	prefixed := project.Prefix(project.Default, "test")
+	prefixed := project.Instance(project.Default, "test")
 	fmt.Println(prefixed)
 
-	prefixed = project.Prefix("project_name", "test1")
+	prefixed = project.Instance("project_name", "test1")
 	fmt.Println(prefixed)
 	// Output: test
 	// project_name_test1
@@ -20,13 +20,13 @@ func ExampleInstanceParts() {
 	projectName, name := project.InstanceParts("unprefixed")
 	fmt.Println(projectName, name)
 
-	projectName, name = project.InstanceParts(project.Prefix(project.Default, "test"))
+	projectName, name = project.InstanceParts(project.Instance(project.Default, "test"))
 	fmt.Println(projectName, name)
 
 	projectName, name = project.InstanceParts("project_name_test")
 	fmt.Println(projectName, name)
 
-	projectName, name = project.InstanceParts(project.Prefix("proj", "test1"))
+	projectName, name = project.InstanceParts(project.Instance("proj", "test1"))
 	fmt.Println(projectName, name)
 
 	// Output: default unprefixed
diff --git a/lxd/storage/backend_lxd.go b/lxd/storage/backend_lxd.go
index 4925ad1119..393da41e7b 100644
--- a/lxd/storage/backend_lxd.go
+++ b/lxd/storage/backend_lxd.go
@@ -332,7 +332,7 @@ func (b *lxdBackend) ensureInstanceSnapshotSymlink(instanceType instancetype.Typ
 
 	parentName, _, _ := shared.InstanceGetParentAndSnapshotName(instanceName)
 	snapshotSymlink := InstancePath(instanceType, projectName, parentName, true)
-	volStorageName := project.Prefix(projectName, parentName)
+	volStorageName := project.Instance(projectName, parentName)
 
 	snapshotTargetPath := drivers.GetVolumeSnapshotDir(b.name, volType, volStorageName)
 
@@ -365,7 +365,7 @@ func (b *lxdBackend) removeInstanceSnapshotSymlinkIfUnused(instanceType instance
 
 	parentName, _, _ := shared.InstanceGetParentAndSnapshotName(instanceName)
 	snapshotSymlink := InstancePath(instanceType, projectName, parentName, true)
-	volStorageName := project.Prefix(projectName, parentName)
+	volStorageName := project.Instance(projectName, parentName)
 
 	snapshotTargetPath := drivers.GetVolumeSnapshotDir(b.name, volType, volStorageName)
 
@@ -446,7 +446,7 @@ func (b *lxdBackend) CreateInstance(inst instance.Instance, op *operations.Opera
 	}
 
 	// Get the volume name on storage.
-	volStorageName := project.Prefix(inst.Project(), inst.Name())
+	volStorageName := project.Instance(inst.Project(), inst.Name())
 
 	vol := b.newVolume(volType, contentType, volStorageName, rootDiskConf)
 	err = b.driver.CreateVolume(vol, nil, op)
@@ -479,7 +479,7 @@ func (b *lxdBackend) CreateInstanceFromBackup(srcBackup backup.Info, srcData io.
 	defer logger.Debug("CreateInstanceFromBackup finished")
 
 	// Get the volume name on storage.
-	volStorageName := project.Prefix(srcBackup.Project, srcBackup.Name)
+	volStorageName := project.Instance(srcBackup.Project, srcBackup.Name)
 
 	// Currently there is no concept of instance type in backups, so we assume container.
 	// We don't know the volume's config yet as tarball hasn't been unpacked.
@@ -543,7 +543,7 @@ func (b *lxdBackend) CreateInstanceFromBackup(srcBackup backup.Info, srcData io.
 		}
 
 		// Get the volume name on storage.
-		volStorageName := project.Prefix(inst.Project(), inst.Name())
+		volStorageName := project.Instance(inst.Project(), inst.Name())
 
 		volType, err := InstanceTypeToVolumeType(inst.Type())
 		if err != nil {
@@ -608,7 +608,7 @@ func (b *lxdBackend) CreateInstanceFromCopy(inst instance.Instance, src instance
 	}
 
 	// Get the volume name on storage.
-	volStorageName := project.Prefix(inst.Project(), inst.Name())
+	volStorageName := project.Instance(inst.Project(), inst.Name())
 
 	// Initialise a new volume containing the root disk config supplied in the new instance.
 	vol := b.newVolume(volType, contentType, volStorageName, rootDiskConf)
@@ -618,7 +618,7 @@ func (b *lxdBackend) CreateInstanceFromCopy(inst instance.Instance, src instance
 	}
 
 	// Get the src volume name on storage.
-	srcVolStorageName := project.Prefix(src.Project(), src.Name())
+	srcVolStorageName := project.Instance(src.Project(), src.Name())
 
 	// We don't need to use the source instance's root disk config, so set to nil.
 	srcVol := b.newVolume(volType, contentType, srcVolStorageName, nil)
@@ -754,13 +754,13 @@ func (b *lxdBackend) RefreshInstance(inst instance.Instance, src instance.Instan
 	}
 
 	// Get the volume name on storage.
-	volStorageName := project.Prefix(inst.Project(), inst.Name())
+	volStorageName := project.Instance(inst.Project(), inst.Name())
 
 	// Initialise a new volume containing the root disk config supplied in the new instance.
 	vol := b.newVolume(volType, contentType, volStorageName, rootDiskConf)
 
 	// Get the src volume name on storage.
-	srcVolStorageName := project.Prefix(src.Project(), src.Name())
+	srcVolStorageName := project.Instance(src.Project(), src.Name())
 
 	// We don't need to use the source instance's root disk config, so set to nil.
 	srcVol := b.newVolume(volType, contentType, srcVolStorageName, nil)
@@ -774,7 +774,7 @@ func (b *lxdBackend) RefreshInstance(inst instance.Instance, src instance.Instan
 		// the data from the snapshot is incorrect.
 
 		// Get the snap volume name on storage.
-		snapVolStorageName := project.Prefix(snapInst.Project(), snapInst.Name())
+		snapVolStorageName := project.Instance(snapInst.Project(), snapInst.Name())
 		srcSnapVol := b.newVolume(volType, contentType, snapVolStorageName, nil)
 		srcSnapVols = append(srcSnapVols, srcSnapVol)
 	}
@@ -916,7 +916,7 @@ func (b *lxdBackend) CreateInstanceFromImage(inst instance.Instance, fingerprint
 	}
 
 	// Get the volume name on storage.
-	volStorageName := project.Prefix(inst.Project(), inst.Name())
+	volStorageName := project.Instance(inst.Project(), inst.Name())
 
 	vol := b.newVolume(volType, contentType, volStorageName, rootDiskConf)
 
@@ -988,7 +988,7 @@ func (b *lxdBackend) CreateInstanceFromMigration(inst instance.Instance, conn io
 	args.Name = inst.Name()
 
 	// Get the volume name on storage.
-	volStorageName := project.Prefix(inst.Project(), args.Name)
+	volStorageName := project.Instance(inst.Project(), args.Name)
 
 	vol := b.newVolume(volType, contentType, volStorageName, args.Config)
 
@@ -1131,8 +1131,8 @@ func (b *lxdBackend) RenameInstance(inst instance.Instance, newName string, op *
 	})
 
 	// Rename the volume and its snapshots on the storage device.
-	volStorageName := project.Prefix(inst.Project(), inst.Name())
-	newVolStorageName := project.Prefix(inst.Project(), newName)
+	volStorageName := project.Instance(inst.Project(), inst.Name())
+	newVolStorageName := project.Instance(inst.Project(), newName)
 	contentType := InstanceContentType(inst)
 
 	// There's no need to pass config as it's not needed when renaming a volume.
@@ -1218,7 +1218,7 @@ func (b *lxdBackend) DeleteInstance(inst instance.Instance, op *operations.Opera
 	}
 
 	// Get the volume name on storage.
-	volStorageName := project.Prefix(inst.Project(), inst.Name())
+	volStorageName := project.Instance(inst.Project(), inst.Name())
 	contentType := InstanceContentType(inst)
 
 	// There's no need to pass config as it's not needed when deleting a volume.
@@ -1273,7 +1273,7 @@ func (b *lxdBackend) UpdateInstance(inst instance.Instance, newDesc string, newC
 		return err
 	}
 
-	volStorageName := project.Prefix(inst.Project(), inst.Name())
+	volStorageName := project.Instance(inst.Project(), inst.Name())
 	contentType := InstanceContentType(inst)
 
 	// Validate config.
@@ -1384,7 +1384,7 @@ func (b *lxdBackend) MigrateInstance(inst instance.Instance, conn io.ReadWriteCl
 	args.Name = inst.Name() // Override args.Name to ensure instance volume is sent.
 
 	// Get the volume name on storage.
-	volStorageName := project.Prefix(inst.Project(), args.Name)
+	volStorageName := project.Instance(inst.Project(), args.Name)
 
 	vol := b.newVolume(volType, contentType, volStorageName, rootDiskConf)
 	err = b.driver.MigrateVolume(vol, conn, args, op)
@@ -1415,7 +1415,7 @@ func (b *lxdBackend) BackupInstance(inst instance.Instance, targetPath string, o
 	}
 
 	// Get the volume name on storage.
-	volStorageName := project.Prefix(inst.Project(), inst.Name())
+	volStorageName := project.Instance(inst.Project(), inst.Name())
 
 	// Ensure the backup file reflects current config.
 	err = b.UpdateInstanceBackupFile(inst, op)
@@ -1446,7 +1446,7 @@ func (b *lxdBackend) GetInstanceUsage(inst instance.Instance) (int64, error) {
 	contentType := InstanceContentType(inst)
 
 	// There's no need to pass config as it's not needed when retrieving the volume usage.
-	volStorageName := project.Prefix(inst.Project(), inst.Name())
+	volStorageName := project.Instance(inst.Project(), inst.Name())
 	vol := b.newVolume(volType, contentType, volStorageName, nil)
 
 	return b.driver.GetVolumeUsage(vol)
@@ -1471,7 +1471,7 @@ func (b *lxdBackend) SetInstanceQuota(inst instance.Instance, size string, op *o
 	}
 
 	contentVolume := InstanceContentType(inst)
-	volStorageName := project.Prefix(inst.Project(), inst.Name())
+	volStorageName := project.Instance(inst.Project(), inst.Name())
 
 	// Get the volume.
 	// There's no need to pass config as it's not needed when setting quotas.
@@ -1499,7 +1499,7 @@ func (b *lxdBackend) MountInstance(inst instance.Instance, op *operations.Operat
 	}
 
 	contentType := InstanceContentType(inst)
-	volStorageName := project.Prefix(inst.Project(), inst.Name())
+	volStorageName := project.Instance(inst.Project(), inst.Name())
 
 	// Get the volume.
 	vol := b.newVolume(volType, contentType, volStorageName, rootDiskConf)
@@ -1526,7 +1526,7 @@ func (b *lxdBackend) UnmountInstance(inst instance.Instance, op *operations.Oper
 	}
 
 	contentType := InstanceContentType(inst)
-	volStorageName := project.Prefix(inst.Project(), inst.Name())
+	volStorageName := project.Instance(inst.Project(), inst.Name())
 
 	// Get the volume.
 	vol := b.newVolume(volType, contentType, volStorageName, rootDiskConf)
@@ -1547,7 +1547,7 @@ func (b *lxdBackend) GetInstanceDisk(inst instance.Instance) (string, error) {
 	}
 
 	contentType := InstanceContentType(inst)
-	volStorageName := project.Prefix(inst.Project(), inst.Name())
+	volStorageName := project.Instance(inst.Project(), inst.Name())
 
 	// Get the volume.
 	// There's no need to pass config as it's not needed when getting the
@@ -1603,7 +1603,7 @@ func (b *lxdBackend) CreateInstanceSnapshot(inst instance.Instance, src instance
 	}
 
 	contentType := InstanceContentType(inst)
-	volStorageName := project.Prefix(inst.Project(), inst.Name())
+	volStorageName := project.Instance(inst.Project(), inst.Name())
 
 	// Get the volume.
 	// There's no need to pass config as it's not needed when creating volume
@@ -1657,7 +1657,7 @@ func (b *lxdBackend) RenameInstanceSnapshot(inst instance.Instance, newName stri
 	}
 
 	contentType := InstanceContentType(inst)
-	volStorageName := project.Prefix(inst.Project(), inst.Name())
+	volStorageName := project.Instance(inst.Project(), inst.Name())
 
 	// Rename storage volume snapshot. No need to pass config as it's not needed when renaming a volume.
 	snapVol := b.newVolume(volType, contentType, volStorageName, nil)
@@ -1670,7 +1670,7 @@ func (b *lxdBackend) RenameInstanceSnapshot(inst instance.Instance, newName stri
 
 	revert.Add(func() {
 		// Revert rename. No need to pass config as it's not needed when renaming a volume.
-		newSnapVol := b.newVolume(volType, contentType, project.Prefix(inst.Project(), newVolName), nil)
+		newSnapVol := b.newVolume(volType, contentType, project.Instance(inst.Project(), newVolName), nil)
 		b.driver.RenameVolumeSnapshot(newSnapVol, oldSnapshotName, op)
 	})
 
@@ -1720,7 +1720,7 @@ func (b *lxdBackend) DeleteInstanceSnapshot(inst instance.Instance, op *operatio
 	contentType := InstanceContentType(inst)
 
 	// Get the parent volume name on storage.
-	parentStorageName := project.Prefix(inst.Project(), parentName)
+	parentStorageName := project.Instance(inst.Project(), parentName)
 
 	// Delete the snapshot from the storage device.
 	// Must come before DB StoragePoolVolumeDelete so that the volume ID is still available.
@@ -1790,7 +1790,7 @@ func (b *lxdBackend) RestoreInstanceSnapshot(inst instance.Instance, src instanc
 	}
 
 	// Get the volume name on storage.
-	volStorageName := project.Prefix(inst.Project(), inst.Name())
+	volStorageName := project.Instance(inst.Project(), inst.Name())
 
 	_, snapshotName, isSnap := shared.InstanceGetParentAndSnapshotName(src.Name())
 	if !isSnap {
@@ -1862,7 +1862,7 @@ func (b *lxdBackend) MountInstanceSnapshot(inst instance.Instance, op *operation
 	}
 
 	// Get the parent and snapshot name.
-	volStorageName := project.Prefix(inst.Project(), inst.Name())
+	volStorageName := project.Instance(inst.Project(), inst.Name())
 
 	// Get the volume.
 	vol := b.newVolume(volType, contentType, volStorageName, rootDiskConf)
@@ -1895,7 +1895,7 @@ func (b *lxdBackend) UnmountInstanceSnapshot(inst instance.Instance, op *operati
 	contentType := InstanceContentType(inst)
 
 	// Get the parent and snapshot name.
-	volStorageName := project.Prefix(inst.Project(), inst.Name())
+	volStorageName := project.Instance(inst.Project(), inst.Name())
 
 	// Get the volume.
 	vol := b.newVolume(volType, contentType, volStorageName, rootDiskConf)
@@ -2905,7 +2905,7 @@ func (b *lxdBackend) UpdateInstanceBackupFile(inst instance.Instance, op *operat
 	}
 
 	// Get the volume name on storage.
-	volStorageName := project.Prefix(inst.Project(), inst.Name())
+	volStorageName := project.Instance(inst.Project(), inst.Name())
 
 	// We don't need to use the volume's config for mounting so set to nil.
 	vol := b.newVolume(volType, contentType, volStorageName, nil)
@@ -2958,7 +2958,7 @@ func (b *lxdBackend) CheckInstanceBackupFileSnapshots(backupConf *backup.Instanc
 	}
 
 	// Get the volume name on storage.
-	volStorageName := project.Prefix(projectName, backupConf.Container.Name)
+	volStorageName := project.Instance(projectName, backupConf.Container.Name)
 
 	// We don't need to use the volume's config for mounting so set to nil.
 	vol := b.newVolume(volType, drivers.ContentTypeFS, volStorageName, nil)
diff --git a/lxd/storage/storage.go b/lxd/storage/storage.go
index 8a37e3ae43..9bbd9279bd 100644
--- a/lxd/storage/storage.go
+++ b/lxd/storage/storage.go
@@ -10,7 +10,7 @@ import (
 
 // InstancePath returns the directory of an instance or snapshot.
 func InstancePath(instanceType instancetype.Type, projectName, instanceName string, isSnapshot bool) string {
-	fullName := project.Prefix(projectName, instanceName)
+	fullName := project.Instance(projectName, instanceName)
 	if instanceType == instancetype.VM {
 		if isSnapshot {
 			return shared.VarPath("virtual-machines-snapshots", fullName)
@@ -31,7 +31,7 @@ func InstancePath(instanceType instancetype.Type, projectName, instanceName stri
 // but does not exist in the LXD database. The presence of this file causes the instance not to be removed from
 // the storage device if the import should fail for some reason.
 func InstanceImportingFilePath(instanceType instancetype.Type, poolName, projectName, instanceName string) string {
-	fullName := project.Prefix(projectName, instanceName)
+	fullName := project.Instance(projectName, instanceName)
 
 	typeDir := "containers"
 	if instanceType == instancetype.VM {
@@ -51,13 +51,13 @@ func GetStoragePoolMountPoint(poolName string) string {
 // GetContainerMountPoint returns the mountpoint of the given container.
 // ${LXD_DIR}/storage-pools/<pool>/containers/[<project_name>_]<container_name>
 func GetContainerMountPoint(projectName string, poolName string, containerName string) string {
-	return shared.VarPath("storage-pools", poolName, "containers", project.Prefix(projectName, containerName))
+	return shared.VarPath("storage-pools", poolName, "containers", project.Instance(projectName, containerName))
 }
 
 // GetSnapshotMountPoint returns the mountpoint of the given container snapshot.
 // ${LXD_DIR}/storage-pools/<pool>/containers-snapshots/<snapshot_name>
 func GetSnapshotMountPoint(projectName, poolName string, snapshotName string) string {
-	return shared.VarPath("storage-pools", poolName, "containers-snapshots", project.Prefix(projectName, snapshotName))
+	return shared.VarPath("storage-pools", poolName, "containers-snapshots", project.Instance(projectName, snapshotName))
 }
 
 // GetImageMountPoint returns the mountpoint of the given image.

From 54ebb431b899b9553ae703b3fde76831b12f622a Mon Sep 17 00:00:00 2001
From: Thomas Parrott <thomas.parrott at canonical.com>
Date: Wed, 4 Mar 2020 08:25:32 +0000
Subject: [PATCH 3/3] lxd/project/project/test: Updates for project.Instance
 rename

Signed-off-by: Thomas Parrott <thomas.parrott at canonical.com>
---
 lxd/project/project_test.go | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lxd/project/project_test.go b/lxd/project/project_test.go
index b6b5b6c96c..f5f7709072 100644
--- a/lxd/project/project_test.go
+++ b/lxd/project/project_test.go
@@ -6,7 +6,7 @@ import (
 	"github.com/lxc/lxd/lxd/project"
 )
 
-func ExamplePrefix() {
+func ExampleInstance() {
 	prefixed := project.Instance(project.Default, "test")
 	fmt.Println(prefixed)
 


More information about the lxc-devel mailing list