mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-31 18:15:25 +00:00
qemu: Implement VIR_DOMAIN_ABORT_JOB_POSTCOPY flag
Signed-off-by: Jiri Denemark <jdenemar@redhat.com> Reviewed-by: Peter Krempa <pkrempa@redhat.com>
This commit is contained in:
parent
479d8e9f09
commit
01d65a1520
@ -12788,6 +12788,30 @@ qemuDomainAbortJobMigration(virDomainObj *vm)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static int
|
||||||
|
qemuDomainAbortJobPostcopy(virDomainObj *vm,
|
||||||
|
unsigned int flags)
|
||||||
|
{
|
||||||
|
qemuDomainObjPrivate *priv = vm->privateData;
|
||||||
|
int rc;
|
||||||
|
|
||||||
|
if (!(flags & VIR_DOMAIN_ABORT_JOB_POSTCOPY)) {
|
||||||
|
virReportError(VIR_ERR_OPERATION_INVALID, "%s",
|
||||||
|
_("cannot abort migration in post-copy mode"));
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
VIR_DEBUG("Suspending post-copy migration at client request");
|
||||||
|
|
||||||
|
qemuDomainObjAbortAsyncJob(vm);
|
||||||
|
qemuDomainObjEnterMonitor(priv->driver, vm);
|
||||||
|
rc = qemuMonitorMigratePause(priv->mon);
|
||||||
|
qemuDomainObjExitMonitor(vm);
|
||||||
|
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
qemuDomainAbortJobFlags(virDomainPtr dom,
|
qemuDomainAbortJobFlags(virDomainPtr dom,
|
||||||
unsigned int flags)
|
unsigned int flags)
|
||||||
@ -12796,11 +12820,10 @@ qemuDomainAbortJobFlags(virDomainPtr dom,
|
|||||||
virDomainObj *vm;
|
virDomainObj *vm;
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
qemuDomainObjPrivate *priv;
|
qemuDomainObjPrivate *priv;
|
||||||
int reason;
|
|
||||||
|
|
||||||
VIR_DEBUG("flags=0x%x", flags);
|
VIR_DEBUG("flags=0x%x", flags);
|
||||||
|
|
||||||
virCheckFlags(0, -1);
|
virCheckFlags(VIR_DOMAIN_ABORT_JOB_POSTCOPY, -1);
|
||||||
|
|
||||||
if (!(vm = qemuDomainObjFromDomain(dom)))
|
if (!(vm = qemuDomainObjFromDomain(dom)))
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -12816,6 +12839,14 @@ qemuDomainAbortJobFlags(virDomainPtr dom,
|
|||||||
|
|
||||||
priv = vm->privateData;
|
priv = vm->privateData;
|
||||||
|
|
||||||
|
if (flags & VIR_DOMAIN_ABORT_JOB_POSTCOPY &&
|
||||||
|
(priv->job.asyncJob != VIR_ASYNC_JOB_MIGRATION_OUT ||
|
||||||
|
!virDomainObjIsPostcopy(vm, VIR_DOMAIN_JOB_OPERATION_MIGRATION_OUT))) {
|
||||||
|
virReportError(VIR_ERR_OPERATION_INVALID, "%s",
|
||||||
|
_("current job is not outgoing migration in post-copy mode"));
|
||||||
|
goto endjob;
|
||||||
|
}
|
||||||
|
|
||||||
switch (priv->job.asyncJob) {
|
switch (priv->job.asyncJob) {
|
||||||
case VIR_ASYNC_JOB_NONE:
|
case VIR_ASYNC_JOB_NONE:
|
||||||
virReportError(VIR_ERR_OPERATION_INVALID, "%s",
|
virReportError(VIR_ERR_OPERATION_INVALID, "%s",
|
||||||
@ -12835,15 +12866,10 @@ qemuDomainAbortJobFlags(virDomainPtr dom,
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case VIR_ASYNC_JOB_MIGRATION_OUT:
|
case VIR_ASYNC_JOB_MIGRATION_OUT:
|
||||||
if ((priv->job.current->status == VIR_DOMAIN_JOB_STATUS_POSTCOPY ||
|
if (virDomainObjIsPostcopy(vm, VIR_DOMAIN_JOB_OPERATION_MIGRATION_OUT))
|
||||||
(virDomainObjGetState(vm, &reason) == VIR_DOMAIN_PAUSED &&
|
ret = qemuDomainAbortJobPostcopy(vm, flags);
|
||||||
reason == VIR_DOMAIN_PAUSED_POSTCOPY))) {
|
else
|
||||||
virReportError(VIR_ERR_OPERATION_INVALID, "%s",
|
ret = qemuDomainAbortJobMigration(vm);
|
||||||
_("cannot abort migration in post-copy mode"));
|
|
||||||
goto endjob;
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = qemuDomainAbortJobMigration(vm);
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case VIR_ASYNC_JOB_SAVE:
|
case VIR_ASYNC_JOB_SAVE:
|
||||||
|
@ -2425,6 +2425,15 @@ qemuMonitorMigrateCancel(qemuMonitor *mon)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int
|
||||||
|
qemuMonitorMigratePause(qemuMonitor *mon)
|
||||||
|
{
|
||||||
|
QEMU_CHECK_MONITOR(mon);
|
||||||
|
|
||||||
|
return qemuMonitorJSONMigratePause(mon);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
qemuMonitorQueryDump(qemuMonitor *mon,
|
qemuMonitorQueryDump(qemuMonitor *mon,
|
||||||
qemuMonitorDumpStats *stats)
|
qemuMonitorDumpStats *stats)
|
||||||
|
@ -890,6 +890,9 @@ int qemuMonitorMigrateToSocket(qemuMonitor *mon,
|
|||||||
|
|
||||||
int qemuMonitorMigrateCancel(qemuMonitor *mon);
|
int qemuMonitorMigrateCancel(qemuMonitor *mon);
|
||||||
|
|
||||||
|
int
|
||||||
|
qemuMonitorMigratePause(qemuMonitor *mon);
|
||||||
|
|
||||||
int qemuMonitorGetDumpGuestMemoryCapability(qemuMonitor *mon,
|
int qemuMonitorGetDumpGuestMemoryCapability(qemuMonitor *mon,
|
||||||
const char *capability);
|
const char *capability);
|
||||||
|
|
||||||
|
@ -3455,6 +3455,25 @@ int qemuMonitorJSONMigrateCancel(qemuMonitor *mon)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int
|
||||||
|
qemuMonitorJSONMigratePause(qemuMonitor *mon)
|
||||||
|
{
|
||||||
|
g_autoptr(virJSONValue) cmd = NULL;
|
||||||
|
g_autoptr(virJSONValue) reply = NULL;
|
||||||
|
|
||||||
|
if (!(cmd = qemuMonitorJSONMakeCommand("migrate-pause", NULL)))
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
if (qemuMonitorJSONCheckError(cmd, reply) < 0)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* qemuMonitorJSONQueryDump:
|
/* qemuMonitorJSONQueryDump:
|
||||||
* @mon: Monitor pointer
|
* @mon: Monitor pointer
|
||||||
* @stats: Monitor dump stats
|
* @stats: Monitor dump stats
|
||||||
|
@ -207,6 +207,9 @@ qemuMonitorJSONGetSpiceMigrationStatus(qemuMonitor *mon,
|
|||||||
int
|
int
|
||||||
qemuMonitorJSONMigrateCancel(qemuMonitor *mon);
|
qemuMonitorJSONMigrateCancel(qemuMonitor *mon);
|
||||||
|
|
||||||
|
int
|
||||||
|
qemuMonitorJSONMigratePause(qemuMonitor *mon);
|
||||||
|
|
||||||
int
|
int
|
||||||
qemuMonitorJSONQueryDump(qemuMonitor *mon,
|
qemuMonitorJSONQueryDump(qemuMonitor *mon,
|
||||||
qemuMonitorDumpStats *stats);
|
qemuMonitorDumpStats *stats);
|
||||||
|
@ -3111,6 +3111,7 @@ mymain(void)
|
|||||||
DO_TEST_GEN_DEPRECATED(qemuMonitorJSONSetMigrationDowntime, true);
|
DO_TEST_GEN_DEPRECATED(qemuMonitorJSONSetMigrationDowntime, true);
|
||||||
DO_TEST_GEN(qemuMonitorJSONMigrate);
|
DO_TEST_GEN(qemuMonitorJSONMigrate);
|
||||||
DO_TEST_GEN(qemuMonitorJSONMigrateRecover);
|
DO_TEST_GEN(qemuMonitorJSONMigrateRecover);
|
||||||
|
DO_TEST_SIMPLE("migrate-pause", qemuMonitorJSONMigratePause);
|
||||||
DO_TEST_GEN(qemuMonitorJSONDump);
|
DO_TEST_GEN(qemuMonitorJSONDump);
|
||||||
DO_TEST_GEN(qemuMonitorJSONGraphicsRelocate);
|
DO_TEST_GEN(qemuMonitorJSONGraphicsRelocate);
|
||||||
DO_TEST_GEN(qemuMonitorJSONRemoveNetdev);
|
DO_TEST_GEN(qemuMonitorJSONRemoveNetdev);
|
||||||
|
Loading…
Reference in New Issue
Block a user