[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v2 10/17] convert net_init_nic() to NetClientOptions
From: |
Laszlo Ersek |
Subject: |
[Qemu-devel] [PATCH v2 10/17] convert net_init_nic() to NetClientOptions |
Date: |
Wed, 13 Jun 2012 10:22:41 +0200 |
v1->v2:
- NetLegacyNicOptions::vectors is of type uint32
Signed-off-by: Laszlo Ersek <address@hidden>
---
net.c | 39 ++++++++++++++++++++++-----------------
1 files changed, 22 insertions(+), 17 deletions(-)
diff --git a/net.c b/net.c
index 2cf40a0..886961c 100644
--- a/net.c
+++ b/net.c
@@ -748,12 +748,15 @@ int net_handle_fd_param(Monitor *mon, const char *param)
return fd;
}
-static int net_init_nic(QemuOpts *opts, const NetClientOptions *new_opts,
+static int net_init_nic(QemuOpts *old_opts, const NetClientOptions *opts,
const char *name, VLANState *vlan)
{
int idx;
NICInfo *nd;
- const char *netdev;
+ const NetLegacyNicOptions *nic;
+
+ assert(opts->kind == NET_CLIENT_OPTIONS_KIND_NIC);
+ nic = opts->nic;
idx = nic_get_free_idx();
if (idx == -1 || nb_nics >= MAX_NICS) {
@@ -765,10 +768,10 @@ static int net_init_nic(QemuOpts *opts, const
NetClientOptions *new_opts,
memset(nd, 0, sizeof(*nd));
- if ((netdev = qemu_opt_get(opts, "netdev"))) {
- nd->netdev = qemu_find_netdev(netdev);
+ if (nic->has_netdev) {
+ nd->netdev = qemu_find_netdev(nic->netdev);
if (!nd->netdev) {
- error_report("netdev '%s' not found", netdev);
+ error_report("netdev '%s' not found", nic->netdev);
return -1;
}
} else {
@@ -778,26 +781,28 @@ static int net_init_nic(QemuOpts *opts, const
NetClientOptions *new_opts,
if (name) {
nd->name = g_strdup(name);
}
- if (qemu_opt_get(opts, "model")) {
- nd->model = g_strdup(qemu_opt_get(opts, "model"));
+ if (nic->has_model) {
+ nd->model = g_strdup(nic->model);
}
- if (qemu_opt_get(opts, "addr")) {
- nd->devaddr = g_strdup(qemu_opt_get(opts, "addr"));
+ if (nic->has_addr) {
+ nd->devaddr = g_strdup(nic->addr);
}
- if (qemu_opt_get(opts, "macaddr") &&
- net_parse_macaddr(nd->macaddr.a, qemu_opt_get(opts, "macaddr")) < 0) {
+ if (nic->has_macaddr &&
+ net_parse_macaddr(nd->macaddr.a, nic->macaddr) < 0) {
error_report("invalid syntax for ethernet address");
return -1;
}
qemu_macaddr_default_if_unset(&nd->macaddr);
- nd->nvectors = qemu_opt_get_number(opts, "vectors",
- DEV_NVECTORS_UNSPECIFIED);
- if (nd->nvectors != DEV_NVECTORS_UNSPECIFIED &&
- (nd->nvectors < 0 || nd->nvectors > 0x7ffffff)) {
- error_report("invalid # of vectors: %d", nd->nvectors);
- return -1;
+ if (nic->has_vectors) {
+ if (nic->vectors > 0x7ffffff) {
+ error_report("invalid # of vectors: %"PRIu32, nic->vectors);
+ return -1;
+ }
+ nd->nvectors = nic->vectors;
+ } else {
+ nd->nvectors = DEV_NVECTORS_UNSPECIFIED;
}
nd->used = 1;
--
1.7.1
- [Qemu-devel] [PATCH v2 00/17] introduce OptsVisitor, rebase -net/-netdev parsing, Laszlo Ersek, 2012/06/13
- [Qemu-devel] [PATCH v2 01/17] qapi: fix error propagation, Laszlo Ersek, 2012/06/13
- [Qemu-devel] [PATCH v2 03/17] qapi: introduce "size" type, Laszlo Ersek, 2012/06/13
- [Qemu-devel] [PATCH v2 07/17] qapi schema: add Netdev types, Laszlo Ersek, 2012/06/13
- [Qemu-devel] [PATCH v2 06/17] qapi schema: remove trailing whitespace, Laszlo Ersek, 2012/06/13
- [Qemu-devel] [PATCH v2 04/17] expose QemuOpt and QemuOpts struct definitions to interested parties, Laszlo Ersek, 2012/06/13
- [Qemu-devel] [PATCH v2 02/17] qapi: generate C types for fixed-width integers, Laszlo Ersek, 2012/06/13
- [Qemu-devel] [PATCH v2 12/17] convert net_init_slirp() to NetClientOptions, Laszlo Ersek, 2012/06/13
- [Qemu-devel] [PATCH v2 10/17] convert net_init_nic() to NetClientOptions,
Laszlo Ersek <=
- [Qemu-devel] [PATCH v2 13/17] convert net_init_socket() to NetClientOptions, Laszlo Ersek, 2012/06/13
- [Qemu-devel] [PATCH v2 08/17] hw, net: "net_client_type" -> "NetClientOptionsKind" (qapi-generated), Laszlo Ersek, 2012/06/13
- [Qemu-devel] [PATCH v2 17/17] remove unused QemuOpts parameter from net init functions, Laszlo Ersek, 2012/06/13
- [Qemu-devel] [PATCH v2 05/17] qapi: introduce OptsVisitor, Laszlo Ersek, 2012/06/13
- [Qemu-devel] [PATCH v2 14/17] convert net_init_vde() to NetClientOptions, Laszlo Ersek, 2012/06/13
- [Qemu-devel] [PATCH v2 11/17] convert net_init_dump() to NetClientOptions, Laszlo Ersek, 2012/06/13
- [Qemu-devel] [PATCH v2 15/17] convert net_init_tap() to NetClientOptions, Laszlo Ersek, 2012/06/13
- [Qemu-devel] [PATCH v2 16/17] convert net_init_bridge() to NetClientOptions, Laszlo Ersek, 2012/06/13