[pve-devel] [PATCH/RFC cluster/common/... many] add cluster-wide hardware device mapping

Dominik Csapak d.csapak at proxmox.com
Tue Jun 22 09:07:16 CEST 2021


i just noticed, it seems i forgot to add some hunks/stashes?
usb does not work properly

there is one qemu patch missing
and two would have to be adapted

i can send a v2 for the whole series, only for qemu-server
or only for the patches, depending on what is preferred

the whole diff is rather small:

----8<----
diff --git a/PVE/API2/Qemu.pm b/PVE/API2/Qemu.pm
index 063b356..bb911b9 100644
--- a/PVE/API2/Qemu.pm
+++ b/PVE/API2/Qemu.pm
@@ -1346,7 +1346,7 @@ my $update_vm_api  = sub {
                     PVE::QemuConfig->add_to_pending_delete($conf, $opt, 
$force);
                     PVE::QemuConfig->write_config($vmid, $conf);
                 } elsif ($opt =~ m/^usb\d+$/) {
-                   my $device = 
PVE::JSONSchema::parse_property_string('pve-qm-usb-device', $val);
+                   my $device = 
PVE::JSONSchema::parse_property_string('pve-qm-usb', $val);
                     my $host = parse_usb_device($device->{host});
                     if ($host->{spice}) {
                         $rpcenv->check_vm_perm($authuser, $vmid, undef, 
['VM.Config.HWType']);
@@ -1404,7 +1404,7 @@ my $update_vm_api  = sub {
                     my $olddevice;
                     my $oldhost;
                     if (defined($conf->{$opt})) {
-                       $olddevice = 
PVE::JSONSchema::parse_property_string('pve-qm-usb-device', $conf->{$opt});
+                       $olddevice = 
PVE::JSONSchema::parse_property_string('pve-qm-usb', $conf->{$opt});
                         $oldhost = parse_usb_device($olddevice->{host});
                     }
                     if (defined($oldhost)) {
@@ -1418,7 +1418,7 @@ my $update_vm_api  = sub {
                         }
                     }

-                   my $newdevice = 
PVE::JSONSchema::parse_property_string('pve-qm-usb-device', $param->{$opt});
+                   my $newdevice = 
PVE::JSONSchema::parse_property_string('pve-qm-usb', $param->{$opt});
                     my $newhost = parse_usb_device($newdevice->{host});

                     if ($newhost->{spice}) {
diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm
index 5edcb6a..ea824a1 100644
--- a/PVE/QemuServer.pm
+++ b/PVE/QemuServer.pm
@@ -1030,6 +1030,8 @@ EODESCR
      },
  };

+PVE::JSONSchema::register_format('pve-qm-usb', $usb_fmt);
+
  my $usbdesc = {
      optional => 1,
      type => 'string', format => $usb_fmt,
@@ -2438,9 +2440,10 @@ sub check_local_resources {
      foreach my $k (keys %$conf) {
         if ($k =~ m/^usb/) {
             my $entry = parse_property_string($usb_fmt, $conf->{$k});
-           next if $entry->{spice};
-           if (my $id = $entry->{mapped}) {
-               $add_not_allowed_nodes->($k, $id);
+           my $host = parse_usb_device($entry->{host});
+           next if $host->{spice};
+           if ($host->{mapped}) {
+               $add_not_allowed_nodes->($k, $entry->{host});
                 push @$mapped_res, $k;
                 next;
             }
---->8----





More information about the pve-devel mailing list