@@ -63,7 +63,7 @@ index afb535c2..db6c3d80 100644
6363 };
6464 die "could not load supported machine versions - $@\n" if $@;
6565diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm
66- index 2046a7c5..942c448d 100644
66+ index 2046a7c5..a958eb77 100644
6767--- a/PVE/QemuServer.pm
6868+++ b/PVE/QemuServer.pm
6969@@ -98,11 +98,40 @@ my $OVMF = {
@@ -421,7 +421,18 @@ index 2046a7c5..942c448d 100644
421421 push @$devices, '-object', get_amd_sev_object($conf->{'amd-sev'}, $conf->{bios});
422422 push @$machineFlags, 'confidential-guest-support=sev0';
423423 }
424- @@ -5049,10 +5107,10 @@ sub vmconfig_hotplug_pending {
424+ @@ -4359,6 +4417,10 @@ sub vm_deviceplug {
425+
426+ my $machine_type = PVE::QemuServer::Machine::qemu_machine_pxe($vmid, $conf);
427+ my $machine_version = PVE::QemuServer::Machine::extract_version($machine_type);
428+ + #loongarch qemu is special, we get machine_version from the current qemu version
429+ + if ( $arch eq 'loongarch64'){
430+ + $machine_version = extract_version($machine_type, kvm_user_version());
431+ + }
432+ my $use_old_bios_files = undef;
433+ ($use_old_bios_files, $machine_type) = qemu_use_old_bios_files($machine_type);
434+
435+ @@ -5049,10 +5111,10 @@ sub vmconfig_hotplug_pending {
425436 if ($defaults->{tablet}) {
426437 vm_deviceplug($storecfg, $conf, $vmid, 'tablet', $arch, $machine_type);
427438 vm_deviceplug($storecfg, $conf, $vmid, 'keyboard', $arch, $machine_type)
@@ -434,7 +445,7 @@ index 2046a7c5..942c448d 100644
434445 }
435446 } elsif ($opt =~ m/^usb(\d+)$/) {
436447 my $index = $1;
437- @@ -5114,10 +5172 ,10 @@ sub vmconfig_hotplug_pending {
448+ @@ -5114,10 +5176 ,10 @@ sub vmconfig_hotplug_pending {
438449 if ($value == 1) {
439450 vm_deviceplug($storecfg, $conf, $vmid, 'tablet', $arch, $machine_type);
440451 vm_deviceplug($storecfg, $conf, $vmid, 'keyboard', $arch, $machine_type)
@@ -448,7 +459,7 @@ index 2046a7c5..942c448d 100644
448459 } elsif ($opt =~ m/^usb(\d+)$/) {
449460 my $index = $1;
450461diff --git a/PVE/QemuServer/CPUConfig.pm b/PVE/QemuServer/CPUConfig.pm
451- index e65d8c26..8432e6f6 100644
462+ index e65d8c26..c229c35f 100644
452463--- a/PVE/QemuServer/CPUConfig.pm
453464+++ b/PVE/QemuServer/CPUConfig.pm
454465@@ -39,22 +39,22 @@ sub load_custom_model_conf {
@@ -490,7 +501,7 @@ index e65d8c26..8432e6f6 100644
490501 };
491502
492503 my $depreacated_cpu_map = {
493- @@ -76,100 +76,100 @@ my $cputypes_32bit = {
504+ @@ -76,100 +76,101 @@ my $cputypes_32bit = {
494505
495506 my $cpu_vendor_list = {
496507 # Intel CPUs
@@ -664,7 +675,8 @@ index e65d8c26..8432e6f6 100644
664675+ 'max' => 'default',
665676+ 'la464_loongarch_cpu' => 'default',
666677+ 'rv64' => 'default',
667- +
678+ + 'la464' => 'default',
679+ + 'la132' => 'default',
668680 };
669681
670682 my @supported_cpu_flags = (
@@ -682,7 +694,7 @@ index e65d8c26..8432e6f6 100644
682694 'aes'
683695 );
684696 my $cpu_flag_supported_re = qr/([+-])(@{[join('|', @supported_cpu_flags)]})/;
685- @@ -191,7 +191 ,7 @@ my $cpu_fmt = {
697+ @@ -191,7 +192 ,7 @@ my $cpu_fmt = {
686698 ." Only valid for custom CPU model definitions, default models will always report themselves to the guest OS.",
687699 type => 'string',
688700 enum => [ sort { lc("$a") cmp lc("$b") } keys %$cpu_vendor_list ],
@@ -691,7 +703,19 @@ index e65d8c26..8432e6f6 100644
691703 optional => 1,
692704 },
693705 hidden => {
694- @@ -633,7 +633,7 @@ sub get_cpu_options {
706+ @@ -576,6 +577,11 @@ sub get_cpu_options {
707+ or die "Cannot parse cpu description: $cpu_prop_str\n";
708+
709+ $cputype = $cpu->{cputype};
710+ +
711+ + if ( $cputype eq 'la464_loongarch_cpu' ) {
712+ + $cputype = 'la464';
713+ + }
714+ +
715+ if (my $model = $builtin_models->{$cputype}) {
716+ $cputype = $model->{'reported-model'};
717+ $builtin_cpu->{flags} = $model->{'flags'};
718+ @@ -633,7 +639,7 @@ sub get_cpu_options {
695719 $pve_forced_flags->{'vendor'} = {
696720 value => $cpu_vendor,
697721 } if $cpu_vendor ne 'default';
@@ -700,7 +724,7 @@ index e65d8c26..8432e6f6 100644
700724 die "internal error"; # should not happen
701725 }
702726
703- @@ -770,7 +770 ,10 @@ sub get_default_cpu_type {
727+ @@ -770,7 +776 ,10 @@ sub get_default_cpu_type {
704728 my ($arch, $kvm) = @_;
705729
706730 my $cputype = $kvm ? 'kvm64' : 'qemu64';
@@ -712,7 +736,7 @@ index e65d8c26..8432e6f6 100644
712736
713737 return $cputype;
714738 }
715- @@ -802,7 +805 ,9 @@ sub get_cpu_bitness {
739+ @@ -802,7 +811 ,9 @@ sub get_cpu_bitness {
716740 }
717741
718742 return $cputypes_32bit->{$cputype} ? 32 : 64 if $arch eq 'x86_64';
0 commit comments