浏览文件
filenames.go
124 行 · 4.7 KB历史下载| 1 | // SPDX-FileCopyrightText: Copyright The Lima Authors |
| 2 | // SPDX-License-Identifier: Apache-2.0 |
| 3 | |
| 4 | // Package filenames defines the names of the files that appear under an instance dir |
| 5 | // or inside the config directory. |
| 6 | // |
| 7 | // See https://lima-vm.io/docs/dev/internals/ |
| 8 | package filenames |
| 9 | |
| 10 | // Instance names starting with an underscore are reserved for lima internal usage |
| 11 | |
| 12 | const ( |
| 13 | CacheDir = "_cache" // not yet implemented |
| 14 | ConfigDir = "_config" |
| 15 | DisksDir = "_disks" // disks are stored here |
| 16 | NetworksDir = "_networks" // network log files are stored here |
| 17 | TemplatesDir = "_templates" // user templates are stored here |
| 18 | ) |
| 19 | |
| 20 | // Filenames used inside the ConfigDir |
| 21 | |
| 22 | const ( |
| 23 | UserPrivateKey = "user" |
| 24 | UserPublicKey = UserPrivateKey + ".pub" |
| 25 | NetworksConfig = "networks.yaml" |
| 26 | Default = "default.yaml" |
| 27 | Override = "override.yaml" |
| 28 | Base = "base.yaml" |
| 29 | ) |
| 30 | |
| 31 | // Filenames that may appear under an instance directory |
| 32 | |
| 33 | const ( |
| 34 | LimaYAML = "lima.yaml" |
| 35 | LimaVersion = "lima-version" // Lima version used to create instance |
| 36 | CIDataISO = "cidata.iso" |
| 37 | CIDataISODir = "cidata" |
| 38 | CloudConfig = "cloud-config.yaml" |
| 39 | Image = "image" // downloaded VM image; renamed to Disk or ISO during setup |
| 40 | ImageIPSW = "image.ipsw" // hardlink to Image for macOS guests |
| 41 | Disk = "disk" // VM disk (or symlink to DiffDiskLegacy for migrated instances) |
| 42 | ISO = "iso" // optional CDROM image (or symlink to BaseDiskLegacy for migrated instances) |
| 43 | BaseDiskLegacy = "basedisk" // legacy name for Image; may remain as qcow2 backing file |
| 44 | DiffDiskLegacy = "diffdisk" // legacy name for Disk |
| 45 | Kernel = "kernel" |
| 46 | KernelCmdline = "kernel.cmdline" |
| 47 | Initrd = "initrd" |
| 48 | QMPSock = "qmp.sock" |
| 49 | SerialLog = "serial.log" // default serial (ttyS0, but ttyAMA0 on qemu-system-{arm,aarch64}) |
| 50 | SerialSock = "serial.sock" |
| 51 | SerialPCILog = "serialp.log" // pci serial (ttyS0 on qemu-system-{arm,aarch64}) |
| 52 | SerialPCISock = "serialp.sock" |
| 53 | SerialVirtioLog = "serialv.log" // virtio serial |
| 54 | SerialVirtioSock = "serialv.sock" |
| 55 | SSHSock = "ssh.sock" |
| 56 | SSHConfig = "ssh.config" |
| 57 | VhostSock = "virtiofsd-%d.sock" |
| 58 | VNCDisplayFile = "vncdisplay" |
| 59 | VNCPasswordFile = "vncpassword" |
| 60 | GuestAgentSock = "ga.sock" |
| 61 | VirtioPort = "io.lima-vm.guest_agent.0" |
| 62 | VirtioWin = "virtio-win" |
| 63 | HostAgentPID = "ha.pid" |
| 64 | HostAgentSock = "ha.sock" |
| 65 | HostAgentStdoutLog = "ha.stdout.log" |
| 66 | HostAgentStderrLog = "ha.stderr.log" |
| 67 | ExternalDriverStderrLog = "driver.stderr.log" |
| 68 | BootSession = "boot-session.tmp" // boot of the host during which the PID files in the same directory were written |
| 69 | VzIdentifier = "vz-identifier" |
| 70 | VzHwModel = "vz-hwmodel" // macOS guests only |
| 71 | VzAux = "vz-aux" // macOS guests only |
| 72 | VzEfi = "vz-efi" // efi variable store |
| 73 | QemuEfiCodeFD = "qemu-efi-code.fd" // efi code; not always created |
| 74 | AnsibleInventoryYAML = "ansible-inventory.yaml" |
| 75 | |
| 76 | // SocketDir is the default location for forwarded sockets with a relative paths in HostSocket. |
| 77 | SocketDir = "sock" |
| 78 | MntDir = "mnt" // mount point (macOS guests only) |
| 79 | |
| 80 | Protected = "protected" // empty file; used by `limactl protect` |
| 81 | |
| 82 | // Swtpm is used for TPM emulation. |
| 83 | SwtpmSock = "swtpm.sock" |
| 84 | SwtpmDir = "swtpm" |
| 85 | |
| 86 | // Marker which indicates Windows OS installation completed. |
| 87 | WinDoneInstallation = "win-done-installation" |
| 88 | ) |
| 89 | |
| 90 | // Filenames used under a disk directory |
| 91 | |
| 92 | const ( |
| 93 | DataDisk = "datadisk" |
| 94 | InUseBy = "in_use_by" |
| 95 | ) |
| 96 | |
| 97 | // LongestSock is the longest socket name. |
| 98 | // On macOS, the full path of the socket (excluding the NUL terminator) must be less than 104 characters. |
| 99 | // See unix(4). |
| 100 | // |
| 101 | // On Linux, the full path must be less than 108 characters. |
| 102 | // |
| 103 | // ssh appends 16 bytes of random characters when it first creates the socket: |
| 104 | // https://github.com/openssh/openssh-portable/blob/V_8_7_P1/mux.c#L1271-L1285 |
| 105 | const LongestSock = SSHSock + ".1234567890123456" |
| 106 | |
| 107 | func PIDFile(name string) string { |
| 108 | return name + ".pid" |
| 109 | } |
| 110 | |
| 111 | // SkipOnClone files should be skipped on cloning an instance. |
| 112 | var SkipOnClone = []string{ |
| 113 | Protected, |
| 114 | SwtpmDir, // TPM state must not be shared between instances. |
| 115 | } |
| 116 | |
| 117 | // NullifyOnClone files should be nullified on cloning an instance. |
| 118 | // FIXME: this list should be provided by the VM driver. |
| 119 | var NullifyOnClone = []string{ |
| 120 | VzIdentifier, |
| 121 | } |
| 122 | |
| 123 | // TmpFileSuffixes is the list of the tmp file suffixes. |
| 124 | var TmpFileSuffixes = []string{".pid", ".sock", ".tmp"} |

