Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix unknown issue with eve agent init #3567

Merged
merged 2 commits into from
Nov 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions pkg/mkimage-raw-efi/install
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@ BAIL_FINAL_CMD=${BAIL_FINAL_CMD:-"exit 1"}
# the contents of this file are saved to $REPORT/installer.log
# After the USB install, users can see the installation status under /Volumes/INVENTORY/<serial#>/installer.log
LOGFILE_DIR="/run"

# pillar behaves differently if this file exists to check if it is running in installer mode - see hypervisor.go
LOGFILE="$LOGFILE_DIR/installer.log"
# logs to both console and a file.
logmsg() {
Expand Down
76 changes: 45 additions & 31 deletions pkg/pillar/cmd/domainmgr/domainmgr.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,9 +136,20 @@
ctx.pubAssignableAdapters.Publish("global", *ctx.assignableAdapters)
}

var currentHypervisor hypervisor.Hypervisor
var currentHypervisorMutex sync.Mutex
var logger *logrus.Logger
var log *base.LogObject

// CurrentHypervisor returns the current hypervisor
func CurrentHypervisor() hypervisor.Hypervisor {
currentHypervisorMutex.Lock()
hv := currentHypervisor
currentHypervisorMutex.Unlock()

return hv

Check warning on line 150 in pkg/pillar/cmd/domainmgr/domainmgr.go

View check run for this annotation

Codecov / codecov/patch

pkg/pillar/cmd/domainmgr/domainmgr.go#L145-L150

Added lines #L145 - L150 were not covered by tests
}

func Run(ps *pubsub.PubSub, loggerArg *logrus.Logger, logArg *base.LogObject, arguments []string) int {
logger = loggerArg
log = logArg
Expand Down Expand Up @@ -168,14 +179,17 @@
fmt.Printf("%s: %s\n", agentName, Version)
return 0
}
currentHypervisorMutex.Lock()
currentHypervisor, err = hypervisor.GetHypervisor(*domainCtx.hypervisorPtr)
currentHypervisorMutex.Unlock()

Check warning on line 184 in pkg/pillar/cmd/domainmgr/domainmgr.go

View check run for this annotation

Codecov / codecov/patch

pkg/pillar/cmd/domainmgr/domainmgr.go#L182-L184

Added lines #L182 - L184 were not covered by tests
if err != nil {
log.Fatal(err)
}

if err := pidfile.CheckAndCreatePidfile(log, agentName); err != nil {
log.Fatal(err)
}
log.Functionf("Starting %s with %s hypervisor backend", agentName, hypervisor.CurrentHypervisor().Name())
log.Functionf("Starting %s with %s hypervisor backend", agentName, CurrentHypervisor().Name())

Check warning on line 192 in pkg/pillar/cmd/domainmgr/domainmgr.go

View check run for this annotation

Codecov / codecov/patch

pkg/pillar/cmd/domainmgr/domainmgr.go#L192

Added line #L192 was not covered by tests

// Run a periodic timer so we always update StillRunning
stillRunning := time.NewTicker(25 * time.Second)
Expand Down Expand Up @@ -472,15 +486,15 @@

