From patchwork Thu Nov 12 20:28:59 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark McLoughlin X-Patchwork-Id: 38276 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 0AC3CB7BA5 for ; Fri, 13 Nov 2009 07:41:48 +1100 (EST) Received: from localhost ([127.0.0.1]:58414 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1N8gUD-00079M-2s for incoming@patchwork.ozlabs.org; Thu, 12 Nov 2009 15:41:45 -0500 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1N8gKU-0003FW-Jd for qemu-devel@nongnu.org; Thu, 12 Nov 2009 15:31:42 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1N8gKP-0003CH-L4 for qemu-devel@nongnu.org; Thu, 12 Nov 2009 15:31:41 -0500 Received: from [199.232.76.173] (port=58768 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1N8gKO-0003BZ-4V for qemu-devel@nongnu.org; Thu, 12 Nov 2009 15:31:36 -0500 Received: from mx1.redhat.com ([209.132.183.28]:40905) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1N8gKN-0005Aw-Bq for qemu-devel@nongnu.org; Thu, 12 Nov 2009 15:31:35 -0500 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id nACKVYJo030274 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 12 Nov 2009 15:31:34 -0500 Received: from blaa.localdomain (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id nACKVXRR001127; Thu, 12 Nov 2009 15:31:34 -0500 Received: by blaa.localdomain (Postfix, from userid 500) id 53D4B62C3; Thu, 12 Nov 2009 20:29:03 +0000 (GMT) From: Mark McLoughlin To: qemu-devel@nongnu.org Date: Thu, 12 Nov 2009 20:28:59 +0000 Message-Id: <1258057742-18699-5-git-send-email-markmc@redhat.com> In-Reply-To: <1258057742-18699-1-git-send-email-markmc@redhat.com> References: <1258057742-18699-1-git-send-email-markmc@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.11 X-detected-operating-system: by monty-python.gnu.org: Genre and OS details not recognized. Cc: Mark McLoughlin , kraxel@redhat.com, quintela@redhat.com Subject: [Qemu-devel] [PATCH 4/7] net: kill off NICInfo/NICConf::vlan/netdev X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org No valid users left except the announce_self() code which currently crashes when used with -netdev. Note the assertion in the xen code. Need to figure out how to support the -netdev arg with xen. Signed-off-by: Mark McLoughlin --- hw/integratorcp.c | 3 +- hw/mcf5208.c | 3 +- hw/mips_mipssim.c | 3 +- hw/mips_r4k.c | 3 +- hw/qdev-properties.c | 75 -------------------------------------------------- hw/qdev.c | 4 -- hw/qdev.h | 10 ------ hw/syborg.c | 2 +- hw/xen_devconfig.c | 9 +++-- net.c | 20 ++++++------ net.h | 8 +---- savevm.c | 4 ++ 12 files changed, 29 insertions(+), 115 deletions(-) diff --git a/hw/integratorcp.c b/hw/integratorcp.c index bee8298..9ce141d 100644 --- a/hw/integratorcp.c +++ b/hw/integratorcp.c @@ -497,8 +497,9 @@ static void integratorcp_init(ram_addr_t ram_size, sysbus_create_simple("pl050_keyboard", 0x18000000, pic[3]); sysbus_create_simple("pl050_mouse", 0x19000000, pic[4]); sysbus_create_varargs("pl181", 0x1c000000, pic[23], pic[24], NULL); - if (nd_table[0].vlan) + if (nd_table[0].used) { smc91c111_init(&nd_table[0], 0xc8000000, pic[27]); + } sysbus_create_simple("pl110", 0xc0000000, pic[22]); diff --git a/hw/mcf5208.c b/hw/mcf5208.c index 5598611..a939cb0 100644 --- a/hw/mcf5208.c +++ b/hw/mcf5208.c @@ -239,8 +239,9 @@ static void mcf5208evb_init(ram_addr_t ram_size, fprintf(stderr, "Too many NICs\n"); exit(1); } - if (nd_table[0].vlan) + if (nd_table[0].used) { mcf_fec_init(&nd_table[0], 0xfc030000, pic + 36); + } /* 0xfc000000 SCM. */ /* 0xfc004000 XBS. */ diff --git a/hw/mips_mipssim.c b/hw/mips_mipssim.c index 9aed40e..5cdfe00 100644 --- a/hw/mips_mipssim.c +++ b/hw/mips_mipssim.c @@ -187,9 +187,10 @@ mips_mipssim_init (ram_addr_t ram_size, if (serial_hds[0]) serial_init(0x3f8, env->irq[4], 115200, serial_hds[0]); - if (nd_table[0].vlan) + if (nd_table[0].used) { /* MIPSnet uses the MIPS CPU INT0, which is interrupt 2. */ mipsnet_init(0x4200, env->irq[2], &nd_table[0]); + } } static QEMUMachine mips_mipssim_machine = { diff --git a/hw/mips_r4k.c b/hw/mips_r4k.c index d525c63..442eda3 100644 --- a/hw/mips_r4k.c +++ b/hw/mips_r4k.c @@ -265,8 +265,9 @@ void mips_r4k_init (ram_addr_t ram_size, isa_vga_init(); - if (nd_table[0].vlan) + if (nd_table[0].used) { isa_ne2000_init(0x300, 9, &nd_table[0]); + } if (drive_get_max_bus(IF_IDE) >= MAX_IDE_BUS) { fprintf(stderr, "qemu: too many IDE bus\n"); diff --git a/hw/qdev-properties.c b/hw/qdev-properties.c index 8ce0de7..fe40813 100644 --- a/hw/qdev-properties.c +++ b/hw/qdev-properties.c @@ -299,71 +299,6 @@ PropertyInfo qdev_prop_net_client = { .print = print_net_client, }; -/* --- netdev device --- */ - -static int parse_netdev(DeviceState *dev, Property *prop, const char *str) -{ - VLANClientState **ptr = qdev_get_prop_ptr(dev, prop); - - *ptr = qemu_find_netdev(str); - if (*ptr == NULL) - return -1; - return 0; -} - -static int print_netdev(DeviceState *dev, Property *prop, char *dest, size_t len) -{ - VLANClientState **ptr = qdev_get_prop_ptr(dev, prop); - - if (*ptr && (*ptr)->name) { - return snprintf(dest, len, "%s", (*ptr)->name); - } else { - return snprintf(dest, len, ""); - } -} - -PropertyInfo qdev_prop_netdev = { - .name = "netdev", - .type = PROP_TYPE_NETDEV, - .size = sizeof(VLANClientState*), - .parse = parse_netdev, - .print = print_netdev, -}; - -/* --- vlan --- */ - -static int parse_vlan(DeviceState *dev, Property *prop, const char *str) -{ - VLANState **ptr = qdev_get_prop_ptr(dev, prop); - int id; - - if (sscanf(str, "%d", &id) != 1) - return -1; - *ptr = qemu_find_vlan(id, 1); - if (*ptr == NULL) - return -1; - return 0; -} - -static int print_vlan(DeviceState *dev, Property *prop, char *dest, size_t len) -{ - VLANState **ptr = qdev_get_prop_ptr(dev, prop); - - if (*ptr) { - return snprintf(dest, len, "%d", (*ptr)->id); - } else { - return snprintf(dest, len, ""); - } -} - -PropertyInfo qdev_prop_vlan = { - .name = "vlan", - .type = PROP_TYPE_VLAN, - .size = sizeof(VLANClientState*), - .parse = parse_vlan, - .print = print_vlan, -}; - /* --- pointer --- */ static int print_ptr(DeviceState *dev, Property *prop, char *dest, size_t len) @@ -583,16 +518,6 @@ void qdev_prop_set_net_client(DeviceState *dev, const char *name, VLANClientStat qdev_prop_set(dev, name, &value, PROP_TYPE_NET_CLIENT); } -void qdev_prop_set_netdev(DeviceState *dev, const char *name, VLANClientState *value) -{ - qdev_prop_set(dev, name, &value, PROP_TYPE_NETDEV); -} - -void qdev_prop_set_vlan(DeviceState *dev, const char *name, VLANState *value) -{ - qdev_prop_set(dev, name, &value, PROP_TYPE_VLAN); -} - void qdev_prop_set_macaddr(DeviceState *dev, const char *name, uint8_t *value) { qdev_prop_set(dev, name, value, PROP_TYPE_MACADDR); diff --git a/hw/qdev.c b/hw/qdev.c index 757b285..b8ab449 100644 --- a/hw/qdev.c +++ b/hw/qdev.c @@ -369,10 +369,6 @@ void qdev_set_nic_properties(DeviceState *dev, NICInfo *nd) if (nd->vc) { qdev_prop_set_net_client(dev, "net-client", nd->vc); } - if (nd->vlan) - qdev_prop_set_vlan(dev, "vlan", nd->vlan); - if (nd->netdev) - qdev_prop_set_netdev(dev, "netdev", nd->netdev); if (nd->nvectors != NIC_NVECTORS_UNSPECIFIED && qdev_prop_exists(dev, "vectors")) { qdev_prop_set_uint32(dev, "vectors", nd->nvectors); diff --git a/hw/qdev.h b/hw/qdev.h index 3e1510f..26e372c 100644 --- a/hw/qdev.h +++ b/hw/qdev.h @@ -80,8 +80,6 @@ enum PropertyType { PROP_TYPE_CHR, PROP_TYPE_STRING, PROP_TYPE_NET_CLIENT, - PROP_TYPE_NETDEV, - PROP_TYPE_VLAN, PROP_TYPE_PTR, }; @@ -196,8 +194,6 @@ extern PropertyInfo qdev_prop_ptr; extern PropertyInfo qdev_prop_macaddr; extern PropertyInfo qdev_prop_drive; extern PropertyInfo qdev_prop_net_client; -extern PropertyInfo qdev_prop_netdev; -extern PropertyInfo qdev_prop_vlan; extern PropertyInfo qdev_prop_pci_devfn; #define DEFINE_PROP(_name, _state, _field, _prop, _type) { \ @@ -239,10 +235,6 @@ extern PropertyInfo qdev_prop_pci_devfn; DEFINE_PROP(_n, _s, _f, qdev_prop_string, char*) #define DEFINE_PROP_NET_CLIENT(_n, _s, _f) \ DEFINE_PROP(_n, _s, _f, qdev_prop_net_client, VLANClientState *) -#define DEFINE_PROP_NETDEV(_n, _s, _f) \ - DEFINE_PROP(_n, _s, _f, qdev_prop_netdev, VLANClientState*) -#define DEFINE_PROP_VLAN(_n, _s, _f) \ - DEFINE_PROP(_n, _s, _f, qdev_prop_vlan, VLANState*) #define DEFINE_PROP_DRIVE(_n, _s, _f) \ DEFINE_PROP(_n, _s, _f, qdev_prop_drive, DriveInfo*) #define DEFINE_PROP_MACADDR(_n, _s, _f) \ @@ -263,8 +255,6 @@ void qdev_prop_set_int32(DeviceState *dev, const char *name, int32_t value); void qdev_prop_set_uint64(DeviceState *dev, const char *name, uint64_t value); void qdev_prop_set_chr(DeviceState *dev, const char *name, CharDriverState *value); void qdev_prop_set_net_client(DeviceState *dev, const char *name, VLANClientState *value); -void qdev_prop_set_netdev(DeviceState *dev, const char *name, VLANClientState *value); -void qdev_prop_set_vlan(DeviceState *dev, const char *name, VLANState *value); void qdev_prop_set_drive(DeviceState *dev, const char *name, DriveInfo *value); void qdev_prop_set_macaddr(DeviceState *dev, const char *name, uint8_t *value); /* FIXME: Remove opaque pointer properties. */ diff --git a/hw/syborg.c b/hw/syborg.c index 2d08cb2..e6a888c 100644 --- a/hw/syborg.c +++ b/hw/syborg.c @@ -77,7 +77,7 @@ static void syborg_init(ram_addr_t ram_size, sysbus_create_simple("syborg,serial", 0xC0008000, pic[7]); sysbus_create_simple("syborg,serial", 0xC0009000, pic[8]); - if (nd_table[0].vlan || nd_table[0].netdev) { + if (nd_table[0].used) { DeviceState *dev; SysBusDevice *s; diff --git a/hw/xen_devconfig.c b/hw/xen_devconfig.c index ea8f8c4..7bda4d0 100644 --- a/hw/xen_devconfig.c +++ b/hw/xen_devconfig.c @@ -126,15 +126,16 @@ int xen_config_dev_nic(NICInfo *nic) snprintf(mac, sizeof(mac), "%02x:%02x:%02x:%02x:%02x:%02x", nic->macaddr[0], nic->macaddr[1], nic->macaddr[2], nic->macaddr[3], nic->macaddr[4], nic->macaddr[5]); - xen_be_printf(NULL, 1, "config nic %d: mac=\"%s\"\n", nic->vlan->id, mac); - xen_config_dev_dirs("vif", "qnic", nic->vlan->id, fe, be, sizeof(fe)); + assert(nic->vc && nic->vc->vlan); + xen_be_printf(NULL, 1, "config nic %d: mac=\"%s\"\n", nic->vc->vlan->id, mac); + xen_config_dev_dirs("vif", "qnic", nic->vc->vlan->id, fe, be, sizeof(fe)); /* frontend */ - xenstore_write_int(fe, "handle", nic->vlan->id); + xenstore_write_int(fe, "handle", nic->vc->vlan->id); xenstore_write_str(fe, "mac", mac); /* backend */ - xenstore_write_int(be, "handle", nic->vlan->id); + xenstore_write_int(be, "handle", nic->vc->vlan->id); xenstore_write_str(be, "mac", mac); /* common stuff */ diff --git a/net.c b/net.c index e90084d..44416b3 100644 --- a/net.c +++ b/net.c @@ -2055,7 +2055,8 @@ static int net_init_nic(QemuOpts *opts, { int idx; NICInfo *nd; - const char *netdev; + const char *netdev_str; + VLANClientState *netdev = NULL; idx = nic_get_free_idx(); if (idx == -1 || nb_nics >= MAX_NICS) { @@ -2067,15 +2068,14 @@ static int net_init_nic(QemuOpts *opts, memset(nd, 0, sizeof(*nd)); - if ((netdev = qemu_opt_get(opts, "netdev"))) { - nd->netdev = qemu_find_netdev(netdev); - if (!nd->netdev) { - qemu_error("netdev '%s' not found\n", netdev); + if ((netdev_str = qemu_opt_get(opts, "netdev"))) { + netdev = qemu_find_netdev(netdev_str); + if (!netdev) { + qemu_error("netdev '%s' not found\n", netdev_str); return -1; } } else { assert(vlan); - nd->vlan = vlan; } if (name) { nd->name = qemu_strdup(name); @@ -2108,13 +2108,13 @@ static int net_init_nic(QemuOpts *opts, } nd->vc = qemu_new_vlan_client(NET_CLIENT_TYPE_NIC, - nd->vlan, nd->netdev, + vlan, netdev, nd->model, nd->name, NULL, NULL, NULL, NULL, NULL, NULL); nd->used = 1; if (vlan) { - nd->vlan->nb_guest_devs++; + vlan->nb_guest_devs++; } nb_nics++; @@ -2651,8 +2651,8 @@ int net_client_init(Monitor *mon, QemuOpts *opts, int is_netdev) void net_client_uninit(NICInfo *nd) { - if (nd->vlan) { - nd->vlan->nb_guest_devs--; + if (nd->vc && nd->vc->vlan) { + nd->vc->vlan->nb_guest_devs--; } nb_nics--; diff --git a/net.h b/net.h index 83e50ab..53d643b 100644 --- a/net.h +++ b/net.h @@ -16,15 +16,11 @@ struct MACAddr { typedef struct NICConf { VLANClientState *client; MACAddr macaddr; - VLANState *vlan; - VLANClientState *peer; } NICConf; #define DEFINE_NIC_PROPERTIES(_state, _conf) \ DEFINE_PROP_NET_CLIENT("net-client", _state, _conf.client), \ - DEFINE_PROP_MACADDR("mac", _state, _conf.macaddr), \ - DEFINE_PROP_VLAN("vlan", _state, _conf.vlan), \ - DEFINE_PROP_NETDEV("netdev", _state, _conf.peer) + DEFINE_PROP_MACADDR("mac", _state, _conf.macaddr) /* VLANs support */ @@ -124,8 +120,6 @@ struct NICInfo { char *model; char *name; char *devaddr; - VLANState *vlan; - VLANClientState *netdev; VLANClientState *vc; void *private; int used; diff --git a/savevm.c b/savevm.c index 74f2c66..039740c 100644 --- a/savevm.c +++ b/savevm.c @@ -126,8 +126,10 @@ static int announce_self_create(uint8_t *buf, static void qemu_announce_self_once(void *opaque) { int i, len; +#ifdef FIXME VLANState *vlan; VLANClientState *vc; +#endif uint8_t buf[60]; static int count = SELF_ANNOUNCE_ROUNDS; QEMUTimer *timer = *(QEMUTimer **)opaque; @@ -136,10 +138,12 @@ static void qemu_announce_self_once(void *opaque) if (!nd_table[i].used) continue; len = announce_self_create(buf, nd_table[i].macaddr); +#ifdef FIXME vlan = nd_table[i].vlan; QTAILQ_FOREACH(vc, &vlan->clients, next) { qemu_send_packet_raw(vc, buf, len); } +#endif } if (--count) { /* delay 50ms, 150ms, 250ms, ... */