All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Add device-path command.
@ 2009-04-06  8:03 Yuji Shimada
  2009-04-06 14:06 ` Daniel P. Berrange
                   ` (2 more replies)
  0 siblings, 3 replies; 10+ messages in thread
From: Yuji Shimada @ 2009-04-06  8:03 UTC (permalink / raw)
  To: Keir Fraser, xen-devel

This patch adds device-path command that converts SBDF into device
path.

'SBDF' format is "[SEG#:]BUS#:DEV#.FUNC#"
  ex) 0000:0a:1f.3
Device path format is "HID[:UID]-DEV#.FUNC#[-DEV#.FUNC#[...]]"
  ex) PNP0A08:0-2.0-0.0

The command can be executed as follows.

# device_path 0a:1f.3
PNP0A08:0-2.0-0.0

Thanks,
--
Yuji Shimada


Signed-off-by: Yuji Shimada <shimada-yxb@necst.nec.co.jp>

diff -r 5a60eb7fad79 Makefile
--- a/Makefile	Thu Apr 02 14:17:19 2009 +0100
+++ b/Makefile	Mon Apr 06 16:30:11 2009 +0900
@@ -224,7 +224,7 @@
 	rm -rf $(D)$(LIBDIR)/xen/
 	rm -rf $(D)/usr/lib/xen/
 	rm -rf $(D)/usr/local/sbin/setmask $(D)/usr/local/sbin/xen*
-	rm -rf $(D)/usr/sbin/xen* $(D)/usr/sbin/netfix $(D)/usr/sbin/xm
+	rm -rf $(D)/usr/sbin/xen* $(D)/usr/sbin/netfix $(D)/usr/sbin/xm $(D)/usr/sbin/device-path
 	rm -rf $(D)/usr/share/doc/xen
 	rm -rf $(D)/usr/share/xen
 	rm -rf $(D)/usr/share/man/man1/xen*
diff -r 5a60eb7fad79 tools/misc/Makefile
--- a/tools/misc/Makefile	Thu Apr 02 14:17:19 2009 +0100
+++ b/tools/misc/Makefile	Mon Apr 06 16:30:11 2009 +0900
@@ -22,7 +22,7 @@
 INSTALL_BIN-$(CONFIG_X86) += xen-detect
 INSTALL_BIN := $(INSTALL_BIN-y)
 
-INSTALL_SBIN-y := netfix xm xen-bugtool xen-python-path xend xenperf xsview xenpm
+INSTALL_SBIN-y := netfix xm xen-bugtool xen-python-path xend xenperf xsview xenpm device-path
 INSTALL_SBIN := $(INSTALL_SBIN-y)
 
 DEFAULT_PYTHON_PATH := $(shell $(XEN_ROOT)/tools/python/get-path)
