mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-06-30 09:13:29 +00:00
qemu: throw error when fail to get addr from bridges
Return error soon when addDeviceToBridge() can not get empty address from bridges, or the error will thrown by qemu, this is not obvious. Fixes: #1005 Signed-off-by: Ace-Tang <aceapril@126.com>
This commit is contained in:
parent
7ff18192a4
commit
c7ace4b4bc
@ -8,6 +8,7 @@ package virtcontainers
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"math"
|
"math"
|
||||||
@ -755,6 +756,10 @@ func (q *qemu) addDeviceToBridge(ID string) (string, types.PCIBridge, error) {
|
|||||||
var err error
|
var err error
|
||||||
var addr uint32
|
var addr uint32
|
||||||
|
|
||||||
|
if len(q.state.Bridges) == 0 {
|
||||||
|
return "", types.PCIBridge{}, errors.New("failed to get available address from bridges")
|
||||||
|
}
|
||||||
|
|
||||||
// looking for an empty address in the bridges
|
// looking for an empty address in the bridges
|
||||||
for _, b := range q.state.Bridges {
|
for _, b := range q.state.Bridges {
|
||||||
addr, err = b.AddDevice(ID)
|
addr, err = b.AddDevice(ID)
|
||||||
|
Loading…
Reference in New Issue
Block a user