Skip to contentSkip to conversation

HVM SMBIOS support 1/6

RFC PATCH In review Andrew D. Ball 2 participants 7 messages Jul 7, 2006 – Jul 11, 2006 Arm/actions semi architecture

lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/1 HVM SMBIOS support 1/6

[HVM] [XEND] Add option for enabling SMBIOS for HVM domU's. Also pass the xenstore UUID of HVM domU's all the way down to xc_hvm_build(). The UUID is needed to fill out SMBIOS tables.

tools/python/xen/lowlevel/xc/xc.c +27 -5
diff -r f91cc71173c5 tools/python/xen/lowlevel/xc/xc.c
@@ -371,18 +371,38 @@
     int pae  = 0;
     int acpi = 0;
     int apic = 0;
+    int smbios = 0;
+    PyObject *uuid_obj = NULL;
+    uint8_t uuid[16];
     unsigned long store_mfn = 0;
+    int i;
+    PyObject *tmp = NULL;
 
     static char *kwd_list[] = { "dom", "store_evtchn",
-				"memsize", "image", "vcpus", "pae", "acpi", "apic",
+				"memsize", "image", "vcpus", "pae", "acpi",
+                                "apic", "smbios", "uuid",
 				NULL };
-    if ( !PyArg_ParseTupleAndKeywords(args, kwds, "iiisiiii", kwd_list,
+
+    if ( !PyArg_ParseTupleAndKeywords(args, kwds, "iiisiiiiiO", kwd_list,
                                       &dom, &store_evtchn, &memsize,
-                                      &image, &vcpus, &pae, &acpi, &apic) )
-        return NULL;
+                                      &image, &vcpus, &pae, &acpi, &apic,
+                                      &smbios, &uuid_obj) )
+
+        return NULL;
+
+    /* convert the UUID array from Python to C if possible */
+    if (!PySequence_Check(uuid_obj) || PySequence_Length(uuid_obj) != 16)
+        return NULL;
+    for (i = 0; i < 16; i++) {
+        tmp = PySequence_GetItem(uuid_obj, i);
+        if (!PyInt_Check(tmp))
+            return NULL;
+        uuid[i] = (uint8_t) PyInt_AsLong(tmp);
+    }
 
     if ( xc_hvm_build(self->xc_handle, dom, memsize, image,
-		      vcpus, pae, acpi, apic, store_evtchn, &store_mfn) != 0 )
+		      vcpus, pae, acpi, apic, smbios, uuid, store_evtchn,
+                      &store_mfn) != 0 )
         return PyErr_SetFromErrno(xc_error);
 
     return Py_BuildValue("{s:i}", "store_mfn", store_mfn);
@@ -1043,6 +1063,8 @@
       " dom     [int]:      Identifier of domain to build into.\n"
       " image   [str]:      Name of HVM loader image file.\n"
       " vcpus   [int, 1]:   Number of Virtual CPUS in domain.\n\n"
+      " smbios  [int, 1]:   Enable SMBIOS if nonzero.\n\n"
+      " uuid    [int[16]]:  UUID of the domain.\n\n"
       "Returns: [int] 0 on success; -1 on error.\n" },
 
     { "bvtsched_global_set",
tools/python/xen/xend/image.py +17 -1
diff -r f91cc71173c5 tools/python/xen/xend/image.py
@@ -221,9 +221,21 @@
 
         self.acpi = int(sxp.child_value(imageConfig, 'acpi', 0))
         self.apic = int(sxp.child_value(imageConfig, 'apic', 0))
+        self.smbios = int(sxp.child_value(imageConfig, 'smbios', 0))
 
     def buildDomain(self):
         store_evtchn = self.vm.getStorePort()
+
+        # convert the DCE formatted UUID string to an array
+        # of 16 integers
+        uuid_str = self.vm.info['uuid']
+        uuid_str = uuid_str.replace('-','')
+
+        uuid_arr = []
+
+        byte_num = 0
+        for i in range(0,32,2):
+            uuid_arr.append(int(uuid_str[i:i+2], 16))
 
         log.debug("dom            = %d", self.vm.getDomid())
         log.debug("image          = %s", self.kernel)
@@ -233,6 +245,8 @@
         log.debug("pae            = %d", self.pae)
         log.debug("acpi           = %d", self.acpi)
         log.debug("apic           = %d", self.apic)
+        log.debug("smbios         = %d", self.smbios)
+        log.debug("uuid           = %s", uuid_arr)
 
         self.register_shutdown_watch()
 
@@ -243,7 +257,9 @@
                             vcpus          = self.vm.getVCpuCount(),
                             pae            = self.pae,
                             acpi           = self.acpi,
-                            apic           = self.apic)
+                            apic           = self.apic,
+                            smbios         = self.smbios,
+                            uuid           = uuid_arr)
 
     # Return a list of cmd line args to the device models based on the
     # xm config file
