[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[Libvir] Re: PATCH 1/2: Qemu feature reporting



This patch lets the qemu/kvm drivers report features for i686 and
x86_64. The output is table-driven, like the rest of the capability
generation. That should make it easy to report additional features for
other arches (which I know zip about)

David

Index: libvirt/src/qemu_driver.c
===================================================================
--- libvirt.orig/src/qemu_driver.c	2007-07-24 09:42:33.000000000 -0700
+++ libvirt/src/qemu_driver.c	2007-07-24 09:43:25.000000000 -0700
@@ -1504,6 +1504,43 @@
     return 0;
 }
 
+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 (strcmp(flags[i].name, "pae") == 0) {
+            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;
@@ -1583,7 +1620,14 @@
         }
         r = virBufferAdd (xml,
                        "\
-    </arch>\n\
+    </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;
 
@@ -1611,7 +1655,14 @@
         }
         r = virBufferAdd (xml,
                        "\
-    </arch>\n\
+    </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-24 09:42:33.000000000 -0700
+++ libvirt/src/qemu_conf.c	2007-07-24 09:43:25.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-24 09:42:33.000000000 -0700
+++ libvirt/src/qemu_conf.h	2007-07-24 09:43:25.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[];
 

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]