[Libvir] [PATCH 4/7] Add migration support to QEMU startup.

Jim Paris jim at jtan.com
Sun Aug 12 23:11:36 UTC 2007


Adds new fields in qemu_vm structure.  vm->migrateFrom specifies the
argument to "-incoming".  vm->stdinFd 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 at jtan.com>
---
 src/qemu_conf.c   |   12 +++++++++++-
 src/qemu_conf.h   |    2 ++
 src/qemu_driver.c |    4 ++--
 3 files changed, 15 insertions(+), 3 deletions(-)

diff --git a/src/qemu_conf.c b/src/qemu_conf.c
index 79dd180..f02d693 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;
diff --git a/src/qemu_conf.h b/src/qemu_conf.h
index 60a38b7..ba61264 100644
--- a/src/qemu_conf.h
+++ b/src/qemu_conf.h
@@ -212,6 +212,8 @@ struct qemud_vm {
 
     char configFile[PATH_MAX];
     char autostartLink[PATH_MAX];
+    char migrateFrom[PATH_MAX];
+    int stdinFd;
 
     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 553aa21..e487640 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, 
-                        0, &vm->stdout, &vm->stderr) == 0) {
+                        vm->stdinFd, &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




More information about the libvir-list mailing list