]> xenbits.xensource.com Git - libvirt.git/commitdiff
esx: Support SMBIOS host mode
authorMatthias Bolte <matthias.bolte@googlemail.com>
Wed, 10 Nov 2010 19:05:51 +0000 (20:05 +0100)
committerMatthias Bolte <matthias.bolte@googlemail.com>
Thu, 11 Nov 2010 18:18:19 +0000 (19:18 +0100)
src/esx/esx_vmx.c
tests/vmx2xmldata/vmx2xml-smbios.vmx [new file with mode: 0644]
tests/vmx2xmldata/vmx2xml-smbios.xml [new file with mode: 0644]
tests/vmx2xmltest.c
tests/xml2vmxdata/xml2vmx-smbios.vmx [new file with mode: 0644]
tests/xml2vmxdata/xml2vmx-smbios.xml [new file with mode: 0644]
tests/xml2vmxtest.c

index b853bdf913ba26c5f03ac4cdb6989699631e51a3..5cbb835a0e52054972778c52c094f278091ccf9e 100644 (file)
@@ -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 (file)
index 0000000..16258b0
--- /dev/null
@@ -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 (file)
index 0000000..db13001
--- /dev/null
@@ -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>
index 2d59297845a465fe7d29115d3593b8e2112c9175..ba50034d2346b998c3e25952019778cb2e26713b 100644 (file)
@@ -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 (file)
index 0000000..8a54cca
--- /dev/null
@@ -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 (file)
index 0000000..b19e9c7
--- /dev/null
@@ -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>
index db7eb53e5b2bcd240cd66700b0ce70297924a387..7041877ce987b4b2c973f79a418e58cfa38f8678 100644 (file)
@@ -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;