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

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

 



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@xxxxxxxxxx>
---
 docs/schemas/domain.rng |   16 ++++++++++++++++
 src/conf/domain_conf.c  |   32 ++++++++++++++++++++++++++++++++
 src/conf/domain_conf.h  |   11 +++++++++++
 3 files changed, 59 insertions(+), 0 deletions(-)

diff --git a/docs/schemas/domain.rng b/docs/schemas/domain.rng
index ced46f3..520bdd4 100644
--- a/docs/schemas/domain.rng
+++ b/docs/schemas/domain.rng
@@ -135,6 +135,9 @@
             </attribute>
           </element>
         </optional>
+        <optional>
+          <ref name="smbios"/>
+        </optional>
       </interleave>
     </element>
   </define>
@@ -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 651a434..c3184aa 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")
@@ -5069,6 +5075,20 @@ static virDomainDefPtr virDomainDefParseXML(virCapsPtr caps,
         if (def->sysinfo == NULL)
             goto error;
     }
+    tmp = virXPathString("string(./os/smbios/@mode)", ctxt);
+    if (tmp) {
+        int mode;
+
+        if ((mode = virDomainSmbiosModeTypeFromString(tmp)) < 0) {
+            virDomainReportError(VIR_ERR_INTERNAL_ERROR,
+                                 _("unknown smbios mode '%s'"), tmp);
+            goto error;
+        }
+        def->os.smbios_mode = mode;
+        VIR_FREE(tmp);
+    } else {
+        def->os.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
@@ -6748,6 +6768,18 @@ char *virDomainDefFormat(virDomainDefPtr def,
         }
     }
 
+    if (def->os.smbios_mode) {
+        const char *mode;
+
+        mode = virDomainSmbiosModeTypeToString(def->os.smbios_mode);
+        if (mode == NULL) {
+            virDomainReportError(VIR_ERR_INTERNAL_ERROR,
+                         _("unexpected smbios mode %d"), def->os.smbios_mode);
+            goto cleanup;
+        }
+        virBufferVSprintf(&buf, "    <smbios mode='%s'/>\n", mode);
+    }
+
     virBufferAddLit(&buf, "  </os>\n");
 
     if (def->features) {
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 91ba131..decacd8 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,
@@ -728,6 +737,7 @@ struct _virDomainOSDef {
     char *loader;
     char *bootloader;
     char *bootloaderArgs;
+    int smbios_mode;
 };
 
 enum virDomainSeclabelType {
@@ -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)
--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]