| View previous topic :: View next topic |
| Author |
Message |
vitoriung Apprentice


Joined: 21 May 2007 Posts: 158 Location: Prague, Czech Republic
|
Posted: Mon Jul 05, 2010 3:16 pm Post subject: patch for qemu-kvm, something is wrong |
|
|
Hi
I created a patch regarding this bug http://bugs.gentoo.org/show_bug.cgi?id=325209 but something went wrong.
Actuall patch - downloaded from here http://git.kernel.org/?p=virt/kvm/qemu-kvm.git;a=commit;h=992cc816c433332f2e93db033919a9ddbfcd1da4
| Code: |
From 992cc816c433332f2e93db033919a9ddbfcd1da4 Mon Sep 17 00:00:00 2001
From: Michael S. Tsirkin <mst@redhat.com>
Date: Wed, 28 Apr 2010 12:27:38 +0300
Subject: [PATCH] qemu-kvm: fix crash on reboot with vhost-net
When vhost-net is disabled on reboot, we set msix mask notifier
to NULL to disable further mask/unmask notifications.
Code currently tries to pass this NULL to notifier,
leading to a crash. The right thing to do is
to add explicit APIs to enable/disable notifications.
Now when disabling notifications:
- if vector is masked, we don't need to notify backend,
just disable future notifications
- if vector is unmasked, invoke callback to unassign backend,
then disable future notifications
This patch also polls notifier before closing it,
to make sure we don't lose events if poll callback
didn't have time to run.
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
---
hw/msix.c | 40 +++++++++++++++++++++++++++++++++++-----
hw/msix.h | 1 +
hw/virtio-pci.c | 7 +++++--
3 files changed, 41 insertions(+), 7 deletions(-)
diff --git a/hw/msix.c b/hw/msix.c
index 3ec8805..8f9a621 100644
--- a/hw/msix.c
+++ b/hw/msix.c
@@ -609,14 +609,44 @@ void msix_unuse_all_vectors(PCIDevice *dev)
int msix_set_mask_notifier(PCIDevice *dev, unsigned vector, void *opaque)
{
+ int r;
+ if (vector >= dev->msix_entries_nr || !dev->msix_entry_used[vector])
+ return 0;
+
+ assert(dev->msix_mask_notifier);
+ assert(opaque);
+ assert(!dev->msix_mask_notifier_opaque[vector]);
+
+ if (msix_is_masked(dev, vector)) {
+ return 0;
+ }
+ r = dev->msix_mask_notifier(dev, vector, opaque,
+ msix_is_masked(dev, vector));
+ if (r < 0) {
+ return r;
+ }
+ dev->msix_mask_notifier_opaque[vector] = opaque;
+ return r;
+}
+
+int msix_unset_mask_notifier(PCIDevice *dev, unsigned vector)
+{
int r = 0;
if (vector >= dev->msix_entries_nr || !dev->msix_entry_used[vector])
return 0;
- if (dev->msix_mask_notifier)
- r = dev->msix_mask_notifier(dev, vector, opaque,
- msix_is_masked(dev, vector));
- if (r >= 0)
- dev->msix_mask_notifier_opaque[vector] = opaque;
+ assert(dev->msix_mask_notifier);
+ assert(dev->msix_mask_notifier_opaque[vector]);
+
+ if (msix_is_masked(dev, vector)) {
+ return 0;
+ }
+ r = dev->msix_mask_notifier(dev, vector,
+ dev->msix_mask_notifier_opaque[vector],
+ msix_is_masked(dev, vector));
+ if (r < 0) {
+ return r;
+ }
+ dev->msix_mask_notifier_opaque[vector] = NULL;
return r;
}
diff --git a/hw/msix.h b/hw/msix.h
index f167231..6b21ffb 100644
--- a/hw/msix.h
+++ b/hw/msix.h
@@ -34,4 +34,5 @@ void msix_reset(PCIDevice *dev);
extern int msix_supported;
int msix_set_mask_notifier(PCIDevice *dev, unsigned vector, void *opaque);
+int msix_unset_mask_notifier(PCIDevice *dev, unsigned vector);
#endif
diff --git a/hw/virtio-pci.c b/hw/virtio-pci.c
index 99a588c..c4bc633 100644
--- a/hw/virtio-pci.c
+++ b/hw/virtio-pci.c
@@ -462,10 +462,13 @@ static int virtio_pci_set_guest_notifier(void *opaque, int n, bool assign)
msix_set_mask_notifier(&proxy->pci_dev,
virtio_queue_vector(proxy->vdev, n), vq);
} else {
- msix_set_mask_notifier(&proxy->pci_dev,
- virtio_queue_vector(proxy->vdev, n), NULL);
+ msix_unset_mask_notifier(&proxy->pci_dev,
+ virtio_queue_vector(proxy->vdev, n));
qemu_set_fd_handler(event_notifier_get_fd(notifier),
NULL, NULL, NULL);
+ /* Test and clear notifier before closing it,
+ * in case poll callback didn't have time to run. */
+ virtio_pci_guest_notifier_read(vq);
event_notifier_cleanup(notifier);
}
--
1.7.1.1
|
Included patch in qemu-kvm-0.12.4-r1.ebuild
| Code: |
src_prepare() {
# prevent docs to get automatically installed
sed -i '/$(DESTDIR)$(docdir)/d' Makefile || die
# Alter target makefiles to accept CFLAGS set via flag-o
sed -i 's/^\(C\|OP_C\|HELPER_C\)FLAGS=/\1FLAGS+=/' \
Makefile Makefile.target || die
# append CFLAGS while linking
sed -i 's/$(LDFLAGS)/$(QEMU_CFLAGS) $(CFLAGS) $(LDFLAGS)/' rules.mak || die
# remove part to make udev happy
sed -e 's~NAME="%k", ~~' -i kvm/scripts/65-kvm.rules || die
epatch "${FILESDIR}"/qemu-0.11.0-mips64-user-fix.patch \
"${FILESDIR}"/${PN}-0.12.3-fix-crash-with-sdl.patch \
"${FILESDIR}"/${PN}-0.12.3-include-madvise-defines.patch \
"${FILESDIR}"/${P}-large-virtio-corruption.patch \
"${FILESDIR}"/${P}-virtio.patch
}
|
Created ebuild
| Code: |
# ebuild qemu-kvm-0.12.4-r1.ebuild digest
>>> Creating Manifest for /usr/portage/app-emulation/qemu-kvm
|
actual emerge command
| Code: |
kvm1srv qemu-kvm # emerge qemu-kvm -av
These are the packages that would be merged, in order:
Calculating dependencies... done!
[ebuild U ] app-emulation/qemu-kvm-0.12.4-r1 [0.12.4] USE="aio ncurses -alsa -bluetooth -curl -esd -fdt -gnutls -hardened -kvm-trace -pulseaudio -qemu-ifup -sasl -sdl -static -vde" QEMU_SOFTMMU_TARGETS="arm cris i386 m68k microblaze mips mips64 mips64el mipsel ppc ppc64 ppcemb sh4 sh4eb sparc sparc64 x86_64" QEMU_USER_TARGETS="alpha arm armeb cris i386 m68k microblaze mips mipsel ppc ppc64 ppc64abi32 sh4 sh4eb sparc sparc32plus sparc64 x86_64" 0 kB
Total: 1 package (1 upgrade), Size of downloads: 0 kB
Would you like to merge these packages? [Yes/No] y
>>> Verifying ebuild manifests
>>> Emerging (1 of 1) app-emulation/qemu-kvm-0.12.4-r1
* qemu-kvm-0.12.4.tar.gz RMD160 SHA1 SHA256 size ;-) ... [ ok ]
* checking ebuild checksums ;-) ... [ ok ]
* checking auxfile checksums ;-) ... [ ok ]
* checking miscfile checksums ;-) ... [ ok ]
* CPV: app-emulation/qemu-kvm-0.12.4-r1
* REPO: gentoo
* USE: aio amd64 elibc_glibc kernel_linux multilib ncurses qemu_softmmu_targets_arm qemu_softmmu_targets_cris qemu_softmmu_targets_i386 qemu_softmmu_targets_m68k qemu_softmmu_targets_microblaze qemu_softmmu_targets_mips qemu_softmmu_targets_mips64 qemu_softmmu_targets_mips64el qemu_softmmu_targets_mipsel qemu_softmmu_targets_ppc qemu_softmmu_targets_ppc64 qemu_softmmu_targets_ppcemb qemu_softmmu_targets_sh4 qemu_softmmu_targets_sh4eb qemu_softmmu_targets_sparc qemu_softmmu_targets_sparc64 qemu_softmmu_targets_x86_64 qemu_user_targets_alpha qemu_user_targets_arm qemu_user_targets_armeb qemu_user_targets_cris qemu_user_targets_i386 qemu_user_targets_m68k qemu_user_targets_microblaze qemu_user_targets_mips qemu_user_targets_mipsel qemu_user_targets_ppc qemu_user_targets_ppc64 qemu_user_targets_ppc64abi32 qemu_user_targets_sh4 qemu_user_targets_sh4eb qemu_user_targets_sparc qemu_user_targets_sparc32plus qemu_user_targets_sparc64 qemu_user_targets_x86_64 userland_GNU
* Determining the location of the kernel source code
* Found kernel source directory:
* /usr/src/linux
* Found kernel object directory:
* /lib/modules/2.6.32-gentoo-r7/build
* Found sources for kernel version:
* 2.6.32-gentoo-r7
>>> Unpacking source...
>>> Unpacking qemu-kvm-0.12.4.tar.gz to /var/tmp/portage/app-emulation/qemu-kvm-0.12.4-r1/work
>>> Source unpacked in /var/tmp/portage/app-emulation/qemu-kvm-0.12.4-r1/work
>>> Preparing source in /var/tmp/portage/app-emulation/qemu-kvm-0.12.4-r1/work/qemu-kvm-0.12.4 ...
* Applying qemu-0.11.0-mips64-user-fix.patch ... [ ok ]
* Applying qemu-kvm-0.12.3-fix-crash-with-sdl.patch ... [ ok ]
* Applying qemu-kvm-0.12.3-include-madvise-defines.patch ... [ ok ]
* Applying qemu-kvm-0.12.4-large-virtio-corruption.patch ... [ ok ]
* Applying qemu-kvm-0.12.4-virtio.patch ...
* Failed Patch: qemu-kvm-0.12.4-virtio.patch !
* ( /usr/portage/app-emulation/qemu-kvm/files/qemu-kvm-0.12.4-virtio.patch )
*
* Include in your bugreport the contents of:
*
* /var/tmp/portage/app-emulation/qemu-kvm-0.12.4-r1/temp/qemu-kvm-0.12.4-virtio.patch.out
* ERROR: app-emulation/qemu-kvm-0.12.4-r1 failed:
* Failed Patch: qemu-kvm-0.12.4-virtio.patch!
*
* Call stack:
* ebuild.sh, line 54: Called src_prepare
* environment, line 3655: Called epatch '/usr/portage/app-emulation/qemu-kvm/files/qemu-0.11.0-mips64-user-fix.patch' '/usr/portage/app-emulation/qemu-kvm/files/qemu-kvm-0.12.3-fix-crash-with-sdl.patch' '/usr/portage/app-emulation/qemu-kvm/files/qemu-kvm-0.12.3-include-madvise-defines.patch' '/usr/portage/app-emulation/qemu-kvm/files/qemu-kvm-0.12.4-large-virtio-corruption.patch' '/usr/portage/app-emulation/qemu-kvm/files/qemu-kvm-0.12.4-virtio.patch'
* environment, line 1529: Called epatch '/usr/portage/app-emulation/qemu-kvm/files/qemu-kvm-0.12.4-virtio.patch'
* environment, line 1665: Called die
* The specific snippet of code:
* die "Failed Patch: ${patchname}!";
*
* If you need support, post the output of 'emerge --info =app-emulation/qemu-kvm-0.12.4-r1',
* the complete build log and the output of 'emerge -pqv =app-emulation/qemu-kvm-0.12.4-r1'.
* The complete build log is located at '/var/tmp/portage/app-emulation/qemu-kvm-0.12.4-r1/temp/build.log'.
* The ebuild environment file is located at '/var/tmp/portage/app-emulation/qemu-kvm-0.12.4-r1/temp/environment'.
* S: '/var/tmp/portage/app-emulation/qemu-kvm-0.12.4-r1/work/qemu-kvm-0.12.4'
>>> Failed to emerge app-emulation/qemu-kvm-0.12.4-r1, Log file:
>>> '/var/tmp/portage/app-emulation/qemu-kvm-0.12.4-r1/temp/build.log'
* Messages for package app-emulation/qemu-kvm-0.12.4-r1:
* Failed Patch: qemu-kvm-0.12.4-virtio.patch !
* ( /usr/portage/app-emulation/qemu-kvm/files/qemu-kvm-0.12.4-virtio.patch )
*
* Include in your bugreport the contents of:
*
* /var/tmp/portage/app-emulation/qemu-kvm-0.12.4-r1/temp/qemu-kvm-0.12.4-virtio.patch.out
* ERROR: app-emulation/qemu-kvm-0.12.4-r1 failed:
* Failed Patch: qemu-kvm-0.12.4-virtio.patch!
*
* Call stack:
* ebuild.sh, line 54: Called src_prepare
* environment, line 3655: Called epatch '/usr/portage/app-emulation/qemu-kvm/files/qemu-0.11.0-mips64-user-fix.patch' '/usr/portage/app-emulation/qemu-kvm/files/qemu-kvm-0.12.3-fix-crash-with-sdl.patch' '/usr/portage/app-emulation/qemu-kvm/files/qemu-kvm-0.12.3-include-madvise-defines.patch' '/usr/portage/app-emulation/qemu-kvm/files/qemu-kvm-0.12.4-large-virtio-corruption.patch' '/usr/portage/app-emulation/qemu-kvm/files/qemu-kvm-0.12.4-virtio.patch'
* environment, line 1529: Called epatch '/usr/portage/app-emulation/qemu-kvm/files/qemu-kvm-0.12.4-virtio.patch'
* environment, line 1665: Called die
* The specific snippet of code:
* die "Failed Patch: ${patchname}!";
*
* If you need support, post the output of 'emerge --info =app-emulation/qemu-kvm-0.12.4-r1',
* the complete build log and the output of 'emerge -pqv =app-emulation/qemu-kvm-0.12.4-r1'.
* The complete build log is located at '/var/tmp/portage/app-emulation/qemu-kvm-0.12.4-r1/temp/build.log'.
* The ebuild environment file is located at '/var/tmp/portage/app-emulation/qemu-kvm-0.12.4-r1/temp/environment'.
* S: '/var/tmp/portage/app-emulation/qemu-kvm-0.12.4-r1/work/qemu-kvm-0.12.4'
|
the files in ebuild directory
| Code: |
kvm1srv qemu-kvm # ll -R
.:
total 65K
-rw-r--r-- 1 portage portage 6.8K Jun 30 23:05 ChangeLog
drwxr-xr-x 2 portage portage 1.0K Jul 5 15:41 files
-rw-r--r-- 1 portage portage 4.0K Jul 5 15:41 Manifest
-rw-r--r-- 1 portage portage 978 Mar 2 17:09 metadata.xml
-rw-r--r-- 1 portage portage 5.6K Jun 30 23:05 qemu-kvm-0.11.1.ebuild
-rw-r--r-- 1 portage portage 5.7K Jun 30 23:05 qemu-kvm-0.11.1-r1.ebuild
-rw-r--r-- 1 portage portage 7.2K Jun 30 23:05 qemu-kvm-0.12.3.ebuild
-rw-r--r-- 1 portage portage 7.3K Jun 30 23:05 qemu-kvm-0.12.3-r1.ebuild
-rw-r--r-- 1 portage portage 7.3K Jun 30 23:05 qemu-kvm-0.12.4.ebuild
-rw-r--r-- 1 portage portage 7.4K Jul 5 15:31 qemu-kvm-0.12.4-r1.ebuild
-rw-r--r-- 1 portage portage 7.5K Jun 30 23:05 qemu-kvm-9999.ebuild
./files:
total 15K
-rw-r--r-- 1 portage portage 313 Nov 22 2009 qemu-0.11.0-mips64-user-fix.patch
-rw-r--r-- 1 portage portage 61 Dec 21 2009 qemu-kvm
-rw-r--r-- 1 portage portage 622 Dec 21 2009 qemu-kvm-0.12.1-kvm_save_mpstate-workaround.patch
-rw-r--r-- 1 portage portage 987 Feb 3 05:41 qemu-kvm-0.12.2-virtio-large-iovecs.patch
-rw-r--r-- 1 portage portage 4.0K Apr 3 14:51 qemu-kvm-0.12.3-fix-crash-with-sdl.patch
-rw-r--r-- 1 portage portage 274 Apr 3 14:51 qemu-kvm-0.12.3-include-madvise-defines.patch
-rw-r--r-- 1 portage portage 1.3K Jun 15 19:41 qemu-kvm-0.12.4-large-virtio-corruption.patch
-rw-r--r-- 1 root root 4.0K Jul 5 15:41 qemu-kvm-0.12.4-virtio.patch
|
I am not sure if the problem is in the way I included the patch or with the patch itself? I am doing this for the first time.
Thanks
Last edited by vitoriung on Mon Jul 05, 2010 9:56 pm; edited 1 time in total |
|
| Back to top |
|
 |
