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 Tue 02 Jul 2019 03:21:54 BST
# gpg:                using RSA key EF04965B398D6211
# gpg: Good signature from "Jason Wang (Jason Wang on RedHat) <jasowang@redhat.com>" [marginal]
# 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:
  migration/colo.c: Add missed filter notify for Xen COLO.
  COLO-compare: Add colo-compare remote notify support
  COLO-compare: Make the compare_chr_send() can send notification message.
  COLO-compare: Add remote notification chardev handler frame
  COLO-compare: Add new parameter to communicate with remote colo-frame
  net/announce: Expand test for stopping self announce
  net/announce: Add HMP optional ID
  net/announce: Add optional ID
  net/announce: Add HMP optional interface list
  net/announce: Allow optional list of interfaces
  net: remove unused get_str_sep() function
  net: use g_strsplit() for parsing host address and port
  net: avoid using variable length array in net_client_init()
  net: fix assertion failure when ipv6-prefixlen is not a number
  ftgmac100: do not link to netdev
  qemu-bridge-helper: Document known shortcomings
  MAINTAINERS: Add qemu-bridge-helper.c to "Network device backends"

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
  • Loading branch information
pm215 committed Jul 2, 2019
2 parents f4af847 + 0e8818f commit 8ef53cd
Show file tree
Hide file tree
Showing 15 changed files with 430 additions and 99 deletions.
1 change: 1 addition & 0 deletions MAINTAINERS
Expand Up @@ -1944,6 +1944,7 @@ M: Jason Wang <jasowang@redhat.com>
S: Maintained
F: net/
F: include/net/
F: qemu-bridge-helper.c
T: git https://github.com/jasowang/qemu.git net
F: qapi/net.json

Expand Down
7 changes: 5 additions & 2 deletions hmp-commands.hx
Expand Up @@ -955,8 +955,8 @@ ETEXI

{
.name = "announce_self",
.args_type = "",
.params = "",
.args_type = "interfaces:s?,id:s?",
.params = "[interfaces] [id]",
.help = "Trigger GARP/RARP announcements",
.cmd = hmp_announce_self,
},
Expand All @@ -967,6 +967,9 @@ STEXI
Trigger a round of GARP/RARP broadcasts; this is useful for explicitly updating the
network infrastructure after a reconfiguration or some forms of migration.
The timings of the round are set by the migration announce parameters.
An optional comma separated @var{interfaces} list restricts the announce to the
named set of interfaces. An optional @var{id} can be used to start a separate announce
timer and to change the parameters of it later.
ETEXI

{
Expand Down
2 changes: 0 additions & 2 deletions hw/net/ftgmac100.c
Expand Up @@ -1017,8 +1017,6 @@ static void ftgmac100_realize(DeviceState *dev, Error **errp)
sysbus_init_irq(sbd, &s->irq);
qemu_macaddr_default_if_unset(&s->conf.macaddr);

s->conf.peers.ncs[0] = nd_table[0].netdev;

s->nic = qemu_new_nic(&net_ftgmac100_info, &s->conf,
object_get_typename(OBJECT(dev)), DEVICE(dev)->id,
s);
Expand Down
4 changes: 2 additions & 2 deletions hw/net/virtio-net.c
Expand Up @@ -2360,7 +2360,7 @@ static int virtio_net_post_load_device(void *opaque, int version_id)
timer_mod(n->announce_timer.tm,
qemu_clock_get_ms(n->announce_timer.type));
} else {
qemu_announce_timer_del(&n->announce_timer);
qemu_announce_timer_del(&n->announce_timer, false);
}
}

Expand Down Expand Up @@ -2784,7 +2784,7 @@ static void virtio_net_device_unrealize(DeviceState *dev, Error **errp)
virtio_net_del_queue(n, i);
}

