Files
podman/pkg/machine/apple/ignition.go
Brent Baude d2c1de5993 Add krun support to podman machine
This PR adds libkrun support to podman machine.  This is an experimental feature and should not be marketed yet.  Before we unmark the experimental status on this function, we will need to have full CI support and a full podman point release has pased.

This work relies on the fact that vfkit and libkrun share a reasonably (if not perfectly) same API.  The --log-level debug option will not show a GUI screen for boots as krun is not capable of this.

Signed-off-by: Brent Baude <bbaude@redhat.com>
2024-04-26 08:58:38 -05:00

46 lines
1.1 KiB
Go

//go:build darwin
package apple
import (
"net"
"net/http"
"github.com/containers/podman/v5/pkg/machine/define"
"github.com/containers/podman/v5/pkg/machine/vmconfigs"
"github.com/sirupsen/logrus"
)
// ServeIgnitionOverSock allows podman to open a small httpd instance on the vsock between the host
// and guest to inject the ignitionfile into fcos
func ServeIgnitionOverSock(ignitionSocket *define.VMFile, mc *vmconfigs.MachineConfig) error {
ignitionFile, err := mc.IgnitionFile()
if err != nil {
return err
}
logrus.Debugf("reading ignition file: %s", ignitionFile.GetPath())
ignFile, err := ignitionFile.Read()
if err != nil {
return err
}
mux := http.NewServeMux()
mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
_, err := w.Write(ignFile)
if err != nil {
logrus.Errorf("failed to serve ignition file: %v", err)
}
})
listener, err := net.Listen("unix", ignitionSocket.GetPath())
if err != nil {
return err
}
logrus.Debugf("ignition socket device: %s", ignitionSocket.GetPath())
defer func() {
if err := listener.Close(); err != nil {
logrus.Error(err)
}
}()
return http.Serve(listener, mux)
}