Bug 1826652
| Summary: | Fail to parse nbd socket path with colon | ||
|---|---|---|---|
| Product: | Red Hat Enterprise Linux Advanced Virtualization | Reporter: | Han Han <hhan> |
| Component: | libvirt | Assignee: | Peter Krempa <pkrempa> |
| Status: | CLOSED ERRATA | QA Contact: | gaojianan <jgao> |
| Severity: | low | Docs Contact: | |
| Priority: | low | ||
| Version: | --- | CC: | eblake, jdenemar, jgao, lmen, pkrempa, virt-maint, xuzhang |
| Target Milestone: | rc | Keywords: | Triaged |
| Target Release: | 8.3 | Flags: | pm-rhel:
mirror+
|
| Hardware: | Unspecified | ||
| OS: | Unspecified | ||
| Whiteboard: | |||
| Fixed In Version: | libvirt-6.3.0-1.el8 | Doc Type: | If docs needed, set a value |
| Doc Text: | Story Points: | --- | |
| Clone Of: | Environment: | ||
| Last Closed: | 2020-11-17 17:48:27 UTC | Type: | Bug |
| Regression: | --- | Mount Type: | --- |
| Documentation: | --- | CRM: | |
| Verified Versions: | Category: | --- | |
| oVirt Team: | --- | RHEL 7.3 requirements from Atomic Host: | |
| Cloudforms Team: | --- | Target Upstream Version: | |
| Embargoed: | |||
Suggested workaround is not to use colons in your socket names. Fixing title. The socket path is not in the json:{} pseudo uri format but rather the old colon separated format. The json:{} version would work properly.
Fixed upstream:
commit f8d6b319a6f033fea951a33fe069b573b2ed5b60 (HEAD -> master, origin/master, origin/HEAD)
Author: Peter Krempa <pkrempa>
Date: Fri Apr 24 13:59:21 2020 +0200
virStorageSourceParseNBDColonString: Rewrite to match what qemu does
Our implementation wasn't quite able to parse everything that qemu does.
This patch rewrites the parser to a code that semantically resembles the
combination of 'nbd_parse_filename' and 'inet_parse' methods in qemu to
be able to parse the strings in an equivalent manner.
The only thing that libvirt doesn't do is to check the lengths of
various components in the nbd string in places where qemu uses constant
size buffers.
The test cases validate that some of the corner cases involving colons
are parsed properly.
https://bugzilla.redhat.com/show_bug.cgi?id=1826652
Signed-off-by: Peter Krempa <pkrempa>
Reviewed-by: Eric Blake <eblake>
Verified on :
libvirt-6.3.0-1.module+el8.3.0+6478+69f490bb.x86_64
Sc1:Have colon in export name field:
1. Create a nbd server with a colon in export name field:
# qemu-nbd -b 127.0.0.1 /tmp/nbd -x :test: -t -f raw -p 10001
Allow qemu to access the socket
~ chown qemu:qemu /tmp/nbd:
~ setenforce 0
2. Rebase a qcow2 file to the nbd address
# qemu-img rebase -b 'nbd://127.0.0.1:10001/:test:' -F raw /var/lib/libvirt/images/nbd2 -f qcow2
# qemu-img info /var/lib/libvirt/images/nbd2
image: /var/lib/libvirt/images/nbd2
file format: qcow2
virtual size: 100 MiB (104857600 bytes)
disk size: 196 KiB
cluster_size: 65536
backing file: nbd://127.0.0.1:10001/:test:
backing file format: raw
Format specific information:
compat: 1.1
lazy refcounts: false
refcount bits: 16
corrupt: false
3.Attach/detach the overlay file as qcow2 to a live VM:
# virsh attach-disk test1 /var/lib/libvirt/images/nbd2 sdc
Disk attached successfully
# virsh detach-disk test1 sdc
Disk detached successfully
Sc2:Have colon in unix socket field:
1.# qemu-nbd -k /tmp/nbd: /tmp/nbd -x : -t -e 10 -f raw
2.# qemu-img rebase -b 'nbd:unix:/tmp/nbd::exportname=:' -F raw /var/lib/libvirt/images/nbd3 -f qcow2
# qemu-img info /var/lib/libvirt/images/nbd3
image: /var/lib/libvirt/images/nbd3
file format: qcow2
virtual size: 100 MiB (104857600 bytes)
disk size: 196 KiB
cluster_size: 65536
backing file: nbd:unix:/tmp/nbd::exportname=:
backing file format: raw
Format specific information:
compat: 1.1
lazy refcounts: false
refcount bits: 16
corrupt: false
3.Attach/detach the overlay file as qcow2 to a live VM:
# virsh attach-disk test1 /var/lib/libvirt/images/nbd3 sdc
Disk attached successfully
# virsh detach-disk test1 sdc
Disk detached successfully
Sc3:Have colon in inet6 field with colon in exportname:
1.qemu-nbd -b 2620:52:0:4224:4dfa:e2:e7af:6034 /tmp/nbd -x :test: -t -f raw -p 10001
2.# qemu-img rebase -b 'nbd:[2620:52:0:4224:4dfa:e2:e7af:6034]:10001:exportname=:test:' -F raw /var/lib/libvirt/images/nbd4 -f qcow2
# qemu-img info /var/lib/libvirt/images/nbd4
image: /var/lib/libvirt/images/nbd4
file format: qcow2
virtual size: 100 MiB (104857600 bytes)
disk size: 196 KiB
cluster_size: 65536
backing file: nbd:[2620:52:0:4224:4dfa:e2:e7af:6034]:10001:exportname=:test:
backing file format: raw
Format specific information:
compat: 1.1
lazy refcounts: false
refcount bits: 16
corrupt: false
3.Attach/detach the overlay file as qcow2 to a live VM:
# virsh attach-disk test1 /var/lib/libvirt/images/nbd4 sdc
Disk attached successfully
# virsh detach-disk test1 sdc
Disk detached successfully
Work as expected,so verified.
Since the problem described in this bug report should be resolved in a recent advisory, it has been closed with a resolution of ERRATA. For information on the advisory (virt:8.3 bug fix and enhancement update), and where to find the updated files, follow the link below. If the solution does not work for you, open a new bug report. https://access.redhat.com/errata/RHBA-2020:5137 |
Description of problem: As subject Version-Release number of selected component (if applicable): libvirt-6.2.0-1.el8.x86_64 How reproducible: 100% Steps to Reproduce: 1. Create a nbd server with a colon in its unix socket: ~ qemu-nbd -k /tmp/nbd: /tmp/nbd -x : -t -e 10 Allow qemu to access the socket ~ chown qemu:qemu /tmp/nbd: ~ setenforce 0 2. Rebase a qcow2 file to the nbd address ~ qemu-img rebase -b 'nbd:unix:/tmp/nbd::exportname=:' -F raw /var/lib/libvirt/images/nbd -f qcow2 ~ qemu-img info /var/lib/libvirt/images/nbd image: /var/lib/libvirt/images/nbd file format: qcow2 virtual size: 100 MiB (104857600 bytes) disk size: 196 KiB cluster_size: 65536 backing file: nbd:unix:/tmp/nbd::exportname=: backing file format: raw Format specific information: compat: 1.1 lazy refcounts: false refcount bits: 16 corrupt: false Attach the overlay file as qcow2 to a live VM: ~ virsh attach-disk pc /var/lib/libvirt/images/nbd vdc --subdriver qcow2 error: Failed to attach disk error: internal error: unable to execute QEMU command 'blockdev-add': Failed to connect socket /tmp/nbd: No such file or directory Libvirtd qmp log: 2020-04-22 08:50:20.454+0000: 1732421: info : qemuMonitorIOWrite:431 : QEMU_MONITOR_IO_WRITE: mon=0x7f37e8039910 buf={"execute":"blockdev-add","arguments":{"driver":"nbd","server":{"type":"unix","path":"/tmp/nbd"},"export":":","node-name":"libvirt-29-storage","auto-read-only":true,"discard":"unmap"},"id":"libvirt-389"} So libvirt regards the colon of socket path as separator. See also: https://bugzilla.redhat.com/show_bug.cgi?id=1733044 Actual results: As above Expected results: Correctly parse the unix socket path with a colon Additional info: