diff --git a/virtcontainers/qemu.go b/virtcontainers/qemu.go index 8258be2fb..5b846f69a 100644 --- a/virtcontainers/qemu.go +++ b/virtcontainers/qemu.go @@ -94,8 +94,9 @@ const ( qmpExecCatCmd = "exec:cat" qmpMigrationWaitTimeout = 5 * time.Second - scsiControllerID = "scsi0" - rngID = "rng0" + scsiControllerID = "scsi0" + rngID = "rng0" + vsockKernelOption = "agent.use_vsock" ) var qemuMajorVersion int @@ -152,6 +153,11 @@ func (q *qemu) kernelParameters() string { // set the maximum number of vCPUs params = append(params, Param{"nr_cpus", fmt.Sprintf("%d", q.config.DefaultMaxVCPUs)}) + // Add a kernel param to indicate if vsock is being used. + // This will be consumed by the agent to determine if it needs to listen on + // a serial or vsock channel + params = append(params, Param{vsockKernelOption, strconv.FormatBool(q.config.UseVSock)}) + // add the params specified by the provided config. As the kernel // honours the last parameter value set and since the config-provided // params are added here, they will take priority over the defaults. diff --git a/virtcontainers/qemu_test.go b/virtcontainers/qemu_test.go index a2d7e4ac7..28b4f3cd6 100644 --- a/virtcontainers/qemu_test.go +++ b/virtcontainers/qemu_test.go @@ -56,7 +56,7 @@ func testQemuKernelParameters(t *testing.T, kernelParams []Param, expected strin } func TestQemuKernelParameters(t *testing.T) { - expectedOut := fmt.Sprintf("panic=1 nr_cpus=%d foo=foo bar=bar", MaxQemuVCPUs()) + expectedOut := fmt.Sprintf("panic=1 nr_cpus=%d agent.use_vsock=false foo=foo bar=bar", MaxQemuVCPUs()) params := []Param{ { Key: "foo",