|
| 1 | +From 5dd2dcf088141ac471037dfcf0607b5968742b8d Mon Sep 17 00:00:00 2001 |
| 2 | +From: jiangcuo <jiangcuo@bingsin.com> |
| 3 | +Date: Mon, 9 Dec 2024 16:33:51 +0800 |
| 4 | +Subject: [PATCH] fix usb hotplug issue |
| 5 | + |
| 6 | +https://github.com/jiangcuo/Proxmox-Port/issues/135 |
| 7 | +--- |
| 8 | + PVE/QemuServer/USB.pm | 22 +++++++++++++++++----- |
| 9 | + debian/changelog | 6 ++++++ |
| 10 | + 2 files changed, 23 insertions(+), 5 deletions(-) |
| 11 | + |
| 12 | +diff --git a/PVE/QemuServer/USB.pm b/PVE/QemuServer/USB.pm |
| 13 | +index 4e900d79..b2daab25 100644 |
| 14 | +--- a/PVE/QemuServer/USB.pm |
| 15 | ++++ b/PVE/QemuServer/USB.pm |
| 16 | +@@ -131,6 +131,12 @@ sub get_usb_controllers { |
| 17 | + |
| 18 | + my $use_qemu_xhci = min_version($machine_version, 7, 1) |
| 19 | + && defined($ostype) && ($ostype eq 'l26' || windows_version($ostype) > 7); |
| 20 | ++ |
| 21 | ++ # We use qemu_xhci only for !x86_64 device |
| 22 | ++ if ($arch ne 'x86_64'){ |
| 23 | ++ $use_qemu_xhci = 1; |
| 24 | ++ } |
| 25 | ++ |
| 26 | + my $is_q35 = PVE::QemuServer::Machine::machine_type_is_q35($conf); |
| 27 | + |
| 28 | + if ($arch ne 'x86_64') { |
| 29 | +@@ -162,11 +168,17 @@ sub get_usb_controllers { |
| 30 | + } |
| 31 | + |
| 32 | + $pciaddr = print_pci_addr("xhci", $bridges, $arch, $machine); |
| 33 | +- if ($use_qemu_xhci && $any_usb) { |
| 34 | +- push @$devices, '-device', print_qemu_xhci_controller($pciaddr); |
| 35 | +- } elsif ($use_usb3) { |
| 36 | +- push @$devices, '-device', "nec-usb-xhci,id=xhci$pciaddr"; |
| 37 | +- } |
| 38 | ++ |
| 39 | ++ if ($arch ne 'x86_64') { |
| 40 | ++ # Create the usb controller on first boot so that we don't need to hot-plug the device later. |
| 41 | ++ push @$devices, '-device', print_qemu_xhci_controller($pciaddr); |
| 42 | ++ }else{ |
| 43 | ++ if ($use_qemu_xhci && $any_usb) { |
| 44 | ++ push @$devices, '-device', print_qemu_xhci_controller($pciaddr); |
| 45 | ++ } elsif ($use_usb3) { |
| 46 | ++ push @$devices, '-device', "nec-usb-xhci,id=xhci$pciaddr"; |
| 47 | ++ } |
| 48 | ++ } |
| 49 | + |
| 50 | + return @$devices; |
| 51 | + } |
0 commit comments