mirror of https://github.com/xqemu/xqemu.git
Merge remote-tracking branch 'stefanha/net' into staging
* stefanha/net: net: consolidate NetClientState header files into one virtio-net: update nc.link_down in virtio_net_load() e1000: update nc.link_down in e1000_post_load() rtl8139: implement 8139cp link status
This commit is contained in:
commit
4336ef7a55
12
hw/e1000.c
12
hw/e1000.c
|
@ -1079,11 +1079,23 @@ static bool is_version_1(void *opaque, int version_id)
|
||||||
return version_id == 1;
|
return version_id == 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int e1000_post_load(void *opaque, int version_id)
|
||||||
|
{
|
||||||
|
E1000State *s = opaque;
|
||||||
|
|
||||||
|
/* nc.link_down can't be migrated, so infer link_down according
|
||||||
|
* to link status bit in mac_reg[STATUS] */
|
||||||
|
s->nic->nc.link_down = (s->mac_reg[STATUS] & E1000_STATUS_LU) == 0;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static const VMStateDescription vmstate_e1000 = {
|
static const VMStateDescription vmstate_e1000 = {
|
||||||
.name = "e1000",
|
.name = "e1000",
|
||||||
.version_id = 2,
|
.version_id = 2,
|
||||||
.minimum_version_id = 1,
|
.minimum_version_id = 1,
|
||||||
.minimum_version_id_old = 1,
|
.minimum_version_id_old = 1,
|
||||||
|
.post_load = e1000_post_load,
|
||||||
.fields = (VMStateField []) {
|
.fields = (VMStateField []) {
|
||||||
VMSTATE_PCI_DEVICE(dev, E1000State),
|
VMSTATE_PCI_DEVICE(dev, E1000State),
|
||||||
VMSTATE_UNUSED_TEST(is_version_1, 4), /* was instance id */
|
VMSTATE_UNUSED_TEST(is_version_1, 4), /* was instance id */
|
||||||
|
|
24
hw/rtl8139.c
24
hw/rtl8139.c
|
@ -167,7 +167,7 @@ enum IntrStatusBits {
|
||||||
PCIErr = 0x8000,
|
PCIErr = 0x8000,
|
||||||
PCSTimeout = 0x4000,
|
PCSTimeout = 0x4000,
|
||||||
RxFIFOOver = 0x40,
|
RxFIFOOver = 0x40,
|
||||||
RxUnderrun = 0x20,
|
RxUnderrun = 0x20, /* Packet Underrun / Link Change */
|
||||||
RxOverflow = 0x10,
|
RxOverflow = 0x10,
|
||||||
TxErr = 0x08,
|
TxErr = 0x08,
|
||||||
TxOK = 0x04,
|
TxOK = 0x04,
|
||||||
|
@ -3003,7 +3003,8 @@ static uint32_t rtl8139_io_readb(void *opaque, uint8_t addr)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MediaStatus:
|
case MediaStatus:
|
||||||
ret = 0xd0;
|
/* The LinkDown bit of MediaStatus is inverse with link status */
|
||||||
|
ret = 0xd0 | (~s->BasicModeStatus & 0x04);
|
||||||
DPRINTF("MediaStatus read 0x%x\n", ret);
|
DPRINTF("MediaStatus read 0x%x\n", ret);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -3258,6 +3259,10 @@ static int rtl8139_post_load(void *opaque, int version_id)
|
||||||
s->cplus_enabled = s->CpCmd != 0;
|
s->cplus_enabled = s->CpCmd != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* nc.link_down can't be migrated, so infer link_down according
|
||||||
|
* to link status bit in BasicModeStatus */
|
||||||
|
s->nic->nc.link_down = (s->BasicModeStatus & 0x04) == 0;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3449,12 +3454,27 @@ static void pci_rtl8139_uninit(PCIDevice *dev)
|
||||||
qemu_del_net_client(&s->nic->nc);
|
qemu_del_net_client(&s->nic->nc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void rtl8139_set_link_status(NetClientState *nc)
|
||||||
|
{
|
||||||
|
RTL8139State *s = DO_UPCAST(NICState, nc, nc)->opaque;
|
||||||
|
|
||||||
|
if (nc->link_down) {
|
||||||
|
s->BasicModeStatus &= ~0x04;
|
||||||
|
} else {
|
||||||
|
s->BasicModeStatus |= 0x04;
|
||||||
|
}
|
||||||
|
|
||||||
|
s->IntrStatus |= RxUnderrun;
|
||||||
|
rtl8139_update_irq(s);
|
||||||
|
}
|
||||||
|
|
||||||
static NetClientInfo net_rtl8139_info = {
|
static NetClientInfo net_rtl8139_info = {
|
||||||
.type = NET_CLIENT_OPTIONS_KIND_NIC,
|
.type = NET_CLIENT_OPTIONS_KIND_NIC,
|
||||||
.size = sizeof(NICState),
|
.size = sizeof(NICState),
|
||||||
.can_receive = rtl8139_can_receive,
|
.can_receive = rtl8139_can_receive,
|
||||||
.receive = rtl8139_receive,
|
.receive = rtl8139_receive,
|
||||||
.cleanup = rtl8139_cleanup,
|
.cleanup = rtl8139_cleanup,
|
||||||
|
.link_status_changed = rtl8139_set_link_status,
|
||||||
};
|
};
|
||||||
|
|
||||||
static int pci_rtl8139_init(PCIDevice *dev)
|
static int pci_rtl8139_init(PCIDevice *dev)
|
||||||
|
|
|
@ -973,6 +973,11 @@ static int virtio_net_load(QEMUFile *f, void *opaque, int version_id)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
n->mac_table.first_multi = i;
|
n->mac_table.first_multi = i;
|
||||||
|
|
||||||
|
/* nc.link_down can't be migrated, so infer link_down according
|
||||||
|
* to link status bit in n->status */
|
||||||
|
n->nic->nc.link_down = (n->status & VIRTIO_NET_S_LINK_UP) == 0;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
11
net.c
11
net.c
|
@ -21,17 +21,14 @@
|
||||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
* THE SOFTWARE.
|
* THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
#include "net.h"
|
|
||||||
|
|
||||||
#include "config-host.h"
|
#include "config-host.h"
|
||||||
|
|
||||||
#include "net/tap.h"
|
#include "net.h"
|
||||||
#include "net/socket.h"
|
#include "net/clients.h"
|
||||||
#include "net/dump.h"
|
|
||||||
#include "net/slirp.h"
|
|
||||||
#include "net/vde.h"
|
|
||||||
#include "net/hub.h"
|
#include "net/hub.h"
|
||||||
|
#include "net/slirp.h"
|
||||||
#include "net/util.h"
|
#include "net/util.h"
|
||||||
|
|
||||||
#include "monitor.h"
|
#include "monitor.h"
|
||||||
#include "qemu-common.h"
|
#include "qemu-common.h"
|
||||||
#include "qemu_socket.h"
|
#include "qemu_socket.h"
|
||||||
|
|
|
@ -21,13 +21,35 @@
|
||||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
* THE SOFTWARE.
|
* THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
#ifndef QEMU_NET_SOCKET_H
|
#ifndef QEMU_NET_CLIENTS_H
|
||||||
#define QEMU_NET_SOCKET_H
|
#define QEMU_NET_CLIENTS_H
|
||||||
|
|
||||||
#include "net.h"
|
#include "net.h"
|
||||||
#include "qapi-types.h"
|
#include "qapi-types.h"
|
||||||
|
|
||||||
|
int net_init_dump(const NetClientOptions *opts, const char *name,
|
||||||
|
NetClientState *peer);
|
||||||
|
|
||||||
|
#ifdef CONFIG_SLIRP
|
||||||
|
int net_init_slirp(const NetClientOptions *opts, const char *name,
|
||||||
|
NetClientState *peer);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
int net_init_hubport(const NetClientOptions *opts, const char *name,
|
||||||
|
NetClientState *peer);
|
||||||
|
|
||||||
int net_init_socket(const NetClientOptions *opts, const char *name,
|
int net_init_socket(const NetClientOptions *opts, const char *name,
|
||||||
NetClientState *peer);
|
NetClientState *peer);
|
||||||
|
|
||||||
#endif /* QEMU_NET_SOCKET_H */
|
int net_init_tap(const NetClientOptions *opts, const char *name,
|
||||||
|
NetClientState *peer);
|
||||||
|
|
||||||
|
int net_init_bridge(const NetClientOptions *opts, const char *name,
|
||||||
|
NetClientState *peer);
|
||||||
|
|
||||||
|
#ifdef CONFIG_VDE
|
||||||
|
int net_init_vde(const NetClientOptions *opts, const char *name,
|
||||||
|
NetClientState *peer);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* QEMU_NET_CLIENTS_H */
|
|
@ -22,7 +22,7 @@
|
||||||
* THE SOFTWARE.
|
* THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "dump.h"
|
#include "clients.h"
|
||||||
#include "qemu-common.h"
|
#include "qemu-common.h"
|
||||||
#include "qemu-error.h"
|
#include "qemu-error.h"
|
||||||
#include "qemu-log.h"
|
#include "qemu-log.h"
|
||||||
|
|
33
net/dump.h
33
net/dump.h
|
@ -1,33 +0,0 @@
|
||||||
/*
|
|
||||||
* QEMU System Emulator
|
|
||||||
*
|
|
||||||
* Copyright (c) 2003-2008 Fabrice Bellard
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
|
||||||
* in the Software without restriction, including without limitation the rights
|
|
||||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
* copies of the Software, and to permit persons to whom the Software is
|
|
||||||
* furnished to do so, subject to the following conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be included in
|
|
||||||
* all copies or substantial portions of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
||||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
||||||
* THE SOFTWARE.
|
|
||||||
*/
|
|
||||||
#ifndef QEMU_NET_DUMP_H
|
|
||||||
#define QEMU_NET_DUMP_H
|
|
||||||
|
|
||||||
#include "net.h"
|
|
||||||
#include "qapi-types.h"
|
|
||||||
|
|
||||||
int net_init_dump(const NetClientOptions *opts, const char *name,
|
|
||||||
NetClientState *peer);
|
|
||||||
|
|
||||||
#endif /* QEMU_NET_DUMP_H */
|
|
|
@ -14,6 +14,7 @@
|
||||||
|
|
||||||
#include "monitor.h"
|
#include "monitor.h"
|
||||||
#include "net.h"
|
#include "net.h"
|
||||||
|
#include "clients.h"
|
||||||
#include "hub.h"
|
#include "hub.h"
|
||||||
#include "iov.h"
|
#include "iov.h"
|
||||||
|
|
||||||
|
|
|
@ -17,8 +17,6 @@
|
||||||
|
|
||||||
#include "qemu-common.h"
|
#include "qemu-common.h"
|
||||||
|
|
||||||
int net_init_hubport(const NetClientOptions *opts, const char *name,
|
|
||||||
NetClientState *peer);
|
|
||||||
NetClientState *net_hub_add_port(int hub_id, const char *name);
|
NetClientState *net_hub_add_port(int hub_id, const char *name);
|
||||||
NetClientState *net_hub_find_client_by_name(int hub_id, const char *name);
|
NetClientState *net_hub_find_client_by_name(int hub_id, const char *name);
|
||||||
void net_hub_info(Monitor *mon);
|
void net_hub_info(Monitor *mon);
|
||||||
|
|
|
@ -30,7 +30,8 @@
|
||||||
#include <sys/wait.h>
|
#include <sys/wait.h>
|
||||||
#endif
|
#endif
|
||||||
#include "net.h"
|
#include "net.h"
|
||||||
#include "net/hub.h"
|
#include "clients.h"
|
||||||
|
#include "hub.h"
|
||||||
#include "monitor.h"
|
#include "monitor.h"
|
||||||
#include "qemu_socket.h"
|
#include "qemu_socket.h"
|
||||||
#include "slirp/libslirp.h"
|
#include "slirp/libslirp.h"
|
||||||
|
|
|
@ -31,9 +31,6 @@
|
||||||
|
|
||||||
#ifdef CONFIG_SLIRP
|
#ifdef CONFIG_SLIRP
|
||||||
|
|
||||||
int net_init_slirp(const NetClientOptions *opts, const char *name,
|
|
||||||
NetClientState *peer);
|
|
||||||
|
|
||||||
void net_slirp_hostfwd_add(Monitor *mon, const QDict *qdict);
|
void net_slirp_hostfwd_add(Monitor *mon, const QDict *qdict);
|
||||||
void net_slirp_hostfwd_remove(Monitor *mon, const QDict *qdict);
|
void net_slirp_hostfwd_remove(Monitor *mon, const QDict *qdict);
|
||||||
|
|
||||||
|
|
|
@ -21,11 +21,10 @@
|
||||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
* THE SOFTWARE.
|
* THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
#include "net/socket.h"
|
|
||||||
|
|
||||||
#include "config-host.h"
|
#include "config-host.h"
|
||||||
|
|
||||||
#include "net.h"
|
#include "net.h"
|
||||||
|
#include "clients.h"
|
||||||
#include "monitor.h"
|
#include "monitor.h"
|
||||||
#include "qemu-char.h"
|
#include "qemu-char.h"
|
||||||
#include "qemu-common.h"
|
#include "qemu-common.h"
|
||||||
|
|
|
@ -26,7 +26,7 @@
|
||||||
* distribution); if not, see <http://www.gnu.org/licenses/>.
|
* distribution); if not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "net/tap.h"
|
#include "tap.h"
|
||||||
|
|
||||||
#include "qemu-common.h"
|
#include "qemu-common.h"
|
||||||
#include "net.h"
|
#include "net.h"
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
* THE SOFTWARE.
|
* THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "net/tap.h"
|
#include "tap.h"
|
||||||
|
|
||||||
#include "config-host.h"
|
#include "config-host.h"
|
||||||
|
|
||||||
|
@ -34,6 +34,7 @@
|
||||||
#include <net/if.h>
|
#include <net/if.h>
|
||||||
|
|
||||||
#include "net.h"
|
#include "net.h"
|
||||||
|
#include "clients.h"
|
||||||
#include "monitor.h"
|
#include "monitor.h"
|
||||||
#include "sysemu.h"
|
#include "sysemu.h"
|
||||||
#include "qemu-char.h"
|
#include "qemu-char.h"
|
||||||
|
|
|
@ -32,9 +32,6 @@
|
||||||
#define DEFAULT_NETWORK_SCRIPT "/etc/qemu-ifup"
|
#define DEFAULT_NETWORK_SCRIPT "/etc/qemu-ifup"
|
||||||
#define DEFAULT_NETWORK_DOWN_SCRIPT "/etc/qemu-ifdown"
|
#define DEFAULT_NETWORK_DOWN_SCRIPT "/etc/qemu-ifdown"
|
||||||
|
|
||||||
int net_init_tap(const NetClientOptions *opts, const char *name,
|
|
||||||
NetClientState *peer);
|
|
||||||
|
|
||||||
int tap_open(char *ifname, int ifname_size, int *vnet_hdr, int vnet_hdr_required);
|
int tap_open(char *ifname, int ifname_size, int *vnet_hdr, int vnet_hdr_required);
|
||||||
|
|
||||||
ssize_t tap_read_packet(int tapfd, uint8_t *buf, int maxlen);
|
ssize_t tap_read_packet(int tapfd, uint8_t *buf, int maxlen);
|
||||||
|
@ -58,7 +55,4 @@ int tap_get_fd(NetClientState *nc);
|
||||||
struct vhost_net;
|
struct vhost_net;
|
||||||
struct vhost_net *tap_get_vhost_net(NetClientState *nc);
|
struct vhost_net *tap_get_vhost_net(NetClientState *nc);
|
||||||
|
|
||||||
int net_init_bridge(const NetClientOptions *opts, const char *name,
|
|
||||||
NetClientState *peer);
|
|
||||||
|
|
||||||
#endif /* QEMU_NET_TAP_H */
|
#endif /* QEMU_NET_TAP_H */
|
||||||
|
|
|
@ -21,13 +21,12 @@
|
||||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
* THE SOFTWARE.
|
* THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
#include "net/vde.h"
|
|
||||||
|
|
||||||
#include "config-host.h"
|
#include "config-host.h"
|
||||||
|
|
||||||
#include <libvdeplug.h>
|
#include <libvdeplug.h>
|
||||||
|
|
||||||
#include "net.h"
|
#include "net.h"
|
||||||
|
#include "clients.h"
|
||||||
#include "qemu-char.h"
|
#include "qemu-char.h"
|
||||||
#include "qemu-common.h"
|
#include "qemu-common.h"
|
||||||
#include "qemu-option.h"
|
#include "qemu-option.h"
|
||||||
|
|
37
net/vde.h
37
net/vde.h
|
@ -1,37 +0,0 @@
|
||||||
/*
|
|
||||||
* QEMU System Emulator
|
|
||||||
*
|
|
||||||
* Copyright (c) 2003-2008 Fabrice Bellard
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
|
||||||
* in the Software without restriction, including without limitation the rights
|
|
||||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
* copies of the Software, and to permit persons to whom the Software is
|
|
||||||
* furnished to do so, subject to the following conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be included in
|
|
||||||
* all copies or substantial portions of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
||||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
||||||
* THE SOFTWARE.
|
|
||||||
*/
|
|
||||||
#ifndef QEMU_NET_VDE_H
|
|
||||||
#define QEMU_NET_VDE_H
|
|
||||||
|
|
||||||
#include "qemu-common.h"
|
|
||||||
#include "qapi-types.h"
|
|
||||||
|
|
||||||
#ifdef CONFIG_VDE
|
|
||||||
|
|
||||||
int net_init_vde(const NetClientOptions *opts, const char *name,
|
|
||||||
NetClientState *peer);
|
|
||||||
|
|
||||||
#endif /* CONFIG_VDE */
|
|
||||||
|
|
||||||
#endif /* QEMU_NET_VDE_H */
|
|
Loading…
Reference in New Issue