From: Mark McLoughlin <markmc@redhat.com>
To: Anthony Liguori <anthony@codemonkey.ws>
Cc: qemu-devel@nongnu.org, Mark McLoughlin <markmc@redhat.com>
Subject: [Qemu-devel] [PATCH 1/4] Add qemu_check_nic_model() and qemu_check_nic_model_list()
Date: Thu, 8 Jan 2009 14:47:46 +0000 [thread overview]
Message-ID: <1231426069-28321-1-git-send-email-markmc@redhat.com> (raw)
In-Reply-To: <1231425939.4296.79.camel@localhost.localdomain>
Signed-off-by: Mark McLoughlin <markmc@redhat.com>
---
net.c | 34 ++++++++++++++++++++++++++++++++++
net.h | 3 +++
2 files changed, 37 insertions(+), 0 deletions(-)
diff --git a/net.c b/net.c
index 15f9153..4609be2 100644
--- a/net.c
+++ b/net.c
@@ -1491,6 +1491,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 b89d165..19ab649 100644
--- a/net.h
+++ b/net.h
@@ -43,6 +43,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);
--
1.6.0.6
next prev parent reply other threads:[~2009-01-08 14:47 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-01-07 17:42 [Qemu-devel] [6216] Add a model string to VLANClientState (Mark McLoughlin) Anthony Liguori
2009-01-07 19:23 ` Stefan Weil
2009-01-08 14:45 ` Mark McLoughlin
2009-01-08 14:47 ` Mark McLoughlin [this message]
2009-01-08 14:47 ` [Qemu-devel] [PATCH 2/4] Check NIC model in some NIC init functions Mark McLoughlin
2009-01-08 14:47 ` [Qemu-devel] [PATCH 3/4] Make virtio_net_init() return void Mark McLoughlin
2009-01-08 14:47 ` [Qemu-devel] [PATCH 4/4] Make pci_nic_init() use qemu_setup_nic_model() Mark McLoughlin
2009-01-13 19:25 ` [Qemu-devel] [PATCH 1/3] Check NIC model in some NIC init functions Mark McLoughlin
2009-01-13 19:25 ` [Qemu-devel] [PATCH 2/3] Make virtio_net_init() return void Mark McLoughlin
2009-01-13 19:25 ` [Qemu-devel] [PATCH 3/3] Make pci_nic_init() use qemu_setup_nic_model() Mark McLoughlin
2009-01-13 19:47 ` [Qemu-devel] Re: [PATCH 1/3] Check NIC model in some NIC init functions Anthony Liguori
2009-01-13 20:59 ` Sylvain Petreolle
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1231426069-28321-1-git-send-email-markmc@redhat.com \
--to=markmc@redhat.com \
--cc=anthony@codemonkey.ws \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).