public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
* [pve-devel] [PATCH qemu-server] vm_start: add syslog info with which PID a VM was started
@ 2024-09-26  8:36 Daniel Kral
  2024-10-22 11:13 ` Fiona Ebner
  0 siblings, 1 reply; 3+ messages in thread
From: Daniel Kral @ 2024-09-26  8:36 UTC (permalink / raw)
  To: pve-devel

Adds a syslog entry to log the process id that has been given to the
QEMU VM process at start. This is helpful debugging information if the
pid shows up at other places, like a kernel stack trace, while the VM
has been running, but cannot be retrieved anymore (e.g. the pidfile has
been deleted or only the syslog is available).

The syslog has been put in the `PVE::QemuServer::vm_start_nolock`
subroutine to make sure that the PID is logged not only when the VM has
been started by the API endpoint `vm_start`, but also when the VM is
started by a remote migration.

Signed-off-by: Daniel Kral <d.kral@proxmox.com>
Suggested-by: Hannes Dürr <h.duerr@proxmox.com>
Suggested-by: Friedrich Weber <f.weber@proxmox.com>
---
 PVE/QemuServer.pm | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm
index b26da505..d998b360 100644
--- a/PVE/QemuServer.pm
+++ b/PVE/QemuServer.pm
@@ -43,6 +43,7 @@ use PVE::ProcFSTools;
 use PVE::PBSClient;
 use PVE::RESTEnvironment qw(log_warn);
 use PVE::RPCEnvironment;
+use PVE::SafeSyslog;
 use PVE::Storage;
 use PVE::SysFSTools;
 use PVE::Systemd;
@@ -5971,6 +5972,8 @@ sub vm_start_nolock {
     eval { PVE::QemuServer::PCI::reserve_pci_usage($pci_reserve_list, $vmid, undef, $pid) };
     warn $@ if $@;
 
+    syslog("info", "VM $vmid started with pid $pid.");
+
     if (defined(my $migrate = $res->{migrate})) {
 	if ($migrate->{proto} eq 'tcp') {
 	    my $nodename = nodename();
-- 
2.39.5



_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [pve-devel] [PATCH qemu-server] vm_start: add syslog info with which PID a VM was started
  2024-09-26  8:36 [pve-devel] [PATCH qemu-server] vm_start: add syslog info with which PID a VM was started Daniel Kral
@ 2024-10-22 11:13 ` Fiona Ebner
  2024-10-23 10:01   ` Daniel Kral
  0 siblings, 1 reply; 3+ messages in thread
From: Fiona Ebner @ 2024-10-22 11:13 UTC (permalink / raw)
  To: Proxmox VE development discussion, Daniel Kral

Am 26.09.24 um 10:36 schrieb Daniel Kral:
> Adds a syslog entry to log the process id that has been given to the
> QEMU VM process at start. This is helpful debugging information if the
> pid shows up at other places, like a kernel stack trace, while the VM
> has been running, but cannot be retrieved anymore (e.g. the pidfile has
> been deleted or only the syslog is available).
> 
> The syslog has been put in the `PVE::QemuServer::vm_start_nolock`
> subroutine to make sure that the PID is logged not only when the VM has
> been started by the API endpoint `vm_start`, but also when the VM is
> started by a remote migration.
> 
> Signed-off-by: Daniel Kral <d.kral@proxmox.com>
> Suggested-by: Hannes Dürr <h.duerr@proxmox.com>
> Suggested-by: Friedrich Weber <f.weber@proxmox.com>

Nit: the Signed-off-by trailer should come after the Suggested-by
trailers, because it was the last thing that happened chronologically
(the change was first suggested, then you wrote it ;)).

With the nits addressed:

Reviewed-by: Fiona Ebner <f.ebner@proxmox.com>

> ---
>  PVE/QemuServer.pm | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm
> index b26da505..d998b360 100644
> --- a/PVE/QemuServer.pm
> +++ b/PVE/QemuServer.pm
> @@ -43,6 +43,7 @@ use PVE::ProcFSTools;
>  use PVE::PBSClient;
>  use PVE::RESTEnvironment qw(log_warn);
>  use PVE::RPCEnvironment;
> +use PVE::SafeSyslog;
>  use PVE::Storage;
>  use PVE::SysFSTools;
>  use PVE::Systemd;
> @@ -5971,6 +5972,8 @@ sub vm_start_nolock {
>      eval { PVE::QemuServer::PCI::reserve_pci_usage($pci_reserve_list, $vmid, undef, $pid) };
>      warn $@ if $@;
>  
> +    syslog("info", "VM $vmid started with pid $pid.");

Nit: I'd capitalize "PID"

> +
>      if (defined(my $migrate = $res->{migrate})) {
>  	if ($migrate->{proto} eq 'tcp') {
>  	    my $nodename = nodename();


_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [pve-devel] [PATCH qemu-server] vm_start: add syslog info with which PID a VM was started
  2024-10-22 11:13 ` Fiona Ebner
