From: Yosuke Iwamatsu <y-iwamatsu@ab.jp.nec.com>
To: xen-devel@lists.xensource.com
Subject: [PATCH] Xend: Fix PCI Device Configuration
Date: Mon, 17 Dec 2007 18:30:47 +0900 [thread overview]
Message-ID: <476641C7.9060808@ab.jp.nec.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 206 bytes --]
Xend doesn't correctly work after restart, when there is a domU which owns
a pci device (driver domain). This patch fixes the problem.
Regards,
-------------------
Yosuke Iwamatsu
NEC Corporation
[-- Attachment #2: pci_config.patch --]
[-- Type: text/plain, Size: 6639 bytes --]
# HG changeset patch
# User y-iwamatsu@ab.jp.nec.com
# Date 1197870815 -32400
# Node ID a70ffc489ae2a2f62415dffadc43d7a4badb196b
# Parent 966a6d3b74087474df337e00b31cbecf495b442a
Xend: Fix pci device configurations.
Xend doesn't correctly work after restart when there is a domU which owns
a pci device. This is caused by two reasons:
1) Pci devices have a different configuration format from regular devices.
Xend treats pci device configurations distinctly at startup, but not at
restart. This patch makes xend correctly parse pci device configurations
both at startup and at restart.
2) configuration() function in PciController class should have an additional
argument 'transaction'.
Signed-off-by: Yosuke Iwamatsu <y-iwamatsu@ab.jp.nec.com>
diff -r 966a6d3b7408 -r a70ffc489ae2 tools/python/xen/xend/XendConfig.py
--- a/tools/python/xen/xend/XendConfig.py Fri Dec 14 11:50:24 2007 +0000
+++ b/tools/python/xen/xend/XendConfig.py Mon Dec 17 14:53:35 2007 +0900
@@ -533,55 +533,13 @@ class XendConfig(dict):
cfg['HVM_boot_policy'] = 'BIOS order'
cfg['HVM_boot_params'] = { 'order' : boot_order }
- # Parsing the device SXP's. In most cases, the SXP looks
- # like this:
- #
- # [device, [vif, [mac, xx:xx:xx:xx:xx:xx], [ip 1.3.4.5]]]
- #
- # However, for PCI devices it looks like this:
- #
- # [device, [pci, [dev, [domain, 0], [bus, 0], [slot, 1]]]]
- #
- # It seems the reasoning for this difference is because
- # pciif.py needs all the PCI device configurations at
- # the same time when creating the devices.
- #
- # To further complicate matters, Xen 2.0 configuration format
- # uses the following for pci device configuration:
- #
- # [device, [pci, [domain, 0], [bus, 0], [dev, 1], [func, 2]]]
- #
- # Hence we deal with pci device configurations outside of
- # the regular device parsing.
-
+
+ # Parsing the device SXP's.
cfg['devices'] = {}
for dev in sxp.children(sxp_cfg, 'device'):
config = sxp.child0(dev)
dev_type = sxp.name(config)
- dev_info = {}
-
- if dev_type == 'pci':
- pci_devs_uuid = sxp.child_value(config, 'uuid',
- uuid.createString())
- pci_devs = []
- for pci_dev in sxp.children(config, 'dev'):
- pci_dev_info = {}
- for opt_val in pci_dev[1:]:
- try:
- opt, val = opt_val
- pci_dev_info[opt] = val
- except TypeError:
- pass
- pci_devs.append(pci_dev_info)
-
- cfg['devices'][pci_devs_uuid] = (dev_type,
- {'devs': pci_devs,
- 'uuid': pci_devs_uuid})
-
- log.debug("XendConfig: reading device: %s" % pci_devs)
- else:
- self.device_add(dev_type, cfg_sxp = config, target = cfg)
- log.debug("XendConfig: reading device: %s" % scrub_password(dev_info))
+ self.device_add(dev_type, cfg_sxp = config, target = cfg)
# Extract missing data from configuration entries
image_sxp = sxp.child_value(sxp_cfg, 'image', [])
@@ -1096,6 +1054,44 @@ class XendConfig(dict):
dev_type = sxp.name(config)
dev_info = {}
+ # Parsing the device SXP's. In most cases, the SXP looks
+ # like this:
+ #
+ # [device, [vif, [mac, xx:xx:xx:xx:xx:xx], [ip 1.3.4.5]]]
+ #
+ # However, for PCI devices it looks like this:
+ #
+ # [device, [pci, [dev, [domain, 0], [bus, 0], [slot, 1]]]]
+ #
+ # It seems the reasoning for this difference is because
+ # pciif.py needs all the PCI device configurations at
+ # the same time when creating the devices.
+ #
+ # To further complicate matters, Xen 2.0 configuration format
+ # uses the following for pci device configuration:
+ #
+ # [device, [pci, [domain, 0], [bus, 0], [dev, 1], [func, 2]]]
+
+ if dev_type == 'pci':
+ pci_devs_uuid = sxp.child_value(config, 'uuid',
+ uuid.createString())
+ pci_devs = []
+ for pci_dev in sxp.children(config, 'dev'):
+ pci_dev_info = {}
+ for opt_val in pci_dev[1:]:
+ try:
+ opt, val = opt_val
+ pci_dev_info[opt] = val
+ except TypeError:
+ pass
+ pci_devs.append(pci_dev_info)
+ target['devices'][pci_devs_uuid] = (dev_type,
+ {'devs': pci_devs,
+ 'uuid': pci_devs_uuid})
+
+ log.debug("XendConfig: reading device: %s" % pci_devs)
+ return pci_devs_uuid
+
for opt_val in config[1:]:
try:
opt, val = opt_val
@@ -1177,6 +1173,7 @@ class XendConfig(dict):
if dev_uuid not in target['console_refs']:
target['console_refs'].append(dev_uuid)
+ log.debug("XendConfig: reading device: %s" % scrub_password(dev_info))
return dev_uuid
if cfg_xenapi:
diff -r 966a6d3b7408 -r a70ffc489ae2 tools/python/xen/xend/server/pciif.py
--- a/tools/python/xen/xend/server/pciif.py Fri Dec 14 11:50:24 2007 +0000
+++ b/tools/python/xen/xend/server/pciif.py Mon Dec 17 14:53:35 2007 +0900
@@ -102,13 +102,13 @@ class PciController(DevController):
result['uuid'] = self.readBackend(devid, 'uuid')
return result
- def configuration(self, devid):
+ def configuration(self, devid, transaction = None):
"""Returns SXPR for devices on domain.
@note: we treat this dict especially to convert to
SXP because it is not a straight dict of strings."""
- configDict = self.getDeviceConfiguration(devid)
+ configDict = self.getDeviceConfiguration(devid, transaction)
sxpr = [self.deviceClass]
# remove devs
[-- 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:[~2007-12-17 9:30 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=476641C7.9060808@ab.jp.nec.com \
--to=y-iwamatsu@ab.jp.nec.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.