mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-08-13 13:46:46 +00:00
Merge pull request #71 from alicefr/vsock_cid
qemu: change Context ID for Vsock to uint64
This commit is contained in:
commit
7efe742ea8
@ -1014,7 +1014,7 @@ func (bridgeDev BridgeDevice) QemuParams(config *Config) []string {
|
|||||||
type VSOCKDevice struct {
|
type VSOCKDevice struct {
|
||||||
ID string
|
ID string
|
||||||
|
|
||||||
ContextID uint32
|
ContextID uint64
|
||||||
|
|
||||||
// VHostFD vhost file descriptor that holds the ContextID
|
// VHostFD vhost file descriptor that holds the ContextID
|
||||||
VHostFD *os.File
|
VHostFD *os.File
|
||||||
@ -1028,7 +1028,10 @@ type VSOCKDevice struct {
|
|||||||
|
|
||||||
const (
|
const (
|
||||||
// MinimalGuestCID is the smallest valid context ID for a guest.
|
// MinimalGuestCID is the smallest valid context ID for a guest.
|
||||||
MinimalGuestCID uint32 = 3
|
MinimalGuestCID uint64 = 3
|
||||||
|
|
||||||
|
// MaxGuestCID is the largest valid context ID for a guest.
|
||||||
|
MaxGuestCID uint64 = 1<<32 - 1
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -1038,7 +1041,7 @@ const (
|
|||||||
|
|
||||||
// Valid returns true if the VSOCKDevice structure is valid and complete.
|
// Valid returns true if the VSOCKDevice structure is valid and complete.
|
||||||
func (vsock VSOCKDevice) Valid() bool {
|
func (vsock VSOCKDevice) Valid() bool {
|
||||||
if vsock.ID == "" || vsock.ContextID < MinimalGuestCID {
|
if vsock.ID == "" || vsock.ContextID < MinimalGuestCID || vsock.ContextID > MaxGuestCID {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -312,6 +312,12 @@ func TestVSOCKValid(t *testing.T) {
|
|||||||
t.Fatalf("VSOCK Context ID is not valid")
|
t.Fatalf("VSOCK Context ID is not valid")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
vsockDevice.ContextID = MaxGuestCID + 1
|
||||||
|
|
||||||
|
if vsockDevice.Valid() {
|
||||||
|
t.Fatalf("VSOCK Context ID is not valid")
|
||||||
|
}
|
||||||
|
|
||||||
vsockDevice.ID = ""
|
vsockDevice.ID = ""
|
||||||
|
|
||||||
if vsockDevice.Valid() {
|
if vsockDevice.Valid() {
|
||||||
|
Loading…
Reference in New Issue
Block a user