From c5dfcab929a2e7d53c8176d8a78abcb3ffed5477 Mon Sep 17 00:00:00 2001 From: wangyueliang Date: Fri, 28 Jun 2024 16:50:19 +0800 Subject: [PATCH] kola: Add support for full emulation and other auxiliary debugging options [upstream] d812406d5ea8834d130fc8dda605e3a12a58250e kola: Add `--qemu-bind-ro` f57f73562d99b767567c9507889a469774050f9b run: Add `noautoupdate` ignition fragment 5cf1cfdc7a9e32afa0258214f49dd9299a743590 qemu: Add support for full emulation --- mantle/cmd/kola/qemuexec.go | 11 ++++++++++- mantle/platform/machine/qemu/cluster.go | 8 ++++++++ mantle/platform/machine/qemu/flight.go | 3 +++ mantle/platform/qemu.go | 5 +++-- src/deps.txt | 2 +- 5 files changed, 25 insertions(+), 4 deletions(-) diff --git a/mantle/cmd/kola/qemuexec.go b/mantle/cmd/kola/qemuexec.go index 5a16be40..93082545 100644 --- a/mantle/cmd/kola/qemuexec.go +++ b/mantle/cmd/kola/qemuexec.go @@ -84,9 +84,10 @@ func init() { cmdQemuExec.Flags().StringVarP(&firstbootkargs, "firstbootkargs", "", "", "Additional first boot kernel arguments") cmdQemuExec.Flags().StringArrayVar(&kargs, "kargs", nil, "Additional kernel arguments applied") cmdQemuExec.Flags().BoolVarP(&usernet, "usernet", "U", false, "Enable usermode networking") - cmdQemuExec.Flags().StringSliceVar(&ignitionFragments, "add-ignition", nil, "Append well-known Ignition fragment: [\"autologin\", \"autoresize\"]") + cmdQemuExec.Flags().StringSliceVar(&ignitionFragments, "add-ignition", nil, "Append well-known Ignition fragment: [\"autologin\", \"autoresize\", \"noautoupdate\"]") cmdQemuExec.Flags().StringVarP(&hostname, "hostname", "", "", "Set hostname via DHCP") cmdQemuExec.Flags().IntVarP(&memory, "memory", "m", 0, "Memory in MB") + cmdQemuExec.Flags().StringVar(&architecture, "arch", "", "Use full emulation for target architecture (e.g. aarch64, x86_64, s390x, ppc64le)") cmdQemuExec.Flags().StringArrayVarP(&addDisks, "add-disk", "D", []string{}, "Additional disk, human readable size (repeatable)") cmdQemuExec.Flags().BoolVar(&cpuCountHost, "auto-cpus", false, "Automatically set number of cpus to host count") cmdQemuExec.Flags().BoolVar(&directIgnition, "ignition-direct", false, "Do not parse Ignition, pass directly to instance") @@ -113,6 +114,8 @@ func renderFragments(fragments []string, c *conf.Conf) error { c.AddAutoLogin() case "autoresize": c.AddAutoResize() + case "noautoupdate": + c.DisableAutomaticUpdates() default: return fmt.Errorf("Unknown fragment: %s", fragtype) } @@ -247,6 +250,12 @@ func runQemuExec(cmd *cobra.Command, args []string) error { builder := platform.NewQemuBuilder() defer builder.Close() + if architecture != "" { + if err := builder.SetArchitecture(architecture); err != nil { + return err + } + } + var config *conf.Conf if butane != "" { buf, err := os.ReadFile(butane) diff --git a/mantle/platform/machine/qemu/cluster.go b/mantle/platform/machine/qemu/cluster.go index 8b0e4dce..28d159f0 100644 --- a/mantle/platform/machine/qemu/cluster.go +++ b/mantle/platform/machine/qemu/cluster.go @@ -19,6 +19,7 @@ import ( "os" "path/filepath" "strconv" + "strings" "sync" "time" @@ -120,6 +121,13 @@ func (qc *Cluster) NewMachineWithQemuOptions(userdata *conf.UserData, options pl builder.Hostname = fmt.Sprintf("qemu%d", qc.BaseCluster.AllocateMachineSerial()) builder.ConsoleFile = qm.consolePath + // This one doesn't support configuring the path because we can't + // reliably change the Ignition config here... + for _, path := range qc.flight.opts.BindRO { + destpathrel := strings.TrimLeft(path, "/") + builder.MountHost(path, "/kola/host/"+destpathrel, true) + } + if qc.flight.opts.Memory != "" { memory, err := strconv.ParseInt(qc.flight.opts.Memory, 10, 32) if err != nil { diff --git a/mantle/platform/machine/qemu/flight.go b/mantle/platform/machine/qemu/flight.go index 188fd599..8abc4db8 100644 --- a/mantle/platform/machine/qemu/flight.go +++ b/mantle/platform/machine/qemu/flight.go @@ -46,6 +46,9 @@ type Options struct { //Option to create a temporary software TPM - true by default Swtpm bool + // Array of $hostpath + BindRO []string + //IBM Secure Execution SecureExecution bool SecureExecutionIgnitionPubKey string diff --git a/mantle/platform/qemu.go b/mantle/platform/qemu.go index ccdbe66e..38e6bafc 100644 --- a/mantle/platform/qemu.go +++ b/mantle/platform/qemu.go @@ -692,11 +692,12 @@ func (builder *QemuBuilder) setupAdditionalNetworking() error { // SetArchitecture enables qemu full emulation for the target architecture. func (builder *QemuBuilder) SetArchitecture(arch string) error { switch arch { - case "x86_64", "aarch64", "s390x", "ppc64le": + //case "x86_64", "aarch64", "s390x", "ppc64le": + case "x86_64", "aarch64": builder.architecture = arch return nil } - return fmt.Errorf("architecture %s not supported by coreos-assembler qemu", arch) + return fmt.Errorf("architecture %s not supported by nestos-assembler qemu", arch) } // SetSecureExecution enables qemu confidential guest support and adds hostkey to ignition config. diff --git a/src/deps.txt b/src/deps.txt index 50cbafc2..5d38e443 100644 --- a/src/deps.txt +++ b/src/deps.txt @@ -32,7 +32,7 @@ make git rpm-build libguestfs-tools libguestfs-tools-c virtiofsd /usr/bin/qemu-img qemu-kvm swtpm # And the main arch emulators for cross-arch testing #qemu-system-aarch64-core qemu-system-ppc-core qemu-system-s390x-core qemu-system-x86-core -qemu-system-aarch64-core qemu-system-x86-core +qemu-system-aarch64 qemu-system-x86 # Useful for moving files around rsync -- Gitee