Skip to contentSkip to conversation

blktap2: Remove set() for Python 2.3

PATCH In review KUWAMURA Shin'ya 4 participants 6 messages Jul 17, 2009 – Jul 24, 2009

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 blktap2: Remove set() for Python 2.3

Hi,

This removes set() for Python 2.3, since set() is added from Python 2.4.

Signature · 1 line
  KUWAMURA Shin'ya

# HG changeset patch
# User KUWAMURA Shin'ya <[email protected]> # Date 1247803999 -32400
# Node ID a32f75dd8932f2301247009172915f1a1c380c89 # Parent 63b8d3d7aa8e88a06c734f94e0a399602e1bbfa7
blktap2: Remove set() for Python 2.3

set() is removed for Python 2.3.

tools/python/xen/xend/server/BlktapController.py +5 -5
diff -r 63b8d3d7aa8e -r a32f75dd8932 tools/python/xen/xend/server/BlktapController.py
@@ -13,7 +13,7 @@ TAPDISK_DEVICE  = '/dev/xen/blktap-2/tap
 TAPDISK_DEVICE  = '/dev/xen/blktap-2/tapdev'
 TAPDISK_CONTROL = TAPDISK_SYSFS + '/blktap'
 
-blktap1_disk_types = set([
+blktap1_disk_types = [
     'aio',
     'sync',
     'vmdk',
@@ -21,16 +21,16 @@ blktap1_disk_types = set([
     'qcow',
     'qcow2',
     'ioemu',
-    ])
+    ]
 
-blktap2_disk_types = set([
+blktap2_disk_types = [
     'aio',
     'ram',
     'qcow',
     'vhd',
-    ])
+    ]
 
-blktap_disk_types = blktap1_disk_types | blktap2_disk_types
+blktap_disk_types = blktap1_disk_types + blktap2_disk_types
 
 def doexec(args, inputtext=None):
     """Execute a subprocess, then return its return code, stdout and stderr"""

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

Acked-by on v1 1/1
#1 lore raw

KUWAMURA Shin'ya writes ("[Xen-devel] [PATCH] blktap2: Remove set() for Python 2.3"):

Quoted 1 line

This removes set() for Python 2.3, since set() is added from Python 2.4.

This looks reasonable to me, although I haven't tested it.

Ian.

#2 lore raw
In reply to KUWAMURA Shin'ya
Quoted 3 lines · KUWAMURA Shin'ya

Hi,

This removes set() for Python 2.3, since set() is added from Python 2.4.

set() seems to be used in a number of other places in the code. Is that a problem?

# grep -r [^a-z_]set\( tools/python/xen/
tools/python/xen/util/acmpolicy.py:            bad_renamings = set(vmlabel_map.keys()) - set(oldvmnames)
tools/python/xen/util/acmpolicy.py:            bad_renamings = set(reslabel_map.keys()) - set(oldresnames)
tools/python/xen/util/acmpolicy.py:               len( set(res_stes).intersection( set(vm_stes) ) ) == 0:
tools/python/xen/util/acmpolicy.py:        unknown_ste = set()
tools/python/xen/util/acmpolicy.py:        unknown_chw = set()
tools/python/xen/util/acmpolicy.py:        if len(vmlabels) != len(set(vmlabels)) or \
tools/python/xen/util/acmpolicy.py:           len(resnames) != len(set(resnames)) or \
tools/python/xen/util/acmpolicy.py:           len(stes)     != len(set(stes))     or \
tools/python/xen/util/acmpolicy.py:           len(chws)     != len(set(chws)):
tools/python/xen/util/acmpolicy.py:                unknown_chw |= (set(chws_by_vm[v]) - set(chws))
tools/python/xen/util/acmpolicy.py:                unknown_ste |= (set(stes_by_vm[v]) - set(stes))
tools/python/xen/util/acmpolicy.py:                unknown_ste |= (set(stes_by_res[r]) - set(stes))
tools/python/xen/util/pci.py:    if len(l) != len(set(l)):
tools/python/xen/xend/XendAPI.py:            'classes' : set(),
tools/python/xen/xend/XendDomainInfo.py:        # just itterating through set(map(..., pci_devs))
tools/python/xen/xend/XendDomainInfo.py:        done = set()
tools/python/xen/xend/XendDomainInfo.py:            done |= set([key])
tools/python/xen/xend/server/DevController.py:    ev.set()
tools/python/xen/xend/server/DevController.py:    ev.set()
tools/python/xen/xend/server/DevController.py:    ev.set()
tools/python/xen/xend/server/pciif.py:        if len(pci_str_list) != len(set(pci_str_list)):
tools/python/xen/xm/labels.py:        names = list(set(names1).union(names2))
tools/python/xen/xm/main.py:        def set(keys, val):
tools/python/xen/xm/main.py:                lambda x: set(['MAC'], x),
tools/python/xen/xm/main.py:                lambda x: set(['network'], get_net_from_bridge(x)),
tools/python/xen/xm/main.py:                lambda x: set(['other_config', 'ip'], x),
tools/python/xen/xm/main.py:                lambda x: set(['other_config', 'script'], x),
tools/python/xen/xm/main.py:                lambda x: set(['other_config', 'backend'], x),
tools/python/xen/xm/main.py:                lambda x: set(['device'], x),
tools/python/xen/xm/main.py:                lambda x: set(['qos_algorithm_params', 'rate'], x),
tools/python/xen/xm/main.py:                lambda x: set(['other_config', 'accel'], x)
tools/python/xen/xm/main.py:    if len(set(vdevfns)) > 1:
tools/python/xen/xm/opts.py:        self.set(default)
tools/python/xen/xm/opts.py:        self.set(self.default)
tools/python/xen/xm/opts.py:    def set(self, value):
tools/python/xen/xm/opts.py:        self.set(v)
tools/python/xen/xm/opts.py:        return opt.set(val)
tools/python/xen/xm/opts.py:    opt.set(1)
tools/python/xen/xm/opts.py:    opt.set(0)
tools/python/xen/xm/opts.py:        opt.set(1)
tools/python/xen/xm/opts.py:        opt.set(0)
tools/python/xen/xm/opts.py:    opt.set(v)
tools/python/xen/xm/opts.py:    opt.set(v)
tools/python/xen/xm/opts.py:    opt.set(v)
tools/python/xen/xm/opts.py:    opt.set(v)
#3 lore raw

Hi,

Quoted 8 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

On Tue, 21 Jul 2009 13:41:59 +1000
[email protected](Simon Horman) said:

Quoted 1 line · KUWAMURA Shin'ya

This removes set() for Python 2.3, since set() is added from Python 2.4.

set() seems to be used in a number of other places in the code. Is that a problem?

They cause a problem only when the corresponding feature is used. # XenAPI, ACM, etc.

But starting xend failed by the following code:

Quoted 1 line

tools/python/xen/util/pci.py: if len(l) != len(set(l)):

I removed it on weekly testing ad hoc.

Best regards,

Signature · 1 line
  KUWAMURA Shin'ya
#4 lore raw

How about creating a file which includes the followings and import it?

+# for 2.3 compatibility
+try:
+ set()
+except NameError:
+ from sets import Set as set

Quoted 20 lines · KUWAMURA Shin'ya

Hi,

Quoted 8 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

On Tue, 21 Jul 2009 13:41:59 +1000
[email protected](Simon Horman) said:

Quoted 1 line · KUWAMURA Shin'ya

This removes set() for Python 2.3, since set() is added from Python 2.4.

set() seems to be used in a number of other places in the code. Is that a problem?

They cause a problem only when the corresponding feature is used. # XenAPI, ACM, etc.

But starting xend failed by the following code:

Quoted 1 line

tools/python/xen/util/pci.py: if len(l) != len(set(l)):

I removed it on weekly testing ad hoc.

Best regards,

Signature · 1 line
yamahata
#5 lore raw

Hi,

Review

Quoted 9 lines · Isaku Yamahata

How about creating a file which includes the followings and import it?

(quoted diff) +5 -0
+# for 2.3 compatibility
+try:
+    set()
+except NameError:
+    from sets import Set as set

Good! Xend can start on Python 2.3. Thank you.

Best regards,

Signature · 1 line
  KUWAMURA Shin'ya
tools/python/xen/util/pci.py +6 -0
diff -r bc3aca17cb88 tools/python/xen/util/pci.py
@@ -18,6 +18,12 @@ from xen.xend import sxp
 from xen.xend import sxp
 from xen.xend.XendConstants import AUTO_PHP_SLOT
 from xen.xend.XendSXPDev import dev_dict_to_sxp
+
+# for 2.3 compatibility
+try:
+    set()
+except NameError:
+    from sets import Set as set
 
 PROC_PCI_PATH = '/proc/bus/pci/devices'
 PROC_PCI_NUM_RESOURCES = 7

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel