I was testing out the new snapshot on functionality with GSX (VMWare Server 2.0.2) and noticed that it would fail to create a snapshot on a VM with no snapshots. I tracked it down to the esxDomainSnapshotCreateXML call, which would prematurely fail if the Root Snapshot Tree was empty -- which it would be.<div>


<br></div><div>Verified that both ESXi 4.0 and GSX return an empty snapshot tree. I don't feel this should be an error, and it prevents snapshots from being created.</div><div><br></div><div>I don't think I saw a fix for this in the master git branch. I'm not too sure if this is the proper path to go down, but at the very least it fixes my specific problem. If there is another fix or if I completely missed this point, let me know.</div>


<div><br></div><div><div>diff --git a/src/esx/esx_driver.c b/src/esx/esx_driver.c</div><div>index fea887a..70bfc2c 100644</div><div>--- a/src/esx/esx_driver.c</div><div>+++ b/src/esx/esx_driver.c</div><div>@@ -3330,12 +3330,16 @@ esxDomainSnapshotCreateXML(virDomainPtr domain, const char *xmlDesc,</div>

<div>           (priv->host, domain->uuid, NULL, &virtualMachine,</div><div>            priv->autoAnswer) < 0 ||</div><div>         esxVI_LookupRootSnapshotTreeList(priv->host, domain->uuid,</div><div>

-                                         &rootSnapshotList) < 0 ||</div><div>-        esxVI_GetSnapshotTreeByName(rootSnapshotList, def->name,</div><div>-                                    &snapshotTree, &snapshotTreeParent,</div>

<div>-                                    esxVI_Occurrence_OptionalItem) < 0) {</div><div>+                                         &rootSnapshotList) < 0) {</div><div>         goto failure;</div><div>     }</div>

<div>+    if (rootSnapshotList) {</div><div>+        if (esxVI_GetSnapshotTreeByName(rootSnapshotList, def->name,</div><div>+                                        &snapshotTree, &snapshotTreeParent,</div><div>

+                                        esxVI_Occurrence_OptionalItem) < 0) {</div><div>+            goto failure;</div><div>+        }</div><div>+    }</div><div><br></div><div>     if (snapshotTree != NULL) {</div>
<div>
         ESX_ERROR(VIR_ERR_OPERATION_INVALID,</div><div>diff --git a/src/esx/esx_vi.c b/src/esx/esx_vi.c</div><div>index 89ef2dd..93ef36b 100644</div><div>--- a/src/esx/esx_vi.c</div><div>+++ b/src/esx/esx_vi.c</div><div>

@@ -2561,12 +2561,6 @@ esxVI_LookupRootSnapshotTreeList</div><div>         }</div><div>     }</div><div><br></div><div>-    if (*rootSnapshotTreeList == NULL) {</div><div>-        ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR, "%s",</div>

<div>-                     _("Could not lookup root snapshot list"));</div><div>-        goto failure;</div><div>-    }</div><div>-</div><div>   cleanup:</div><div>     esxVI_String_Free(&propertyNameList);</div>

<div>     esxVI_ObjectContent_Free(&virtualMachine);</div><div><br></div></div>