vendor: update govmm to be compatible with qemu 2.8

govmm has ExecuteBlockdevAdd() function and ExecuteBlockdevDel() function
doesn't compatible with qemu 2.8,because blockdev-add and x-blockdev-del usages
are different between qemu 2.7 and qemu 2.8

shortlog:

ce070d1 govmm: modify govmm to be compatible with qemu 2.8
0286ff9 qemu/qmp: support hotplug a nic whose qdisc is mq
8515ae4 qmp: Remind users that you must first call ExecuteQMPCapabilities()
21504d3 qemu/qmp: Add netdev_add with chardev support
ed34f61 Add some negative test cases for qmp.go
17cacc7 Add negative test cases for qemu.go

fixes: #637

Signed-off-by: flyflypeng <jiangpengfei9@huawei.com>
This commit is contained in:
flyflypeng 2018-08-25 22:01:16 +08:00
parent cc29b8d4b6
commit f841e89dc7
3 changed files with 45 additions and 6 deletions

5
Gopkg.lock generated
View File

@ -115,11 +115,11 @@
revision = "3520598351bb3500a49ae9563f5539666ae0a27c"
[[projects]]
digest = "1:e35245b8aac4b53c6dd7b161c8c19f038e2ad29a54a03d276a88f3fc2a656c29"
digest = "1:052c0d6d677c7a3f12d8f83e0a1ce20a896cc206782b035f380249d23bf1265d"
name = "github.com/intel/govmm"
packages = ["qemu"]
pruneopts = "NUT"
revision = "d8f80cafe3ee3bba440a9ff8d234817b64a30b07"
revision = "1a16b5f98f133796f9c5e9b6ae3aa6d786cff9b1"
[[projects]]
digest = "1:55460fbdfca464360cec902b0805126451908aa1a058fe4072b01650ebe768b3"
@ -405,6 +405,7 @@
"github.com/opencontainers/runc/libcontainer/utils",
"github.com/opencontainers/runtime-spec/specs-go",
"github.com/opentracing/opentracing-go",
"github.com/opentracing/opentracing-go/log",
"github.com/safchain/ethtool",
"github.com/sirupsen/logrus",
"github.com/sirupsen/logrus/hooks/syslog",

View File

@ -52,7 +52,7 @@
[[constraint]]
name = "github.com/intel/govmm"
revision = "d8f80cafe3ee3bba440a9ff8d234817b64a30b07"
revision = "1a16b5f98f133796f9c5e9b6ae3aa6d786cff9b1"
[[constraint]]
name = "github.com/kata-containers/agent"

View File

@ -561,6 +561,10 @@ func (q *QMP) executeCommand(ctx context.Context, name string, args map[string]i
// block until they have received a success or failure message from QMP,
// i.e., {"return": {}} or {"error":{}}, and in some cases certain events
// are received.
//
// QEMU currently requires that the "qmp_capabilties" command is sent before any
// other command. Therefore you must call qmp.ExecuteQMPCapabilities() before
// you execute any other command.
func QMPStart(ctx context.Context, socket string, cfg QMPConfig, disconnectedCh chan struct{}) (*QMP, *QMPVersion, error) {
if cfg.Logger == nil {
cfg.Logger = qmpNullLogger{}
@ -653,7 +657,7 @@ func (q *QMP) ExecuteBlockdevAdd(ctx context.Context, device, blockdevID string)
},
}
if q.version.Major > 2 || (q.version.Major == 2 && q.version.Minor >= 9) {
if q.version.Major > 2 || (q.version.Major == 2 && q.version.Minor >= 8) {
blockdevArgs["node-name"] = blockdevID
args = blockdevArgs
} else {
@ -742,7 +746,12 @@ func (q *QMP) ExecuteBlockdevDel(ctx context.Context, blockdevID string) error {
return q.executeCommand(ctx, "blockdev-del", args, nil)
}
args["id"] = blockdevID
if q.version.Major == 2 && q.version.Minor == 8 {
args["node-name"] = blockdevID
} else {
args["id"] = blockdevID
}
return q.executeCommand(ctx, "x-blockdev-del", args, nil)
}
@ -764,6 +773,22 @@ func (q *QMP) ExecuteNetdevAdd(ctx context.Context, netdevType, netdevID, ifname
return q.executeCommand(ctx, "netdev_add", args, nil)
}
// ExecuteNetdevChardevAdd adds a Net device to a QEMU instance
// using the netdev_add command. netdevID is the id of the device to add.
// Must be valid QMP identifier.
func (q *QMP) ExecuteNetdevChardevAdd(ctx context.Context, netdevType, netdevID, chardev string, queues int) error {
args := map[string]interface{}{
"type": netdevType,
"id": netdevID,
"chardev": chardev,
}
if queues > 1 {
args["queues"] = queues
}
return q.executeCommand(ctx, "netdev_add", args, nil)
}
// ExecuteNetdevAddByFds adds a Net device to a QEMU instance
// using the netdev_add command by fds and vhostfds. netdevID is the id of the device to add.
// Must be valid QMP identifier.
@ -793,7 +818,8 @@ func (q *QMP) ExecuteNetdevDel(ctx context.Context, netdevID string) error {
// ExecuteNetPCIDeviceAdd adds a Net PCI device to a QEMU instance
// using the device_add command. devID is the id of the device to add.
// Must be valid QMP identifier. netdevID is the id of nic added by previous netdev_add.
func (q *QMP) ExecuteNetPCIDeviceAdd(ctx context.Context, netdevID, devID, macAddr, addr, bus string) error {
// queues is the number of queues of a nic.
func (q *QMP) ExecuteNetPCIDeviceAdd(ctx context.Context, netdevID, devID, macAddr, addr, bus string, queues int) error {
args := map[string]interface{}{
"id": devID,
"driver": VirtioNetPCI,
@ -805,6 +831,18 @@ func (q *QMP) ExecuteNetPCIDeviceAdd(ctx context.Context, netdevID, devID, macAd
if bus != "" {
args["bus"] = bus
}
if queues > 0 {
// (2N+2 vectors, N for tx queues, N for rx queues, 1 for config, and one for possible control vq)
// -device virtio-net-pci,mq=on,vectors=2N+2...
// enable mq in guest by 'ethtool -L eth0 combined $queue_num'
// Clearlinux automatically sets up the queues properly
// The agent implementation should do this to ensure that it is
// always set
args["mq"] = "on"
args["vectors"] = 2*queues + 2
}
return q.executeCommand(ctx, "device_add", args, nil)
}