From 9e783d3fa508ad3e9daa86eabe0c37d55bb14770 Mon Sep 17 00:00:00 2001 From: Rin Date: Sun, 17 Mar 2024 17:46:13 +0800 Subject: [PATCH] update params and test run --- .github/workflows/ci.yml | 3 ++ dist/index.js | 64 ++++++++++++++++++++-------------------- index.js | 62 +++++++++++++++++++------------------- 3 files changed, 66 insertions(+), 63 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6bfa546..86dff8b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -5,6 +5,9 @@ on: [push, pull_request] jobs: test: runs-on: ubuntu-latest + timeout-minutes: 10 + env: + QEMU_VERSION: "8.2.2" steps: - uses: actions/checkout@v4 - uses: ./ diff --git a/dist/index.js b/dist/index.js index 014b077..b3ec81a 100644 --- a/dist/index.js +++ b/dist/index.js @@ -31101,34 +31101,34 @@ function start_vm(qemu_version, os, cpu, arch, bios, machine, filename, pubkey) show_message("info", qemu_executable + ' ' + qemu_args.join(' ')); - // qemu_wrapper(qemu_executable, qemu_args, (qemu_process) => { - // let ssh_ready = false; - // let do_ssh_callback = () => { - // qemu_executable.stdin.write("mkdir -p ~/.ssh && cat > ~/.ssh/authorized_keys <> /etc/rc.conf && echo 'PermitRootLogin yes' >> /etc/ssh/sshd_config && /etc/rc.d/sshd start && /etc/rc.d/sshd restart\n"); - // qemu_executable.stdin.write(pubkey + "\nEOF\n"); - // }; - - // let waitForPrompt = (() => { - // let concat = '' - // return (data) => { - // concat += data.toString() - // if (concat.includes('root@freebsd:~ #')) { - // if (!ssh_ready) { - // ssh_ready = true; - // do_ssh_callback(); - // } else { - // show_message("info", "SSH okay. VM is ready to use."); - // waitForLogin = () => { } - // } - // } - // } - // })() - - // qemu_process.stdout.on('data', (data) => { - // waitForPrompt(data) - // }); - // qemu_process.stdin.write('root\n') - // }); + qemu_wrapper(qemu_executable, qemu_args, (qemu_process) => { + let ssh_ready = false; + let do_ssh_callback = () => { + qemu_executable.stdin.write("mkdir -p ~/.ssh && cat > ~/.ssh/authorized_keys <> /etc/rc.conf && echo 'PermitRootLogin yes' >> /etc/ssh/sshd_config && /etc/rc.d/sshd start && /etc/rc.d/sshd restart\n"); + qemu_executable.stdin.write(pubkey + "\nEOF\n"); + }; + + let waitForPrompt = (() => { + let concat = '' + return (data) => { + concat += data.toString() + if (concat.includes('root@freebsd:~ #')) { + if (!ssh_ready) { + ssh_ready = true; + do_ssh_callback(); + } else { + show_message("info", "SSH okay. VM is ready to use."); + waitForLogin = () => { } + } + } + } + })() + + qemu_process.stdout.on('data', (data) => { + waitForPrompt(data) + }); + qemu_process.stdin.write('root\n') + }); core.endGroup(); }; @@ -31147,7 +31147,7 @@ function ensure_install_ovmf() { show_message("fatal", `Error installing OVMF. Exit code: ${result.status}`); } - result = spawnSync("sudo", ["apt-get", "--no-install-recommends", "-y", "install", "ovmf"], { + result = spawnSync("sudo", ["apt-get", "-y", "install", "ovmf"], { stdio: "inherit", env: { ...process.env, DEBIAN_FRONTEND: "noninteractive" }, }); @@ -31172,7 +31172,7 @@ try { // core.endGroup(); core.startGroup("Set up QEMU"); - const qemu_version = "8.2.0"; + const qemu_version = "8.2.2"; setup_precompiled_qemu(qemu_version); core.endGroup(); @@ -31272,7 +31272,7 @@ try { bios = "edk2-aarch64-code.fd"; break; case "riscv64": - bios = "opensbi-riscv64-generic-fw_dynamic.bin"; + bios = "fw_payload.elf"; break; default: show_message("fatal", `Unknown architecture: ${arch}`); @@ -31287,7 +31287,7 @@ try { machine = "pc"; break; case "aarch64": - machine = "virt,gic-version=2"; + machine = "virt,gic-version=3"; break; case "riscv64": machine = "virt"; diff --git a/index.js b/index.js index e4028a1..43d0a7d 100644 --- a/index.js +++ b/index.js @@ -211,34 +211,34 @@ function start_vm(qemu_version, os, cpu, arch, bios, machine, filename, pubkey) show_message("info", qemu_executable + ' ' + qemu_args.join(' ')); - // qemu_wrapper(qemu_executable, qemu_args, (qemu_process) => { - // let ssh_ready = false; - // let do_ssh_callback = () => { - // qemu_executable.stdin.write("mkdir -p ~/.ssh && cat > ~/.ssh/authorized_keys <> /etc/rc.conf && echo 'PermitRootLogin yes' >> /etc/ssh/sshd_config && /etc/rc.d/sshd start && /etc/rc.d/sshd restart\n"); - // qemu_executable.stdin.write(pubkey + "\nEOF\n"); - // }; - - // let waitForPrompt = (() => { - // let concat = '' - // return (data) => { - // concat += data.toString() - // if (concat.includes('root@freebsd:~ #')) { - // if (!ssh_ready) { - // ssh_ready = true; - // do_ssh_callback(); - // } else { - // show_message("info", "SSH okay. VM is ready to use."); - // waitForLogin = () => { } - // } - // } - // } - // })() - - // qemu_process.stdout.on('data', (data) => { - // waitForPrompt(data) - // }); - // qemu_process.stdin.write('root\n') - // }); + qemu_wrapper(qemu_executable, qemu_args, (qemu_process) => { + let ssh_ready = false; + let do_ssh_callback = () => { + qemu_executable.stdin.write("mkdir -p ~/.ssh && cat > ~/.ssh/authorized_keys <> /etc/rc.conf && echo 'PermitRootLogin yes' >> /etc/ssh/sshd_config && /etc/rc.d/sshd start && /etc/rc.d/sshd restart\n"); + qemu_executable.stdin.write(pubkey + "\nEOF\n"); + }; + + let waitForPrompt = (() => { + let concat = '' + return (data) => { + concat += data.toString() + if (concat.includes('root@freebsd:~ #')) { + if (!ssh_ready) { + ssh_ready = true; + do_ssh_callback(); + } else { + show_message("info", "SSH okay. VM is ready to use."); + waitForLogin = () => { } + } + } + } + })() + + qemu_process.stdout.on('data', (data) => { + waitForPrompt(data) + }); + qemu_process.stdin.write('root\n') + }); core.endGroup(); }; @@ -282,7 +282,7 @@ try { // core.endGroup(); core.startGroup("Set up QEMU"); - const qemu_version = "8.2.0"; + const qemu_version = "8.2.2"; setup_precompiled_qemu(qemu_version); core.endGroup(); @@ -382,7 +382,7 @@ try { bios = "edk2-aarch64-code.fd"; break; case "riscv64": - bios = "opensbi-riscv64-generic-fw_dynamic.bin"; + bios = "fw_payload.elf"; break; default: show_message("fatal", `Unknown architecture: ${arch}`); @@ -397,7 +397,7 @@ try { machine = "pc"; break; case "aarch64": - machine = "virt,gic-version=2"; + machine = "virt,gic-version=3"; break; case "riscv64": machine = "virt";