All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Andrew D. Ball" <aball@us.ibm.com>
To: xen-devel@lists.xensource.com
Subject: [RFC] [PATCH] HVM SMBIOS support 1/6
Date: Fri, 07 Jul 2006 15:36:49 -0400	[thread overview]
Message-ID: <1152301009.7155.8.camel@localhost.localdomain> (raw)

[-- Attachment #1: Type: text/plain, Size: 5563 bytes --]

[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.

Signed-off-by: Andrew D. Ball <aball@us.ibm.com>

diff -r f91cc71173c5 tools/python/xen/lowlevel/xc/xc.c
--- a/tools/python/xen/lowlevel/xc/xc.c	Thu Jun 22 20:37:33 2006
+++ b/tools/python/xen/lowlevel/xc/xc.c	Fri Jul  7 13:49:52 2006
@@ -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",
diff -r f91cc71173c5 tools/python/xen/xend/image.py
--- a/tools/python/xen/xend/image.py	Thu Jun 22 20:37:33 2006
+++ b/tools/python/xen/xend/image.py	Fri Jul  7 13:49:52 2006
@@ -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
diff -r f91cc71173c5 tools/python/xen/xm/create.py
--- a/tools/python/xen/xm/create.py	Thu Jun 22 20:37:33 2006
+++ b/tools/python/xen/xm/create.py	Fri Jul  7 13:49:52 2006
@@ -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]])


[-- Attachment #2: smbios_1_xend.patch --]
[-- Type: text/x-patch, Size: 5562 bytes --]

[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.

Signed-off-by: Andrew D. Ball <aball@us.ibm.com>

diff -r f91cc71173c5 tools/python/xen/lowlevel/xc/xc.c
--- a/tools/python/xen/lowlevel/xc/xc.c	Thu Jun 22 20:37:33 2006
+++ b/tools/python/xen/lowlevel/xc/xc.c	Fri Jul  7 13:49:52 2006
@@ -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",
diff -r f91cc71173c5 tools/python/xen/xend/image.py
--- a/tools/python/xen/xend/image.py	Thu Jun 22 20:37:33 2006
+++ b/tools/python/xen/xend/image.py	Fri Jul  7 13:49:52 2006
@@ -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
diff -r f91cc71173c5 tools/python/xen/xm/create.py
--- a/tools/python/xen/xm/create.py	Thu Jun 22 20:37:33 2006
+++ b/tools/python/xen/xm/create.py	Fri Jul  7 13:49:52 2006
@@ -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]])

[-- Attachment #3: Type: text/plain, Size: 138 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel

             reply	other threads:[~2006-07-07 19:36 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-07-07 19:36 Andrew D. Ball [this message]
2006-07-10 14:49 ` [RFC] [PATCH] HVM SMBIOS support 1/6 Keir Fraser
2006-07-10 15:11   ` Andrew D. Ball
2006-07-11 18:12   ` Andrew D. Ball
2006-07-11 18:34     ` Keir Fraser
2006-07-11 19:01       ` Keir Fraser
2006-07-11 19:27       ` Andrew D. Ball

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1152301009.7155.8.camel@localhost.localdomain \
    --to=aball@us.ibm.com \
    --cc=xen-devel@lists.xensource.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.