Merge pull request #2337 from zacheryph/qemu-pidfile

save qemu pid in state directory
This commit is contained in:
Justin Cormack 2017-08-02 15:53:17 +01:00 committed by GitHub
commit 550bf41d0b
3 changed files with 8 additions and 10 deletions

View File

@ -32,6 +32,7 @@ type QemuConfig struct {
GUI bool
Disks Disks
MetadataPath string
StatePath string
FWPath string
Arch string
CPUs string
@ -183,13 +184,10 @@ func runQemu(args []string) {
if *state == "" {
*state = prefix + "-state"
}
var mkstate func()
mkstate = func() {
if err := os.MkdirAll(*state, 0755); err != nil {
log.Fatalf("Could not create state directory: %v", err)
}
mkstate = func() {}
}
isoPath := ""
if *data != "" {
@ -202,7 +200,6 @@ func runQemu(args []string) {
log.Fatalf("Cannot read user data: %v", err)
}
}
mkstate()
isoPath = filepath.Join(*state, "data.iso")
if err := WriteMetadataISO(isoPath, d); err != nil {
log.Fatalf("Cannot write user data ISO: %v", err)
@ -218,7 +215,6 @@ func runQemu(args []string) {
d.Format = "qcow2"
}
if d.Size != 0 && d.Path == "" {
mkstate()
d.Path = filepath.Join(*state, "disk"+id+".img")
}
if d.Path == "" {
@ -283,6 +279,7 @@ func runQemu(args []string) {
GUI: *enableGUI,
Disks: disks,
MetadataPath: isoPath,
StatePath: *state,
FWPath: *fw,
Arch: *arch,
CPUs: *cpus,
@ -463,6 +460,7 @@ func buildQemuCmdline(config QemuConfig) (QemuConfig, []string) {
qemuArgs = append(qemuArgs, "-smp", config.CPUs)
qemuArgs = append(qemuArgs, "-m", config.Memory)
qemuArgs = append(qemuArgs, "-uuid", config.UUID.String())
qemuArgs = append(qemuArgs, "-pidfile", filepath.Join(config.StatePath, "qemu.pid"))
// Need to specify the vcpu type when running qemu on arm64 platform, for security reason,
// the vcpu should be "host" instead of other names such as "cortex-a53"...
if config.Arch == "aarch64" {

View File

@ -10,7 +10,7 @@ set -e
. "${RT_PROJECT_ROOT}/_lib/lib.sh"
clean_up() {
find . -iname "test-containerd*" -not -iname "*.yml" -exec rm -rf {} \;
find . -depth -iname "test-containerd*" -not -iname "*.yml" -exec rm -rf {} \;
}
trap clean_up EXIT

View File

@ -12,7 +12,7 @@ set -e
NAME=test-ctr
clean_up() {
find . -iname "test-ctr*" -not -iname "*.yml" -exec rm -rf {} \;
find . -depth -iname "test-ctr*" -not -iname "*.yml" -exec rm -rf {} \;
}
trap clean_up EXIT