static int
-esxDomainIsPersistent(virDomainPtr domain ATTRIBUTE_UNUSED)
+esxDomainIsPersistent(virDomainPtr domain)
{
- /* ESX has no concept of transient domains, so all of them are persistent */
- return 1;
+ /* ESX has no concept of transient domains, so all of them are
+ * persistent. However, we do want to check for existence. */
+ int result = -1;
+ esxPrivate *priv = domain->conn->privateData;
+ esxVI_ObjectContent *virtualMachine = NULL;
+
+ if (esxVI_EnsureSession(priv->primary) < 0)
+ return -1;
+
+ if (esxVI_LookupVirtualMachineByUuid(priv->primary, domain->uuid,
+ NULL, &virtualMachine,
+ esxVI_Occurrence_RequiredItem) < 0)
+ goto cleanup;
+
+ result = 1;
+
+cleanup:
+ esxVI_ObjectContent_Free(&virtualMachine);
+
+ return result;
}
static int
esxDomainIsUpdated(virDomainPtr domain ATTRIBUTE_UNUSED)
{
- return 0;
+ /* ESX domains never have a persistent state that differs from
+ * current state. However, we do want to check for existence. */
+ int result = -1;
+ esxPrivate *priv = domain->conn->privateData;
+ esxVI_ObjectContent *virtualMachine = NULL;
+
+ if (esxVI_EnsureSession(priv->primary) < 0)
+ return -1;
+
+ if (esxVI_LookupVirtualMachineByUuid(priv->primary, domain->uuid,
+ NULL, &virtualMachine,
+ esxVI_Occurrence_RequiredItem) < 0)
+ goto cleanup;
+
+ result = 0;
+
+cleanup:
+ esxVI_ObjectContent_Free(&virtualMachine);
+
+ return result;
}
}
-static int vboxDomainIsPersistent(virDomainPtr dom ATTRIBUTE_UNUSED) {
- /* All domains are persistent. */
- return 1;
+static int vboxDomainIsPersistent(virDomainPtr dom ATTRIBUTE_UNUSED)
+{
+ /* All domains are persistent. However, we do want to check for
+ * existence. */
+ VBOX_OBJECT_CHECK(dom->conn, int, -1);
+ vboxIID iid = VBOX_IID_INITIALIZER;
+ IMachine *machine = NULL;
+ nsresult rc;
+
+ vboxIIDFromUUID(&iid, dom->uuid);
+ rc = VBOX_OBJECT_GET_MACHINE(iid.value, &machine);
+ if (NS_FAILED(rc)) {
+ vboxError(VIR_ERR_NO_DOMAIN, "%s",
+ _("no domain with matching UUID"));
+ goto cleanup;
+ }
+
+ ret = 1;
+
+cleanup:
+ VBOX_RELEASE(machine);
+ vboxIIDUnalloc(&iid);
+ return ret;
}
static int vboxDomainIsUpdated(virDomainPtr dom ATTRIBUTE_UNUSED) {
- return 0;
+ /* VBox domains never have a persistent state that differs from
+ * current state. However, we do want to check for existence. */
+ VBOX_OBJECT_CHECK(dom->conn, int, -1);
+ vboxIID iid = VBOX_IID_INITIALIZER;
+ IMachine *machine = NULL;
+ nsresult rc;
+
+ vboxIIDFromUUID(&iid, dom->uuid);
+ rc = VBOX_OBJECT_GET_MACHINE(iid.value, &machine);
+ if (NS_FAILED(rc)) {
+ vboxError(VIR_ERR_NO_DOMAIN, "%s",
+ _("no domain with matching UUID"));
+ goto cleanup;
+ }
+
+ ret = 0;
+
+cleanup:
+ VBOX_RELEASE(machine);
+ vboxIIDUnalloc(&iid);
+ return ret;
}
static int vboxDomainSuspend(virDomainPtr dom) {