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 1 commit 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?

vm/vmimpl/console.go Outdated Show resolved Hide resolved
vm/adb/adb.go Outdated Show resolved Hide resolved
vm/adb/adb.go Outdated Show resolved Hide resolved
@jiangenj jiangenj force-pushed the consolecmd branch 2 times, most recently from 19cf8f5 to 30cf4f4 Compare January 24, 2025 07:25
- Sometimes we need customized cmd to get serial log, ex FTDI4232H
chip gets serial log through usb directly, thus we need to call
cmd like `pyterm.py ftdi://ftdi:4232:FT7JLD0U/1`.
- There are seveval places in console implementation to call
osutil.Command, move the command code into one function.
Copy link
Collaborator

@a-nogikh a-nogikh left a comment

Choose a reason for hiding this comment

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

Now it looks much better, thanks.

if inst.console == "" {
if inst.console != "" {
log.Logf(0, "associating adb device %v with console %v", inst.device, inst.console)
} else if inst.consoleCmd != nil {
Copy link
Collaborator

Choose a reason for hiding this comment

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

len(inst.consoleCmd) > 0

}

// Open console log by cmd.
func OpenConsoleByCmd(args []string) (rc io.ReadCloser, 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.

Let's make it OpenConsoleByCmd(bin string, args []string)

cmd := osutil.Command("ssh", conAddr, "tail", "-f", console)
cmd.Stdout = wpipe
cmd.Stderr = wpipe
if _, err := cmd.StdinPipe(); err != nil {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why did you drop this part?

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