[PATCH] esx: Support SMBIOS host mode

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

 



---
 src/esx/esx_vmx.c                    |   27 ++++++++++++++++++++++++++-
 tests/vmx2xmldata/vmx2xml-smbios.vmx |    3 +++
 tests/vmx2xmldata/vmx2xml-smbios.xml |   16 ++++++++++++++++
 tests/vmx2xmltest.c                  |    2 ++
 tests/xml2vmxdata/xml2vmx-smbios.vmx |   11 +++++++++++
 tests/xml2vmxdata/xml2vmx-smbios.xml |    9 +++++++++
 tests/xml2vmxtest.c                  |    2 ++
 7 files changed, 69 insertions(+), 1 deletions(-)
 create mode 100644 tests/vmx2xmldata/vmx2xml-smbios.vmx
 create mode 100644 tests/vmx2xmldata/vmx2xml-smbios.xml
 create mode 100644 tests/xml2vmxdata/xml2vmx-smbios.vmx
 create mode 100644 tests/xml2vmxdata/xml2vmx-smbios.xml

diff --git a/src/esx/esx_vmx.c b/src/esx/esx_vmx.c
index b853bdf..5cbb835 100644
--- a/src/esx/esx_vmx.c
+++ b/src/esx/esx_vmx.c
@@ -74,6 +74,7 @@ def->os
 ->loader
 ->bootloader
 ->bootloaderArgs
+->smbios_mode                     <=>   smbios.reflecthost = "<value>"          # <value> == true means SMBIOS_HOST, otherwise it's SMBIOS_EMULATE, defaults to "false"
 
 
 