qemu_announce_timer_del(&n->announce_timer);
qemu_announce_timer_del(&n->announce_timer, false);
g_free(n->vqs);
qemu_del_nic(n->nic);
virtio_net_rsc_cleanup(n);
Expand Down
8 changes: 6 additions & 2 deletions include/net/announce.h
Expand Up @@ -22,8 +22,12 @@ struct AnnounceTimer {
/* Returns: update the timer to the next time point */
int64_t qemu_announce_timer_step(AnnounceTimer *timer);

/* Delete the underlying timer */
void qemu_announce_timer_del(AnnounceTimer *timer);
/*
* Delete the underlying timer and other data
* If 'free_named' true and the timer is a named timer, then remove
* it from the list of named timers and free the AnnounceTimer itself.
*/
void qemu_announce_timer_del(AnnounceTimer *timer, bool free_named);

/*
* Under BQL/main thread
Expand Down
2 changes: 2 additions & 0 deletions migration/colo.c
Expand Up @@ -259,6 +259,8 @@ ReplicationStatus *qmp_query_xen_replication_status(Error **errp)
void qmp_xen_colo_do_checkpoint(Error **errp)
{
replication_do_checkpoint_all(errp);
/* Notify all filters of all NIC to do checkpoint */
colo_notify_filters_event(COLO_EVENT_CHECKPOINT, errp);
}
#endif

Expand Down
41 changes: 40 additions & 1 deletion monitor/hmp-cmds.c
Expand Up @@ -27,6 +27,7 @@
#include "monitor/monitor-internal.h"
#include "monitor/qdev.h"
#include "qapi/error.h"
#include "qapi/clone-visitor.h"
#include "qapi/opts-visitor.h"
#include "qapi/qapi-builtin-visit.h"
#include "qapi/qapi-commands-block.h"
Expand All @@ -38,6 +39,7 @@
#include "qapi/qapi-commands-run-state.h"
#include "qapi/qapi-commands-tpm.h"
#include "qapi/qapi-commands-ui.h"
#include "qapi/qapi-visit-net.h"
#include "qapi/qmp/qdict.h"
#include "qapi/qmp/qerror.h"
#include "qapi/string-input-visitor.h"
Expand Down Expand Up @@ -67,6 +69,32 @@ static void hmp_handle_error(Monitor *mon, Error **errp)
}
}

/*
* Produce a strList from a comma separated list.
* A NULL or empty input string return NULL.
*/
static strList *strList_from_comma_list(const char *in)
{
strList *res = NULL;
strList **hook = &res;

while (in && in[0]) {
char *comma = strchr(in, ',');
*hook = g_new0(strList, 1);

if (comma) {
(*hook)->value = g_strndup(in, comma - in);
in = comma + 1; /* skip the , */
} else {
(*hook)->value = g_strdup(in);
in = NULL;
}
hook = &(*hook)->next;
}

return res;
}