diff -r 5a60eb7fad79 tools/misc/device-path
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/misc/device-path	Mon Apr 06 16:30:11 2009 +0900
@@ -0,0 +1,78 @@
+#!/usr/bin/env python
+#  -*- mode: python; -*-
+#============================================================================
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of version 2.1 of the GNU Lesser General Public
+# License as published by the Free Software Foundation.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+#============================================================================
+# Copyright (c) 2009, NEC Corporation.
+#============================================================================
+# This script converts SBDF into device path.
+#   'SBDF' format is "[SEG#:]BUS#:DEV#.FUNC#"
+#       ex) 0000:0a:1f.3
+#   Device path format is "HID[:UID]-DEV#.FUNC#[-DEV#.FUNC#[...]]"
+#       ex) PNP0A08:0-2.0-0.0
+#============================================================================
+
+import sys
+import os
+
+# add fallback path for non-native python path installs if needed
+sys.path.append('/usr/lib/python')
+sys.path.append('/usr/lib64/python')
+from xen.util.pci import *
+
+SYSFS_ACPI_DEVS_PATH = '/firmware/acpi/namespace/ACPI/_SB'
+
+def find_hid_uid(dom, b, d, f):
+    sb_path = find_sysfs_mnt() + SYSFS_ACPI_DEVS_PATH
+    obj_list = os.listdir(sb_path)
+    for obj in obj_list:
+        obj_path = sb_path + '/' + obj.strip() + '/'
+        if os.path.exists(obj_path + 'seg') and \
+            os.path.exists(obj_path + 'bbn'):
+            seg = open(obj_path + 'seg').read()
+            bbn = open(obj_path + 'bbn').read()
+            if int(seg) == dom and int(bbn) == b:
+                hid = open(obj_path + 'hid').read()
+                if os.path.exists(obj_path + 'uid') is False:
+                    path_str = hid.strip()
+                else:
+                    uid = open(obj_path + 'uid').read()
+                    path_str = hid.strip() + ':' + uid.strip()
+                return path_str
+    return None
+
+def make_device_path(dom, b, d, f):
+    dev = PciDevice(dom, b, d, f)
+    parent = dev.find_parent()
+    if parent is None:
+        path_str = find_hid_uid(dom, b, d, f)
+        path_str = path_str + '-' + hex(d).replace('0x', '') + '.' + \
+            hex(f).replace('0x', '')
+        return path_str
+    (pdom, pb, pd, pf) = parent
+    path_str = make_device_path(pdom, pb, pd, pf)
+    path_str = path_str + '-' + hex(d).replace('0x', '') + '.' + \
+        hex(f).replace('0x', '')
+    return path_str
+
+# main
+if len(sys.argv) <> 2:
+    print 'Usage: device-path SBDF\n'
+else:
+    path = os.environ['PATH']
+    os.environ['PATH'] = path + ':/sbin' + ':/user/sbin'
+    sbdf = sys.argv[1]
+    (dom, b, d, f) = parse_pci_name(sbdf)
+    path_str = make_device_path(dom, b, d, f)
+    print path_str

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] Add device-path command.
  2009-04-06  8:03 [PATCH] Add device-path command Yuji Shimada
@ 2009-04-06 14:06 ` Daniel P. Berrange
  2009-04-06 14:45   ` Keir Fraser
  2009-04-07  7:29   ` Yuji Shimada
  2009-04-07 16:42 ` Ian Jackson
  2009-04-09  8:49 ` [PATCH v2] Add sbdf2devicepath command Yuji Shimada
  2 siblings, 2 replies; 10+ messages in thread
From: Daniel P. Berrange @ 2009-04-06 14:06 UTC (permalink / raw)
  To: Yuji Shimada; +Cc: xen-devel, Keir Fraser

On Mon, Apr 06, 2009 at 05:03:37PM +0900, Yuji Shimada wrote:
> This patch adds device-path command that converts SBDF into device
> path.

[snip]

> diff -r 5a60eb7fad79 tools/misc/device-path
> --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
> +++ b/tools/misc/device-path	Mon Apr 06 16:30:11 2009 +0900


[snip]

> +SYSFS_ACPI_DEVS_PATH = '/firmware/acpi/namespace/ACPI/_SB'
> +
> +def find_hid_uid(dom, b, d, f):
> +    sb_path = find_sysfs_mnt() + SYSFS_ACPI_DEVS_PATH
> +    obj_list = os.listdir(sb_path)
> +    for obj in obj_list:
> +        obj_path = sb_path + '/' + obj.strip() + '/'
> +        if os.path.exists(obj_path + 'seg') and \
> +            os.path.exists(obj_path + 'bbn'):
> +            seg = open(obj_path + 'seg').read()
> +            bbn = open(obj_path + 'bbn').read()
> +            if int(seg) == dom and int(bbn) == b:
> +                hid = open(obj_path + 'hid').read()
> +                if os.path.exists(obj_path + 'uid') is False:
> +                    path_str = hid.strip()
> +                else:
> +                    uid = open(obj_path + 'uid').read()
> +                    path_str = hid.strip() + ':' + uid.strip()
> +                return path_str
> +    return None

I don't know how critical this piece of code is to the overall functionality
in this tool, but be warned that the path being used here was removed from
sysfs in upstream kernel quite a while ago

To quote an old copy of  Documentation/feature-removal-schedule.txt

  What:  /sys/firmware/acpi/namespace
  When:  2.6.21
  Why:   The ACPI namespace is effectively the symbol list for
         the BIOS.  The device names are completely arbitrary
         and have no place being exposed to user-space.
  
         For those interested in the BIOS ACPI namespace,
         the BIOS can be extracted and disassembled with acpidump
         and iasl as documented in the pmtools package here:
         http://ftp.kernel.org/pub/linux/kernel/people/lenb/acpi/utils

Regards,
Daniel
-- 
|: Red Hat, Engineering, London   -o-   http://people.redhat.com/berrange/ :|
|: http://libvirt.org  -o-  http://virt-manager.org  -o-  http://ovirt.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505  -o-  F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] Add device-path command.
  2009-04-06 14:06 ` Daniel P. Berrange
