Currently, we are passing only one boolean (migrated) so there is
no real profit in this. But it creates starting position for
next patch.
---
src/qemu/qemu_driver.c | 16 ++++++++--------
src/qemu/qemu_migration.c | 20 +++++++++++++-------
src/qemu/qemu_process.c | 22 ++++++++++++----------
src/qemu/qemu_process.h | 8 ++++++--
4 files changed, 39 insertions(+), 27 deletions(-)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index d3f74d2..bda07c7 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -1870,7 +1870,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);
@@ -2731,7 +2731,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,
@@ -3136,7 +3136,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,
@@ -9781,7 +9781,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. */
@@ -10255,7 +10255,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. */
@@ -11072,8 +11072,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,
@@ -11186,7 +11186,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 a1fb962..b893fd5 100644
--- a/src/qemu/qemu_migration.c
+++ b/src/qemu/qemu_migration.c
@@ -1329,7 +1329,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 */
@@ -2647,7 +2647,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,
@@ -2944,7 +2945,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,
@@ -2977,7 +2979,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;
@@ -3023,7 +3026,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,
@@ -3054,7 +3058,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,
@@ -3118,7 +3123,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 33f57be..4cb0a83 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) {
@@ -3151,7 +3151,7 @@ error:
* really is and FAILED means "failed to start" */
state = VIR_DOMAIN_SHUTOFF_UNKNOWN;
}
- qemuProcessStop(driver, obj, 0, state);
+ qemuProcessStop(driver, obj, state, 0);
if (!obj->persistent)
qemuDomainRemoveInactive(driver, obj);
else
@@ -3229,7 +3229,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
@@ -3770,7 +3770,7 @@ cleanup:
VIR_FREE(nodemask);
virCommandFree(cmd);
VIR_FORCE_CLOSE(logfile);
- qemuProcessStop(driver, vm, 0, VIR_DOMAIN_SHUTOFF_FAILED);
+ qemuProcessStop(driver, vm, VIR_DOMAIN_SHUTOFF_FAILED, 0);
return -1;
}
@@ -3873,8 +3873,8 @@ cleanup:
void qemuProcessStop(struct qemud_driver *driver,
virDomainObjPtr vm,
- int migrated,
- virDomainShutoffReason reason)
+ virDomainShutoffReason reason,
+ unsigned int flags)
{
int ret;
int retries = 0;
@@ -3887,8 +3887,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);
@@ -3985,7 +3985,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 */
@@ -4304,7 +4305,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 2d75b005..ce59215 100644
--- a/src/qemu/qemu_process.h
+++ b/src/qemu/qemu_process.h
@@ -60,10 +60,14 @@ int qemuProcessStart(virConnectPtr conn,
enum virNetDevVPortProfileOp vmop,
unsigned int flags);
+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,
--
1.7.8.5