Skip to content

Commit

Permalink
Drivers: hv: vmbus: Add module parameter to cap the VMBus version
Browse files Browse the repository at this point in the history
Currently, Linux guests negotiate the VMBus version with Hyper-V
and use the highest available VMBus version they can connect to.
This has some drawbacks: by using the highest available version,
certain code paths are never executed and can not be tested when
the guest runs on the newest host.

Add the module parameter "max_version", to upper-bound the VMBus
versions guests can negotiate.

Suggested-by: Dexuan Cui <[email protected]>
Signed-off-by: Andrea Parri <[email protected]>
Reviewed-by: Wei Liu <[email protected]>
Reviewed-by: Michael Kelley <[email protected]>
Signed-off-by: Sasha Levin <[email protected]>
  • Loading branch information
Andrea Parri authored and Sasha Levin committed Nov 22, 2019
1 parent 2d4f49b commit 931cccc
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions drivers/hv/connection.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include <linux/wait.h>
#include <linux/delay.h>
#include <linux/mm.h>
#include <linux/module.h>
#include <linux/slab.h>
#include <linux/vmalloc.h>
#include <linux/hyperv.h>
Expand Down Expand Up @@ -55,6 +56,16 @@ static __u32 vmbus_versions[] = {
VERSION_WS2008
};

/*
* Maximal VMBus protocol version guests can negotiate. Useful to cap the
* VMBus version for testing and debugging purpose.
*/
static uint max_version = VERSION_WIN10_V5_2;

module_param(max_version, uint, S_IRUGO);
MODULE_PARM_DESC(max_version,
"Maximal VMBus protocol version which can be negotiated");

int vmbus_negotiate_version(struct vmbus_channel_msginfo *msginfo, u32 version)
{
int ret = 0;
Expand Down Expand Up @@ -240,6 +251,8 @@ int vmbus_connect(void)
goto cleanup;

version = vmbus_versions[i];
if (version > max_version)
continue;

ret = vmbus_negotiate_version(msginfo, version);
if (ret == -ETIMEDOUT)
Expand Down

0 comments on commit 931cccc

Please sign in to comment.