@ 2009-04-06 14:45   ` Keir Fraser
  2009-04-07  7:29   ` Yuji Shimada
  1 sibling, 0 replies; 10+ messages in thread
From: Keir Fraser @ 2009-04-06 14:45 UTC (permalink / raw)
  To: Daniel P. Berrange, Yuji Shimada; +Cc: xen-devel@lists.xensource.com

On 06/04/2009 15:06, "Daniel P. Berrange" <berrange@redhat.com> wrote:

> I don't know how critical this piece of code is to the overall functionality
> in this tool, but be warned that the path being used here was removed from
> sysfs in upstream kernel quite a while ago

That makes the script not very generally usable then. Unless there is some
other way to get this info easily, I'll just revert the changeset that
checked it in.

 -- Keir

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] Add device-path command.
  2009-04-06 14:06 ` Daniel P. Berrange
  2009-04-06 14:45   ` Keir Fraser
@ 2009-04-07  7:29   ` Yuji Shimada
  2009-04-07  8:15     ` Keir Fraser
  2009-04-07  8:16     ` Yuji Shimada
  1 sibling, 2 replies; 10+ messages in thread
From: Yuji Shimada @ 2009-04-07  7:29 UTC (permalink / raw)
  To: Daniel P. Berrange; +Cc: xen-devel, Keir Fraser

On Mon, 6 Apr 2009 15:06:00 +0100
"Daniel P. Berrange" <berrange@redhat.com> wrote:

> On Mon, Apr 06, 2009 at 05:03:37PM +0900, Yuji Shimada wrote:
> > This patch adds device-path command that converts SBDF into device
> > path.
> 
> [snip]
> 
> > diff -r 5a60eb7fad79 tools/misc/device-path
> > --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
> > +++ b/tools/misc/device-path	Mon Apr 06 16:30:11 2009 +0900
> 
> 
> [snip]
> 
> > +SYSFS_ACPI_DEVS_PATH = '/firmware/acpi/namespace/ACPI/_SB'
> > +
> > +def find_hid_uid(dom, b, d, f):
> > +    sb_path = find_sysfs_mnt() + SYSFS_ACPI_DEVS_PATH
> > +    obj_list = os.listdir(sb_path)
> > +    for obj in obj_list:
> > +        obj_path = sb_path + '/' + obj.strip() + '/'
> > +        if os.path.exists(obj_path + 'seg') and \
> > +            os.path.exists(obj_path + 'bbn'):
> > +            seg = open(obj_path + 'seg').read()
> > +            bbn = open(obj_path + 'bbn').read()
> > +            if int(seg) == dom and int(bbn) == b:
> > +                hid = open(obj_path + 'hid').read()
> > +                if os.path.exists(obj_path + 'uid') is False:
> > +                    path_str = hid.strip()
> > +                else:
> > +                    uid = open(obj_path + 'uid').read()
> > +                    path_str = hid.strip() + ':' + uid.strip()
> > +                return path_str
> > +    return None
> 
> I don't know how critical this piece of code is to the overall functionality
> in this tool, but be warned that the path being used here was removed from
> sysfs in upstream kernel quite a while ago
> 
> To quote an old copy of  Documentation/feature-removal-schedule.txt
> 
>   What:  /sys/firmware/acpi/namespace
>   When:  2.6.21
>   Why:   The ACPI namespace is effectively the symbol list for
>          the BIOS.  The device names are completely arbitrary
>          and have no place being exposed to user-space.
>   
>          For those interested in the BIOS ACPI namespace,
>          the BIOS can be extracted and disassembled with acpidump
>          and iasl as documented in the pmtools package here:
>          http://ftp.kernel.org/pub/linux/kernel/people/lenb/acpi/utils
> 

It is difficult for users to get device path of particular device.
So I made this command that converts SBDF into device path.

SBDF of devices can be changed at boot time. But device path is not
changed at boot time.
I have already added the function to specify guest passthrough device
by device path with "guestdev" boot parameter.
The linux-2.6.18-xen kernel changeset is the following.

# changeset fad85221407bf32df2574bca54cba730748343a2
# changeset 2fdc121e9b5d76464b3efd47d711c58253ef6348
# changeset cfb171ddbb333df9671a1da62e40122a56213ab4
# changeset 79e82ae1bad02c0dfb504db3153599e52a0affb3

Is there any kernel that has already merged above changeset?
If yes, could you tell me where it is?
If no, I think it is not necessary to make device-path script support
upstream linux.

Thanks,
--
Yuji Shimada

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] Add device-path command.
  2009-04-07  7:29   ` Yuji Shimada
