On 01/03/2012 02:55 AM, madhuri appana wrote:
> Hi cleber,
>
> The ultimate idea is to build qemu and kernel using the git repo.

I see.

>
> So please add a comment in tests.cfg that
> # As for the defaults:
> # * qemu and qemu-img are expected to be found under /usr/bin/qemu-kvm
> and
> #   /usr/bin/qemu-img respectively.

Do you think those comments are needed? I mean, we already have these 
assignments:

    - @qemu_kvm_9p_export:
         qemu_binary = /usr/bin/qemu-kvm
         qemu_img_binary = /usr/bin/qemu-img
         qemu_io_binary = /usr/bin/qemu-io

> # * qemu and qemu-img are expected to be found
> under ./install_root/bin/qemu-system-x86_64 and
> #   ./install_root/bin/qemu-img respectively if qemu is build from git
> repo in build.cfg

This could be done, but it's not the most common way to do that. We 
expect either the parameters qemu{,_img,_io}_binary to be set, or use 
the binaries located at the test directory 
(/usr/local/autotest/client/[tests]/kvm). During the build phase, a link 
will be created, say, linking:

/usr/local/autotest/client/tests/kvm/qemu -> 
/usr/local/autotest/client/tests/kvm/install_root/bin/qemu-system-x86_64

So, it's not needed to be set explicitly.

>
> Also, if you are going to submit all the 5 patches for Virtfs at a time
> then your patchset looks fine for me.

If you agree with the comments above, I'll merge this branch to master.

Thanks!

