[SOLVED] Troubles creating Git/Quilt patches for PVE

r4mzy

Member
May 8, 2017
3
0
21
South Africa
r4mzy.co.za
Hi there,

I am trying to test an idea for a minor change to the behaviour of a function in the vma-reader.c file in the pve-qemu-kvm repository, but I'm having a very hard time getting my change into the source and compiling it.

I'm quite a n00b when it comes to Git and Quilt, let alone both at once, so I think I just need a little guidance on how exactly to use those when creating a patch for PVE. Hopefully someone here can point me in the right direction... :)

So far I have set up a dev VM following the Developer Documentation instructions (https (colon-slash-slash) pve (dot) proxmox (dot) com/wiki/Developer_Documentation) and the Build instructions (https (colon-slash-slash) git (dot) proxmox (dot) com/?p=pve-common.git;a=blob_plain;f=README.dev;hb=HEAD). I'm trying this on Debian Stretch and I have modified the sources.list for the appropriate repo and all that, so I have my working PVE installation all done with packages installed, etc., and I have cloned the git modules.

The problem I'm running into is working with the patches - I'm not getting it right to create a valid patch file that I can then add with quilt/git and have it included when I run 'make dinstall'.
So far I have a patch file that I added to the Quilt series following the instructions here:
https (colon-slash-slash) raphaelhertzog (dot) com/2012/08/08/how-to-use-quilt-to-manage-patches-in-debian-packages/

But if I compare my patch file and the patch files in pve-qemu-kvm/debian/pve/patches, I see the one Quilt generated is missing lines and it looks like the patches were actually generated with Git. Which makes me wonder where the "Learn to use the quilt patch scripts" from Development Environment setup fits into things... To make things worse, when I try to even apply the existing Quilt patches in pve/patches it throws errors (mostly files not found) and I have to force the patches, & I don't know if that's what I should be doing... If I try using Git to apply the patches ("git apply patches/pve/*.patch") I just get a long list of "0 files changed."

I feel like the different docs I'm looking at are maybe intended for different versions and I can't tell what does or doesn't apply anymore between Git and Quilt. I'd really appreciate if someone could please explain the current, correct workflow for "clone & branch repo -> apply all patches -> make desired edits -> generate patch file" up to "make dinstall" is supposed to go?

edit: apologies for the weird URLs; new users can't post links and all that...
 
Thanks for the reminder to update the pve-qemu-kvm.git repository with new instructions.
We changed the workflow to one using submodules (it's more convenient and needs much less space).
You'll want to clone the pve-qemu.git repository and its submodule (there's a convenience make target for this (`make submodule`)).
The submodule will point to the upstream commit the "quilt" patches are based on. They're now always created with `git format-patch` and not pushed in applied form to the mirror since we use a force-push like workflow there.

For a simple workflow one way of checking out the repositories is to clone the pve-qemu.git repository, initializing its submodule to get to the state the patches are based on, and cloning this locally to a separate directory to work with it more easily.
Code:
~/Code $ git clone git://git.proxmox.com/git/pve-qemu.git
~/Code $ cd pve-qemu
~/Code/pve-qemu $ make submodule
~/Code/pve-qemu $ cd ..
~/Code $ git clone pve-qemu/qemu/.git working-qemu
~/Code $ cd working-qemu
~/Code/working-qemu $ git checkout -b current-pve
~/Code/working-qemu $ git am ../pve-qemu/debian/patches/pve/*
~/Code/working-qemu $ git checkout -b my-working-branch

In `working-qemu` you then have a `current-pve` branch representing the qemu code with pve patches applied.
You can compile&test locally in that repository (see `pve-qemu/debian/rules` for the exact `./configure` command to start building with), or just work on the code and create extra patches via `git format-patch current-pve..my-working-branch` (or `git diff` if you don't want to create commits), then copy the patch files to pve-qemu/debian/patches and add them to pve-qemu/debian/patches/series, then run `make` in the pve-qemu repository.

(The most convenient way to develop & test changes is to compile in the working-qemu repository (you only have to do the ./configure once) and symlink /usr/bin/kvm to `...working-qemu/x86_64-softmmu/qemu-system-x86_64` and start VMs via qm or the pve gui, that way you don't have to deal with the qemu command line or installing packages to test each tiny change.)
 
  • Like
Reactions: r4mzy

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!