block: Do not prematurely remove "filename"

If "filename" is removed from the options QDict before entering
bdrv_open_common(), it cannot be stored in the BDS. Therefore, wait
until it has been copied there and remove it from the options only
afterwards.

This fixes "filename" in the BDS being empty for block drivers which do
not need the filename because they have parsed it already (e.g. NBD).

Signed-off-by: Max Reitz <mreitz@redhat.com>
Reviewed-by: Benoit Canet <benoit@irqsave.net>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
iotests: Add test for set "filename" for NBD

Add a new test for qemu-iotests which checks whether the "filename" (and
consequently the "file") attribute is set for images which are opened
over NBD.

Signed-off-by: Max Reitz <mreitz@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>