Skip to content

Commit

Permalink
Merge remote-tracking branch 'remotes/jasowang/tags/net-pull-request'…
Browse files Browse the repository at this point in the history
… into staging

# gpg: Signature made Mon 05 Mar 2018 03:06:59 GMT
# gpg:                using RSA key EF04965B398D6211
# gpg: Good signature from "Jason Wang (Jason Wang on RedHat) <jasowang@redhat.com>"
# gpg: WARNING: This key is not certified with sufficiently trusted signatures!
# gpg:          It is not certain that the signature belongs to the owner.
# Primary key fingerprint: 215D 46F4 8246 689E C77F  3562 EF04 965B 398D 6211

* remotes/jasowang/tags/net-pull-request:
  tap: setting error appropriately when calling net_init_tap_one()
  hw/net: Remove unnecessary header includes
  net: Add a new convenience option "--nic" to configure default/on-board NICs
  net: Remove the deprecated 'host_net_add' and 'host_net_remove' HMP commands
  net: Remove the deprecated way of dumping network packets
  net: Make net_client_init() static
  net: Only show vhost-user in the help text if CONFIG_POSIX is defined
  net: List available netdevs with "-netdev help"
  net: Move error reporting from net_init_client/netdev to the calling site

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
  • Loading branch information
pm215 committed Mar 5, 2018
2 parents 4a22592 + 46d4d36 commit 41dfc0d
Show file tree
Hide file tree
Showing 21 changed files with 190 additions and 391 deletions.
30 changes: 0 additions & 30 deletions hmp-commands.hx
Expand Up @@ -1288,36 +1288,6 @@ STEXI
@item pcie_aer_inject_error
@findex pcie_aer_inject_error
Inject PCIe AER error
ETEXI

{
.name = "host_net_add",
.args_type = "device:s,opts:s?",
.params = "tap|user|socket|vde|netmap|bridge|vhost-user|dump [options]",
.help = "add host VLAN client (deprecated, use netdev_add instead)",
.cmd = hmp_host_net_add,
.command_completion = host_net_add_completion,
},

STEXI
@item host_net_add
@findex host_net_add
Add host VLAN client. Deprecated, please use @code{netdev_add} instead.
ETEXI

{
.name = "host_net_remove",
.args_type = "vlan_id:i,device:s",
.params = "vlan_id name",
.help = "remove host VLAN client (deprecated, use netdev_del instead)",
.cmd = hmp_host_net_remove,
.command_completion = host_net_remove_completion,
},

STEXI
@item host_net_remove
@findex host_net_remove
Remove host VLAN client. Deprecated, please use @code{netdev_del} instead.
ETEXI