@ 2009-04-07  8:15     ` Keir Fraser
  2009-04-07  8:16     ` Yuji Shimada
  1 sibling, 0 replies; 10+ messages in thread
From: Keir Fraser @ 2009-04-07  8:15 UTC (permalink / raw)
  To: Yuji Shimada, Daniel P. Berrange; +Cc: xen-devel@lists.xensource.com

On 07/04/2009 08:29, "Yuji Shimada" <shimada-yxb@necst.nec.co.jp> wrote:

> Is there any kernel that has already merged above changeset?
> If yes, could you tell me where it is?
> If no, I think it is not necessary to make device-path script support
> upstream linux.

It'll have to be ported to pv_ops soon enough (or be rendered obsolete), and
what will we do there?

 -- Keir

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] Add device-path command.
  2009-04-07  7:29   ` Yuji Shimada
  2009-04-07  8:15     ` Keir Fraser
@ 2009-04-07  8:16     ` Yuji Shimada
  1 sibling, 0 replies; 10+ messages in thread
From: Yuji Shimada @ 2009-04-07  8:16 UTC (permalink / raw)
  To: Daniel P. Berrange; +Cc: xen-devel, Keir Fraser

On Tue, 07 Apr 2009 16:29:05 +0900
Yuji Shimada <shimada-yxb@necst.nec.co.jp> wrote:

> On Mon, 6 Apr 2009 15:06:00 +0100
> "Daniel P. Berrange" <berrange@redhat.com> wrote:
> 
> > On Mon, Apr 06, 2009 at 05:03:37PM +0900, Yuji Shimada wrote:
> > > This patch adds device-path command that converts SBDF into device
> > > path.
> > 
> > [snip]
> > 
> > > diff -r 5a60eb7fad79 tools/misc/device-path
> > > --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
> > > +++ b/tools/misc/device-path	Mon Apr 06 16:30:11 2009 +0900
> > 
> > 
> > [snip]
> > 
> > > +SYSFS_ACPI_DEVS_PATH = '/firmware/acpi/namespace/ACPI/_SB'
> > > +
> > > +def find_hid_uid(dom, b, d, f):
> > > +    sb_path = find_sysfs_mnt() + SYSFS_ACPI_DEVS_PATH
> > > +    obj_list = os.listdir(sb_path)
> > > +    for obj in obj_list:
> > > +        obj_path = sb_path + '/' + obj.strip() + '/'
> > > +        if os.path.exists(obj_path + 'seg') and \
> > > +            os.path.exists(obj_path + 'bbn'):
> > > +            seg = open(obj_path + 'seg').read()
> > > +            bbn = open(obj_path + 'bbn').read()
> > > +            if int(seg) == dom and int(bbn) == b:
> > > +                hid = open(obj_path + 'hid').read()
> > > +                if os.path.exists(obj_path + 'uid') is False:
> > > +                    path_str = hid.strip()
> > > +                else:
> > > +                    uid = open(obj_path + 'uid').read()
> > > +                    path_str = hid.strip() + ':' + uid.strip()
> > > +                return path_str
> > > +    return None
> > 
> > I don't know how critical this piece of code is to the overall functionality
> > in this tool, but be warned that the path being used here was removed from
> > sysfs in upstream kernel quite a while ago
> > 
> > To quote an old copy of  Documentation/feature-removal-schedule.txt
> > 
> >   What:  /sys/firmware/acpi/namespace
> >   When:  2.6.21
> >   Why:   The ACPI namespace is effectively the symbol list for
> >          the BIOS.  The device names are completely arbitrary
> >          and have no place being exposed to user-space.
> >   
> >          For those interested in the BIOS ACPI namespace,
> >          the BIOS can be extracted and disassembled with acpidump
> >          and iasl as documented in the pmtools package here:
> >          http://ftp.kernel.org/pub/linux/kernel/people/lenb/acpi/utils
> > 
> 
> It is difficult for users to get device path of particular device.
> So I made this command that converts SBDF into device path.
> 
> SBDF of devices can be changed at boot time. But device path is not
> changed at boot time.
> I have already added the function to specify guest passthrough device
> by device path with "guestdev" boot parameter.
> The linux-2.6.18-xen kernel changeset is the following.
> 
> # changeset fad85221407bf32df2574bca54cba730748343a2
> # changeset 2fdc121e9b5d76464b3efd47d711c58253ef6348
> # changeset cfb171ddbb333df9671a1da62e40122a56213ab4
> # changeset 79e82ae1bad02c0dfb504db3153599e52a0affb3

Sorry, above changesets are wrong.
They are correct changesets.

# changeset 765 : fad85221407bf32df2574bca54cba730748343a2
# changeset 766 : 2fdc121e9b5d76464b3efd47d711c58253ef6348
# changeset 767 : 78d81e85e8cd8a0a26bc9b760c67d435341f43f8
# changeset 768 : cfb171ddbb333df9671a1da62e40122a56213ab4

Thanks,
--
Yuji Shimada

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] Add device-path command.
  2009-04-06  8:03 [PATCH] Add device-path command Yuji Shimada
  2009-04-06 14:06 ` Daniel P. Berrange
