mirror of
https://github.com/containers/podman.git
synced 2025-09-19 23:03:16 +08:00
Merge pull request #22759 from slp/krun-debug
Enable libkrun provider to open a debug console
This commit is contained in:
@ -8,6 +8,7 @@ import (
|
||||
"fmt"
|
||||
"net"
|
||||
"os"
|
||||
"os/exec"
|
||||
"syscall"
|
||||
"time"
|
||||
|
||||
@ -275,6 +276,42 @@ func StartGenericAppleVM(mc *vmconfigs.MachineConfig, cmdBinary string, bootload
|
||||
|
||||
logrus.Debugf("helper command-line: %v", cmd.Args)
|
||||
|
||||
if mc.LibKrunHypervisor != nil && logrus.IsLevelEnabled(logrus.DebugLevel) {
|
||||
rtDir, err := mc.RuntimeDir()
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
kdFile, err := rtDir.AppendToNewVMFile("krunkit-debug.sh", nil)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
f, err := os.Create(kdFile.Path)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
err = os.Chmod(kdFile.Path, 0744)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
_, err = f.WriteString("#!/bin/sh\nexec ")
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
for _, arg := range cmd.Args {
|
||||
_, err = f.WriteString(fmt.Sprintf("%q ", arg))
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
}
|
||||
err = f.Close()
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
cmd = exec.Command("/usr/bin/open", "-Wa", "Terminal", kdFile.Path)
|
||||
}
|
||||
|
||||
if err := cmd.Start(); err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
@ -9,6 +9,7 @@ import (
|
||||
"github.com/containers/podman/v5/pkg/machine/vmconfigs"
|
||||
vfConfig "github.com/crc-org/vfkit/pkg/config"
|
||||
"github.com/crc-org/vfkit/pkg/rest"
|
||||
"github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
func GetDefaultDevices(mc *vmconfigs.MachineConfig) ([]vfConfig.VirtioDevice, *define.VMFile, error) {
|
||||
@ -41,7 +42,12 @@ func GetDefaultDevices(mc *vmconfigs.MachineConfig) ([]vfConfig.VirtioDevice, *d
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
devices = append(devices, disk, rng, serial, readyDevice)
|
||||
devices = append(devices, disk, rng, readyDevice)
|
||||
if mc.LibKrunHypervisor == nil || !logrus.IsLevelEnabled(logrus.DebugLevel) {
|
||||
// If libkrun is the provider and we want to show the debug console,
|
||||
// don't add a virtio serial device to avoid redirecting the output.
|
||||
devices = append(devices, serial)
|
||||
}
|
||||
|
||||
if mc.AppleHypervisor != nil && mc.AppleHypervisor.Vfkit.Rosetta {
|
||||
rosetta := &vfConfig.RosettaShare{
|
||||
|
Reference in New Issue
Block a user