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.
This commit is contained in:
Michal Privoznik 2012-06-11 15:20:44 +02:00
parent e3559a6e66
commit 69dd77149c
4 changed files with 39 additions and 27 deletions

View File

@ -1870,7 +1870,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);
@ -2731,7 +2731,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,
@ -3136,7 +3136,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,
@ -9781,7 +9781,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. */
@ -10255,7 +10255,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. */
@ -11153,8 +11153,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,
@ -11267,7 +11267,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

@ -1329,7 +1329,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 */
@ -2647,7 +2647,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,
@ -2944,7 +2945,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,
@ -2977,7 +2979,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;
@ -3023,7 +3026,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,
@ -3054,7 +3058,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,
@ -3118,7 +3123,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) {
@ -3151,7 +3151,7 @@ error:
* really is and FAILED means "failed to start" */ * really is and FAILED means "failed to start" */
state = VIR_DOMAIN_SHUTOFF_UNKNOWN; state = VIR_DOMAIN_SHUTOFF_UNKNOWN;
} }
qemuProcessStop(driver, obj, 0, state); qemuProcessStop(driver, obj, state, 0);
if (!obj->persistent) if (!obj->persistent)
qemuDomainRemoveInactive(driver, obj); qemuDomainRemoveInactive(driver, obj);
else else
@ -3229,7 +3229,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
@ -3770,7 +3770,7 @@ cleanup:
VIR_FREE(nodemask); VIR_FREE(nodemask);
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;
} }
@ -3873,8 +3873,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;
@ -3887,8 +3887,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);
@ -3985,7 +3985,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 */
@ -4304,7 +4305,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

@ -60,10 +60,14 @@ int qemuProcessStart(virConnectPtr conn,
enum virNetDevVPortProfileOp vmop, enum virNetDevVPortProfileOp vmop,
unsigned int flags); unsigned int flags);
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,