mirror of
https://github.com/aljazceru/kata-containers.git
synced 2025-12-26 02:24:21 +01: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:
@@ -8,6 +8,7 @@ package virtcontainers
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"math"
|
||||
@@ -755,6 +756,10 @@ func (q *qemu) addDeviceToBridge(ID string) (string, types.PCIBridge, error) {
|
||||
var err error
|
||||
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
|
||||
for _, b := range q.state.Bridges {
|
||||
addr, err = b.AddDevice(ID)
|
||||
|
||||
Reference in New Issue
Block a user