From 57b103a81b905728099d76eec70ed167eaa4d43f Mon Sep 17 00:00:00 2001 From: Archana Shinde Date: Mon, 1 Apr 2019 21:56:25 -0700 Subject: [PATCH] vsock: Pass info about vsock being used or not to the agent. Instead of the agent trying to determine if a serial or vsock channel is used, pass this information explicitly as a kernel command line option. Fixes #1457 Signed-off-by: Archana Shinde --- virtcontainers/qemu.go | 10 ++++++++-- virtcontainers/qemu_test.go | 2 +- 2 files changed, 9 insertions(+), 3 deletions(-) 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",