mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-06-25 15:02:45 +00:00
vc: hypervisor: use our own logger
This'll end up moving to hypervisors pkg, but let's stop using virtLog, instead introduce hvLogger. Fixes: #2884 Signed-off-by: Eric Ernst <eric_ernst@apple.com>
This commit is contained in:
parent
4c2883f7e2
commit
2227c46c25
@ -35,7 +35,7 @@ var virtLog = logrus.WithField("source", "virtcontainers")
|
||||
func SetLogger(ctx context.Context, logger *logrus.Entry) {
|
||||
fields := virtLog.Data
|
||||
virtLog = logger.WithFields(fields)
|
||||
|
||||
SetHypervisorLogger(virtLog) // TODO: this will move to hypervisors pkg
|
||||
deviceApi.SetLogger(virtLog)
|
||||
compatoci.SetLogger(virtLog)
|
||||
deviceConfig.SetLogger(virtLog)
|
||||
|
@ -813,7 +813,7 @@ func (clh *cloudHypervisor) AddDevice(ctx context.Context, devInfo interface{},
|
||||
//###########################################################################
|
||||
|
||||
func (clh *cloudHypervisor) Logger() *log.Entry {
|
||||
return virtLog.WithField("subsystem", "cloudHypervisor")
|
||||
return hvLogger.WithField("subsystem", "cloudHypervisor")
|
||||
}
|
||||
|
||||
// Adds all capabilities supported by cloudHypervisor implementation of hypervisor interface
|
||||
|
@ -18,6 +18,8 @@ import (
|
||||
"github.com/kata-containers/kata-containers/src/runtime/virtcontainers/device/config"
|
||||
"github.com/kata-containers/kata-containers/src/runtime/virtcontainers/types"
|
||||
"github.com/kata-containers/kata-containers/src/runtime/virtcontainers/utils"
|
||||
|
||||
"github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
// HypervisorType describes an hypervisor type.
|
||||
@ -45,14 +47,10 @@ const (
|
||||
|
||||
// MockHypervisor is a mock hypervisor for testing purposes
|
||||
MockHypervisor HypervisorType = "mock"
|
||||
)
|
||||
|
||||
const (
|
||||
procMemInfo = "/proc/meminfo"
|
||||
procCPUInfo = "/proc/cpuinfo"
|
||||
)
|
||||
|
||||
const (
|
||||
defaultVCPUs = 1
|
||||
// 2 GiB
|
||||
defaultMemSzMiB = 2048
|
||||
@ -73,6 +71,10 @@ const (
|
||||
MinHypervisorMemory = 256
|
||||
)
|
||||
|
||||
var (
|
||||
hvLogger = logrus.WithField("source", "virtcontainers/hypervisor")
|
||||
)
|
||||
|
||||
// In some architectures the maximum number of vCPUs depends on the number of physical cores.
|
||||
var defaultMaxQemuVCPUs = MaxQemuVCPUs()
|
||||
|
||||
@ -143,6 +145,12 @@ type MemoryDevice struct {
|
||||
Probe bool
|
||||
}
|
||||
|
||||
// SetHypervisorLogger sets up a logger for the hypervisor part of this pkg
|
||||
func SetHypervisorLogger(logger *logrus.Entry) {
|
||||
fields := hvLogger.Data
|
||||
hvLogger = logger.WithFields(fields)
|
||||
}
|
||||
|
||||
// Set sets an hypervisor type based on the input string.
|
||||
func (hType *HypervisorType) Set(value string) error {
|
||||
switch value {
|
||||
@ -604,7 +612,7 @@ func (conf *HypervisorConfig) AddCustomAsset(a *types.Asset) error {
|
||||
return fmt.Errorf("Invalid %s at %s", a.Type(), a.Path())
|
||||
}
|
||||
|
||||
virtLog.Debugf("Using custom %v asset %s", a.Type(), a.Path())
|
||||
hvLogger.Debugf("Using custom %v asset %s", a.Type(), a.Path())
|
||||
|
||||
if conf.customAssets == nil {
|
||||
conf.customAssets = make(map[types.AssetType]*types.Asset)
|
||||
@ -872,7 +880,7 @@ func RunningOnVMM(cpuInfoPath string) (bool, error) {
|
||||
return flags["hypervisor"], nil
|
||||
}
|
||||
|
||||
virtLog.WithField("arch", runtime.GOARCH).Info("Unable to know if the system is running inside a VM")
|
||||
hvLogger.WithField("arch", runtime.GOARCH).Info("Unable to know if the system is running inside a VM")
|
||||
return false, nil
|
||||
}
|
||||
|
||||
|
@ -141,7 +141,7 @@ type qmpLogger struct {
|
||||
|
||||
func newQMPLogger() qmpLogger {
|
||||
return qmpLogger{
|
||||
logger: virtLog.WithField("subsystem", "qmp"),
|
||||
logger: hvLogger.WithField("subsystem", "qmp"),
|
||||
}
|
||||
}
|
||||
|
||||
@ -163,7 +163,7 @@ func (l qmpLogger) Errorf(format string, v ...interface{}) {
|
||||
|
||||
// Logger returns a logrus logger appropriate for logging qemu messages
|
||||
func (q *qemu) Logger() *logrus.Entry {
|
||||
return virtLog.WithField("subsystem", "qemu")
|
||||
return hvLogger.WithField("subsystem", "qemu")
|
||||
}
|
||||
|
||||
func (q *qemu) kernelParameters() string {
|
||||
|
@ -169,7 +169,7 @@ func (q *qemuAmd64) cpuModel() string {
|
||||
// VMX is not migratable yet.
|
||||
// issue: https://github.com/kata-containers/runtime/issues/1750
|
||||
if q.vmFactory {
|
||||
virtLog.WithField("subsystem", "qemuAmd64").Warn("VMX is not migratable yet: turning it off")
|
||||
hvLogger.WithField("subsystem", "qemuAmd64").Warn("VMX is not migratable yet: turning it off")
|
||||
cpuModel += ",vmx=off"
|
||||
}
|
||||
|
||||
@ -200,7 +200,7 @@ func (q *qemuAmd64) enableProtection() error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
logger := virtLog.WithFields(logrus.Fields{
|
||||
logger := hvLogger.WithFields(logrus.Fields{
|
||||
"subsystem": "qemuAmd64",
|
||||
"machine": q.qemuMachine,
|
||||
"kernel-params-debug": q.kernelParamsDebug,
|
||||
|
@ -846,6 +846,6 @@ func (q *qemuArchBase) setPFlash(p []string) {
|
||||
|
||||
// append protection device
|
||||
func (q *qemuArchBase) appendProtectionDevice(devices []govmmQemu.Device, firmware string) ([]govmmQemu.Device, string, error) {
|
||||
virtLog.WithField("arch", runtime.GOARCH).Warnf("Confidential Computing has not been implemented for this architecture")
|
||||
hvLogger.WithField("arch", runtime.GOARCH).Warnf("Confidential Computing has not been implemented for this architecture")
|
||||
return devices, firmware, nil
|
||||
}
|
||||
|
@ -171,6 +171,6 @@ func (q *qemuArm64) enableProtection() error {
|
||||
|
||||
func (q *qemuArm64) appendProtectionDevice(devices []govmmQemu.Device, firmware string) ([]govmmQemu.Device, string, error) {
|
||||
err := q.enableProtection()
|
||||
virtLog.WithField("arch", runtime.GOARCH).Warnf("%v", err)
|
||||
hvLogger.WithField("arch", runtime.GOARCH).Warnf("%v", err)
|
||||
return devices, firmware, err
|
||||
}
|
||||
|
@ -51,7 +51,7 @@ var supportedQemuMachine = govmmQemu.Machine{
|
||||
|
||||
// Logger returns a logrus logger appropriate for logging qemu messages
|
||||
func (q *qemuPPC64le) Logger() *logrus.Entry {
|
||||
return virtLog.WithField("subsystem", "qemuPPC64le")
|
||||
return hvLogger.WithField("subsystem", "qemuPPC64le")
|
||||
}
|
||||
|
||||
// MaxQemuVCPUs returns the maximum number of vCPUs supported
|
||||
@ -141,7 +141,7 @@ func (q *qemuPPC64le) enableProtection() error {
|
||||
q.qemuMachine.Options += ","
|
||||
}
|
||||
q.qemuMachine.Options += fmt.Sprintf("confidential-guest-support=%s", pefID)
|
||||
virtLog.WithFields(logrus.Fields{
|
||||
hvLogger.WithFields(logrus.Fields{
|
||||
"subsystem": "qemuPPC64le",
|
||||
"machine": q.qemuMachine,
|
||||
"kernel-params": q.kernelParams,
|
||||
|
@ -324,7 +324,7 @@ func (q *qemuS390x) enableProtection() error {
|
||||
q.qemuMachine.Options += ","
|
||||
}
|
||||
q.qemuMachine.Options += fmt.Sprintf("confidential-guest-support=%s", secExecID)
|
||||
virtLog.WithFields(logrus.Fields{
|
||||
hvLogger.WithFields(logrus.Fields{
|
||||
"subsystem": logSubsystem,
|
||||
"machine": q.qemuMachine}).
|
||||
Info("Enabling guest protection with Secure Execution")
|
||||
|
@ -216,7 +216,7 @@ func (v *virtiofsd) valid() error {
|
||||
}
|
||||
|
||||
func (v *virtiofsd) Logger() *log.Entry {
|
||||
return virtLog.WithField("subsystem", "virtiofsd")
|
||||
return hvLogger.WithField("subsystem", "virtiofsd")
|
||||
}
|
||||
|
||||
func (v *virtiofsd) kill(ctx context.Context) (err error) {
|
||||
|
Loading…
Reference in New Issue
Block a user