[Libvirt-cim] [PATCH] Allow user to specify whether ACPI should be enabled

Kaitlin Rupert kaitlin at linux.vnet.ibm.com
Fri Oct 30 23:47:02 UTC 2009


# HG changeset patch
# User Kaitlin Rupert <karupert at us.ibm.com>
# Date 1256942565 25200
# Node ID fa2c916f6772d7e02ab32f1d167d83826898cacb
# Parent  a5cfc77fe35238cf4e17f4d09fcd09633f6f3149
Allow user to specify whether ACPI should be enabled.

Signed-off-by: Kaitlin Rupert <karupert at us.ibm.com>

diff -r a5cfc77fe352 -r fa2c916f6772 libxkutil/device_parsing.c
--- a/libxkutil/device_parsing.c	Fri Oct 30 05:11:06 2009 -0700
+++ b/libxkutil/device_parsing.c	Fri Oct 30 15:42:45 2009 -0700
@@ -866,6 +866,18 @@
         return 1;
 }
 
+static int parse_features(struct domain *dominfo, xmlNode *features)
+{
+        xmlNode *child;
+
+        for (child = features->children; child != NULL; child = child->next) {
+                if (XSTREQ(child->name, "acpi"))
+                        dominfo->acpi = true;
+        }
+
+        return 1;
+}
+
 static void set_action(int *val, xmlNode *child)
 {
         const char *action = (char *)xmlNodeGetContent(child);
@@ -910,6 +922,8 @@
                         set_action(&dominfo->on_crash, child);
                 else if (XSTREQ(child->name, "clock"))
                         dominfo->clock = get_attr_value(child, "offset");
+                else if (XSTREQ(child->name, "features"))
+                        parse_features(dominfo, child);
         }
 
         return 1;
diff -r a5cfc77fe352 -r fa2c916f6772 libxkutil/device_parsing.h
--- a/libxkutil/device_parsing.h	Fri Oct 30 05:11:06 2009 -0700
+++ b/libxkutil/device_parsing.h	Fri Oct 30 15:42:45 2009 -0700
@@ -126,6 +126,7 @@
         char *bootloader;
         char *bootloader_args;
         char *clock;
+        bool acpi;
 
         union {
                 struct pv_os_info pv;
diff -r a5cfc77fe352 -r fa2c916f6772 libxkutil/xmlgen.c
--- a/libxkutil/xmlgen.c	Fri Oct 30 05:11:06 2009 -0700
+++ b/libxkutil/xmlgen.c	Fri Oct 30 15:42:45 2009 -0700
@@ -503,11 +503,6 @@
         if (ret == 0)
                 return XML_ERROR;
 
-        tmp = xmlNewChild(root, NULL, BAD_CAST "features", NULL);
-        xmlNewChild(tmp, NULL, BAD_CAST "pae", NULL);
-        xmlNewChild(tmp, NULL, BAD_CAST "acpi", NULL);
-        xmlNewChild(tmp, NULL, BAD_CAST "apic", NULL);
-
         return NULL;
 }
 
@@ -576,6 +571,25 @@
                 return "Unsupported domain type";
 }
 
+static char *features_xml(xmlNodePtr root, struct domain *domain)
+{
+        xmlNodePtr features;
+
+        features = xmlNewChild(root, NULL, BAD_CAST "features", NULL);
+        if (features == NULL)
+                return "Failed to allocate XML memory";
+
+        if (domain->type == DOMAIN_XENFV) {
+                xmlNewChild(features, NULL, BAD_CAST "pae", NULL);
+                xmlNewChild(features, NULL, BAD_CAST "apic", NULL);
+        }
+
+        if (domain->acpi)
+                xmlNewChild(features, NULL, BAD_CAST "acpi", NULL);
+
+        return NULL;
+}
+
 static char *tree_to_xml(xmlNodePtr root)
 {
         xmlBufferPtr buffer = NULL;
@@ -748,6 +762,10 @@
         if (msg != NULL)
                 goto out;
 
+        msg = features_xml(root, dominfo);
+        if (msg != NULL)
+                goto out;
+
         msg = mem_xml(root, dominfo);
         if (msg != NULL)
                 goto out;
diff -r a5cfc77fe352 -r fa2c916f6772 schema/Virt_VSSD.mof
--- a/schema/Virt_VSSD.mof	Fri Oct 30 05:11:06 2009 -0700
+++ b/schema/Virt_VSSD.mof	Fri Oct 30 15:42:45 2009 -0700
@@ -15,4 +15,7 @@
   [Description("UUID assigned to this DomU.")]
   string UUID;
 
+  [Description ("Flag to determine whether this guest has acpi enabled")]
+  boolean EnableACPI;
+
 };
diff -r a5cfc77fe352 -r fa2c916f6772 src/Virt_VSSD.c
--- a/src/Virt_VSSD.c	Fri Oct 30 05:11:06 2009 -0700
+++ b/src/Virt_VSSD.c	Fri Oct 30 15:42:45 2009 -0700
@@ -211,6 +211,9 @@
         CMSetProperty(inst, "AutomaticRecoveryAction",
                       (CMPIValue *)&dominfo->on_crash, CMPI_uint16);
 
+        CMSetProperty(inst, "EnableACPI",
+                      (CMPIValue *)&dominfo->acpi, CMPI_boolean);
+
         if (dominfo->clock != NULL) {
                 uint16_t clock = VSSD_CLOCK_UTC;
 
diff -r a5cfc77fe352 -r fa2c916f6772 src/Virt_VirtualSystemManagementService.c
--- a/src/Virt_VirtualSystemManagementService.c	Fri Oct 30 05:11:06 2009 -0700
+++ b/src/Virt_VirtualSystemManagementService.c	Fri Oct 30 15:42:45 2009 -0700
@@ -425,6 +425,7 @@
         const char *val;
         const char *cn;
         char *pfx = NULL;
+        bool bool_val;
         bool fullvirt;
         CMPIObjectPath *opathp = NULL;
 
@@ -470,6 +471,13 @@
         if (cu_get_bool_prop(inst, "IsFullVirt", &fullvirt) != CMPI_RC_OK)
                 fullvirt = false;
 
+        if (cu_get_bool_prop(inst, "EnableACPI", &bool_val) != CMPI_RC_OK) {
+                if (fullvirt || STREQC(pfx, "KVM"))
+                        bool_val = true;
+        }
+
+        domain->acpi = bool_val;
+
         if (cu_get_u16_prop(inst, "ClockOffset", &tmp) == CMPI_RC_OK) {
                 if (tmp == VSSD_CLOCK_UTC)
                         domain->clock = strdup("utc");




More information about the Libvirt-cim mailing list