mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-06-09 07:24:44 +00:00
vhost-user: updating comments for accuracy, rename device field
Some comments were network specific for vhost-user devices, which is incorect. Fixed these. Renamed the HWAddress field to be Address, so that it could potentially be used more generically for non-network based vhost-user types. Signed-off-by: Eric Ernst <eric.ernst@intel.com>
This commit is contained in:
parent
425b3629c7
commit
e9e27673fa
14
qemu/qemu.go
14
qemu/qemu.go
@ -704,7 +704,7 @@ func (blkdev BlockDevice) QemuParams(config *Config) []string {
|
|||||||
return qemuParams
|
return qemuParams
|
||||||
}
|
}
|
||||||
|
|
||||||
// VhostUserDeviceType is a qemu networking device type.
|
// VhostUserDeviceType is a qemu vhost-user device type.
|
||||||
type VhostUserDeviceType string
|
type VhostUserDeviceType string
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -714,21 +714,21 @@ const (
|
|||||||
VhostUserNet = "virtio-net-pci"
|
VhostUserNet = "virtio-net-pci"
|
||||||
)
|
)
|
||||||
|
|
||||||
// VhostUserDevice represents a qemu vhost-user network device meant to be passed
|
// VhostUserDevice represents a qemu vhost-user device meant to be passed
|
||||||
// in to the guest
|
// in to the guest
|
||||||
type VhostUserDevice struct {
|
type VhostUserDevice struct {
|
||||||
SocketPath string //path to vhostuser socket on host
|
SocketPath string //path to vhostuser socket on host
|
||||||
CharDevID string
|
CharDevID string
|
||||||
TypeDevID string //id (SCSI) or netdev (net) device parameter
|
TypeDevID string //variable QEMU parameter based on value of VhostUserType
|
||||||
MacAddress string //only valid if device type is VhostUserNet
|
Address string //used for MAC address in net case
|
||||||
VhostUserType VhostUserDeviceType
|
VhostUserType VhostUserDeviceType
|
||||||
}
|
}
|
||||||
|
|
||||||
// Valid returns true if there is a valid socket path defined for VhostUserDevice
|
// Valid returns true if there is a valid structure defined for VhostUserDevice
|
||||||
func (vhostuserDev VhostUserDevice) Valid() bool {
|
func (vhostuserDev VhostUserDevice) Valid() bool {
|
||||||
if vhostuserDev.SocketPath == "" || vhostuserDev.CharDevID == "" ||
|
if vhostuserDev.SocketPath == "" || vhostuserDev.CharDevID == "" ||
|
||||||
vhostuserDev.TypeDevID == "" ||
|
vhostuserDev.TypeDevID == "" ||
|
||||||
(vhostuserDev.VhostUserType == VhostUserNet && vhostuserDev.MacAddress == "") {
|
(vhostuserDev.VhostUserType == VhostUserNet && vhostuserDev.Address == "") {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -755,7 +755,7 @@ func (vhostuserDev VhostUserDevice) QemuParams(config *Config) []string {
|
|||||||
|
|
||||||
devParams = append(devParams, VhostUserNet)
|
devParams = append(devParams, VhostUserNet)
|
||||||
devParams = append(devParams, fmt.Sprintf("netdev=%s", vhostuserDev.TypeDevID))
|
devParams = append(devParams, fmt.Sprintf("netdev=%s", vhostuserDev.TypeDevID))
|
||||||
devParams = append(devParams, fmt.Sprintf("mac=%s", vhostuserDev.MacAddress))
|
devParams = append(devParams, fmt.Sprintf("mac=%s", vhostuserDev.Address))
|
||||||
} else {
|
} else {
|
||||||
devParams = append(devParams, VhostUserSCSI)
|
devParams = append(devParams, VhostUserSCSI)
|
||||||
devParams = append(devParams, fmt.Sprintf("id=%s", vhostuserDev.TypeDevID))
|
devParams = append(devParams, fmt.Sprintf("id=%s", vhostuserDev.TypeDevID))
|
||||||
|
@ -273,7 +273,7 @@ func TestAppendDeviceVhostUser(t *testing.T) {
|
|||||||
SocketPath: "/tmp/nonexistentsocket.socket",
|
SocketPath: "/tmp/nonexistentsocket.socket",
|
||||||
CharDevID: "char1",
|
CharDevID: "char1",
|
||||||
TypeDevID: "scsi1",
|
TypeDevID: "scsi1",
|
||||||
MacAddress: "",
|
Address: "",
|
||||||
VhostUserType: VhostUserSCSI,
|
VhostUserType: VhostUserSCSI,
|
||||||
}
|
}
|
||||||
testAppend(vhostuserSCSIDevice, deviceVhostUserSCSIString, t)
|
testAppend(vhostuserSCSIDevice, deviceVhostUserSCSIString, t)
|
||||||
@ -282,7 +282,7 @@ func TestAppendDeviceVhostUser(t *testing.T) {
|
|||||||
SocketPath: "/tmp/nonexistentsocket.socket",
|
SocketPath: "/tmp/nonexistentsocket.socket",
|
||||||
CharDevID: "char1",
|
CharDevID: "char1",
|
||||||
TypeDevID: "net1",
|
TypeDevID: "net1",
|
||||||
MacAddress: "00:11:22:33:44:55",
|
Address: "00:11:22:33:44:55",
|
||||||
VhostUserType: VhostUserNet,
|
VhostUserType: VhostUserNet,
|
||||||
}
|
}
|
||||||
testAppend(vhostuserNetDevice, deviceVhostUserNetString, t)
|
testAppend(vhostuserNetDevice, deviceVhostUserNetString, t)
|
||||||
|
Loading…
Reference in New Issue
Block a user