Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vm: support console_cmd to run cmd to collect console log #5677

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

jiangenj
Copy link
Contributor


Before sending a pull request, please review Contribution Guidelines:
https://github.com/google/syzkaller/blob/master/docs/contributing.md


@a-nogikh
Copy link
Collaborator

Hi Joey!
Could you please share some more context re. this pull request? In what cases will the new parameter be helpful and what could be some practical examples of console_cmd values?

@jiangenj
Copy link
Contributor Author

Hi Joey! Could you please share some more context re. this pull request? In what cases will the new parameter be helpful and what could be some practical examples of console_cmd values?

Hi Alex,
In our case, we are using FTDI chip which hasn't exported /dev/ttyUSBx like serial port, the serial log needs to be pulled directly from usb. For example, we are using pyterm.py ftdi://ftdi:4232:FT7JLD0U/1 to get the serial log where pyterm.py is operating on libusb library to communicate with FTDI chip directly.
The default OpenConsole doesn't work since the absence of /dev/ttyUSBx device.

The console_cmd is to run this pyterm.py ftdi://ftdi:4232:FT7JLD0U/1 cmd which will output the serial log.

@tarasmadan
Copy link
Collaborator

I would propose to run this command externally and redirect its output to the pipe. Syzkaller may read that pipe instead of command spawning.

@jiangenj
Copy link
Contributor Author

I would propose to run this command externally and redirect its output to the pipe. Syzkaller may read that pipe instead of command spawning.

How to?

@@ -134,6 +135,25 @@ func OpenAdbConsole(bin, dev string) (rc io.ReadCloser, err error) {
return OpenRemoteConsole(bin, "-s", dev, "shell")
}

// Open console log by cmd.
func OpenConsoleByCmd(cmdline string) (rc io.ReadCloser, cmd *exec.Cmd, err error) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please note that other similar methods don't return exec.Cmd explicitly -- the process is killed once rc.Close() is called. There's no reason not to follow the approach here as well.

Console string `json:"console"` // console device name (e.g. "/dev/pts/0")
Serial string `json:"serial"` // device serial to connect
Console string `json:"console"` // console device name (e.g. "/dev/pts/0")
ConsoleCmd string `json:"console_cmd"` // command to obtain device console log
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: you could also make it []string to prevent the need to split by the whitespace (which won't work correctly if you need to pass e.g. strings).

@@ -149,10 +152,15 @@ func (pool *Pool) Create(workdir string, index int) (vmimpl.Instance, error) {
if err := inst.repair(); err != nil {
return nil, err
}
if inst.console == "" {
if inst.console == "" && inst.consoleCmd == "" {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if inst.console != "" {
// ...
} else if inst.consoleCmd != "" {
// ...
} else {
// ...
}

would be more readable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants