hal: Branch 'master'

David Zeuthen david at kemper.freedesktop.org
Mon Mar 3 14:00:07 PST 2008


 doc/spec/hal-spec-properties.xml |   34 ++++++++++++++++++++++++
 hald/linux/device.c              |   55 +++++++++++++++++++++++++++++++++++++++
 2 files changed, 89 insertions(+)

New commits:
commit e24b990287f81cc4c9394360e5ca477c0fd27993
Author: Jeremy Katz <katzj at redhat.com>
Date:   Mon Mar 3 16:58:43 2008 -0500

    add suport for the virtio bus
    
    The new virtio (http://kvm.qumranet.com/kvmwiki/Virtio) virtual
    devices which are available to provide PV drivers to KVM and other
    virt technologies don't seem to be showing up in hal.  It looks like
    we just need to add support for the "virtio" bus
    
    See https://bugzilla.redhat.com/show_bug.cgi?id=435640 for more
    details.

diff --git a/doc/spec/hal-spec-properties.xml b/doc/spec/hal-spec-properties.xml
index 3539f41..2d3e781 100644
--- a/doc/spec/hal-spec-properties.xml
+++ b/doc/spec/hal-spec-properties.xml
@@ -2870,6 +2870,40 @@ org.freedesktop.Hal.Device.Volume.method_signatures = {'ssas', 'as', 'as'}
         </tgroup>
       </informaltable>
     </sect2>
+
+    <sect2 id="device-properties-virtio">
+      <title>
+        virtio namespace
+      </title>
+      <para>
+        Devices on the VirtIO bus are represented by device
+        objects where <literal>info.subsystem</literal> equals
+        <literal>virtio</literal>. The following properties are
+        available for such device objects.
+      </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>virtio.id</literal> (string)
+              </entry>
+              <entry>example: serial</entry>
+              <entry>Yes</entry>
+              <entry>Device identification</entry>
+            </row>
+          </tbody>
+        </tgroup>
+      </informaltable>
+    </sect2>
   </sect1>
 
   <sect1 id="properties-functional">
diff --git a/hald/linux/device.c b/hald/linux/device.c
index 14e9af4..1d5fc58 100644
--- a/hald/linux/device.c
+++ b/hald/linux/device.c
@@ -3482,6 +3482,52 @@ ps3_system_bus_compute_udi (HalDevice *d)
 /*--------------------------------------------------------------------------------------------------------------*/
 
 static HalDevice *
+virtio_add (const gchar *sysfs_path, const gchar *device_file, HalDevice *parent_dev,
+		    const gchar *sysfs_path_in_devices)
+{
+	HalDevice *d;
+	const gchar *dev_id;
+	gchar buf[64];
+
+	d = hal_device_new ();
+	hal_device_property_set_string (d, "linux.sysfs_path", sysfs_path);
+	hal_device_property_set_string (d, "info.subsystem", "virtio");
+	hal_device_property_set_string (d, "info.bus", "virtio");
+	if (parent_dev != NULL) {
+		hal_device_property_set_string (d, "info.parent", hal_device_get_udi (parent_dev));
+	} else {
+		hal_device_property_set_string (d, "info.parent", "/org/freedesktop/Hal/devices/computer");
+	}
+
+	hal_util_set_driver (d, "info.linux.driver", sysfs_path);
+
+	dev_id = hal_util_get_last_element (sysfs_path);
+
+	hal_device_property_set_string (d, "virtio.id", dev_id);
+
+	g_snprintf (buf, sizeof (buf), "VirtIO Device (%s)", hal_device_property_get_string (d, "virtio.id"));
+	hal_device_property_set_string (d, "info.product", buf);
+
+	return d;
+}
+
+static gboolean
+virtio_compute_udi (HalDevice *d)
+{
+	gchar udi[256];
+
+	hal_util_compute_udi (hald_get_gdl (), udi, sizeof (udi),
+			      "/org/freedesktop/Hal/devices/virtio_%s",
+			      hal_device_property_get_string (d, "virtio.id"));
+	hal_device_set_udi (d, udi);
+	hal_device_property_set_string (d, "info.udi", udi);
+
+	return TRUE;
+}
+
+/*--------------------------------------------------------------------------------------------------------------*/
+
+static HalDevice *
 pseudo_add (const gchar *sysfs_path, const gchar *device_file, HalDevice *parent_dev, const gchar *parent_path)
 {
 	HalDevice *d;
@@ -3834,6 +3880,14 @@ static DevHandler dev_handler_ps3_system_bus =
 	.remove      = dev_remove
 };
 
+static DevHandler dev_handler_virtio =
+{
+	.subsystem   = "virtio",
+	.add         = virtio_add,
+	.compute_udi = virtio_compute_udi,
+	.remove      = dev_remove
+};
+
 /* SCSI debug, to test thousends of fake devices */
 static DevHandler dev_handler_pseudo = {
 	.subsystem   = "pseudo",
@@ -3879,6 +3933,7 @@ static DevHandler *dev_handlers[] = {
 	&dev_handler_power_supply,
 	&dev_handler_drm,
 	&dev_handler_ps3_system_bus,
+	&dev_handler_virtio,
 	NULL
 };
 


More information about the hal-commit mailing list