@ 2009-04-07 16:42 ` Ian Jackson
  2009-04-09  8:49 ` [PATCH v2] Add sbdf2devicepath command Yuji Shimada
  2 siblings, 0 replies; 10+ messages in thread
From: Ian Jackson @ 2009-04-07 16:42 UTC (permalink / raw)
  To: Yuji Shimada; +Cc: xen-devel@lists.xensource.com, Keir Fraser

Yuji Shimada writes ("[Xen-devel] [PATCH] Add device-path command."):
> This patch adds device-path command that converts SBDF into device
> path.

This program should have some more specific name, at the very least.

Ian.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH v2] Add sbdf2devicepath command.
  2009-04-06  8:03 [PATCH] Add device-path command Yuji Shimada
  2009-04-06 14:06 ` Daniel P. Berrange
  2009-04-07 16:42 ` Ian Jackson
@ 2009-04-09  8:49 ` Yuji Shimada
  2009-04-15  6:00   ` [PATCH] Modify makefiles to install/uninstall " Yuji Shimada
  2 siblings, 1 reply; 10+ messages in thread
From: Yuji Shimada @ 2009-04-09  8:49 UTC (permalink / raw)
  To: Daniel P. Berrange, Keir Fraser, Ian Jackson; +Cc: xen-devel

Thanks for all of your comments.

I change command name from 'device-path'to 'sbdf2devicepath'.
And I add error message in case ACPI namespace directory does not
present.

Thanks,
--
Yuji Shimada

This patch adds 'sbdf2devicepath' command that converts SBDF into
device path.

'SBDF' format is "[SEG#:]BUS#:DEV#.FUNC#"
  ex) 0000:0a:1f.3
Device path format is "HID[:UID]-DEV#.FUNC#[-DEV#.FUNC#[...]]"
  ex) PNP0A08:0-2.0-0.0

The command can be executed as follows.

# sbdf2devicepath 0a:1f.3
PNP0A08:0-2.0-0.0

Signed-off-by: Yuji Shimada <shimada-yxb@necst.nec.co.jp>

diff -r accf139b2eb9 Makefile
--- a/Makefile	Mon Apr 06 21:12:33 2009 +0100
+++ b/Makefile	Thu Apr 09 17:12:34 2009 +0900
@@ -224,7 +224,7 @@
 	rm -rf $(D)$(LIBDIR)/xen/
 	rm -rf $(D)/usr/lib/xen/
 	rm -rf $(D)/usr/local/sbin/setmask $(D)/usr/local/sbin/xen*
-	rm -rf $(D)/usr/sbin/xen* $(D)/usr/sbin/netfix $(D)/usr/sbin/xm
+	rm -rf $(D)/usr/sbin/xen* $(D)/usr/sbin/netfix $(D)/usr/sbin/xm $(D)/usr/sbin/sbdf2devicepath
 	rm -rf $(D)/usr/share/doc/xen
 	rm -rf $(D)/usr/share/xen
 	rm -rf $(D)/usr/share/man/man1/xen*
