Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.

Bug 1809674

Summary: Rebase libnbd for RHEL-AV 8.3.0
Product: Red Hat Enterprise Linux Advanced Virtualization Reporter: Jeff Nelson <jen>
Component: libnbdAssignee: Richard W.M. Jones <rjones>
Status: CLOSED ERRATA QA Contact: liuzi <zili>
Severity: high Docs Contact:
Priority: high    
Version: 8.2CC: eblake, jsuchane, leiwang, libvirt-maint, linl, mrezanin, mtessun, mxie, ptoscano, rjones, tzheng, wshi, xiaodwan, ymankad, yoguo
Target Milestone: rcKeywords: Rebase
Target Release: 8.3Flags: pm-rhel: mirror+
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: libnbd-1.4.0-2.module+el8.3.0+7998+6ff5e5ab Doc Type: Rebase: Bug Fixes and Enhancements
Doc Text:
Story Points: ---
Clone Of: 1705231 Environment:
Last Closed: 2020-11-17 17:46:46 UTC Type: Component Upgrade
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Comment 1 Richard W.M. Jones 2020-03-09 22:37:01 UTC
Current version in RHEL AV 8.2 is libnbd-1.2.2-1.el8 which
is also the last stable release upstream.

Recently I evaluated what had changed upstream since 1.2 was
released, and it's pretty thin gruel.  See the link below.  Therefore
it seems unlikely that we would do a new upstream stable branch any
time soon, and so it's also unlikely we will need to rebase
in RHEL any time soon.

https://github.com/libguestfs/libnbd/commit/46946622d985d878ad6686280b6b566d083ece7b#diff-89313975504c64c94d7288c0f4e41d39

Comment 2 Richard W.M. Jones 2020-06-03 17:04:04 UTC
Please note this is a rebase along the stable branch, so it doesn't introduce
any new features, only bug fixes.

Comment 5 liuzi 2020-06-28 02:48:57 UTC
Verify bug with builds:
python3-libnbd-1.2.3-1.module+el8.3.0+6898+0f584f31.x86_64
libnbd-1.2.3-1.module+el8.3.0+6898+0f584f31.x86_64
nbdfuse-1.2.3-1.module+el8.3.0+6898+0f584f31.x86_64
nbdkit-1.20.3-1.module+el8.3.0+6969+c553f4a0.x86_64

1.Install latest libnbd package to the 8.3 AV server,and check the package info:
# yum info libnbd
Updating Subscription Management repositories.
Unable to read consumer identity
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Last metadata expiration check: 1:31:21 ago on Wed 24 Jun 2020 03:48:47 AM EDT.
Installed Packages
Name         : libnbd
Version      : 1.2.3
Release      : 1.module+el8.3.0+6898+0f584f31
Architecture : x86_64
Size         : 202 k
Source       : libnbd-1.2.3-1.module+el8.3.0+6898+0f584f31.src.rpm
Repository   : @System
From repo    : fast
Summary      : NBD client library in userspace
URL          : https://github.com/libguestfs/libnbd
License      : LGPLv2+
Description  : NBD — Network Block Device — is a protocol for accessing Block
             : Devices (hard disks and disk-like things) over a Network.
             : 
             : This is the NBD client library in userspace, a simple library
             : for writing NBD clients.
             : 
             : The key features are:
             : 
             :  * Synchronous and asynchronous APIs, both for ease of use and
             :    for writing non-blocking, multithreaded clients.
             : 
             :  * High performance.
             : 
             :  * Minimal dependencies for the basic library.
             : 
             :  * Well-documented, stable API.
             : 
             :  * Bindings in several programming languages.

Scenario 1: Test nbdsh
1.1 Test libnbd works well. Use nbdsh to test simple nbd API calls.
# nbdsh

Welcome to nbdsh, the shell for interacting with
Network Block Device (NBD) servers.

The ‘nbd’ module has already been imported and there
is an open NBD handle called ‘h’.

