Skip to content

Commit

Permalink
Revert "qapi: net: Add query-netdev command"
Browse files Browse the repository at this point in the history
Several issues has been reported for query-netdev series. Consider
it's late in the rc, this reverts commit
d32ad10.

Signed-off-by: Jason Wang <jasowang@redhat.com>
  • Loading branch information
jasowang committed Apr 8, 2021
1 parent 2231730 commit f9bb0c1
Show file tree
Hide file tree
Showing 12 changed files with 9 additions and 477 deletions.
3 changes: 0 additions & 3 deletions include/net/net.h
Expand Up @@ -5,8 +5,6 @@
#include "qapi/qapi-types-net.h"
#include "net/queue.h"
#include "hw/qdev-properties-system.h"
#include "qapi/clone-visitor.h"
#include "qapi/qapi-visit-net.h"

#define MAC_FMT "%02X:%02X:%02X:%02X:%02X:%02X"
#define MAC_ARG(x) ((uint8_t *)(x))[0], ((uint8_t *)(x))[1], \
Expand Down Expand Up @@ -95,7 +93,6 @@ struct NetClientState {
char *model;
char *name;
char info_str[256];
NetdevInfo *stored_config;
unsigned receive_disabled : 1;
NetClientDestructor *destructor;
unsigned int queue_index;
Expand Down
7 changes: 0 additions & 7 deletions net/l2tpv3.c
Expand Up @@ -723,13 +723,6 @@ int net_init_l2tpv3(const Netdev *netdev,

l2tpv3_read_poll(s, true);

/* Store startup parameters */
nc->stored_config = g_new0(NetdevInfo, 1);
nc->stored_config->type = NET_BACKEND_L2TPV3;

QAPI_CLONE_MEMBERS(NetdevL2TPv3Options,
&nc->stored_config->u.l2tpv3, l2tpv3);

snprintf(s->nc.info_str, sizeof(s->nc.info_str),
"l2tpv3: connected");
return 0;
Expand Down
30 changes: 1 addition & 29 deletions net/net.c
Expand Up @@ -36,6 +36,7 @@
#include "monitor/monitor.h"
#include "qemu/help_option.h"
#include "qapi/qapi-commands-net.h"
#include "qapi/qapi-visit-net.h"
#include "qapi/qmp/qdict.h"
#include "qapi/qmp/qerror.h"
#include "qemu/error-report.h"
Expand Down Expand Up @@ -352,7 +353,6 @@ static void qemu_free_net_client(NetClientState *nc)
}
g_free(nc->name);
g_free(nc->model);
qapi_free_NetdevInfo(nc->stored_config);
if (nc->destructor) {
nc->destructor(nc);
}
Expand Down Expand Up @@ -1289,34 +1289,6 @@ RxFilterInfoList *qmp_query_rx_filter(bool has_name, const char *name,
return filter_list;
}

NetdevInfoList *qmp_query_netdev(Error **errp)
{
NetdevInfoList *list = NULL;
NetClientState *nc;

QTAILQ_FOREACH(nc, &net_clients, next) {
/*
* Only look at netdevs (backend network devices), not for each queue
* or NIC / hubport
*/
if (nc->stored_config) {
NetdevInfo *element = QAPI_CLONE(NetdevInfo, nc->stored_config);

g_free(element->id); /* Need to dealloc empty id after clone */
element->id = g_strdup(nc->name);

element->has_peer_id = nc->peer != NULL;
if (element->has_peer_id) {
element->peer_id = g_strdup(nc->peer->name);
}

QAPI_LIST_PREPEND(list, element);
}
}

return list;
}

void hmp_info_network(Monitor *mon, const QDict *qdict)
{
NetClientState *nc, *peer;
Expand Down
7 changes: 0 additions & 7 deletions net/netmap.c
Expand Up @@ -427,13 +427,6 @@ int net_init_netmap(const Netdev *netdev,
pstrcpy(s->ifname, sizeof(s->ifname), netmap_opts->ifname);
netmap_read_poll(s, true); /* Initially only poll for reads. */

/* Store startup parameters */
nc->stored_config = g_new0(NetdevInfo, 1);
nc->stored_config->type = NET_BACKEND_NETMAP;

QAPI_CLONE_MEMBERS(NetdevNetmapOptions,
&nc->stored_config->u.netmap, netmap_opts);

return 0;
}

122 changes: 0 additions & 122 deletions net/slirp.c
Expand Up @@ -387,9 +387,6 @@ static int net_slirp_init(NetClientState *peer, const char *model,
int shift;
char *end;
struct slirp_config_str *config;
NetdevUserOptions *stored;
StringList **stored_hostfwd;
StringList **stored_guestfwd;

if (!ipv4 && (vnetwork || vhost || vnameserver)) {
error_setg(errp, "IPv4 disabled but netmask/host/dns provided");
Expand Down Expand Up @@ -565,115 +562,6 @@ static int net_slirp_init(NetClientState *peer, const char *model,

nc = qemu_new_net_client(&net_slirp_info, peer, model, name);

/* Store startup parameters */
nc->stored_config = g_new0(NetdevInfo, 1);
nc->stored_config->type = NET_BACKEND_USER;
stored = &nc->stored_config->u.user;

if (vhostname) {
stored->has_hostname = true;
stored->hostname = g_strdup(vhostname);
}

stored->has_q_restrict = true;
stored->q_restrict = restricted;

stored->has_ipv4 = true;
stored->ipv4 = ipv4;

stored->has_ipv6 = true;
stored->ipv6 = ipv6;

if (ipv4) {
uint8_t *net_bytes = (uint8_t *)&net;
uint8_t *mask_bytes = (uint8_t *)&mask;

stored->has_net = true;
stored->net = g_strdup_printf("%d.%d.%d.%d/%d.%d.%d.%d",
net_bytes[0], net_bytes[1],
net_bytes[2], net_bytes[3],
mask_bytes[0], mask_bytes[1],
mask_bytes[2], mask_bytes[3]);

stored->has_host = true;
stored->host = g_strdup(inet_ntoa(host));
}

if (tftp_export) {
stored->has_tftp = true;
stored->tftp = g_strdup(tftp_export);
}

if (bootfile) {
stored->has_bootfile = true;
stored->bootfile = g_strdup(bootfile);
}

if (vdhcp_start) {
stored->has_dhcpstart = true;
stored->dhcpstart = g_strdup(vdhcp_start);
}

if (ipv4) {
stored->has_dns = true;
stored->dns = g_strdup(inet_ntoa(dns));
}

if (dnssearch) {
stored->has_dnssearch = true;
StringList **stored_list = &stored->dnssearch;

for (int i = 0; dnssearch[i]; i++) {
String *element = g_new0(String, 1);

element->str = g_strdup(dnssearch[i]);
QAPI_LIST_APPEND(stored_list, element);
}
}

if (vdomainname) {
stored->has_domainname = true;
stored->domainname = g_strdup(vdomainname);
}

if (ipv6) {
char addrstr[INET6_ADDRSTRLEN];
const char *res;

stored->has_ipv6_prefix = true;
stored->ipv6_prefix = g_strdup(vprefix6);

stored->has_ipv6_prefixlen = true;
stored->ipv6_prefixlen = vprefix6_len;

res = inet_ntop(AF_INET6, &ip6_host,
addrstr, sizeof(addrstr));

stored->has_ipv6_host = true;
stored->ipv6_host = g_strdup(res);

res = inet_ntop(AF_INET6, &ip6_dns,
addrstr, sizeof(addrstr));

stored->has_ipv6_dns = true;
stored->ipv6_dns = g_strdup(res);
}

if (smb_export) {
stored->has_smb = true;
stored->smb = g_strdup(smb_export);
}

if (vsmbserver) {
stored->has_smbserver = true;
stored->smbserver = g_strdup(vsmbserver);
}

if (tftp_server_name) {
stored->has_tftp_server_name = true;
stored->tftp_server_name = g_strdup(tftp_server_name);
}

snprintf(nc->info_str, sizeof(nc->info_str),
"net=%s,restrict=%s", inet_ntoa(net),
restricted ? "on" : "off");
Expand Down Expand Up @@ -703,25 +591,15 @@ static int net_slirp_init(NetClientState *peer, const char *model,
s->poll_notifier.notify = net_slirp_poll_notify;
main_loop_poll_add_notifier(&s->poll_notifier);

stored_hostfwd = &stored->hostfwd;
stored_guestfwd = &stored->guestfwd;

for (config = slirp_configs; config; config = config->next) {
String *element = g_new0(String, 1);

element->str = g_strdup(config->str);
if (config->flags & SLIRP_CFG_HOSTFWD) {
if (slirp_hostfwd(s, config->str, errp) < 0) {
goto error;
}
stored->has_hostfwd = true;
QAPI_LIST_APPEND(stored_hostfwd, element);
} else {
if (slirp_guestfwd(s, config->str, errp) < 0) {
goto error;
}
stored->has_guestfwd = true;
QAPI_LIST_APPEND(stored_guestfwd, element);
}
}
#ifndef _WIN32
Expand Down

0 comments on commit f9bb0c1

Please sign in to comment.