Repository: hashicorp/nomad
File: drivers/qemu/driver.go (Go)

Code before:
// during recovery.
type TaskState struct {
	ReattachConfig *pstructs.ReattachConfig
	TaskConfig     *drivers.TaskConfig
	Pid            int
	StartedAt      time.Time
}

// Config is the driver configuration set by SetConfig RPC call
type Config struct {
	// ImagePaths is an allow-list of paths qemu is allowed to load an image from
	ImagePaths []string `codec:"image_paths"`

	// ArgsAllowList is an allow-list of arguments the jobspec can
	// include in arguments to qemu, so that cluster operators can can
	// prevent access to devices
	ArgsAllowList []string `codec:"args_allowlist"`
}

// Driver is a driver for running images via Qemu
type Driver struct {
	// eventer is used to handle multiplexing of TaskEvents calls such that an
	// event can be broadcast to all callers
	eventer *eventer.Eventer

	// config is the driver configuration set by the SetConfig RPC
	config Config

	// tasks is the in memory datastore mapping taskIDs to qemuTaskHandle
	tasks *taskStore

	// ctx is the context for the driver. It is passed to other subsystems to
	// coordinate shutdown
	ctx context.Context

	// nomadConf is the client agent's configuration
	nomadConfig *base.ClientDriverConfig

	// logger will log to the Nomad agent
	logger hclog.Logger
}

func NewQemuDriver(ctx context.Context, logger hclog.Logger) drivers.DriverPlugin {
	logger = logger.Named(pluginName)
	return &Driver{
		eventer: eventer.NewEventer(ctx, logger),
		tasks:   newTaskStore(),
		ctx:     ctx,
		logger:  logger,
	}
}

Review comment (suggestion):
This code was never added to the hcl spec, so it is effectively invisible to users and always uses the default, which is why it is not listed in the docs.  It was removed in https://github.com/hashicorp/nomad/pull/27182 in favor of an emulator allowlist.

Code after:
	GuestAgent       bool               `codec:"guest_agent"`
}

// TaskState is the state which is encoded in the handle returned in StartTask.
// This information is needed to rebuild the taskConfig state and handler
// during recovery.
type TaskState struct {
	ReattachConfig *pstructs.ReattachConfig
	TaskConfig     *drivers.TaskConfig
	Pid            int
	StartedAt      time.Time
}

// Config is the driver configuration set by SetConfig RPC call
type Config struct {
	// ImagePaths is an allow-list of paths qemu is allowed to load an image from
	ImagePaths []string `codec:"image_paths"`

	// ArgsAllowList is an allow-list of arguments the jobspec can
	// include in arguments to qemu, so that cluster operators can can
	// prevent access to devices
	ArgsAllowList []string `codec:"args_allowlist"`

	// FingerprintEmulator specifies which QEMU binary is used
	// for fingerprinting
	FingerprintEmulator string `codec:"fingerprint_emulator"`
}

// Driver is a driver for running images via Qemu
type Driver struct {
	// eventer is used to handle multiplexing of TaskEvents calls such that an
	// event can be broadcast to all callers
	eventer *eventer.Eventer

	// config is the driver configuration set by the SetConfig RPC
	config Config

	// tasks is the in memory datastore mapping taskIDs to qemuTaskHandle
	tasks *taskStore

	// ctx is the context for the driver. It is passed to other subsystems to
	// coordinate shutdown
	ctx context.Context

	// nomadConf is the client agent's configuration
	nomadConfig *base.ClientDriverConfig

	// logger will log to the Nomad agent
	logger hclog.Logger
}