提交 48e2faf2 编写于 作者: P Peter Maydell 提交者: Anthony Liguori

net: Warn about "-net nic" options which were ignored

Diagnose the case where the user asked for a NIC via "-net nic"
but the board didn't instantiate that NIC (for example where the
user asked for two NICs but the board only supports one). Note
that this diagnostic doesn't apply to NICs created through -device,
because those are always instantiated.
Signed-off-by: NPeter Maydell <peter.maydell@linaro.org>
Signed-off-by: NAnthony Liguori <aliguori@us.ibm.com>
上级 641f6eae
......@@ -468,6 +468,7 @@ void qdev_set_nic_properties(DeviceState *dev, NICInfo *nd)
qdev_prop_exists(dev, "vectors")) {
qdev_prop_set_uint32(dev, "vectors", nd->nvectors);
}
nd->instantiated = 1;
}
BusState *qdev_get_child_bus(DeviceState *dev, const char *name)
......
......@@ -1304,6 +1304,7 @@ void net_check_clients(void)
{
VLANState *vlan;
VLANClientState *vc;
int i;
/* Don't warn about the default network setup that you get if
* no command line -net or -netdev options are specified. There
......@@ -1348,6 +1349,20 @@ void net_check_clients(void)
vc->name);
}
}
/* Check that all NICs requested via -net nic actually got created.
* NICs created via -device don't need to be checked here because
* they are always instantiated.
*/
for (i = 0; i < MAX_NICS; i++) {
NICInfo *nd = &nd_table[i];
if (nd->used && !nd->instantiated) {
fprintf(stderr, "Warning: requested NIC (%s, model %s) "
"was not created (not supported by this machine?)\n",
nd->name ? nd->name : "anonymous",
nd->model ? nd->model : "unspecified");
}
}
}
static int net_init_client(QemuOpts *opts, void *dummy)
......
......@@ -133,7 +133,8 @@ struct NICInfo {
char *devaddr;
VLANState *vlan;
VLANClientState *netdev;
int used;
int used; /* is this slot in nd_table[] being used? */
int instantiated; /* does this NICInfo correspond to an instantiated NIC? */
int nvectors;
};
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册