From ecb67f1f2d244da2c58571f860be2724f7810705 Mon Sep 17 00:00:00 2001 From: Rin Date: Sun, 17 Mar 2024 19:13:35 +0800 Subject: [PATCH] ahhhh revert --- dist/index.js | 26 ++++++++++++++++++++++++++ index.js | 26 ++++++++++++++++++++++++++ 2 files changed, 52 insertions(+) diff --git a/dist/index.js b/dist/index.js index c4572f5..3e8757b 100644 --- a/dist/index.js +++ b/dist/index.js @@ -31024,6 +31024,32 @@ function ensure_host_ssh_key() { return pubkey; }; +function qemu_wrapper(qemu_cmd, qemu_args, ready_callback) { + show_message("info", 'starting qemu process with command: ' + qemu_cmd + ' ' + qemu_args.join(' ')); + const qemuProcess = spawn(qemu_cmd, qemu_args); + + let waitForLogin = (() => { + let concat = '' + return (data) => { + concat += data.toString() + if (concat.includes('login')) { + ready_callback(qemuProcess) + waitForLogin = () => { } + } + } + })() + + qemuProcess.stdout.on('data', (data) => { + waitForLogin(data) + }); + + qemuProcess.on('close', (code) => { + show_message("info", `qemu exited with code ${code}`); + }); + + return qemuProcess; +} + function start_vm(qemu_version, os, cpu, arch, bios, machine, filename, pubkey) { core.startGroup("Start VM"); show_message("info", "Starting VM"); diff --git a/index.js b/index.js index a80b5a2..54c3327 100644 --- a/index.js +++ b/index.js @@ -134,6 +134,32 @@ function ensure_host_ssh_key() { return pubkey; }; +function qemu_wrapper(qemu_cmd, qemu_args, ready_callback) { + show_message("info", 'starting qemu process with command: ' + qemu_cmd + ' ' + qemu_args.join(' ')); + const qemuProcess = spawn(qemu_cmd, qemu_args); + + let waitForLogin = (() => { + let concat = '' + return (data) => { + concat += data.toString() + if (concat.includes('login')) { + ready_callback(qemuProcess) + waitForLogin = () => { } + } + } + })() + + qemuProcess.stdout.on('data', (data) => { + waitForLogin(data) + }); + + qemuProcess.on('close', (code) => { + show_message("info", `qemu exited with code ${code}`); + }); + + return qemuProcess; +} + function start_vm(qemu_version, os, cpu, arch, bios, machine, filename, pubkey) { core.startGroup("Start VM"); show_message("info", "Starting VM");