[pve-devel] [PATCH qemu-server v6 2/4] api: status/current: add display property
Fiona Ebner
f.ebner at proxmox.com
Tue Apr 8 13:26:11 CEST 2025
Am 08.04.25 um 12:37 schrieb Aaron Lauterer:
> This new property returns the configured or default display for a VM.
>
> Instead of a flat property, we use a nested 'type' object that contains
> the actual information. This way we can add other properties that belong
> to a VM's display in the future without much hassle, to have them all in
> one place.
> Candidates to be moved into the display property are for example the
> spice and clipboard property.
>
> Signed-off-by: Aaron Lauterer <a.lauterer at proxmox.com>
> ---
> Getting all the parameters for get_vga_properties added a bit of
> boilerplate. Should be get another external call site to it we could
> think about moving the boilerplate into get_vga_properties to handle
> missing parameters. But for now I would rather not change the
> get_vga_properties itself.
Yeah, that's not too nice. FWIW, machine versions 2.X will get dropped
with QEMU 10.0, so at least we'll not require the machine version
anymore then.
> @@ -3087,8 +3097,19 @@ __PACKAGE__->register_method({
>
> $status->{ha} = PVE::HA::Config::get_service_status("vm:$param->{vmid}");
>
> + my $arch = PVE::QemuServer::Helpers::get_vm_arch($conf);
> + my $kvm_binary = PVE::QemuServer::Helpers::get_command_for_arch($arch);
> + my $kvmver = PVE::QemuServer::Helpers::kvm_user_version($kvm_binary);
> + my $machine_type = PVE::QemuServer::Machine::get_vm_machine($conf, undef, $arch);
> + my $machine_version = PVE::QemuServer::extract_version($machine_type, $kvmver);
Please use the PVE::QemuServer::Machine::extract_version() helper here.
> + my $winversion = PVE::QemuServer::Helpers::windows_version($conf->{ostype});
> + my ($default_display, undef) = PVE::QemuServer::get_vga_properties($conf, $arch, $machine_version, $winversion);
That's not necessarily the default display. It's only the default if
there is no $conf->{vga}. It /would/ already be the effectively
configured one, except...the helper re-maps 'qxl2', 'qxl3' and 'qxl4' to
'qxl' :/ And because of that re-mapping you'll still need the line below
after parsing.
(The qxl ones shouldn't have been separate types in hindsight, but
rather type=qxl,qxl-display-count=N, but too late for that).
I guess we do want a separate helper get_deafult_vga_type() for just
getting the default and use that here and within get_vga_properties().
> +
> + $status->{display}->{type} = $default_display->{type};
> if ($conf->{vga}) {
> my $vga = PVE::QemuServer::parse_vga($conf->{vga});
> + $status->{display}->{type} = $vga->{type} if defined($vga->{type});
> +
> my $spice = defined($vga->{type}) && $vga->{type} =~ /^virtio/;
> $spice ||= PVE::QemuServer::vga_conf_has_spice($conf->{vga});
> $status->{spice} = 1 if $spice;
More information about the pve-devel
mailing list