[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] libxl: wait for QEMU exit before restarting a domain


  • To: Jason Andryuk <jason.andryuk@xxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxxx
  • From: Jiaqing Zhao <Zhao.Jiaqing@xxxxxxx>
  • Date: Thu, 5 Nov 2026 13:36:38 +0800
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=amd.com; dmarc=pass action=none header.from=amd.com; dkim=pass header.d=amd.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=nTdQjIkgwe2il1v3wDnnVUE8kYmkCUg3nXFxQlfrlEk=; b=b69tFUlJ/T92O6BtEeD9ZpQaSnwvq48HwHwExyAeSHpmd4Ei4cnbCAcFSXWHwO1jTWafMQpuesRQa5aM2fceVHZTdIggmmGEeULIMqCMGCK6JLo/uNQr27wqOdlkUb3MjN0wh+DY74NoDPcQtETaCNHp5b90D7ZJlvQXY5EBj/rWkWP66P1YxSMvAeG0WZpgZ4TLxZWHo50/J+MGmdcxLkAregmFQfjlzw6QquWL7gZcTCdPiCbfoL73A/96xPKuHHQl0ZNPv5oy+Cfv5ImEzUZyT1WauIxLyvyznMBaN8lbr3ENecPWCQiacqsfsCkDkiZle3cCPX1Tsv0b3cMu4g==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=p09/G4CtcCGmS1De82c5rIJBS1d5pQsRvr2h3oecRLCN1MJGOYHeCaoR2n3glE3ZaTyHwgMoSCFkEuEQqOJSzClmGyGU04PrqvsUrJEv8YguRR6aeFSCXRsJwhy6BvFq9WULYeXzMEGDce94HQJLxIVrB/cyWQ22WzyohgGMRRcJGyIPCJyTXvdWeRmnnhYk8MGYqT/3WAt1sPNYr3yZPKV97iUmbBeKsH5P6AZs2O0cPkcjJmI5Sk4vu9zbn4JGZv4QOxEGyvC7hd7UjhpW+oby53MHxjV0dOiuFEzNV9XoQN5cCNHWSFMELCeoidpBhu/kQg0qx4dNpf5YXA2gSg==
  • Authentication-results: eu.smtp.expurgate.cloud; dkim=pass header.s=selector1 header.d=amd.com header.i="@amd.com" header.h="From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck"
  • Authentication-results: mx.microsoft.com 1; dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=amd.com;
  • Cc: Anthony PERARD <anthony.perard@xxxxxxxxxx>, Juergen Gross <jgross@xxxxxxxx>, Roger Pau Monné <roger@xxxxxxxxxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Penny Zheng <penny.zheng@xxxxxxx>
  • Delivery-date: Thu, 05 Nov 2026 05:37:06 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

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@xxxxxxx>
> 
>> @@ -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:
>>       /*




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.