From 9225f9e12f5b8421139e81c9a6b09619bccd189b Mon Sep 17 00:00:00 2001 From: Michal Privoznik Date: Mon, 11 Jun 2012 15:20:44 +0200 Subject: [PATCH] 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 69dd77149cacc6b12740bd70b729b6cb7506f4e0) Conflicts: src/qemu/qemu_process.c --- src/qemu/qemu_driver.c | 16 ++++++++-------- src/qemu/qemu_migration.c | 20 +++++++++++++------- src/qemu/qemu_process.c | 20 +++++++++++--------- src/qemu/qemu_process.h | 8 ++++++-- 4 files changed, 38 insertions(+), 26 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index cadb3db609..1cbe47b787 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -1849,7 +1849,7 @@ qemuDomainDestroyFlags(virDomainPtr dom, goto endjob; } - qemuProcessStop(driver, vm, 0, VIR_DOMAIN_SHUTOFF_DESTROYED); + qemuProcessStop(driver, vm, VIR_DOMAIN_SHUTOFF_DESTROYED, 0); event = virDomainEventNewFromObj(vm, VIR_DOMAIN_EVENT_STOPPED, VIR_DOMAIN_EVENT_STOPPED_DESTROYED); @@ -2710,7 +2710,7 @@ qemuDomainSaveInternal(struct qemud_driver *driver, virDomainPtr dom, ret = 0; /* Shut it down */ - qemuProcessStop(driver, vm, 0, VIR_DOMAIN_SHUTOFF_SAVED); + qemuProcessStop(driver, vm, VIR_DOMAIN_SHUTOFF_SAVED, 0); virDomainAuditStop(vm, "saved"); event = virDomainEventNewFromObj(vm, VIR_DOMAIN_EVENT_STOPPED, @@ -3115,7 +3115,7 @@ static int qemudDomainCoreDump(virDomainPtr dom, endjob: 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"); event = virDomainEventNewFromObj(vm, VIR_DOMAIN_EVENT_STOPPED, @@ -9750,7 +9750,7 @@ qemuDomainSnapshotCreateActive(virConnectPtr conn, event = virDomainEventNewFromObj(vm, VIR_DOMAIN_EVENT_STOPPED, 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"); /* We already filtered the _HALT flag for persistent domains * only, so this end job never drops the last reference. */ @@ -10224,7 +10224,7 @@ qemuDomainSnapshotCreateDiskActive(virConnectPtr conn, event = virDomainEventNewFromObj(vm, VIR_DOMAIN_EVENT_STOPPED, 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"); /* We already filtered the _HALT flag for persistent domains * only, so this end job never drops the last reference. */ @@ -11041,8 +11041,8 @@ static int qemuDomainRevertToSnapshot(virDomainSnapshotPtr snapshot, goto endjob; } virResetError(err); - qemuProcessStop(driver, vm, 0, - VIR_DOMAIN_SHUTOFF_FROM_SNAPSHOT); + qemuProcessStop(driver, vm, + VIR_DOMAIN_SHUTOFF_FROM_SNAPSHOT, 0); virDomainAuditStop(vm, "from-snapshot"); detail = VIR_DOMAIN_EVENT_STOPPED_FROM_SNAPSHOT; event = virDomainEventNewFromObj(vm, @@ -11154,7 +11154,7 @@ static int qemuDomainRevertToSnapshot(virDomainSnapshotPtr snapshot, if (virDomainObjIsActive(vm)) { /* 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"); detail = VIR_DOMAIN_EVENT_STOPPED_FROM_SNAPSHOT; event = virDomainEventNewFromObj(vm, diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index 4fec6464cc..aee613e993 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -1328,7 +1328,7 @@ qemuMigrationPrepareAny(struct qemud_driver *driver, virReportSystemError(errno, "%s", _("cannot pass pipe for tunnelled migration")); virDomainAuditStart(vm, "migrated", false); - qemuProcessStop(driver, vm, 0, VIR_DOMAIN_SHUTOFF_FAILED); + qemuProcessStop(driver, vm, VIR_DOMAIN_SHUTOFF_FAILED, 0); goto endjob; } dataFD[1] = -1; /* 'st' owns the FD now & will close it */ @@ -2646,7 +2646,8 @@ qemuMigrationPerformJob(struct qemud_driver *driver, * confirm step. */ 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"); event = virDomainEventNewFromObj(vm, VIR_DOMAIN_EVENT_STOPPED, @@ -2943,7 +2944,8 @@ qemuMigrationFinish(struct qemud_driver *driver, } 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"); event = virDomainEventNewFromObj(vm, VIR_DOMAIN_EVENT_STOPPED, @@ -2976,7 +2978,8 @@ qemuMigrationFinish(struct qemud_driver *driver, * to restart during confirm() step, so we kill it off now. */ 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"); if (newVM) vm->persistent = 0; @@ -3022,7 +3025,8 @@ qemuMigrationFinish(struct qemud_driver *driver, * things up */ 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"); event = virDomainEventNewFromObj(vm, VIR_DOMAIN_EVENT_STOPPED, @@ -3053,7 +3057,8 @@ qemuMigrationFinish(struct qemud_driver *driver, /* Guest is successfully running, so cancel previous auto destroy */ qemuProcessAutoDestroyRemove(driver, vm); } else { - qemuProcessStop(driver, vm, 1, VIR_DOMAIN_SHUTOFF_FAILED); + qemuProcessStop(driver, vm, VIR_DOMAIN_SHUTOFF_FAILED, + VIR_QEMU_PROCESS_STOP_MIGRATED); virDomainAuditStop(vm, "failed"); event = virDomainEventNewFromObj(vm, VIR_DOMAIN_EVENT_STOPPED, @@ -3117,7 +3122,8 @@ int qemuMigrationConfirm(struct qemud_driver *driver, * domain object, but if no, resume CPUs */ 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"); event = virDomainEventNewFromObj(vm, diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 20fb491724..244dcdc948 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -311,7 +311,7 @@ qemuProcessHandleMonitorEOF(qemuMonitorPtr mon ATTRIBUTE_UNUSED, event = virDomainEventNewFromObj(vm, VIR_DOMAIN_EVENT_STOPPED, eventReason); - qemuProcessStop(driver, vm, 0, stopReason); + qemuProcessStop(driver, vm, stopReason, 0); virDomainAuditStop(vm, auditReason); if (!vm->persistent) { @@ -3230,7 +3230,7 @@ qemuProcessReconnectHelper(void *payload, } else if (virDomainObjUnref(obj) > 0) { /* We can't spawn a thread and thus connect to monitor. * Kill qemu */ - qemuProcessStop(src->driver, obj, 0, VIR_DOMAIN_SHUTOFF_FAILED); + qemuProcessStop(src->driver, obj, VIR_DOMAIN_SHUTOFF_FAILED, 0); if (!obj->persistent) qemuDomainRemoveInactive(src->driver, obj); else @@ -3738,7 +3738,7 @@ cleanup: * pretend we never started it */ virCommandFree(cmd); VIR_FORCE_CLOSE(logfile); - qemuProcessStop(driver, vm, 0, VIR_DOMAIN_SHUTOFF_FAILED); + qemuProcessStop(driver, vm, VIR_DOMAIN_SHUTOFF_FAILED, 0); return -1; } @@ -3841,8 +3841,8 @@ cleanup: void qemuProcessStop(struct qemud_driver *driver, virDomainObjPtr vm, - int migrated, - virDomainShutoffReason reason) + virDomainShutoffReason reason, + unsigned int flags) { int ret; int retries = 0; @@ -3855,8 +3855,8 @@ void qemuProcessStop(struct qemud_driver *driver, char *timestamp; char ebuf[1024]; - VIR_DEBUG("Shutting down VM '%s' pid=%d migrated=%d", - vm->def->name, vm->pid, migrated); + VIR_DEBUG("Shutting down VM '%s' pid=%d flags=%x", + vm->def->name, vm->pid, flags); if (!virDomainObjIsActive(vm)) { VIR_DEBUG("VM '%s' not active", vm->def->name); @@ -3953,7 +3953,8 @@ void qemuProcessStop(struct qemud_driver *driver, /* Reset Security Labels */ virSecurityManagerRestoreAllLabel(driver->securityManager, - vm->def, migrated); + vm->def, + flags & VIR_QEMU_PROCESS_STOP_MIGRATED); virSecurityManagerReleaseLabel(driver->securityManager, vm->def); /* Clear out dynamically assigned labels */ @@ -4272,7 +4273,8 @@ qemuProcessAutoDestroy(struct qemud_driver *driver, goto cleanup; 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"); event = virDomainEventNewFromObj(dom, VIR_DOMAIN_EVENT_STOPPED, diff --git a/src/qemu/qemu_process.h b/src/qemu/qemu_process.h index 5cb5ffcbe5..4b3a628582 100644 --- a/src/qemu/qemu_process.h +++ b/src/qemu/qemu_process.h @@ -56,10 +56,14 @@ int qemuProcessStart(virConnectPtr conn, virDomainSnapshotObjPtr snapshot, enum virNetDevVPortProfileOp vmop); +typedef enum { + VIR_QEMU_PROCESS_STOP_MIGRATED = 1 << 0, +} qemuProcessStopFlags; + void qemuProcessStop(struct qemud_driver *driver, virDomainObjPtr vm, - int migrated, - virDomainShutoffReason reason); + virDomainShutoffReason reason, + unsigned int flags); int qemuProcessAttach(virConnectPtr conn, struct qemud_driver *driver,