@ 2024-10-23 10:01   ` Daniel Kral
  0 siblings, 0 replies; 3+ messages in thread
From: Daniel Kral @ 2024-10-23 10:01 UTC (permalink / raw)
  To: Fiona Ebner, Proxmox VE development discussion

On 10/22/24 13:13, Fiona Ebner wrote:
> Am 26.09.24 um 10:36 schrieb Daniel Kral:
>> Adds a syslog entry to log the process id that has been given to the
>> QEMU VM process at start. This is helpful debugging information if the
>> pid shows up at other places, like a kernel stack trace, while the VM
>> has been running, but cannot be retrieved anymore (e.g. the pidfile has
>> been deleted or only the syslog is available).
>>
>> The syslog has been put in the `PVE::QemuServer::vm_start_nolock`
>> subroutine to make sure that the PID is logged not only when the VM has
>> been started by the API endpoint `vm_start`, but also when the VM is
>> started by a remote migration.
>>
>> Signed-off-by: Daniel Kral <d.kral@proxmox.com>
>> Suggested-by: Hannes Dürr <h.duerr@proxmox.com>
>> Suggested-by: Friedrich Weber <f.weber@proxmox.com>
> 
> Nit: the Signed-off-by trailer should come after the Suggested-by
> trailers, because it was the last thing that happened chronologically
> (the change was first suggested, then you wrote it ;)).

Thanks for the clarification, makes sense and will keep that in mind in 
future cases for sure :).

> 
> With the nits addressed:
> 
> Reviewed-by: Fiona Ebner <f.ebner@proxmox.com>
> 
>> ---
>>   PVE/QemuServer.pm | 3 +++
>>   1 file changed, 3 insertions(+)
>>
>> diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm
>> index b26da505..d998b360 100644
>> --- a/PVE/QemuServer.pm
>> +++ b/PVE/QemuServer.pm
>> @@ -43,6 +43,7 @@ use PVE::ProcFSTools;
>>   use PVE::PBSClient;
>>   use PVE::RESTEnvironment qw(log_warn);
>>   use PVE::RPCEnvironment;
>> +use PVE::SafeSyslog;
>>   use PVE::Storage;
>>   use PVE::SysFSTools;
>>   use PVE::Systemd;
>> @@ -5971,6 +5972,8 @@ sub vm_start_nolock {
>>       eval { PVE::QemuServer::PCI::reserve_pci_usage($pci_reserve_list, $vmid, undef, $pid) };
>>       warn $@ if $@;
>>   
>> +    syslog("info", "VM $vmid started with pid $pid.");
> 
> Nit: I'd capitalize "PID"
> 
>> +
>>       if (defined(my $migrate = $res->{migrate})) {
>>   	if ($migrate->{proto} eq 'tcp') {
>>   	    my $nodename = nodename();

Sent a v2 with both changes [0].

[0] 
https://lore.proxmox.com/pve-devel/20241023095543.57202-1-d.kral@proxmox.com/


_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-10-23 10:00 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-09-26  8:36 [pve-devel] [PATCH qemu-server] vm_start: add syslog info with which PID a VM was started Daniel Kral
2024-10-22 11:13 ` Fiona Ebner
2024-10-23 10:01   ` Daniel Kral

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal