mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 13:45:38 +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
|
||||
qemuDomainAbortJobFlags(virDomainPtr dom,
|
||||
unsigned int flags)
|
||||
@ -12796,11 +12820,10 @@ qemuDomainAbortJobFlags(virDomainPtr dom,
|
||||
virDomainObj *vm;
|
||||
int ret = -1;
|
||||
qemuDomainObjPrivate *priv;
|
||||
int reason;
|
||||
|
||||
VIR_DEBUG("flags=0x%x", flags);
|
||||
|
||||
virCheckFlags(0, -1);
|
||||
virCheckFlags(VIR_DOMAIN_ABORT_JOB_POSTCOPY, -1);
|
||||
|
||||
if (!(vm = qemuDomainObjFromDomain(dom)))
|
||||
goto cleanup;
|
||||
@ -12816,6 +12839,14 @@ qemuDomainAbortJobFlags(virDomainPtr dom,
|
||||
|
||||
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) {
|
||||
case VIR_ASYNC_JOB_NONE:
|
||||
virReportError(VIR_ERR_OPERATION_INVALID, "%s",
|
||||
@ -12835,15 +12866,10 @@ qemuDomainAbortJobFlags(virDomainPtr dom,
|
||||
break;
|
||||
|
||||
case VIR_ASYNC_JOB_MIGRATION_OUT:
|
||||
if ((priv->job.current->status == VIR_DOMAIN_JOB_STATUS_POSTCOPY ||
|
||||
(virDomainObjGetState(vm, &reason) == VIR_DOMAIN_PAUSED &&
|
||||
reason == VIR_DOMAIN_PAUSED_POSTCOPY))) {
|
||||
virReportError(VIR_ERR_OPERATION_INVALID, "%s",
|
||||
_("cannot abort migration in post-copy mode"));
|
||||
goto endjob;
|
||||
}
|
||||
|
||||
ret = qemuDomainAbortJobMigration(vm);
|
||||
if (virDomainObjIsPostcopy(vm, VIR_DOMAIN_JOB_OPERATION_MIGRATION_OUT))
|
||||
ret = qemuDomainAbortJobPostcopy(vm, flags);
|
||||
else
|
||||
ret = qemuDomainAbortJobMigration(vm);
|
||||
break;
|
||||
|
||||
case VIR_ASYNC_JOB_SAVE:
|
||||
|
@ -2425,6 +2425,15 @@ qemuMonitorMigrateCancel(qemuMonitor *mon)
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
qemuMonitorMigratePause(qemuMonitor *mon)
|
||||
{
|
||||
QEMU_CHECK_MONITOR(mon);
|
||||
|
||||
return qemuMonitorJSONMigratePause(mon);
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
qemuMonitorQueryDump(qemuMonitor *mon,
|
||||
qemuMonitorDumpStats *stats)
|
||||
|
@ -890,6 +890,9 @@ int qemuMonitorMigrateToSocket(qemuMonitor *mon,
|
||||
|
||||
int qemuMonitorMigrateCancel(qemuMonitor *mon);
|
||||
|
||||
int
|
||||
qemuMonitorMigratePause(qemuMonitor *mon);
|
||||
|
||||
int qemuMonitorGetDumpGuestMemoryCapability(qemuMonitor *mon,
|
||||
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:
|
||||
* @mon: Monitor pointer
|
||||
* @stats: Monitor dump stats
|
||||
|
@ -207,6 +207,9 @@ qemuMonitorJSONGetSpiceMigrationStatus(qemuMonitor *mon,
|
||||
int
|
||||
qemuMonitorJSONMigrateCancel(qemuMonitor *mon);
|
||||
|
||||
int
|
||||
qemuMonitorJSONMigratePause(qemuMonitor *mon);
|
||||
|
||||
int
|
||||
qemuMonitorJSONQueryDump(qemuMonitor *mon,
|
||||
qemuMonitorDumpStats *stats);
|
||||
|
@ -3111,6 +3111,7 @@ mymain(void)
|
||||
DO_TEST_GEN_DEPRECATED(qemuMonitorJSONSetMigrationDowntime, true);
|
||||
DO_TEST_GEN(qemuMonitorJSONMigrate);
|
||||
DO_TEST_GEN(qemuMonitorJSONMigrateRecover);
|
||||
DO_TEST_SIMPLE("migrate-pause", qemuMonitorJSONMigratePause);
|
||||
DO_TEST_GEN(qemuMonitorJSONDump);
|
||||
DO_TEST_GEN(qemuMonitorJSONGraphicsRelocate);
|
||||
DO_TEST_GEN(qemuMonitorJSONRemoveNetdev);
|
||||
|
Loading…
Reference in New Issue
Block a user