qemu: Fix virtio-net-pci QMP command

This patch fixes the wrong behavior of specifying a netdev, MAC
address or PCI address entry when those were empty. Instead, it
does not provide those entries if the content is empty.

Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
This commit is contained in:
Sebastien Boeuf 2018-10-16 13:20:55 -07:00
parent b1635d5dcb
commit 9c819db5a3

View File

@ -912,15 +912,21 @@ func (q *QMP) ExecuteNetPCIDeviceAdd(ctx context.Context, netdevID, devID, macAd
args := map[string]interface{}{ args := map[string]interface{}{
"id": devID, "id": devID,
"driver": VirtioNetPCI, "driver": VirtioNetPCI,
"netdev": netdevID,
"mac": macAddr,
"addr": addr,
"romfile": romfile, "romfile": romfile,
} }
if bus != "" { if bus != "" {
args["bus"] = bus args["bus"] = bus
} }
if addr != "" {
args["addr"] = addr
}
if macAddr != "" {
args["mac"] = macAddr
}
if netdevID != "" {
args["netdev"] = netdevID
}
if queues > 0 { if queues > 0 {
// (2N+2 vectors, N for tx queues, N for rx queues, 1 for config, and one for possible control vq) // (2N+2 vectors, N for tx queues, N for rx queues, 1 for config, and one for possible control vq)