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

[libvirt] [PATCH 3/7] Add smbios element to schema and configuration



the element has a mode attribute allowing only 3 values:
  - emulate: use the smbios emulation from the hypervisor
  - host: try to use the smbios values from the node
  - sysinfo: grab the values from the <sysinfo> fields

* docs/schemas/domain.rng: extend the schemas
* src/conf/domain_conf.h: add the flag to the domain config
* src/conf/domain_conf.h: parse and serialize the smbios if present

Signed-off-by: Daniel Veillard <veillard redhat com>
---
 docs/schemas/domain.rng |   16 ++++++++++++++++
 src/conf/domain_conf.c  |   17 +++++++++++++++++
 src/conf/domain_conf.h  |   11 +++++++++++
 3 files changed, 44 insertions(+), 0 deletions(-)

diff --git a/docs/schemas/domain.rng b/docs/schemas/domain.rng
index ced46f3..aee425f 100644
--- a/docs/schemas/domain.rng
+++ b/docs/schemas/domain.rng
@@ -33,6 +33,9 @@
         <optional>
           <ref name="sysinfo"/>
         </optional>
+        <optional>
+          <ref name="smbios"/>
+        </optional>
         <ref name="os"/>
         <ref name="clock"/>
         <ref name="resources"/>
@@ -1819,6 +1822,19 @@
     </data>
   </define>
 
+  <define name="smbios">
+    <element name="smbios">
+      <attribute name="mode">
+        <choice>
+          <value>emulate</value>
+          <value>host</value>
+          <value>sysinfo</value>
+        </choice>
+      </attribute>
+      <empty/>
+    </element>
+  </define>
+
   <define name="address">
     <element name="address">
       <choice>
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 2fc761b..259ee80 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -230,6 +230,12 @@ VIR_ENUM_IMPL(virDomainMemballoonModel, VIR_DOMAIN_MEMBALLOON_MODEL_LAST,
 VIR_ENUM_IMPL(virDomainSysinfo, VIR_DOMAIN_SYSINFO_LAST,
               "smbios")
 
+VIR_ENUM_IMPL(virDomainSmbiosMode, VIR_DOMAIN_SMBIOS_LAST,
+              "none",
+              "emulate",
+              "host",
+              "sysinfo")
+
 VIR_ENUM_IMPL(virDomainWatchdogModel, VIR_DOMAIN_WATCHDOG_MODEL_LAST,
               "i6300esb",
               "ib700")
@@ -5068,6 +5074,17 @@ static virDomainDefPtr virDomainDefParseXML(virCapsPtr caps,
         if (def->sysinfo == NULL)
             goto error;
     }
+    tmp = virXPathString("string(./smbios/@mode)", ctxt);
+    if (tmp) {
+        if ((def->smbios_mode = virDomainSmbiosModeTypeFromString(tmp)) < 0) {
+            virDomainReportError(VIR_ERR_INTERNAL_ERROR,
+                                 _("unknown smbios mode '%s'"), tmp);
+            goto error;
+        }
+        VIR_FREE(tmp);
+    } else {
+        def->smbios_mode = VIR_DOMAIN_SMBIOS_NONE; /* not present */
+    }
 
     /* we have to make a copy of all of the callback pointers here since
      * we won't have the virCaps structure available during free
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 91ba131..ca416be 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -630,6 +630,15 @@ struct _virSysinfoDef {
     char *system_sku;
 };
 
+enum virDomainSmbiosMode {
+    VIR_DOMAIN_SMBIOS_NONE,
+    VIR_DOMAIN_SMBIOS_EMULATE,
+    VIR_DOMAIN_SMBIOS_HOST,
+    VIR_DOMAIN_SMBIOS_SYSINFO,
+
+    VIR_DOMAIN_SMBIOS_LAST
+};
+
 /* Flags for the 'type' field in next struct */
 enum virDomainDeviceType {
     VIR_DOMAIN_DEVICE_DISK,
@@ -968,6 +977,7 @@ struct _virDomainDef {
     virDomainMemballoonDefPtr memballoon;
     virCPUDefPtr cpu;
     virSysinfoDefPtr sysinfo;
+    int smbios_mode;
 
     void *namespaceData;
     virDomainXMLNamespace ns;
@@ -1221,6 +1231,7 @@ VIR_ENUM_DECL(virDomainChrTcpProtocol)
 VIR_ENUM_DECL(virDomainSoundModel)
 VIR_ENUM_DECL(virDomainMemballoonModel)
 VIR_ENUM_DECL(virDomainSysinfo)
+VIR_ENUM_DECL(virDomainSmbiosMode)
 VIR_ENUM_DECL(virDomainWatchdogModel)
 VIR_ENUM_DECL(virDomainWatchdogAction)
 VIR_ENUM_DECL(virDomainVideo)

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