From 7f13bee986ec81cf3785186417834df5713044a2 Mon Sep 17 00:00:00 2001 From: jiangcuo Date: Thu, 26 Dec 2024 13:24:29 +0800 Subject: [PATCH] update qemu-server to 8.3.1 --- ...001-port.patch => 001-init-for-port.patch} | 186 ++++++++++++------ .../patches/002-fix-usb-hotplug.patch | 51 ----- ...3-fix-loongarch-nvram-and-acpi-issue.patch | 106 ---------- ...t-default-bios-to-ovmf-when-vm-create.diff | 16 ++ .../004-add-Kunpeng-920-cpu-model.patch | 12 ++ .../changelog/001-update-to8.3.0+port1.patch | 14 -- .../changelog/002-update-to8.3.0+port2.patch | 25 --- .../changelog/003-update-to8.3.0+port3.patch | 14 -- packages/qemu-server/qemu-server | 2 +- packages/qemu-server/series | 9 +- 10 files changed, 158 insertions(+), 277 deletions(-) rename packages/qemu-server/patches/{001-port.patch => 001-init-for-port.patch} (91%) delete mode 100644 packages/qemu-server/patches/002-fix-usb-hotplug.patch delete mode 100644 packages/qemu-server/patches/003-fix-loongarch-nvram-and-acpi-issue.patch create mode 100644 packages/qemu-server/patches/003-set-default-bios-to-ovmf-when-vm-create.diff create mode 100644 packages/qemu-server/patches/004-add-Kunpeng-920-cpu-model.patch delete mode 100644 packages/qemu-server/patches/changelog/001-update-to8.3.0+port1.patch delete mode 100644 packages/qemu-server/patches/changelog/002-update-to8.3.0+port2.patch delete mode 100644 packages/qemu-server/patches/changelog/003-update-to8.3.0+port3.patch diff --git a/packages/qemu-server/patches/001-port.patch b/packages/qemu-server/patches/001-init-for-port.patch similarity index 91% rename from packages/qemu-server/patches/001-port.patch rename to packages/qemu-server/patches/001-init-for-port.patch index 0fe2b0e..76826cb 100644 --- a/packages/qemu-server/patches/001-port.patch +++ b/packages/qemu-server/patches/001-init-for-port.patch @@ -63,10 +63,10 @@ index afb535c2..db6c3d80 100644 }; die "could not load supported machine versions - $@\n" if $@; diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm -index 2046a7c5..a958eb77 100644 +index 5cde94a1..6f0d41fc 100644 --- a/PVE/QemuServer.pm +++ b/PVE/QemuServer.pm -@@ -98,11 +98,40 @@ my $OVMF = { +@@ -98,11 +98,73 @@ my $OVMF = { ], }, aarch64 => { @@ -96,18 +96,51 @@ index 2046a7c5..a958eb77 100644 + "$EDK2_FW_BASE/LOONGARCH64_VIRT_CODE.fd", + "$EDK2_FW_BASE/LOONGARCH64_VIRT_VARS.fd", + ], ++ '4m-no-smm' => [ ++ "$EDK2_FW_BASE/LOONGARCH64_VIRT_CODE.fd", ++ "$EDK2_FW_BASE/LOONGARCH64_VIRT_VARS.fd", ++ ], ++ '4m-no-smm-ms' => [ ++ "$EDK2_FW_BASE/LOONGARCH64_VIRT_CODE.fd", ++ "$EDK2_FW_BASE/LOONGARCH64_VIRT_VARS.fd", ++ ], ++ '4m' => [ ++ "$EDK2_FW_BASE/LOONGARCH64_VIRT_CODE.fd", ++ "$EDK2_FW_BASE/LOONGARCH64_VIRT_VARS.fd", ++ ], ++ '4m-ms' => [ ++ "$EDK2_FW_BASE/LOONGARCH64_VIRT_CODE.fd", ++ "$EDK2_FW_BASE/LOONGARCH64_VIRT_VARS.fd", ++ ], + }, + riscv64 => { + default => [ + "$EDK2_FW_BASE/RISCV_VIRT_CODE.fd", + "$EDK2_FW_BASE/RISCV_VIRT_VARS.fd", + ], ++ '4m-no-smm' => [ ++ "$EDK2_FW_BASE/RISCV_VIRT_CODE.fd", ++ "$EDK2_FW_BASE/RISCV_VIRT_VARS.fd", ++ ], ++ '4m-no-smm-ms' => [ ++ "$EDK2_FW_BASE/RISCV_VIRT_CODE.fd", ++ "$EDK2_FW_BASE/RISCV_VIRT_VARS.fd", ++ ], ++ '4m' => [ ++ "$EDK2_FW_BASE/RISCV_VIRT_CODE.fd", ++ "$EDK2_FW_BASE/RISCV_VIRT_VARS.fd", ++ ], ++ '4m-ms' => [ ++ "$EDK2_FW_BASE/RISCV_VIRT_CODE.fd", ++ "$EDK2_FW_BASE/RISCV_VIRT_VARS.fd", ++ ], ++ + }, + }; my $cpuinfo = PVE::ProcFSTools::read_cpuinfo(); -@@ -185,7 +214,7 @@ my $vga_fmt = { +@@ -185,7 +247,7 @@ my $vga_fmt = { default => 'std', optional => 1, default_key => 1, @@ -116,7 +149,7 @@ index 2046a7c5..a958eb77 100644 }, memory => { description => "Sets the VGA memory (in MiB). Has no effect with serial display.", -@@ -398,8 +427,8 @@ my $confdesc = { +@@ -398,8 +460,8 @@ my $confdesc = { optional => 1, type => 'string', description => "SCSI controller model", @@ -127,7 +160,7 @@ index 2046a7c5..a958eb77 100644 }, description => { optional => 1, -@@ -411,8 +440,7 @@ my $confdesc = { +@@ -411,8 +473,7 @@ my $confdesc = { ostype => { optional => 1, type => 'string', @@ -137,7 +170,7 @@ index 2046a7c5..a958eb77 100644 description => "Specify guest operating system.", verbose_description => < { optional => 1, @@ -149,7 +182,7 @@ index 2046a7c5..a958eb77 100644 }, cpu => { optional => 1, -@@ -653,7 +681,7 @@ EODESCR +@@ -653,7 +714,7 @@ EODESCR description => "Virtual processor architecture. Defaults to the host.", optional => 1, type => 'string', @@ -158,7 +191,7 @@ index 2046a7c5..a958eb77 100644 }, smbios1 => { description => "Specify SMBIOS type 1 fields.", -@@ -1376,11 +1404,14 @@ sub print_tabletdevice_full { +@@ -1376,11 +1437,14 @@ sub print_tabletdevice_full { # we use uhci for old VMs because tablet driver was buggy in older qemu my $usbbus; @@ -176,7 +209,7 @@ index 2046a7c5..a958eb77 100644 return "usb-tablet,id=tablet,bus=$usbbus.0,port=1"; } -@@ -1388,7 +1419,7 @@ sub print_tabletdevice_full { +@@ -1388,7 +1452,7 @@ sub print_tabletdevice_full { sub print_keyboarddevice_full { my ($conf, $arch) = @_; @@ -185,7 +218,7 @@ index 2046a7c5..a958eb77 100644 return "usb-kbd,id=keyboard,bus=ehci.0,port=2"; } -@@ -1782,15 +1813,19 @@ my $vga_map = { +@@ -1797,15 +1861,19 @@ my $vga_map = { 'std' => 'VGA', 'vmware' => 'vmware-svga', 'virtio' => 'virtio-vga', @@ -208,7 +241,7 @@ index 2046a7c5..a958eb77 100644 } my $vgamem_mb = $vga->{memory}; -@@ -1842,7 +1877,7 @@ sub print_vga_device { +@@ -1857,7 +1925,7 @@ sub print_vga_device { } if ($vga->{type} eq 'virtio-gl') { @@ -217,7 +250,7 @@ index 2046a7c5..a958eb77 100644 die "missing libraries for '$vga->{type}' detected! Please install 'libgl1' and 'libegl1'\n" if !-e "${base}EGL.so.1" || !-e "${base}GL.so.1"; -@@ -3185,7 +3220,14 @@ sub add_tpm_device { +@@ -3211,7 +3279,14 @@ sub add_tpm_device { push @$devices, "-chardev", "socket,id=tpmchar,path=$paths->{socket}"; push @$devices, "-tpmdev", "emulator,id=tpmdev,chardev=tpmchar"; @@ -232,7 +265,7 @@ index 2046a7c5..a958eb77 100644 } sub start_swtpm { -@@ -3281,6 +3323,8 @@ sub get_vm_arch { +@@ -3309,6 +3384,8 @@ sub get_vm_arch { my $default_machines = { x86_64 => 'pc', aarch64 => 'virt', @@ -241,16 +274,16 @@ index 2046a7c5..a958eb77 100644 }; sub get_installed_machine_version { -@@ -3326,7 +3370,7 @@ sub get_vm_machine { +@@ -3354,7 +3431,7 @@ sub get_vm_machine { if (windows_version($conf->{ostype})) { $machine = windows_get_pinned_machine_version($machine, '5.1', $kvmversion); } - $arch //= 'x86_64'; + $arch //= get_host_arch(); $machine ||= $default_machines->{$arch}; - if ($add_pve_version) { - my $pvever = PVE::QemuServer::Machine::get_pve_version($kvmversion); -@@ -3355,13 +3399,9 @@ sub get_ovmf_files($$$) { + my $pvever = PVE::QemuServer::Machine::get_pve_version($kvmversion); + $machine .= "+pve$pvever"; +@@ -3381,13 +3458,9 @@ sub get_ovmf_files($$$) { or die "no OVMF images known for architecture '$arch'\n"; my $type = 'default'; @@ -267,7 +300,7 @@ index 2046a7c5..a958eb77 100644 } my ($ovmf_code, $ovmf_vars) = $types->{$type}->@*; -@@ -3374,6 +3414,8 @@ sub get_ovmf_files($$$) { +@@ -3400,6 +3473,8 @@ sub get_ovmf_files($$$) { my $Arch2Qemu = { aarch64 => '/usr/bin/qemu-system-aarch64', x86_64 => '/usr/bin/qemu-system-x86_64', @@ -276,7 +309,7 @@ index 2046a7c5..a958eb77 100644 }; sub get_command_for_arch($) { my ($arch) = @_; -@@ -3414,8 +3456,8 @@ sub query_supported_cpu_flags { +@@ -3440,8 +3515,8 @@ sub query_supported_cpu_flags { # FIXME: Once this is merged, the code below should work for ARM as well: # https://lists.nongnu.org/archive/html/qemu-devel/2019-06/msg04947.html @@ -287,7 +320,7 @@ index 2046a7c5..a958eb77 100644 my $kvm_supported = defined(kvm_version()); my $qemu_cmd = get_command_for_arch($arch); -@@ -3434,7 +3476,8 @@ sub query_supported_cpu_flags { +@@ -3460,7 +3535,8 @@ sub query_supported_cpu_flags { '-chardev', "socket,id=qmp,path=/var/run/qemu-server/$fakevmid.qmp,server=on,wait=off", '-mon', 'chardev=qmp,mode=control', '-pidfile', $pidfile, @@ -297,7 +330,7 @@ index 2046a7c5..a958eb77 100644 ]; if (!$kvm) { -@@ -3562,7 +3605,7 @@ my sub get_vga_properties { +@@ -3585,7 +3661,7 @@ my sub get_vga_properties { $vga->{type} = 'qxl' if $qxlnum; if (!$vga->{type}) { @@ -306,26 +339,19 @@ index 2046a7c5..a958eb77 100644 $vga->{type} = 'virtio'; } elsif (min_version($machine_version, 2, 9)) { $vga->{type} = (!$winversion || $winversion >= 6) ? 'std' : 'cirrus'; -@@ -3722,8 +3765,16 @@ sub config_to_command { +@@ -3697,7 +3773,10 @@ sub config_to_command { - my ($code_drive_str, $var_drive_str) = - print_ovmf_drive_commandlines($conf, $storecfg, $vmid, $arch, $q35, $version_guard); -- push $cmd->@*, '-drive', $code_drive_str; -- push $cmd->@*, '-drive', $var_drive_str; -+ if ($arch eq 'loongarch64') { -+ push $cmd->@*, '-bios','/usr/share/pve-edk2-firmware//LOONGARCH64_VIRT_CODE.fd'; -+ }elsif ($arch eq 'riscv64') { -+ push @$cmd, '-bios','/usr/share/pve-edk2-firmware//fw_dynamic.bin'; -+ push @$cmd, '-drive', $code_drive_str; -+ }else{ -+ push $cmd->@*, '-drive', $code_drive_str; -+ push $cmd->@*, '-drive', $var_drive_str; -+ } -+ - } + push @$cmd, '-name', "$vmname,debug-threads=on"; - if ($q35) { # tell QEMU to load q35 config early -@@ -3735,11 +3786,12 @@ sub config_to_command { +- push @$cmd, '-no-shutdown'; ++ # fix nvram poweroff issue on loongarch ++ if ( $arch ne 'loongarch64'){ ++ push @$cmd, '-no-shutdown'; ++ } + + my $use_virtio = 0; + +@@ -3756,11 +3835,12 @@ sub config_to_command { } } @@ -339,7 +365,7 @@ index 2046a7c5..a958eb77 100644 push @$devices, '-device', 'vmgenid,guid='.$conf->{vmgenid}; } -@@ -3787,7 +3839,7 @@ sub config_to_command { +@@ -3808,7 +3888,7 @@ sub config_to_command { # On aarch64, serial0 is the UART device. QEMU only allows # connecting UART devices via the '-serial' command line, as # the device has a fixed slot on the hardware... @@ -348,7 +374,13 @@ index 2046a7c5..a958eb77 100644 push @$devices, '-serial', "chardev:serial$i"; } else { push @$devices, '-device', "isa-serial,chardev=serial$i"; -@@ -3853,9 +3905,12 @@ sub config_to_command { +@@ -3869,14 +3949,17 @@ sub config_to_command { + + push @$cmd, '-boot', "menu=on,strict=on,reboot-timeout=1000,splash=/usr/share/qemu-server/bootsplash.jpg"; + +- push $machineFlags->@*, 'acpi=off' if defined($conf->{acpi}) && $conf->{acpi} == 0; ++ push $machineFlags->@*, 'acpi=off' if defined($conf->{acpi}) && $conf->{acpi} == 0 && $arch ne 'loongarch64'; + push @$cmd, '-no-reboot' if defined($conf->{reboot}) && $conf->{reboot} == 0; if ($vga->{type} && $vga->{type} !~ m/^serial\d+$/ && $vga->{type} ne 'none'){ @@ -364,7 +396,7 @@ index 2046a7c5..a958eb77 100644 push @$cmd, '-display', 'egl-headless,gl=core' if $vga->{type} eq 'virtio-gl'; # VIRGL my $socket = PVE::QemuServer::Helpers::vnc_socket($vmid); -@@ -4151,14 +4206,19 @@ sub config_to_command { +@@ -4172,14 +4255,19 @@ sub config_to_command { if ($k == 2 && $legacy_igd) { $k_name = "$k-igd"; } @@ -391,10 +423,10 @@ index 2046a7c5..a958eb77 100644 } if (!$kvm) { -@@ -4172,20 +4232,18 @@ sub config_to_command { - $machine_type_min =~ s/\+pve\d+$//; - $machine_type_min .= "+pve$required_pve_version"; - } +@@ -4191,20 +4279,18 @@ sub config_to_command { + my $machine_type_min = $machine_type; + $machine_type_min =~ s/\+pve\d+$//; + $machine_type_min .= "+pve$required_pve_version"; - push @$machineFlags, "type=${machine_type_min}"; - - PVE::QemuServer::Machine::assert_valid_machine_property($conf, $machine_conf); @@ -421,7 +453,7 @@ index 2046a7c5..a958eb77 100644 push @$devices, '-object', get_amd_sev_object($conf->{'amd-sev'}, $conf->{bios}); push @$machineFlags, 'confidential-guest-support=sev0'; } -@@ -4359,6 +4417,10 @@ sub vm_deviceplug { +@@ -4378,6 +4464,10 @@ sub vm_deviceplug { my $machine_type = PVE::QemuServer::Machine::qemu_machine_pxe($vmid, $conf); my $machine_version = PVE::QemuServer::Machine::extract_version($machine_type); @@ -432,7 +464,7 @@ index 2046a7c5..a958eb77 100644 my $use_old_bios_files = undef; ($use_old_bios_files, $machine_type) = qemu_use_old_bios_files($machine_type); -@@ -5049,10 +5111,10 @@ sub vmconfig_hotplug_pending { +@@ -5068,10 +5158,10 @@ sub vmconfig_hotplug_pending { if ($defaults->{tablet}) { vm_deviceplug($storecfg, $conf, $vmid, 'tablet', $arch, $machine_type); vm_deviceplug($storecfg, $conf, $vmid, 'keyboard', $arch, $machine_type) @@ -445,7 +477,7 @@ index 2046a7c5..a958eb77 100644 } } elsif ($opt =~ m/^usb(\d+)$/) { my $index = $1; -@@ -5114,10 +5176,10 @@ sub vmconfig_hotplug_pending { +@@ -5133,10 +5223,10 @@ sub vmconfig_hotplug_pending { if ($value == 1) { vm_deviceplug($storecfg, $conf, $vmid, 'tablet', $arch, $machine_type); vm_deviceplug($storecfg, $conf, $vmid, 'keyboard', $arch, $machine_type) @@ -748,7 +780,7 @@ index e65d8c26..c229c35f 100644 die "unsupported architecture '$arch'\n"; } diff --git a/PVE/QemuServer/PCI.pm b/PVE/QemuServer/PCI.pm -index 491ba078..98141516 100644 +index d758ae9d..15c18691 100644 --- a/PVE/QemuServer/PCI.pm +++ b/PVE/QemuServer/PCI.pm @@ -14,6 +14,7 @@ our @EXPORT_OK = qw( @@ -1214,11 +1246,19 @@ index 491ba078..98141516 100644 $pciaddr = print_pci_addr($pci_name, $bridges, $arch, $machine_type); } diff --git a/PVE/QemuServer/USB.pm b/PVE/QemuServer/USB.pm -index 017ef9c0..4e900d79 100644 +index 017ef9c0..b2daab25 100644 --- a/PVE/QemuServer/USB.pm +++ b/PVE/QemuServer/USB.pm -@@ -133,9 +133,13 @@ sub get_usb_controllers { +@@ -131,11 +131,21 @@ sub get_usb_controllers { + + my $use_qemu_xhci = min_version($machine_version, 7, 1) && defined($ostype) && ($ostype eq 'l26' || windows_version($ostype) > 7); ++ ++ # We use qemu_xhci only for !x86_64 device ++ if ($arch ne 'x86_64'){ ++ $use_qemu_xhci = 1; ++ } ++ my $is_q35 = PVE::QemuServer::Machine::machine_type_is_q35($conf); - if ($arch eq 'aarch64') { @@ -1233,7 +1273,7 @@ index 017ef9c0..4e900d79 100644 } elsif (!$is_q35) { $pciaddr = print_pci_addr("piix3", $bridges, $arch, $machine); push @$devices, '-device', "piix3-usb-uhci,id=uhci$pciaddr.0x2"; -@@ -152,7 +156,7 @@ sub get_usb_controllers { +@@ -152,17 +162,23 @@ sub get_usb_controllers { $use_usb2 = 1 if !$d->{usb3}; } @@ -1242,11 +1282,32 @@ index 017ef9c0..4e900d79 100644 # include usb device config if still on x86 before-xhci machines and if USB 3 is not used push @$devices, '-readconfig', '/usr/share/qemu-server/pve-usb.cfg'; } + + $pciaddr = print_pci_addr("xhci", $bridges, $arch, $machine); +- if ($use_qemu_xhci && $any_usb) { +- push @$devices, '-device', print_qemu_xhci_controller($pciaddr); +- } elsif ($use_usb3) { +- push @$devices, '-device', "nec-usb-xhci,id=xhci$pciaddr"; +- } ++ ++ if ($arch ne 'x86_64') { ++ # Create the usb controller on first boot so that we don't need to hot-plug the device later. ++ push @$devices, '-device', print_qemu_xhci_controller($pciaddr); ++ }else{ ++ if ($use_qemu_xhci && $any_usb) { ++ push @$devices, '-device', print_qemu_xhci_controller($pciaddr); ++ } elsif ($use_usb3) { ++ push @$devices, '-device', "nec-usb-xhci,id=xhci$pciaddr"; ++ } ++ } + + return @$devices; + } diff --git a/debian/changelog b/debian/changelog -index e686bac4..9e7f8d2c 100644 +index 8a19bf70..1439b7f3 100644 --- a/debian/changelog +++ b/debian/changelog -@@ -195,6 +195,20 @@ qemu-server (8.1.2) bookworm; urgency=medium +@@ -224,6 +224,20 @@ qemu-server (8.1.2) bookworm; urgency=medium -- Proxmox Support Team Fri, 19 Apr 2024 16:09:18 +0200 @@ -1267,7 +1328,7 @@ index e686bac4..9e7f8d2c 100644 qemu-server (8.1.1) bookworm; urgency=medium * config: pending network: avoid undef-warning on old/new comparison -@@ -247,6 +261,12 @@ qemu-server (8.1.0) bookworm; urgency=medium +@@ -276,6 +290,12 @@ qemu-server (8.1.0) bookworm; urgency=medium -- Proxmox Support Team Fri, 08 Mar 2024 15:00:25 +0100 @@ -1280,7 +1341,7 @@ index e686bac4..9e7f8d2c 100644 qemu-server (8.0.10) bookworm; urgency=medium * sdn: pass vmid and hostname to allow requesting a new mapping -@@ -265,6 +285,16 @@ qemu-server (8.0.9) bookworm; urgency=medium +@@ -294,6 +314,16 @@ qemu-server (8.0.9) bookworm; urgency=medium -- Proxmox Support Team Tue, 21 Nov 2023 15:40:27 +0100 @@ -1298,7 +1359,7 @@ index e686bac4..9e7f8d2c 100644 * fix #2816: restore: remove timeout when allocating disks diff --git a/debian/control b/debian/control -index 0dcd3b30..7e79ee09 100644 +index 81f0fad6..f4e95b71 100644 --- a/debian/control +++ b/debian/control @@ -20,6 +20,7 @@ Build-Depends: debhelper-compat (= 13), @@ -1309,14 +1370,19 @@ index 0dcd3b30..7e79ee09 100644 pve-firewall, pve-ha-manager , pve-qemu-kvm (>= 7.1~), -@@ -49,6 +50,7 @@ Depends: dbus, +@@ -49,9 +50,11 @@ Depends: dbus, # TODO: make legacy edk2 optional (suggests) for PVE 9 and warn explicitly about it pve-edk2-firmware-legacy | pve-edk2-firmware (<< 4~), pve-edk2-firmware-ovmf | pve-edk2-firmware (>= 3.20210831-1), + pve-edk2-firmware-aarch64, ++ pve-edk2-firmware-loongarch64 [loong64], pve-firewall (>= 5.0.4), pve-ha-manager (>= 3.0-9), - pve-qemu-kvm (>= 7.1~), +- pve-qemu-kvm (>= 7.1~), ++ pve-qemu-kvm (>= 9.0~), + socat, + swtpm, + swtpm-tools, diff --git a/qemu-configs/Makefile b/qemu-configs/Makefile index f55e9bef..bccbc7e4 100644 --- a/qemu-configs/Makefile diff --git a/packages/qemu-server/patches/002-fix-usb-hotplug.patch b/packages/qemu-server/patches/002-fix-usb-hotplug.patch deleted file mode 100644 index e713d40..0000000 --- a/packages/qemu-server/patches/002-fix-usb-hotplug.patch +++ /dev/null @@ -1,51 +0,0 @@ -From 5dd2dcf088141ac471037dfcf0607b5968742b8d Mon Sep 17 00:00:00 2001 -From: jiangcuo -Date: Mon, 9 Dec 2024 16:33:51 +0800 -Subject: [PATCH] fix usb hotplug issue - -https://github.com/jiangcuo/Proxmox-Port/issues/135 ---- - PVE/QemuServer/USB.pm | 22 +++++++++++++++++----- - debian/changelog | 6 ++++++ - 2 files changed, 23 insertions(+), 5 deletions(-) - -diff --git a/PVE/QemuServer/USB.pm b/PVE/QemuServer/USB.pm -index 4e900d79..b2daab25 100644 ---- a/PVE/QemuServer/USB.pm -+++ b/PVE/QemuServer/USB.pm -@@ -131,6 +131,12 @@ sub get_usb_controllers { - - my $use_qemu_xhci = min_version($machine_version, 7, 1) - && defined($ostype) && ($ostype eq 'l26' || windows_version($ostype) > 7); -+ -+ # We use qemu_xhci only for !x86_64 device -+ if ($arch ne 'x86_64'){ -+ $use_qemu_xhci = 1; -+ } -+ - my $is_q35 = PVE::QemuServer::Machine::machine_type_is_q35($conf); - - if ($arch ne 'x86_64') { -@@ -162,11 +168,17 @@ sub get_usb_controllers { - } - - $pciaddr = print_pci_addr("xhci", $bridges, $arch, $machine); -- if ($use_qemu_xhci && $any_usb) { -- push @$devices, '-device', print_qemu_xhci_controller($pciaddr); -- } elsif ($use_usb3) { -- push @$devices, '-device', "nec-usb-xhci,id=xhci$pciaddr"; -- } -+ -+ if ($arch ne 'x86_64') { -+ # Create the usb controller on first boot so that we don't need to hot-plug the device later. -+ push @$devices, '-device', print_qemu_xhci_controller($pciaddr); -+ }else{ -+ if ($use_qemu_xhci && $any_usb) { -+ push @$devices, '-device', print_qemu_xhci_controller($pciaddr); -+ } elsif ($use_usb3) { -+ push @$devices, '-device', "nec-usb-xhci,id=xhci$pciaddr"; -+ } -+ } - - return @$devices; - } diff --git a/packages/qemu-server/patches/003-fix-loongarch-nvram-and-acpi-issue.patch b/packages/qemu-server/patches/003-fix-loongarch-nvram-and-acpi-issue.patch deleted file mode 100644 index cb6eeee..0000000 --- a/packages/qemu-server/patches/003-fix-loongarch-nvram-and-acpi-issue.patch +++ /dev/null @@ -1,106 +0,0 @@ -diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm -index a958eb77..514d52ec 100644 ---- a/PVE/QemuServer.pm -+++ b/PVE/QemuServer.pm -@@ -124,12 +124,45 @@ my $OVMF = { - "$EDK2_FW_BASE/LOONGARCH64_VIRT_CODE.fd", - "$EDK2_FW_BASE/LOONGARCH64_VIRT_VARS.fd", - ], -+ '4m-no-smm' => [ -+ "$EDK2_FW_BASE/LOONGARCH64_VIRT_CODE.fd", -+ "$EDK2_FW_BASE/LOONGARCH64_VIRT_VARS.fd", -+ ], -+ '4m-no-smm-ms' => [ -+ "$EDK2_FW_BASE/LOONGARCH64_VIRT_CODE.fd", -+ "$EDK2_FW_BASE/LOONGARCH64_VIRT_VARS.fd", -+ ], -+ '4m' => [ -+ "$EDK2_FW_BASE/LOONGARCH64_VIRT_CODE.fd", -+ "$EDK2_FW_BASE/LOONGARCH64_VIRT_VARS.fd", -+ ], -+ '4m-ms' => [ -+ "$EDK2_FW_BASE/LOONGARCH64_VIRT_CODE.fd", -+ "$EDK2_FW_BASE/LOONGARCH64_VIRT_VARS.fd", -+ ], - }, - riscv64 => { - default => [ - "$EDK2_FW_BASE/RISCV_VIRT_CODE.fd", - "$EDK2_FW_BASE/RISCV_VIRT_VARS.fd", - ], -+ '4m-no-smm' => [ -+ "$EDK2_FW_BASE/RISCV_VIRT_CODE.fd", -+ "$EDK2_FW_BASE/RISCV_VIRT_VARS.fd", -+ ], -+ '4m-no-smm-ms' => [ -+ "$EDK2_FW_BASE/RISCV_VIRT_CODE.fd", -+ "$EDK2_FW_BASE/RISCV_VIRT_VARS.fd", -+ ], -+ '4m' => [ -+ "$EDK2_FW_BASE/RISCV_VIRT_CODE.fd", -+ "$EDK2_FW_BASE/RISCV_VIRT_VARS.fd", -+ ], -+ '4m-ms' => [ -+ "$EDK2_FW_BASE/RISCV_VIRT_CODE.fd", -+ "$EDK2_FW_BASE/RISCV_VIRT_VARS.fd", -+ ], -+ - }, - - }; -@@ -3719,7 +3752,10 @@ sub config_to_command { - - push @$cmd, '-name', "$vmname,debug-threads=on"; - -- push @$cmd, '-no-shutdown'; -+ # fix nvram poweroff issue on loongarch -+ if ( $arch ne 'loongarch64'){ -+ push @$cmd, '-no-shutdown'; -+ } - - my $use_virtio = 0; - -@@ -3765,16 +3801,8 @@ sub config_to_command { - - my ($code_drive_str, $var_drive_str) = - print_ovmf_drive_commandlines($conf, $storecfg, $vmid, $arch, $q35, $version_guard); -- if ($arch eq 'loongarch64') { -- push $cmd->@*, '-bios','/usr/share/pve-edk2-firmware//LOONGARCH64_VIRT_CODE.fd'; -- }elsif ($arch eq 'riscv64') { -- push @$cmd, '-bios','/usr/share/pve-edk2-firmware//fw_dynamic.bin'; -- push @$cmd, '-drive', $code_drive_str; -- }else{ -- push $cmd->@*, '-drive', $code_drive_str; -- push $cmd->@*, '-drive', $var_drive_str; -- } -- -+ push $cmd->@*, '-drive', $code_drive_str; -+ push $cmd->@*, '-drive', $var_drive_str; - } - - if ($q35) { # tell QEMU to load q35 config early -@@ -3900,7 +3928,7 @@ sub config_to_command { - - push @$cmd, '-boot', "menu=on,strict=on,reboot-timeout=1000,splash=/usr/share/qemu-server/bootsplash.jpg"; - -- push $machineFlags->@*, 'acpi=off' if defined($conf->{acpi}) && $conf->{acpi} == 0; -+ push $machineFlags->@*, 'acpi=off' if defined($conf->{acpi}) && $conf->{acpi} == 0 && $arch ne 'loongarch64'; - - push @$cmd, '-no-reboot' if defined($conf->{reboot}) && $conf->{reboot} == 0; - -diff --git a/debian/control b/debian/control -index 7e79ee09..94995a68 100644 ---- a/debian/control -+++ b/debian/control -@@ -51,9 +51,10 @@ Depends: dbus, - pve-edk2-firmware-legacy | pve-edk2-firmware (<< 4~), - pve-edk2-firmware-ovmf | pve-edk2-firmware (>= 3.20210831-1), - pve-edk2-firmware-aarch64, -+ pve-edk2-firmware-loongarch64 [loong64], - pve-firewall (>= 5.0.4), - pve-ha-manager (>= 3.0-9), -- pve-qemu-kvm (>= 7.1~), -+ pve-qemu-kvm (>= 9.0~), - socat, - swtpm, - swtpm-tools, diff --git a/packages/qemu-server/patches/003-set-default-bios-to-ovmf-when-vm-create.diff b/packages/qemu-server/patches/003-set-default-bios-to-ovmf-when-vm-create.diff new file mode 100644 index 0000000..9be3702 --- /dev/null +++ b/packages/qemu-server/patches/003-set-default-bios-to-ovmf-when-vm-create.diff @@ -0,0 +1,16 @@ +diff --git a/PVE/API2/Qemu.pm b/PVE/API2/Qemu.pm +index db356b7e..e1dc3e7e 100644 +--- a/PVE/API2/Qemu.pm ++++ b/PVE/API2/Qemu.pm +@@ -1223,6 +1223,11 @@ __PACKAGE__->register_method({ + ); + $conf->{$_} = $created_opts->{$_} for keys $created_opts->%*; + ++ # set default bios to ovmf ++ if (!$conf->{bios}){ ++ $conf->{bios} = 'ovmf'; ++ } ++ + if (!$conf->{boot}) { + my $devs = PVE::QemuServer::get_default_bootdevices($conf); + $conf->{boot} = PVE::QemuServer::print_bootorder($devs); diff --git a/packages/qemu-server/patches/004-add-Kunpeng-920-cpu-model.patch b/packages/qemu-server/patches/004-add-Kunpeng-920-cpu-model.patch new file mode 100644 index 0000000..3d140ad --- /dev/null +++ b/packages/qemu-server/patches/004-add-Kunpeng-920-cpu-model.patch @@ -0,0 +1,12 @@ +diff --git a/PVE/QemuServer/CPUConfig.pm b/PVE/QemuServer/CPUConfig.pm +index c229c35f..f5344716 100644 +--- a/PVE/QemuServer/CPUConfig.pm ++++ b/PVE/QemuServer/CPUConfig.pm +@@ -168,6 +168,7 @@ my $cpu_vendor_list = { + 'rv64' => 'default', + 'la464' => 'default', + 'la132' => 'default', ++ 'Kunpeng-920' => 'default', + }; + + my @supported_cpu_flags = ( diff --git a/packages/qemu-server/patches/changelog/001-update-to8.3.0+port1.patch b/packages/qemu-server/patches/changelog/001-update-to8.3.0+port1.patch deleted file mode 100644 index f4e49a1..0000000 --- a/packages/qemu-server/patches/changelog/001-update-to8.3.0+port1.patch +++ /dev/null @@ -1,14 +0,0 @@ -diff --git a/debian/changelog b/debian/changelog -index 9e7f8d2c..39ee0d12 100644 ---- a/debian/changelog -+++ b/debian/changelog -@@ -1,3 +1,9 @@ -+qemu-server (8.3.0+port1) bookworm; urgency=medium -+ -+ * Fix cpu type on loongarch64 -+ -+ -- Jiangcuo Thu, 05 Dec 2024 14:16:44 +0800 -+ - qemu-server (8.3.0) bookworm; urgency=medium - - * api: import working storage: improve error message diff --git a/packages/qemu-server/patches/changelog/002-update-to8.3.0+port2.patch b/packages/qemu-server/patches/changelog/002-update-to8.3.0+port2.patch deleted file mode 100644 index e163f60..0000000 --- a/packages/qemu-server/patches/changelog/002-update-to8.3.0+port2.patch +++ /dev/null @@ -1,25 +0,0 @@ -From 5dd2dcf088141ac471037dfcf0607b5968742b8d Mon Sep 17 00:00:00 2001 -From: jiangcuo -Date: Mon, 9 Dec 2024 16:33:51 +0800 -Subject: [PATCH] fix usb hotplug issue - -https://github.com/jiangcuo/Proxmox-Port/issues/135 ---- - PVE/QemuServer/USB.pm | 22 +++++++++++++++++----- - debian/changelog | 6 ++++++ - 2 files changed, 23 insertions(+), 5 deletions(-) - -diff --git a/debian/changelog b/debian/changelog -index 39ee0d12..4e9a4824 100644 ---- a/debian/changelog -+++ b/debian/changelog -@@ -1,3 +1,9 @@ -+qemu-server (8.3.0+port2) bookworm; urgency=medium -+ -+ * Fix usb hotplug error -+ -+ -- Jiangcuo Mon, 09 Dec 2024 16:30:48 +0800 -+ - qemu-server (8.3.0+port1) bookworm; urgency=medium - - * Fix cpu type on loongarch64 diff --git a/packages/qemu-server/patches/changelog/003-update-to8.3.0+port3.patch b/packages/qemu-server/patches/changelog/003-update-to8.3.0+port3.patch deleted file mode 100644 index daaa076..0000000 --- a/packages/qemu-server/patches/changelog/003-update-to8.3.0+port3.patch +++ /dev/null @@ -1,14 +0,0 @@ -diff --git a/debian/changelog b/debian/changelog -index 4e9a4824..f9f1f392 100644 ---- a/debian/changelog -+++ b/debian/changelog -@@ -1,3 +1,9 @@ -+qemu-server (8.3.0+port3) bookworm; urgency=medium -+ -+ * Add loongarch efi_vars support -+ -+ -- Jiangcuo Wed, 11 Dec 2024 13:44:37 +0800 -+ - qemu-server (8.3.0+port2) bookworm; urgency=medium - - * Fix usb hotplug error diff --git a/packages/qemu-server/qemu-server b/packages/qemu-server/qemu-server index 7547eb3..30587be 160000 --- a/packages/qemu-server/qemu-server +++ b/packages/qemu-server/qemu-server @@ -1 +1 @@ -Subproject commit 7547eb37a96a648a7946c584400295eab23f594e +Subproject commit 30587be4ac8a8daf5d8bc0dd437e242463dda569 diff --git a/packages/qemu-server/series b/packages/qemu-server/series index 3949d36..393846b 100644 --- a/packages/qemu-server/series +++ b/packages/qemu-server/series @@ -1,6 +1,3 @@ -patches/001-port.patch -patches/002-fix-usb-hotplug.patch -patches/003-fix-loongarch-nvram-and-acpi-issue.patch -patches/changelog/001-update-to8.3.0+port1.patch -patches/changelog/002-update-to8.3.0+port2.patch -patches/changelog/003-update-to8.3.0+port3.patch +patches/001-init-for-port.patch +patches/003-set-default-bios-to-ovmf-when-vm-create.diff +patches/004-add-Kunpeng-920-cpu-model.patch