{
Expand Down
3 changes: 0 additions & 3 deletions hmp.h
Expand Up @@ -132,9 +132,6 @@ void migrate_set_capability_completion(ReadLineState *rs, int nb_args,
const char *str);
void migrate_set_parameter_completion(ReadLineState *rs, int nb_args,
const char *str);
void host_net_add_completion(ReadLineState *rs, int nb_args, const char *str);
void host_net_remove_completion(ReadLineState *rs, int nb_args,
const char *str);
void delvm_completion(ReadLineState *rs, int nb_args, const char *str);
void loadvm_completion(ReadLineState *rs, int nb_args, const char *str);
void hmp_rocker(Monitor *mon, const QDict *qdict);
Expand Down
1 change: 0 additions & 1 deletion hw/net/e1000.c
Expand Up @@ -30,7 +30,6 @@
#include "hw/pci/pci.h"
#include "net/net.h"
#include "net/checksum.h"
#include "hw/loader.h"
#include "sysemu/sysemu.h"
#include "sysemu/dma.h"
#include "qemu/iov.h"
Expand Down
3 changes: 0 additions & 3 deletions hw/net/lance.c
Expand Up @@ -36,10 +36,7 @@
*/

#include "qemu/osdep.h"
#include "hw/sysbus.h"
#include "net/net.h"
#include "qemu/timer.h"
#include "qemu/sockets.h"
#include "hw/sparc/sparc32_dma.h"
#include "hw/net/lance.h"
#include "trace.h"
Expand Down
2 changes: 0 additions & 2 deletions hw/net/ne2000.c
Expand Up @@ -23,10 +23,8 @@
*/
#include "qemu/osdep.h"
#include "hw/pci/pci.h"
#include "net/net.h"
#include "net/eth.h"
#include "ne2000.h"
#include "hw/loader.h"
#include "sysemu/sysemu.h"

/* debug NE2000 card */
Expand Down
1 change: 0 additions & 1 deletion hw/net/pcnet-pci.c
Expand Up @@ -30,7 +30,6 @@
#include "qemu/osdep.h"
#include "hw/pci/pci.h"
#include "net/net.h"
#include "hw/loader.h"
#include "qemu/timer.h"
#include "sysemu/dma.h"
#include "sysemu/sysemu.h"
Expand Down
1 change: 0 additions & 1 deletion hw/net/pcnet.c
Expand Up @@ -40,7 +40,6 @@
#include "net/net.h"
#include "net/eth.h"
#include "qemu/timer.h"
#include "qemu/sockets.h"
#include "sysemu/sysemu.h"
#include "trace.h"

Expand Down
2 changes: 0 additions & 2 deletions hw/net/rtl8139.c
Expand Up @@ -58,9 +58,7 @@
#include "qemu/timer.h"
#include "net/net.h"
#include "net/eth.h"
#include "hw/loader.h"
#include "sysemu/sysemu.h"
#include "qemu/iov.h"

/* debug RTL8139 card */
//#define DEBUG_RTL8139 1
Expand Down
1 change: 0 additions & 1 deletion hw/net/xgmac.c
Expand Up @@ -28,7 +28,6 @@
#include "hw/sysbus.h"
#include "qemu/log.h"
#include "net/net.h"
#include "net/checksum.h"

#ifdef DEBUG_XGMAC
#define DEBUGF_BRK(message, args...) do { \
Expand Down
4 changes: 1 addition & 3 deletions include/net/net.h
Expand Up @@ -204,9 +204,8 @@ extern const char *host_net_devices[];
extern const char *legacy_tftp_prefix;
extern const char *legacy_bootp_filename;

int net_client_init(QemuOpts *opts, bool is_netdev, Error **errp);
int net_client_parse(QemuOptsList *opts_list, const char *str);
int net_init_clients(void);
int net_init_clients(Error **errp);
void net_check_clients(void);
void net_cleanup(void);
void hmp_host_net_add(Monitor *mon, const QDict *qdict);
Expand All @@ -228,7 +227,6 @@ void qdev_set_nic_properties(DeviceState *dev, NICInfo *nd);
#define POLYNOMIAL_LE 0xedb88320
uint32_t net_crc32(const uint8_t *p, int len);
uint32_t net_crc32_le(const uint8_t *p, int len);
unsigned compute_mcast_idx(const uint8_t *ep);

#define vmstate_offset_macaddr(_state, _field) \
vmstate_offset_array(_state, _field.a, uint8_t, \
Expand Down
3 changes: 3 additions & 0 deletions include/net/vhost_net.h
Expand Up @@ -4,6 +4,9 @@
#include "net/net.h"
#include "hw/virtio/vhost-backend.h"

#define VHOST_NET_INIT_FAILED \
"vhost-net requested but could not be initialized"

struct vhost_net;
typedef struct vhost_net VHostNetState;

Expand Down
1 change: 1 addition & 0 deletions include/sysemu/sysemu.h
Expand Up @@ -198,6 +198,7 @@ extern QemuOptsList bdrv_runtime_opts;
extern QemuOptsList qemu_chardev_opts;
extern QemuOptsList qemu_device_opts;
extern QemuOptsList qemu_netdev_opts;
extern QemuOptsList qemu_nic_opts;
extern QemuOptsList qemu_net_opts;
extern QemuOptsList qemu_global_opts;
extern QemuOptsList qemu_mon_opts;
Expand Down
61 changes: 0 additions & 61 deletions monitor.c
Expand Up @@ -3581,67 +3581,6 @@ void migrate_set_parameter_completion(ReadLineState *rs, int nb_args,
}
}

void host_net_add_completion(ReadLineState *rs, int nb_args, const char *str)
{
int i;
size_t len;
if (nb_args != 2) {
return;
}
len = strlen(str);
readline_set_completion_index(rs, len);
for (i = 0; host_net_devices[i]; i++) {
if (!strncmp(host_net_devices[i], str, len)) {
readline_add_completion(rs, host_net_devices[i]);
}
}
}

void host_net_remove_completion(ReadLineState *rs, int nb_args, const char *str)
{
NetClientState *ncs[MAX_QUEUE_NUM];
int count, i, len;

len = strlen(str);
readline_set_completion_index(rs, len);
if (nb_args == 2) {
count = qemu_find_net_clients_except(NULL, ncs,
NET_CLIENT_DRIVER_NONE,
MAX_QUEUE_NUM);
for (i = 0; i < MIN(count, MAX_QUEUE_NUM); i++) {
int id;
char name[16];

if (net_hub_id_for_client(ncs[i], &id)) {
continue;
}
snprintf(name, sizeof(name), "%d", id);
if (!strncmp(str, name, len)) {
readline_add_completion(rs, name);
}
}
return;
} else if (nb_args == 3) {
count = qemu_find_net_clients_except(NULL, ncs,
NET_CLIENT_DRIVER_NIC,
MAX_QUEUE_NUM);
for (i = 0; i < MIN(count, MAX_QUEUE_NUM); i++) {
int id;
const char *name;

if (ncs[i]->info->type == NET_CLIENT_DRIVER_HUBPORT ||
net_hub_id_for_client(ncs[i], &id)) {
continue;
}
name = ncs[i]->name;
if (!strncmp(str, name, len)) {
readline_add_completion(rs, name);
}
}
return;
}
}

static void vm_completion(ReadLineState *rs, const char *str)
{
size_t len;
Expand Down
102 changes: 2 additions & 100 deletions net/dump.c
Expand Up @@ -109,7 +109,7 @@ static int net_dump_state_init(DumpState *s, const char *filename,

fd = open(filename, O_CREAT | O_TRUNC | O_WRONLY | O_BINARY, 0644);
if (fd < 0) {
error_setg_errno(errp, errno, "-net dump: can't open %s", filename);
error_setg_errno(errp, errno, "net dump: can't open %s", filename);
return -1;
}

Expand All @@ -122,7 +122,7 @@ static int net_dump_state_init(DumpState *s, const char *filename,
hdr.linktype = 1;

if (write(fd, &hdr, sizeof(hdr)) < sizeof(hdr)) {
error_setg_errno(errp, errno, "-net dump write error");
error_setg_errno(errp, errno, "net dump write error");
close(fd);
return -1;
}
Expand All @@ -136,104 +136,6 @@ static int net_dump_state_init(DumpState *s, const char *filename,
return 0;
}

/* Dumping via VLAN netclient */

struct DumpNetClient {
NetClientState nc;
DumpState ds;
};
typedef struct DumpNetClient DumpNetClient;

static ssize_t dumpclient_receive(NetClientState *nc, const uint8_t *buf,
size_t size)
{
DumpNetClient *dc = DO_UPCAST(DumpNetClient, nc, nc);
struct iovec iov = {
.iov_base = (void *)buf,
.iov_len = size
};

return dump_receive_iov(&dc->ds, &iov, 1);
}

static ssize_t dumpclient_receive_iov(NetClientState *nc,
const struct iovec *iov, int cnt)
{
DumpNetClient *dc = DO_UPCAST(DumpNetClient, nc, nc);

return dump_receive_iov(&dc->ds, iov, cnt);
}

static void dumpclient_cleanup(NetClientState *nc)
{
DumpNetClient *dc = DO_UPCAST(DumpNetClient, nc, nc);

dump_cleanup(&dc->ds);
}

static NetClientInfo net_dump_info = {
.type = NET_CLIENT_DRIVER_DUMP,
.size = sizeof(DumpNetClient),
.receive = dumpclient_receive,
.receive_iov = dumpclient_receive_iov,
.cleanup = dumpclient_cleanup,
};

int net_init_dump(const Netdev *netdev, const char *name,
NetClientState *peer, Error **errp)
{
int len, rc;
const char *file;
char def_file[128];
const NetdevDumpOptions *dump;
NetClientState *nc;
DumpNetClient *dnc;

assert(netdev->type == NET_CLIENT_DRIVER_DUMP);
dump = &netdev->u.dump;

assert(peer);

error_report("'-net dump' is deprecated. "
"Please use '-object filter-dump' instead.");

if (dump->has_file) {
file = dump->file;
} else {
int id;
int ret;

ret = net_hub_id_for_client(peer, &id);
assert(ret == 0); /* peer must be on a hub */

snprintf(def_file, sizeof(def_file), "qemu-vlan%d.pcap", id);
file = def_file;
}

if (dump->has_len) {
if (dump->len > INT_MAX) {
error_setg(errp, "invalid length: %"PRIu64, dump->len);
return -1;
}
len = dump->len;
} else {
len = 65536;
}

nc = qemu_new_net_client(&net_dump_info, peer, "dump", name);
snprintf(nc->info_str, sizeof(nc->info_str),
"dump to %s (len=%d)", file, len);

dnc = DO_UPCAST(DumpNetClient, nc, nc);
rc = net_dump_state_init(&dnc->ds, file, len, errp);
if (rc) {
qemu_del_net_client(nc);
}
return rc;
}

/* Dumping via filter */

#define TYPE_FILTER_DUMP "filter-dump"

#define FILTER_DUMP(obj) \
Expand Down

0 comments on commit 41dfc0d

Please sign in to comment.