aboutsummaryrefslogtreecommitdiff
path: root/net.c
diff options
context:
space:
mode:
authoraliguori <aliguori@c046a42c-6fe2-441c-8c8c-71466251a162>2009-01-13 19:03:57 +0000
committeraliguori <aliguori@c046a42c-6fe2-441c-8c8c-71466251a162>2009-01-13 19:03:57 +0000
commitd07f22c53051472ea26618821941a060b63d5453 (patch)
tree72d85c12f0e0569a67ca29100650be272a9cc054 /net.c
parent5a37791249c2dc6fe788fcb618a9dd9531695b84 (diff)
Add qemu_check_nic_model() and qemu_check_nic_model_list() (Mark McLoughlin)
Signed-off-by: Mark McLoughlin <markmc@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6281 c046a42c-6fe2-441c-8c8c-71466251a162
Diffstat (limited to 'net.c')
-rw-r--r--net.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/net.c b/net.c
index 30ba71791c..8bba09c104 100644
--- a/net.c
+++ b/net.c
@@ -1497,6 +1497,40 @@ VLANState *qemu_find_vlan(int id)
return vlan;
}
+void qemu_check_nic_model(NICInfo *nd, const char *model)
+{
+ const char *models[2];
+
+ models[0] = model;
+ models[1] = NULL;
+
+ qemu_check_nic_model_list(nd, models, model);
+}
+
+void qemu_check_nic_model_list(NICInfo *nd, const char * const *models,
+ const char *default_model)
+{
+ int i, exit_status = 0;
+
+ if (!nd->model)
+ nd->model = strdup(default_model);
+
+ if (strcmp(nd->model, "?") != 0) {
+ for (i = 0 ; models[i]; i++)
+ if (strcmp(nd->model, models[i]) == 0)
+ return;
+
+ fprintf(stderr, "qemu: Unsupported NIC model: %s\n", nd->model);
+ exit_status = 1;
+ }
+
+ fprintf(stderr, "qemu: Supported NIC models: ");
+ for (i = 0 ; models[i]; i++)
+ fprintf(stderr, "%s%c", models[i], models[i+1] ? ',' : '\n');
+
+ exit(exit_status);
+}
+
int net_client_init(const char *device, const char *p)
{
char buf[1024];