void hmp_info_name(Monitor *mon, const QDict *qdict)
{
NameInfo *info;
Expand Down Expand Up @@ -1631,7 +1659,18 @@ void hmp_info_snapshots(Monitor *mon, const QDict *qdict)

void hmp_announce_self(Monitor *mon, const QDict *qdict)
{
qmp_announce_self(migrate_announce_params(), NULL);
const char *interfaces_str = qdict_get_try_str(qdict, "interfaces");
const char *id = qdict_get_try_str(qdict, "id");
AnnounceParameters *params = QAPI_CLONE(AnnounceParameters,
migrate_announce_params());

qapi_free_strList(params->interfaces);
params->interfaces = strList_from_comma_list(interfaces_str);
params->has_interfaces = params->interfaces != NULL;
params->id = g_strdup(id);
params->has_id = !!params->id;
qmp_announce_self(params, NULL);
qapi_free_AnnounceParameters(params);
}

void hmp_migrate_cancel(Monitor *mon, const QDict *qdict)
Expand Down
89 changes: 76 additions & 13 deletions net/announce.c
Expand Up @@ -15,6 +15,8 @@
#include "qapi/qapi-commands-net.h"
#include "trace.h"

static GData *named_timers;

int64_t qemu_announce_timer_step(AnnounceTimer *timer)
{
int64_t step;
Expand All @@ -31,13 +33,38 @@ int64_t qemu_announce_timer_step(AnnounceTimer *timer)
return step;
}

void qemu_announce_timer_del(AnnounceTimer *timer)
/*
* If 'free_named' is true, then remove the timer from the list
* and free the timer itself.
*/
void qemu_announce_timer_del(AnnounceTimer *timer, bool free_named)
{
bool free_timer = false;
if (timer->tm) {
timer_del(timer->tm);
timer_free(timer->tm);
timer->tm = NULL;
}
qapi_free_strList(timer->params.interfaces);
timer->params.interfaces = NULL;
if (free_named && timer->params.has_id) {
AnnounceTimer *list_timer;
/*
* Sanity check: There should only be one timer on the list with
* the id.
*/
list_timer = g_datalist_get_data(&named_timers, timer->params.id);
assert(timer == list_timer);
free_timer = true;
g_datalist_remove_data(&named_timers, timer->params.id);
}
trace_qemu_announce_timer_del(free_named, free_timer, timer->params.id);
g_free(timer->params.id);
timer->params.id = NULL;

if (free_timer) {
g_free(timer);
}
}

/*
Expand All @@ -54,7 +81,7 @@ void qemu_announce_timer_reset(AnnounceTimer *timer,
* We're under the BQL, so the current timer can't
* be firing, so we should be able to delete it.
*/
qemu_announce_timer_del(timer);
qemu_announce_timer_del(timer, false);

QAPI_CLONE_MEMBERS(AnnounceParameters, &timer->params, params);
timer->round = params->rounds;
Expand Down Expand Up @@ -96,29 +123,53 @@ static int announce_self_create(uint8_t *buf,

static void qemu_announce_self_iter(NICState *nic, void *opaque)
{
AnnounceTimer *timer = opaque;
uint8_t buf[60];
int len;
bool skip;

if (timer->params.has_interfaces) {
strList *entry = timer->params.interfaces;
/* Skip unless we find our name in the requested list */
skip = true;

while (entry) {
if (!strcmp(entry->value, nic->ncs->name)) {
/* Found us */
skip = false;
break;
}
entry = entry->next;
}
} else {
skip = false;
}

trace_qemu_announce_self_iter(timer->params.has_id ? timer->params.id : "_",
nic->ncs->name,
qemu_ether_ntoa(&nic->conf->macaddr), skip);

trace_qemu_announce_self_iter(qemu_ether_ntoa(&nic->conf->macaddr));
len = announce_self_create(buf, nic->conf->macaddr.a);
if (!skip) {
len = announce_self_create(buf, nic->conf->macaddr.a);

qemu_send_packet_raw(qemu_get_queue(nic), buf, len);
qemu_send_packet_raw(qemu_get_queue(nic), buf, len);

/* if the NIC provides it's own announcement support, use it as well */
if (nic->ncs->info->announce) {
nic->ncs->info->announce(nic->ncs);
/* if the NIC provides it's own announcement support, use it as well */
if (nic->ncs->info->announce) {
nic->ncs->info->announce(nic->ncs);
}
}
}
static void qemu_announce_self_once(void *opaque)
{
AnnounceTimer *timer = (AnnounceTimer *)opaque;

qemu_foreach_nic(qemu_announce_self_iter, NULL);
qemu_foreach_nic(qemu_announce_self_iter, timer);

if (--timer->round) {
qemu_announce_timer_step(timer);
} else {
qemu_announce_timer_del(timer);
qemu_announce_timer_del(timer, true);
}
}

Expand All @@ -129,12 +180,24 @@ void qemu_announce_self(AnnounceTimer *timer, AnnounceParameters *params)
if (params->rounds) {
qemu_announce_self_once(timer);
} else {
qemu_announce_timer_del(timer);
qemu_announce_timer_del(timer, true);
}
}

void qmp_announce_self(AnnounceParameters *params, Error **errp)
{
static AnnounceTimer announce_timer;
qemu_announce_self(&announce_timer, params);
AnnounceTimer *named_timer;
if (!params->has_id) {
params->id = g_strdup("");
params->has_id = true;
}

named_timer = g_datalist_get_data(&named_timers, params->id);

if (!named_timer) {
named_timer = g_new0(AnnounceTimer, 1);
g_datalist_set_data(&named_timers, params->id, named_timer);
}

qemu_announce_self(named_timer, params);
}

0 comments on commit 8ef53cd

Please sign in to comment.