Skip to content

Commit

Permalink
isolated device manager:
Browse files Browse the repository at this point in the history
- fix find boot_vga got No such file or dirtory
  • Loading branch information
wanyaoqi committed Jun 3, 2020
1 parent 7873fa5 commit 44cbdd0
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
4 changes: 3 additions & 1 deletion pkg/hostman/hostinfo/hostinfo.go
Original file line number Diff line number Diff line change
Expand Up @@ -1337,7 +1337,9 @@ func (h *SHostInfo) getIsolatedDevices() {
func (h *SHostInfo) onGetIsolatedDeviceSucc(objs []jsonutils.JSONObject) {
for _, obj := range objs {
info := isolated_device.CloudDeviceInfo{}
obj.Unmarshal(&info)
if err := obj.Unmarshal(&info); err != nil {
h.onFail(fmt.Sprintf("unmarshal isolated device to cloud device info failed %s", err))
}
dev := h.IsolatedDeviceMan.GetDeviceByIdent(info.VendorDeviceId, info.Addr)
if dev != nil {
dev.SetDeviceInfo(info)
Expand Down
15 changes: 13 additions & 2 deletions pkg/hostman/isolated_device/isolated_device.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@ package isolated_device
import (
"fmt"
"os"
"os/exec"
"path/filepath"
"strings"
"syscall"
"time"

"yunion.io/x/jsonutils"
Expand Down Expand Up @@ -537,11 +539,20 @@ func (d *PCIDevice) IsBootVGA() (bool, error) {
addr := d.Addr
output, err := procutils.NewCommand("find", "/sys/devices", "-name", "boot_vga").Output()
if err != nil {
return false, err
if exiterr, ok := err.(*exec.ExitError); ok {
if code, ok := exiterr.Sys().(syscall.WaitStatus); ok &&
code.ExitStatus() == 1 && strings.Contains(string(output), "No such file or directory") {
log.Warningf("find boot vga %s", output)
} else {
return false, err
}
} else {
return false, err
}
}
paths := ParseOutput(output)
for _, p := range paths {
if strings.Contains(p, addr) {
if strings.Contains(p, addr) && !strings.Contains(p, "No such file or directory") {
if content, err := fileutils2.FileGetContents(p); err != nil {
return false, err
} else {
Expand Down

0 comments on commit 44cbdd0

Please sign in to comment.