diff -r accf139b2eb9 tools/misc/Makefile
--- a/tools/misc/Makefile	Mon Apr 06 21:12:33 2009 +0100
+++ b/tools/misc/Makefile	Thu Apr 09 17:12:34 2009 +0900
@@ -22,7 +22,7 @@
 INSTALL_BIN-$(CONFIG_X86) += xen-detect
 INSTALL_BIN := $(INSTALL_BIN-y)
 
-INSTALL_SBIN-y := xm xen-bugtool xen-python-path xend xenperf xsview xenpm
+INSTALL_SBIN-y := xm xen-bugtool xen-python-path xend xenperf xsview xenpm sbdf2devicepath
 INSTALL_SBIN := $(INSTALL_SBIN-y)
 
 DEFAULT_PYTHON_PATH := $(shell $(XEN_ROOT)/tools/python/get-path)
diff -r accf139b2eb9 tools/misc/sbdf2devicepath
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/misc/sbdf2devicepath	Thu Apr 09 17:12:34 2009 +0900
@@ -0,0 +1,82 @@
+#!/usr/bin/env python
+#  -*- mode: python; -*-
+#============================================================================
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of version 2.1 of the GNU Lesser General Public
+# License as published by the Free Software Foundation.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+#============================================================================
+# Copyright (c) 2009, NEC Corporation.
+#============================================================================
+# This script converts SBDF into device path.
+#   'SBDF' format is "[SEG#:]BUS#:DEV#.FUNC#"
+#       ex) 0000:0a:1f.3
+#   Device path format is "HID[:UID]-DEV#.FUNC#[-DEV#.FUNC#[...]]"
+#       ex) PNP0A08:0-2.0-0.0
+#=============================================================================
+
+import sys
+import os
+
+# add fallback path for non-native python path installs if needed
+sys.path.append('/usr/lib/python')
+sys.path.append('/usr/lib64/python')
+from xen.util.pci import *
+
+SYSFS_ACPI_DEVS_PATH = '/firmware/acpi/namespace/ACPI/_SB'
+
+def find_hid_uid(dom, b, d, f):
+    obj_list = os.listdir(sb_path)
+    for obj in obj_list:
+        obj_path = sb_path + '/' + obj.strip() + '/'
+        if os.path.exists(obj_path + 'seg') and \
+            os.path.exists(obj_path + 'bbn'):
+            seg = open(obj_path + 'seg').read()
+            bbn = open(obj_path + 'bbn').read()
+            if int(seg) == dom and int(bbn) == b:
+                hid = open(obj_path + 'hid').read()
+                if os.path.exists(obj_path + 'uid') is False:
+                    path_str = hid.strip()
+                else:
+                    uid = open(obj_path + 'uid').read()
+                    path_str = hid.strip() + ':' + uid.strip()
+                return path_str
+    return None
+
+def make_device_path(dom, b, d, f):
+    dev = PciDevice(dom, b, d, f)
+    parent = dev.find_parent()
+    if parent is None:
+        path_str = find_hid_uid(dom, b, d, f)
+        path_str = path_str + '-' + hex(d).replace('0x', '') + '.' + \
+            hex(f).replace('0x', '')
+        return path_str
+    (pdom, pb, pd, pf) = parent
+    path_str = make_device_path(pdom, pb, pd, pf)
+    path_str = path_str + '-' + hex(d).replace('0x', '') + '.' + \
+        hex(f).replace('0x', '')
+    return path_str
+
+# main
+if len(sys.argv) <> 2:
+    print 'Usage: sbdf2devicepath SBDF\n'
+else:
+    sb_path = find_sysfs_mnt() + SYSFS_ACPI_DEVS_PATH
+    if os.path.exists(sb_path):
+        path = os.environ['PATH']
+        os.environ['PATH'] = path + ':/sbin' + ':/user/sbin'
+        sbdf = sys.argv[1]
+        (dom, b, d, f) = parse_pci_name(sbdf)
+        path_str = make_device_path(dom, b, d, f)
+        print path_str
+    else:
+        print sb_path + ' not found.\n'
+        print 'This command is only for linux 2.6.18.8 xen kernel.\n'

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH] Modify makefiles to install/uninstall sbdf2devicepath command.
  2009-04-09  8:49 ` [PATCH v2] Add sbdf2devicepath command Yuji Shimada
@ 2009-04-15  6:00   ` Yuji Shimada
  2009-04-15  7:42     ` Keir Fraser
  0 siblings, 1 reply; 10+ messages in thread
From: Yuji Shimada @ 2009-04-15  6:00 UTC (permalink / raw)
  To: Keir Fraser; +Cc: Ian Jackson, xen-devel, Daniel P. Berrange

This patch modifies makefiles to install/uninstall the command.

"sbdf2devicepath" command is not installed/uninstalled by the
following changeset.

http://xenbits.xensource.com/xen-unstable.hg?rev/0b9b6d5a61c1

Thanks,
--
Yuji Shimada


Signed-off-by: Yuji Shimada <shimada-yxb@necst.nec.co.jp>

diff -r 94ffd85005c5 Makefile
--- a/Makefile	Tue Apr 14 15:23:53 2009 +0100
+++ b/Makefile	Wed Apr 15 11:58:35 2009 +0900
@@ -220,7 +220,7 @@
 	rm -rf $(D)$(LIBDIR)/xen/
 	rm -rf $(D)/usr/lib/xen/
 	rm -rf $(D)/usr/local/sbin/setmask $(D)/usr/local/sbin/xen*
-	rm -rf $(D)/usr/sbin/xen* $(D)/usr/sbin/netfix $(D)/usr/sbin/xm
+	rm -rf $(D)/usr/sbin/xen* $(D)/usr/sbin/netfix $(D)/usr/sbin/xm $(D)/usr/sbin/sbdf2devicepath
 	rm -rf $(D)/usr/share/doc/xen
 	rm -rf $(D)/usr/share/xen
 	rm -rf $(D)/usr/share/man/man1/xen*
diff -r 94ffd85005c5 tools/misc/Makefile
--- a/tools/misc/Makefile	Tue Apr 14 15:23:53 2009 +0100
+++ b/tools/misc/Makefile	Wed Apr 15 11:58:35 2009 +0900
@@ -22,7 +22,7 @@
 INSTALL_BIN-$(CONFIG_X86) += xen-detect
 INSTALL_BIN := $(INSTALL_BIN-y)
 
-INSTALL_SBIN-y := xm xen-bugtool xen-python-path xend xenperf xsview xenpm
+INSTALL_SBIN-y := xm xen-bugtool xen-python-path xend xenperf xsview xenpm sbdf2devicepath
 INSTALL_SBIN := $(INSTALL_SBIN-y)
 
 DEFAULT_PYTHON_PATH := $(shell $(XEN_ROOT)/tools/python/get-path)

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] Modify makefiles to install/uninstall sbdf2devicepath command.
  2009-04-15  6:00   ` [PATCH] Modify makefiles to install/uninstall " Yuji Shimada