h.connect_tcp ("remote", "10809")   # Connect to a remote server.
h.get_size ()                       # Get size of the remote disk.
buf = h.pread (512, 0, 0)           # Read the first sector.
exit() or Ctrl-D                    # Quit the shell
help (nbd)                          # Display documentation

nbd> h.connect_command (["nbdkit", "-s", "memory", "size=1G"])
nbd> h.get_size()
1073741824
nbd> buf = b"rhel800rhel00"
nbd> h.pwrite(buf,0,0)
nbd> buf2 = h.pread(50,0)
nbd> print(buf2)
b'rhel800rhel00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'

Scenario 2: Test zero-searching feature:
2.1 Create a buffer from a bytearray with non-zero bytes 
nbd> buf=nbd.Buffer.from_bytearray(bytearray(b"abc"))
nbd> print(buf.is_zero())
False
nbd> print(buf.is_zero(offset=0))
False
nbd> print(buf.is_zero(offset=1))
False


2.2 Create a buffer from a bytearray where all bytes are zeroes:
nbd> buf=nbd.Buffer.from_bytearray(bytearray(b"\0\0\0"))
nbd> print(buf.is_zero(offset=1))
True
nbd> print(buf.is_zero(offset=0))
True
nbd> print(buf.is_zero(size=0))
True
nbd> print(buf.is_zero(size=1))
True
nbd> print(buf.is_zero(size=3))
True

2.3 Create an empty buffer:
nbd> buf=nbd.Buffer.from_bytearray(bytearray(b""))
nbd> print(buf.is_zero(offset=0))
True
nbd> print(buf.is_zero())
True
nbd> print(buf.is_zero(size=0))
True


2.4 Create a Non-zero and zero combinations buffer:
nbd> buf=nbd.Buffer.from_bytearray(bytearray(b"\0a\02\0"))
nbd> print(buf.is_zero(offset=0))
False
nbd> print(buf.is_zero(offset=2))
False
nbd> print(buf.is_zero(offset=4))
True
nbd> print(buf.is_zero(size=0))
True
nbd> print(buf.is_zero(size=1))
True
nbd> print(buf.is_zero(size=3))
False

Scenario 3:Turn a qcow2 file into raw file:
3.1 Prepare a qcow2 file 
# qemu-img create -f qcow2 file.qcow2 1G
Formatting 'file.qcow2', fmt=qcow2 size=1073741824 cluster_size=65536 lazy_refcounts=off refcount_bits=16
# qemu-img info file.qcow2
image: file.qcow2
file format: qcow2
virtual size: 1 GiB (1073741824 bytes)
disk size: 196 KiB
cluster_size: 65536
Format specific information:
    compat: 1.1
    lazy refcounts: false
    refcount bits: 16
    corrupt: false

3.2 Use nbdfuse to transfer the file as raw:
# nbdfuse /var/tmp/test/file.raw --socket-activation qemu-nbd -f qcow2 file.qcow2 &
[1] 156332

3.3 Check the new file info
# qemu-img info  /var/tmp/test/file.raw 
image: /var/tmp/test/file.raw
file format: raw
virtual size: 1 GiB (1073741824 bytes)
disk size: 0 B

As above testing ,now change the bug from ON_QA to VERIFIED.

Comment 6 Richard W.M. Jones 2020-08-26 09:41:14 UTC
Setting back to ON_QA because I intend to rebase this package to 1.4.0.
https://www.redhat.com/archives/libguestfs/2020-August/msg00318.html

Comment 9 liuzi 2020-09-11 08:27:27 UTC
Verify bug with builds:
libnbd-1.4.0-2.module+el8.3.0+7998+6ff5e5ab.x86_64
nbdkit-1.22.0-1.module+el8.3.0+7898+13f907d5.x86_64
python3-libnbd-1.4.0-2.module+el8.3.0+7998+6ff5e5ab.x86_64
nbdfuse-1.4.0-2.module+el8.3.0+7998+6ff5e5ab.x86_64


