-
Notifications
You must be signed in to change notification settings - Fork 100
qemu/qmp: implement function for hotplug network #24
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -727,6 +727,51 @@ func (q *QMP) ExecuteBlockdevDel(ctx context.Context, blockdevID string) error { | |
return q.executeCommand(ctx, "x-blockdev-del", args, nil) | ||
} | ||
|
||
// ExecuteNetdevAdd 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) ExecuteNetdevAdd(ctx context.Context, netdevType, netdevID, ifname, downscript, script string, queues int) error { | ||
args := map[string]interface{}{ | ||
"type": netdevType, | ||
"id": netdevID, | ||
"ifname": ifname, | ||
"downscript": downscript, | ||
"script": script, | ||
} | ||
if queues > 1 { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This comment comes a little late but I just wanted to confirm that there's no need to ever explicitly set args["queues"] = 1 and that this is essentially the default. I had a quick check of the qemu manual but I was unable to confirm this for netdev. |
||
args["queues"] = queues | ||
} | ||
|
||
return q.executeCommand(ctx, "netdev_add", args, nil) | ||
} | ||
|
||
// ExecuteNetdevDel deletes a Net device from a QEMU instance | ||
// using the netdev_del command. netdevID is the id of the device to delete. | ||
func (q *QMP) ExecuteNetdevDel(ctx context.Context, netdevID string) error { | ||
args := map[string]interface{}{ | ||
"id": netdevID, | ||
} | ||
return q.executeCommand(ctx, "netdev_del", args, nil) | ||
} | ||
|
||
// 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 { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would you please add UT for ExecuteNetPCIDeviceAdd() as well? So that we can get rid of the codecov drop. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Check is passed. I will add it. |
||
args := map[string]interface{}{ | ||
"id": devID, | ||
"driver": VirtioNetPCI, | ||
"netdev": netdevID, | ||
"mac": macAddr, | ||
"addr": addr, | ||
} | ||
|
||
if bus != "" { | ||
args["bus"] = bus | ||
} | ||
return q.executeCommand(ctx, "device_add", args, nil) | ||
} | ||
|
||
// ExecuteDeviceDel deletes guest portion of a QEMU device by sending a | ||
// device_del command. devId is the identifier of the device to delete. | ||
// Typically it would match the devID parameter passed to an earlier call | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any reason
script
is not exposed butdownscript
is? In kata containers, I think we will always set them to "no" but if we expose one of them, we'd better expose the other too.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"script" is in the next line 739
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sorry I thought I deleted that line of comment but somehow it still appeared there...