@ 2009-04-15  7:42     ` Keir Fraser
  0 siblings, 0 replies; 10+ messages in thread
From: Keir Fraser @ 2009-04-15  7:42 UTC (permalink / raw)
  To: Yuji Shimada
  Cc: Ian Jackson, xen-devel@lists.xensource.com, Daniel P. Berrange

On 15/04/2009 07:00, "Yuji Shimada" <shimada-yxb@necst.nec.co.jp> wrote:

> This patch modifies makefiles to install/uninstall the command.
> 
> "sbdf2devicepath" command is not installed/uninstalled by the
> following changeset.
> 
> http://xenbits.xensource.com/xen-unstable.hg?rev/0b9b6d5a61c1

I don't think this is generically useful enough to install on all systems.
We'll keep it as a helpful script that users can be pointed at if doing
advanced passthru stuff.

 -- Keir

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2009-04-15  7:42 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-04-06  8:03 [PATCH] Add device-path command Yuji Shimada
2009-04-06 14:06 ` Daniel P. Berrange
2009-04-06 14:45   ` Keir Fraser
2009-04-07  7:29   ` Yuji Shimada
2009-04-07  8:15     ` Keir Fraser
2009-04-07  8:16     ` Yuji Shimada
2009-04-07 16:42 ` Ian Jackson
2009-04-09  8:49 ` [PATCH v2] Add sbdf2devicepath command Yuji Shimada
2009-04-15  6:00   ` [PATCH] Modify makefiles to install/uninstall " Yuji Shimada
2009-04-15  7:42     ` Keir Fraser

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.