mirror of
https://github.com/linuxkit/linuxkit.git
synced 2025-07-21 01:59:07 +00:00
qemu: Generate a random uuid and pass via -uuid
This is the same behaviour as the LinuxKit backend. This populates /sys/class/dmi/id/product_uuid, which newer version of weave-net appears to require. Signed-off-by: Ian Campbell <ijc@docker.com>
This commit is contained in:
parent
29ead2bd9d
commit
cb86cdb027
@ -11,6 +11,7 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
log "github.com/Sirupsen/logrus"
|
log "github.com/Sirupsen/logrus"
|
||||||
|
"github.com/satori/go.uuid"
|
||||||
"golang.org/x/crypto/ssh/terminal"
|
"golang.org/x/crypto/ssh/terminal"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -36,6 +37,7 @@ type QemuConfig struct {
|
|||||||
QemuImgPath string
|
QemuImgPath string
|
||||||
PublishedPorts []string
|
PublishedPorts []string
|
||||||
TapDevice string
|
TapDevice string
|
||||||
|
UUID uuid.UUID
|
||||||
}
|
}
|
||||||
|
|
||||||
func haveKVM() bool {
|
func haveKVM() bool {
|
||||||
@ -95,6 +97,9 @@ func runQemu(args []string) {
|
|||||||
// Backend configuration
|
// Backend configuration
|
||||||
qemuContainerized := flags.Bool("containerized", false, "Run qemu in a container")
|
qemuContainerized := flags.Bool("containerized", false, "Run qemu in a container")
|
||||||
|
|
||||||
|
// Generate UUID, so that /sys/class/dmi/id/product_uuid is populated
|
||||||
|
vmUUID := uuid.NewV4()
|
||||||
|
|
||||||
publishFlags := multipleFlag{}
|
publishFlags := multipleFlag{}
|
||||||
flags.Var(&publishFlags, "publish", "Publish a vm's port(s) to the host (default [])")
|
flags.Var(&publishFlags, "publish", "Publish a vm's port(s) to the host (default [])")
|
||||||
tapDevice := flags.String("tap-device", "", "Tap device to use as eth0 (optional)")
|
tapDevice := flags.String("tap-device", "", "Tap device to use as eth0 (optional)")
|
||||||
@ -218,6 +223,7 @@ func runQemu(args []string) {
|
|||||||
Containerized: *qemuContainerized,
|
Containerized: *qemuContainerized,
|
||||||
PublishedPorts: publishFlags,
|
PublishedPorts: publishFlags,
|
||||||
TapDevice: *tapDevice,
|
TapDevice: *tapDevice,
|
||||||
|
UUID: vmUUID,
|
||||||
}
|
}
|
||||||
|
|
||||||
config = discoverBackend(config)
|
config = discoverBackend(config)
|
||||||
@ -380,6 +386,7 @@ func buildQemuCmdline(config QemuConfig) (QemuConfig, []string) {
|
|||||||
qemuArgs = append(qemuArgs, "-device", "virtio-rng-pci")
|
qemuArgs = append(qemuArgs, "-device", "virtio-rng-pci")
|
||||||
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())
|
||||||
// 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" {
|
||||||
|
Loading…
Reference in New Issue
Block a user