qemuProcessStop: Switch to flags

Currently, we are passing only one boolean (migrated) so there is
no real profit in this. But it creates starting position for
next patch.
(cherry picked from commit 69dd77149c)

Conflicts:

	src/qemu/qemu_process.c
This commit is contained in:
Michal Privoznik 2012-06-11 15:20:44 +02:00 committed by Cole Robinson
parent a016b20fa4
commit 9225f9e12f
4 changed files with 38 additions and 26 deletions

View File

@ -1849,7 +1849,7 @@ qemuDomainDestroyFlags(virDomainPtr dom,
goto endjob; goto endjob;
} }
qemuProcessStop(driver, vm, 0, VIR_DOMAIN_SHUTOFF_DESTROYED); qemuProcessStop(driver, vm, VIR_DOMAIN_SHUTOFF_DESTROYED, 0);
event = virDomainEventNewFromObj(vm, event = virDomainEventNewFromObj(vm,
VIR_DOMAIN_EVENT_STOPPED, VIR_DOMAIN_EVENT_STOPPED,
VIR_DOMAIN_EVENT_STOPPED_DESTROYED); VIR_DOMAIN_EVENT_STOPPED_DESTROYED);
@ -2710,7 +2710,7 @@ qemuDomainSaveInternal(struct qemud_driver *driver, virDomainPtr dom,
ret = 0; ret = 0;
/* Shut it down */ /* Shut it down */
qemuProcessStop(driver, vm, 0, VIR_DOMAIN_SHUTOFF_SAVED); qemuProcessStop(driver, vm, VIR_DOMAIN_SHUTOFF_SAVED, 0);
virDomainAuditStop(vm, "saved"); virDomainAuditStop(vm, "saved");
event = virDomainEventNewFromObj(vm, event = virDomainEventNewFromObj(vm,
VIR_DOMAIN_EVENT_STOPPED, VIR_DOMAIN_EVENT_STOPPED,
@ -3115,7 +3115,7 @@ static int qemudDomainCoreDump(virDomainPtr dom,
endjob: endjob:
if ((ret == 0) && (flags & VIR_DUMP_CRASH)) { if ((ret == 0) && (flags & VIR_DUMP_CRASH)) {
qemuProcessStop(driver, vm, 0, VIR_DOMAIN_SHUTOFF_CRASHED); qemuProcessStop(driver, vm, VIR_DOMAIN_SHUTOFF_CRASHED, 0);
virDomainAuditStop(vm, "crashed"); virDomainAuditStop(vm, "crashed");
event = virDomainEventNewFromObj(vm, event = virDomainEventNewFromObj(vm,
VIR_DOMAIN_EVENT_STOPPED, VIR_DOMAIN_EVENT_STOPPED,
@ -9750,7 +9750,7 @@ qemuDomainSnapshotCreateActive(virConnectPtr conn,
event = virDomainEventNewFromObj(vm, VIR_DOMAIN_EVENT_STOPPED, event = virDomainEventNewFromObj(vm, VIR_DOMAIN_EVENT_STOPPED,
VIR_DOMAIN_EVENT_STOPPED_FROM_SNAPSHOT); VIR_DOMAIN_EVENT_STOPPED_FROM_SNAPSHOT);
qemuProcessStop(driver, vm, 0, VIR_DOMAIN_SHUTOFF_FROM_SNAPSHOT); qemuProcessStop(driver, vm, VIR_DOMAIN_SHUTOFF_FROM_SNAPSHOT, 0);
virDomainAuditStop(vm, "from-snapshot"); virDomainAuditStop(vm, "from-snapshot");
/* We already filtered the _HALT flag for persistent domains /* We already filtered the _HALT flag for persistent domains
* only, so this end job never drops the last reference. */ * only, so this end job never drops the last reference. */
@ -10224,7 +10224,7 @@ qemuDomainSnapshotCreateDiskActive(virConnectPtr conn,
event = virDomainEventNewFromObj(vm, VIR_DOMAIN_EVENT_STOPPED, event = virDomainEventNewFromObj(vm, VIR_DOMAIN_EVENT_STOPPED,
VIR_DOMAIN_EVENT_STOPPED_FROM_SNAPSHOT); VIR_DOMAIN_EVENT_STOPPED_FROM_SNAPSHOT);
qemuProcessStop(driver, vm, 0, VIR_DOMAIN_SHUTOFF_FROM_SNAPSHOT); qemuProcessStop(driver, vm, VIR_DOMAIN_SHUTOFF_FROM_SNAPSHOT, 0);
virDomainAuditStop(vm, "from-snapshot"); virDomainAuditStop(vm, "from-snapshot");
/* We already filtered the _HALT flag for persistent domains /* We already filtered the _HALT flag for persistent domains
* only, so this end job never drops the last reference. */ * only, so this end job never drops the last reference. */
@ -11041,8 +11041,8 @@ static int qemuDomainRevertToSnapshot(virDomainSnapshotPtr snapshot,
goto endjob; goto endjob;
} }
virResetError(err); virResetError(err);
qemuProcessStop(driver, vm, 0, qemuProcessStop(driver, vm,
VIR_DOMAIN_SHUTOFF_FROM_SNAPSHOT); VIR_DOMAIN_SHUTOFF_FROM_SNAPSHOT, 0);
virDomainAuditStop(vm, "from-snapshot"); virDomainAuditStop(vm, "from-snapshot");
detail = VIR_DOMAIN_EVENT_STOPPED_FROM_SNAPSHOT; detail = VIR_DOMAIN_EVENT_STOPPED_FROM_SNAPSHOT;
event = virDomainEventNewFromObj(vm, event = virDomainEventNewFromObj(vm,
@ -11154,7 +11154,7 @@ static int qemuDomainRevertToSnapshot(virDomainSnapshotPtr snapshot,
if (virDomainObjIsActive(vm)) { if (virDomainObjIsActive(vm)) {
/* Transitions 4, 7 */ /* Transitions 4, 7 */
qemuProcessStop(driver, vm, 0, VIR_DOMAIN_SHUTOFF_FROM_SNAPSHOT); qemuProcessStop(driver, vm, VIR_DOMAIN_SHUTOFF_FROM_SNAPSHOT, 0);
virDomainAuditStop(vm, "from-snapshot"); virDomainAuditStop(vm, "from-snapshot");
detail = VIR_DOMAIN_EVENT_STOPPED_FROM_SNAPSHOT; detail = VIR_DOMAIN_EVENT_STOPPED_FROM_SNAPSHOT;
event = virDomainEventNewFromObj(vm, event = virDomainEventNewFromObj(vm,

View File

@ -1328,7 +1328,7 @@ qemuMigrationPrepareAny(struct qemud_driver *driver,
virReportSystemError(errno, "%s", virReportSystemError(errno, "%s",
_("cannot pass pipe for tunnelled migration")); _("cannot pass pipe for tunnelled migration"));
virDomainAuditStart(vm, "migrated", false); virDomainAuditStart(vm, "migrated", false);
qemuProcessStop(driver, vm, 0, VIR_DOMAIN_SHUTOFF_FAILED); qemuProcessStop(driver, vm, VIR_DOMAIN_SHUTOFF_FAILED, 0);
goto endjob; goto endjob;
} }
dataFD[1] = -1; /* 'st' owns the FD now & will close it */ dataFD[1] = -1; /* 'st' owns the FD now & will close it */
@ -2646,7 +2646,8 @@ qemuMigrationPerformJob(struct qemud_driver *driver,
* confirm step. * confirm step.
*/ */
if (!v3proto) { if (!v3proto) {
qemuProcessStop(driver, vm, 1, VIR_DOMAIN_SHUTOFF_MIGRATED); qemuProcessStop(driver, vm, VIR_DOMAIN_SHUTOFF_MIGRATED,
VIR_QEMU_PROCESS_STOP_MIGRATED);
virDomainAuditStop(vm, "migrated"); virDomainAuditStop(vm, "migrated");
event = virDomainEventNewFromObj(vm, event = virDomainEventNewFromObj(vm,
VIR_DOMAIN_EVENT_STOPPED, VIR_DOMAIN_EVENT_STOPPED,
@ -2943,7 +2944,8 @@ qemuMigrationFinish(struct qemud_driver *driver,
} }
if (qemuMigrationVPAssociatePortProfiles(vm->def) < 0) { if (qemuMigrationVPAssociatePortProfiles(vm->def) < 0) {
qemuProcessStop(driver, vm, 1, VIR_DOMAIN_SHUTOFF_FAILED); qemuProcessStop(driver, vm, VIR_DOMAIN_SHUTOFF_FAILED,
VIR_QEMU_PROCESS_STOP_MIGRATED);
virDomainAuditStop(vm, "failed"); virDomainAuditStop(vm, "failed");
event = virDomainEventNewFromObj(vm, event = virDomainEventNewFromObj(vm,
VIR_DOMAIN_EVENT_STOPPED, VIR_DOMAIN_EVENT_STOPPED,
@ -2976,7 +2978,8 @@ qemuMigrationFinish(struct qemud_driver *driver,
* to restart during confirm() step, so we kill it off now. * to restart during confirm() step, so we kill it off now.
*/ */
if (v3proto) { if (v3proto) {
qemuProcessStop(driver, vm, 1, VIR_DOMAIN_SHUTOFF_FAILED); qemuProcessStop(driver, vm, VIR_DOMAIN_SHUTOFF_FAILED,
VIR_QEMU_PROCESS_STOP_MIGRATED);
virDomainAuditStop(vm, "failed"); virDomainAuditStop(vm, "failed");
if (newVM) if (newVM)
vm->persistent = 0; vm->persistent = 0;
@ -3022,7 +3025,8 @@ qemuMigrationFinish(struct qemud_driver *driver,
* things up * things up
*/ */
if (v3proto) { if (v3proto) {
qemuProcessStop(driver, vm, 1, VIR_DOMAIN_SHUTOFF_FAILED); qemuProcessStop(driver, vm, VIR_DOMAIN_SHUTOFF_FAILED,
VIR_QEMU_PROCESS_STOP_MIGRATED);
virDomainAuditStop(vm, "failed"); virDomainAuditStop(vm, "failed");
event = virDomainEventNewFromObj(vm, event = virDomainEventNewFromObj(vm,
VIR_DOMAIN_EVENT_STOPPED, VIR_DOMAIN_EVENT_STOPPED,
@ -3053,7 +3057,8 @@ qemuMigrationFinish(struct qemud_driver *driver,
/* Guest is successfully running, so cancel previous auto destroy */ /* Guest is successfully running, so cancel previous auto destroy */
qemuProcessAutoDestroyRemove(driver, vm); qemuProcessAutoDestroyRemove(driver, vm);
} else { } else {
qemuProcessStop(driver, vm, 1, VIR_DOMAIN_SHUTOFF_FAILED); qemuProcessStop(driver, vm, VIR_DOMAIN_SHUTOFF_FAILED,
VIR_QEMU_PROCESS_STOP_MIGRATED);
virDomainAuditStop(vm, "failed"); virDomainAuditStop(vm, "failed");
event = virDomainEventNewFromObj(vm, event = virDomainEventNewFromObj(vm,
VIR_DOMAIN_EVENT_STOPPED, VIR_DOMAIN_EVENT_STOPPED,
@ -3117,7 +3122,8 @@ int qemuMigrationConfirm(struct qemud_driver *driver,
* domain object, but if no, resume CPUs * domain object, but if no, resume CPUs
*/ */
if (retcode == 0) { if (retcode == 0) {
qemuProcessStop(driver, vm, 1, VIR_DOMAIN_SHUTOFF_MIGRATED); qemuProcessStop(driver, vm, VIR_DOMAIN_SHUTOFF_MIGRATED,
VIR_QEMU_PROCESS_STOP_MIGRATED);
virDomainAuditStop(vm, "migrated"); virDomainAuditStop(vm, "migrated");
event = virDomainEventNewFromObj(vm, event = virDomainEventNewFromObj(vm,

View File

@ -311,7 +311,7 @@ qemuProcessHandleMonitorEOF(qemuMonitorPtr mon ATTRIBUTE_UNUSED,
event = virDomainEventNewFromObj(vm, event = virDomainEventNewFromObj(vm,
VIR_DOMAIN_EVENT_STOPPED, VIR_DOMAIN_EVENT_STOPPED,
eventReason); eventReason);
qemuProcessStop(driver, vm, 0, stopReason); qemuProcessStop(driver, vm, stopReason, 0);
virDomainAuditStop(vm, auditReason); virDomainAuditStop(vm, auditReason);
if (!vm->persistent) { if (!vm->persistent) {
@ -3230,7 +3230,7 @@ qemuProcessReconnectHelper(void *payload,
} else if (virDomainObjUnref(obj) > 0) { } else if (virDomainObjUnref(obj) > 0) {
/* We can't spawn a thread and thus connect to monitor. /* We can't spawn a thread and thus connect to monitor.
* Kill qemu */ * Kill qemu */
qemuProcessStop(src->driver, obj, 0, VIR_DOMAIN_SHUTOFF_FAILED); qemuProcessStop(src->driver, obj, VIR_DOMAIN_SHUTOFF_FAILED, 0);
if (!obj->persistent) if (!obj->persistent)
qemuDomainRemoveInactive(src->driver, obj); qemuDomainRemoveInactive(src->driver, obj);
else else
@ -3738,7 +3738,7 @@ cleanup:
* pretend we never started it */ * pretend we never started it */
virCommandFree(cmd); virCommandFree(cmd);
VIR_FORCE_CLOSE(logfile); VIR_FORCE_CLOSE(logfile);
qemuProcessStop(driver, vm, 0, VIR_DOMAIN_SHUTOFF_FAILED); qemuProcessStop(driver, vm, VIR_DOMAIN_SHUTOFF_FAILED, 0);
return -1; return -1;
} }
@ -3841,8 +3841,8 @@ cleanup:
void qemuProcessStop(struct qemud_driver *driver, void qemuProcessStop(struct qemud_driver *driver,
virDomainObjPtr vm, virDomainObjPtr vm,
int migrated, virDomainShutoffReason reason,
virDomainShutoffReason reason) unsigned int flags)
{ {
int ret; int ret;
int retries = 0; int retries = 0;
@ -3855,8 +3855,8 @@ void qemuProcessStop(struct qemud_driver *driver,
char *timestamp; char *timestamp;
char ebuf[1024]; char ebuf[1024];
VIR_DEBUG("Shutting down VM '%s' pid=%d migrated=%d", VIR_DEBUG("Shutting down VM '%s' pid=%d flags=%x",
vm->def->name, vm->pid, migrated); vm->def->name, vm->pid, flags);
if (!virDomainObjIsActive(vm)) { if (!virDomainObjIsActive(vm)) {
VIR_DEBUG("VM '%s' not active", vm->def->name); VIR_DEBUG("VM '%s' not active", vm->def->name);
@ -3953,7 +3953,8 @@ void qemuProcessStop(struct qemud_driver *driver,
/* Reset Security Labels */ /* Reset Security Labels */
virSecurityManagerRestoreAllLabel(driver->securityManager, virSecurityManagerRestoreAllLabel(driver->securityManager,
vm->def, migrated); vm->def,
flags & VIR_QEMU_PROCESS_STOP_MIGRATED);
virSecurityManagerReleaseLabel(driver->securityManager, vm->def); virSecurityManagerReleaseLabel(driver->securityManager, vm->def);
/* Clear out dynamically assigned labels */ /* Clear out dynamically assigned labels */
@ -4272,7 +4273,8 @@ qemuProcessAutoDestroy(struct qemud_driver *driver,
goto cleanup; goto cleanup;
VIR_DEBUG("Killing domain"); VIR_DEBUG("Killing domain");
qemuProcessStop(driver, dom, 1, VIR_DOMAIN_SHUTOFF_DESTROYED); qemuProcessStop(driver, dom, VIR_DOMAIN_SHUTOFF_DESTROYED,
VIR_QEMU_PROCESS_STOP_MIGRATED);
virDomainAuditStop(dom, "destroyed"); virDomainAuditStop(dom, "destroyed");
event = virDomainEventNewFromObj(dom, event = virDomainEventNewFromObj(dom,
VIR_DOMAIN_EVENT_STOPPED, VIR_DOMAIN_EVENT_STOPPED,

View File

@ -56,10 +56,14 @@ int qemuProcessStart(virConnectPtr conn,
virDomainSnapshotObjPtr snapshot, virDomainSnapshotObjPtr snapshot,
enum virNetDevVPortProfileOp vmop); enum virNetDevVPortProfileOp vmop);
typedef enum {
VIR_QEMU_PROCESS_STOP_MIGRATED = 1 << 0,
} qemuProcessStopFlags;
void qemuProcessStop(struct qemud_driver *driver, void qemuProcessStop(struct qemud_driver *driver,
virDomainObjPtr vm, virDomainObjPtr vm,
int migrated, virDomainShutoffReason reason,
virDomainShutoffReason reason); unsigned int flags);
int qemuProcessAttach(virConnectPtr conn, int qemuProcessAttach(virConnectPtr conn,
struct qemud_driver *driver, struct qemud_driver *driver,