This series of patches contains fixes for pass-through and Xen API such that xm can now use Xen API to create domains and, attach, detach and list pass-through devices. _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Simon Horman
2009-Jun-04 03:21 UTC
[Xen-devel] [patch 1/9] xend: pass-through: report attach errors from device model
Cc: Masaki Kanno <kanno.masaki@jp.fujitsu.com>
Cc: Edwin Zhai <edwin.zhai@intel.com>
Signed-off-by: Simon Horman <horms@verge.net.au>
---
Changes
- Use spaces for indentation
- Removed spurious debug message
Index: xen-unstable.hg/tools/python/xen/xend/XendDomainInfo.py
==================================================================---
xen-unstable.hg.orig/tools/python/xen/xend/XendDomainInfo.py 2009-06-04
12:45:56.000000000 +1000
+++ xen-unstable.hg/tools/python/xen/xend/XendDomainInfo.py 2009-06-04
12:45:58.000000000 +1000
@@ -752,6 +752,12 @@ class XendDomainInfo:
vslot =
xstransact.Read("/local/domain/0/device-model/%i/parameter"
% self.getDomid())
+ try:
+ vslot_int = int(vslot, 16)
+ except ValueError:
+ raise VmError(("Cannot pass-through PCI function
''%s''. " +
+ "Device model reported an error: %s")
%
+ (bdf_str, vslot))
else:
vslot = new_dev[''vslot'']
--
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel
Simon Horman
2009-Jun-04 03:21 UTC
[Xen-devel] [patch 2/9] xm: xen-api: Install create.dtd in SHAREDIR
* Install create.dtd in SHAREDIR
* Use SHAREDIR/create.dtd
* import os.path.join into xenapi_create.py,
it already seems to be used many times
Resolves the following error when using XenAPI:
$ xm create hvm.conf
Couldn''t open resource ''/usr/share/xen/create.dtd'' at
/usr/share/xen/create.dtd:1:0
Cc: Dexuan Cui <dexuan.cui@intel.com>,
Cc: Masaki Kanno <kanno.masaki@jp.fujitsu.com>
Signed-off-by: Simon Horman <horms@verge.net.au>
Index: xen-unstable.hg/tools/python/Makefile
==================================================================---
xen-unstable.hg.orig/tools/python/Makefile 2009-06-03 09:41:34.000000000 +1000
+++ xen-unstable.hg/tools/python/Makefile 2009-06-03 09:56:44.000000000 +1000
@@ -22,6 +22,7 @@ genpath:
echo "BINDIR=\"$(BINDIR)\"" >> ${xenpath}
echo "LIBEXEC=\"$(LIBEXEC)\"" >> ${xenpath}
echo "LIBDIR=\"$(LIBDIR)\"" >> ${xenpath}
+ echo "SHAREDIR=\"$(SHAREDIR)\"" >> ${xenpath}
echo "PRIVATE_BINDIR=\"$(PRIVATE_BINDIR)\"" >>
${xenpath}
echo "XEN_CONFIG_DIR=\"$(XEN_CONFIG_DIR)\"" >>
${xenpath}
echo "XEN_SCRIPT_DIR=\"$(XEN_SCRIPT_DIR)\"" >>
${xenpath}
@@ -70,8 +71,8 @@ install: install-messages install-dtd
$(PYTHON_PREFIX_ARG) --root="$(DESTDIR)" --force
install-dtd: all
- $(INSTALL_DIR) $(DESTDIR)$(DOCDIR)
- $(INSTALL_DATA) xen/xm/create.dtd $(DESTDIR)$(DOCDIR)
+ $(INSTALL_DIR) $(DESTDIR)$(SHAREDIR)
+ $(INSTALL_DATA) xen/xm/create.dtd $(DESTDIR)$(SHAREDIR)
install-messages: all
set -e; if which $(MSGFMT) >/dev/null ; then \
Index: xen-unstable.hg/tools/python/xen/xm/xenapi_create.py
==================================================================---
xen-unstable.hg.orig/tools/python/xen/xm/xenapi_create.py 2009-06-03
09:41:34.000000000 +1000
+++ xen-unstable.hg/tools/python/xen/xm/xenapi_create.py 2009-06-03
10:21:54.000000000 +1000
@@ -26,10 +26,12 @@ from xen.xend.XendAPIConstants import XE
XEN_API_ON_CRASH_BEHAVIOUR
from xen.xm.opts import OptionError
from xen.util import xsconstants
+from xen.util.path import SHAREDIR
import xen.util.xsm.xsm as security
import sys
import os
+from os.path import join
import traceback
import re
@@ -75,7 +77,7 @@ class xenapi_create:
def __init__(self):
self.DEFAULT_STORAGE_REPOSITORY = get_default_SR()
- self.dtd = "/usr/share/xen/create.dtd"
+ self.dtd = join(SHAREDIR, "create.dtd")
def create(self, filename=None, document=None, skipdtd=False):
"""
--
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel
Simon Horman
2009-Jun-04 03:21 UTC
[Xen-devel] [patch 3/9] xm: xen-api, pass-through: Dont pass empty opts
Internally xend doesn''t know how to handle empty opts.
This code ensures that opts is only included in the sxpr
if its value will be non-empty.
Cc: Dexuan Cui <dexuan.cui@intel.com>
Cc: Masaki Kanno <kanno.masaki@jp.fujitsu.com>
Signed-off-by: Simon Horman <horms@verge.net.au>
Index: xen-unstable.hg/tools/python/xen/xend/XendDomainInfo.py
==================================================================---
xen-unstable.hg.orig/tools/python/xen/xend/XendDomainInfo.py 2009-06-04
12:45:58.000000000 +1000
+++ xen-unstable.hg/tools/python/xen/xend/XendDomainInfo.py 2009-06-04
12:46:06.000000000 +1000
@@ -39,7 +39,7 @@ from xen.util import asserts, auxbin
from xen.util.blkif import blkdev_uname_to_file, blkdev_uname_to_taptype
import xen.util.xsm.xsm as security
from xen.util import xsconstants
-from xen.util.pci import serialise_pci_opts
+from xen.util.pci import serialise_pci_opts, pci_opts_list_to_spx
from xen.xend import balloon, sxp, uuid, image, arch
from xen.xend import XendOptions, XendNode, XendConfig
@@ -3771,23 +3771,21 @@ class XendDomainInfo:
opts_dict = xenapi_pci.get(''options'')
for k in opts_dict.keys():
dpci_opts.append([k, opts_dict[k]])
+ opts_sxp = pci_opts_list_to_spx(dpci_opts)
# Convert xenapi to sxp
ppci = XendAPIStore.get(xenapi_pci.get(''PPCI''),
''PPCI'')
- target_pci_sxp = \
- [''pci'',
- [''dev'',
- [''domain'', ''0x%02x'' %
ppci.get_domain()],
- [''bus'', ''0x%02x'' %
ppci.get_bus()],
- [''slot'', ''0x%02x'' %
ppci.get_slot()],
- [''func'', ''0x%1x'' %
ppci.get_func()],
- [''vslot'', ''0x%02x'' %
xenapi_pci.get(''hotplug_slot'')],
- [''opts'', dpci_opts],
- [''uuid'', dpci_uuid]
- ],
- [''state'', ''Initialising'']
- ]
+ dev_sxp = [''dev'',
+ [''domain'', ''0x%02x'' %
ppci.get_domain()],
+ [''bus'', ''0x%02x'' %
ppci.get_bus()],
+ [''slot'', ''0x%02x'' %
ppci.get_slot()],
+ [''func'', ''0x%1x'' %
ppci.get_func()],
+ [''vslot'', ''0x%02x'' %
xenapi_pci.get(''hotplug_slot'')],
+ [''uuid'', dpci_uuid]]
+ dev_sxp = sxp.merge(dev_sxp, opts_sxp)
+
+ target_pci_sxp = [''pci'', dev_sxp,
[''state'', ''Initialising''] ]
if self._stateGet() != XEN_API_VM_POWER_STATE_RUNNING:
Index: xen-unstable.hg/tools/python/xen/util/pci.py
==================================================================---
xen-unstable.hg.orig/tools/python/xen/util/pci.py 2009-06-04 12:40:28.000000000
+1000
+++ xen-unstable.hg/tools/python/xen/util/pci.py 2009-06-04 12:46:06.000000000
+1000
@@ -120,6 +120,9 @@ def serialise_pci_opts(opts):
def split_pci_opts(opts):
return map(lambda x: x.split(''=''),
opts.split('',''))
+def pci_opts_list_to_spx(list):
+ [''dev''] + map(lambda x: [''opts'', x],
list)
+
def parse_hex(val):
try:
if isinstance(val, types.StringTypes):
--
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel
Simon Horman
2009-Jun-04 03:21 UTC
[Xen-devel] [patch 4/9] xend: pass-through: prefix vslot with 0x in device configration
I don''t know of the historical reasons for this, but by convention
hex values are stored without a leading ''0x'' in the backend
and
with a leading ''0x'' in the device configuration.
This patch also removes handling of the case where vslot is missing
from the backend, should never occur.
Cc: Dexuan Cui <dexuan.cui@intel.com>
Cc: Masaki Kanno <kanno.masaki@jp.fujitsu.com>
Signed-off-by: Simon Horman <horms@verge.net.au>
Index: xen-unstable.hg/tools/python/xen/xend/server/pciif.py
==================================================================---
xen-unstable.hg.orig/tools/python/xen/xend/server/pciif.py 2009-06-03
14:31:05.000000000 +1000
+++ xen-unstable.hg/tools/python/xen/xend/server/pciif.py 2009-06-03
14:31:45.000000000 +1000
@@ -191,11 +191,8 @@ class PciController(DevController):
# Per device uuid info
dev_dict[''uuid''] = self.readBackend(devid,
''uuid-%d'' % i)
- vslot = self.readBackend(devid, ''vslot-%d'' %
i)
- if vslot != None:
- dev_dict[''vslot''] =
self.readBackend(devid, ''vslot-%d'' % i)
- else:
- dev_dict[''vslot''] = AUTO_PHP_SLOT_STR
+ dev_dict[''vslot''] = ''0x%s''
% \
+ self.readBackend(devid,
''vslot-%d'' % i)
#append opts info
opts = self.readBackend(devid, ''opts-%d'' % i)
--
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel
Simon Horman
2009-Jun-04 03:21 UTC
[Xen-devel] [patch 5/9] xm, xend: xen-api: DPCI.get_hotplug_slot() returns a decimal
xm uses the following code to read pci information using Xen API:
ppci_ref = server.xenapi.DPCI.get_PPCI(dpci_ref)
ppci_record = server.xenapi.PPCI.get_record(ppci_ref)
dev = {
"domain": int(ppci_record["domain"]),
"bus": int(ppci_record["bus"]),
"slot": int(ppci_record["slot"]),
"func": int(ppci_record["func"]),
"vslot": int(server.xenapi.DPCI.get_hotplug_slot(dpci_ref))
}
As the domain, bus, slot and func values are returned as string
representations of decimal, it makes sense for get_hotplug_slot() to also
return string representations of decimal.
As it is, the int() conversion will break cause xm to fail with
an error if the vslot is in the range 0xa-0xf or 0x1a-0x1f.
$ xm pci-list debian
Error: Invalid argument.
And the int() conversion will return the wrong value if
the vslot is in the range 0x10-0x19.
This patch also alters XendDPCI to store hotplug_vslot as an integer
rather than a string. This is consitent with the way other
values are stored inside XendDPCI.
get_hotplug_slot() returning a string is not consistent
with other calls inside XendDPCI, which return integers.
Cc: Dexuan Cui <dexuan.cui@intel.com>
Cc: Masaki Kanno <kanno.masaki@jp.fujitsu.com>
Signed-off-by: Simon Horman <horms@verge.net.au>
Index: xen-unstable.hg/tools/python/xen/xend/XendDPCI.py
==================================================================---
xen-unstable.hg.orig/tools/python/xen/xend/XendDPCI.py 2009-06-03
15:03:10.000000000 +1000
+++ xen-unstable.hg/tools/python/xen/xend/XendDPCI.py 2009-06-03
15:04:10.000000000 +1000
@@ -119,7 +119,7 @@ class XendDPCI(XendBase):
self.VM = record[''VM'']
self.PPCI = record[''PPCI'']
- self.hotplug_slot = record[''hotplug_slot'']
+ self.hotplug_slot = int(record[''hotplug_slot''], 16)
if ''options'' in record.keys():
self.options = record[''options'']
@@ -153,7 +153,7 @@ class XendDPCI(XendBase):
return self.PPCI
def get_hotplug_slot(self):
- return self.hotplug_slot
+ return "%d" % self.hotplug_slot
def get_options(self):
return self.options
--
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel
Simon Horman
2009-Jun-04 03:21 UTC
[Xen-devel] [patch 6/9] xend: xen-api, pass-through: Add create_dpci_from_sxp()
Move some duplicated code into create_dpci_from_sxp()
Cc: Dexuan Cui <dexuan.cui@intel.com>
Cc: Masaki Kanno <kanno.masaki@jp.fujitsu.com>
Signed-off-by: Simon Horman <horms@verge.net.au>
Index: xen-unstable.hg/tools/python/xen/xend/XendConfig.py
==================================================================---
xen-unstable.hg.orig/tools/python/xen/xend/XendConfig.py 2009-06-03
16:30:59.000000000 +1000
+++ xen-unstable.hg/tools/python/xen/xend/XendConfig.py 2009-06-04
08:27:04.000000000 +1000
@@ -1221,7 +1221,29 @@ class XendConfig(dict):
raise XendConfigError(''The mac "%s"
is already defined'' %
dev_mac)
return None
-
+
+ def create_dpci_from_sxp(self, pci_devs):
+ for pci_dev in pci_devs:
+ dpci_uuid = pci_dev.get(''uuid'')
+ log.debug("create_dpci_from_sxp: %s" % pci_dev)
+ ppci_uuid =
XendPPCI.get_by_sbdf(pci_dev[''domain''],
+ pci_dev[''bus''],
+ pci_dev[''slot''],
+ pci_dev[''func''])
+ if ppci_uuid is None:
+ continue
+ dpci_record = {
+ ''VM'': self[''uuid''],
+ ''PPCI'': ppci_uuid,
+ ''hotplug_slot'':
pci_dev.get(''vslot'', 0)
+ }
+
+ dpci_opts = pci_dev.get(''opts'')
+ if dpci_opts and len(dpci_opts) > 0:
+ dpci_record[''options''] = dpci_opts
+
+ XendDPCI(dpci_uuid, dpci_record)
+
def device_add(self, dev_type, cfg_sxp = None, cfg_xenapi = None,
target = None):
"""Add a device configuration in SXP format or XenAPI
struct format.
@@ -1276,25 +1298,7 @@ class XendConfig(dict):
pci_devs = pci_dict[''devs'']
# create XenAPI DPCI objects.
- for pci_dev in pci_devs:
- dpci_uuid = pci_dev.get(''uuid'')
- ppci_uuid =
XendPPCI.get_by_sbdf(pci_dev[''domain''],
-
pci_dev[''bus''],
-
pci_dev[''slot''],
-
pci_dev[''func''])
- if ppci_uuid is None:
- continue
- dpci_record = {
- ''VM'': self[''uuid''],
- ''PPCI'': ppci_uuid,
- ''hotplug_slot'':
pci_dev.get(''vslot'', 0)
- }
-
- dpci_opts = pci_dev.get(''opts'')
- if dpci_opts and len(dpci_opts) > 0:
- dpci_record[''options''] = dpci_opts
-
- XendDPCI(dpci_uuid, dpci_record)
+ self.create_dpci_from_sxp(pci_devs)
target[''devices''][pci_devs_uuid] = (dev_type,
{''devs'':
pci_devs,
@@ -1846,25 +1850,7 @@ class XendConfig(dict):
XendAPIStore.deregister(dpci_uuid, "DPCI")
# create XenAPI DPCI objects.
- for pci_dev in pci_devs:
- dpci_uuid = pci_dev.get(''uuid'')
- ppci_uuid =
XendPPCI.get_by_sbdf(pci_dev[''domain''],
-
pci_dev[''bus''],
-
pci_dev[''slot''],
-
pci_dev[''func''])
- if ppci_uuid is None:
- continue
- dpci_record = {
- ''VM'': self[''uuid''],
- ''PPCI'': ppci_uuid,
- ''hotplug_slot'':
pci_dev.get(''vslot'', 0)
- }
-
- dpci_opts = pci_dev.get(''opts'')
- if dpci_opts and len(dpci_opts) > 0:
- dpci_record[''options''] = dpci_opts
-
- XendDPCI(dpci_uuid, dpci_record)
+ self.create_dpci_from_sxp(pci_devs)
self[''devices''][dev_uuid] = (dev_type,
{''devs'':
pci_devs,
--
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel
Simon Horman
2009-Jun-04 03:21 UTC
[Xen-devel] [patch 7/9] xm: xen-api, pass-through: create: Use vslot for hotplug_slot
Using func for hotplug_slot is not correct, although func is often zero,
previously zero meant please pick a vslot and asking xend to pick a vslot
was the only method available.
This resolves the following error when using Xen API:
$ xm create hvm.conf
...
Internal error: Timed out waiting for device model action.
Cc: Dexuan Cui <dexuan.cui@intel.com>
Cc: Masaki Kanno <kanno.masaki@jp.fujitsu.com>
Signed-off-by: Simon Horman <horms@verge.net.au>
Index: xen-unstable.hg/tools/python/xen/xm/xenapi_create.py
==================================================================---
xen-unstable.hg.orig/tools/python/xen/xm/xenapi_create.py 2009-06-04
08:30:35.000000000 +1000
+++ xen-unstable.hg/tools/python/xen/xm/xenapi_create.py 2009-06-04
08:31:01.000000000 +1000
@@ -539,7 +539,7 @@ class xenapi_create:
"PPCI":
target_ref,
"hotplug_slot":
- int(pci.attributes["func"].value, 16),
+ int(pci.attributes["vslot"].value, 16),
"options":
get_child_nodes_as_dict(pci,
"pci_opt", "key", "value")
--
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel
Simon Horman
2009-Jun-04 03:21 UTC
[Xen-devel] [patch 8/9] xend: pass-through: Use AUTO_PHP_SLOT as unknown vslot
This fixes a few cases where 0 is still used for an known vslot.
Cc: Dexuan Cui <dexuan.cui@intel.com>
Cc: Masaki Kanno <kanno.masaki@jp.fujitsu.com>
Signed-off-by: Simon Horman <horms@verge.net.au>
Index: xen-unstable.hg/tools/python/xen/xend/server/pciif.py
==================================================================---
xen-unstable.hg.orig/tools/python/xen/xend/server/pciif.py 2009-06-04
08:28:46.000000000 +1000
+++ xen-unstable.hg/tools/python/xen/xend/server/pciif.py 2009-06-04
08:28:54.000000000 +1000
@@ -74,7 +74,8 @@ class PciController(DevController):
bus = parse_hex(pci_config.get(''bus'', 0))
slot = parse_hex(pci_config.get(''slot'', 0))
func = parse_hex(pci_config.get(''func'', 0))
- vslot = parse_hex(pci_config.get(''vslot'', 0))
+ vslot = parse_hex(pci_config.get(''vslot'',
+ ''0x'' +
AUTO_PHP_SLOT_STR))
if pci_config.has_key(''opts''):
opts = serialise_pci_opts(pci_config[''opts''])
Index: xen-unstable.hg/tools/python/xen/xend/XendConfig.py
==================================================================---
xen-unstable.hg.orig/tools/python/xen/xend/XendConfig.py 2009-06-04
08:28:46.000000000 +1000
+++ xen-unstable.hg/tools/python/xen/xend/XendConfig.py 2009-06-04
08:28:54.000000000 +1000
@@ -31,7 +31,7 @@ from xen.xend.XendDSCSI import XendDSCSI
from xen.xend.XendError import VmError
from xen.xend.XendDevices import XendDevices
from xen.xend.PrettyPrint import prettyprintstring
-from xen.xend.XendConstants import DOM_STATE_HALTED
+from xen.xend.XendConstants import DOM_STATE_HALTED, AUTO_PHP_SLOT_STR
from xen.xend.xenstore.xstransact import xstransact
from xen.xend.server.BlktapController import blktap_disk_types
from xen.xend.server.netif import randomMAC
@@ -1235,7 +1235,8 @@ class XendConfig(dict):
dpci_record = {
''VM'': self[''uuid''],
''PPCI'': ppci_uuid,
- ''hotplug_slot'':
pci_dev.get(''vslot'', 0)
+ ''hotplug_slot'':
pci_dev.get(''vslot'',
+ ''0x'' + AUTO_PHP_SLOT_STR)
}
dpci_opts = pci_dev.get(''opts'')
--
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel
Simon Horman
2009-Jun-04 03:21 UTC
[Xen-devel] [patch 9/9] xm: pass-through: sort the output of xm pci-list
Other than being arguably more human readable,
this patch reconciles the output differences between
using Xen API and xmlrpc to manipulate domains.
Cc: Dexuan Cui <dexuan.cui@intel.com>
Cc: Masaki Kanno <kanno.masaki@jp.fujitsu.com>
Signed-off-by: Simon Horman <horms@verge.net.au>
Index: xen-unstable.hg/tools/python/xen/util/pci.py
==================================================================---
xen-unstable.hg.orig/tools/python/xen/util/pci.py 2009-06-04 09:34:36.000000000
+1000
+++ xen-unstable.hg/tools/python/xen/util/pci.py 2009-06-04 09:35:10.000000000
+1000
@@ -114,6 +114,10 @@ PAGE_MASK=~(PAGE_SIZE - 1)
def PCI_DEVFN(slot, func):
return ((((slot) & 0x1f) << 3) | ((func) & 0x07))
+def PCI_BDF(domain, bus, slot, func):
+ return (((domain & 0xffff) << 16) | ((bus & 0xff) << 8)
|
+ PCI_DEVFN(slot, func))
+
def serialise_pci_opts(opts):
return reduce(lambda x, y: x+'',''+y, map(lambda (x, y):
x+''=''+y, opts))
Index: xen-unstable.hg/tools/python/xen/xm/main.py
==================================================================---
xen-unstable.hg.orig/tools/python/xen/xm/main.py 2009-06-04 09:33:27.000000000
+1000
+++ xen-unstable.hg/tools/python/xen/xm/main.py 2009-06-04 11:03:13.000000000
+1000
@@ -2205,6 +2205,9 @@ def xm_pci_list(args):
if len(devs) == 0:
return
+ devs.sort(None, lambda x: x[''vslot''] << 32 |
PCI_BDF(x[''domain''], x[''bus''],
+
x[''slot''], x[''func'']))
+
has_vslot = False
for x in devs:
if x[''vslot''] == AUTO_PHP_SLOT:
--
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel
Masaki Kanno
2009-Jun-04 04:18 UTC
Re: [Xen-devel] [patch 6/9] xend: xen-api, pass-through: Add create_dpci_from_sxp()
Hi Simon,
Good job!!
This line includes Tab indent.
+ log.debug("create_dpci_from_sxp: %s" % pci_dev)
Best regards,
Kan
Thu, 04 Jun 2009 13:21:21 +1000, Simon Horman wrote:
>Move some duplicated code into create_dpci_from_sxp()
>
>Cc: Dexuan Cui <dexuan.cui@intel.com>
>Cc: Masaki Kanno <kanno.masaki@jp.fujitsu.com>
>Signed-off-by: Simon Horman <horms@verge.net.au>
>
>Index: xen-unstable.hg/tools/python/xen/xend/XendConfig.py
>==================================================================>---
xen-unstable.hg.orig/tools/python/xen/xend/XendConfig.py 2009-06-03 16:
>30:59.000000000 +1000
>+++ xen-unstable.hg/tools/python/xen/xend/XendConfig.py 2009-06-04 08:
27:04>.000000000 +1000
>@@ -1221,7 +1221,29 @@ class XendConfig(dict):
> raise XendConfigError(''The mac
"%s" is already
>defined'' %
> dev_mac)
> return None
>-
>+
>+ def create_dpci_from_sxp(self, pci_devs):
>+ for pci_dev in pci_devs:
>+ dpci_uuid = pci_dev.get(''uuid'')
>+ log.debug("create_dpci_from_sxp: %s" % pci_dev)
>+ ppci_uuid =
XendPPCI.get_by_sbdf(pci_dev[''domain''],
>+
pci_dev[''bus''],
>+
pci_dev[''slot''],
>+
pci_dev[''func''])
>+ if ppci_uuid is None:
>+ continue
>+ dpci_record = {
>+ ''VM'': self[''uuid''],
>+ ''PPCI'': ppci_uuid,
>+ ''hotplug_slot'':
pci_dev.get(''vslot'', 0)
>+ }
>+
>+ dpci_opts = pci_dev.get(''opts'')
>+ if dpci_opts and len(dpci_opts) > 0:
>+ dpci_record[''options''] = dpci_opts
>+
>+ XendDPCI(dpci_uuid, dpci_record)
>+
> def device_add(self, dev_type, cfg_sxp = None, cfg_xenapi = None,
> target = None):
> """Add a device configuration in SXP format or
XenAPI struct format.
>@@ -1276,25 +1298,7 @@ class XendConfig(dict):
> pci_devs = pci_dict[''devs'']
>
> # create XenAPI DPCI objects.
>- for pci_dev in pci_devs:
>- dpci_uuid = pci_dev.get(''uuid'')
>- ppci_uuid =
XendPPCI.get_by_sbdf(pci_dev[''domain''],
>-
pci_dev[''bus''],
>-
pci_dev[''slot''],
>-
pci_dev[''func''])
>- if ppci_uuid is None:
>- continue
>- dpci_record = {
>- ''VM'':
self[''uuid''],
>- ''PPCI'': ppci_uuid,
>- ''hotplug_slot'':
pci_dev.get(''vslot'', 0)
>- }
>-
>- dpci_opts = pci_dev.get(''opts'')
>- if dpci_opts and len(dpci_opts) > 0:
>- dpci_record[''options''] =
dpci_opts
>-
>- XendDPCI(dpci_uuid, dpci_record)
>+ self.create_dpci_from_sxp(pci_devs)
>
> target[''devices''][pci_devs_uuid] =
(dev_type,
>
{''devs'': pci_devs,
>@@ -1846,25 +1850,7 @@ class XendConfig(dict):
> XendAPIStore.deregister(dpci_uuid, "DPCI")
>
> # create XenAPI DPCI objects.
>- for pci_dev in pci_devs:
>- dpci_uuid = pci_dev.get(''uuid'')
>- ppci_uuid =
XendPPCI.get_by_sbdf(pci_dev[''domain''],
>-
pci_dev[''bus''],
>-
pci_dev[''slot''],
>-
pci_dev[''func''])
>- if ppci_uuid is None:
>- continue
>- dpci_record = {
>- ''VM'':
self[''uuid''],
>- ''PPCI'': ppci_uuid,
>- ''hotplug_slot'':
pci_dev.get(''vslot'', 0)
>- }
>-
>- dpci_opts = pci_dev.get(''opts'')
>- if dpci_opts and len(dpci_opts) > 0:
>- dpci_record[''options''] =
dpci_opts
>-
>- XendDPCI(dpci_uuid, dpci_record)
>+ self.create_dpci_from_sxp(pci_devs)
>
> self[''devices''][dev_uuid] = (dev_type,
> {''devs'':
pci_devs,
>
>--
>
>_______________________________________________
>Xen-devel mailing list
>Xen-devel@lists.xensource.com
>http://lists.xensource.com/xen-devel
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel
Masaki Kanno
2009-Jun-04 04:22 UTC
Re: [Xen-devel] [patch 8/9] xend: pass-through: Use AUTO_PHP_SLOT asunknown vslot
Hi Simon, These line include Tab indent. pciif.py: + ''0x'' + AUTO_PHP_SLOT_STR)) XendConfig.py: + ''0x'' + AUTO_PHP_SLOT_STR) Best regards, Kan Thu, 04 Jun 2009 13:21:23 +1000, Simon Horman wrote:>This fixes a few cases where 0 is still used for an known vslot. > >Cc: Dexuan Cui <dexuan.cui@intel.com> >Cc: Masaki Kanno <kanno.masaki@jp.fujitsu.com> >Signed-off-by: Simon Horman <horms@verge.net.au> > >Index: xen-unstable.hg/tools/python/xen/xend/server/pciif.py >==================================================================>--- xen-unstable.hg.orig/tools/python/xen/xend/server/pciif.py 2009-06-04 >08:28:46.000000000 +1000 >+++ xen-unstable.hg/tools/python/xen/xend/server/pciif.py 2009-06-04 08:28:>54.000000000 +1000 >@@ -74,7 +74,8 @@ class PciController(DevController): > bus = parse_hex(pci_config.get(''bus'', 0)) > slot = parse_hex(pci_config.get(''slot'', 0)) > func = parse_hex(pci_config.get(''func'', 0)) >- vslot = parse_hex(pci_config.get(''vslot'', 0)) >+ vslot = parse_hex(pci_config.get(''vslot'', >+ ''0x'' + AUTO_PHP_SLOT_STR)) > > if pci_config.has_key(''opts''): > opts = serialise_pci_opts(pci_config[''opts'']) >Index: xen-unstable.hg/tools/python/xen/xend/XendConfig.py >==================================================================>--- xen-unstable.hg.orig/tools/python/xen/xend/XendConfig.py 2009-06-04 08: >28:46.000000000 +1000 >+++ xen-unstable.hg/tools/python/xen/xend/XendConfig.py 2009-06-04 08:28:54>.000000000 +1000 >@@ -31,7 +31,7 @@ from xen.xend.XendDSCSI import XendDSCSI > from xen.xend.XendError import VmError > from xen.xend.XendDevices import XendDevices > from xen.xend.PrettyPrint import prettyprintstring >-from xen.xend.XendConstants import DOM_STATE_HALTED >+from xen.xend.XendConstants import DOM_STATE_HALTED, AUTO_PHP_SLOT_STR > from xen.xend.xenstore.xstransact import xstransact > from xen.xend.server.BlktapController import blktap_disk_types > from xen.xend.server.netif import randomMAC >@@ -1235,7 +1235,8 @@ class XendConfig(dict): > dpci_record = { > ''VM'': self[''uuid''], > ''PPCI'': ppci_uuid, >- ''hotplug_slot'': pci_dev.get(''vslot'', 0) >+ ''hotplug_slot'': pci_dev.get(''vslot'', >+ ''0x'' + AUTO_PHP_SLOT_STR) > } > > dpci_opts = pci_dev.get(''opts'') > >-- > >_______________________________________________ >Xen-devel mailing list >Xen-devel@lists.xensource.com >http://lists.xensource.com/xen-devel_______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Simon Horman
2009-Jun-04 06:53 UTC
[Xen-devel] [patch v2] xend: pass-through: Use AUTO_PHP_SLOT as unknown vslot
This fixes a few cases where 0 is still used for an known vslot.
Cc: Dexuan Cui <dexuan.cui@intel.com>
Cc: Masaki Kanno <kanno.masaki@jp.fujitsu.com>
Signed-off-by: Simon Horman <horms@verge.net.au>
---
* Updated to use spaces instead of tabs for indentation
Index: xen-unstable.hg/tools/python/xen/xend/server/pciif.py
==================================================================---
xen-unstable.hg.orig/tools/python/xen/xend/server/pciif.py 2009-06-04
08:28:46.000000000 +1000
+++ xen-unstable.hg/tools/python/xen/xend/server/pciif.py 2009-06-04
08:28:54.000000000 +1000
@@ -74,7 +74,8 @@ class PciController(DevController):
bus = parse_hex(pci_config.get(''bus'', 0))
slot = parse_hex(pci_config.get(''slot'', 0))
func = parse_hex(pci_config.get(''func'', 0))
- vslot = parse_hex(pci_config.get(''vslot'', 0))
+ vslot = parse_hex(pci_config.get(''vslot'',
+ ''0x'' +
AUTO_PHP_SLOT_STR))
if pci_config.has_key(''opts''):
opts = serialise_pci_opts(pci_config[''opts''])
Index: xen-unstable.hg/tools/python/xen/xend/XendConfig.py
==================================================================---
xen-unstable.hg.orig/tools/python/xen/xend/XendConfig.py 2009-06-04
08:28:46.000000000 +1000
+++ xen-unstable.hg/tools/python/xen/xend/XendConfig.py 2009-06-04
08:28:54.000000000 +1000
@@ -31,7 +31,7 @@ from xen.xend.XendDSCSI import XendDSCSI
from xen.xend.XendError import VmError
from xen.xend.XendDevices import XendDevices
from xen.xend.PrettyPrint import prettyprintstring
-from xen.xend.XendConstants import DOM_STATE_HALTED
+from xen.xend.XendConstants import DOM_STATE_HALTED, AUTO_PHP_SLOT_STR
from xen.xend.xenstore.xstransact import xstransact
from xen.xend.server.BlktapController import blktap_disk_types
from xen.xend.server.netif import randomMAC
@@ -1235,7 +1235,8 @@ class XendConfig(dict):
dpci_record = {
''VM'': self[''uuid''],
''PPCI'': ppci_uuid,
- ''hotplug_slot'':
pci_dev.get(''vslot'', 0)
+ ''hotplug_slot'':
pci_dev.get(''vslot'',
+ ''0x'' +
AUTO_PHP_SLOT_STR)
}
dpci_opts = pci_dev.get(''opts'')
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel
Simon Horman
2009-Jun-04 06:53 UTC
Re: [Xen-devel] [patch 8/9] xend: pass-through: Use AUTO_PHP_SLOT asunknown vslot
On Thu, Jun 04, 2009 at 01:22:37PM +0900, Masaki Kanno wrote:> Hi Simon, > > These line include Tab indent. > > pciif.py: > + ''0x'' + AUTO_PHP_SLOT_STR)) > > XendConfig.py: > + ''0x'' + AUTO_PHP_SLOT_STR) >Thanks, I have posted a new version without tabs. _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Simon Horman
2009-Jun-04 06:56 UTC
Re: [Xen-devel] [patch 6/9] xend: xen-api, pass-through: Add create_dpci_from_sxp()
On Thu, Jun 04, 2009 at 01:18:30PM +0900, Masaki Kanno wrote:> Hi Simon, > > Good job!! > > This line includes Tab indent. > > + log.debug("create_dpci_from_sxp: %s" % pci_dev)Thanks, I will remove that line and re-post. _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Simon Horman
2009-Jun-04 06:57 UTC
[Xen-devel] [patch v2] xend: xen-api, pass-through: Add create_dpci_from_sxp()
Move some duplicated code into create_dpci_from_sxp()
Cc: Dexuan Cui <dexuan.cui@intel.com>
Cc: Masaki Kanno <kanno.masaki@jp.fujitsu.com>
Signed-off-by: Simon Horman <horms@verge.net.au>
---
* v2: Updated to remove spurious debug message
Index: xen-unstable.hg/tools/python/xen/xend/XendConfig.py
==================================================================---
xen-unstable.hg.orig/tools/python/xen/xend/XendConfig.py 2009-06-03
16:30:59.000000000 +1000
+++ xen-unstable.hg/tools/python/xen/xend/XendConfig.py 2009-06-04
08:27:04.000000000 +1000
@@ -1221,7 +1221,28 @@ class XendConfig(dict):
raise XendConfigError(''The mac "%s"
is already defined'' %
dev_mac)
return None
-
+
+ def create_dpci_from_sxp(self, pci_devs):
+ for pci_dev in pci_devs:
+ dpci_uuid = pci_dev.get(''uuid'')
+ ppci_uuid =
XendPPCI.get_by_sbdf(pci_dev[''domain''],
+ pci_dev[''bus''],
+ pci_dev[''slot''],
+ pci_dev[''func''])
+ if ppci_uuid is None:
+ continue
+ dpci_record = {
+ ''VM'': self[''uuid''],
+ ''PPCI'': ppci_uuid,
+ ''hotplug_slot'':
pci_dev.get(''vslot'', 0)
+ }
+
+ dpci_opts = pci_dev.get(''opts'')
+ if dpci_opts and len(dpci_opts) > 0:
+ dpci_record[''options''] = dpci_opts
+
+ XendDPCI(dpci_uuid, dpci_record)
+
def device_add(self, dev_type, cfg_sxp = None, cfg_xenapi = None,
target = None):
"""Add a device configuration in SXP format or XenAPI
struct format.
@@ -1276,25 +1298,7 @@ class XendConfig(dict):
pci_devs = pci_dict[''devs'']
# create XenAPI DPCI objects.
- for pci_dev in pci_devs:
- dpci_uuid = pci_dev.get(''uuid'')
- ppci_uuid =
XendPPCI.get_by_sbdf(pci_dev[''domain''],
-
pci_dev[''bus''],
-
pci_dev[''slot''],
-
pci_dev[''func''])
- if ppci_uuid is None:
- continue
- dpci_record = {
- ''VM'': self[''uuid''],
- ''PPCI'': ppci_uuid,
- ''hotplug_slot'':
pci_dev.get(''vslot'', 0)
- }
-
- dpci_opts = pci_dev.get(''opts'')
- if dpci_opts and len(dpci_opts) > 0:
- dpci_record[''options''] = dpci_opts
-
- XendDPCI(dpci_uuid, dpci_record)
+ self.create_dpci_from_sxp(pci_devs)
target[''devices''][pci_devs_uuid] = (dev_type,
{''devs'':
pci_devs,
@@ -1846,25 +1850,7 @@ class XendConfig(dict):
XendAPIStore.deregister(dpci_uuid, "DPCI")
# create XenAPI DPCI objects.
- for pci_dev in pci_devs:
- dpci_uuid = pci_dev.get(''uuid'')
- ppci_uuid =
XendPPCI.get_by_sbdf(pci_dev[''domain''],
-
pci_dev[''bus''],
-
pci_dev[''slot''],
-
pci_dev[''func''])
- if ppci_uuid is None:
- continue
- dpci_record = {
- ''VM'': self[''uuid''],
- ''PPCI'': ppci_uuid,
- ''hotplug_slot'':
pci_dev.get(''vslot'', 0)
- }
-
- dpci_opts = pci_dev.get(''opts'')
- if dpci_opts and len(dpci_opts) > 0:
- dpci_record[''options''] = dpci_opts
-
- XendDPCI(dpci_uuid, dpci_record)
+ self.create_dpci_from_sxp(pci_devs)
self[''devices''][dev_uuid] = (dev_type,
{''devs'':
pci_devs,
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel