qemu-block
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-block] Disconecting /dev/nbdX leaves stale partitions and device


From: Nir Soffer
Subject: [Qemu-block] Disconecting /dev/nbdX leaves stale partitions and device
Date: Thu, 5 Jul 2018 02:10:58 +0300

I'm trying to access a qcow2 image via /dev/nbdX device.

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

reply via email to

[Prev in Thread] Current Thread [Next in Thread]