Since it's an object that has the config-properties as keys (e.g.
hostpci0), we have to add all possible values (hostpciX/usbX) to it as
optional, like we do for e.g. config GET api calls.

The actual info per property is not much currently, just the name of
the mapping and for PCI devices if they're marked as live-migratable.

Signed-off-by: Dominik Csapak <d.csa...@proxmox.com>
---
this is a follow-up for:
[PATCH qemu-server v7 6/9] api: enable live migration for marked mapped pci 
devices
https://lore.proxmox.com/pve-devel/20250311132055.2826686-9-d.csa...@proxmox.com/

could also be squashed in on applying if wanted

 PVE/API2/Qemu.pm | 41 +++++++++++++++++++++++++++++++++++++++++
 1 file changed, 41 insertions(+)

diff --git a/PVE/API2/Qemu.pm b/PVE/API2/Qemu.pm
index 459c7e29..a2e200c7 100644
--- a/PVE/API2/Qemu.pm
+++ b/PVE/API2/Qemu.pm
@@ -4580,6 +4580,46 @@ my $check_vm_disks_local = sub {
     return $local_disks;
 };
 
+sub mapped_resource_info_properties {
+    my $properties= {};
+
+    for (my $i = 0; $i < $PVE::QemuServer::PCI::MAX_HOSTPCI_DEVICES; $i++) {
+       $properties->{"hostpci$i"} = {
+           type => 'object',
+           description => "Information about hostpci$i",
+           optional => 1,
+           properties => {
+               name => {
+                   type => 'string',
+                   description => 'The name of the mapping.',
+               },
+               'live-migration' => {
+                   type => 'boolean',
+                   optional => 1,
+                   default => 0,
+                   description => "True if the mapping is marked as 
live-migration capable.",
+               },
+           },
+       };
+    }
+
+    for (my $i = 0; $i < $PVE::QemuServer::USB::MAX_USB_DEVICES; $i++) {
+       $properties->{"usb$i"} = {
+           type => 'object',
+           description => "Information about usb$i",
+           optional => 1,
+           properties => {
+               name => {
+                   type => 'string',
+                   description => 'The name of the mapping.',
+               },
+           },
+       };
+    }
+
+    return $properties;
+}
+
 __PACKAGE__->register_method({
     name => 'migrate_vm_precondition',
     path => '{vmid}/migrate',
@@ -4681,6 +4721,7 @@ __PACKAGE__->register_method({
            'mapped-resource-info' => {
                type => 'object',
                description => "Object of mapped resources with additional 
information such if they're live migratable.",
+               properties => mapped_resource_info_properties(),
            },
        },
     },
-- 
2.39.5



_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel

Reply via email to