diff -rup libvirt-0.2.2/qemud/conf.c libvirt-0.2.2.new/qemud/conf.c
--- libvirt-0.2.2/qemud/conf.c 2007-04-17 04:34:42.000000000 -0400
+++ libvirt-0.2.2.new/qemud/conf.c 2007-05-14 10:36:12.000000000 -0400
@@ -245,21 +245,25 @@ static int qemudExtractVersionInfo(const
cleanup1:
_exit(-1); /* Just in case */
} else { /* Parent */
- char help[4096]; /* Ought to be enough to hold QEMU help screen */
- int got, ret = -1;
+ char help[8192]; /* Ought to be enough to hold QEMU help screen */
+ int got = 0, ret = -1;
int major, minor, micro;
if (close(newstdout[1]) < 0)
goto cleanup2;
- reread:
- if ((got = read(newstdout[0], help, sizeof(help)-1)) < 0) {
- if (errno == EINTR)
- goto reread;
- goto cleanup2;
+ while (got < (sizeof(help)-1)) {
+ int len;
+ if ((len = read(newstdout[0], help+got, sizeof(help)-got-1)) <= 0) {
+ if (!len)
+ break;
+ if (errno == EINTR)
+ continue;
+ goto cleanup2;
+ }
+ got += len;
}
help[got] = '\0';
-
if (sscanf(help, "QEMU PC emulator version %d.%d.%d", &major,&minor, µ) != 3) {
goto cleanup2;
}
@@ -267,6 +271,8 @@ static int qemudExtractVersionInfo(const
*version = (major * 1000 * 1000) + (minor * 1000) + micro;
if (strstr(help, "-no-kqemu"))
*flags |= QEMUD_CMD_FLAG_KQEMU;
+ if (strstr(help, "-no-reboot"))
+ *flags |= QEMUD_CMD_FLAG_NO_REBOOT;
if (*version >= 9000)
*flags |= QEMUD_CMD_FLAG_VNC_COLON;
ret = 0;
@@ -858,6 +864,22 @@ static struct qemud_vm_def *qemudParseXM
}
xmlXPathFreeObject(obj);
+
+ /* See if we disable reboots */
+ obj = xmlXPathEval(BAD_CAST "string(/domain/on_reboot)", ctxt);
+ if ((obj == NULL) || (obj->type != XPATH_STRING) ||
+ (obj->stringval == NULL) || (obj->stringval[0] == 0)) {
+ def->noReboot = 0;
+ } else {
+ if (!strcmp((char*)obj->stringval, "destroy"))
+ def->noReboot = 1;
+ else
+ def->noReboot = 0;
+ }
+ if (obj)
+ xmlXPathFreeObject(obj);
+
+
/* Extract OS type info */
obj = xmlXPathEval(BAD_CAST "string(/domain/os/type[1])", ctxt);
if ((obj == NULL) || (obj->type != XPATH_STRING) ||
@@ -1220,6 +1242,8 @@ int qemudBuildCommandLine(struct qemud_s
2 + /* cpus */
2 + /* boot device */
2 + /* monitor */
+ (server->qemuCmdFlags & QEMUD_CMD_FLAG_NO_REBOOT &&
+ vm->def->noReboot ? 1 : 0) + /* no-reboot */
(vm->def->features & QEMUD_FEATURE_ACPI ? 0 : 1) + /* acpi */
(vm->def->os.kernel[0] ? 2 : 0) + /* kernel */
(vm->def->os.initrd[0] ? 2 : 0) + /* initrd */
@@ -1255,6 +1279,11 @@ int qemudBuildCommandLine(struct qemud_s
goto no_memory;
if (!((*argv)[++n] = strdup("pty")))
goto no_memory;
+ if (server->qemuCmdFlags & QEMUD_CMD_FLAG_NO_REBOOT &&
+ vm->def->noReboot) {
+ if (!((*argv)[++n] = strdup("-no-reboot")))
+ goto no_memory;
+ }
if (!(vm->def->features & QEMUD_FEATURE_ACPI)) {
if (!((*argv)[++n] = strdup("-no-acpi")))
@@ -2517,6 +2546,17 @@ char *qemudGenerateXML(struct qemud_serv
goto no_memory;
}
+ if (bufferAdd(buf, " <on_poweroff>destroy</on_poweroff>\n", -1) < 0)
+ goto no_memory;
+ if (def->noReboot) {
+ if (bufferAdd(buf, " <on_reboot>destroy</on_reboot>\n", -1) < 0)
+ goto no_memory;
+ } else {
+ if (bufferAdd(buf, " <on_reboot>restart</on_reboot>\n", -1) < 0)
+ goto no_memory;
+ }
+ if (bufferAdd(buf, " <on_crash>destroy</on_crash>\n", -1) < 0)
+ goto no_memory;
if (bufferAdd(buf, " <devices>\n", -1) < 0)
goto no_memory;
diff -rup libvirt-0.2.2/qemud/internal.h libvirt-0.2.2.new/qemud/internal.h
--- libvirt-0.2.2/qemud/internal.h 2007-04-11 10:13:36.000000000 -0400
+++ libvirt-0.2.2.new/qemud/internal.h 2007-05-14 10:36:02.000000000 -0400
@@ -161,6 +161,7 @@ enum qemud_vm_grapics_type {
enum qemud_cmd_flags {
QEMUD_CMD_FLAG_KQEMU = 1,
QEMUD_CMD_FLAG_VNC_COLON = 2,
+ QEMUD_CMD_FLAG_NO_REBOOT = 4,
};
@@ -191,6 +192,8 @@ struct qemud_vm_def {
int maxmem;
int vcpus;
+ int noReboot;
+
struct qemud_vm_os_def os;
int features;