Skip to content

Commit

Permalink
lxd/device: Allow / in container TPM device name
Browse files Browse the repository at this point in the history
Signed-off-by: hamistao <[email protected]>
  • Loading branch information
hamistao committed Jun 26, 2024
1 parent e30aa8a commit 610fe75
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions lxd/device/tpm.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,9 @@ func (d *tpm) Start() (*deviceConfig.RunConfig, error) {
}

func (d *tpm) startContainer() (*deviceConfig.RunConfig, error) {
tpmDevPath := filepath.Join(d.inst.Path(), fmt.Sprintf("tpm.%s", d.name))
logFileName := fmt.Sprintf("tpm.%s.log", d.name)
escapedDeviceName := filesystem.PathNameEncode(d.name)
tpmDevPath := filepath.Join(d.inst.Path(), fmt.Sprintf("tpm.%s", escapedDeviceName))
logFileName := fmt.Sprintf("tpm.%s.log", escapedDeviceName)
logPath := filepath.Join(d.inst.LogPath(), logFileName)

proc, err := subprocess.NewProcess("swtpm", []string{"chardev", "--tpm2", "--tpmstate", fmt.Sprintf("dir=%s", tpmDevPath), "--vtpm-proxy"}, logPath, "")
Expand All @@ -135,7 +136,7 @@ func (d *tpm) startContainer() (*deviceConfig.RunConfig, error) {
// Stop the TPM emulator if anything goes wrong.
revert.Add(func() { _ = proc.Stop() })

pidPath := filepath.Join(d.inst.DevicesPath(), fmt.Sprintf("%s.pid", d.name))
pidPath := filepath.Join(d.inst.DevicesPath(), fmt.Sprintf("%s.pid", escapedDeviceName))

err = proc.Save(pidPath)
if err != nil {
Expand Down

0 comments on commit 610fe75

Please sign in to comment.