public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Dominik Csapak <d.csapak@proxmox.com>
To: Kaiyang Wu <wukaiyang2003@gmail.com>, pve-devel@lists.proxmox.com
Cc: Kaiyang Wu <wukaiyang@loongfans.cn>
Subject: Re: [PATCH qemu-server 1/3] qemuserver: add pvpanic device
Date: Fri, 4 Sep 2026 10:30:05 +0200	[thread overview]
Message-ID: <80d7911d-77d5-40aa-af27-a0bac993858c@proxmox.com> (raw)
In-Reply-To: <20260827103529.393388-2-wukaiyang@loongfans.cn>

comment inline

On 8/27/26 12:35 PM, Kaiyang Wu wrote:
> Add pvpanic device to monitor virtual machine system panics. Add pvpanic
> field in virtual machine configuration files, allowing to choose the ISA
> or the PCI variant of the pvpanic device.
> 
> Signed-off-by: Kaiyang Wu <wukaiyang@loongfans.cn>
> ---
>   src/PVE/API2/Qemu.pm      |  1 +
>   src/PVE/QemuServer.pm     | 19 +++++++++++++++++++
>   src/PVE/QemuServer/PCI.pm |  1 +
>   3 files changed, 21 insertions(+)
> 
> diff --git a/src/PVE/API2/Qemu.pm b/src/PVE/API2/Qemu.pm
> index 71247eec..933f6221 100644
> --- a/src/PVE/API2/Qemu.pm
> +++ b/src/PVE/API2/Qemu.pm
> @@ -818,6 +818,7 @@ my $hwtypeoptions = {
>       'watchdog' => 1,
>       'audio0' => 1,
>       'rng0' => 1,
> +    'pvpanic0' => 1,
>   };
>   
>   my $generaloptions = {
> diff --git a/src/PVE/QemuServer.pm b/src/PVE/QemuServer.pm
> index 63d8c135..f476af94 100644
> --- a/src/PVE/QemuServer.pm
> +++ b/src/PVE/QemuServer.pm
> @@ -739,6 +739,13 @@ EODESCR
>           optional => 1,
>           default => 1,
>       },
> +    pvpanic0 => {

since it won't make sense (ever?) to add multiple panic devices,
i think having simply 'pvpanic' is enough, no need to add an index

> +        optional => 1,
> +        type => 'string',
> +        description => "Configure a pvpanic device to monitor guest panics",
> +        enum => [qw(pvpanic pvpanic-pci)],

is it really useful to have two variants? couldn't we always
use the PCI variant or is there some specific usecase for the ISA one?

It could even be simply an option somewhere else (e.g. on the machine 
maybe?)

if we just have single option, this might simplify the code below...

> +        default => undef,
> +    },
>   };
>   
>   my $cicustom_fmt = {
> @@ -3415,6 +3422,18 @@ sub config_to_command {
>           push @$cmd, '-nographic';
>       }
>   
> +    my $pvpanic = $conf->{pvpanic0};
> +    if (defined($pvpanic)) {
> +        if ($pvpanic eq 'pvpanic') {
> +            push @$devices, '-device', $pvpanic;
> +        } elsif ($pvpanic eq 'pvpanic-pci') {
> +            my $pvpanicpciaddr = print_pci_addr("pvpanic0", $bridges, $arch);
> +            push @$devices, '-device', "$pvpanic,id=pvpanic$pvpanicpciaddr";
> +        } else {
> +            die "unknown pvpanic device type $pvpanic";
> +        }
> +    }

... here.

this would all collapse into a single
---
if (defined()) {
     push ...
}
---

part

> +
>       # For now, handles only specific parts, but the final goal is to cover everything.
>       my $cfg2cmd_opts = { forcemachine => $forcemachine };
>       my $cfg2cmd = PVE::QemuServer::Cfg2Cmd->new($conf, $defaults, $version_guard, $cfg2cmd_opts);
> diff --git a/src/PVE/QemuServer/PCI.pm b/src/PVE/QemuServer/PCI.pm
> index 0b67943c..56770091 100644
> --- a/src/PVE/QemuServer/PCI.pm
> +++ b/src/PVE/QemuServer/PCI.pm
> @@ -220,6 +220,7 @@ sub get_pci_addr_map {
>           'pci.4' => { bus => 1, addr => 28 },
>           'rng0' => { bus => 1, addr => 29 },
>           'pci.2-igd' => { bus => 1, addr => 30 }, # replaces pci.2 in case a legacy IGD device is passed through
> +        'pvpanic0' => { bus => 1, addr => 31 },
>           'virtio6' => { bus => 2, addr => 1 },
>           'virtio7' => { bus => 2, addr => 2 },
>           'virtio8' => { bus => 2, addr => 3 },

side note (not really directed at you though)"
urgh i really hate that we have to do it this way (finding free slots
by checking each line if there is a gap...)

I'm currently rewriting part of the pci addr handling so this
should become a bit better in the future...




  reply	other threads:[~2026-09-04  8:30 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-27 10:35 [PATCH qemu-server/docs/manager 0/3] add pvpanic device support Kaiyang Wu
2026-08-27 10:35 ` [PATCH qemu-server 1/3] qemuserver: add pvpanic device Kaiyang Wu
2026-09-04  8:30   ` Dominik Csapak [this message]
2026-08-27 10:35 ` [PATCH docs 2/3] qm: add document section for the " Kaiyang Wu
2026-08-27 10:35 ` [PATCH manager 3/3] ui: qemu: add pvpanic device support Kaiyang Wu
2026-09-04  8:30   ` Dominik Csapak
2026-09-03  8:42 ` [PATCH qemu-server/docs/manager 0/3] " Kaiyang Wu
2026-09-04  8:30 ` Dominik Csapak

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=80d7911d-77d5-40aa-af27-a0bac993858c@proxmox.com \
    --to=d.csapak@proxmox.com \
    --cc=pve-devel@lists.proxmox.com \
    --cc=wukaiyang2003@gmail.com \
    --cc=wukaiyang@loongfans.cn \
    /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 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