[Libguestfs] [p2v PATCH 00/10] Simplify NBD server management

Laszlo Ersek
2022-03-31T07:22:01Z

Repo:   https://github.com/lersek/virt-p2v.git
Branch: nbd-servers-simplification

Rich proposed a list of tasks at
<https://listman.redhat.com/archives/libguestfs/2022-March/028475.html>,
for simplifying NBD server management. This series implements them.

Earlier I said I'd post this as an RFC series, but after reviewing and
testing the set myself, I decided to post it as a PATCH series.

The set builds at every stage. I verified the documentation
("docs/p2v-building.1" and "virt-p2v.1") at every stage that
modifies
the sources of those files, too.

The set passes

  make check

I also tested it with

  make run-virt-p2v-in-an-nvme-vm

i.e. an actual conversion, running against a RHEL9 conversion server
(virt-v2v 1.45.99rhel=9,release=1.el9; nbdkit 1.30.1-1.el9.x86_64). The
converted guest boots fine. The conversion log is available if needed.

On the p2v (virtual) machine, I saved the interesting messages from the
serial console (they are interesting because they relate to code
modified by this series):

> [  232.205162] launch-virt-p2v[669]: checking for nbdkit ...
> [  233.209388] launch-virt-p2v[675]: nbdkit 1.28.6 (nbdkit-1.28.6-1.fc35)
> [  233.213329] launch-virt-p2v[675]: file 1.28.6
> [  233.216906] launch-virt-p2v[669]: found nbdkit
>
> [  301.197612] launch-virt-p2v[669]: virt-p2v: bound to localhost:50123 (2
socket(s))
> [  301.198566] launch-virt-p2v[669]: starting nbdkit for /dev/nvme0n1 using
socket activation
> [  301.220919] launch-virt-p2v[669]: ssh command: ssh -p 22 -l root -o
StrictHostKeyChecking=no -o ConnectTimeout=60 -o ServerAliveInterval=300 -o
ServerAliveCountMax=6 -o PreferredAuthentications=keyboard-interactive,password
-R 0:localhost:50123 -N 192.168.122.184
> [  301.225792] launch-virt-p2v[748]: nbdkit: file[1]: error: reading
initial client flags: conn->recv: Connection reset by peer
>
> [  301.583073] launch-virt-p2v[669]: virt-p2v: data connection for
/dev/nvme0n1: SSH remote port 44479, local port 50123
>
> [  301.588509] launch-virt-p2v[669]: virt-p2v: bound to localhost:50124 (2
socket(s))
> [  301.592034] launch-virt-p2v[669]: starting nbdkit for /dev/nvme1n1 using
socket activation
> [  301.605749] launch-virt-p2v[669]: ssh command: ssh -p 22 -l root -o
StrictHostKeyChecking=no -o ConnectTimeout=60 -o ServerAliveInterval=300 -o
ServerAliveCountMax=6 -o PreferredAuthentications=keyboard-interactive,password
-R 0:localhost:50124 -N 192.168.122.184
> [  301.612459] launch-virt-p2v[751]: nbdkit: file[1]: error: reading
initial client flags: conn->recv: Connection reset by peer
>
> [  302.002998] launch-virt-p2v[669]: virt-p2v: data connection for
/dev/nvme1n1: SSH remote port 35789, local port 50124
>
> [  302.007171] launch-virt-p2v[669]: virt-p2v: bound to localhost:50125 (2
socket(s))
> [  302.009976] launch-virt-p2v[669]: starting nbdkit for /dev/nvme1n2 using
socket activation
> [  302.020637] launch-virt-p2v[669]: ssh command: ssh -p 22 -l root -o
StrictHostKeyChecking=no -o ConnectTimeout=60 -o ServerAliveInterval=300 -o
ServerAliveCountMax=6 -o PreferredAuthentications=keyboard-interactive,password
-R 0:localhost:50125 -N 192.168.122.184
> [  302.026882] launch-virt-p2v[754]: nbdkit: file[1]: error: reading
initial client flags: conn->recv: Connection reset by peer
>
> [  302.410966] launch-virt-p2v[669]: virt-p2v: data connection for
/dev/nvme1n2: SSH remote port 38663, local port 50125

I formatted the series with "-W" (aka "--function-context"),
for easier
review.

Some patches are best viewed with "-b" (aka
"--ignore-space-change"),
for masking un-indentation; I did not use that option for posting this
series, as it could interfere with applying the patches from the list.
For looking at some of the patches like that, fetch the series from the
URL at the top (or apply it from the list), and run "git show -b"
locally.

Thanks,
Laszlo

Laszlo Ersek (10):
  remove qemu-nbd support
  remove "--nbd=nbdkit-no-sa" option parsing
  nbd.c: simplify start_nbdkit()
  open-code "localhost" as the listen hostname for nbdkit
  nbd.c: remove bind_source_port()
  remove "--nbd" option parsing
  nbd.c: remove nbd_server_string()
  nbd.c: remove "enum nbd_server"
  rely on Linux for killing nbdkit, when the parent thread exits
  nbd.c: bind listening socket without AI_ADDRCONFIG

 Makefile.am                                                         |   2 -
 contrib/aux-scripts/do-build.sh                                     |   7 +-
 contrib/patches/0002-RHEL-5-ONLY-QEMU-NBD-1.4-HAS-NO-f-OPTION.patch |  34 --
 conversion.c                                                        |  23 +-
 dependencies.m4                                                     |   6 +-
 docs/p2v-building.pod                                               |   9 +-
 main.c                                                              |   7 +-
 nbd.c                                                               | 514
+++-----------------
 p2v.h                                                               |  10 +-
 ssh.c                                                               |   6 +-
 test-virt-p2v-nbdkit.sh                                             |   6 +-
 test-virt-p2v-scp.sh                                                |   2 +-
 test-virt-p2v-ssh.sh                                                |   4 +-
 test-virt-p2v.sh                                                    |  56 ---
 virt-p2v.pod                                                        |  49 +-
 15 files changed, 109 insertions(+), 626 deletions(-)
 delete mode 100644
contrib/patches/0002-RHEL-5-ONLY-QEMU-NBD-1.4-HAS-NO-f-OPTION.patch
 delete mode 100755 test-virt-p2v.sh


base-commit: c1a4bd83a8bba5959470ef1f6deb06dc61587112
--
2.19.1.3.g30247aa5d201