+Sat Dec 20 14:10:09 CET 2008 Guido Günther <agx@sigxcpu.org>
+
+ save and remove kvm/qemu domain status
+ * src/qemu_driver.c (qemdRemoveDomainStatus): new function
+ (qemudOpenMonitor): save monitor path
+ (qemudStartVMDaemon, qemudDomainSuspend, qemudDomainResume,
+ qemudDomainAttachDevice, qemudDomainDetachDevice): save status
+ (qemudShutdownVMDaemon): remove status
+
Sat Dec 20 13:53:14 CET 2008 Guido Günther <agx@sigxcpu.org>
add XML parsing for qemu/kvm status files
virConnectClose(conn);
}
+
+/**
+ * qemudRemoveDomainStatus
+ *
+ * remove all state files of a domain from statedir
+ *
+ * Returns 0 on success
+ */
+static int
+qemudRemoveDomainStatus(virConnectPtr conn,
+ struct qemud_driver *driver,
+ virDomainObjPtr vm)
+{
+ int rc = -1;
+ char *file = NULL;
+
+ if (virAsprintf(&file, "%s/%s.xml", driver->stateDir, vm->def->name) < 0) {
+ qemudReportError(conn, vm, NULL, VIR_ERR_NO_MEMORY,
+ "%s", _("failed to allocate space for status file"));
+ goto cleanup;
+ }
+
+ if (unlink(file) < 0 && errno != ENOENT && errno != ENOTDIR) {
+ qemudReportError(conn, vm, NULL, VIR_ERR_INTERNAL_ERROR,
+ _("Failed to unlink status file %s"), file);
+ goto cleanup;
+ }
+
+ if(virFileDeletePid(driver->stateDir, vm->def->name))
+ goto cleanup;
+
+ rc = 0;
+cleanup:
+ VIR_FREE(file);
+ return rc;
+}
+
+
/**
* qemudStartup:
*
qemudCheckMonitorPrompt,
"monitor", 10000);
+ if (!(vm->monitorpath = strdup(monitor))) {
+ qemudReportError(conn, NULL, NULL, VIR_ERR_NO_MEMORY,
+ "%s", _("failed to allocate space for monitor path"));
+ goto error;
+ }
+
/* Keep monitor open upon success */
if (ret == 0)
return ret;
return -1;
}
}
+ qemudSaveDomainStatus(conn, qemu_driver, vm);
return ret;
}
"%s", _("Got unexpected pid, damn\n"));
}
}
+ qemudRemoveDomainStatus(conn, driver, vm);
vm->pid = -1;
vm->def->id = -1;
VIR_DOMAIN_EVENT_SUSPENDED_PAUSED);
VIR_FREE(info);
}
+ qemudSaveDomainStatus(dom->conn, driver, vm);
ret = 0;
cleanup:
VIR_DOMAIN_EVENT_RESUMED_UNPAUSED);
VIR_FREE(info);
}
+ qemudSaveDomainStatus(dom->conn, driver, vm);
ret = 0;
cleanup:
goto cleanup;
}
+ qemudSaveDomainStatus(dom->conn, driver, vm);
cleanup:
if (ret < 0)
virDomainDeviceDefFree(dev);
qemudReportError(dom->conn, dom, NULL, VIR_ERR_NO_SUPPORT,
"%s", _("only SCSI or virtio disk device can be detached dynamically"));
+ qemudSaveDomainStatus(dom->conn, driver, vm);
cleanup:
virDomainDeviceDefFree(dev);
if (vm)