]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
esx: Fetch snapshot info directly for filtering
authorTomáš Golembiovský <tgolembi@redhat.com>
Tue, 12 Jul 2016 03:20:03 +0000 (05:20 +0200)
committerMichal Privoznik <mprivozn@redhat.com>
Tue, 12 Jul 2016 16:04:41 +0000 (18:04 +0200)
When fetching domains with virConnectListAllDomains() and when filtering
by snapshot existence is requested the ESX driver first lists all the
domains and then check one-by-one for snapshot existence. This process
takes unnecessarily long time.

To significantly improve the time necessary to finish the query we can
request the snapshot related info directly when querying the list of
domains from VMware.

Signed-off-by: Tomáš Golembiovský <tgolembi@redhat.com>
src/esx/esx_driver.c

index eae015a26fe71ac036c426032d085050a6534da0..3d90b695de6b3d8868b3cee6a9092c456ff3eecd 100644 (file)
@@ -4924,6 +4924,7 @@ esxConnectListAllDomains(virConnectPtr conn,
     int count = 0;
     bool autostart;
     int state;
+    esxVI_DynamicProperty *dynamicProperty = NULL;
 
     virCheckFlags(VIR_CONNECT_LIST_DOMAINS_FILTERS_ALL, -1);
 
@@ -4985,6 +4986,13 @@ esxConnectListAllDomains(virConnectPtr conn,
         }
     }
 
+    if (MATCH(VIR_CONNECT_LIST_DOMAINS_FILTERS_SNAPSHOT)) {
+        if (esxVI_String_AppendValueToList(&propertyNameList,
+                                           "snapshot.rootSnapshotList") < 0) {
+            goto cleanup;
+        }
+    }
+
     if (esxVI_LookupVirtualMachineList(priv->primary, propertyNameList,
                                        &virtualMachineList) < 0)
         goto cleanup;
@@ -5023,11 +5031,19 @@ esxConnectListAllDomains(virConnectPtr conn,
 
         /* filter by snapshot existence */
         if (MATCH(VIR_CONNECT_LIST_DOMAINS_FILTERS_SNAPSHOT)) {
+
             esxVI_VirtualMachineSnapshotTree_Free(&rootSnapshotTreeList);
 
-            if (esxVI_LookupRootSnapshotTreeList(priv->primary, uuid,
-                                                 &rootSnapshotTreeList) < 0) {
-                goto cleanup;
+            for (dynamicProperty = virtualMachine->propSet; dynamicProperty;
+                dynamicProperty = dynamicProperty->_next) {
+                if (STREQ(dynamicProperty->name, "snapshot.rootSnapshotList")) {
+                    if (esxVI_VirtualMachineSnapshotTree_CastListFromAnyType
+                        (dynamicProperty->val, &rootSnapshotTreeList) < 0) {
+                        goto cleanup;
+                    }
+
+                    break;
+                }
             }
 
             if (!((MATCH(VIR_CONNECT_LIST_DOMAINS_HAS_SNAPSHOT) &&