tools/python/xen/xm/create.py +7 -1
diff -r f91cc71173c5 tools/python/xen/xm/create.py
@@ -173,6 +173,9 @@
 gopts.var('apic', val='APIC',
           fn=set_int, default=0,
           use="Disable or enable APIC of HVM domain.")
+gopts.var('smbios', val='SMBIOS',
+          fn=set_int, default=1,
+          use="Disable or enable SMBIOS tables of an HVM domain.")
 
 gopts.var('vcpus', val='VCPUS',
           fn=set_int, default=1,
@@ -431,6 +434,9 @@
           addresses for virtual network interfaces.  This must be a unique 
           value across the entire cluster.""")
 
+gopts.var('smbios', val='SMBIOS',
+          fn=set_int, default=0,
+          use="Disable or enable SMBIOS for an HVM domain.")
 
 def err(msg):
     """Print an error to stderr and exit.
@@ -622,7 +628,7 @@
     args = [ 'device_model', 'pae', 'vcpus', 'cdrom', 'boot', 'fda', 'fdb',
              'localtime', 'serial', 'stdvga', 'isa', 'nographic', 'audio',
              'vnc', 'vncviewer', 'sdl', 'display', 'ne2000', 'acpi', 'apic',
-             'xauthority', 'usb', 'usbdevice' ]
+             'xauthority', 'smbios', 'uuid' ]
     for a in args:
         if (vals.__dict__[a]):
             config_image.append([a, vals.__dict__[a]])

[HVM] [XEND] Add option for enabling SMBIOS for HVM domU's. Also pass the xenstore UUID of HVM domU's all the way down to xc_hvm_build(). The UUID is needed to fill out SMBIOS tables.

tools/python/xen/lowlevel/xc/xc.c +27 -5
diff -r f91cc71173c5 tools/python/xen/lowlevel/xc/xc.c
@@ -371,18 +371,38 @@
     int pae  = 0;
     int acpi = 0;
     int apic = 0;
+    int smbios = 0;
+    PyObject *uuid_obj = NULL;
+    uint8_t uuid[16];
     unsigned long store_mfn = 0;
+    int i;
+    PyObject *tmp = NULL;
 
     static char *kwd_list[] = { "dom", "store_evtchn",
-				"memsize", "image", "vcpus", "pae", "acpi", "apic",
+				"memsize", "image", "vcpus", "pae", "acpi",
+                                "apic", "smbios", "uuid",
 				NULL };
-    if ( !PyArg_ParseTupleAndKeywords(args, kwds, "iiisiiii", kwd_list,
+
+    if ( !PyArg_ParseTupleAndKeywords(args, kwds, "iiisiiiiiO", kwd_list,
                                       &dom, &store_evtchn, &memsize,
-                                      &image, &vcpus, &pae, &acpi, &apic) )
-        return NULL;
+                                      &image, &vcpus, &pae, &acpi, &apic,
+                                      &smbios, &uuid_obj) )
+
+        return NULL;
+
+    /* convert the UUID array from Python to C if possible */
+    if (!PySequence_Check(uuid_obj) || PySequence_Length(uuid_obj) != 16)
+        return NULL;
+    for (i = 0; i < 16; i++) {
+        tmp = PySequence_GetItem(uuid_obj, i);
+        if (!PyInt_Check(tmp))
+            return NULL;
+        uuid[i] = (uint8_t) PyInt_AsLong(tmp);
+    }
 
     if ( xc_hvm_build(self->xc_handle, dom, memsize, image,
-		      vcpus, pae, acpi, apic, store_evtchn, &store_mfn) != 0 )
+		      vcpus, pae, acpi, apic, smbios, uuid, store_evtchn,
+                      &store_mfn) != 0 )
         return PyErr_SetFromErrno(xc_error);
 
     return Py_BuildValue("{s:i}", "store_mfn", store_mfn);
