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 <archana.m.shinde@intel.com>
This commit is contained in:
Archana Shinde 2019-04-01 21:56:25 -07:00
parent c89eb81dec
commit 57b103a81b
2 changed files with 9 additions and 3 deletions

View File

@ -96,6 +96,7 @@ const (
scsiControllerID = "scsi0" scsiControllerID = "scsi0"
rngID = "rng0" rngID = "rng0"
vsockKernelOption = "agent.use_vsock"
) )
var qemuMajorVersion int var qemuMajorVersion int
@ -152,6 +153,11 @@ func (q *qemu) kernelParameters() string {
// set the maximum number of vCPUs // set the maximum number of vCPUs
params = append(params, Param{"nr_cpus", fmt.Sprintf("%d", q.config.DefaultMaxVCPUs)}) 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 // add the params specified by the provided config. As the kernel
// honours the last parameter value set and since the config-provided // honours the last parameter value set and since the config-provided
// params are added here, they will take priority over the defaults. // params are added here, they will take priority over the defaults.

View File

@ -56,7 +56,7 @@ func testQemuKernelParameters(t *testing.T, kernelParams []Param, expected strin
} }
func TestQemuKernelParameters(t *testing.T) { 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{ params := []Param{
{ {
Key: "foo", Key: "foo",