aboutsummaryrefslogtreecommitdiffstats
path: root/vm
diff options
context:
space:
mode:
authorLaura Peskin <pesk@google.com>2025-06-18 16:25:53 -0700
committerglpesk <114444708+glpesk@users.noreply.github.com>2025-07-22 22:06:08 +0000
commite1dd4f22ed632d9954196b3727a41db69b93ed67 (patch)
tree79e2864a9279247b0b8d0885ebb5b23fc74482e1 /vm
parentf3762ee614bce38772288104d514e80d779996da (diff)
vm/starnix: get path for ffx log binary
ffx log is now built separately from the main ffx binary.
Diffstat (limited to 'vm')
-rw-r--r--vm/starnix/starnix.go60
1 files changed, 36 insertions, 24 deletions
diff --git a/vm/starnix/starnix.go b/vm/starnix/starnix.go
index 98d44d3ff..9b478735d 100644
--- a/vm/starnix/starnix.go
+++ b/vm/starnix/starnix.go
@@ -46,25 +46,26 @@ type Pool struct {
}
type instance struct {
- fuchsiaDir string
- ffxBinary string
- ffxDir string
- name string
- index int
- cfg *Config
- version string
- debug bool
- workdir string
- port int
- forwardPort int
- rpipe io.ReadCloser
- wpipe io.WriteCloser
- fuchsiaLogs *exec.Cmd
- sshBridge *exec.Cmd
- sshPubKey string
- sshPrivKey string
- merger *vmimpl.OutputMerger
- timeouts targets.Timeouts
+ fuchsiaDir string
+ ffxBinary string
+ ffxLogBinary string
+ ffxDir string
+ name string
+ index int
+ cfg *Config
+ version string
+ debug bool
+ workdir string
+ port int
+ forwardPort int
+ rpipe io.ReadCloser
+ wpipe io.WriteCloser
+ fuchsiaLogs *exec.Cmd
+ sshBridge *exec.Cmd
+ sshPubKey string
+ sshPrivKey string
+ merger *vmimpl.OutputMerger
+ timeouts targets.Timeouts
}
const targetDir = "/tmp"
@@ -122,6 +123,10 @@ func (pool *Pool) Create(workdir string, index int) (vmimpl.Instance, error) {
if err != nil {
return nil, err
}
+ inst.ffxLogBinary, err = GetToolPath(inst.fuchsiaDir, "ffx-log")
+ if err != nil {
+ return nil, err
+ }
inst.rpipe, inst.wpipe, err = osutil.LongPipe()
if err != nil {
@@ -240,14 +245,20 @@ func (inst *instance) startFuchsiaLogs() error {
// only request logs from now on.
cmd := inst.ffxCommand(
true,
- "--target", inst.name,
- "log", "--since", "now",
+ inst.ffxLogBinary,
+ "--target", inst.name, "log", "--since", "now",
"--show-metadata", "--show-full-moniker", "--no-color",
"--exclude-tags", "netlink")
cmd.Stdout = inst.wpipe
cmd.Stderr = inst.wpipe
inst.merger.Add("fuchsia", inst.rpipe)
+ if inst.debug {
+ log.Logf(1, "instance %s: starting ffx log", inst.name)
+ }
if err := cmd.Start(); err != nil {
+ if inst.debug {
+ log.Logf(0, "instance %s: failed to start ffx log", inst.name)
+ }
return err
}
inst.fuchsiaLogs = cmd
@@ -345,13 +356,13 @@ func (inst *instance) connect() error {
return nil
}
-func (inst *instance) ffxCommand(isolated bool, args ...string) *exec.Cmd {
+func (inst *instance) ffxCommand(isolated bool, binary string, args ...string) *exec.Cmd {
config := []string{"-c", "log.enabled=false,ffx.analytics.disabled=true"}
if !isolated {
config = append(config, "-c", "daemon.autostart=false")
}
args = slices.Concat(config, args)
- cmd := osutil.Command(inst.ffxBinary, args...)
+ cmd := osutil.Command(binary, args...)
cmd.Dir = inst.fuchsiaDir
cmd.Env = append(cmd.Environ(), "FUCHSIA_ANALYTICS_DISABLED=1")
if isolated {
@@ -368,7 +379,8 @@ func (inst *instance) runFfx(timeout time.Duration, isolated bool, args ...strin
}
log.Logf(1, "instance %s: running ffx %s isolation: %q", inst.name, isolation, args)
}
- cmd := inst.ffxCommand(isolated, args...)
+
+ cmd := inst.ffxCommand(isolated, inst.ffxBinary, args...)
cmd.Stderr = os.Stderr
output, err := osutil.Run(timeout, cmd)
if inst.debug {