On 12/15/2011 11:30 PM, Richard Yang wrote:
> On Thu, Dec 15, 2011 at 03:27:36PM +0800, Richard Yang wrote:
>> On Thu, Dec 15, 2011 at 10:05:10AM +0800, Richard Yang wrote:
>>> From: Wei Yang<[email protected]>
>>>
>>> In client/virt/virt_utils.py, we assign the ioctl command value
>>> according to its arch.
>>> ---
>>> client/virt/virt_utils.py |   50 
>>> ++++++++++++++++++++++++++++++++------------
>>> 1 files changed, 36 insertions(+), 14 deletions(-)
>>>
>>> diff --git a/client/virt/virt_utils.py b/client/virt/virt_utils.py
>>> index 7759b2d..bf9352b 100644
>>> --- a/client/virt/virt_utils.py
>>> +++ b/client/virt/virt_utils.py
>>> @@ -11,26 +11,48 @@ from autotest_lib.client.bin import utils, os_dep
>>> from autotest_lib.client.common_lib import error, logging_config
>>> from autotest_lib.client.common_lib import logging_manager, git
>>> import rss_client, aexpect
>>> +import platform
>>> +
>>> try:
>>>      import koji
>>>      KOJI_INSTALLED = True
>>> except ImportError:
>>>      KOJI_INSTALLED = False
>>>
>>> -# From include/linux/sockios.h
>>> -SIOCSIFHWADDR = 0x8924
>>> -SIOCGIFHWADDR = 0x8927
>>> -SIOCSIFFLAGS = 0x8914
>>> -SIOCGIFINDEX = 0x8933
>>> -SIOCBRADDIF = 0x89a2
>>> -# From linux/include/linux/if_tun.h
>>> -TUNSETIFF = 0x400454ca
>>> -TUNGETIFF = 0x800454d2
>>> -TUNGETFEATURES = 0x800454cf
>>> -IFF_UP = 0x1
>>> -IFF_TAP = 0x0002
>>> -IFF_NO_PI = 0x1000
>>> -IFF_VNET_HDR = 0x4000
>>> +ARCH = platform.machine()
>>> +if ARCH == "ppc64":
>>> +       # From include/linux/sockios.h
>>> +       SIOCSIFHWADDR  = 0x8924
>>> +       SIOCGIFHWADDR  = 0x8927
>>> +       SIOCSIFFLAGS   = 0x8914
>>> +       SIOCGIFINDEX   = 0x8933
>>> +       SIOCBRADDIF    = 0x89a2
>>> +       # From linux/include/linux/if_tun.h
>>> +       TUNSETIFF      = 0x800454ca
>>> +       TUNGETIFF      = 0x400454d2
>>> +       TUNGETFEATURES = 0x400454cf
>>> +       IFF_TAP        = 0x2
>>> +       IFF_NO_PI      = 0x1000
>>> +       IFF_VNET_HDR   = 0x4000
>>> +       # From linux/include/linux/if.h
>>> +       IFF_UP = 0x1
>>> +else:
>>> +       # From include/linux/sockios.h
>>> +       SIOCSIFHWADDR = 0x8924
>>> +       SIOCGIFHWADDR = 0x8927
>>> +       SIOCSIFFLAGS = 0x8914
>>> +       SIOCGIFINDEX = 0x8933
>>> +       SIOCBRADDIF = 0x89a2
>>> +       # From linux/include/linux/if_tun.h
>>> +       TUNSETIFF = 0x400454ca
>>> +       TUNGETIFF = 0x800454d2
>>> +       TUNGETFEATURES = 0x800454cf
>>> +       IFF_TAP = 0x0002
>>> +       IFF_NO_PI = 0x1000
>>> +       IFF_VNET_HDR = 0x4000
>>> +       # From linux/include/linux/if.h
>>> +       IFF_UP = 0x1
>>> +
>>>
>>> def _lock_file(filename):
>>>      f = open(filename, "w")
>>> --
>>> 1.7.7
> Forgot to copy Lucas.
>
> Lucas
>
> Actually I think this method is not perfect.
> If the header file is changed or someone use Autotest on other platform
> then the value is not correct again.
>
> I have two proposal:
> 1. use ctypes to export functions and in the virt_utils.py assign the
>     value by those functions.
> 2. use a script and gcc -E and awk to produce a file with the
>     assignment. Then let virt_utils.py to include this file.
>
> I think these step could be done in the get_started.py. So this will not
> add extra steps when users want to use autotest.
>
> One issue I can't solve is how to generate the ".so" or script on the client
> when KVM Autotest is run in the servier mode.
> How could server compile or copy the file to client?

Let's keep it simple and use the approach taken on the patch you sent. 
If more people do need that for their own archs, the'll send patches to 
the mailing list... Now, by looking at your patch, the only value 
different among the 2 archs is:

IFF_TAP        = 0x2

am I correct? If so, we could only have that particular value to change 
among architecture, saving  some lines of code.

_______________________________________________
Autotest mailing list
[email protected]
http://test.kernel.org/cgi-bin/mailman/listinfo/autotest

Reply via email to