@@ -880,6 +881,7 @@ esxVMX_ParseConfig(esxVMX_Context *ctx, virCapsPtr caps, const char *vmx,
     long long numvcpus = 0;
     char *sched_cpu_affinity = NULL;
     char *guestOS = NULL;
+    bool smbios_reflecthost = false;
     int controller;
     int bus;
     int port;
@@ -1195,6 +1197,16 @@ esxVMX_ParseConfig(esxVMX_Context *ctx, virCapsPtr caps, const char *vmx,
         goto cleanup;
     }
 
+    /* vmx:smbios.reflecthost -> def:os.smbios_mode */
+    if (esxUtil_GetConfigBoolean(conf, "smbios.reflecthost",
+                                 &smbios_reflecthost, false, true) < 0) {
+        goto cleanup;
+    }
+
+    if (smbios_reflecthost) {
+        def->os.smbios_mode = VIR_DOMAIN_SMBIOS_HOST;
+    }
+
     /* def:features */
     /* FIXME */
 
@@ -2552,7 +2564,7 @@ esxVMX_FormatConfig(esxVMX_Context *ctx, virCapsPtr caps, virDomainDefPtr def,
         goto cleanup;
     }
 
-    /* def:arch -> vmx:guestOS */
+    /* def:os.arch -> vmx:guestOS */
     if (def->os.arch == NULL || STRCASEEQ(def->os.arch, "i686")) {
         virBufferAddLit(&buffer, "guestOS = \"other\"\n");
     } else if (STRCASEEQ(def->os.arch, "x86_64")) {
@@ -2564,6 +2576,19 @@ esxVMX_FormatConfig(esxVMX_Context *ctx, virCapsPtr caps, virDomainDefPtr def,
         goto cleanup;
     }
 
+    /* def:os.smbios_mode -> vmx:smbios.reflecthost */
+    if (def->os.smbios_mode == VIR_DOMAIN_SMBIOS_NONE ||
+        def->os.smbios_mode == VIR_DOMAIN_SMBIOS_EMULATE) {
+        /* nothing */
+    } else if (def->os.smbios_mode == VIR_DOMAIN_SMBIOS_HOST) {
+        virBufferAddLit(&buffer, "smbios.reflecthost = \"true\"\n");
+    } else {
+        ESX_ERROR(VIR_ERR_CONFIG_UNSUPPORTED,
+                  _("Unsupported SMBIOS mode '%s'"),
+                  virDomainSmbiosModeTypeToString(def->os.smbios_mode));
+        goto cleanup;
+    }
+
     /* def:uuid -> vmx:uuid.action, vmx:uuid.bios */
     if (memcmp(def->uuid, zero, VIR_UUID_BUFLEN) == 0) {
         virBufferAddLit(&buffer, "uuid.action = \"create\"\n");
diff --git a/tests/vmx2xmldata/vmx2xml-smbios.vmx b/tests/vmx2xmldata/vmx2xml-smbios.vmx
new file mode 100644
index 0000000..16258b0
--- /dev/null
+++ b/tests/vmx2xmldata/vmx2xml-smbios.vmx
@@ -0,0 +1,3 @@
+config.version = "8"
+virtualHW.version = "4"
+smbios.reflecthost = "true"
diff --git a/tests/vmx2xmldata/vmx2xml-smbios.xml b/tests/vmx2xmldata/vmx2xml-smbios.xml
new file mode 100644
index 0000000..db13001
--- /dev/null
+++ b/tests/vmx2xmldata/vmx2xml-smbios.xml
@@ -0,0 +1,16 @@
+<domain type='vmware'>
+  <uuid>00000000-0000-0000-0000-000000000000</uuid>
+  <memory>32768</memory>
+  <currentMemory>32768</currentMemory>
+  <vcpu>1</vcpu>
+  <os>
+    <type arch='i686'>hvm</type>
+    <smbios mode='host'/>
+  </os>
+  <clock offset='utc'/>
+  <on_poweroff>destroy</on_poweroff>
+  <on_reboot>restart</on_reboot>
+  <on_crash>destroy</on_crash>
+  <devices>
+  </devices>
+</domain>
diff --git a/tests/vmx2xmltest.c b/tests/vmx2xmltest.c
index 2d59297..ba50034 100644
--- a/tests/vmx2xmltest.c
+++ b/tests/vmx2xmltest.c
@@ -285,6 +285,8 @@ mymain(int argc, char **argv)
 
     DO_TEST("annotation", "annotation", esxVI_ProductVersion_ESX35);
 
+    DO_TEST("smbios", "smbios", esxVI_ProductVersion_ESX35);
+
     virCapabilitiesFree(caps);
 
     return result == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
diff --git a/tests/xml2vmxdata/xml2vmx-smbios.vmx b/tests/xml2vmxdata/xml2vmx-smbios.vmx
new file mode 100644
index 0000000..8a54cca
--- /dev/null
+++ b/tests/xml2vmxdata/xml2vmx-smbios.vmx
@@ -0,0 +1,11 @@
+.encoding = "UTF-8"
+config.version = "8"
+virtualHW.version = "4"
+guestOS = "other"
+smbios.reflecthost = "true"
+uuid.bios = "56 4d 9b ef ac d9 b4 e0-c8 f0 ae a8 b9 10 35 15"
+displayName = "smbios"
+memsize = "4"
+numvcpus = "1"
+floppy0.present = "false"
+floppy1.present = "false"
diff --git a/tests/xml2vmxdata/xml2vmx-smbios.xml b/tests/xml2vmxdata/xml2vmx-smbios.xml
new file mode 100644
index 0000000..b19e9c7
--- /dev/null
+++ b/tests/xml2vmxdata/xml2vmx-smbios.xml
@@ -0,0 +1,9 @@
+<domain type='vmware'>
+  <name>smbios</name>
+  <uuid>564d9bef-acd9-b4e0-c8f0-aea8b9103515</uuid>
+  <memory>4096</memory>
+  <os>
+    <type>hvm</type>
+    <smbios mode='host'/>
+  </os>
+</domain>
diff --git a/tests/xml2vmxtest.c b/tests/xml2vmxtest.c
index db7eb53..7041877 100644
--- a/tests/xml2vmxtest.c
+++ b/tests/xml2vmxtest.c
@@ -278,6 +278,8 @@ mymain(int argc, char **argv)
 
     DO_TEST("annotation", "annotation", esxVI_ProductVersion_ESX35);
 
+    DO_TEST("smbios", "smbios", esxVI_ProductVersion_ESX35);
+
     virCapabilitiesFree(caps);
 
     return result == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
-- 
1.7.0.4

--
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]