[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-block] Disconecting /dev/nbdX leaves stale partitions and devi
From: |
Stefan Hajnoczi |
Subject: |
Re: [Qemu-block] Disconecting /dev/nbdX leaves stale partitions and device |
Date: |
Wed, 11 Jul 2018 13:40:34 +0100 |
User-agent: |
Mutt/1.10.0 (2018-05-17) |
On Thu, Jul 05, 2018 at 02:10:58AM +0300, Nir Soffer wrote:
CCing Eric and Paolo, who maintain QEMU's NBD code.
> I'm trying to access a qcow2 image via /dev/nbdX device.
Untrusted disk images should not be attached to the host using qemu-nbd
(or loopback devices) for security reasons. If you hit this bug during
development or ad-hoc qemu-nbd usage, then that's fine. But I just
wanted to post a reminder that production use cases should not use this
feature when dealing with untrusted disk images.
> I'm connecting a fedora 27 image (created using virt-builder) on a block
> device:
>
> qemu-nbd -c /dev/nbd0 -f qcow2 -n --detect-zeroes=on --aio=native
> /dev/27837a03-64f9-4f2b-abb0-daa2195b01ae/acb196da-31fc-454d-856b-c31ab24715b3
>
> It works, and I can read and write to the image via /dev/nbd0.
>
> Disconnecting the device "works":
>
> # qemu-nbd -d /dev/nbd0
> /dev/nbd0 disconnected
>
> But when trying to connect the image again, I get this error:
>
> # qemu-nbd -c /dev/nbd1 -f qcow2 -n --detect-zeroes=on --aio=native
> /dev/27837a03-64f9-4f2b-abb0-daa2195b01ae/acb196da-31fc-454d-856b-c31ab24715b3
> Failed to set NBD socket
> Disconnect client, due to: Unexpected end-of-file before all bytes were read
>
> Turns out each time nbd devices is disconnected, it leaves the device
> and all the partitions on it "connected":
>
> # lsblk
> ...
> nbd0
> 43:0 0 6G 0 disk
> ├─nbd0p1
> 43:1 0 1M 0 part
> ├─nbd0p2
> 43:2 0 1G 0 part
> ├─nbd0p3
> 43:3 0 615M 0 part
> └─nbd0p4
> 43:4 0 4.4G 0 part
> nbd1
> 43:32 0 6G 0 disk
> ├─nbd1p1
> 43:33 0 1M 0 part
> ├─nbd1p2
> 43:34 0 1G 0 part
> ├─nbd1p3
> 43:35 0 615M 0 part
> └─nbd1p4
> 43:36 0 4.4G 0 part
>
> I tried also to do:
>
> kpartx -d /dev/nbd1
> qemu-nbd -d /dev/nbd1
>
> But I get the same results.
>
> Testing on Fedora 28:
> kernel-4.17.2-200.fc28.x86_64
> qemu-img-2.12.0-0.5.rc1.fc28.x86_64
>
> Nir
signature.asc
Description: PGP signature
- [Qemu-block] Disconecting /dev/nbdX leaves stale partitions and device, Nir Soffer, 2018/07/04
- Re: [Qemu-block] Disconecting /dev/nbdX leaves stale partitions and device, Nir Soffer, 2018/07/04
- Re: [Qemu-block] Disconecting /dev/nbdX leaves stale partitions and device,
Stefan Hajnoczi <=
- Re: [Qemu-block] Disconecting /dev/nbdX leaves stale partitions and device, Nir Soffer, 2018/07/11
- Re: [Qemu-block] Disconecting /dev/nbdX leaves stale partitions and device, Stefan Hajnoczi, 2018/07/27
- Re: [Qemu-block] Disconecting /dev/nbdX leaves stale partitions and device, Richard W.M. Jones, 2018/07/27
- Re: [Qemu-block] Disconecting /dev/nbdX leaves stale partitions and device, Nir Soffer, 2018/07/27
- Re: [Qemu-block] Disconecting /dev/nbdX leaves stale partitions and device, Richard W.M. Jones, 2018/07/27
- Re: [Qemu-block] Disconecting /dev/nbdX leaves stale partitions and device, Nir Soffer, 2018/07/27