mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-08-27 02:51:16 +00:00
save and remove kvm/qemu domain status
This commit is contained in:
parent
b679ebe877
commit
5614e868e1
@ -1,3 +1,12 @@
|
|||||||
|
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>
|
Sat Dec 20 13:53:14 CET 2008 Guido Günther <agx@sigxcpu.org>
|
||||||
|
|
||||||
add XML parsing for qemu/kvm status files
|
add XML parsing for qemu/kvm status files
|
||||||
|
@ -182,6 +182,44 @@ qemudAutostartConfigs(struct qemud_driver *driver) {
|
|||||||
virConnectClose(conn);
|
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:
|
* qemudStartup:
|
||||||
*
|
*
|
||||||
@ -531,6 +569,12 @@ static int qemudOpenMonitor(virConnectPtr conn,
|
|||||||
qemudCheckMonitorPrompt,
|
qemudCheckMonitorPrompt,
|
||||||
"monitor", 10000);
|
"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 */
|
/* Keep monitor open upon success */
|
||||||
if (ret == 0)
|
if (ret == 0)
|
||||||
return ret;
|
return ret;
|
||||||
@ -1030,6 +1074,7 @@ static int qemudStartVMDaemon(virConnectPtr conn,
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
qemudSaveDomainStatus(conn, qemu_driver, vm);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -1095,6 +1140,7 @@ static void qemudShutdownVMDaemon(virConnectPtr conn ATTRIBUTE_UNUSED,
|
|||||||
"%s", _("Got unexpected pid, damn\n"));
|
"%s", _("Got unexpected pid, damn\n"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
qemudRemoveDomainStatus(conn, driver, vm);
|
||||||
|
|
||||||
vm->pid = -1;
|
vm->pid = -1;
|
||||||
vm->def->id = -1;
|
vm->def->id = -1;
|
||||||
@ -1738,6 +1784,7 @@ static int qemudDomainSuspend(virDomainPtr dom) {
|
|||||||
VIR_DOMAIN_EVENT_SUSPENDED_PAUSED);
|
VIR_DOMAIN_EVENT_SUSPENDED_PAUSED);
|
||||||
VIR_FREE(info);
|
VIR_FREE(info);
|
||||||
}
|
}
|
||||||
|
qemudSaveDomainStatus(dom->conn, driver, vm);
|
||||||
ret = 0;
|
ret = 0;
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
@ -1787,6 +1834,7 @@ static int qemudDomainResume(virDomainPtr dom) {
|
|||||||
VIR_DOMAIN_EVENT_RESUMED_UNPAUSED);
|
VIR_DOMAIN_EVENT_RESUMED_UNPAUSED);
|
||||||
VIR_FREE(info);
|
VIR_FREE(info);
|
||||||
}
|
}
|
||||||
|
qemudSaveDomainStatus(dom->conn, driver, vm);
|
||||||
ret = 0;
|
ret = 0;
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
@ -3221,6 +3269,7 @@ static int qemudDomainAttachDevice(virDomainPtr dom,
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
qemudSaveDomainStatus(dom->conn, driver, vm);
|
||||||
cleanup:
|
cleanup:
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
virDomainDeviceDefFree(dev);
|
virDomainDeviceDefFree(dev);
|
||||||
@ -3337,6 +3386,7 @@ static int qemudDomainDetachDevice(virDomainPtr dom,
|
|||||||
qemudReportError(dom->conn, dom, NULL, VIR_ERR_NO_SUPPORT,
|
qemudReportError(dom->conn, dom, NULL, VIR_ERR_NO_SUPPORT,
|
||||||
"%s", _("only SCSI or virtio disk device can be detached dynamically"));
|
"%s", _("only SCSI or virtio disk device can be detached dynamically"));
|
||||||
|
|
||||||
|
qemudSaveDomainStatus(dom->conn, driver, vm);
|
||||||
cleanup:
|
cleanup:
|
||||||
virDomainDeviceDefFree(dev);
|
virDomainDeviceDefFree(dev);
|
||||||
if (vm)
|
if (vm)
|
||||||
|
Loading…
Reference in New Issue
Block a user