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 #550 from 01org/sameo/topic/qemu
Browse files Browse the repository at this point in the history
qemu: Build qemu parameters from a configuration structure
  • Loading branch information
mcastelino authored Sep 19, 2016
2 parents 53c686c + c1a5e01 commit 449023f
Show file tree
Hide file tree
Showing 4 changed files with 1,229 additions and 12 deletions.
11 changes: 6 additions & 5 deletions ciao-launcher/qemu.go
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,8 @@ func launchQemuWithNC(params []string, fds []*os.File, ipAddress string) (int, e
ncString := "socket,port=%d,host=%s,server,id=gnc0,server,nowait"
params[len(params)-1] = fmt.Sprintf(ncString, port, ipAddress)
var errStr string
errStr, err = qemu.LaunchQemu(context.Background(), params, fds, qmpGlogLogger{})

errStr, err = qemu.LaunchCustomQemu(context.Background(), "", params, fds, qmpGlogLogger{})
if err == nil {
glog.Info("============================================")
glog.Infof("Connect to vm with netcat %s %d", ipAddress, port)
Expand All @@ -378,7 +379,7 @@ func launchQemuWithNC(params []string, fds []*os.File, ipAddress string) (int, e

if port == 0 || (err != nil && tries == vcTries) {
glog.Warning("Failed to launch qemu due to chardev error. Relaunching without virtual console")
_, err = qemu.LaunchQemu(context.Background(), params[:len(params)-4], fds, qmpGlogLogger{})
_, err = qemu.LaunchCustomQemu(context.Background(), "", params[:len(params)-4], fds, qmpGlogLogger{})
}

return port, err
Expand All @@ -397,7 +398,7 @@ func launchQemuWithSpice(params []string, fds []*os.File, ipAddress string) (int
}
params[len(params)-1] = fmt.Sprintf("port=%d,addr=%s,disable-ticketing", port, ipAddress)
var errStr string
errStr, err = qemu.LaunchQemu(context.Background(), params, fds, qmpGlogLogger{})
errStr, err = qemu.LaunchCustomQemu(context.Background(), "", params, fds, qmpGlogLogger{})
if err == nil {
glog.Info("============================================")
glog.Infof("Connect to vm with spicec -h %s -p %d", ipAddress, port)
Expand All @@ -416,7 +417,7 @@ func launchQemuWithSpice(params []string, fds []*os.File, ipAddress string) (int
if port == 0 || (err != nil && tries == vcTries) {
glog.Warning("Failed to launch qemu due to spice error. Relaunching without virtual console")
params = append(params[:len(params)-2], "-display", "none", "-vga", "none")
_, err = qemu.LaunchQemu(context.Background(), params, fds, qmpGlogLogger{})
_, err = qemu.LaunchCustomQemu(context.Background(), "", params, fds, qmpGlogLogger{})
}

return port, err
Expand Down Expand Up @@ -519,7 +520,7 @@ func (q *qemuV) startVM(vnicName, ipAddress, cephID string) error {

if !launchWithUI.Enabled() {
params = append(params, "-display", "none", "-vga", "none")
_, err = qemu.LaunchQemu(context.Background(), params, fds, qmpGlogLogger{})
_, err = qemu.LaunchCustomQemu(context.Background(), "", params, fds, qmpGlogLogger{})
} else if launchWithUI.String() == "spice" {
var port int
port, err = launchQemuWithSpice(params, fds, ipAddress)
Expand Down
4 changes: 2 additions & 2 deletions qemu/examples_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ func Example() {
// resources
params = append(params, "-m", "370", "-smp", "cpus=2")

// LaunchQemu should return as soon as the instance has launched as we
// LaunchCustomQemu should return as soon as the instance has launched as we
// are using the --daemonize flag. It will set up a unix domain socket
// called /tmp/qmp-socket that we can use to manage the instance.
_, err := qemu.LaunchQemu(context.Background(), params, nil, nil)
_, err := qemu.LaunchCustomQemu(context.Background(), "", params, nil, nil)
if err != nil {
panic(err)
}
Expand Down
Loading

0 comments on commit 449023f

Please sign in to comment.