mirror of
https://github.com/containers/podman.git
synced 2025-11-29 09:37:38 +08:00
Fix running machines with volumes containing spaces
Machines configured to mount local paths containing spaces failed to start on Hyper-V and silently failed to mount the folder on macOS/Linux. On Windows/hyperv, where local paths are mounted running a 9p client inside the VM, the local host path needs to be surrounding with quotation marks before using in a `podman machine ssh ...` command. A similar behavior happened on Linux/QEMU where the path was used in a SSH command to mount the folder using virtiofs. Quoting the path when buidling the command arguments fixed the problem. On macOS/libkit,applehv the path was written as is in a systemd unit name to instruct how to mount it. Escaping space chars so that they are are parsed successfully fixed this: ```diff -- enable path with spaces.mount ++ enable path\x20with\x20spaces.mount ``` Fixes https://github.com/containers/podman/issues/25500 Signed-off-by: Mario Loriedo <mario.loriedo@gmail.com>
This commit is contained in:
@@ -349,7 +349,7 @@ func (q *QEMUStubber) MountVolumesToVM(mc *vmconfigs.MachineConfig, quiet bool)
|
||||
if !strings.HasPrefix(mount.Target, "/home") && !strings.HasPrefix(mount.Target, "/mnt") {
|
||||
args = append(args, "sudo", "chattr", "-i", "/", ";")
|
||||
}
|
||||
args = append(args, "sudo", "mkdir", "-p", mount.Target)
|
||||
args = append(args, "sudo", "mkdir", "-p", strconv.Quote(mount.Target))
|
||||
if !strings.HasPrefix(mount.Target, "/home") && !strings.HasPrefix(mount.Target, "/mnt") {
|
||||
args = append(args, ";", "sudo", "chattr", "+i", "/", ";")
|
||||
}
|
||||
@@ -362,7 +362,7 @@ func (q *QEMUStubber) MountVolumesToVM(mc *vmconfigs.MachineConfig, quiet bool)
|
||||
// in other words we don't want to make people unnecessarily reprovision their machines
|
||||
// to upgrade from 9p to virtiofs.
|
||||
mountOptions := []string{"-t", "virtiofs"}
|
||||
mountOptions = append(mountOptions, []string{mount.Tag, mount.Target}...)
|
||||
mountOptions = append(mountOptions, []string{mount.Tag, strconv.Quote(mount.Target)}...)
|
||||
mountFlags := fmt.Sprintf("context=\"%s\"", machine.NFSSELinuxContext)
|
||||
if mount.ReadOnly {
|
||||
mountFlags += ",ro"
|
||||
|
||||
Reference in New Issue
Block a user