Patch updated with feedback (mostly formatting) David
Index: libvirt/src/qemu_driver.c =================================================================== --- libvirt.orig/src/qemu_driver.c 2007-07-27 10:07:17.000000000 -0700 +++ libvirt/src/qemu_driver.c 2007-07-27 10:13:03.000000000 -0700 @@ -1416,6 +1416,40 @@ return virNodeInfoPopulate(conn, nodeinfo); } +static int qemudGetFeatures(virBufferPtr xml, + const struct qemu_feature_flags *flags) { + int i, r; + + if (flags == NULL) + return 0; + + r = virBufferAdd(xml, "\ + <features>\n", -1); + if (r == -1) return r; + for (i = 0; flags[i].name; ++i) { + if (STREQ(flags[i].name, "pae")) { + int pae = flags[i].default_on || flags[i].toggle; + int nonpae = flags[i].toggle; + if (pae) { + r = virBufferAdd(xml, " <pae/>\n", -1); + if (r == -1) return r; + } + if (nonpae) { + r = virBufferAdd(xml, " <nonpae/>\n", -1); + if (r == -1) return r; + } + } else { + r = virBufferVSprintf(xml, " <%s default='%s' toggle='%s'/>\n", + flags[i].name, + flags[i].default_on ? "on" : "off", + flags[i].toggle ? "yes" : "no"); + if (r == -1) return r; + } + } + r = virBufferAdd(xml, " </features>\n", -1); + return r; +} + static char *qemudGetCapabilities(virConnectPtr conn ATTRIBUTE_UNUSED) { struct utsname utsname; int i, j, r; @@ -1493,10 +1527,13 @@ </domain>\n", -1); if (r == -1) goto vir_buffer_failed; } - r = virBufferAdd (xml, - "\ - </arch>\n\ - </guest>\n", -1); + r = virBufferAdd (xml, " </arch>\n", -1); + if (r == -1) goto vir_buffer_failed; + + r = qemudGetFeatures(xml, qemudArchs[i].fflags); + if (r == -1) goto vir_buffer_failed; + + r = virBufferAdd (xml, " </guest>\n", -1); if (r == -1) goto vir_buffer_failed; /* The "other" PC architecture needs emulation. */ @@ -1521,10 +1558,7 @@ qemudArchs[i].machines[j]); if (r == -1) goto vir_buffer_failed; } - r = virBufferAdd (xml, - "\ - </arch>\n\ - </guest>\n", -1); + r = virBufferAdd (xml, " </arch>\n </guest>\n", -1); if (r == -1) goto vir_buffer_failed; } @@ -1550,10 +1584,13 @@ qemudArchs[i].machines[j]); if (r == -1) goto vir_buffer_failed; } - r = virBufferAdd (xml, - "\ - </arch>\n\ - </guest>\n", -1); + r = virBufferAdd (xml, " </arch>\n", -1); + if (r == -1) goto vir_buffer_failed; + + r = qemudGetFeatures(xml, qemudArchs[i].fflags); + if (r == -1) goto vir_buffer_failed; + + r = virBufferAdd (xml, " </guest>\n", -1); if (r == -1) goto vir_buffer_failed; } Index: libvirt/src/qemu_conf.c =================================================================== --- libvirt.orig/src/qemu_conf.c 2007-07-27 10:06:55.000000000 -0700 +++ libvirt/src/qemu_conf.c 2007-07-27 10:08:23.000000000 -0700 @@ -221,17 +221,31 @@ "g3bw", "mac99", "prep", NULL }; +/* Feature flags for the architecture info */ +struct qemu_feature_flags arch_info_i686_flags [] = { + { "pae", 1, 1 }, + { "acpi", 1, 1 }, + { "apic", 1, 0 }, + { NULL, -1, -1 } +}; + +struct qemu_feature_flags arch_info_x86_64_flags [] = { + { "acpi", 1, 1 }, + { "apic", 1, 0 }, + { NULL, -1, -1 } +}; + /* The archicture tables for supported QEMU archs */ struct qemu_arch_info qemudArchs[] = { /* i686 must be in position 0 */ - { "i686", 32, arch_info_x86_machines, "qemu" }, + { "i686", 32, arch_info_x86_machines, "qemu", arch_info_i686_flags }, /* x86_64 must be in position 1 */ - { "x86_64", 64, arch_info_x86_machines, "qemu-system-x86_64" }, - { "mips", 32, arch_info_mips_machines, "qemu-system-mips" }, - { "mipsel", 32, arch_info_mips_machines, "qemu-system-mipsel" }, - { "sparc", 32, arch_info_sparc_machines, "qemu-system-sparc" }, - { "ppc", 32, arch_info_ppc_machines, "qemu-system-ppc" }, - { NULL, -1, NULL, NULL } + { "x86_64", 64, arch_info_x86_machines, "qemu-system-x86_64", arch_info_x86_64_flags }, + { "mips", 32, arch_info_mips_machines, "qemu-system-mips", NULL }, + { "mipsel", 32, arch_info_mips_machines, "qemu-system-mipsel", NULL }, + { "sparc", 32, arch_info_sparc_machines, "qemu-system-sparc", NULL }, + { "ppc", 32, arch_info_ppc_machines, "qemu-system-ppc", NULL }, + { NULL, -1, NULL, NULL, NULL } }; /* Return the default architecture if none is explicitly requested*/ Index: libvirt/src/qemu_conf.h =================================================================== --- libvirt.orig/src/qemu_conf.h 2007-07-27 10:06:55.000000000 -0700 +++ libvirt/src/qemu_conf.h 2007-07-27 10:08:23.000000000 -0700 @@ -384,11 +384,18 @@ struct qemud_network *network, struct qemud_network_def *def); +struct qemu_feature_flags { + const char *name; + const int default_on; + const int toggle; +}; + struct qemu_arch_info { const char *arch; int wordsize; const char **machines; const char *binary; + const struct qemu_feature_flags *fflags; }; extern struct qemu_arch_info qemudArchs[];
-- Libvir-list mailing list Libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list