aboutsummaryrefslogtreecommitdiffstats
path: root/vm/qemu
diff options
context:
space:
mode:
authorAleksandr Nogikh <nogikh@google.com>2025-09-26 13:17:29 +0200
committerAleksandr Nogikh <nogikh@google.com>2025-10-01 14:41:08 +0000
commit9f36949b26d43c6ccbb08181c9d4452458d2c673 (patch)
tree7b9268d4f63e42c11e0abe67168e910b77b887dd /vm/qemu
parenta6341f95a21baff8dca02c63fea4abccc6056672 (diff)
vm: add context to Pool.Create()
Enable external abortion of the instance creation process. This is especially useful for the qemu case where we retry the creation/boot up to 1000 times, which can take significant time (e.g. it timeouts syz-cluster pods on unstable kernels). The context can be further propagated to WaitForSSH, but that requires another quite significant vm/ refactoring.
Diffstat (limited to 'vm/qemu')
-rw-r--r--vm/qemu/qemu.go5
1 files changed, 4 insertions, 1 deletions
diff --git a/vm/qemu/qemu.go b/vm/qemu/qemu.go
index 3bf546aa2..63598d4bb 100644
--- a/vm/qemu/qemu.go
+++ b/vm/qemu/qemu.go
@@ -324,7 +324,7 @@ func (pool *Pool) Count() int {
return pool.cfg.Count
}
-func (pool *Pool) Create(workdir string, index int) (vmimpl.Instance, error) {
+func (pool *Pool) Create(ctx context.Context, workdir string, index int) (vmimpl.Instance, error) {
sshkey := pool.env.SSHKey
sshuser := pool.env.SSHUser
if pool.env.Image == "9p" {
@@ -341,6 +341,9 @@ func (pool *Pool) Create(workdir string, index int) (vmimpl.Instance, error) {
}
for i := 0; ; i++ {
+ if err := ctx.Err(); err != nil {
+ return nil, err
+ }
inst, err := pool.ctor(workdir, sshkey, sshuser, index)
if err == nil {
return inst, nil