@@ -1043,6 +1063,8 @@
       " dom     [int]:      Identifier of domain to build into.\n"
       " image   [str]:      Name of HVM loader image file.\n"
       " vcpus   [int, 1]:   Number of Virtual CPUS in domain.\n\n"
+      " smbios  [int, 1]:   Enable SMBIOS if nonzero.\n\n"
+      " uuid    [int[16]]:  UUID of the domain.\n\n"
       "Returns: [int] 0 on success; -1 on error.\n" },
 
     { "bvtsched_global_set",
tools/python/xen/xend/image.py +17 -1
diff -r f91cc71173c5 tools/python/xen/xend/image.py
@@ -221,9 +221,21 @@
 
         self.acpi = int(sxp.child_value(imageConfig, 'acpi', 0))
         self.apic = int(sxp.child_value(imageConfig, 'apic', 0))
+        self.smbios = int(sxp.child_value(imageConfig, 'smbios', 0))
 
     def buildDomain(self):
         store_evtchn = self.vm.getStorePort()
+
+        # convert the DCE formatted UUID string to an array
+        # of 16 integers
+        uuid_str = self.vm.info['uuid']
+        uuid_str = uuid_str.replace('-','')
+
+        uuid_arr = []
+
+        byte_num = 0
+        for i in range(0,32,2):
+            uuid_arr.append(int(uuid_str[i:i+2], 16))
 
         log.debug("dom            = %d", self.vm.getDomid())
         log.debug("image          = %s", self.kernel)
@@ -233,6 +245,8 @@
         log.debug("pae            = %d", self.pae)
         log.debug("acpi           = %d", self.acpi)
         log.debug("apic           = %d", self.apic)
+        log.debug("smbios         = %d", self.smbios)
+        log.debug("uuid           = %s", uuid_arr)
 
         self.register_shutdown_watch()
 
@@ -243,7 +257,9 @@
                             vcpus          = self.vm.getVCpuCount(),
                             pae            = self.pae,
                             acpi           = self.acpi,
-                            apic           = self.apic)
+                            apic           = self.apic,
+                            smbios         = self.smbios,
+                            uuid           = uuid_arr)
 
     # Return a list of cmd line args to the device models based on the
     # xm config file
tools/python/xen/xm/create.py +7 -1
diff -r f91cc71173c5 tools/python/xen/xm/create.py
@@ -173,6 +173,9 @@
 gopts.var('apic', val='APIC',
           fn=set_int, default=0,
           use="Disable or enable APIC of HVM domain.")
+gopts.var('smbios', val='SMBIOS',
+          fn=set_int, default=1,
+          use="Disable or enable SMBIOS tables of an HVM domain.")
 
 gopts.var('vcpus', val='VCPUS',
           fn=set_int, default=1,
@@ -431,6 +434,9 @@
           addresses for virtual network interfaces.  This must be a unique 
           value across the entire cluster.""")
 
+gopts.var('smbios', val='SMBIOS',
+          fn=set_int, default=0,
+          use="Disable or enable SMBIOS for an HVM domain.")
 
 def err(msg):
     """Print an error to stderr and exit.
@@ -622,7 +628,7 @@
     args = [ 'device_model', 'pae', 'vcpus', 'cdrom', 'boot', 'fda', 'fdb',
              'localtime', 'serial', 'stdvga', 'isa', 'nographic', 'audio',
              'vnc', 'vncviewer', 'sdl', 'display', 'ne2000', 'acpi', 'apic',
-             'xauthority', 'usb', 'usbdevice' ]
+             'xauthority', 'smbios', 'uuid' ]
     for a in args:
         if (vals.__dict__[a]):
             config_image.append([a, vals.__dict__[a]])

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#1 lore raw
Quoted 5 lines · Andrew D. Ball

[HVM] [XEND] Add option for enabling SMBIOS for HVM domU's. Also pass the xenstore UUID of HVM domU's all the way down to xc_hvm_build(). The UUID is needed to fill out SMBIOS tables.

Does it need to be optional? I don't think most BIOSes let you disable the SMBIOS tables?

