The following pull request was submitted through Github. It can be accessed and reviewed at: https://github.com/lxc/lxd/pull/6495
This e-mail was sent by the LXC bot, direct replies will not reach the author unless they happen to be subscribed to this list. === Description (from pull-request) ===
From dc59d48749631cccb1cc7f1cdd3e2b4ca80df69f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgra...@ubuntu.com> Date: Fri, 22 Nov 2019 01:14:09 -0500 Subject: [PATCH 1/2] lxd/vm: Add support for aarch64 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Stéphane Graber <stgra...@ubuntu.com> --- lxd/vm_qemu.go | 53 +++++++++++++++++++++++++++++++++----------------- 1 file changed, 35 insertions(+), 18 deletions(-) diff --git a/lxd/vm_qemu.go b/lxd/vm_qemu.go index 3e6bd600bb..b1b2d5b192 100644 --- a/lxd/vm_qemu.go +++ b/lxd/vm_qemu.go @@ -540,18 +540,24 @@ func (vm *vmQemu) Start(stateful bool) error { devConfs = append(devConfs, runConf) } - confFile, err := vm.generateQemuConfigFile(devConfs) + // Get qemu configuration + qemuBinary, qemuType, qemuConfig, err := vm.qemuArchConfig() + if err != nil { + return err + } + + confFile, err := vm.generateQemuConfigFile(qemuType, qemuConfig, devConfs) if err != nil { return err } // Check qemu is installed. - _, err = exec.LookPath("qemu-system-x86_64") + _, err = exec.LookPath(qemuBinary) if err != nil { return err } - _, err = shared.RunCommand("qemu-system-x86_64", "-name", vm.Name(), "-uuid", vmUUID, "-daemonize", "-cpu", "host", "-nographic", "-serial", "chardev:console", "-nodefaults", "-readconfig", confFile, "-pidfile", vm.pidFilePath()) + _, err = shared.RunCommand(qemuBinary, "-name", vm.Name(), "-uuid", vmUUID, "-daemonize", "-cpu", "host", "-nographic", "-serial", "chardev:console", "-nodefaults", "-readconfig", confFile, "-pidfile", vm.pidFilePath()) if err != nil { return err } @@ -559,6 +565,27 @@ func (vm *vmQemu) Start(stateful bool) error { return nil } +func (vm *vmQemu) qemuArchConfig() (string, string, string, error) { + if vm.architecture == osarch.ARCH_64BIT_INTEL_X86 { + conf := ` +[global] +driver = "ICH9-LPC" +property = "disable_s3" +value = "1" + +[global] +driver = "ICH9-LPC" +property = "disable_s4" +value = "1" +` + return "qemu-system-x86_64", "q35", conf, nil + } else if vm.architecture == osarch.ARCH_64BIT_ARMV8_LITTLE_ENDIAN { + return "qemu-system-aarch64", "virt", "", nil + } + + return "", "", "", fmt.Errorf("Architecture isn't supported for virtual machines") +} + // deviceVolatileGetFunc returns a function that retrieves a named device's volatile config and // removes its device prefix from the keys. func (vm *vmQemu) deviceVolatileGetFunc(devName string) func() map[string]string { @@ -887,29 +914,19 @@ echo "To start it now, unmount this filesystem and run: systemctl start lxd-agen // generateQemuConfigFile writes the qemu config file and returns its location. // It writes the config file inside the VM's log path. -func (vm *vmQemu) generateQemuConfigFile(devConfs []*deviceConfig.RunConfig) (string, error) { +func (vm *vmQemu) generateQemuConfigFile(qemuType string, qemuConf string, devConfs []*deviceConfig.RunConfig) (string, error) { var sb *strings.Builder = &strings.Builder{} // Base config. This is common for all VMs and has no variables in it. - sb.WriteString(` + sb.WriteString(fmt.Sprintf(` # Machine [machine] graphics = "off" -type = "q35" +type = "%s" accel = "kvm" usb = "off" graphics = "off" - -[global] -driver = "ICH9-LPC" -property = "disable_s3" -value = "1" - -[global] -driver = "ICH9-LPC" -property = "disable_s4" -value = "1" - +%s [boot-opts] strict = "on" @@ -969,7 +986,7 @@ addr = "0x0" # Console [chardev "console"] backend = "pty" -`) +`, qemuType, qemuConf)) // Now add the dynamic parts of the config. err := vm.addMemoryConfig(sb) From 1062bd93910820f4aabb80dca97e92034aa8ce60 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgra...@ubuntu.com> Date: Fri, 22 Nov 2019 12:41:12 -0500 Subject: [PATCH 2/2] api: Add virtual-machines API extension MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Stéphane Graber <stgra...@ubuntu.com> --- doc/api-extensions.md | 3 +++ shared/version/api.go | 1 + 2 files changed, 4 insertions(+) diff --git a/doc/api-extensions.md b/doc/api-extensions.md index a9eca7d47c..9031630d42 100644 --- a/doc/api-extensions.md +++ b/doc/api-extensions.md @@ -883,3 +883,6 @@ redirect filesystem mounts to their fuse implementation. To this end, set e.g. ## container\_disk\_ceph This allows for existing a CEPH RDB or FS to be directly connected to a LXD container. + +## virtual\_machines +Add virtual machine support. diff --git a/shared/version/api.go b/shared/version/api.go index 2f57e00682..1afdc1b2d0 100644 --- a/shared/version/api.go +++ b/shared/version/api.go @@ -178,6 +178,7 @@ var APIExtensions = []string{ "container_nic_routed", "container_syscall_intercept_mount_fuse", "container_disk_ceph", + "virtual-machines", } // APIExtensionsCount returns the number of available API extensions.
_______________________________________________ lxc-devel mailing list lxc-devel@lists.linuxcontainers.org http://lists.linuxcontainers.org/listinfo/lxc-devel