qemu/net: flag to control the number of vectors a nic has

Add an option to specify the number of MSI-X vectors for PCI NIC cards. This
can also be used to disable MSI-X, for compatibility with old qemu. This
option currently only affects virtio cards.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
This commit is contained in:
Michael S. Tsirkin 2009-06-21 19:51:18 +03:00 committed by Anthony Liguori
parent 566e2d3e88
commit ffe6370c9f
4 changed files with 33 additions and 8 deletions

18
net.c
View file

@ -2169,7 +2169,7 @@ int net_client_init(Monitor *mon, const char *device, const char *p)
}
if (!strcmp(device, "nic")) {
static const char * const nic_params[] = {
"vlan", "name", "macaddr", "model", "addr", NULL
"vlan", "name", "macaddr", "model", "addr", "vectors", NULL
};
NICInfo *nd;
uint8_t *macaddr;
@ -2207,6 +2207,22 @@ int net_client_init(Monitor *mon, const char *device, const char *p)
if (get_param_value(buf, sizeof(buf), "addr", p)) {
nd->devaddr = strdup(buf);
}
nd->nvectors = NIC_NVECTORS_UNSPECIFIED;
if (get_param_value(buf, sizeof(buf), "vectors", p)) {
char *endptr;
long vectors = strtol(buf, &endptr, 0);
if (*endptr) {
config_error(mon, "invalid syntax for # of vectors\n");
ret = -1;
goto out;
}
if (vectors < 0 || vectors > 0x7ffffff) {
config_error(mon, "invalid # of vectors\n");
ret = -1;
goto out;
}
nd->nvectors = vectors;
}
nd->vlan = vlan;
nd->name = name;
nd->used = 1;