Skip to content

Commit

Permalink
update params and test run
Browse files Browse the repository at this point in the history
  • Loading branch information
shinohara-rin committed Mar 17, 2024
1 parent 82bdda0 commit 9e783d3
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 63 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: ./
Expand Down
64 changes: 32 additions & 32 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 <<EOF && chmod 600 ~/.ssh/authorized_keys && echo 'sshd_enable=\"YES\"' >> /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 <<EOF && chmod 600 ~/.ssh/authorized_keys && echo 'sshd_enable=\"YES\"' >> /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();
};

Expand All @@ -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" },
});
Expand All @@ -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();

Expand Down Expand Up @@ -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}`);
Expand All @@ -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";
Expand Down
62 changes: 31 additions & 31 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 <<EOF && chmod 600 ~/.ssh/authorized_keys && echo 'sshd_enable=\"YES\"' >> /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 <<EOF && chmod 600 ~/.ssh/authorized_keys && echo 'sshd_enable=\"YES\"' >> /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();
};

Expand Down Expand Up @@ -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();

Expand Down Expand Up @@ -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}`);
Expand All @@ -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";
Expand Down

0 comments on commit 9e783d3

Please sign in to comment.