mirror of
https://github.com/linuxkit/linuxkit.git
synced 2025-07-19 09:16:29 +00:00
Merge pull request #2337 from zacheryph/qemu-pidfile
save qemu pid in state directory
This commit is contained in:
commit
550bf41d0b
@ -32,6 +32,7 @@ type QemuConfig struct {
|
|||||||
GUI bool
|
GUI bool
|
||||||
Disks Disks
|
Disks Disks
|
||||||
MetadataPath string
|
MetadataPath string
|
||||||
|
StatePath string
|
||||||
FWPath string
|
FWPath string
|
||||||
Arch string
|
Arch string
|
||||||
CPUs string
|
CPUs string
|
||||||
@ -183,12 +184,9 @@ func runQemu(args []string) {
|
|||||||
if *state == "" {
|
if *state == "" {
|
||||||
*state = prefix + "-state"
|
*state = prefix + "-state"
|
||||||
}
|
}
|
||||||
var mkstate func()
|
|
||||||
mkstate = func() {
|
if err := os.MkdirAll(*state, 0755); err != nil {
|
||||||
if err := os.MkdirAll(*state, 0755); err != nil {
|
log.Fatalf("Could not create state directory: %v", err)
|
||||||
log.Fatalf("Could not create state directory: %v", err)
|
|
||||||
}
|
|
||||||
mkstate = func() {}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
isoPath := ""
|
isoPath := ""
|
||||||
@ -202,7 +200,6 @@ func runQemu(args []string) {
|
|||||||
log.Fatalf("Cannot read user data: %v", err)
|
log.Fatalf("Cannot read user data: %v", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
mkstate()
|
|
||||||
isoPath = filepath.Join(*state, "data.iso")
|
isoPath = filepath.Join(*state, "data.iso")
|
||||||
if err := WriteMetadataISO(isoPath, d); err != nil {
|
if err := WriteMetadataISO(isoPath, d); err != nil {
|
||||||
log.Fatalf("Cannot write user data ISO: %v", err)
|
log.Fatalf("Cannot write user data ISO: %v", err)
|
||||||
@ -218,7 +215,6 @@ func runQemu(args []string) {
|
|||||||
d.Format = "qcow2"
|
d.Format = "qcow2"
|
||||||
}
|
}
|
||||||
if d.Size != 0 && d.Path == "" {
|
if d.Size != 0 && d.Path == "" {
|
||||||
mkstate()
|
|
||||||
d.Path = filepath.Join(*state, "disk"+id+".img")
|
d.Path = filepath.Join(*state, "disk"+id+".img")
|
||||||
}
|
}
|
||||||
if d.Path == "" {
|
if d.Path == "" {
|
||||||
@ -283,6 +279,7 @@ func runQemu(args []string) {
|
|||||||
GUI: *enableGUI,
|
GUI: *enableGUI,
|
||||||
Disks: disks,
|
Disks: disks,
|
||||||
MetadataPath: isoPath,
|
MetadataPath: isoPath,
|
||||||
|
StatePath: *state,
|
||||||
FWPath: *fw,
|
FWPath: *fw,
|
||||||
Arch: *arch,
|
Arch: *arch,
|
||||||
CPUs: *cpus,
|
CPUs: *cpus,
|
||||||
@ -463,6 +460,7 @@ func buildQemuCmdline(config QemuConfig) (QemuConfig, []string) {
|
|||||||
qemuArgs = append(qemuArgs, "-smp", config.CPUs)
|
qemuArgs = append(qemuArgs, "-smp", config.CPUs)
|
||||||
qemuArgs = append(qemuArgs, "-m", config.Memory)
|
qemuArgs = append(qemuArgs, "-m", config.Memory)
|
||||||
qemuArgs = append(qemuArgs, "-uuid", config.UUID.String())
|
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,
|
// 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"...
|
// the vcpu should be "host" instead of other names such as "cortex-a53"...
|
||||||
if config.Arch == "aarch64" {
|
if config.Arch == "aarch64" {
|
||||||
|
@ -10,7 +10,7 @@ set -e
|
|||||||
. "${RT_PROJECT_ROOT}/_lib/lib.sh"
|
. "${RT_PROJECT_ROOT}/_lib/lib.sh"
|
||||||
|
|
||||||
clean_up() {
|
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
|
trap clean_up EXIT
|
||||||
|
|
||||||
|
@ -12,7 +12,7 @@ set -e
|
|||||||
NAME=test-ctr
|
NAME=test-ctr
|
||||||
|
|
||||||
clean_up() {
|
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
|
trap clean_up EXIT
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user