Currently when version 3 of the API is used to request the disks of a virtual machine, the API uses the GetAllDisksByVmId query, which in turn uses the GetDisksbyVmGuid stored procedure to retrive the disks. In addition this query, for each disk, calls the GetSnapshotByLeafGuid stored procedure, to retrieve snapshot details, and the GetDiskVmElementVyDiskVmElementId, to get attachment details. The GetSnapshotByLeafGuid stored procedure is complex, and consumes a important amount of database time. Version 4 of the API uses lighter stored procedures. This patch changes the V3 compatibility layer of the API so that it calls the V4 disk attachments and disk resources instead of using the GetAllDisksByVmId query. In an otherwise idle enviroment with approxy 4000 virtual machines this reduces the total use of CPU (85% database + 15% engine) from 57 minutes to 14 minutes. Reproducer: This can be reproduced using the following Ruby script, which uses the 'ovirt' gem to retrieve the virtual machines and their disks: require 'active_support/all' require 'ovirt' service = Ovirt::Service.new( server: 'rhvm41.local', port: 443, domain: 'internal', username: 'admin', password: '...', verify_ssl: false, timeout: 1.hour ) vms = Ovirt::Vm.all(service) vms.each do |vm| vm.disks.each do |disk| puts "#{vm[:name]}: #{disk[:name]}" end end service.disconnect
Verified on ovirt-engine-4.1.2-0.1.el7.noarch 6 vms: 4.1.1.2-0.1.el7 time: 3.567 sec 4.1.2-0.1.el7 time: 1.735 sec