-- Keir

#2 lore raw
Quoted 8 lines · Keir Fraser
Quoted 6 lines · Andrew D. Ball

[HVM] [XEND] Add option for enabling SMBIOS for HVM domU's. Also pass the
xenstore UUID of HVM domU's all the way down to xc_hvm_build(). The UUID
is needed to fill out SMBIOS tables.

Quoted 5 lines
Quoted 1 line

Does it need to be optional? I don't think most BIOSes let you disable the SMBIOS tables?

Good point. It's fine with me to always generate the SMBIOS tables.

Andrew

Quoted 7 lines

-- Keir

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#3 lore raw
In reply to Keir Fraser

Do you see any other things to work on for the SMBIOS patches? Making SMBIOS not optional cuts down on a bit of the code, so I'm working on that and getting the code to run on the latest changeset today.

Thanks for your help!
Andrew

Quoted 21 lines · Keir Fraser
Quoted 7 lines · Andrew D. Ball

[HVM] [XEND] Add option for enabling SMBIOS for HVM domU's. Also pass the
xenstore UUID of HVM domU's all the way down to xc_hvm_build(). The UUID
is needed to fill out SMBIOS tables.

Does it need to be optional? I don't think most BIOSes let you disable the SMBIOS tables?

-- Keir

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#4 lore raw
Quoted 3 lines · Andrew D. Ball

Do you see any other things to work on for the SMBIOS patches? Making SMBIOS not optional cuts down on a bit of the code, so I'm working on that and getting the code to run on the latest changeset today.

I think they're basically okay. I find it a bit weird that hvmloader puts SMBIOS tables in a fixed place and then rombios copies them -- not sure why that's needed but I suppose you're only copying what is done for ACPI tables. Couldn't hvmloader write all BIOS tables to a safe location and be done with them, or is the problem that 0xf0000 upwards is not available at the time hvmloader runs? Also, is the e820 reservation entry actually valid: 0x9f000-0xA0000 is reserved, but rombios copies the tables out of that area, right? Does rombios also update the e820 table?

-- Keir

#5 lore raw
Quoted 1 line · Keir Fraser

Couldn't hvmloader write all BIOS tables to a safe location and be done with them, or is the problem that 0xf0000 upwards is not available at the time hvmloader runs? Also, is the e820 reservation entry actually valid: 0x9f000-0xA0000 is reserved, but rombios copies the tables out of that area, right? Does rombios also update the e820 table?

Actually don't worry about this. Some cleanups to the e820 stuff can be done later in a separate patch (e.g., getting rid of the xen-specific e820 types). The current e820 map is fine for now though, and I think the BIOS table copying and so on probably does make sense.

-- Keir

#6 lore raw
In reply to Keir Fraser
Quoted 6 lines · Keir Fraser
Quoted 3 lines · Andrew D. Ball

Do you see any other things to work on for the SMBIOS patches? Making SMBIOS not optional cuts down on a bit of the code, so I'm working on that and getting the code to run on the latest changeset today.

Quoted 6 lines

I think they're basically okay. I find it a bit weird that hvmloader puts SMBIOS tables in a fixed place and then rombios copies them -- not sure why that's needed but I suppose you're only copying what is done for ACPI tables. Couldn't hvmloader write all BIOS tables to a safe location and be done with them, or is the problem that 0xf0000 upwards is not available at the time hvmloader runs?

More or less. 0xf0000-0xfffff is reserved for the ROMBIOS, but I need a 31-bit entry point somewhere on a 16-byte boundary there. It's only the 31-bit entry point that gets copied.

Quoted 4 lines

Also, is the e820
reservation entry actually valid: 0x9f000-0xA0000 is reserved, but rombios copies the tables out of that area, right? Does rombios also update the e820 table?

I'm a little confused about this myself. Whenever I change the e820 map in libxenguest, it seems to work, but I see two other places that might change it

(1) copy_e820_table in rombios.c -- looks like this doesn't do anything if 0x91e8 is 0, which is probably the case.
(2) some code in vmxassist's setup.c -- looks like this has a copy of the same e820map defined in xc_hvm_build.c and only changes it if TEST is defined.

Thanks for your help!
Andrew

Quoted 9 lines

-- Keir

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel