hal: Branch 'master'

David Zeuthen david at kemper.freedesktop.org
Wed Aug 2 13:00:23 PDT 2006


 doc/api/tmpl/libhal.sgml         |    8 ++++
 doc/spec/hal-spec-properties.xml |   42 ++++++++++++++++++++++++
 hald/linux2/physdev.c            |   66 +++++++++++++++++++++++++++++++++++++++
 3 files changed, 116 insertions(+)

New commits:
diff-tree 9512652670bbb48a4b5c64547047617296e57d19 (from c8dd0572406248f88149aeeb733c065c193acf30)
Author: Mark McLoughlin <markmc at redhat.com>
Date:   Wed Aug 2 15:59:53 2006 -0400

    add support for Xen devices
    
    Add a xen namespace to the spec and make HAL recognize bus devices
    exported by Xen. This patch comes from Mark McLoughlin. Fixed
    freedesktop.org bug #7521.

diff --git a/doc/api/tmpl/libhal.sgml b/doc/api/tmpl/libhal.sgml
index 0e83348..8ec53ed 100644
--- a/doc/api/tmpl/libhal.sgml
+++ b/doc/api/tmpl/libhal.sgml
@@ -17,6 +17,14 @@ libhal
 <!-- ##### SECTION Stability_Level ##### -->
 
 
+<!-- ##### MACRO LIBHAL_FREE_DBUS_ERROR ##### -->
+<para>
+
+</para>
+
+ at _dbus_error_: 
+
+
 <!-- ##### MACRO LIBHAL_CHECK_LIBHALCONTEXT ##### -->
 <para>
 
diff --git a/doc/spec/hal-spec-properties.xml b/doc/spec/hal-spec-properties.xml
index eaef610..a7c9752 100644
--- a/doc/spec/hal-spec-properties.xml
+++ b/doc/spec/hal-spec-properties.xml
@@ -2080,6 +2080,48 @@
         </tgroup>
       </informaltable>
     </sect2>
+    <sect2 id="device-properties-xen">
+      <title><literal>xen</literal> namespace</title>
+      <para>
+	Device objects representing virtual devices under the Xen
+	Virtual Machine Monitor, such as frontend network or block
+	devices, will have <literal>info.bus</literal> set to
+	<literal>block</literal> and will export a number of
+	properties in then <literal>xen</literal> namespace.
+      </para>
+      <informaltable>
+        <tgroup cols="2">
+          <thead>
+            <row>
+              <entry>Key (type)</entry>
+              <entry>Values</entry>
+              <entry>Mandatory</entry>
+              <entry>Description</entry>
+            </row>
+          </thead>
+          <tbody>
+            <row>
+              <entry><literal>xen.bus_id</literal> (string)</entry>
+              <entry>example: vif-0 </entry>
+              <entry>Yes</entry>
+              <entry>The XenBus ID of the device</entry>
+            </row>
+            <row>
+              <entry><literal>xen.path</literal> (string)</entry>
+              <entry>example: device/vif/0 </entry>
+              <entry>Yes</entry>
+              <entry>The XenBus path of the device</entry>
+            </row>
+            <row>
+              <entry><literal>xen.type</literal> (string)</entry>
+              <entry>example: vif</entry>
+              <entry>Yes</entry>
+              <entry>The type of Xen device</entry>
+            </row>
+          </tbody>
+        </tgroup>
+      </informaltable>
+    </sect2>
   </sect1>
 
   <sect1 id="properties-functional">
diff --git a/hald/linux2/physdev.c b/hald/linux2/physdev.c
index 2412619..e73dc35 100644
--- a/hald/linux2/physdev.c
+++ b/hald/linux2/physdev.c
@@ -810,6 +810,64 @@ mmc_compute_udi (HalDevice *d)
 /*--------------------------------------------------------------------------------------------------------------*/
 
 static HalDevice *
+xen_add (const gchar *sysfs_path, HalDevice *parent)
+{
+	HalDevice *d;
+	const gchar *devtype;
+
+	d = hal_device_new ();
+	hal_device_property_set_string (d, "linux.sysfs_path", sysfs_path);
+	hal_device_property_set_string (d, "linux.sysfs_path_device", sysfs_path);
+	hal_device_property_set_string (d, "info.bus", "xen");
+	if (parent != NULL) {
+		hal_device_property_set_string (d, "info.parent", parent->udi);
+	} else {
+		hal_device_property_set_string (d, "info.parent", "/org/freedesktop/Hal/devices/computer");
+	}
+
+	hal_util_set_driver (d, "info.linux.driver", sysfs_path);
+
+	hal_device_property_set_string (d, "xen.bus_id",
+					hal_util_get_last_element (sysfs_path));
+
+	hal_util_set_string_from_file (d, "xen.path", sysfs_path, "nodename");
+
+	devtype = hal_util_get_string_from_file (sysfs_path, "devtype");
+	hal_device_property_set_string (d, "xen.type", devtype);
+
+	if (strcmp (devtype, "pci") == 0) {
+		hal_device_property_set_string (d, "info.product", "Xen PCI Device");
+	} else if (strcmp (devtype, "vbd") == 0) {
+		hal_device_property_set_string (d, "info.product", "Xen Virtual Block Device");
+	} else if (strcmp (devtype, "vif") == 0) {
+		hal_device_property_set_string (d, "info.product", "Xen Virtual Network Device");
+	} else if (strcmp (devtype, "vtpm") == 0) {
+		hal_device_property_set_string (d, "info.product", "Xen Virtual Trusted Platform Module");
+	} else {
+		char buf[64];
+		g_snprintf (buf, sizeof (buf), "Xen Device (%s)", devtype);
+		hal_device_property_set_string (d, "info.product", buf);
+	}
+
+	return d;
+}
+
+static gboolean
+xen_compute_udi (HalDevice *d)
+{
+	gchar udi[256];
+
+	hal_util_compute_udi (hald_get_gdl (), udi, sizeof (udi),
+			      "/org/freedesktop/Hal/devices/xen_%s",
+			      hal_device_property_get_string (d, "xen.bus_id"));
+	hal_device_set_udi (d, udi);
+	hal_device_property_set_string (d, "info.udi", udi);
+	return TRUE;
+}
+
+/*--------------------------------------------------------------------------------------------------------------*/
+
+static HalDevice *
 ieee1394_add (const gchar *sysfs_path, HalDevice *parent)
 {
 	HalDevice *d;
@@ -1378,6 +1436,13 @@ static PhysDevHandler physdev_handler_ie
 	.remove      = physdev_remove
 };
 
+static PhysDevHandler physdev_handler_xen = {
+	.subsystem   = "xen",
+	.add         = xen_add,
+	.compute_udi = xen_compute_udi,
+	.remove      = physdev_remove
+};
+
 /* s390 specific busses */
 static PhysDevHandler physdev_handler_ccw = {
 	.subsystem   = "ccw",
@@ -1419,6 +1484,7 @@ static PhysDevHandler *phys_handlers[] =
 	&physdev_handler_scsi,
 	&physdev_handler_mmc,
 	&physdev_handler_ieee1394,
+	&physdev_handler_xen,
 	&physdev_handler_ccw,
 	&physdev_handler_ccwgroup,
 	&physdev_handler_iucv,



More information about the hal-commit mailing list