From: Jiaqing Zhao <Zhao.Jiaqing@amd.com>
To: Jason Andryuk <jason.andryuk@amd.com>, xen-devel@lists.xenproject.org
Cc: "Anthony PERARD" <anthony.perard@vates.tech>,
"Juergen Gross" <jgross@suse.com>,
"Roger Pau Monné" <roger@xenproject.com>,
"Stefano Stabellini" <sstabellini@kernel.org>,
"Penny Zheng" <penny.zheng@amd.com>
Subject: Re: [PATCH] libxl: wait for QEMU exit before restarting a domain
Date: Thu, 5 Nov 2026 13:36:38 +0800 [thread overview]
Message-ID: <7750495f-c007-4b56-aaba-cb85ecfa6820@amd.com> (raw)
In-Reply-To: <0762b21d-3173-4014-bd43-fa2a9cef9c85@amd.com>
On 2026-11-05 01:33, Jason Andryuk wrote:
> On 2026-11-04 01:46, Jiaqing Zhao wrote:
>> The PID-based device model destruction path returns immediately after
>> sending SIGHUP, before QEMU has necessarily exited. When an HVM guest
>> reboots with VNC enabled, the new QEMU process may fail to bind the VNC
>> port because the old process still holds it.
>>
>> Wait for QEMU to exit in a child process after singaling it for at most
>
> "signaling"
>
>> 60 seconds. If waiting fails or times out, log the error and retain the
>> existing domain destruction behaviour.
>
> 60 seconds seems like a lot. Did you measure the time to see how long it takes? It's an upper bound, but maybe 10 seconds would be better?
Typically it costs less than 3s. Most time it only takes 1s. Will change
to 10s in v2.
>> Signed-off-by: Jiaqing Zhao <Zhao.Jiaqing@amd.com>
>
>> @@ -3547,12 +3564,28 @@ void libxl__destroy_device_model(libxl__egc *egc,
>> LOGD(DEBUG, domid, "Didn't find dm UID; destroying by pid");
>> path = GCSPRINTF("/local/domain/%d/image/device-model-pid", domid);
>> - rc = kill_device_model(gc, path);
>> -
>> + rc = kill_device_model(gc, path, &dm_pid);
>
> If you just read the pid directly here, you don't need to change kill_device_model(). But your approach is only a single read, so maybe it's better. I'm undecided, but maybe someone else has an opinion.
Yes keeping old kill_device_model() requires an extra libxl__xs_read_checked()
to read the pid. Let's wait for more comments.
>> if (rc) {
>> ACCUMULATE_RC(ddms->rc);
>> LOGD(ERROR, domid, "Killing device model pid from path %s", path);
>> + goto out;
>> + }
>> +
>> + LOGD(DEBUG, domid, "Waiting for device model [%d] to exit", dm_pid);
>> + reaper_pid = libxl__ev_child_fork(gc, &ddms->destroyer,
>> + kill_device_model_uid_cb);
>
> The reaper_pid handling below is duplicated from
> `if (dm_kill_uid_str) {`
>
> Put the above pid code in an else, and use a single implementation of the reaper_pid handling.
>
>> + if (reaper_pid < 0) {
>> + rc = ERROR_FAIL;
>> + ACCUMULATE_RC(ddms->rc);
>> + LOGD(ERROR, domid, "Unable to fork device model exit waiter");
>> + goto out;
>> }
>> + if (!reaper_pid) {
>> + rc = wait_device_model_pid_child(gc, domid, dm_pid);
>
> Though this would need an additional conditional.
>
> Thanks,
> Jason
Sure, will do in v2.
>> + assert(rc <= 0 && rc >= -125);
>> + _exit(-rc);
>> + }
>> + return;
>> out:
>> /*
next prev parent reply other threads:[~2026-11-05 5:37 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-04 6:46 [PATCH] libxl: wait for QEMU exit before restarting a domain Jiaqing Zhao
2026-11-04 17:33 ` Jason Andryuk
2026-11-05 5:36 ` Jiaqing Zhao [this message]
2026-11-05 8:13 ` Jan Beulich
2026-11-10 9:10 ` Jiaqing Zhao
2026-11-10 9:22 ` Jan Beulich
2026-11-06 9:17 ` Roger Pau Monné
2026-11-10 9:27 ` Jiaqing Zhao
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=7750495f-c007-4b56-aaba-cb85ecfa6820@amd.com \
--to=zhao.jiaqing@amd.com \
--cc=anthony.perard@vates.tech \
--cc=jason.andryuk@amd.com \
--cc=jgross@suse.com \
--cc=penny.zheng@amd.com \
--cc=roger@xenproject.com \
--cc=sstabellini@kernel.org \
--cc=xen-devel@lists.xenproject.org \
/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.