pkg/machine: remove deadcode

Yes this is a lot.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
This commit is contained in:
Paul Holzinger
2025-06-18 14:34:09 +02:00
parent d919a3666b
commit f3c82a917c
19 changed files with 1 additions and 806 deletions

View File

@ -15,7 +15,6 @@ import (
"github.com/containers/common/pkg/strongunits"
"github.com/containers/podman/v5/pkg/machine/compression"
"github.com/containers/podman/v5/pkg/machine/define"
"github.com/containers/podman/v5/pkg/machine/env"
"github.com/containers/podman/v5/pkg/machine/vmconfigs"
"github.com/sirupsen/logrus"
)
@ -146,61 +145,6 @@ const (
DockerGlobal
)
// TODO THis should be able to be removed once WSL is refactored for podman5
type Virtualization struct {
artifact define.Artifact
compression compression.ImageCompression
format define.ImageFormat
vmKind define.VMType
}
func (p *Virtualization) Artifact() define.Artifact {
return p.artifact
}
func (p *Virtualization) Compression() compression.ImageCompression {
return p.compression
}
func (p *Virtualization) Format() define.ImageFormat {
return p.format
}
func (p *Virtualization) VMType() define.VMType {
return p.vmKind
}
func (p *Virtualization) NewDownload(vmName string) (Download, error) {
cacheDir, err := env.GetCacheDir(p.VMType())
if err != nil {
return Download{}, err
}
dataDir, err := env.GetDataDir(p.VMType())
if err != nil {
return Download{}, err
}
return Download{
Artifact: p.Artifact(),
CacheDir: cacheDir,
CompressionType: p.Compression(),
DataDir: dataDir,
Format: p.Format(),
VMKind: p.VMType(),
VMName: vmName,
}, nil
}
func NewVirtualization(artifact define.Artifact, compression compression.ImageCompression, format define.ImageFormat, vmKind define.VMType) Virtualization {
return Virtualization{
artifact,
compression,
format,
vmKind,
}
}
func dialSocket(socket string, timeout time.Duration) (net.Conn, error) {
scheme := "unix"
if strings.Contains(socket, "://") {

View File

@ -3,8 +3,6 @@ package define
import (
"errors"
"fmt"
"github.com/containers/common/pkg/strongunits"
)
var (
@ -32,14 +30,6 @@ func (err *ErrVMDoesNotExist) Error() string {
return fmt.Sprintf("%s: VM does not exist", err.Name)
}
type ErrNewDiskSizeTooSmall struct {
OldSize, NewSize strongunits.GiB
}
func (err *ErrNewDiskSizeTooSmall) Error() string {
return fmt.Sprintf("invalid disk size %d: new disk must be larger than %dGB", err.OldSize, err.NewSize)
}
type ErrIncompatibleMachineConfig struct {
Name string
Path string

View File

@ -11,19 +11,6 @@ import (
"github.com/containers/storage/pkg/homedir"
)
// GetCacheDir returns the dir where VM images are downloaded into when pulled
func GetCacheDir(vmType define.VMType) (string, error) {
dataDir, err := GetDataDir(vmType)
if err != nil {
return "", err
}
cacheDir := filepath.Join(dataDir, "cache")
if err := fileutils.Exists(cacheDir); !errors.Is(err, os.ErrNotExist) {
return cacheDir, nil
}
return cacheDir, os.MkdirAll(cacheDir, 0755)
}
// GetDataDir returns the filepath where vm images should
// live for podman-machine.
func GetDataDir(vmType define.VMType) (string, error) {

View File

@ -1,11 +0,0 @@
//go:build darwin || dragonfly || freebsd || linux || netbsd || openbsd
package machine
import (
"runtime"
)
func DetermineMachineArch() string {
return runtime.GOARCH
}

View File

@ -1,32 +0,0 @@
package machine
import (
"runtime"
"syscall"
"github.com/sirupsen/logrus"
"golang.org/x/sys/windows"
)
func DetermineMachineArch() string {
const fallbackMsg = "this may result in the wrong Linux arch under emulation"
var machine, native uint16
current, _ := syscall.GetCurrentProcess()
if err := windows.IsWow64Process2(windows.Handle(current), &machine, &native); err != nil {
logrus.Warnf("Failure detecting native system architecture, %s: %v", fallbackMsg, err)
// Fall-back to binary arch
return runtime.GOARCH
}
switch native {
// Only care about archs in use with WSL
case 0xAA64:
return "arm64"
case 0x8664:
return "amd64"
default:
logrus.Warnf("Unknown or unsupported native system architecture [%d], %s", native, fallbackMsg)
return runtime.GOARCH
}
}

View File

@ -573,18 +573,6 @@ func GetPodmanDockerTmpConfig(uid int, rootful bool, newline bool) string {
return fmt.Sprintf("L+ /run/docker.sock - - - - %s%s", podmanSock, suffix)
}
// SetIgnitionFile creates a new Machine File for the machine's ignition file
// and assigns the handle to `loc`
func SetIgnitionFile(loc *define.VMFile, vmtype define.VMType, vmName, vmConfigDir string) error {
ignitionFile, err := define.NewMachineFile(filepath.Join(vmConfigDir, vmName+".ign"), nil)
if err != nil {
return err
}
*loc = *ignitionFile
return nil
}
type IgnitionBuilder struct {
dynamicIgnition DynamicIgnition
units []Unit

View File

@ -4,7 +4,6 @@ package machine
import (
"bytes"
"errors"
"fmt"
"os"
"os/exec"
@ -12,7 +11,6 @@ import (
"strings"
"github.com/containers/storage/pkg/fileutils"
"github.com/sirupsen/logrus"
)
var sshCommand = []string{"ssh-keygen", "-N", "", "-t", "ed25519", "-f"}
@ -51,22 +49,6 @@ func GetSSHKeys(identityPath string) (string, error) {
return CreateSSHKeys(identityPath)
}
func CreateSSHKeysPrefix(identityPath string, passThru bool, skipExisting bool, prefix ...string) (string, error) {
e := fileutils.Exists(identityPath)
if !skipExisting || errors.Is(e, os.ErrNotExist) {
if err := generatekeysPrefix(identityPath, passThru, prefix...); err != nil {
return "", err
}
} else {
fmt.Println("Keys already exist, reusing")
}
b, err := os.ReadFile(identityPath + ".pub")
if err != nil {
return "", err
}
return strings.TrimSuffix(string(b), "\n"), nil
}
// generatekeys creates an ed25519 set of keys
func generatekeys(writeLocation string) error {
args := append(append([]string{}, sshCommand[1:]...), writeLocation)
@ -84,35 +66,3 @@ func generatekeys(writeLocation string) error {
return nil
}
// generatekeys creates an ed25519 set of keys
func generatekeysPrefix(identityPath string, passThru bool, prefix ...string) error {
dir := filepath.Dir(identityPath)
file := filepath.Base(identityPath)
if err := os.MkdirAll(dir, 0700); err != nil {
return fmt.Errorf("could not create ssh directory: %w", err)
}
args := append([]string{}, prefix[1:]...)
args = append(args, sshCommand...)
args = append(args, file)
binary, err := exec.LookPath(prefix[0])
if err != nil {
return err
}
binary, err = filepath.Abs(binary)
if err != nil {
return err
}
cmd := exec.Command(binary, args...)
cmd.Dir = dir
if passThru {
cmd.Stdin = os.Stdin
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
}
logrus.Debugf("Running wsl cmd %v in dir: %s", args, dir)
return cmd.Run()
}

View File

@ -3,14 +3,11 @@
package machine
import (
"encoding/json"
"fmt"
"os"
"strings"
"github.com/containers/podman/v5/pkg/machine/connection"
"github.com/containers/podman/v5/pkg/machine/define"
"github.com/containers/storage/pkg/ioutils"
)
// GetDevNullFiles returns pointers to Read-only and Write-only DevNull files
@ -110,29 +107,3 @@ issues with non-podman clients, you can switch using the following command:
`
fmt.Printf(fmtString, suffix)
}
// SetRootful modifies the machine's default connection to be either rootful or
// rootless
func SetRootful(rootful bool, name, rootfulName string) error {
return connection.UpdateConnectionIfDefault(rootful, name, rootfulName)
}
// WriteConfig writes the machine's JSON config file
func WriteConfig(configPath string, v VM) error {
opts := &ioutils.AtomicFileWriterOptions{ExplicitCommit: true}
w, err := ioutils.NewAtomicFileWriterWithOpts(configPath, 0644, opts)
if err != nil {
return err
}
defer w.Close()
enc := json.NewEncoder(w)
enc.SetIndent("", " ")
if err := enc.Encode(v); err != nil {
return err
}
// Commit the changes to disk if no errors
return w.Commit()
}

View File

@ -7,35 +7,8 @@ import (
"errors"
"fmt"
"net"
"strings"
)
// ParseVolumeFromPath is a oneshot parsing of a provided volume. It follows the "rules" of
// the singular parsing functions
func ParseVolumeFromPath(v string) (source, target, options string, readonly bool, err error) {
split := strings.SplitN(v, ":", 3)
switch len(split) {
case 1:
source = split[0]
target = split[0]
case 2:
source = split[0]
target = split[1]
case 3:
source = split[0]
target = split[1]
options = split[2]
default:
return "", "", "", false, errors.New("invalid volume provided")
}
// I suppose an option not intended for read-only could interfere here but I do not see a better way
if strings.Contains(options, "ro") {
readonly = true
}
return
}
func DialNamedPipe(ctx context.Context, path string) (net.Conn, error) {
return nil, errors.New("not implemented")
}

View File

@ -2,17 +2,9 @@ package ocipull
import (
"fmt"
"os"
"path/filepath"
"strings"
"github.com/blang/semver/v4"
"github.com/containers/image/v5/pkg/compression"
"github.com/containers/image/v5/types"
"github.com/containers/podman/v5/pkg/machine/define"
"github.com/containers/podman/v5/version"
"github.com/containers/storage/pkg/archive"
"github.com/sirupsen/logrus"
)
type OSVersion struct {
@ -23,37 +15,6 @@ type Disker interface {
Get() error
}
type OCIOpts struct {
Scheme *OCIKind
Dir *string
}
type OCIKind string
var (
OCIDir OCIKind = "oci-dir"
OCIRegistry OCIKind = "docker"
OCIUnknown OCIKind = "unknown"
)
func (o OCIKind) String() string {
switch o {
case OCIDir:
return string(OCIDir)
case OCIRegistry:
return string(OCIRegistry)
}
return string(OCIUnknown)
}
func (o OCIKind) IsOCIDir() bool {
return o == OCIDir
}
func StripOCIReference(input string) string {
return strings.TrimPrefix(input, "docker://")
}
func getVersion() *OSVersion {
v := version.Version
return &OSVersion{&v}
@ -62,53 +23,3 @@ func getVersion() *OSVersion {
func (o *OSVersion) majorMinor() string {
return fmt.Sprintf("%d.%d", o.Major, o.Minor)
}
func unpackOCIDir(ociTb, machineImageDir string) (*define.VMFile, error) {
imageFileName, err := findTarComponent(ociTb)
if err != nil {
return nil, err
}
unpackedFileName := filepath.Join(machineImageDir, imageFileName)
f, err := os.Open(ociTb)
if err != nil {
return nil, err
}
defer func() {
if err := f.Close(); err != nil {
logrus.Error(err)
}
}()
uncompressedReader, _, err := compression.AutoDecompress(f)
if err != nil {
return nil, err
}
defer func() {
if err := uncompressedReader.Close(); err != nil {
logrus.Error(err)
}
}()
logrus.Debugf("untarring %q to %q", ociTb, machineImageDir)
if err := archive.Untar(uncompressedReader, machineImageDir, &archive.TarOptions{
NoLchown: true,
}); err != nil {
return nil, err
}
return define.NewMachineFile(unpackedFileName, nil)
}
func localOCIDiskImageDir(blobDirPath string, localBlob *types.BlobInfo) string {
return filepath.Join(blobDirPath, "blobs", "sha256", localBlob.Digest.Hex())
}
func finalFQImagePathName(vmName, imageName string) string {
// imageName here is fully qualified. we need to break
// it apart and add the vmname
baseDir, filename := filepath.Split(imageName)
return filepath.Join(baseDir, fmt.Sprintf("%s-%s", vmName, filename))
}

View File

@ -1,117 +0,0 @@
package ocipull
import (
"archive/tar"
"context"
"errors"
"fmt"
"io"
"os"
"strings"
"github.com/containers/image/v5/pkg/compression"
"github.com/containers/image/v5/types"
diskcompression "github.com/containers/podman/v5/pkg/machine/compression"
"github.com/containers/podman/v5/pkg/machine/define"
"github.com/sirupsen/logrus"
)
type LocalBlobDir struct {
blob *types.BlobInfo
blobDirPath string
ctx context.Context
imageName string
machineImageDir string
vmName string
}
func NewOCIDir(ctx context.Context, inputDir, machineImageDir, vmName string) *LocalBlobDir {
strippedInputDir := strings.TrimPrefix(inputDir, fmt.Sprintf("%s:/", OCIDir.String()))
l := LocalBlobDir{
blob: nil,
blobDirPath: strippedInputDir,
ctx: ctx,
imageName: "",
machineImageDir: machineImageDir,
vmName: vmName,
}
return &l
}
func (l *LocalBlobDir) Pull() error {
localBlob, err := GetLocalBlob(l.ctx, l.DiskEndpoint())
if err != nil {
return err
}
l.blob = localBlob
return nil
}
func (l *LocalBlobDir) Decompress(compressedFile *define.VMFile) (*define.VMFile, error) {
finalName := finalFQImagePathName(l.vmName, l.imageName)
if err := diskcompression.Decompress(compressedFile, finalName); err != nil {
return nil, err
}
return define.NewMachineFile(finalName, nil)
}
func (l *LocalBlobDir) Unpack() (*define.VMFile, error) {
tbPath := localOCIDiskImageDir(l.blobDirPath, l.blob)
unPackedFile, err := unpackOCIDir(tbPath, l.machineImageDir)
if err != nil {
return nil, err
}
l.imageName = unPackedFile.GetPath()
return unPackedFile, err
}
func (l *LocalBlobDir) DiskEndpoint() string {
return l.blobDirPath
}
func (l *LocalBlobDir) LocalBlob() *types.BlobInfo {
return l.blob
}
// findTarComponent returns a header and a reader matching componentPath within inputFile,
// or (nil, nil, nil) if not found.
func findTarComponent(pathToTar string) (string, error) {
f, err := os.Open(pathToTar)
if err != nil {
return "", err
}
defer func() {
if err := f.Close(); err != nil {
logrus.Error(err)
}
}()
uncompressedReader, _, err := compression.AutoDecompress(f)
if err != nil {
return "", err
}
defer func() {
if err := uncompressedReader.Close(); err != nil {
logrus.Error(err)
}
}()
var (
filename string
headerCount uint
)
t := tar.NewReader(uncompressedReader)
for {
h, err := t.Next()
if err == io.EOF {
break
}
if err != nil {
return "", err
}
filename = h.Name
headerCount++
}
if headerCount != 1 {
return "", errors.New("invalid oci machine image")
}
return filename, nil
}

View File

@ -10,9 +10,7 @@ import (
"github.com/containers/buildah/pkg/parse"
"github.com/containers/image/v5/copy"
"github.com/containers/image/v5/oci/layout"
"github.com/containers/image/v5/pkg/shortnames"
"github.com/containers/image/v5/signature"
"github.com/containers/image/v5/transports/alltransports"
"github.com/containers/image/v5/types"
"github.com/containers/podman/v5/pkg/machine/define"
"github.com/sirupsen/logrus"
@ -95,16 +93,3 @@ func Pull(ctx context.Context, imageInput types.ImageReference, localDestPath *d
return nil
}
func stringToImageReference(imageInput string) (types.ImageReference, error) { //nolint:unused
if shortnames.IsShortName(imageInput) {
return nil, fmt.Errorf("pulling source images by short name (%q) is not supported, please use a fully-qualified name", imageInput)
}
ref, err := alltransports.ParseImageName("docker://" + imageInput)
if err != nil {
return nil, fmt.Errorf("parsing image name: %w", err)
}
return ref, nil
}

View File

@ -1,234 +0,0 @@
//go:build amd64 || arm64
package machine
import (
"errors"
"fmt"
"io"
"net/http"
url2 "net/url"
"os"
"path/filepath"
"strings"
"time"
"github.com/containers/podman/v5/pkg/machine/compression"
"github.com/containers/podman/v5/pkg/machine/define"
"github.com/containers/podman/v5/pkg/machine/env"
"github.com/containers/podman/v5/pkg/machine/ocipull"
"github.com/containers/podman/v5/utils"
"github.com/sirupsen/logrus"
)
// GenericDownload is used when a user provides a URL
// or path for an image
type GenericDownload struct {
Download
}
// NewGenericDownloader is used when the disk image is provided by the user
func NewGenericDownloader(vmType define.VMType, vmName, pullPath string) (DistributionDownload, error) {
var (
imageName string
)
dataDir, err := env.GetDataDir(vmType)
if err != nil {
return nil, err
}
cacheDir, err := env.GetCacheDir(vmType)
if err != nil {
return nil, err
}
dl := Download{}
// Is pullpath a file or url?
if getURL := supportedURL(pullPath); getURL != nil {
urlSplit := strings.Split(getURL.Path, "/")
imageName = urlSplit[len(urlSplit)-1]
dl.URL = getURL
dl.LocalPath = filepath.Join(cacheDir, imageName)
} else {
// Dealing with FilePath
imageName = filepath.Base(pullPath)
dl.LocalPath = pullPath
}
dl.VMName = vmName
dl.ImageName = imageName
dl.LocalUncompressedFile = dl.GetLocalUncompressedFile(dataDir)
// The download needs to be pulled into the datadir
gd := GenericDownload{Download: dl}
return gd, nil
}
func supportedURL(path string) (url *url2.URL) {
getURL, err := url2.Parse(path)
if err != nil {
// ignore error, probably not a URL, fallback & treat as file path
return nil
}
// Check supported scheme. Since URL is passed to net.http, only http
// schemes are supported. Also, windows drive paths can resemble a
// URL, but with a single letter scheme. These values should be
// passed through for interpretation as a file path.
switch getURL.Scheme {
case "http":
fallthrough
case "https":
return getURL
default:
return nil
}
}
func (dl Download) GetLocalUncompressedFile(dataDir string) string {
compressedFilename := dl.VMName + "_" + dl.ImageName
extension := compression.KindFromFile(compressedFilename)
uncompressedFile := strings.TrimSuffix(compressedFilename, fmt.Sprintf(".%s", extension.String()))
dl.LocalUncompressedFile = filepath.Join(dataDir, uncompressedFile)
return dl.LocalUncompressedFile
}
func (g GenericDownload) Get() *Download {
return &g.Download
}
func (g GenericDownload) HasUsableCache() (bool, error) {
// If we have a URL for this "downloader", we now pull it
return g.URL == nil, nil
}
// CleanCache cleans out downloaded uncompressed image files
func (g GenericDownload) CleanCache() error {
// Remove any image that has been downloaded via URL
// We never read from cache for generic downloads
if g.URL != nil {
if err := os.Remove(g.LocalPath); err != nil && !errors.Is(err, os.ErrNotExist) {
return err
}
}
return nil
}
func DownloadImage(d DistributionDownload) error {
// check if the latest image is already present
ok, err := d.HasUsableCache()
if err != nil {
return err
}
if !ok {
if err := DownloadVMImage(d.Get().URL, d.Get().ImageName, d.Get().LocalPath); err != nil {
return err
}
// Clean out old cached images, since we didn't find needed image in cache
defer func() {
if err = d.CleanCache(); err != nil {
logrus.Warnf("error cleaning machine image cache: %s", err)
}
}()
}
localPath, err := define.NewMachineFile(d.Get().LocalPath, nil)
if err != nil {
return err
}
return compression.Decompress(localPath, d.Get().LocalUncompressedFile)
}
// DownloadVMImage downloads a VM image from url to given path
// with download status
func DownloadVMImage(downloadURL *url2.URL, imageName string, localImagePath string) error {
out, err := os.Create(localImagePath)
if err != nil {
return err
}
defer func() {
if err := out.Close(); err != nil {
logrus.Error(err)
}
}()
resp, err := http.Get(downloadURL.String())
if err != nil {
return err
}
defer func() {
if err := resp.Body.Close(); err != nil {
logrus.Error(err)
}
}()
if resp.StatusCode != http.StatusOK {
return fmt.Errorf("downloading VM image %s: %s", downloadURL, resp.Status)
}
size := resp.ContentLength
prefix := "Downloading VM image: " + imageName
onComplete := prefix + ": done"
p, bar := utils.ProgressBar(prefix, size, onComplete)
proxyReader := bar.ProxyReader(resp.Body)
defer func() {
if err := proxyReader.Close(); err != nil {
logrus.Error(err)
}
}()
if _, err := io.Copy(out, proxyReader); err != nil {
return err
}
p.Wait()
return nil
}
func RemoveImageAfterExpire(dir string, expire time.Duration) error {
now := time.Now()
err := filepath.Walk(dir, func(path string, info os.FileInfo, err error) error {
// Delete any cache files that are older than expiry date
if !info.IsDir() && (now.Sub(info.ModTime()) > expire) {
err := os.Remove(path)
if err != nil && !errors.Is(err, os.ErrNotExist) {
logrus.Warnf("unable to clean up cached image: %s", path)
} else {
logrus.Debugf("cleaning up cached image: %s", path)
}
}
return nil
})
return err
}
// AcquireAlternateImage downloads the alternate image the user provided, which
// can be a file path or URL
func (dl Download) AcquireAlternateImage(inputPath string) (*define.VMFile, error) {
g, err := NewGenericDownloader(dl.VMKind, dl.VMName, inputPath)
if err != nil {
return nil, err
}
imagePath, err := define.NewMachineFile(g.Get().LocalUncompressedFile, nil)
if err != nil {
return nil, err
}
if err := DownloadImage(g); err != nil {
return nil, err
}
return imagePath, nil
}
func isOci(input string) (bool, *ocipull.OCIKind, error) { //nolint:unused
inputURL, err := url2.Parse(input)
if err != nil {
return false, nil, err
}
switch inputURL.Scheme {
case ocipull.OCIDir.String():
return true, &ocipull.OCIDir, nil
case ocipull.OCIRegistry.String():
return true, &ocipull.OCIRegistry, nil
}
return false, nil, nil
}

View File

@ -9,13 +9,11 @@ import (
"io"
"io/fs"
"os"
"os/exec"
"strconv"
"strings"
"syscall"
"time"
"github.com/containers/common/pkg/config"
"github.com/containers/podman/v5/pkg/errorhandling"
"github.com/containers/podman/v5/pkg/machine/define"
"github.com/containers/podman/v5/pkg/machine/vmconfigs"
@ -297,43 +295,3 @@ func (q *QEMUStubber) State(mc *vmconfigs.MachineConfig, bypass bool) (define.St
// If there is a monitor, let's see if we can query state
return q.checkStatus(monitor)
}
// executes qemu-image info to get the virtual disk size
// of the diskimage
func getDiskSize(path string) (uint64, error) { //nolint:unused
// Find the qemu executable
cfg, err := config.Default()
if err != nil {
return 0, err
}
qemuPathDir, err := cfg.FindHelperBinary("qemu-img", true)
if err != nil {
return 0, err
}
diskInfo := exec.Command(qemuPathDir, "info", "--output", "json", path)
stdout, err := diskInfo.StdoutPipe()
if err != nil {
return 0, err
}
if err := diskInfo.Start(); err != nil {
return 0, err
}
tmpInfo := struct {
VirtualSize uint64 `json:"virtual-size"`
Filename string `json:"filename"`
ClusterSize int64 `json:"cluster-size"`
Format string `json:"format"`
FormatSpecific struct {
Type string `json:"type"`
Data map[string]string `json:"data"`
}
DirtyFlag bool `json:"dirty-flag"`
}{}
if err := json.NewDecoder(stdout).Decode(&tmpInfo); err != nil {
return 0, err
}
if err := diskInfo.Wait(); err != nil {
return 0, err
}
return tmpInfo.VirtualSize, nil
}

View File

@ -14,22 +14,6 @@ import (
"github.com/sirupsen/logrus"
)
// SetSocket creates a new machine file for the socket and assigns it to
// `socketLoc`
func SetSocket(socketLoc *define.VMFile, path string, symlink *string) error {
socket, err := define.NewMachineFile(path, symlink)
if err != nil {
return err
}
*socketLoc = *socket
return nil
}
// ReadySocketPath returns the filepath for the ready socket
func ReadySocketPath(runtimeDir, machineName string) string {
return filepath.Join(runtimeDir, fmt.Sprintf("%s_ready.sock", machineName))
}
// ListenAndWaitOnSocket waits for a new connection to the listener and sends
// any error back through the channel. ListenAndWaitOnSocket is intended to be
// used as a goroutine

View File

@ -29,9 +29,6 @@ type MachineConfig struct {
Swap strongunits.MiB
// Image stuff
imageDescription machineImage //nolint:unused
ImagePath *define.VMFile // Temporary only until a proper image struct is worked out
// Provider stuff
@ -59,28 +56,6 @@ type MachineConfig struct {
Ansible *AnsibleConfig
}
type machineImage interface { //nolint:unused
download() error
path() string
}
type OCIMachineImage struct {
// registry
// TODO JSON serial/deserial will write string to disk
// but in code it is a types.ImageReference
// quay.io/podman/podman-machine-image:5.0
FQImageReference string
}
func (o OCIMachineImage) path() string {
return ""
}
func (o OCIMachineImage) download() error {
return nil
}
type VMProvider interface { //nolint:interfacebloat
CreateVM(opts define.CreateVMOpts, mc *MachineConfig, builder *ignition.IgnitionBuilder) error
PrepareIgnition(mc *MachineConfig, ignBuilder *ignition.IgnitionBuilder) (*ignition.ReadyUnitOpts, error)

View File

@ -11,7 +11,6 @@ import (
"time"
"github.com/containers/common/pkg/strongunits"
define2 "github.com/containers/podman/v5/libpod/define"
"github.com/containers/podman/v5/pkg/errorhandling"
"github.com/containers/podman/v5/pkg/machine/connection"
"github.com/containers/podman/v5/pkg/machine/define"
@ -145,17 +144,6 @@ func (mc *MachineConfig) SetRootful(rootful bool) error {
return nil
}
func (mc *MachineConfig) removeSystemConnection() error { //nolint:unused
return define2.ErrNotImplemented
}
// updateLastBoot writes the current time to the machine configuration file. it is
// an non-locking method and assumes it is being called locked
func (mc *MachineConfig) updateLastBoot() error { //nolint:unused
mc.LastUp = time.Now()
return mc.Write()
}
func (mc *MachineConfig) Remove(machines map[string]bool, saveIgnition, saveImage bool) ([]string, func() error, error) {
ignitionFile, err := mc.IgnitionFile()
if err != nil {

View File

@ -10,21 +10,12 @@ import (
"time"
"github.com/containers/podman/v5/pkg/machine"
"github.com/containers/podman/v5/pkg/machine/compression"
"github.com/containers/podman/v5/pkg/machine/define"
"github.com/containers/podman/v5/utils"
"github.com/sirupsen/logrus"
)
type WSLVirtualization struct {
machine.Virtualization
}
func VirtualizationProvider() machine.VirtProvider {
return &WSLVirtualization{
machine.NewVirtualization(define.None, compression.Xz, define.Tar, vmtype),
}
}
type WSLVirtualization struct{}
// NewMachine initializes an instance of a wsl machine
func (p *WSLVirtualization) NewMachine(opts define.InitOptions) (machine.VM, error) {

View File

@ -16,7 +16,6 @@ import (
"github.com/containers/common/pkg/config"
"github.com/containers/common/pkg/strongunits"
"github.com/containers/podman/v5/pkg/machine"
"github.com/containers/podman/v5/pkg/machine/define"
"github.com/containers/podman/v5/pkg/machine/env"
"github.com/containers/podman/v5/pkg/machine/ignition"
@ -476,11 +475,6 @@ func wslPipe(input string, dist string, arg ...string) error {
return pipeCmdPassThrough("wsl", input, newArgs...)
}
//nolint:unused
func wslCreateKeys(identityPath string, dist string) (string, error) {
return machine.CreateSSHKeysPrefix(identityPath, true, true, "wsl", "-u", "root", "-d", dist)
}
func runCmdPassThrough(name string, arg ...string) error {
logrus.Debugf("Running command: %s %v", name, arg)
cmd := exec.Command(name, arg...)