Skip to content
This repository has been archived by the owner on Jul 16, 2020. It is now read-only.

Commit

Permalink
Merge pull request #618 from 01org/sameo/topic/qemu
Browse files Browse the repository at this point in the history
Support for qemu daemonization and socket based consoles
  • Loading branch information
kaccardi authored Sep 30, 2016
2 parents 0ef69a6 + 4bfb85b commit 65203c1
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 19 deletions.
30 changes: 12 additions & 18 deletions qemu/qemu.go
Original file line number Diff line number Diff line change
Expand Up @@ -276,23 +276,6 @@ func (cdev CharDevice) Valid() bool {
return true
}

func appendCharDevice(params []string, cdev CharDevice) ([]string, error) {
if cdev.Valid() == false {
return nil, fmt.Errorf("Invalid character device")
}

var cdevParams []string

cdevParams = append(cdevParams, string(cdev.Backend))
cdevParams = append(cdevParams, fmt.Sprintf(",id=%s", cdev.ID))
cdevParams = append(cdevParams, fmt.Sprintf(",path=%s", cdev.Path))

params = append(params, "-chardev")
params = append(params, strings.Join(cdevParams, ""))

return params, nil
}

// QemuParams returns the qemu parameters built out of this character device.
func (cdev CharDevice) QemuParams(config *Config) []string {
var cdevParams []string
Expand All @@ -305,7 +288,11 @@ func (cdev CharDevice) QemuParams(config *Config) []string {

cdevParams = append(cdevParams, string(cdev.Backend))
cdevParams = append(cdevParams, fmt.Sprintf(",id=%s", cdev.ID))
cdevParams = append(cdevParams, fmt.Sprintf(",path=%s", cdev.Path))
if cdev.Backend == Socket {
cdevParams = append(cdevParams, fmt.Sprintf(",path=%s,server,nowait", cdev.Path))
} else {
cdevParams = append(cdevParams, fmt.Sprintf(",path=%s", cdev.Path))
}

qemuParams = append(qemuParams, "-device")
qemuParams = append(qemuParams, strings.Join(deviceParams, ""))
Expand Down Expand Up @@ -682,6 +669,9 @@ type Knobs struct {

// NoGraphic completely disables graphic output.
NoGraphic bool

// Daemonize will turn the qemu process into a daemon
Daemonize bool
}

// Config is the qemu configuration structure.
Expand Down Expand Up @@ -925,6 +915,10 @@ func (config *Config) appendKnobs() {
if config.Knobs.NoGraphic == true {
config.qemuParams = append(config.qemuParams, "-nographic")
}

if config.Knobs.Daemonize == true {
config.qemuParams = append(config.qemuParams, "-daemonize")
}
}

// LaunchQemu can be used to launch a new qemu instance.
Expand Down
3 changes: 2 additions & 1 deletion qemu/qemu_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,13 +173,14 @@ func TestAppendEmptyDevice(t *testing.T) {
testAppend(device, "", t)
}

var knobsString = "-no-user-config -nodefaults -nographic"
var knobsString = "-no-user-config -nodefaults -nographic -daemonize"

func TestAppendKnobsAllTrue(t *testing.T) {
knobs := Knobs{
NoUserConfig: true,
NoDefaults: true,
NoGraphic: true,
Daemonize: true,
}

testAppend(knobs, knobsString, t)
Expand Down

0 comments on commit 65203c1

Please sign in to comment.