All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Denis V. Lunev" <den@openvz.org>
To: qemu-devel@nongnu.org
Cc: den@openvz.org, qemu-block@nongnu.org,
	Kevin Wolf <kwolf@redhat.com>, Hanna Reitz <hreitz@redhat.com>,
	Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>,
	Andrey Drobyshev <andrey.drobyshev@virtuozzo.com>
Subject: [PATCH 08/13] qemu-io: accept --object iothread
Date: Wed, 30 Sep 2026 18:49:54 +0200	[thread overview]
Message-ID: <20260930165000.303236-9-den@openvz.org> (raw)
In-Reply-To: <20260930165000.303236-1-den@openvz.org>

From: Denis V. Lunev <den@openvz.org>

qemu-io refused "--object iothread,id=t0" with "invalid object type:
iothread", because iothread.c was built into blockdev_ss, which qemu-io
does not link. Move it to block_ss: it wraps an AioContext and has
nothing to do with blockdev, and linking blockdev instead would drag in
os-posix.c, whose qemu_system_killed() every program linking it has to
define.

Collect the --object arguments during option parsing and process them
once qemu_init_main_loop() has run; nothing before that point uses an
object. An iothread created earlier registers the timer lists of its
AioContext with clocks that qemu_init_clocks() then resets, unlinking
them silently: no failure, just timers that never fire.

Signed-off-by: Denis V. Lunev <den@openvz.org>
CC: Kevin Wolf <kwolf@redhat.com>
CC: Hanna Reitz <hreitz@redhat.com>
CC: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
CC: Andrey Drobyshev <andrey.drobyshev@virtuozzo.com>
---
 meson.build | 2 +-
 qemu-io.c   | 9 ++++++++-
 2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/meson.build b/meson.build
index cfac634cf1..4c3f6518fd 100644
--- a/meson.build
+++ b/meson.build
@@ -3816,6 +3816,7 @@ if have_block
   block_ss.add(files(
     'block.c',
     'blockjob.c',
+    'iothread.c',
     'job.c',
     'qemu-io-cmds.c',
   ))
@@ -3830,7 +3831,6 @@ if have_block
   blockdev_ss.add(files(
     'blockdev.c',
     'blockdev-nbd.c',
-    'iothread.c',
     'job-qmp.c',
   ))
 
diff --git a/qemu-io.c b/qemu-io.c
index 598d5b1c9c..2b684ccf55 100644
--- a/qemu-io.c
+++ b/qemu-io.c
@@ -532,6 +532,7 @@ int main(int argc, char **argv)
     QDict *opts = NULL;
     const char *format = NULL;
     bool force_share = false;
+    g_autoptr(GPtrArray) objects = g_ptr_array_new();
 
 #ifdef CONFIG_POSIX
     signal(SIGPIPE, SIG_IGN);
@@ -607,7 +608,7 @@ int main(int argc, char **argv)
             force_share = true;
             break;
         case OPTION_OBJECT:
-            user_creatable_process_cmdline(optarg);
+            g_ptr_array_add(objects, optarg);
             break;
         case OPTION_IMAGE_OPTS:
             imageOpts = true;
@@ -630,6 +631,11 @@ int main(int argc, char **argv)
 
     qemu_init_main_loop(&error_fatal);
 
+    /* An iothread object cannot be created before the main loop exists. */
+    for (guint i = 0; i < objects->len; i++) {
+        user_creatable_process_cmdline(g_ptr_array_index(objects, i));
+    }
+
     if (!trace_init_backends()) {
         exit(1);
     }
@@ -686,6 +692,7 @@ int main(int argc, char **argv)
     bdrv_drain_all();
 
     blk_unref(qemuio_blk);
+    user_creatable_cleanup();
     g_free(readline_state);
 
     if (ret < 0) {
-- 
2.53.0



  parent reply	other threads:[~2026-09-30 16:51 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-30 16:49 [PATCH 00/13] block: fix data loss in the preallocate filter Denis V. Lunev
2026-09-30 16:49 ` [PATCH 01/13] block/file-posix: drop the XFS workaround for post-EOF fallocate Denis V. Lunev
2026-10-02 16:16   ` Andrey Drobyshev
2026-09-30 16:49 ` [PATCH 02/13] block/preallocate: keep zero_start above written data Denis V. Lunev
2026-10-02 16:16   ` Andrey Drobyshev
2026-09-30 16:49 ` [PATCH 03/13] block/preallocate: collect the state assignments in one place Denis V. Lunev
2026-10-02 16:16   ` Andrey Drobyshev
2026-09-30 16:49 ` [PATCH 04/13] block/preallocate: serialise the filter state Denis V. Lunev
2026-10-02 16:16   ` Andrey Drobyshev
2026-09-30 16:49 ` [PATCH 05/13] block/preallocate: hold back writes into a preallocation in flight Denis V. Lunev
2026-10-02 16:16   ` Andrey Drobyshev
2026-09-30 16:49 ` [PATCH 06/13] iotests/298: add testcase for async writes with preallocation filter Denis V. Lunev
2026-09-30 16:49 ` [PATCH 07/13] tests/unit: prefix the iothread test helper Denis V. Lunev
2026-10-05 20:06   ` Eric Blake
2026-09-30 16:49 ` Denis V. Lunev [this message]
2026-10-05 20:11   ` [PATCH 08/13] qemu-io: accept --object iothread Eric Blake
2026-09-30 16:49 ` [PATCH 09/13] qemu-io: add -t to run an aio request in a named iothread Denis V. Lunev
2026-10-05 20:28   ` Eric Blake
2026-09-30 16:49 ` [PATCH 10/13] qemu-io: add -g to write past the end of the image Denis V. Lunev
2026-10-05 20:36   ` Eric Blake
2026-09-30 16:49 ` [PATCH 11/13] block/blkdebug: make a breakpoint work across AioContexts Denis V. Lunev
2026-10-05 20:42   ` Eric Blake
2026-09-30 16:49 ` [PATCH 12/13] block: add blkdebug events for a write before it is tracked Denis V. Lunev
2026-10-05 20:45   ` Eric Blake
2026-09-30 16:49 ` [PATCH 13/13] iotests/298: cover the preallocation races Denis V. Lunev
2026-10-05 21:06   ` Eric Blake

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260930165000.303236-9-den@openvz.org \
    --to=den@openvz.org \
    --cc=andrey.drobyshev@virtuozzo.com \
    --cc=hreitz@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=vsementsov@yandex-team.ru \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.