]> Git Repo - qemu.git/commitdiff
Add qemu_check_nic_model() and qemu_check_nic_model_list() (Mark McLoughlin)
authoraliguori <aliguori@c046a42c-6fe2-441c-8c8c-71466251a162>
Tue, 13 Jan 2009 19:03:57 +0000 (19:03 +0000)
committeraliguori <aliguori@c046a42c-6fe2-441c-8c8c-71466251a162>
Tue, 13 Jan 2009 19:03:57 +0000 (19:03 +0000)
Signed-off-by: Mark McLoughlin <[email protected]>
Signed-off-by: Anthony Liguori <[email protected]>
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6281 c046a42c-6fe2-441c-8c8c-71466251a162

net.c
net.h

diff --git a/net.c b/net.c
index 30ba71791c4c56013fd5f455681d123612733b1f..8bba09c104a28cd87bad6bbd1d620fdb1262c28d 100644 (file)
--- 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];
diff --git a/net.h b/net.h
index e79ee3d70a71d9fb297775246b3e75661494efca..291807a65c6cba89e6976bdce5addbbfbe6fdf74 100644 (file)
--- a/net.h
+++ b/net.h
@@ -47,6 +47,9 @@ ssize_t qemu_sendv_packet(VLANClientState *vc, const struct iovec *iov,
                           int iovcnt);
 void qemu_send_packet(VLANClientState *vc, const uint8_t *buf, int size);
 void qemu_format_nic_info_str(VLANClientState *vc, uint8_t macaddr[6]);
+void qemu_check_nic_model(NICInfo *nd, const char *model);
+void qemu_check_nic_model_list(NICInfo *nd, const char * const *models,
+                               const char *default_model);
 void qemu_handler_true(void *opaque);
 
 void do_info_network(void);
This page took 0.0323369999999999 seconds and 4 git commands to generate.