Documentation ¶
Overview ¶
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Index ¶
- Constants
- func APISocketPath() string
- func ConfigureUEFIVars(c *qcli.Config, srcCode, srcVars, runDir string, secureBoot bool) error
- func CopyFileBits(src, dest string) error
- func CopyFileRefSparse(src, dest string) error
- func CreateLocalDataSource(cfg CloudInitConfig, directory string) error
- func EnsureDir(dir string) error
- func ForceLink(oldname, newname string) error
- func GenerateQConfig(runDir, sockDir string, v VMDef) (*qcli.Config, error)
- func GetAPIURL(endpoint string) string
- func GetCommandErrorRC(err error) int
- func GetCommandErrorRCDefault(err error, rcError int) int
- func GetKvmPath() (string, error)
- func GetTempSocketDir() (string, error)
- func HasCloudConfig(config CloudInitConfig) bool
- func LogCommand(args ...string) error
- func LogCommandDebug(args ...string) error
- func LogCommandWithFunc(logf func(string, ...interface{}), args ...string) error
- func NewDefaultAarch64Config(name string, numCpus uint32, numMemMB uint32, sockDir string) (*qcli.Config, error)
- func NewDefaultX86Config(name string, numCpus, numMemMB uint32, sockDir string) (*qcli.Config, error)
- func NewVVFATBlockDev(id, directory, label string) (qcli.BlockDevice, error)
- func NextFreePort(first int) int
- func PathExists(d string) bool
- func PrepareMetadata(config *CloudInitConfig, hostname string) error
- func RandomMAC() (string, error)
- func RandomQemuMAC() (string, error)
- func RenderCloudInitConfig(config CloudInitConfig, outputPath string) error
- func RsyncDirWithErrorQuiet(src, dest string) error
- func RunCommand(args ...string) error
- func RunCommandWithOutputErrorRc(args ...string) ([]byte, []byte, int)
- func RunCommandWithRc(args ...string) ([]byte, int)
- func UserConfigDir() (string, error)
- func UserDataDir() (string, error)
- func UserRuntimeDir() (string, error)
- func UserStateDir() (string, error)
- func WaitForPath(path string, retries, sleepSeconds int) bool
- func Which(commandName string) string
- func WhichInRoot(commandName string, root string) string
- type CloudInitConfig
- type ConsoleInfo
- type Controller
- type DiskSize
- type Machine
- func (cls *Machine) ConfigDir() string
- func (cls *Machine) ConfigFile() string
- func (cls *Machine) Context() context.Context
- func (cls *Machine) DataDir() string
- func (m *Machine) Delete() error
- func (m *Machine) GetStatus() string
- func (m *Machine) IsRunning() bool
- func (cls *Machine) SaveConfig() error
- func (m *Machine) SerialSocket() (string, error)
- func (m *Machine) SpiceConnection() (SpiceConnection, error)
- func (m *Machine) Start() error
- func (cls *Machine) StateDir() string
- func (m *Machine) Stop(force bool) error
- type MachineConsoleRequest
- type MachineController
- func (ctl *MachineController) AddMachine(newMachine Machine, cfg *MachineDaemonConfig) error
- func (ctl *MachineController) DeleteMachine(machineName string, cfg *MachineDaemonConfig) error
- func (ctl *MachineController) GetMachine(machineName string) (Machine, error)
- func (ctl *MachineController) GetMachineByName(machineName string) (*Machine, error)
- func (ctl *MachineController) GetMachineConsole(machineName string, consoleType string) (ConsoleInfo, error)
- func (ctl *MachineController) GetMachines() []Machine
- func (ctl *MachineController) StartMachine(machineName string) error
- func (ctl *MachineController) StopMachine(machineName string, force bool) error
- func (ctl *MachineController) StopMachines() error
- func (ctl *MachineController) UpdateMachine(updateMachine Machine, cfg *MachineDaemonConfig) error
- type MachineDaemonConfig
- type MetaData
- type NetworkDef
- type NicDef
- type Port
- type PortRule
- type QMPMachineLogger
- type QemuDisk
- type RouteHandler
- func (rh *RouteHandler) DeleteMachine(ctx *gin.Context)
- func (rh *RouteHandler) GetMachine(ctx *gin.Context)
- func (rh *RouteHandler) GetMachineConsole(ctx *gin.Context)
- func (rh *RouteHandler) GetMachines(ctx *gin.Context)
- func (rh *RouteHandler) PostMachine(ctx *gin.Context)
- func (rh *RouteHandler) SetupRoutes()
- func (rh *RouteHandler) StartMachine(ctx *gin.Context)
- func (rh *RouteHandler) StopMachine(ctx *gin.Context)
- func (rh *RouteHandler) UpdateMachine(ctx *gin.Context)
- type SpiceConnection
- type StopChannel
- type SwTPM
- type VM
- func (v *VM) BackgroundRun() error
- func (v *VM) Delete() error
- func (v *VM) IsRunning() bool
- func (v *VM) MonitorSocket() (string, error)
- func (v *VM) Name() string
- func (v *VM) QMPStatus() qcli.RunState
- func (v *VM) SerialSocket() (string, error)
- func (v *VM) SocketDir() string
- func (v *VM) SpiceDevice() (qcli.SpiceDevice, error)
- func (v *VM) Start() error
- func (v *VM) StartQMP() error
- func (v *VM) Status() VMState
- func (v *VM) Stop(force bool) error
- func (v *VM) TPMSocket() (string, error)
- type VMDef
- type VMNic
- type VMState
Constants ¶
const ( MachineStatusInitialized string = "initialized" MachineStatusStopped string = "stopped" MachineStatusStarting string = "starting" MachineStatusRunning string = "running" MachineStatusStopping string = "stopping" MachineStatusFailed string = "failed" SerialConsole string = "console" VGAConsole string = "vga" )
const LinuxUnixSocketMaxLen int = 108
LinuxUnixSocketMaxLen - 108 chars max for a unix socket path (including null byte).
const MachineUnixSocketName = "machined.socket"
const (
NoCloudFSLabel = "cidata"
)
Variables ¶
This section is empty.
Functions ¶
func APISocketPath ¶
func APISocketPath() string
func ConfigureUEFIVars ¶
func CopyFileBits ¶
CopyFileBits - copy file content from a to b differs from CopyFile in:
- does not do permissions - new files created with 0644
- if src is a symlink, copies content, not link.
- does not invoke sh.
func CopyFileRefSparse ¶
Copy one file to a new path, i.e. cp a b
func CreateLocalDataSource ¶ added in v0.1.3
func CreateLocalDataSource(cfg CloudInitConfig, directory string) error
func GetCommandErrorRC ¶
func GetKvmPath ¶
func GetTempSocketDir ¶
func HasCloudConfig ¶ added in v0.1.3
func HasCloudConfig(config CloudInitConfig) bool
func LogCommand ¶
func LogCommandDebug ¶
func LogCommandWithFunc ¶
func NewDefaultAarch64Config ¶
func NewDefaultX86Config ¶
func NewVVFATBlockDev ¶ added in v0.1.3
func NewVVFATBlockDev(id, directory, label string) (qcli.BlockDevice, error)
func NextFreePort ¶
func PathExists ¶
func PrepareMetadata ¶ added in v0.1.3
func PrepareMetadata(config *CloudInitConfig, hostname string) error
func RandomQemuMAC ¶
func RenderCloudInitConfig ¶ added in v0.1.3
func RenderCloudInitConfig(config CloudInitConfig, outputPath string) error
func RsyncDirWithErrorQuiet ¶ added in v0.1.3
func RunCommand ¶
func RunCommandWithRc ¶
func WaitForPath ¶
func WhichInRoot ¶
Types ¶
type CloudInitConfig ¶ added in v0.1.3
type ConsoleInfo ¶
type Controller ¶
type Controller struct { Config *MachineDaemonConfig Router *gin.Engine MachineController MachineController Server *http.Server // contains filtered or unexported fields }
func NewController ¶
func NewController(config *MachineDaemonConfig) *Controller
func (*Controller) InitMachineController ¶
func (c *Controller) InitMachineController(ctx context.Context) error
type Machine ¶
type Machine struct { Type string `yaml:"type"` Config VMDef `yaml:"config"` Description string `yaml:"description"` Ephemeral bool `yaml:"ephemeral"` Name string `yaml:"name"` Status string // contains filtered or unexported fields }
func LoadConfig ¶
func (*Machine) ConfigFile ¶
func (*Machine) SaveConfig ¶
func (*Machine) SerialSocket ¶
func (*Machine) SpiceConnection ¶
func (m *Machine) SpiceConnection() (SpiceConnection, error)
type MachineConsoleRequest ¶
type MachineConsoleRequest struct {
ConsoleType string `json:"type"`
}
type MachineController ¶
type MachineController struct {
Machines []Machine
}
func (*MachineController) AddMachine ¶
func (ctl *MachineController) AddMachine(newMachine Machine, cfg *MachineDaemonConfig) error
func (*MachineController) DeleteMachine ¶
func (ctl *MachineController) DeleteMachine(machineName string, cfg *MachineDaemonConfig) error
func (*MachineController) GetMachine ¶
func (ctl *MachineController) GetMachine(machineName string) (Machine, error)
func (*MachineController) GetMachineByName ¶
func (ctl *MachineController) GetMachineByName(machineName string) (*Machine, error)
func (*MachineController) GetMachineConsole ¶
func (ctl *MachineController) GetMachineConsole(machineName string, consoleType string) (ConsoleInfo, error)
func (*MachineController) GetMachines ¶
func (ctl *MachineController) GetMachines() []Machine
func (*MachineController) StartMachine ¶
func (ctl *MachineController) StartMachine(machineName string) error
func (*MachineController) StopMachine ¶
func (ctl *MachineController) StopMachine(machineName string, force bool) error
func (*MachineController) StopMachines ¶
func (ctl *MachineController) StopMachines() error
func (*MachineController) UpdateMachine ¶
func (ctl *MachineController) UpdateMachine(updateMachine Machine, cfg *MachineDaemonConfig) error
type MachineDaemonConfig ¶
type MachineDaemonConfig struct { ConfigDirectory string DataDirectory string StateDirectory string }
func DefaultMachineDaemonConfig ¶
func DefaultMachineDaemonConfig() *MachineDaemonConfig
func (*MachineDaemonConfig) GetConfigContext ¶
func (c *MachineDaemonConfig) GetConfigContext() context.Context
type NetworkDef ¶
type NicDef ¶
type NicDef struct { BusAddr string `yaml:"addr,omitempty"` Device string `yaml:"device"` ID string `yaml:"id",omitempty` Mac string `yaml:"mac",omitempty` Network string `yaml:"network",omitempty` Ports []PortRule `yaml:"ports",omitempty` BootIndex string `yaml:"bootindex,omitempty` ROMFile string `yaml:"romfile,omitempty` // contains filtered or unexported fields }
func (NicDef) QNetDevice ¶
type QMPMachineLogger ¶
type QMPMachineLogger struct{}
func (QMPMachineLogger) Errorf ¶
func (l QMPMachineLogger) Errorf(format string, v ...interface{})
func (QMPMachineLogger) Infof ¶
func (l QMPMachineLogger) Infof(format string, v ...interface{})
func (QMPMachineLogger) V ¶
func (l QMPMachineLogger) V(level int32) bool
func (QMPMachineLogger) Warningf ¶
func (l QMPMachineLogger) Warningf(format string, v ...interface{})
type QemuDisk ¶
type QemuDisk struct { File string `yaml:"file,omitempty"` Format string `yaml:"format,omitempty"` Size DiskSize `yaml:"size"` Attach string `yaml:"attach,omitempty"` Type string `yaml:"type"` BlockSize int `yaml:"blocksize,omitempty"` BusAddr string `yaml:"addr,omitempty"` BootIndex string `yaml:"bootindex,omitempty"` ReadOnly bool `yaml:"read-only,omitempty"` }
func (*QemuDisk) ImportDiskImage ¶
FIXME: what to do with remote client/server ? push to zot and use zot URLs? ImportDiskImage will copy/create a source image to server image
func (*QemuDisk) QBlockDevice ¶
func (qd *QemuDisk) QBlockDevice(qti *qcli.QemuTypeIndex) (qcli.BlockDevice, error)
type RouteHandler ¶
type RouteHandler struct {
// contains filtered or unexported fields
}
func NewRouteHandler ¶
func NewRouteHandler(c *Controller) *RouteHandler
func (*RouteHandler) DeleteMachine ¶
func (rh *RouteHandler) DeleteMachine(ctx *gin.Context)
func (*RouteHandler) GetMachine ¶
func (rh *RouteHandler) GetMachine(ctx *gin.Context)
func (*RouteHandler) GetMachineConsole ¶
func (rh *RouteHandler) GetMachineConsole(ctx *gin.Context)
func (*RouteHandler) GetMachines ¶
func (rh *RouteHandler) GetMachines(ctx *gin.Context)
func (*RouteHandler) PostMachine ¶
func (rh *RouteHandler) PostMachine(ctx *gin.Context)
func (*RouteHandler) SetupRoutes ¶
func (rh *RouteHandler) SetupRoutes()
func (*RouteHandler) StartMachine ¶
func (rh *RouteHandler) StartMachine(ctx *gin.Context)
func (*RouteHandler) StopMachine ¶
func (rh *RouteHandler) StopMachine(ctx *gin.Context)
func (*RouteHandler) UpdateMachine ¶
func (rh *RouteHandler) UpdateMachine(ctx *gin.Context)
type SpiceConnection ¶
type StopChannel ¶
type StopChannel chan struct{}
type SwTPM ¶
type VM ¶
type VM struct { Ctx context.Context Cancel context.CancelFunc Config VMDef State VMState RunDir string Cmd *exec.Cmd SwTPM *SwTPM // contains filtered or unexported fields }
TODO: Rename fields
func (*VM) BackgroundRun ¶
func (*VM) MonitorSocket ¶
func (*VM) SerialSocket ¶
func (*VM) SocketDir ¶
note VM.sockDir is the path to the real sockets and runDir/sockets is a symlink to the socket
func (*VM) SpiceDevice ¶
func (v *VM) SpiceDevice() (qcli.SpiceDevice, error)
type VMDef ¶
type VMDef struct { Name string `yaml:"name"` Cpus uint32 `yaml:"cpus" default:1` Memory uint32 `yaml:"memory"` Serial string `yaml:"serial"` Nics []NicDef `yaml:"nics"` Disks []QemuDisk `yaml:"disks"` Boot string `yaml:"boot"` Cdrom string `yaml:"cdrom"` UEFICode string `yaml:"uefi-code"` UEFIVars string `yaml:"uefi-vars"` TPM bool `yaml:"tpm"` TPMVersion string `yaml:"tpm-version"` SecureBoot bool `yaml:"secure-boot"` Gui bool `yaml:"gui"` CloudInit CloudInitConfig `yaml:"cloud-init"` }
func (*VMDef) AdjustBootIndicies ¶
func (v *VMDef) AdjustBootIndicies(qti *qcli.QemuTypeIndex) error