This repository was archived by the owner on Jan 20, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 94
qemu/qmp: implement functions to hotplug chardevs and serial ports #31
Merged
markdryan
merged 2 commits into
kata-containers:master
from
devimc:topic/virtserialportHotplug
Aug 6, 2018
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -963,3 +963,40 @@ func (q *QMP) ExecuteGetFD(ctx context.Context, fdname string, fd *os.File) erro | |
| _, err := q.executeCommandWithResponse(ctx, "getfd", args, oob, nil) | ||
| return err | ||
| } | ||
|
|
||
| // ExecuteCharDevUnixSocketAdd adds a character device using as backend a unix socket, | ||
| // id is an identifier for the device, path specifies the local path of the unix socket, | ||
| // wait is to block waiting for a client to connect, server specifies that the socket is a listening socket. | ||
| func (q *QMP) ExecuteCharDevUnixSocketAdd(ctx context.Context, id, path string, wait, server bool) error { | ||
| args := map[string]interface{}{ | ||
| "id": id, | ||
| "backend": map[string]interface{}{ | ||
| "type": "socket", | ||
| "data": map[string]interface{}{ | ||
| "wait": wait, | ||
| "server": server, | ||
| "addr": map[string]interface{}{ | ||
| "type": "unix", | ||
| "data": map[string]interface{}{ | ||
| "path": path, | ||
| }, | ||
| }, | ||
| }, | ||
| }, | ||
| } | ||
| return q.executeCommand(ctx, "chardev-add", args, nil) | ||
| } | ||
|
|
||
| // ExecuteVirtSerialPortAdd adds a virtserialport. | ||
| // id is an identifier for the virtserialport, name is a name for the virtserialport and | ||
| // it will be visible in the VM, chardev is the character device id previously added. | ||
| func (q *QMP) ExecuteVirtSerialPortAdd(ctx context.Context, id, name, chardev string) error { | ||
| args := map[string]interface{}{ | ||
| "driver": VirtioSerialPort, | ||
| "id": id, | ||
| "name": name, | ||
| "chardev": chardev, | ||
|
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. In other parts of the code, where a parameter is optional, we usually only store it in the map if it is defined, e.g., https://github.com/intel/govmm/pull/31/files#diff-3f8ad3b51588f02283eda2d19c5ffd06R912. Should we do this here? 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. sorry nop, I'll remove the comment |
||
| } | ||
|
|
||
| return q.executeCommand(ctx, "device_add", args, nil) | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
That's a lot of indentation here. I bet this is what's expected by the JSON syntax from QMP, right ?
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.
right