From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1LMoYV-0002JA-D8 for qemu-devel@nongnu.org; Tue, 13 Jan 2009 14:04:03 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1LMoYU-0002Ik-NO for qemu-devel@nongnu.org; Tue, 13 Jan 2009 14:04:03 -0500 Received: from [199.232.76.173] (port=52284 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LMoYU-0002Ib-He for qemu-devel@nongnu.org; Tue, 13 Jan 2009 14:04:02 -0500 Received: from savannah.gnu.org ([199.232.41.3]:53777 helo=sv.gnu.org) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1LMoYT-0006hj-Tc for qemu-devel@nongnu.org; Tue, 13 Jan 2009 14:04:02 -0500 Received: from cvs.savannah.gnu.org ([199.232.41.69]) by sv.gnu.org with esmtp (Exim 4.63) (envelope-from ) id 1LMoYQ-0005Sn-Ji for qemu-devel@nongnu.org; Tue, 13 Jan 2009 19:03:58 +0000 Received: from aliguori by cvs.savannah.gnu.org with local (Exim 4.63) (envelope-from ) id 1LMoYQ-0005Sj-DI for qemu-devel@nongnu.org; Tue, 13 Jan 2009 19:03:58 +0000 MIME-Version: 1.0 Errors-To: aliguori Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Anthony Liguori Message-Id: Date: Tue, 13 Jan 2009 19:03:58 +0000 Subject: [Qemu-devel] [6281] Add qemu_check_nic_model() and qemu_check_nic_model_list() ( Mark McLoughlin) Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Revision: 6281 http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=6281 Author: aliguori Date: 2009-01-13 19:03:57 +0000 (Tue, 13 Jan 2009) Log Message: ----------- Add qemu_check_nic_model() and qemu_check_nic_model_list() (Mark McLoughlin) Signed-off-by: Mark McLoughlin Signed-off-by: Anthony Liguori Modified Paths: -------------- trunk/net.c trunk/net.h Modified: trunk/net.c =================================================================== --- trunk/net.c 2009-01-13 16:28:01 UTC (rev 6280) +++ trunk/net.c 2009-01-13 19:03:57 UTC (rev 6281) @@ -1497,6 +1497,40 @@ 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]; Modified: trunk/net.h =================================================================== --- trunk/net.h 2009-01-13 16:28:01 UTC (rev 6280) +++ trunk/net.h 2009-01-13 19:03:57 UTC (rev 6281) @@ -47,6 +47,9 @@ 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);