Hu Watchman

Joined: 06 Mar 2007 Posts: 7678
|
Posted: Mon Jul 05, 2010 9:22 pm Post subject: |
|
|
| Please use a separate code tag for each major command executed, so that we can more readily see the boundaries between commands and output. I do not see that you have shown the contents requested in the failure message, so there is not much we can do. How did you download the patch file to your system? |
|
| Back to top |
|
 |
vitoriung Apprentice


Joined: 21 May 2007 Posts: 158 Location: Prague, Czech Republic
|
|
| Back to top |
|
 |
Hu Watchman

Joined: 06 Mar 2007 Posts: 7678
|
Posted: Mon Jul 05, 2010 11:14 pm Post subject: |
|
|
| That tells us where you got it, but not how you got it. Did you choose File->Save As in the browser, copy the entire displayed page to a text editor, or something else? |
|
| Back to top |
|
 |
Mad Merlin Veteran

Joined: 09 May 2005 Posts: 1134
|
Posted: Mon Jul 05, 2010 11:33 pm Post subject: |
|
|
Why don't you try the patch directly on the source?
| Code: |
tar xjvf /usr/portage/distfiles/qemu-kvm-0.12.4.tar.gz
cd qemu-kvm-0.12.4
patch --dry-run -p1 <~/virtio.patch
|
The actual error returned from patch may also be in your emerge.log. _________________ Game! - Where the stick is mightier than the sword! |
|
| Back to top |
|
 |
