]> git.ipfire.org Git - thirdparty/qemu.git/commitdiff
net/filter-buffer: make interval change take effect immediately
authorJason Wang <jasowang@redhat.com>
Mon, 29 Dec 2025 08:45:40 +0000 (16:45 +0800)
committerJason Wang <jasowang@redhat.com>
Fri, 23 Jan 2026 06:43:57 +0000 (14:43 +0800)
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>
net/filter-buffer.c

index a36be31dc8ec437d76079cb9b4c6df0a59f840e6..427da24097f2ec0897f69ba4ec5c9d7dbe6e9a52 100644 (file)
@@ -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)