allow building spice from git
PATCH 1/1 allow building spice from git
Hi,
These patches refactor the kvm_installer and add two repositories, spice-protocol and spice.
I'm not sure what the best way is to achieve the next points I need to do:
1. Installing pre built qxl drivers into images. I'd assume there is already support for installing virtio? is the unattended install for windows used for that?
2. Running a spice client. Is there already support for running some long lived process while a vm is running, and controlling it?
I would possibly like to also build qxl drivers - it is doable from linux using wine and ddk, and possibly with mingw (the former I already use). Is something similar being done for virtio drivers?
Alon Levy (4):
kvm_vm: add build/lib to LD_LIBRARY_PATH for qemu_cmd
kvm_installer: introduce GitRepo helper class
kvm_installer: build spice from git client/tests/kvm/build.cfg.sample: add commented spice parameters
client/tests/kvm/build.cfg.sample | 8 ++ client/virt/kvm_installer.py | 188 +++++++++++++++++++------------------ client/virt/kvm_vm.py | 3 + 3 files changed, 106 insertions(+), 93 deletions(-)
Signature · 1 line
1.7.5.4
PATCH 1/1 kvm_vm: add build/lib to LD_LIBRARY_PATH for qemu_cmd
build/lib can contain libspice-server.so built from git.
--- client/virt/kvm_vm.py | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-)
client/virt/kvm_vm.py +3 -0
@@ -403,6 +403,9 @@ class VM(virt_vm.BaseVM): # Set the X11 display parameter if requested if params.get("x11_display"): qemu_cmd += "DISPLAY=%s " % params.get("x11_display") + # Update LD_LIBRARY_PATH for built libraries (libspice-server) + qemu_cmd += "LD_LIBRARY_PATH=%s " % ( + os.path.abspath(os.path.join(self.root_dir, 'build/lib'))) # Add the qemu binary qemu_cmd += qemu_binary # Add the VM's name
Signature · 1 line
1.7.5.4
PATCH 1/1 kvm_installer: introduce GitRepo helper class
In reply to Alon LevyWill allow adding further git repositories more easily later.
--- client/virt/kvm_installer.py | 163 ++++++++++++++++++----------------------- 1 files changed, 72 insertions(+), 91 deletions(-)
client/virt/kvm_installer.py +72 -91
@@ -598,6 +598,38 @@ class SourceDirInstaller(BaseInstaller): if self.save_results: virt_installer.save_build(self.srcdir, self.results_dir) +class GitRepo(object): + def __init__(self, installer, prefix, + srcdir, build_steps=[], repo_param=None): + params = installer.params + self.installer = installer + self.repo = params.get(repo_param or (prefix + '_repo')) + self.branch = params.get(prefix + '_branch', 'master') + self.lbranch = params.get(prefix + '_lbranch', 'master') + self.commit = params.get(prefix + '_commit', None) + self.patches = params.get(prefix + '_patches', []) + self.build_steps = build_steps + self.srcdir = os.path.join(self.installer.srcdir, srcdir) + + + def fetch_and_patch(self): + if not self.repo: + return + virt_utils.get_git_branch(self.repo, self.branch, self.srcdir, + self.commit, self.lbranch) + os.chdir(self.srcdir) + for patch in self.patches: + utils.get_file(patch, os.path.join(self.srcdir, + os.path.basename(patch))) + utils.system('patch -p1 < %s' % os.path.basename(patch)) + + + def build(self): + os.chdir(self.srcdir) + for step in self.build_steps: + logging.info(step) + utils.run(step) + class GitInstaller(SourceDirInstaller): def _pull_code(self):
@@ -605,120 +637,69 @@ class GitInstaller(SourceDirInstaller): Retrieves code from git repositories. """ params = self.params + make_jobs = utils.count_cpus() + cfg = 'PKG_CONFIG_PATH="%s/lib/pkgconfig:%s/share/pkgconfig" ./configure' % ( + self.prefix, self.prefix) - kernel_repo = params.get("git_repo") - user_repo = params.get("user_git_repo") - kmod_repo = params.get("kmod_repo") + self.kernel = GitRepo(installer=self, prefix='kernel', + repo_param='git_repo', srcdir='kvm') + self.kmod = GitRepo(installer=self, prefix='kmod', srcdir="kvm_kmod") + if params.get('kernel_git_repo'): + cfg += ' --kerneldir=%s' % self.host_kernel_srcdir + self.kernel.build_steps = [cfg, + 'make clean', + 'make -C kernel LINUX=%s sync' % self.kernel.srcdir] + self.kmod.build_steps=[cfg, + 'make clean', + 'make sync LINUX=%s' % self.kernel.srcdir, + 'make'] - kernel_branch = params.get("kernel_branch", "master") - user_branch = params.get("user_branch", "master") - kmod_branch = params.get("kmod_branch", "master") + self.userspace = GitRepo(installer=self, prefix='user', + repo_param='user_git_repo', srcdir='kvm_userspace') - kernel_lbranch = params.get("kernel_lbranch", "master") - user_lbranch = params.get("user_lbranch", "master") - kmod_lbranch = params.get("kmod_lbranch", "master") + p = os.path.join(self.userspace.srcdir, 'configure') + self.configure_options = virt_installer.check_configure_options(p) - kernel_commit = params.get("kernel_commit", None) - user_commit = params.get("user_commit", None) - kmod_commit = params.get("kmod_commit", None) + cfg = cfg + ' --prefix=%s' % self.prefix + if "--disable-strip" in self.configure_options: + cfg += ' --disable-strip' + if self.extra_configure_options: + cfg += ' %s' % self.extra_configure_options - kernel_patches = eval(params.get("kernel_patches", "[]")) - user_patches = eval(params.get("user_patches", "[]")) - kmod_patches = eval(params.get("user_patches", "[]")) + self.userspace.build_steps=[cfg, 'make clean', 'make -j %s' % make_jobs] - if not user_repo: + if not self.userspace.repo: message = "KVM user git repository path not specified" logging.error(message) raise error.TestError(message) - userspace_srcdir = os.path.join(self.srcdir, "kvm_userspace") - virt_utils.get_git_branch(user_repo, user_branch, userspace_srcdir, - user_commit, user_lbranch) - self.userspace_srcdir = userspace_srcdir - - if user_patches: - os.chdir(self.userspace_srcdir) - for patch in user_patches: - utils.get_file(patch, os.path.join(self.userspace_srcdir, - os.path.basename(patch))) - utils.system('patch -p1 < %s' % os.path.basename(patch)) - - if kernel_repo: - kernel_srcdir = os.path.join(self.srcdir, "kvm") - virt_utils.get_git_branch(kernel_repo, kernel_branch, kernel_srcdir, - kernel_commit, kernel_lbranch) - self.kernel_srcdir = kernel_srcdir - if kernel_patches: - os.chdir(self.kernel_srcdir) - for patch in kernel_patches: - utils.get_file(patch, os.path.join(self.userspace_srcdir, - os.path.basename(patch))) - utils.system('patch -p1 < %s' % os.path.basename(patch)) - else: - self.kernel_srcdir = None - - if kmod_repo: - kmod_srcdir = os.path.join (self.srcdir, "kvm_kmod") - virt_utils.get_git_branch(kmod_repo, kmod_branch, kmod_srcdir, - kmod_commit, kmod_lbranch) - self.kmod_srcdir = kmod_srcdir - if kmod_patches: - os.chdir(self.kmod_srcdir) - for patch in kmod_patches: - utils.get_file(patch, os.path.join(self.userspace_srcdir, - os.path.basename(patch))) - utils.system('patch -p1 < %s' % os.path.basename(patch)) - else: - self.kmod_srcdir = None - - p = os.path.join(self.userspace_srcdir, 'configure') - self.configure_options = virt_installer.check_configure_options(p) - + for repo in [self.userspace, self.kernel, self.kmod]: + if not repo.repo: + continue + repo.fetch_and_patch() def _build(self): - make_jobs = utils.count_cpus() - cfg = './configure' - if self.kmod_srcdir: + if self.kmod.repo: logging.info('Building KVM modules') - os.chdir(self.kmod_srcdir) - module_build_steps = [cfg, - 'make clean', - 'make sync LINUX=%s' % self.kernel_srcdir, - 'make'] - elif self.kernel_srcdir: + self.kmod.build() + elif self.kernel.repo: logging.info('Building KVM modules') - os.chdir(self.userspace_srcdir) - cfg += ' --kerneldir=%s' % self.host_kernel_srcdir - module_build_steps = [cfg, - 'make clean', - 'make -C kernel LINUX=%s sync' % self.kernel_srcdir] - else: - module_build_steps = [] + self.kernel.build() - for step in module_build_steps: - utils.run(step) logging.info('Building KVM userspace code') - os.chdir(self.userspace_srcdir) - cfg += ' --prefix=%s' % self.prefix - if "--disable-strip" in self.configure_options: - cfg += ' --disable-strip' - if self.extra_configure_options: - cfg += ' %s' % self.extra_configure_options - utils.system(cfg) - utils.system('make clean') - utils.system('make -j %s' % make_jobs) + self.userspace.build() def _install(self): - if self.kernel_srcdir: - os.chdir(self.userspace_srcdir) + if self.kernel: + os.chdir(self.userspace.srcdir) # the kernel module install with --prefix doesn't work, and DESTDIR # wouldn't work for the userspace stuff, so we clear WANT_MODULE: utils.system('make install WANT_MODULE=') # and install the old-style-kmod modules manually: - self._install_kmods_old_userspace(self.userspace_srcdir) - elif self.kmod_srcdir: + self._install_kmods_old_userspace(self.userspace.srcdir) + elif self.kmod: # if we have a kmod repository, it is easier: # 1) install userspace: os.chdir(self.userspace_srcdir)
@@ -728,7 +709,7 @@ class GitInstaller(SourceDirInstaller): else: # if we don't have kmod sources, we just install # userspace: - os.chdir(self.userspace_srcdir) + os.chdir(self.userspace.srcdir) utils.system('make install') if self.path_to_roms:
Signature · 1 line
1.7.5.4
PATCH 1/1 kvm_installer: build spice from git
In reply to Alon Levy--- client/virt/kvm_installer.py | 23 ++++++++++++++++++++++- 1 files changed, 22 insertions(+), 1 deletions(-)
client/virt/kvm_installer.py +22 -1
@@ -654,6 +654,20 @@ class GitInstaller(SourceDirInstaller): 'make sync LINUX=%s' % self.kernel.srcdir, 'make'] + self.spice_protocol = GitRepo(installer=self, prefix='spice_protocol', + srcdir='spice-protocol', + build_steps= ['./autogen.sh', + './configure --prefix=%s' % self.prefix, + 'make clean', + 'make -j %s' % (make_jobs), + 'make install']) + + self.spice = GitRepo(installer=self, prefix='spice', srcdir='spice', + build_steps= ['PKG_CONFIG_PATH="%s/lib/pkgconfig:%s/share/pkgconfig" CXXFLAGS=-Wl,--add-needed ./autogen.sh --prefix=%s' % (self.prefix, self.prefix, self.prefix), + 'make clean', + 'make -j %s' % (make_jobs), + 'make install']) + self.userspace = GitRepo(installer=self, prefix='user', repo_param='user_git_repo', srcdir='kvm_userspace')
@@ -673,7 +687,7 @@ class GitInstaller(SourceDirInstaller): logging.error(message) raise error.TestError(message) - for repo in [self.userspace, self.kernel, self.kmod]: + for repo in [self.userspace, self.kernel, self.kmod, self.spice_protocol, self.spice]: if not repo.repo: continue repo.fetch_and_patch()
@@ -686,6 +700,13 @@ class GitInstaller(SourceDirInstaller): logging.info('Building KVM modules') self.kernel.build() + if self.spice_protocol.repo: + logging.info('Building Spice-protocol') + self.spice_protocol.build() + + if self.spice.repo: + logging.info('Building Spice') + self.spice.build() logging.info('Building KVM userspace code') self.userspace.build()
Signature · 1 line
1.7.5.4
PATCH 1/1 client/tests/kvm/build.cfg.sample: add commented spice parameters
In reply to Alon Levy--- client/tests/kvm/build.cfg.sample | 8 ++++++++ 1 files changed, 8 insertions(+), 0 deletions(-)
client/tests/kvm/build.cfg.sample +8 -0
@@ -78,6 +78,14 @@ variants: # kmod_lbranch = kmod_lbranch_name # kmod_commit = kmod_commit_name # kmod_patches = ['http://foo.com/patch1', 'http://foo.com/patch2'] + # spice_repo = git://anongit.freedesktop.org/spice/spice + # spice_branch = master + # spice_lbranch = master + # spice_patches = [] + # spice_protocol_repo = git://anongit.freedesktop.org/spice/spice-protocol + # spice_protocol_branch = master + # spice_protocol_lbranch = master + # spice_protocol_patches = [] # In some cases, you might want to provide a ROM dir, so ROM # files can be copied from there to your source based install # path_to_rom_images = /usr/share/kvm
Signature · 1 line
1.7.5.4