1.Install latest libnbd package to the 8.3 AV server,and check the package info:
# yum info libnbd
Updating Subscription Management repositories.
Unable to read consumer identity

This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.

Last metadata expiration check: 2:55:15 ago on Thu 10 Sep 2020 11:39:01 PM EDT.
Installed Packages
Name         : libnbd
Version      : 1.4.0
Release      : 2.module+el8.3.0+7998+6ff5e5ab
Architecture : x86_64
Size         : 273 k
Source       : libnbd-1.4.0-2.module+el8.3.0+7998+6ff5e5ab.src.rpm
Repository   : @System
From repo    : fast
Summary      : NBD client library in userspace
URL          : https://github.com/libguestfs/libnbd
License      : LGPLv2+
Description  : NBD — Network Block Device — is a protocol for accessing Block
             : Devices (hard disks and disk-like things) over a Network.
             : 
             : This is the NBD client library in userspace, a simple library
             : for writing NBD clients.
             : 
             : The key features are:
             : 
             :  * Synchronous and asynchronous APIs, both for ease of use and
             :    for writing non-blocking, multithreaded clients.
             : 
             :  * High performance.
             : 
             :  * Minimal dependencies for the basic library.
             : 
             :  * Well-documented, stable API.
             : 
             :  * Bindings in several programming languages.

# nbdsh

Welcome to nbdsh, the shell for interacting with
Network Block Device (NBD) servers.

The ‘nbd’ module has already been imported and there
is an open NBD handle called ‘h’.

h.connect_tcp("remote", "10809")   # Connect to a remote server.
h.get_size()                       # Get size of the remote disk.
buf = h.pread(512, 0, 0)           # Read the first sector.
exit() or Ctrl-D                   # Quit the shell
help(nbd)                          # Display documentation

nbd> h.connect_command (["nbdkit", "-s", "memory", "size=1G"])
nbd> h.get_size()
1073741824
nbd> buf = b"rhel800rhel00"
nbd> h.pwrite(buf,0,0)
nbd> buf2 = h.pread(50,0)
nbd> print(buf2)
b'rhel800rhel00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'

Scenario 2: Test zero-searching feature:
nbd> buf=nbd.Buffer.from_bytearray(bytearray(b"abcwr4t7"))
nbd> print(buf.is_zero())
False
nbd> buf=nbd.Buffer.from_bytearray(bytearray(b"\0\0\0"))
nbd> print(buf.is_zero(size=1))
True
nbd> buf=nbd.Buffer.from_bytearray(bytearray(b""))
nbd> print(buf.is_zero(size=0))
nbd> buf=nbd.Buffer.from_bytearray(bytearray(b"\0a\02\0"))
nbd> print(buf.is_zero(offset=4))
True

Scenario 3:Turn a qcow2 file into raw file:
3.1 Prepare a qcow2 file 
# qemu-img create -f qcow2 file.qcow2 1G
Formatting 'file.qcow2', fmt=qcow2 size=1073741824 cluster_size=65536 lazy_refcounts=off refcount_bits=16
# qemu-img info file.qcow2 
image: file.qcow2
file format: qcow2
virtual size: 1 GiB (1073741824 bytes)
disk size: 196 KiB
cluster_size: 65536
Format specific information:
    compat: 1.1
    compression type: zlib
    lazy refcounts: false
    refcount bits: 16
    corrupt: false

3.2 Use nbdfuse to transfer the file as raw:
# nbdfuse /test/file.raw --socket-activation qemu-nbd -f qcow2 file.qcow2 &
[1] 690079

3.3 Check the new file info
[root@zili-rhel8-test ~]# qemu-img info /test/file.raw 
image: /test/file.raw
file format: raw
virtual size: 1 GiB (1073741824 bytes)
disk size: 0 B

As above testing ,now change the bug from ON_QA to VERIFIED.

Comment 12 errata-xmlrpc 2020-11-17 17:46:46 UTC
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