Commit d07f22c53051472ea26618821941a060b63d5453
1 parent
5a377912
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
Showing
2 changed files
with
37 additions
and
0 deletions
net.c
@@ -1497,6 +1497,40 @@ VLANState *qemu_find_vlan(int id) | @@ -1497,6 +1497,40 @@ VLANState *qemu_find_vlan(int id) | ||
1497 | return vlan; | 1497 | return vlan; |
1498 | } | 1498 | } |
1499 | 1499 | ||
1500 | +void qemu_check_nic_model(NICInfo *nd, const char *model) | ||
1501 | +{ | ||
1502 | + const char *models[2]; | ||
1503 | + | ||
1504 | + models[0] = model; | ||
1505 | + models[1] = NULL; | ||
1506 | + | ||
1507 | + qemu_check_nic_model_list(nd, models, model); | ||
1508 | +} | ||
1509 | + | ||
1510 | +void qemu_check_nic_model_list(NICInfo *nd, const char * const *models, | ||
1511 | + const char *default_model) | ||
1512 | +{ | ||
1513 | + int i, exit_status = 0; | ||
1514 | + | ||
1515 | + if (!nd->model) | ||
1516 | + nd->model = strdup(default_model); | ||
1517 | + | ||
1518 | + if (strcmp(nd->model, "?") != 0) { | ||
1519 | + for (i = 0 ; models[i]; i++) | ||
1520 | + if (strcmp(nd->model, models[i]) == 0) | ||
1521 | + return; | ||
1522 | + | ||
1523 | + fprintf(stderr, "qemu: Unsupported NIC model: %s\n", nd->model); | ||
1524 | + exit_status = 1; | ||
1525 | + } | ||
1526 | + | ||
1527 | + fprintf(stderr, "qemu: Supported NIC models: "); | ||
1528 | + for (i = 0 ; models[i]; i++) | ||
1529 | + fprintf(stderr, "%s%c", models[i], models[i+1] ? ',' : '\n'); | ||
1530 | + | ||
1531 | + exit(exit_status); | ||
1532 | +} | ||
1533 | + | ||
1500 | int net_client_init(const char *device, const char *p) | 1534 | int net_client_init(const char *device, const char *p) |
1501 | { | 1535 | { |
1502 | char buf[1024]; | 1536 | char buf[1024]; |
net.h
@@ -47,6 +47,9 @@ ssize_t qemu_sendv_packet(VLANClientState *vc, const struct iovec *iov, | @@ -47,6 +47,9 @@ ssize_t qemu_sendv_packet(VLANClientState *vc, const struct iovec *iov, | ||
47 | int iovcnt); | 47 | int iovcnt); |
48 | void qemu_send_packet(VLANClientState *vc, const uint8_t *buf, int size); | 48 | void qemu_send_packet(VLANClientState *vc, const uint8_t *buf, int size); |
49 | void qemu_format_nic_info_str(VLANClientState *vc, uint8_t macaddr[6]); | 49 | void qemu_format_nic_info_str(VLANClientState *vc, uint8_t macaddr[6]); |
50 | +void qemu_check_nic_model(NICInfo *nd, const char *model); | ||
51 | +void qemu_check_nic_model_list(NICInfo *nd, const char * const *models, | ||
52 | + const char *default_model); | ||
50 | void qemu_handler_true(void *opaque); | 53 | void qemu_handler_true(void *opaque); |
51 | 54 | ||
52 | void do_info_network(void); | 55 | void do_info_network(void); |