mirror of
				https://github.com/containers/podman.git
				synced 2025-11-01 02:42:11 +08:00 
			
		
		
		
	 9bb191df51
			
		
	
	9bb191df51
	
	
	
		
			
			The following PR is the leading PR for refactoring podman machine with the following goals: * less duplication/more re-use * common configuration file between providers * more consistentency in how machines are handled by providers The goal of this PR is the rough refactor. There are still rough spots for sure, specifically around the podman socket and pipe. This implemention is only for Linux. All other providers are still present but will not compile or work. This is why tests for them have been temporarily suspended. The ready socket code is another area that needs to be smoothed over. Right now, the ready socket code is still in QEMU. Preferably it would be moved to a generic spot where all three approaches to readiness socket use can be defined. It should also be noted: * all machine related tests pass. * make validate for Linux passes * Apple QEMU was largely removed * More code pruning is possible; will become clearer when other providers are complete. the dir pkg/machine/p5 is not permanent. i had to seperate this from machine initially due to circular import problems. i think when all providers are done (or nearly done), it can be placed and named properly. Signed-off-by: Brent Baude <bbaude@redhat.com>
		
			
				
	
	
		
			39 lines
		
	
	
		
			975 B
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			39 lines
		
	
	
		
			975 B
		
	
	
	
		
			Go
		
	
	
	
	
	
| //go:build !windows && !darwin
 | |
| 
 | |
| package provider
 | |
| 
 | |
| import (
 | |
| 	"fmt"
 | |
| 	"os"
 | |
| 
 | |
| 	"github.com/containers/podman/v4/pkg/machine/vmconfigs"
 | |
| 
 | |
| 	"github.com/containers/common/pkg/config"
 | |
| 	"github.com/containers/podman/v4/pkg/machine/define"
 | |
| 	"github.com/containers/podman/v4/pkg/machine/qemu"
 | |
| 	"github.com/sirupsen/logrus"
 | |
| )
 | |
| 
 | |
| func Get() (vmconfigs.VMStubber, error) {
 | |
| 	cfg, err := config.Default()
 | |
| 	if err != nil {
 | |
| 		return nil, err
 | |
| 	}
 | |
| 	provider := cfg.Machine.Provider
 | |
| 	if providerOverride, found := os.LookupEnv("CONTAINERS_MACHINE_PROVIDER"); found {
 | |
| 		provider = providerOverride
 | |
| 	}
 | |
| 	resolvedVMType, err := define.ParseVMType(provider, define.QemuVirt)
 | |
| 	if err != nil {
 | |
| 		return nil, err
 | |
| 	}
 | |
| 
 | |
| 	logrus.Debugf("Using Podman machine with `%s` virtualization provider", resolvedVMType.String())
 | |
| 	switch resolvedVMType {
 | |
| 	case define.QemuVirt:
 | |
| 		return new(qemu.QEMUStubber), nil
 | |
| 	default:
 | |
| 		return nil, fmt.Errorf("unsupported virtualization provider: `%s`", resolvedVMType.String())
 | |
| 	}
 | |
| }
 |