提交 1e64d8c7 编写于 作者: D Daniel P. Berrange

Add API for 'stop' monitor command

* src/qemu/qemu_monitor.c, src/qemu/qemu_monitor.h: Add a new
  qemuMonitorStopCPUs() API
* src/qemu/qemu_driver.c: Replace direct monitor commands for 'stop'
  with qemuMonitorStopCPUs()
上级 4734a422
...@@ -2749,7 +2749,6 @@ cleanup: ...@@ -2749,7 +2749,6 @@ cleanup:
static int qemudDomainSuspend(virDomainPtr dom) { static int qemudDomainSuspend(virDomainPtr dom) {
struct qemud_driver *driver = dom->conn->privateData; struct qemud_driver *driver = dom->conn->privateData;
char *info;
virDomainObjPtr vm; virDomainObjPtr vm;
int ret = -1; int ret = -1;
virDomainEventPtr event = NULL; virDomainEventPtr event = NULL;
...@@ -2770,17 +2769,12 @@ static int qemudDomainSuspend(virDomainPtr dom) { ...@@ -2770,17 +2769,12 @@ static int qemudDomainSuspend(virDomainPtr dom) {
goto cleanup; goto cleanup;
} }
if (vm->state != VIR_DOMAIN_PAUSED) { if (vm->state != VIR_DOMAIN_PAUSED) {
if (qemudMonitorCommand(vm, "stop", &info) < 0) { if (qemuMonitorStopCPUs(vm) < 0)
qemudReportError(dom->conn, dom, NULL, VIR_ERR_OPERATION_FAILED,
"%s", _("suspend operation failed"));
goto cleanup; goto cleanup;
}
vm->state = VIR_DOMAIN_PAUSED; vm->state = VIR_DOMAIN_PAUSED;
qemudDebug("Reply %s", info);
event = virDomainEventNewFromObj(vm, event = virDomainEventNewFromObj(vm,
VIR_DOMAIN_EVENT_SUSPENDED, VIR_DOMAIN_EVENT_SUSPENDED,
VIR_DOMAIN_EVENT_SUSPENDED_PAUSED); VIR_DOMAIN_EVENT_SUSPENDED_PAUSED);
VIR_FREE(info);
} }
if (virDomainSaveStatus(dom->conn, driver->stateDir, vm) < 0) if (virDomainSaveStatus(dom->conn, driver->stateDir, vm) < 0)
goto cleanup; goto cleanup;
...@@ -3365,14 +3359,9 @@ static int qemudDomainSave(virDomainPtr dom, ...@@ -3365,14 +3359,9 @@ static int qemudDomainSave(virDomainPtr dom,
/* Pause */ /* Pause */
if (vm->state == VIR_DOMAIN_RUNNING) { if (vm->state == VIR_DOMAIN_RUNNING) {
header.was_running = 1; header.was_running = 1;
if (qemudMonitorCommand(vm, "stop", &info) < 0) { if (qemuMonitorStopCPUs(vm) < 0)
qemudReportError(dom->conn, dom, NULL, VIR_ERR_OPERATION_FAILED,
"%s", _("suspend operation failed"));
goto cleanup; goto cleanup;
}
vm->state = VIR_DOMAIN_PAUSED; vm->state = VIR_DOMAIN_PAUSED;
qemudDebug("Reply %s", info);
VIR_FREE(info);
} }
/* Get XML for the domain */ /* Get XML for the domain */
...@@ -3527,13 +3516,8 @@ static int qemudDomainCoreDump(virDomainPtr dom, ...@@ -3527,13 +3516,8 @@ static int qemudDomainCoreDump(virDomainPtr dom,
/* Pause domain for non-live dump */ /* Pause domain for non-live dump */
if (vm->state == VIR_DOMAIN_RUNNING) { if (vm->state == VIR_DOMAIN_RUNNING) {
if (qemudMonitorCommand (vm, "stop", &info) < 0) { if (qemuMonitorStopCPUs(vm) < 0)
qemudReportError(dom->conn, dom, NULL, VIR_ERR_OPERATION_FAILED,
"%s", _("suspending before dump failed"));
goto cleanup; goto cleanup;
}
DEBUG ("%s: stop reply: %s", vm->def->name, info);
VIR_FREE(info);
paused = 1; paused = 1;
} }
...@@ -6747,13 +6731,8 @@ qemudDomainMigratePerform (virDomainPtr dom, ...@@ -6747,13 +6731,8 @@ qemudDomainMigratePerform (virDomainPtr dom,
if (!(flags & VIR_MIGRATE_LIVE)) { if (!(flags & VIR_MIGRATE_LIVE)) {
/* Pause domain for non-live migration */ /* Pause domain for non-live migration */
if (qemudMonitorCommand (vm, "stop", &info) < 0) { if (qemuMonitorStopCPUs(vm) < 0)
qemudReportError(dom->conn, dom, NULL, VIR_ERR_OPERATION_FAILED,
"%s", _("off-line migration specified, but suspend operation failed"));
goto cleanup; goto cleanup;
}
DEBUG ("%s: stop reply: %s", vm->def->name, info);
VIR_FREE(info);
paused = 1; paused = 1;
event = virDomainEventNewFromObj(vm, event = virDomainEventNewFromObj(vm,
......
...@@ -438,6 +438,19 @@ qemuMonitorStartCPUs(virConnectPtr conn, ...@@ -438,6 +438,19 @@ qemuMonitorStartCPUs(virConnectPtr conn,
} }
int
qemuMonitorStopCPUs(const virDomainObjPtr vm) {
char *info;
if (qemudMonitorCommand(vm, "stop", &info) < 0) {
qemudReportError(NULL, NULL, NULL, VIR_ERR_OPERATION_FAILED,
"%s", _("cannot stop CPU execution"));
return -1;
}
VIR_FREE(info);
return 0;
}
int qemuMonitorGetCPUInfo(const virDomainObjPtr vm, int qemuMonitorGetCPUInfo(const virDomainObjPtr vm,
int **pids) int **pids)
{ {
......
...@@ -67,6 +67,7 @@ int qemudMonitorCommandExtra(const virDomainObjPtr vm, ...@@ -67,6 +67,7 @@ int qemudMonitorCommandExtra(const virDomainObjPtr vm,
int qemuMonitorStartCPUs(virConnectPtr conn, int qemuMonitorStartCPUs(virConnectPtr conn,
const virDomainObjPtr vm); const virDomainObjPtr vm);
int qemuMonitorStopCPUs(const virDomainObjPtr vm);
int qemuMonitorGetCPUInfo(const virDomainObjPtr vm, int qemuMonitorGetCPUInfo(const virDomainObjPtr vm,
int **pids); int **pids);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册