{"record":{"id":"9353ac725f455e9e","repo":"hashicorp/nomad","slug":"qemu-driver-can-t-execute-commands","errorCode":null,"errorMessage":"QEMU driver can't execute commands","messagePattern":"QEMU driver can't execute commands","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"drivers/qemu/driver.go","lineNumber":814,"sourceCode":"func (d *Driver) TaskStats(ctx context.Context, taskID string, interval time.Duration) (<-chan *drivers.TaskResourceUsage, error) {\n\thandle, ok := d.tasks.Get(taskID)\n\tif !ok {\n\t\treturn nil, drivers.ErrTaskNotFound\n\t}\n\n\treturn handle.exec.Stats(ctx, interval)\n}\n\nfunc (d *Driver) TaskEvents(ctx context.Context) (<-chan *drivers.TaskEvent, error) {\n\treturn d.eventer.TaskEvents(ctx)\n}\n\nfunc (d *Driver) SignalTask(_ string, _ string) error {\n\treturn fmt.Errorf(\"QEMU driver can't signal commands\")\n}\n\nfunc (d *Driver) ExecTask(_ string, _ []string, _ time.Duration) (*drivers.ExecTaskResult, error) {\n\treturn nil, fmt.Errorf(\"QEMU driver can't execute commands\")\n\n}\n\n// GetAbsolutePath returns the absolute path of the passed binary by resolving\n// it in the path and following symlinks.\nfunc GetAbsolutePath(bin string) (string, error) {\n\tlp, err := exec.LookPath(bin)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"failed to resolve path to %q executable: %v\", bin, err)\n\t}\n\n\treturn filepath.EvalSymlinks(lp)\n}\n\nfunc (d *Driver) handleWait(ctx context.Context, handle *taskHandle, ch chan *drivers.ExitResult) {\n\tdefer close(ch)\n\tvar result *drivers.ExitResult\n\tps, err := handle.exec.Wait(ctx)","sourceCodeStart":796,"sourceCodeEnd":832,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/drivers/qemu/driver.go#L796-L832","documentation":"Unconditional error from the QEMU driver's ExecTask: commands cannot be executed inside a QEMU-started virtual machine, so any exec request against a QEMU task always fails.","triggerScenarios":"Calling Driver.ExecTask(taskID, cmd, timeout) on a QEMU task, e.g. nomad alloc exec or exec-based health checks against a QEMU workload.","commonSituations":"Running `nomad alloc exec <alloc> qemu-task -- ls` ; exec-based check blocks in job specs; debugging scripts assuming exec support.","solutions":["Use exec-based tooling inside the guest VM (SSH, cloud-init, QEMU guest agent) instead","Switch exec-based health checks to TCP/HTTP checks against the VM","Use the raw_exec or exec driver if in-VM exec via Nomad is essential"],"exampleFix":"// before\nres, err := driver.ExecTask(taskID, []string{\"ls\"}, time.Second) // unsupported\n// after\n// check: nomad alloc exec only works for exec/java/raw_exec drivers; use ssh into the VM","handlingStrategy":"validation","validationCode":"// Go: gate exec calls by driver kind\nif driverName == \"qemu\" {\n    return errors.New(\"exec unsupported; use ssh/guest agent\")\n}","typeGuard":null,"tryCatchPattern":"if _, err := drv.ExecTask(id, cmd, timeout); err != nil && strings.Contains(err.Error(), \"can't execute commands\") {\n    // fall back to ssh into the VM\n}","preventionTips":["Avoid exec-based health checks on QEMU tasks; use TCP/HTTP checks","Do not use `nomad alloc exec` on QEMU allocations","Plan VM debugging via SSH or cloud-init"],"tags":["qemu","exec","unsupported-operation","nomad-driver"],"backgroundTag":"operation-not-supported","analyzedSha":"482b49bf1aec006f089bcfc7e632d8f6ac303e5e","analyzedAt":"2026-09-04T07:54:14.808Z","contentChangedAt":"2026-09-04T07:54:14.808Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}