vitoriung Apprentice


Joined: 21 May 2007 Posts: 158 Location: Prague, Czech Republic
|
Posted: Mon Jul 12, 2010 4:18 pm Post subject: |
|
|
I run as you suggested:
| Code: | # patch --dry-run -p1 </usr/portage/app-emulation/qemu-kvm/files/qemu-kvm-0.12.4-virtio.patch
patching file hw/msix.c
Hunk #1 FAILED at 609.
1 out of 1 hunk FAILED -- saving rejects to file hw/msix.c.rej
patching file hw/msix.h
Hunk #1 FAILED at 34.
1 out of 1 hunk FAILED -- saving rejects to file hw/msix.h.rej
patching file hw/virtio-pci.c
Hunk #1 FAILED at 462.
1 out of 1 hunk FAILED -- saving rejects to file hw/virtio-pci.c.rej
|
Don't have any idea what those Hunk#1 Failed means...
Emerge.log didn't show anything useful.
| Hu wrote: | | That tells us where you got it, but not how you got it. Did you choose File->Save As in the browser, copy the entire displayed page to a text editor, or something else? |
I did copy and pasted the entire page to nano editor (as guy on IRC gentoo advised), maybe there will be something wrong.. |
|
| Back to top |
|
 |
Hu Watchman

Joined: 06 Mar 2007 Posts: 7678
|
Posted: Tue Jul 13, 2010 2:05 am Post subject: |
|
|
| vitoriung wrote: | | I did copy and pasted the entire page to nano editor (as guy on IRC gentoo advised), maybe there will be something wrong.. | Please find this individual and inform him that he was completely and utterly wrong. By design, patch files contain context to show where they should be merged, so it is critical that you preserve the context lines exactly as they were in the posted file. Pasting something through a terminal has a high likelihood of mangling the patch, either through conversion of tabs to spaces and/or through your editor helpfully applying line wrapping where none is allowed. The correct way to download a patch is to instruct an agent of your choice to save the patch as a file. This can be done by viewing the content in Firefox and choosing Save Page As, by right clicking on the link and choosing Save Link As, or by using a dedicated agent such as wget. |
|
| Back to top |
|
 |