capabilitiesSent := false
capabilitiesTicker := time.NewTicker(5 * time.Second)
if err := getAndPublishCapabilities(&domainCtx, hypervisor.CurrentHypervisor()); err != nil {
if err := getAndPublishCapabilities(&domainCtx, CurrentHypervisor()); err != nil {

Check warning on line 489 in pkg/pillar/cmd/domainmgr/domainmgr.go

View check run for this annotation

Codecov / codecov/patch

pkg/pillar/cmd/domainmgr/domainmgr.go#L489

Added line #L489 was not covered by tests
log.Warnf("getAndPublishCapabilities: %v", err)
} else {
capabilitiesSent = true
capabilitiesTicker.Stop()
}

log.Functionf("Creating %s at %s", "metricsTimerTask", agentlog.GetMyStack())
go metricsTimerTask(&domainCtx, hypervisor.CurrentHypervisor())
go metricsTimerTask(&domainCtx, CurrentHypervisor())

Check warning on line 497 in pkg/pillar/cmd/domainmgr/domainmgr.go

View check run for this annotation

Codecov / codecov/patch

pkg/pillar/cmd/domainmgr/domainmgr.go#L497

Added line #L497 was not covered by tests

// Before starting to process DomainConfig, domainmgr should (in this order):
// 1. wait for NIM to publish DNS to learn which ports are used for management
Expand Down Expand Up @@ -516,7 +530,7 @@
publishProcessesHandler(&domainCtx)

case <-capabilitiesTicker.C:
if err := getAndPublishCapabilities(&domainCtx, hypervisor.CurrentHypervisor()); err != nil {
if err := getAndPublishCapabilities(&domainCtx, CurrentHypervisor()); err != nil {

Check warning on line 533 in pkg/pillar/cmd/domainmgr/domainmgr.go

View check run for this annotation

Codecov / codecov/patch

pkg/pillar/cmd/domainmgr/domainmgr.go#L533

Added line #L533 was not covered by tests
log.Warnf("getAndPublishCapabilities: %v", err)
} else {
capabilitiesSent = true
Expand All @@ -542,7 +556,7 @@
var resources types.HostMemory
for i := 0; true; i++ {
delay := 10
resources, err = hypervisor.CurrentHypervisor().GetHostCPUMem()
resources, err = CurrentHypervisor().GetHostCPUMem()

Check warning on line 559 in pkg/pillar/cmd/domainmgr/domainmgr.go

View check run for this annotation

Codecov / codecov/patch

pkg/pillar/cmd/domainmgr/domainmgr.go#L559

Added line #L559 was not covered by tests
if err == nil {
break
}
Expand Down Expand Up @@ -930,7 +944,7 @@
configActivate = true
}

domainID, domainStatus, err := hypervisor.CurrentHypervisor().Task(status).Info(status.DomainName)
domainID, domainStatus, err := CurrentHypervisor().Task(status).Info(status.DomainName)

Check warning on line 947 in pkg/pillar/cmd/domainmgr/domainmgr.go

View check run for this annotation

Codecov / codecov/patch

pkg/pillar/cmd/domainmgr/domainmgr.go#L947

Added line #L947 was not covered by tests
if err != nil || domainStatus == types.HALTED {
if status.Activated && configActivate {
if err == nil {
Expand Down Expand Up @@ -963,10 +977,10 @@
}

//cleanup app instance tasks
if err := hypervisor.CurrentHypervisor().Task(status).Delete(status.DomainName); err != nil {
if err := CurrentHypervisor().Task(status).Delete(status.DomainName); err != nil {

Check warning on line 980 in pkg/pillar/cmd/domainmgr/domainmgr.go

View check run for this annotation

Codecov / codecov/patch

pkg/pillar/cmd/domainmgr/domainmgr.go#L980

Added line #L980 was not covered by tests
log.Errorf("failed to delete domain: %s (%v)", status.DomainName, err)
}
if err := hypervisor.CurrentHypervisor().Task(status).Cleanup(status.DomainName); err != nil {
if err := CurrentHypervisor().Task(status).Cleanup(status.DomainName); err != nil {

Check warning on line 983 in pkg/pillar/cmd/domainmgr/domainmgr.go

View check run for this annotation

Codecov / codecov/patch

pkg/pillar/cmd/domainmgr/domainmgr.go#L983

Added line #L983 was not covered by tests
log.Errorf("failed to cleanup domain: %s (%v)", status.DomainName, err)
}
}
Expand Down Expand Up @@ -1104,7 +1118,7 @@
}
defer file.Close()

if err := hypervisor.CurrentHypervisor().Task(status).Setup(*status, *config, ctx.assignableAdapters, nil, file); err != nil {
if err := CurrentHypervisor().Task(status).Setup(*status, *config, ctx.assignableAdapters, nil, file); err != nil {

Check warning on line 1121 in pkg/pillar/cmd/domainmgr/domainmgr.go

View check run for this annotation

Codecov / codecov/patch

pkg/pillar/cmd/domainmgr/domainmgr.go#L1121

Added line #L1121 was not covered by tests
//it is retry, so omit error
log.Errorf("Failed to create DomainStatus from %v: %s",
config, err)
Expand Down Expand Up @@ -1383,14 +1397,14 @@

}
for i, long := range assignmentsPci {
err := hypervisor.CurrentHypervisor().PCIReserve(long)
err := CurrentHypervisor().PCIReserve(long)

Check warning on line 1400 in pkg/pillar/cmd/domainmgr/domainmgr.go

View check run for this annotation

Codecov / codecov/patch

pkg/pillar/cmd/domainmgr/domainmgr.go#L1400

Added line #L1400 was not covered by tests
if err != nil {
// Undo what we assigned
for j, long := range assignmentsPci {
if j >= i {
break
}
hypervisor.CurrentHypervisor().PCIRelease(long)
CurrentHypervisor().PCIRelease(long)

Check warning on line 1407 in pkg/pillar/cmd/domainmgr/domainmgr.go

View check run for this annotation

Codecov / codecov/patch

pkg/pillar/cmd/domainmgr/domainmgr.go#L1407

Added line #L1407 was not covered by tests
}
if publishAssignableAdapters {
ctx.publishAssignableAdapters()
Expand Down Expand Up @@ -1567,7 +1581,7 @@
defer file.Close()

globalConfig := agentlog.GetGlobalConfig(log, ctx.subGlobalConfig)
if err := hypervisor.CurrentHypervisor().Task(status).Setup(*status, config, ctx.assignableAdapters, globalConfig, file); err != nil {
if err := CurrentHypervisor().Task(status).Setup(*status, config, ctx.assignableAdapters, globalConfig, file); err != nil {

Check warning on line 1584 in pkg/pillar/cmd/domainmgr/domainmgr.go

View check run for this annotation

Codecov / codecov/patch

pkg/pillar/cmd/domainmgr/domainmgr.go#L1584

Added line #L1584 was not covered by tests
log.Errorf("Failed to create DomainStatus from %v: %s",
config, err)
status.SetErrorNow(err.Error())
Expand Down Expand Up @@ -1626,17 +1640,17 @@
status.State = types.BOOTING
publishDomainStatus(ctx, status)

err := hypervisor.CurrentHypervisor().Task(status).Start(status.DomainName)
err := CurrentHypervisor().Task(status).Start(status.DomainName)

Check warning on line 1643 in pkg/pillar/cmd/domainmgr/domainmgr.go

View check run for this annotation

Codecov / codecov/patch

pkg/pillar/cmd/domainmgr/domainmgr.go#L1643

Added line #L1643 was not covered by tests
if err != nil {
log.Errorf("domain start for %s: %s", status.DomainName, err)
status.SetErrorNow(err.Error())

// Delete
if err := hypervisor.CurrentHypervisor().Task(status).Delete(status.DomainName); err != nil {
if err := CurrentHypervisor().Task(status).Delete(status.DomainName); err != nil {

Check warning on line 1649 in pkg/pillar/cmd/domainmgr/domainmgr.go

View check run for this annotation

Codecov / codecov/patch

pkg/pillar/cmd/domainmgr/domainmgr.go#L1649

Added line #L1649 was not covered by tests
log.Errorf("failed to delete domain: %s (%v)", status.DomainName, err)
}
// Cleanup
if err := hypervisor.CurrentHypervisor().Task(status).Cleanup(status.DomainName); err != nil {
if err := CurrentHypervisor().Task(status).Cleanup(status.DomainName); err != nil {

Check warning on line 1653 in pkg/pillar/cmd/domainmgr/domainmgr.go

View check run for this annotation

Codecov / codecov/patch

pkg/pillar/cmd/domainmgr/domainmgr.go#L1653

Added line #L1653 was not covered by tests
log.Errorf("failed to cleanup domain: %s (%v)", status.DomainName, err)
}

Expand All @@ -1650,7 +1664,7 @@
status.VifList = checkIfEmu(status.VifList)

status.State = types.RUNNING
domainID, state, err := hypervisor.CurrentHypervisor().Task(status).Info(status.DomainName)
domainID, state, err := CurrentHypervisor().Task(status).Info(status.DomainName)

Check warning on line 1667 in pkg/pillar/cmd/domainmgr/domainmgr.go

View check run for this annotation

Codecov / codecov/patch

pkg/pillar/cmd/domainmgr/domainmgr.go#L1667

Added line #L1667 was not covered by tests

if err != nil {
// Immediate failure treat as above
Expand All @@ -1661,11 +1675,11 @@
log.Errorf("doActivateTail(%v) failed for %s: %s",
status.UUIDandVersion, status.DisplayName, err)
// Delete
if err := hypervisor.CurrentHypervisor().Task(status).Delete(status.DomainName); err != nil {
if err := CurrentHypervisor().Task(status).Delete(status.DomainName); err != nil {

Check warning on line 1678 in pkg/pillar/cmd/domainmgr/domainmgr.go

View check run for this annotation

Codecov / codecov/patch

pkg/pillar/cmd/domainmgr/domainmgr.go#L1678

Added line #L1678 was not covered by tests
log.Errorf("failed to delete domain: %s (%v)", status.DomainName, err)
}
// Cleanup
if err := hypervisor.CurrentHypervisor().Task(status).Cleanup(status.DomainName); err != nil {
if err := CurrentHypervisor().Task(status).Cleanup(status.DomainName); err != nil {

Check warning on line 1682 in pkg/pillar/cmd/domainmgr/domainmgr.go

View check run for this annotation

Codecov / codecov/patch

pkg/pillar/cmd/domainmgr/domainmgr.go#L1682

Added line #L1682 was not covered by tests
log.Errorf("failed to cleanup domain: %s (%v)", status.DomainName, err)
}
return
Expand Down Expand Up @@ -1710,7 +1724,7 @@

log.Functionf("doInactivate(%v) for %s domainId %d",
status.UUIDandVersion, status.DisplayName, status.DomainId)
domainID, _, err := hypervisor.CurrentHypervisor().Task(status).Info(status.DomainName)
domainID, _, err := CurrentHypervisor().Task(status).Info(status.DomainName)

Check warning on line 1727 in pkg/pillar/cmd/domainmgr/domainmgr.go

View check run for this annotation

Codecov / codecov/patch

pkg/pillar/cmd/domainmgr/domainmgr.go#L1727

Added line #L1727 was not covered by tests
if err == nil && domainID != status.DomainId {
status.DomainId = domainID
status.BootTime = time.Now()
Expand Down Expand Up @@ -1784,7 +1798,7 @@
}

if status.DomainId != 0 {
if err := hypervisor.CurrentHypervisor().Task(status).Delete(status.DomainName); err != nil {
if err := CurrentHypervisor().Task(status).Delete(status.DomainName); err != nil {

Check warning on line 1801 in pkg/pillar/cmd/domainmgr/domainmgr.go

View check run for this annotation

Codecov / codecov/patch

pkg/pillar/cmd/domainmgr/domainmgr.go#L1801

Added line #L1801 was not covered by tests
log.Errorf("Failed to delete domain %s (%v)", status.DomainName, err)
} else {
log.Functionf("doInactivate(%v) for %s: Delete succeeded",
Expand All @@ -1802,7 +1816,7 @@
}

func doCleanup(ctx *domainContext, status *types.DomainStatus) {
if err := hypervisor.CurrentHypervisor().Task(status).Cleanup(status.DomainName); err != nil {
if err := CurrentHypervisor().Task(status).Cleanup(status.DomainName); err != nil {

Check warning on line 1819 in pkg/pillar/cmd/domainmgr/domainmgr.go

View check run for this annotation

Codecov / codecov/patch

pkg/pillar/cmd/domainmgr/domainmgr.go#L1819

Added line #L1819 was not covered by tests
log.Errorf("failed to cleanup domain: %s (%v)", status.DomainName, err)
}

Expand Down Expand Up @@ -1906,7 +1920,7 @@
checkIoBundleAll(ctx)
}
for _, long := range assignments {
err := hypervisor.CurrentHypervisor().PCIRelease(long)
err := CurrentHypervisor().PCIRelease(long)

Check warning on line 1923 in pkg/pillar/cmd/domainmgr/domainmgr.go

View check run for this annotation

Codecov / codecov/patch

pkg/pillar/cmd/domainmgr/domainmgr.go#L1923

Added line #L1923 was not covered by tests
if err != nil && !ignoreErrors {
status.SetErrorNow(err.Error())
}
Expand Down Expand Up @@ -2275,7 +2289,7 @@
time.Sleep(delay)
waited += delay
}
_, state, err := hypervisor.CurrentHypervisor().Task(&status).Info(status.DomainName)
_, state, err := CurrentHypervisor().Task(&status).Info(status.DomainName)

Check warning on line 2292 in pkg/pillar/cmd/domainmgr/domainmgr.go

View check run for this annotation

Codecov / codecov/patch

pkg/pillar/cmd/domainmgr/domainmgr.go#L2292

Added line #L2292 was not covered by tests
if err != nil {
log.Errorf("waitForDomainGone(%v) for %s error %s state %s",
status.UUIDandVersion, status.DisplayName,
Expand Down Expand Up @@ -2363,7 +2377,7 @@
log.Errorf("DomainCreate(%s) no DomainConfig", status.Key())
return 0, fmt.Errorf("DomainCreate(%s) no DomainConfig", status.Key())
}
domainID, err = hypervisor.CurrentHypervisor().Task(&status).Create(status.DomainName, filename, config)
domainID, err = CurrentHypervisor().Task(&status).Create(status.DomainName, filename, config)

Check warning on line 2380 in pkg/pillar/cmd/domainmgr/domainmgr.go

View check run for this annotation

Codecov / codecov/patch

pkg/pillar/cmd/domainmgr/domainmgr.go#L2380

Added line #L2380 was not covered by tests

return domainID, err
}
Expand All @@ -2376,7 +2390,7 @@

// Stop the domain
log.Functionf("Stopping domain - %s", status.DomainName)
err = hypervisor.CurrentHypervisor().Task(&status).Stop(status.DomainName, force)
err = CurrentHypervisor().Task(&status).Stop(status.DomainName, force)

Check warning on line 2393 in pkg/pillar/cmd/domainmgr/domainmgr.go

View check run for this annotation

Codecov / codecov/patch

pkg/pillar/cmd/domainmgr/domainmgr.go#L2393

Added line #L2393 was not covered by tests

return err
}
Expand Down Expand Up @@ -2833,7 +2847,7 @@
len(aa.IoBundleList))

// check for mismatched PCI-ids and assignment groups and mark as errors
aa.CheckBadAssignmentGroups(log, hypervisor.CurrentHypervisor().PCISameController)
aa.CheckBadAssignmentGroups(log, CurrentHypervisor().PCISameController)

Check warning on line 2850 in pkg/pillar/cmd/domainmgr/domainmgr.go

View check run for this annotation

Codecov / codecov/patch

pkg/pillar/cmd/domainmgr/domainmgr.go#L2850

Added line #L2850 was not covered by tests
for i := range aa.IoBundleList {
ib := &aa.IoBundleList[i]
log.Functionf("handlePhysicalIOAdapterListImpl: new Adapter: %+v",
Expand Down Expand Up @@ -2878,7 +2892,7 @@
aa.AddOrUpdateIoBundle(log, *ib)

// check for mismatched PCI-ids and assignment groups and mark as errors
aa.CheckBadAssignmentGroups(log, hypervisor.CurrentHypervisor().PCISameController)
aa.CheckBadAssignmentGroups(log, CurrentHypervisor().PCISameController)

Check warning on line 2895 in pkg/pillar/cmd/domainmgr/domainmgr.go

View check run for this annotation

Codecov / codecov/patch

pkg/pillar/cmd/domainmgr/domainmgr.go#L2895

Added line #L2895 was not covered by tests
// Lookup since it could have changed
ib = aa.LookupIoBundlePhylabel(ib.Phylabel)
updatePortAndPciBackIoBundle(ctx, ib)
Expand Down Expand Up @@ -2979,7 +2993,7 @@
// expand list to include other PCI functions on the same PCI controller
// since they need to be treated as part of the same bundle even if the
// EVE controller doesn't know it
list = aa.ExpandControllers(log, list, hypervisor.CurrentHypervisor().PCISameController)
list = aa.ExpandControllers(log, list, CurrentHypervisor().PCISameController)

Check warning on line 2996 in pkg/pillar/cmd/domainmgr/domainmgr.go

View check run for this annotation

Codecov / codecov/patch

pkg/pillar/cmd/domainmgr/domainmgr.go#L2996

Added line #L2996 was not covered by tests
for _, ib := range list {
if types.IsPort(ctx.deviceNetworkStatus, ib.Ifname) {
isPort = true
Expand Down Expand Up @@ -3065,7 +3079,7 @@
if ib.PciLong != "" {
log.Functionf("updatePortAndPciBackIoMember: Removing %s (%s) from pciback",
ib.Phylabel, ib.PciLong)
err = hypervisor.CurrentHypervisor().PCIRelease(ib.PciLong)
err = CurrentHypervisor().PCIRelease(ib.PciLong)

Check warning on line 3082 in pkg/pillar/cmd/domainmgr/domainmgr.go

View check run for this annotation

Codecov / codecov/patch

pkg/pillar/cmd/domainmgr/domainmgr.go#L3082

Added line #L3082 was not covered by tests
if err != nil {
err = fmt.Errorf("adapter %s (group %s, type %d) PCI ID %s; not released by hypervisor: %v",
ib.Phylabel, ib.AssignmentGroup, ib.Type,
Expand Down Expand Up @@ -3112,7 +3126,7 @@
} else if ib.PciLong != "" && ib.UsbAddr == "" {
log.Noticef("Assigning %s (%s) to pciback",
ib.Phylabel, ib.PciLong)
err := hypervisor.CurrentHypervisor().PCIReserve(ib.PciLong)
err := CurrentHypervisor().PCIReserve(ib.PciLong)

Check warning on line 3129 in pkg/pillar/cmd/domainmgr/domainmgr.go

View check run for this annotation

Codecov / codecov/patch

pkg/pillar/cmd/domainmgr/domainmgr.go#L3129

Added line #L3129 was not covered by tests
if err != nil {
return changed, err
}
Expand Down Expand Up @@ -3353,7 +3367,7 @@
log.Functionf("handleIBDelete: Assigning %s (%s) back",
ib.Phylabel, ib.PciLong)
if ib.PciLong != "" {
err := hypervisor.CurrentHypervisor().PCIRelease(ib.PciLong)
err := CurrentHypervisor().PCIRelease(ib.PciLong)

Check warning on line 3370 in pkg/pillar/cmd/domainmgr/domainmgr.go

View check run for this annotation

Codecov / codecov/patch

pkg/pillar/cmd/domainmgr/domainmgr.go#L3370

Added line #L3370 was not covered by tests
if err != nil {
log.Errorf("handleIBDelete(%d %s %s) PCIRelease %s failed %v",
ib.Type, ib.Phylabel, ib.AssignmentGroup, ib.PciLong, err)
Expand Down
3 changes: 2 additions & 1 deletion pkg/pillar/cmd/usbmanager/usbmanager.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

"github.com/lf-edge/eve/pkg/pillar/agentbase"
"github.com/lf-edge/eve/pkg/pillar/base"
"github.com/lf-edge/eve/pkg/pillar/cmd/domainmgr"
"github.com/lf-edge/eve/pkg/pillar/hypervisor"
"github.com/lf-edge/eve/pkg/pillar/pubsub"
"github.com/lf-edge/eve/pkg/pillar/utils"
Expand Down Expand Up @@ -81,7 +82,7 @@
}
log.Functionf("processed Vault Status")

currentHypervisor := hypervisor.CurrentHypervisor()
currentHypervisor := domainmgr.CurrentHypervisor()

Check warning on line 85 in pkg/pillar/cmd/usbmanager/usbmanager.go

View check run for this annotation

Codecov / codecov/patch

pkg/pillar/cmd/usbmanager/usbmanager.go#L85

Added line #L85 was not covered by tests
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It probably makes sense to have this pick up and use the boot time hypervisor by parsing /run/eve-hv-type.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But let's do that in a separate PR.

_, ok := currentHypervisor.(hypervisor.KvmContext)
if ok {
usbCtx.subscribe(ps)
Expand Down
32 changes: 1 addition & 31 deletions pkg/pillar/hypervisor/hypervisor.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,44 +4,14 @@
package hypervisor

import (
"flag"
"fmt"
"log"
"os"

"github.com/lf-edge/eve/pkg/pillar/types"
fileutils "github.com/lf-edge/eve/pkg/pillar/utils/file"
"github.com/shirou/gopsutil/cpu"
"github.com/shirou/gopsutil/mem"
"github.com/sirupsen/logrus"
"os"
)

var currentHypervisor Hypervisor

func init() {
if fileutils.FileExists(nil, "/run/installer.log") {
// if this file exists it means we're running in the installer and we should not inititialize the containerd
// hypervisor as it interferes with the installer
return
}

var err error

flagSet := flag.NewFlagSet("", flag.ExitOnError)
allHypervisors, enabledHypervisors := GetAvailableHypervisors()
hypervisorPtr := flagSet.String("h", enabledHypervisors[0], fmt.Sprintf("Current hypervisor %+q", allHypervisors))

currentHypervisor, err = GetHypervisor(*hypervisorPtr)
if err != nil {
log.Fatal(err)
}
}

// CurrentHypervisor returns the current hypervisor
func CurrentHypervisor() Hypervisor {
return currentHypervisor
}

// Hypervisor provides methods for manipulating domains on the host
type Hypervisor interface {
Name() string
Expand Down
Loading