Skip to content

Commit

Permalink
vm/proxyapp: pass kernel image data to ProxyApp (google#3696)
Browse files Browse the repository at this point in the history
We need the kernel built by Syzkaller to start the VM.

If transfer_file_content is set, pass the image data in addition to the
path. It's sent in the CreatePool RPC, since future CreateInstance RPCs
should use the same image.
  • Loading branch information
kalder authored Feb 21, 2023
1 parent d21349b commit 42a4d50
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 10 deletions.
29 changes: 21 additions & 8 deletions vm/proxyapp/proxyappclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ func (p *pool) init(params *proxyAppParams, cfg *Config) error {

p.proxy.doLogPooling(params.LogOutput)

count, err := p.proxy.CreatePool(string(cfg.ProxyAppConfig), p.env.Debug)
count, err := p.proxy.CreatePool(cfg, p.env.Image, p.env.Debug)
if err != nil || count == 0 || (p.count != 0 && p.count != count) {
if err == nil {
err = fmt.Errorf("wrong pool size %v, prev was %v", count, p.count)
Expand Down Expand Up @@ -163,7 +163,7 @@ func (p *pool) Create(workdir string, index int) (vmimpl.Instance, error) {
return nil, fmt.Errorf("can't create instance using nil pool")
}

return proxy.CreateInstance(workdir, index)
return proxy.CreateInstance(workdir, p.env.Image, index)
}

// Close is not used now. Its support require wide code changes.
Expand Down Expand Up @@ -342,23 +342,36 @@ func (proxy *ProxyApp) doLogPooling(writer io.Writer) {
}()
}

func (proxy *ProxyApp) CreatePool(config string, debug bool) (int, error) {
func (proxy *ProxyApp) CreatePool(config *Config, image string, debug bool) (int, error) {
var reply proxyrpc.CreatePoolResult
params := proxyrpc.CreatePoolParams{
Debug: debug,
Param: string(config.ProxyAppConfig),
Image: image,
}

if config.TransferFileContent {
imageData, err := os.ReadFile(image)
if err != nil {
return 0, fmt.Errorf("read image on host: %v", err)
}

params.ImageData = imageData
}

err := proxy.Call(
"ProxyVM.CreatePool",
proxyrpc.CreatePoolParams{
Debug: debug,
Param: config,
},
params,
&reply)

if err != nil {
return 0, err
}

return reply.Count, nil
}

func (proxy *ProxyApp) CreateInstance(workdir string, index int) (vmimpl.Instance, error) {
func (proxy *ProxyApp) CreateInstance(workdir, image string, index int) (vmimpl.Instance, error) {
var reply proxyrpc.CreateInstanceResult

params := proxyrpc.CreateInstanceParams{
Expand Down
6 changes: 4 additions & 2 deletions vm/proxyapp/proxyrpc/proxyrpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@ type ProxyAppInterface interface {
}

type CreatePoolParams struct {
Debug bool
Param string
Debug bool
Param string
Image string
ImageData []byte
}

type CreatePoolResult struct {
Expand Down

0 comments on commit 42a4d50

Please sign in to comment.