>
> Thanks,
> Madhuri
> On Mon, 2012-01-02 at 23:35 -0300, Cleber Rosa wrote:
>> Hi Madhuri,
>>
>> I've posted your patch set, with some changes at:
>>
>> https://github.com/clebergnu/autotest/tree/guest_kernel_9p
>>
>> The current version is working for me, but in case you want to change
>> anything, now is the time. Let's work on that towards a final version!
>>
>> Thanks for the great work you've done!
>>
>> Cheers,
>> CR.
>>
>> On 12/26/2011 09:31 AM, Madhuri Appana wrote:
>>> From: Madhuri Appana<[email protected]>
>>>
>>>
>>> Signed-off-by: Madhuri Appana<[email protected]>
>>> ---
>>>    client/tests/kvm/build.cfg.sample |    9 ++++
>>>    client/virt/base_installer.py     |    9 ++++
>>>    client/virt/installer.py          |    5 ++
>>>    client/virt/kvm_installer.py      |    8 +++-
>>>    client/virt/virt_utils.py         |   95 
>>> +++++++++++++++++++++++++++++++++++++
>>>    5 files changed, 125 insertions(+), 1 deletions(-)
>>>
>>> diff --git a/client/tests/kvm/build.cfg.sample 
>>> b/client/tests/kvm/build.cfg.sample
>>> index 6e3d134..fd5217d 100644
>>> --- a/client/tests/kvm/build.cfg.sample
>>> +++ b/client/tests/kvm/build.cfg.sample
>>> @@ -1,5 +1,6 @@
>>>    # Copy this file to build.cfg and edit it.
>>>
>>> +include config.cfg
>>>    vm_type = kvm
>>>
>>>    variants:
>>> @@ -23,6 +24,14 @@ variants:
>>>            # QEMU installation from a local source directory
>>>            # local_src_qemu_path = /tmp/qemu-0.15.1
>>>
>>> +        # Guest Kernel installation from a GIT repo
>>> +        git_repo_guest_kernel_uri = 
>>> git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
>>> +        git_repo_guest_kernel_branch = master
>>> +        #git_repo_guest_kernel_patches = ['http://foo/bar.patch', 
>>> 'http://foo/baz.patch']
>>> +        guest_kernel_config =  http://foo/bar/kernel-config
>>> +        guest_kernel_build_target = bzImage
>>> +        guest_kernel_build_image  = arch/x86/boot/bzImage
>>> +
>>>            # QEMU installation from a GIT repo
>>>            git_repo_qemu_uri = git://git.qemu.org/qemu.git
>>>            git_repo_qemu_configure_options = --target-list=x86_64-softmmu 
>>> --enable-spice
>>> diff --git a/client/virt/base_installer.py b/client/virt/base_installer.py
>>> index a414fde..94c2a4e 100644
>>> --- a/client/virt/base_installer.py
>>> +++ b/client/virt/base_installer.py
>>> @@ -687,6 +687,15 @@ class GitRepoInstaller(BaseLocalSourceInstaller):
>>>            self._set_build_helper()
>>>
>>>
>>> +class GitRepoKernelInstaller(BaseLocalSourceInstaller):
>>> +    def set_install_params(self, test, params):
>>> +        super(GitRepoKernelInstaller, self).set_install_params(test, 
>>> params)
>>> +
>>> +        self.content_helper = virt_utils.GitRepoParamHelper(params, 
>>> self.name,
>>> +                                                            
>>> self.source_destination)
>>> +        self.build_helper = virt_utils.LinuxKernelBuildHelper(params, 
>>> self.name,
>>> +                                                              
>>> self.source_destination)
>>> +
>>>    class FailedInstaller:
>>>        """
>>>        Class used to be returned instead of the installer if a installation 
>>> fails
>>> diff --git a/client/virt/installer.py b/client/virt/installer.py
>>> index 4e96853..b3f2b2e 100644
>>> --- a/client/virt/installer.py
>>> +++ b/client/virt/installer.py
>>> @@ -103,6 +103,8 @@ INSTALLER_REGISTRY.register('koji',
>>>                                base_installer.KojiInstaller)
>>>    INSTALLER_REGISTRY.register('git_repo',
>>>                                base_installer.GitRepoInstaller)
>>> +INSTALLER_REGISTRY.register('git_kernel',
>>> +                            base_installer.GitRepoKernelInstaller)
>>>    INSTALLER_REGISTRY.register('local_src',
>>>                                base_installer.LocalSourceDirInstaller)
>>>    INSTALLER_REGISTRY.register('local_tar',
>>> @@ -122,6 +124,9 @@ INSTALLER_REGISTRY.register('koji',
>>>    INSTALLER_REGISTRY.register('git_repo',
>>>                                kvm_installer.GitRepoInstaller,
>>>                                'kvm')
>>> +INSTALLER_REGISTRY.register('git_kernel',
>>> +                            kvm_installer.GitRepoKernelInstaller,
>>> +                            'kvm')
>>>    INSTALLER_REGISTRY.register('local_src',
>>>                                kvm_installer.LocalSourceDirInstaller,
>>>                                'kvm')
>>> diff --git a/client/virt/kvm_installer.py b/client/virt/kvm_installer.py
>>> index c4002bc..f8b49d8 100644
>>> --- a/client/virt/kvm_installer.py
>>> +++ b/client/virt/kvm_installer.py
>>> @@ -10,7 +10,7 @@ from autotest_lib.client.common_lib import error
>>>    from autotest_lib.client.virt import base_installer
>>>
>>>
>>> -__all__ = ['GitRepoInstaller', 'LocalSourceDirInstaller',
>>> +__all__ = ['GitRepoInstaller', 'GitRepoKernelInstaller', 
>>> 'LocalSourceDirInstaller',
>>>               'LocalSourceTarInstaller', 'RemoteSourceTarInstaller']
>>>
>>>
>>> @@ -215,6 +215,12 @@ class GitRepoInstaller(KVMBaseInstaller,
>>>        '''
>>>        pass
>>>
>>> +class GitRepoKernelInstaller(KVMBaseInstaller,
>>> +                             base_installer.GitRepoKernelInstaller):
>>> +    '''
>>> +    Installer that deals with source code on Git repositories
>>> +    '''
>>> +    pass
>>>
>>>    class LocalSourceDirInstaller(KVMBaseInstaller,
>>>                                  base_installer.LocalSourceDirInstaller):
>>> diff --git a/client/virt/virt_utils.py b/client/virt/virt_utils.py
>>> index 1b90d0f..952a559 100644
>>> --- a/client/virt/virt_utils.py
>>> +++ b/client/virt/virt_utils.py
>>> @@ -3055,6 +3055,101 @@ class GnuSourceBuildHelper(object):
>>>            self.configure()
>>>            self.make()
>>>
>>> +class LinuxKernelBuildHelper(object):
>>> +    '''
>>> +    Handles Building Linux Kernel.
>>> +
>>> +    '''
>>> +    def __init__(self, params, name, source):
>>> +        '''
>>> +        @type source: string
>>> +        @param source: source directory or tarball
>>> +        @type prefix: string
>>> +        @param prefix: installation prefix
>>> +        @throws: GnuSourceBuildInvalidSource
>>> +        '''
>>> +        self.params = params
>>> +        self.name = name
>>> +        self.source = source
>>> +        self._parse_params()
>>> +
>>> +    def _parse_params(self):
>>> +        '''
>>> +        Parses the params items for entries related to guest kernel
>>> +
>>> +        '''
>>> +        configure_opt_key = '%s_config' % self.name
>>> +        self.config = self.params.get(configure_opt_key, '')
>>> +
>>> +        build_image_key = '%s_build_image' % self.name
>>> +        self.build_image = self.params.get(build_image_key, 
>>> 'arch/x86/boot/bzImage')
>>> +
>>> +        build_target_key = '%s_build_target' % self.name
>>> +        self.build_target = self.params.get(build_target_key, 'bzImage')
>>> +
>>> +        kernel_path_key = '%s_kernel_path' % self.name
>>> +        self.kernel_path = self.params.get(kernel_path_key, 
>>> '/tmp/kvm_autotest_root/images/' + self.build_target)
>>> +
>>> +        logging.info('Parsing Linux kernel build parameters for %s' % 
>>> self.name)
>>> +
>>> +
>>> +    def make_guest_kernel(self):
>>> +        '''
>>> +        Runs "make", using a single job
>>> +        '''
>>> +        os.chdir(self.source)
>>> +        logging.info("Building guest kernel")
>>> +        logging.debug("Kernel config is %s" % self.config)
>>> +        utils.get_file(self.config, '.config')
>>> +
>>> +        # FIXME currently no support for builddir
>>> +        # run old config
>>> +        utils.system('yes "" | make oldconfig>   /dev/null')
>>> +        parallel_make_jobs = utils.count_cpus()
>>> +        make_command = "make -j %s %s" % (parallel_make_jobs, 
>>> self.build_target)
>>> +        logging.info("Running parallel make on src dir")
>>> +        utils.system(make_command)
>>> +
>>> +    def make_clean(self):
>>> +        '''
>>> +        Runs "make clean"
>>> +        '''
>>> +        os.chdir(self.source)
>>> +        utils.system("make clean")
>>> +
>>> +
>>> +    def make(self, failure_feedback=True):
>>> +        '''
>>> +        Runs a parallel make
>>> +
>>> +        @param failure_feedback: return information on build failure by 
>>> raising
>>> +                                 the appropriate exceptions
>>> +        @raise: GnuSourceBuildParallelFailed if parallel build fails, or
>>> +        '''
>>> +        try:
>>> +            self.make_clean()
>>> +            self.make_guest_kernel()
>>> +        except error.CmdError:
>>> +            if failure_feedback:
>>> +                raise GnuSourceBuildParallelFailed
>>> +
>>> +    def cp_linux_kernel(self):
>>> +        '''
>>> +        Copying Linux kernel to target path
>>> +        '''
>>> +        os.chdir(self.source)
>>> +        utils.force_copy(self.build_image, self.kernel_path)
>>> +
>>> +
>>> +    install = cp_linux_kernel
>>> +
>>> +
>>> +    def execute(self):
>>> +        '''
>>> +        Runs appropriate steps for *building* this source code tree
>>> +        '''
>>> +        self.make()
>>> +
>>>
>>>    class GnuSourceBuildParamHelper(GnuSourceBuildHelper):
>>>        '''
>

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

Reply via email to