Browse Source

net/filter-buffer: make interval change take effect immediately

Previously, when the 'interval' property was modified at runtime via
QMP, the new value would only take effect after the current timer
period elapsed. This could lead to unexpected behavior when users
expect immediate changes.

Fix this by checking if the timer is already running when setting
the interval property. If so, reschedule the timer with the new
interval value immediately.

Reviewed-by: Zhang Chen <zhangckid@gmail.com>
Signed-off-by: Jason Wang <jasowang@redhat.com>
pull/316/head
Jason Wang 3 months ago
parent
commit
60a8b9b75a
  1. 6
      net/filter-buffer.c

6
net/filter-buffer.c

@ -159,6 +159,7 @@ static void filter_buffer_set_interval(Object *obj, Visitor *v,
Error **errp)
{
FilterBufferState *s = FILTER_BUFFER(obj);
NetFilterState *nf = NETFILTER(obj);
uint32_t value;
if (!visit_type_uint32(v, name, &value, errp)) {
@ -170,6 +171,11 @@ static void filter_buffer_set_interval(Object *obj, Visitor *v,
return;
}
s->interval = value;
if (nf->netdev && nf->on) {
timer_mod(&s->release_timer,
qemu_clock_get_us(QEMU_CLOCK_VIRTUAL) + s->interval);
}
}
static void filter_buffer_class_init(ObjectClass *oc, const void *data)

Loading…
Cancel
Save