qemu-kvm aborts - vhost_dev_unassign_memory: Assertion `to >= 0' failed.
David Ahern
Reviewed-by Anthony Liguoriqemu-kvm.git as of:
commit dacdc4b10bafbb21120e1c24a9665444768ef999
Merge: 7b69d4f 0af4922
Author: Avi Kivity <[email protected]>
Date: Sun Jul 31 11:42:26 2011 +0300
Merge branch 'upstream-merge' into next
is aborting with the error:
qemu-kvm: qemu-kvm.git/hw/vhost.c:123: vhost_dev_unassign_memory:
Assertion `to >= 0' failed.
Aborted
$ git bisect bad 00cb2a99f5e7f73c4fff54ae16c7b6acf463ab5c is the first bad commit commit 00cb2a99f5e7f73c4fff54ae16c7b6acf463ab5c Author: Avi Kivity <[email protected]> Date: Tue Jul 26 14:26:17 2011 +0300
pc: convert pc_memory_init() to memory API
:040000 040000 3d709c2cab75b934030fb9fbdfa99024c855b2a6720d362f9702f15d16519093555182169d0b09bd M hw
Quoted 7 lines · David Ahern
qemu-kvm.git as of:
commit
dacdc4b10bafbb21120e1c24a9665444768ef999
Merge: 7b69d4f 0af4922
Author: Avi Kivity <[email protected]>
Date: Sun Jul 31 11:42:26 2011 +0300
Quoted 7 lines
Merge branch 'upstream-merge' into next
is aborting with the error:
qemu-kvm:
qemu-kvm.git/hw/vhost.c:123:vhost_dev_unassign_memory:
Assertion `to >= 0' failed.
Aborted
BTW, happens when I pass a kernel and initrd on the command line. qemu-kvm -kernel vmlinuz -initrd initrd.img ...
David
Quoted 16 lines
$ git bisect bad 00cb2a99f5e7f73c4fff54ae16c7b6acf463ab5c is the first bad commit commit 00cb2a99f5e7f73c4fff54ae16c7b6acf463ab5c Author: Avi Kivity <[email protected]> Date: Tue Jul 26 14:26:17 2011 +0300pc: convert
pc_memory_init()to memory APIReviewed-by Anthony Liguori <[email protected]>Signed-off-by Avi Kivity <[email protected]>Signed-off-by Anthony Liguori <[email protected]>:040000 040000
3d709c2cab75b934030fb9fbdfa99024c855b2a6720d362f9702f15d16519093555182169d0b09bdM hw
Quoted 7 lines · David Ahern
qemu-kvm.git as of:
commit
dacdc4b10bafbb21120e1c24a9665444768ef999
Merge: 7b69d4f 0af4922
Author: Avi Kivity<[email protected]>
Date: Sun Jul 31 11:42:26 2011 +0300
Quoted 7 lines
Merge branch 'upstream-merge' into next
is aborting with the error:
qemu-kvm:
qemu-kvm.git/hw/vhost.c:123:vhost_dev_unassign_memory:
Assertion `to>= 0' failed.
Aborted
Full command line please?
Signature · 1 line
error compiling committee.c: too many arguments to function
At 08/03/2011 05:01 PM, Avi Kivity Write:
Quoted 10 lines · David Ahern
Quoted 9 lines
qemu-kvm.git as of:
commit
dacdc4b10bafbb21120e1c24a9665444768ef999
Merge: 7b69d4f 0af4922
Author: Avi Kivity<[email protected]>
Date: Sun Jul 31 11:42:26 2011 +0300Merge branch 'upstream-merge' into next
Quoted 7 lines
Quoted 5 lines
is aborting with the error:
qemu-kvm:
qemu-kvm.git/hw/vhost.c:123:vhost_dev_unassign_memory:
Assertion `to>= 0' failed.
AbortedFull command line please?
I use the upstream qemu, and meet the same problem.
I use libvirt to start vm. Here is the command line:
2011-08-03 13:58:21.157: starting up
LC_ALL=C PATH=/usr/lib64/qt-3.3/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin HOME=/root USER=root LOGNAME=root QEMU_AUDIO_DRV=none /usr/local2/bin/ qemu-system-x86_64 -S -M pc-0.14 -enable-kvm -m 512 -smp 4,sockets=4,cores=1,threads=1 -name vm1 -uuid a1cd0309-72a3-48b7-835d-212c86de407f -nodefconfig -nodefaults -chardev soc ket,id=charmonitor,path=/var/lib/libvirt/qemu/vm1.monitor,server,nowait -mon chardev=charmonitor,id=monitor,mode=control -rtc base=localtime -no-shutdown -device lsi,id=scsi0,bu s=pci.0,multifunction=on,addr=0x5.0x0 -drive file=/var/lib/libvirt/images/vm1.img,if=none,id=drive-ide0-0-0,format=qcow2,cache=writethrough -device ide-drive,bus=ide.0,unit=0,dr ive=drive-ide0-0-0,id=ide0-0-0,bootindex=1 -drive file=/var/lib/libvirt/images/test.iso,if=none,media=cdrom,id=drive-ide0-1-0,readonly=on,format=raw -device ide-drive,bus=ide.1, unit=0,drive=drive-ide0-1-0,id=ide0-1-0 -drive file=/var/lib/libvirt/images/test.img,if=none,id=drive-virtio-disk0,format=qcow2,serial=Fujitsu-virtio-0001 -device virtio-blk-pci ,bus=pci.0,multifunction=on,addr=0x7.0x0,drive=drive-virtio-disk0,id=virtio-disk0,bootindex=2 -netdev tap,fd=25,id=hostnet0,vhost=on,vhostfd=26 -device virtio-net-pci,netdev=hos tnet0,id=net0,mac=52:54:00:04:72:f2,bus=pci.0,multifunction=on,addr=0x3.0x0 -netdev tap,fd=27,id=hostnet1 -device rtl8139,netdev=hostnet1,id=net1,mac=52:54:00:04:72:f3,bus=pci.0 ,multifunction=on,addr=0x6.0x0 -chardev pty,id=charserial0 -device isa-serial,chardev=charserial0,id=serial0 -usb -vnc 0.0.0.0:1 -vga cirrus -device virtio-balloon-pci,id=balloo n0,bus=pci.0,multifunction=on,addr=0x4.0x0
char device redirected to /dev/pts/7
qemu-system-x86_64: /home/wency/source/qemu/hw/vhost.c:123: vhost_dev_unassign_memory: Assertion `to >= 0' failed.
2011-08-03 13:58:21.400: shutting down
If I do not use vhost(command line does not include vhost=on,vhostfd=26), the vm can start succefully.
Thanks
Wen Congyang
Quoted 1 line
Quoted 7 lines · David Ahern
qemu-kvm.git as of:
commit
dacdc4b10bafbb21120e1c24a9665444768ef999
Merge: 7b69d4f 0af4922
Author: Avi Kivity<[email protected]>
Date: Sun Jul 31 11:42:26 2011 +0300
Quoted 8 lines
Merge branch 'upstream-merge' into next
is aborting with the error:
qemu-kvm:
qemu-kvm.git/hw/vhost.c:123:vhost_dev_unassign_memory:
Assertion `to>= 0' failed.
Aborted
It's a bug in vhost:
/* Assign/unassign. Keep an unsorted array of non-overlapping
* memory regions in dev->mem. */
static void vhost_dev_unassign_memory(struct vhost_dev *dev,
uint64_t start_addr,
uint64_t size)
{
int from, to, n = dev->mem->nregions;
/* Track overlapping/split regions for sanity checking. */
int overlap_start = 0, overlap_end = 0, overlap_middle = 0, split = 0;
for (from = 0, to = 0; from < n; ++from, ++to) {
struct vhost_memory_region *reg = dev->mem->regions + to;
uint64_t reglast;
uint64_t memlast;
uint64_t change;
/* clone old region */
if (to != from) {
memcpy(reg, dev->mem->regions + from, sizeof *reg);
}
/* No overlap is simple */
if (!ranges_overlap(reg->guest_phys_addr, reg->memory_size,
start_addr, size)) {
continue;
}
/* Split only happens if supplied region
* is in the middle of an existing one. Thus it can not
* overlap with any other existing region. */
assert(!split);
reglast = range_get_last(reg->guest_phys_addr, reg->memory_size);
memlast = range_get_last(start_addr, size);
/* Remove whole region */
if (start_addr <= reg->guest_phys_addr && memlast >= reglast) {
--dev->mem->nregions;
--to;
assert(to >= 0);
++overlap_middle;
continue;
}We're removing the first region, and 'to' goes negative. Michael?
Signature · 1 line
error compiling committee.c: too many arguments to function
Quoted 64 lines · Avi Kivity
Quoted 7 lines · David Ahern
qemu-kvm.git as of:
commit
dacdc4b10bafbb21120e1c24a9665444768ef999
Merge: 7b69d4f 0af4922
Author: Avi Kivity<[email protected]>
Date: Sun Jul 31 11:42:26 2011 +0300Quoted 8 lines
Merge branch 'upstream-merge' into next
is aborting with the error:
qemu-kvm:
qemu-kvm.git/hw/vhost.c:123:vhost_dev_unassign_memory:
Assertion `to>= 0' failed.
AbortedIt's a bug in vhost:
/* Assign/unassign. Keep an unsorted array of non-overlapping
* memory regions indev->mem. */
static void vhost_dev_unassign_memory(structvhost_dev*dev,uint64_t start_addr, uint64_t size) { int from, to, n = dev->mem->nregions; /* Track overlapping/split regions for sanity checking. */ int overlap_start = 0, overlap_end = 0, overlap_middle = 0, split = 0; for (from = 0, to = 0; from < n; ++from, ++to) { struct vhost_memory_region *reg = dev->mem->regions + to; uint64_t reglast; uint64_t memlast; uint64_t change; /* clone old region */ if (to != from) { memcpy(reg, dev->mem->regions + from, sizeof *reg); } /* No overlap is simple */ if (!ranges_overlap(reg->guest_phys_addr, reg->memory_size, start_addr, size)) { continue; } /* Split only happens if supplied region * is in the middle of an existing one. Thus it can not * overlap with any other existing region. */ assert(!split); reglast = range_get_last(reg->guest_phys_addr, reg->memory_size); memlast = range_get_last(start_addr, size); /* Remove whole region */ if (start_addr <= reg->guest_phys_addr && memlast >= reglast) { --dev->mem->nregions; --to; assert(to >= 0); ++overlap_middle; continue; }
Quoted 1 line
We're removing the first region, and 'to' goes negative. Michael?
Yes, that assert is wrong.
--->
Subject: vhost: remove an incorrect assert
The 'to' can go negative when the first region gets removed (it gets incremented by to 0 immediately afterward), which makes the assertion fail. Nothing breaks if
to < 0 here so just remove the assert.
----
hw/vhost.c +0 -1
@@ -120,7 +120,6 @@ static void vhost_dev_unassign_memory(struct vhost_dev *dev,if (start_addr <= reg->guest_phys_addr && memlast >= reglast) { --dev->mem->nregions; --to; -assert (to >=0 ); ++overlap_middle;continue ; }
Quoted 21 lines · David Ahern
qemu-kvm.git as of:
commit
dacdc4b10bafbb21120e1c24a9665444768ef999
Merge: 7b69d4f 0af4922
Author: Avi Kivity <[email protected]>
Date: Sun Jul 31 11:42:26 2011 +0300Merge branch 'upstream-merge' into next
is aborting with the error:
qemu-kvm:
qemu-kvm.git/hw/vhost.c:123:vhost_dev_unassign_memory:
Assertion `to >= 0' failed.
Aborted$ git bisect bad 00cb2a99f5e7f73c4fff54ae16c7b6acf463ab5c is the first bad commit commit 00cb2a99f5e7f73c4fff54ae16c7b6acf463ab5c Author: Avi Kivity <[email protected]> Date: Tue Jul 26 14:26:17 2011 +0300
Quoted 9 lines
pc: convert
pc_memory_init()to memory APIReviewed-by Anthony Liguori <[email protected]>Signed-off-by Avi Kivity <[email protected]>Signed-off-by Anthony Liguori <[email protected]>:040000 040000
3d709c2cab75b934030fb9fbdfa99024c855b2a6720d362f9702f15d16519093555182169d0b09bdM hw
Thanks for the report.
As Avi pointed out it's a vhost bug that got exposed by a memory API change.
I have posted a patch which should fix that problem - could you please try it and let me know?
Thanks!
Signature · 1 line
MST
David Ahern
Tested-byQuoted 87 lines · Michael S. Tsirkin
Quoted 64 lines · Avi Kivity
Quoted 7 lines · David Ahern
qemu-kvm.git as of:
commit
dacdc4b10bafbb21120e1c24a9665444768ef999
Merge: 7b69d4f 0af4922
Author: Avi Kivity<[email protected]>
Date: Sun Jul 31 11:42:26 2011 +0300Quoted 8 lines
Merge branch 'upstream-merge' into next
is aborting with the error:
qemu-kvm:
qemu-kvm.git/hw/vhost.c:123:vhost_dev_unassign_memory:
Assertion `to>= 0' failed.
AbortedIt's a bug in vhost:
/* Assign/unassign. Keep an unsorted array of non-overlapping
* memory regions indev->mem. */
static void vhost_dev_unassign_memory(structvhost_dev*dev,uint64_t start_addr, uint64_t size) { int from, to, n = dev->mem->nregions; /* Track overlapping/split regions for sanity checking. */ int overlap_start = 0, overlap_end = 0, overlap_middle = 0, split = 0; for (from = 0, to = 0; from < n; ++from, ++to) { struct vhost_memory_region *reg = dev->mem->regions + to; uint64_t reglast; uint64_t memlast; uint64_t change; /* clone old region */ if (to != from) { memcpy(reg, dev->mem->regions + from, sizeof *reg); } /* No overlap is simple */ if (!ranges_overlap(reg->guest_phys_addr, reg->memory_size, start_addr, size)) { continue; } /* Split only happens if supplied region * is in the middle of an existing one. Thus it can not * overlap with any other existing region. */ assert(!split); reglast = range_get_last(reg->guest_phys_addr, reg->memory_size); memlast = range_get_last(start_addr, size); /* Remove whole region */ if (start_addr <= reg->guest_phys_addr && memlast >= reglast) { --dev->mem->nregions; --to; assert(to >= 0); ++overlap_middle; continue; }Quoted 1 line
We're removing the first region, and 'to' goes negative. Michael?
Yes, that assert is wrong.
--->
Subject: vhost: remove an incorrect assertThe 'to' can go negative when the first region gets removed (it gets incremented by to 0 immediately afterward), which makes the assertion fail. Nothing breaks if
to < 0 here so just remove the assert.Signed-off-by Michael S. Tsirkin <[email protected]>----
hw/vhost.c +0
-0
hw/vhost.c static void vhost_dev_unassign_memory(struct vhost_dev *dev, · line 125
Quoted 7 lines
hw/vhost.c +0
-1@@ -120,7 +120,6 @@ static void vhost_dev_unassign_memory(struct vhost_dev *dev,if (start_addr <= reg->guest_phys_addr && memlast >= reglast) { --dev->mem->nregions; --to; -assert (to >=0 ); ++overlap_middle;continue ; }
Removing the assert appears to work fine.
David
Michael S. Tsirkin
AppliedQuoted 3 lines · David Ahern
Tested-by David Ahern <[email protected]>David
Applied, thanks very much.
Quoted 7 lines · Michael S. Tsirkin
Quoted 3 lines · David Ahern
Tested-by David Ahern <[email protected]>David
Applied, thanks very much.
I assume this will make 0.15 since it is a regression? haven't seen the patch applied to that branch yet.
David
Quoted 4 lines · David Ahern
Quoted 1 line · Michael S. Tsirkin
On Wed, Aug 03, 2011 at 07:55:47AM -0600, David Ahern wrote:
Quoted 8 lines
Quoted 6 lines
Quoted 3 lines
Tested-by David Ahern <[email protected]>David
Applied, thanks very much.
I assume this will make 0.15 since it is a regression?
How is this a regression in 0.15? I thought it's an old bug exposed by the memory API which I expect is not going into 0.15.
Quoted 4 lines
haven't seen the
patch applied to that branch yet.David
My branch will have to get merged in trunk first.
Signature · 1 line
MST
Quoted 9 lines · Michael S. Tsirkin
Quoted 8 lines · David Ahern
Quoted 5 lines · Michael S. Tsirkin
Quoted 3 lines · David Ahern
Tested-by David Ahern <[email protected]>David
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines
Applied, thanks very much.
I assume this will make 0.15 since it is a regression?
How is this a regression in 0.15? I thought it's an old bug exposed by the memory API which I expect is not going into 0.15.
Is qemu-kvm.git not tagged as 0.15 rc?
David
Quoted 8 lines
Quoted 5 lines
haven't seen the
patch applied to that branch yet.David
My branch will have to get merged in trunk first.