From: Max Reitz <mreitz@redhat.com>
To: Kashyap Chamarthy <kchamart@redhat.com>, Kevin Wolf <kwolf@redhat.com>
Cc: qemu-devel@nongnu.org, stefanha@redhat.com
Subject: Re: [Qemu-devel] QEMU segfault: Booting an overlay with backing_file over NBD: nbd.c:nbd_receive_request():L756: read failed
Date: Fri, 30 Jan 2015 14:32:25 -0500 [thread overview]
Message-ID: <54CBDC49.6040305@redhat.com> (raw)
In-Reply-To: <20150130184143.GA9654@tesla.redhat.com>
On 2015-01-30 at 13:41, Kashyap Chamarthy wrote:
> On Fri, Jan 30, 2015 at 06:15:21PM +0100, Kevin Wolf wrote:
>> Am 29.01.2015 um 17:25 hat Kashyap Chamarthy geschrieben:
>>> $ qemu-system-x86_64 \
>>> -nographic \
>>> -nodefconfig \
>>> -nodefaults \
>>> -m 2048 \
>>> -device virtio-scsi-pci,id=scsi \
>>> -device virtio-serial-pci \
>>> -serial stdio \
>>> -drive file=./overlay1.qcow2,format=qcow2,if=virtio,cache=writeback
>>> Segmentation fault (core dumped)
>>>
>>>
>>> On the shell where `qemu-nbd` is running, I notice this
>>>
>>> nbd.c:nbd_receive_request():L756: read failed
>>>
>>>
>>> Haven't investigated further with GDB, thought I'd bring it up here
>>> first.
>>>
>>>
>>> Versions
>>> --------
>>>
>>> $ rpm -q qemu; uname -r
>>> qemu-2.1.2-7.fc21.x86_64
>>> 3.17.8-300.fc21.x86_64
>> Copying Stefan because he's the master of AIO contexts and it is
>> bs->aio_context that becomes NULL. I couldn't see anything obvious.
>>
>>
>> In the meantime, could you retest on git master?
> Just tested from git, and I can still reproduce it.
>
> That's the commit I'm at:
>
> $ git describe
> v2.2.0-682-g16017c4
>
>
> Run the NBD server, from git:
>
> $ /home/kashyapc/build/qemu/qemu-nbd -f qcow2 \
> -p10809 ./f21vm.qcow2 -t
>
>
> Create the overlay:
>
> $ /home/kashyapc/build/qemu/qemu-img create \
> -f qcow2 -F nbd -o backing_file=nbd://localhost overlay2-of-f21vm.qcow2
> Segmentation fault (core dumped)
You want to use -F raw. The file format is raw, not nbd (nbd is the
protocol over which the data is read, which is in format raw).
Anyway, -F nbd shouldn't result in a segfault. One way to prevent this
is to check whether the backing file format specified (or any format
given to qemu-img in general) is a real format or the name of a protocol
driver and then error out if it's the latter; but that would be more of
a hotfix.
Kevin, Stefan: The real problem is that block/nbd.c stores a
BDRVNBDState object in bs->opaque and passes &BDRVNBDState.client (an
NbdClientSession object) to the block/nbd-client.c functions. Those
functions then receive the BDS pointer from client->bs. If an NBD BDS is
a root BDS (as in this case), at some point a bdrv_swap() may happen
(and it does happen here) which leads to ((BDRVNBDState
*)bs->opaque)->client.bs != bs, and that's where the segfault comes from
(bdrv_get_aio_context() returns NULL).
One way to fix this real problem is to remove the BDS pointer from the
NbdClientSession and to always pass the BDS explicitly to the
block/nbd-client.c functions; the other is to always update the BDS
pointer in NbdClientSession in block/nbd.c. I'll try the former, and if
it doesn't work, will do the latter (if you don't object).
Max
> Creating the overlay from the git-compiled `qemu-img` binary fails.
>
> So, let's create the overlay using the `qemu-img` binary from the system
> (RPM version noted above) and boot the overlay from the just compiled
> QEMU x86_64 binary from git, still core dumps:
>
> $ /home/kashyapc/build/qemu/x86_64-softmmu/qemu-system-x86_64 \
> -nographic \
> -nodefconfig \
> -nodefaults \
> -m 2048 \
> -device virtio-scsi-pci,id=scsi \
> -device virtio-serial-pci \
> -serial stdio \
> -drive file=./overlay2-f21vm.qcow2,format=qcow2,if=virtio,cache=writeback
> Segmentation fault (core dumped)
>
>
> PS: I'm traveling, so I'll be a little slow to respond here, but can
> provide more debugging info from the coredump of `qemu-img` binary as I
> have access to a real computer.
>
>
next prev parent reply other threads:[~2015-01-30 19:32 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-01-29 16:25 [Qemu-devel] QEMU segfault: Booting an overlay with backing_file over NBD: nbd.c:nbd_receive_request():L756: read failed Kashyap Chamarthy
2015-01-29 16:47 ` Richard W.M. Jones
2015-01-29 17:22 ` Kashyap Chamarthy
2015-01-29 23:33 ` Kashyap Chamarthy
2015-01-30 17:15 ` Kevin Wolf
2015-01-30 18:41 ` Kashyap Chamarthy
2015-01-30 19:32 ` Max Reitz [this message]
2015-01-30 22:13 ` Kashyap Chamarthy
2015-02-02 8:14 ` Stefan Hajnoczi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=54CBDC49.6040305@redhat.com \
--to=mreitz@redhat.com \
--cc=kchamart@redhat.com \
--cc=kwolf@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.