vitoriung Apprentice


Joined: 21 May 2007 Posts: 158 Location: Prague, Czech Republic
|
Posted: Tue Jul 13, 2010 8:45 am Post subject: |
|
|
| Hu wrote: | | vitoriung wrote: | | I did copy and pasted the entire page to nano editor (as guy on IRC gentoo advised), maybe there will be something wrong.. | Please find this individual and inform him that he was completely and utterly wrong. By design, patch files contain context to show where they should be merged, so it is critical that you preserve the context lines exactly as they were in the posted file. Pasting something through a terminal has a high likelihood of mangling the patch, either through conversion of tabs to spaces and/or through your editor helpfully applying line wrapping where none is allowed. The correct way to download a patch is to instruct an agent of your choice to save the patch as a file. This can be done by viewing the content in Firefox and choosing Save Page As, by right clicking on the link and choosing Save Link As, or by using a dedicated agent such as wget. |
OK, thanks for the information, I will remember that
However, after using above instructions, saving the patch with Save page as option in Firefox, does return the same error:
| Code: | # patch --dry-run -p1 </shares/home/qemu-kvm.git-992cc816c433332f2e93db033919a9ddbfcd1da4.patch
patching file hw/msix.c
Hunk #1 FAILED at 609.
1 out of 1 hunk FAILED -- saving rejects to file hw/msix.c.rej
patching file hw/msix.h
Hunk #1 FAILED at 34.
1 out of 1 hunk FAILED -- saving rejects to file hw/msix.h.rej
patching file hw/virtio-pci.c
Hunk #1 FAILED at 462.
1 out of 1 hunk FAILED -- saving rejects to file hw/virtio-pci.c.rej
|
Emerge of the package fails as well. Can I assume that there will be something wrong with the actual patch then? |
|
| Back to top |
|
 |
Hu Watchman

Joined: 06 Mar 2007 Posts: 7678
|
Posted: Wed Jul 14, 2010 3:49 am Post subject: |
|
|
| Yes. You are trying to patch a function which is not even present in qemu-kvm-0.12.4. |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|