Adds new fields in qemu_vm structure. vm->migrateFrom specifies the
argument to "-incoming". vm->stdin specifies the file descriptor to
pass to virExec as stdin, which will be used for the "-incoming stdio"
case.
Signed-off-by: Jim Paris <jim(a)jtan.com>
---
src/qemu_conf.c | 13 ++++++++++++-
src/qemu_conf.h | 2 ++
src/qemu_driver.c | 4 ++--
3 files changed, 16 insertions(+), 3 deletions(-)
diff --git a/src/qemu_conf.c b/src/qemu_conf.c
index 79dd180..2bbd072 100644
--- a/src/qemu_conf.c
+++ b/src/qemu_conf.c
@@ -1518,7 +1518,8 @@ int qemudBuildCommandLine(virConnectPtr conn,
(vm->def->os.initrd[0] ? 2 : 0) + /* initrd */
(vm->def->os.cmdline[0] ? 2 : 0) + /* cmdline */
(vm->def->graphicsType == QEMUD_GRAPHICS_VNC ? 2 :
- (vm->def->graphicsType == QEMUD_GRAPHICS_SDL ? 0 : 1)); /* graphics */
+ (vm->def->graphicsType == QEMUD_GRAPHICS_SDL ? 0 : 1)) + /* graphics */
+ (vm->migrateFrom[0] ? 3 : 0); /* migrateFrom */
snprintf(memory, sizeof(memory), "%d", vm->def->memory/1024);
snprintf(vcpus, sizeof(vcpus), "%d", vm->def->vcpus);
@@ -1767,6 +1768,15 @@ int qemudBuildCommandLine(virConnectPtr conn,
/* SDL is the default. no args needed */
}
+ if (vm->migrateFrom[0]) {
+ if (!((*argv)[++n] = strdup("-S")))
+ goto no_memory;
+ if (!((*argv)[++n] = strdup("-incoming")))
+ goto no_memory;
+ if (!((*argv)[++n] = strdup(vm->migrateFrom)))
+ goto no_memory;
+ }
+
(*argv)[++n] = NULL;
return 0;
@@ -1884,6 +1894,7 @@ qemudAssignVMDef(virConnectPtr conn,
return NULL;
}
+ vm->stdin = -1;
vm->stdout = -1;
vm->stderr = -1;
vm->monitor = -1;
diff --git a/src/qemu_conf.h b/src/qemu_conf.h
index 60a38b7..4a9b1ae 100644
--- a/src/qemu_conf.h
+++ b/src/qemu_conf.h
@@ -199,6 +199,7 @@ struct qemud_vm_def {
/* Guest VM runtime state */
struct qemud_vm {
+ int stdin;
int stdout;
int stderr;
int monitor;
@@ -212,6 +213,7 @@ struct qemud_vm {
char configFile[PATH_MAX];
char autostartLink[PATH_MAX];
+ char migrateFrom[PATH_MAX];
struct qemud_vm_def *def; /* The current definition */
struct qemud_vm_def *newDef; /* New definition to activate at shutdown */
diff --git a/src/qemu_driver.c b/src/qemu_driver.c
index 15b94b8..e649060 100644
--- a/src/qemu_driver.c
+++ b/src/qemu_driver.c
@@ -656,9 +656,9 @@ static int qemudStartVMDaemon(virConnectPtr conn,
errno, strerror(errno));
if (virExecNonBlock(conn, argv, &vm->pid,
- -1, &vm->stdout, &vm->stderr) == 0) {
+ vm->stdin, &vm->stdout, &vm->stderr) == 0) {
vm->id = driver->nextvmid++;
- vm->state = VIR_DOMAIN_RUNNING;
+ vm->state = vm->migrateFrom[0] ? VIR_DOMAIN_PAUSED : VIR_DOMAIN_RUNNING;
driver->ninactivevms--;
driver->nactivevms++;
--
1.5.3.rc4