[pve-devel] [PATCH qemu-server 1/2] use KillMode 'process' for systemd scope

Stefan Reiter s.reiter at proxmox.com
Tue Jun 22 09:23:28 CEST 2021


On 22/06/2021 08:02, Thomas Lamprecht wrote:
> On 21.06.21 18:35, Stefan Reiter wrote:
>> KillMode 'none' is deprecated, and systemd loudly complains about that
>> in the journal. To avoid the warning, but keep the behaviour the same,
>> use KillMode 'process'.
>>
>> This mode does two things differently, which we have to stop it from
>> doing:
>> * it sends SIGTERM right when the scope is cancelled (e.g. on shutdown)
>>   -> but only to the "root" process, which in our case is the worker
>>   instance forking QEMU, so it is already dead by the time this happens
>> * it sends SIGKILL to *all* children after a timeout
>>   -> can be avoided by setting either SendSIGKILL to false, or
>>   TimeoutStopUSec to infinity - for safety, we do both
>>
>> In my testing, this replicated the previous behaviour exactly, but
>> without using the deprecated 'none' mode.
>>
>> Signed-off-by: Stefan Reiter <s.reiter at proxmox.com>
>> ---
>>
>> Depends on updated pve-common from patch 2.
>>
>>   PVE/QemuServer.pm | 4 +++-
>>   1 file changed, 3 insertions(+), 1 deletion(-)
>>
>> diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm
>> index 07dd14a..d5b7ead 100644
>> --- a/PVE/QemuServer.pm
>> +++ b/PVE/QemuServer.pm
>> @@ -5286,7 +5286,9 @@ sub vm_start_nolock {
>>   
>>       my %properties = (
>>   	Slice => 'qemu.slice',
>> -	KillMode => 'none'
>> +	KillMode => 'process',
>> +	SendSIGKILL => 0,
>> +	TimeoutStopUSec => ULONG_MAX, # infinity
> 
> 
> I wasn't sure if  ULONG_MAX is used literally, making 71 minutes on 32 bit and ~584k years
> on 64bit, or if it is translated internally to 'infinity', I mean with us only supporting
> 64-bit a duration of 584k year, while not infinity, would be more than enough, but still,
> always good to check those things IMO:
> 
>  From `src/basic/time-util.h`
> 
> typedef uint64_t usec_t;
>   ...
> #define USEC_INFINITY ((usec_t) -1)
> 
> So, yes, literally means infinity.
> 

yeah sorry, should have made the comment more obvious - that's where I 
got the value from too





More information about the pve-devel mailing list