summary refs log tree commit diff stats
path: root/util/qemu-option.c
diff options
context:
space:
mode:
authorKevin Wolf <kwolf@redhat.com>2021-10-08 15:34:37 +0200
committerKevin Wolf <kwolf@redhat.com>2021-10-15 16:11:22 +0200
commit30648dd5d609d111e635112d7e6014ca63f7ba13 (patch)
tree7d75569fee18ec37740e93300649932e02a551a9 /util/qemu-option.c
parent4a1d937796de0fecd8b22d7dbebf87f38e8282fd (diff)
downloadfocaccia-qemu-30648dd5d609d111e635112d7e6014ca63f7ba13.tar.gz
focaccia-qemu-30648dd5d609d111e635112d7e6014ca63f7ba13.zip
qemu-option: Allow deleting opts during qemu_opts_foreach()
Use QTAILQ_FOREACH_SAFE() so that the current QemuOpts can be deleted
while iterating through the whole list.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Message-Id: <20211008133442.141332-11-kwolf@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Tested-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Diffstat (limited to 'util/qemu-option.c')
-rw-r--r--util/qemu-option.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/util/qemu-option.c b/util/qemu-option.c
index 61cb4a97bd..eedd08929b 100644
--- a/util/qemu-option.c
+++ b/util/qemu-option.c
@@ -1126,11 +1126,11 @@ int qemu_opts_foreach(QemuOptsList *list, qemu_opts_loopfunc func,
                       void *opaque, Error **errp)
 {
     Location loc;
-    QemuOpts *opts;
+    QemuOpts *opts, *next;
     int rc = 0;
 
     loc_push_none(&loc);
-    QTAILQ_FOREACH(opts, &list->head, next) {
+    QTAILQ_FOREACH_SAFE(opts, &list->head, next, next) {
         loc_restore(&opts->loc);
         rc = func(opaque, opts, errp);
         if (rc) {