At Rich's suggestion at http://mid.mail-archive.com/20220923095410.GD7773 at redhat.com this series turns GTK3 into a fixed requirement for virt-p2v, also removing GTK2 support code. Along the way, some issues that I've just discovered are fixed. I've checked the series at every stage, plugging the command git clean -ffdx && git reset --hard && git submodule deinit --force --all && autoreconf -i && ./configure --enable-werror && make -j10 && make -j10 check && make dist maintainer-check-extra-dist into git rebase --exec '...' master I've verified the end result with "make run-virt-p2v-directly" and via a freshly built Live ISO. The HTML-rendered build instructions look good to me, too. Laszlo Laszlo Ersek (7): "shutdown_actions": suppress "missing initializer" warnings/errors contrib/: remove directory require GTK3 gui.c: remove line truncation (originally a workaround for a GTK2 bug) gui.c: fix warning label wrapping regression under GTK3 remove GTK2 compat code gui.c: annotate GTK_INPUT_PURPOSE_PASSWORD with upstream GTK3 version Makefile.am | 11 +- contrib/aux-scripts/do-build.sh | 196 -------------------- contrib/build-p2v-iso.sh | 154 --------------- contrib/patches/0001-RHEL-5-ONLY-DISABLE-AUTOMATIC-REMOTE-PORT-ALLOCATION.patch | 54 ------ contrib/test-p2v-iso.sh | 62 ------- dependencies.m4 | 10 +- docs/p2v-building.pod | 11 +- gui-gtk2-compat.h | 116 ------------ gui.c | 78 +------- m4/p2v-libraries.m4 | 32 +--- 10 files changed, 18 insertions(+), 706 deletions(-) delete mode 100644 contrib/aux-scripts/do-build.sh delete mode 100755 contrib/build-p2v-iso.sh delete mode 100644 contrib/patches/0001-RHEL-5-ONLY-DISABLE-AUTOMATIC-REMOTE-PORT-ALLOCATION.patch delete mode 100755 contrib/test-p2v-iso.sh delete mode 100644 gui-gtk2-compat.h
Laszlo Ersek
2022-Sep-26 08:18 UTC
[Libguestfs] [p2v PATCH 1/7] "shutdown_actions": suppress "missing initializer" warnings/errors
gcc reports:> gui.c:1795:3: error: missing initializer for field ?padding? of > ?GActionEntry? {aka ?const struct _GActionEntry?} > [-Werror=missing-field-initializers] > 1795 | { "shutdown", activate_action, NULL, NULL, NULL }, > > gui.c:1796:3: error: missing initializer for field ?padding? of > ?GActionEntry? {aka ?const struct _GActionEntry?} > [-Werror=missing-field-initializers] > 1796 | { "reboot", activate_action, NULL, NULL, NULL },I've found this only now because: - this is the first time I'm building virt-p2v with GTK3, - the "shutdown_actions" array depends on USE_POPOVERS which depends on GTK3 being selected, - the "missing-field-initializers" warning (treated as an error) has recently been enabled via "-Wextra" in commit 391f9833d398 ("p2v-c.m4: elicit a stricter set of warnings from gcc", 2022-09-23). The C-language documentation for GActionEntry is silent on the "padding" array: https://docs.gtk.org/gio/struct.ActionEntry.html However, the D-language docs expose it: https://api.gtkd.org/gio.c.types.GActionEntry.html Provide the missing field initializer. Signed-off-by: Laszlo Ersek <lersek at redhat.com> --- gui.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gui.c b/gui.c index 49301d9a985b..4faaa710ed90 100644 --- a/gui.c +++ b/gui.c @@ -1792,8 +1792,8 @@ static gboolean close_running_dialog (GtkWidget *w, GdkEvent *event, gpointer da #ifdef USE_POPOVERS static const GActionEntry shutdown_actions[] = { - { "shutdown", activate_action, NULL, NULL, NULL }, - { "reboot", activate_action, NULL, NULL, NULL }, + { "shutdown", activate_action, NULL, NULL, NULL, { 0 } }, + { "reboot", activate_action, NULL, NULL, NULL, { 0 } }, }; #endif
Laszlo Ersek
2022-Sep-26 08:18 UTC
[Libguestfs] [p2v PATCH 2/7] contrib/: remove directory
The "contrib" directory contains shell scripts and a RHEL-5 patch for building (and testing) the p2v ISO on RHEL major releases 5 through 7. Recently, we've resumed the P2V ISO preparation by adopting a Fedora 35+-based procedure, with the long term plan being the Image Builder service on RHEL-9+. Theferore the "contrib" directory is now obsolete; remove it. (The "contrib/build-p2v-iso.sh" script "blocks my way" because it references gtk2-devel, and in this series I'd like to remove gtk2 support from virt-p2v. We shouldn't be updating dead code.) Checked with "make dist maintainer-check-extra-dist". Signed-off-by: Laszlo Ersek <lersek at redhat.com> --- Makefile.am | 4 - contrib/aux-scripts/do-build.sh | 196 -------------------- contrib/build-p2v-iso.sh | 154 --------------- contrib/patches/0001-RHEL-5-ONLY-DISABLE-AUTOMATIC-REMOTE-PORT-ALLOCATION.patch | 54 ------ contrib/test-p2v-iso.sh | 62 ------- 5 files changed, 470 deletions(-) diff --git a/Makefile.am b/Makefile.am index 4a47a97251e9..d659ce65c06d 100644 --- a/Makefile.am +++ b/Makefile.am @@ -29,10 +29,6 @@ EXTRA_DIST = \ $(TESTS) $(LIBGUESTFS_TESTS) $(SLOW_TESTS) \ .gitignore \ AUTHORS \ - contrib/aux-scripts/do-build.sh \ - contrib/build-p2v-iso.sh \ - contrib/patches/0001-RHEL-5-ONLY-DISABLE-AUTOMATIC-REMOTE-PORT-ALLOCATION.patch \ - contrib/test-p2v-iso.sh \ dependencies.m4 \ generate-p2v-authors.pl \ generate-p2v-config.pl \ diff --git a/contrib/aux-scripts/do-build.sh b/contrib/aux-scripts/do-build.sh deleted file mode 100644 index 4a0aac840df0..000000000000 --- a/contrib/aux-scripts/do-build.sh +++ /dev/null @@ -1,196 +0,0 @@ -#!/bin/bash - -# Auxiliary script for building virt-p2v ISO. -# Copyright (C) 2017 Red Hat Inc. -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see <https://www.gnu.org/licenses/>. - -# See build-p2v-iso.sh - -set -e -set -x - -# Make sure we're in the virtual environment, and refuse to run otherwise. -if [ ! -f /var/tmp/livecd ]; then - echo "$0: do not run this script directly" - exit 1 -fi - -# If the script exits for any reason (including success) reboot. This -# in fact powers off the virtual machine because we are using -# qemu -no-reboot. -trap reboot INT QUIT TERM EXIT ERR - -cd /var/tmp - -osversion=`cat osversion` -livecd=`cat livecd` -source ./proxy -prefix=`rpm --eval '%_prefix'` -libdir=`rpm --eval '%_libdir'` -sysconfdir=`rpm --eval '%_sysconfdir'` - -# Build virt-p2v from libguestfs sources. -# We have to start from a tarball because at least RHEL 5 autotools -# isn't sufficiently new to run autoreconf. -zcat libguestfs.tar.gz | tar xf - -pushd libguestfs-* - -# Various hacks for different versions of RHEL. -case $osversion in - rhel-5.*|centos-5.*) - # This just forces configure to ignore these missing dependencies. - export LIBTINFO_CFLAGS=-D_GNU_SOURCE - export LIBTINFO_LIBS=-lncurses - export JANSSON_CFLAGS=-D_GNU_SOURCE - export JANSSON_LIBS=-ljansson - # Remove some unsupported flags that the configure script hard codes. - sed -i -e 's/-fno-strict-overflow//' configure - sed -i -e 's/-Wno-strict-overflow//' configure - # Apply some RHEL 5 only patches. - patch -p1 < ../patches/0001-RHEL-5-ONLY-DISABLE-AUTOMATIC-REMOTE-PORT-ALLOCATION.patch - ;; - rhel-6.*|centos-6.*) - # This just forces configure to ignore these missing dependencies. - export LIBTINFO_CFLAGS=-D_GNU_SOURCE - export LIBTINFO_LIBS=-lncurses - export JANSSON_CFLAGS=-D_GNU_SOURCE - export JANSSON_LIBS=-ljansson - ;; -esac - -export vmchannel_test=no -./configure \ - --prefix $prefix \ - --libdir $libdir \ - --sysconfdir $sysconfdir \ - --disable-static \ - --disable-appliance \ - --disable-daemon \ - --disable-lua \ - --disable-ocaml \ - --disable-perl \ - --disable-php \ - --disable-python \ - --disable-ruby \ - --with-qemu=no -# We only need to build a handful of directories to get virt-p2v. -make -C generator -make -C gnulib/lib -make -C common/utils -make -C common/miniexpect -make -C p2v virt-p2v virt-p2v.xz dependencies.redhat -make run - -# Check virt-p2v was built and runs. -./run ./p2v/virt-p2v --version -./run ./p2v/virt-p2v-make-kickstart --version - -# Create the kickstart file. -if [ "x$http_proxy" != "x" ]; then proxy="--proxy=$http_proxy"; fi -./run ./p2v/virt-p2v-make-kickstart -o /var/tmp/p2v.ks $osversion $proxy - -popd - -# More hacks for different versions of RHEL. -case $osversion in - rhel-5.*|centos-5.*) - # RHEL 5 livecd-tools is broken with syslinux, this fixes it: - sed -i -e 's,/usr/lib/syslinux/,/usr/share/syslinux/,g'\ - /usr/lib/python2.4/site-packages/imgcreate/live.py - # livecd-tools cannot parse certain aspects of the kickstart: - sed -i \ - -e 's/--plaintext//g' \ - -e 's/^firewall.*//g' \ - -e 's/^%end.*//g' \ - p2v.ks - # Remove some packages which don't exist on RHEL 5: - sed -i \ - -e 's,^dracut-live.*,,g' \ - -e 's,^dejavu-.*,,g' \ - -e 's,^mesa-dri-drivers.*,,g' \ - -e 's,^network-manager-applet.*,,g' \ - -e 's,^nm-connection-editor.*,,g' \ - -e 's,^nbdkit-server.*,,g' \ - -e 's,^nbdkit-file-plugin.*,,g' \ - -e '/^net-tools/a syslinux' \ - p2v.ks - # Remove systemctl lines, doesn't exist on RHEL 5. - sed -i \ - -e 's/^\(systemctl.*\)/#\1/g' \ - p2v.ks - ;; - rhel-6.*|centos-6.*) - # Remove some packages which don't exist on RHEL 6: - sed -i \ - -e 's,^dracut-live.*,,g' \ - -e 's,^firewalld.*,,g' \ - -e 's,^network-manager-applet.*,,g' \ - -e 's,^nm-connection-editor.*,,g' \ - -e 's,^nbdkit-server.*,,g' \ - -e 's,^nbdkit-file-plugin.*,,g' \ - p2v.ks - # Remove systemctl lines, doesn't exist on RHEL 5. - sed -i \ - -e 's/^\(systemctl.*\)/#\1/g' \ - p2v.ks - ;; -esac - -# Build nbdkit -zcat nbdkit.tar.gz | tar xf - -pushd nbdkit-* -./configure \ - CFLAGS="-D_GNU_SOURCE" \ - --prefix $prefix \ - --libdir $libdir \ - --sysconfdir $sysconfdir \ - --without-liblzma -make -cp src/nbdkit .. -cp plugins/file/.libs/nbdkit-file-plugin.so .. -popd -gzip -c nbdkit > nbdkit.gz -gzip -c nbdkit-file-plugin.so > nbdkit-file-plugin.so.gz -base64 nbdkit.gz > nbdkit.gz.b64 -base64 nbdkit-file-plugin.so.gz > nbdkit-file-plugin.so.gz.b64 - -# Add nbdkit binaries to the kickstart. -echo > fragment.ks -echo '#' `md5sum nbdkit` >> fragment.ks -echo 'base64 -d -i <<EOF | gzip -cd > /usr/bin/nbdkit' >> fragment.ks -cat nbdkit.gz.b64 >> fragment.ks -echo >> fragment.ks -echo EOF >> fragment.ks -echo 'chmod 0755 /usr/bin/nbdkit' >> fragment.ks -echo >> fragment.ks - -echo '#' `md5sum nbdkit-file-plugin.so` >> fragment.ks -echo 'mkdir -p' $libdir/nbdkit/plugins >> fragment.ks -echo 'base64 -d -i <<EOF | gzip -cd >' $libdir/nbdkit/plugins/nbdkit-file-plugin.so >> fragment.ks -cat nbdkit-file-plugin.so.gz.b64 >> fragment.ks -echo >> fragment.ks -echo EOF >> fragment.ks -echo 'chmod 0755' $libdir/nbdkit/plugins/nbdkit-file-plugin.so >> fragment.ks -echo >> fragment.ks - -sed -i -e '/^chmod.*\/usr\/bin\/virt-p2v$/ r fragment.ks' p2v.ks - -# Run livecd-creator to make the live CD. The strange redirect works -# around a bug in RHEL 5's livecd-tools: "/sbin/mksquashfs: invalid -# option" is printed if the output is redirected to a file -# (https://bugs.centos.org/bug_view_page.php?bug_id=3738) -livecd-creator -c p2v.ks > `tty` 2>&1 - -# Move the live CD to the final filename. -mv livecd-*.iso $livecd diff --git a/contrib/build-p2v-iso.sh b/contrib/build-p2v-iso.sh deleted file mode 100755 index c8a456eccb59..000000000000 --- a/contrib/build-p2v-iso.sh +++ /dev/null @@ -1,154 +0,0 @@ -#!/bin/bash - -# Build virt-p2v ISO for RHEL 5/6/7. -# Copyright (C) 2017 Red Hat Inc. -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see <https://www.gnu.org/licenses/>. - -# This script is used to build the virt-p2v ISO on RHEL 5/6/7, -# for 32 bit (i686) and 64 bit (x86-64). -# -# This script is *not* used to build the official RHEL 7 virt-p2v ISO -# for Red Hat customers. However it is used to build alternate ISOs -# which can optionally be used by customers who need older RHEL -# (eg. for proprietary FakeRAID drivers), or have 32 bit physical -# machines that they wish to virtualize. -# -# The virt-p2v ISOs built by this script are hosted at: -# http://oirase.annexia.org/virt-p2v/ - -set -e - -usage () -{ - echo ' libguestfs and nbdkit tarballs' - echo ' (http URLs may also be used here)' - echo ' |' - echo './build-p2v-iso.sh file:///path/to/libguestfs-1.XX.YY.tar.gz \' - echo ' file:///path/to/nbdkit-1.XX.YY.tar.gz \' - echo ' rhel-5.11 i686' - echo ' | |' - echo ' | `--- architecture (i686 or x86_64)' - echo ' `---- version of RHEL (5.x or 6.x tested)' - echo - echo 'Note this downloads the libguestfs tarball from upstream, it' - echo 'does not use libguestfs from the current directory.' - echo - echo 'Minimum versions of: libguestfs = 1.35.22' - echo ' nbdkit = 1.1.13' - echo - echo 'You should run the script on a Fedora (or recent Linux) host.' - echo 'It uses virt-builder to create the RHEL environment' - exit 0 -} - -if [ $# -ne 4 ]; then - usage -fi - -tmpdir="$(mktemp -d)" -cleanup () -{ - rm -rf "$tmpdir" -} -trap cleanup INT QUIT TERM EXIT ERR - -libguestfs_tarball=$1 -nbdkit_tarball=$2 -osversion=$3 -arch=$4 - -# Get the path to the auxiliary script. -d="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" -if [ ! -d "$d/aux-scripts" ]; then - echo "$0: error: cannot locate auxiliary scripts" - exit 1 -fi - -# Build the list of packages needed for the build environment. -pkgs=augeas-devel,bison,coreutils,cpio,file-devel,flex,gcc,gperf,gtk2-devel,libxml2-devel,livecd-tools,mkisofs,ncurses-devel,patch,perl-Pod-Man,perl-Pod-Simple,pcre2-devel,/usr/bin/pod2text,syslinux,syslinux-extlinux,xz,xz-devel - -for f in `cat $d/../../p2v/dependencies.redhat`; do - pkgs="$pkgs,$f" -done - -# Various hacks for different versions of RHEL. -if=virtio -netdev=virtio-net-pci -declare -a epel -case $osversion in - rhel-5.*|centos-5.*) - if=ide - netdev=rtl8139 - # RHEL 5 yum cannot download a package. - curl -o $tmpdir/epel-release.rpm https://dl.fedoraproject.org/pub/epel/epel-release-latest-5.noarch.rpm - epel[0]="--upload" - epel[1]="$tmpdir/epel-release.rpm:/var/tmp" - # RHEL 5 i686 template has a broken RPM DB, so rebuild it. - epel[2]="--run-command" - epel[3]="rm -f /var/lib/rpm/__db*; rpm -vv --rebuilddb" - epel[4]="--run-command" - epel[5]="yum install -y --nogpgcheck /var/tmp/epel-release.rpm" - ;; - rhel-6.*|centos-6.*) - epel[0]="--run-command" - epel[1]="yum install -y --nogpgcheck https://dl.fedoraproject.org/pub/epel/epel-release-latest-6.noarch.rpm" - pkgs="$pkgs,jansson-devel" - ;; - rhel-7.*|centos-7.*) - epel[0]="--run-command" - epel[1]="yum install -y --nogpgcheck https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm" - pkgs="$pkgs,jansson-devel" - ;; -esac - -# Download libguestfs and nbdkit sources. -curl -o $tmpdir/libguestfs.tar.gz $libguestfs_tarball -curl -o $tmpdir/nbdkit.tar.gz $nbdkit_tarball - -# Write a proxy file for the guest environment. -echo "export http_proxy=$http_proxy" >> $tmpdir/proxy -echo "export https_proxy=$https_proxy" >> $tmpdir/proxy -echo "export ftp_proxy=$ftp_proxy" >> $tmpdir/proxy - -# Build the temporary guest RHEL environment. -disk=$tmpdir/tmp-$osversion.img -livecd=virt-p2v-livecd-$osversion-$arch-`date +"%Y%m%d%H%M"`.iso -virt-builder $osversion --arch $arch \ - --size 20G --output $disk \ - "${epel[@]}" \ - --install "$pkgs" \ - --upload $tmpdir/libguestfs.tar.gz:/var/tmp \ - --upload $tmpdir/nbdkit.tar.gz:/var/tmp \ - --copy-in $d/patches:/var/tmp \ - --write /var/tmp/osversion:$osversion \ - --write /var/tmp/livecd:$livecd \ - --upload $tmpdir/proxy:/var/tmp/proxy \ - --firstboot $d/aux-scripts/do-build.sh \ - --selinux-relabel - -# Run the guest. -qemu-system-x86_64 -no-user-config -nodefaults -nographic \ - -no-reboot \ - -machine accel=kvm:tcg \ - -cpu host \ - -m 4096 \ - -drive file=$disk,format=raw,if=$if \ - -netdev user,id=usernet,net=169.254.0.0/16 \ - -device $netdev,netdev=usernet \ - -serial stdio - -# Did we get any output from the auxiliary script? -# (This command will fail if not) -guestfish --ro -a $disk -i download /var/tmp/$livecd $livecd -ls -lh $livecd diff --git a/contrib/patches/0001-RHEL-5-ONLY-DISABLE-AUTOMATIC-REMOTE-PORT-ALLOCATION.patch b/contrib/patches/0001-RHEL-5-ONLY-DISABLE-AUTOMATIC-REMOTE-PORT-ALLOCATION.patch deleted file mode 100644 index a4efb38bf08f..000000000000 --- a/contrib/patches/0001-RHEL-5-ONLY-DISABLE-AUTOMATIC-REMOTE-PORT-ALLOCATION.patch +++ /dev/null @@ -1,54 +0,0 @@ -From 28dd464c8e78f241622d142671a61a75bf5d758e Mon Sep 17 00:00:00 2001 -From: "Richard W.M. Jones" <rjones at redhat.com> -Date: Sat, 21 Jan 2017 05:30:40 -0500 -Subject: [PATCH 1/2] RHEL 5 ONLY DISABLE AUTOMATIC REMOTE PORT ALLOCATION - ---- - p2v/ssh.c | 15 ++++++++++++++- - 1 file changed, 14 insertions(+), 1 deletion(-) - -diff --git a/p2v/ssh.c b/p2v/ssh.c -index 8beaf74..919f2df 100644 ---- a/p2v/ssh.c -+++ b/p2v/ssh.c -@@ -1044,16 +1044,28 @@ open_data_connection (struct config *config, - "-N", - NULL - }; -+#if 0 - CLEANUP_FREE char *port_str = NULL; - const int ovecsize = 12; - int ovector[ovecsize]; -+#endif - -- snprintf (remote_arg, sizeof remote_arg, "0:%s:%d", local_ipaddr, local_port); -+ /* RHEL 5 hack: ssh does not print the "Allocated port ..." string, -+ * so we cannot find the remotely allocated port. Instead just -+ * assign a random port and hope for the best. -+ */ -+ static int next_remote_port = 58123; -+ -+ snprintf (remote_arg, sizeof remote_arg, "%d:%s:%d", -+ next_remote_port, local_ipaddr, local_port); -+ *remote_port = next_remote_port; -+ next_remote_port++; - - h = start_ssh (0, config, (char **) extra_args, 0); - if (h == NULL) - return NULL; - -+#if 0 - switch (mexp_expect (h, - (mexp_regexp[]) { - { 100, .re = portfwd_re }, -@@ -1094,6 +1106,7 @@ open_data_connection (struct config *config, - mexp_close (h); - return NULL; - } -+#endif - - return h; - } --- -1.8.2.3 - diff --git a/contrib/test-p2v-iso.sh b/contrib/test-p2v-iso.sh deleted file mode 100755 index 9ac4c6a301cb..000000000000 --- a/contrib/test-p2v-iso.sh +++ /dev/null @@ -1,62 +0,0 @@ -#!/bin/bash - -# Test virt-p2v ISO for RHEL 5/6/7. -# Copyright (C) 2017 Red Hat Inc. -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see <https://www.gnu.org/licenses/>. - -# Once you have built a virt-p2v ISO (see build-p2v-iso.sh), you -# can interactively test it using this script. - -set -e - -usage () -{ - echo './test-p2v-iso.sh virt-p2v-livecd-....iso' - exit 0 -} - -if [ $# -ne 1 ]; then - usage -fi - -tmpdir="$(mktemp -d)" -cleanup () -{ - rm -rf "$tmpdir" -} -trap cleanup INT QUIT TERM EXIT ERR - -iso=$1 -if [ ! -f "$iso" ]; then - echo "$iso: file not found" - exit 1 -fi - -# Build a temporary guest to test. -disk=$tmpdir/guest.img -virt-builder rhel-6.8 --output $disk - -# Boot the guest as if running with virt-p2v ISO in the CD drive. -qemu-system-x86_64 -no-user-config -nodefaults \ - -no-reboot \ - -machine accel=kvm:tcg \ - -cpu host \ - -m 4096 \ - -display gtk \ - -vga std \ - -drive file=$disk,format=raw,if=ide \ - -cdrom $iso \ - -netdev user,id=usernet,net=169.254.0.0/16 \ - -device rtl8139,netdev=usernet \ - -boot d
Virt-p2v now requires PCRE2, so we can no longer compile virt-p2v on RHEL<=6. This means we can now also require GTK3. In this patch, remove the ./configure knob for GTK version selection, remove the auto-detection, open-code the dependency, and update the build docs. Note that the autoconf module name is changed from GTK to GTK3 as well (for prior art, see commit fb42310a8d0c, "miniexpect: Import miniexpect 1.1 and upgrade to PCRE2", 2022-07-25); this results in ./configure taking GTK3_CFLAGS and GTK3_LIBS. Signed-off-by: Laszlo Ersek <lersek at redhat.com> --- Makefile.am | 6 ++-- dependencies.m4 | 10 +++--- docs/p2v-building.pod | 11 +------ m4/p2v-libraries.m4 | 32 ++------------------ 4 files changed, 11 insertions(+), 48 deletions(-) diff --git a/Makefile.am b/Makefile.am index d659ce65c06d..126ee726278a 100644 --- a/Makefile.am +++ b/Makefile.am @@ -141,13 +141,13 @@ virt_p2v_CFLAGS = \ $(WARN_CFLAGS) $(WERROR_CFLAGS) \ $(PCRE2_CFLAGS) \ $(LIBXML2_CFLAGS) \ - $(GTK_CFLAGS) \ + $(GTK3_CFLAGS) \ $(DBUS_CFLAGS) virt_p2v_LDADD = \ $(PCRE2_LIBS) \ $(LIBXML2_LIBS) \ - $(GTK_LIBS) \ + $(GTK3_LIBS) \ $(DBUS_LIBS) \ gnulib/lib/libgnu.la \ -lm @@ -169,7 +169,7 @@ dependencies_files = \ $(dependencies_files): dependencies.m4 config.status define=`echo $@ | $(SED) 's/dependencies.//;y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'`; \ - m4 -D$$define=1 -DGTK_VERSION=$(GTK_VERSION) $< > $@-t + m4 -D$$define=1 $< > $@-t mv $@-t $@ # Support files needed by the virt-p2v-make-* scripts. diff --git a/dependencies.m4 b/dependencies.m4 index 7bbeb37d5412..b6d7db37287b 100644 --- a/dependencies.m4 +++ b/dependencies.m4 @@ -24,7 +24,7 @@ ifelse(REDHAT,1, dnl Used by the virt-p2v binary. pcre2 libxml2 - gtk`'GTK_VERSION + gtk3 dbus-libs dnl Run as external programs by the p2v binary. @@ -68,7 +68,7 @@ ifelse(REDHAT,1, ifelse(DEBIAN,1, libpcre2-8-0 libxml2 - ifelse(GTK_VERSION,2,libgtk`'GTK_VERSION`'.0-0,libgtk-`'GTK_VERSION`'-0) + libgtk-3-0 libdbus-1-3 openssh-client nbdkit @@ -88,7 +88,7 @@ ifelse(DEBIAN,1, ifelse(ARCHLINUX,1, pcre2 libxml2 - gtk`'GTK_VERSION + gtk3 dbus openssh nbdkit @@ -110,7 +110,7 @@ ifelse(ARCHLINUX,1, ifelse(SUSE,1, pcre2 libxml2 - gtk`'GTK_VERSION + gtk3 libdbus-1-3 nbdkit-server nbdkit-file-plugin @@ -135,7 +135,7 @@ ifelse(OPENMANDRIVA,1, dnl Used by the virt-p2v binary. pcre2 libxml2 - gtk`'GTK_VERSION + gtk3 dbus-libs dnl Run as external programs by the p2v binary. diff --git a/docs/p2v-building.pod b/docs/p2v-building.pod index cb418049fd51..e1ba4de12504 100644 --- a/docs/p2v-building.pod +++ b/docs/p2v-building.pod @@ -80,14 +80,10 @@ Optional. L<virt-p2v(1)> requires nbdkit, but it only needs to be present on the virt-p2v ISO, it does not need to be installed at compile time. -=item Gtk E<ge> 2.24, or 3 +=item Gtk 3 I<Required>. -Either Gtk 2 or Gtk 3 can be used. If you want to select a specific -version of Gtk, use S<C<./configure --with-gtk=2>> or -S<C<./configure --with-gtk=3>>. - =item D-Bus Optional. @@ -201,11 +197,6 @@ by users. For custom and/or local builds, this can be set to C<local> to indicate this is I<not> a distro build. -=item B<--with-gtk=3> - -This option forces virt-p2v to be built against Gtk 3, which is -currently the most widely tested configuration. - =back =head1 USING CLANG (LLVM) INSTEAD OF GCC diff --git a/m4/p2v-libraries.m4 b/m4/p2v-libraries.m4 index 8604baaf8d83..a00b301056d2 100644 --- a/m4/p2v-libraries.m4 +++ b/m4/p2v-libraries.m4 @@ -32,36 +32,8 @@ PKG_CHECK_MODULES([PCRE2], [libpcre2-8]) dnl libxml2 (required) PKG_CHECK_MODULES([LIBXML2], [libxml-2.0]) -dnl Check for Gtk 2 or 3 library, used by virt-p2v. -AC_MSG_CHECKING([for --with-gtk option]) -AC_ARG_WITH([gtk], - [AS_HELP_STRING([--with-gtk=2|3|check|no], - [prefer Gtk version 2 or 3. @<:@default=check@:>@])], - [with_gtk="$withval" - AC_MSG_RESULT([$withval])], - [with_gtk="check" - AC_MSG_RESULT([not set, will check for installed Gtk])] -) - -if test "x$with_gtk" = "x3"; then - PKG_CHECK_MODULES([GTK], [gtk+-3.0], [ - GTK_VERSION=3 - ]) -elif test "x$with_gtk" = "x2"; then - PKG_CHECK_MODULES([GTK], [gtk+-2.0], [ - GTK_VERSION=2 - ], []) -elif test "x$with_gtk" = "xcheck"; then - PKG_CHECK_MODULES([GTK], [gtk+-3.0], [ - GTK_VERSION=3 - ], [ - PKG_CHECK_MODULES([GTK], [gtk+-2.0], [ - GTK_VERSION=2 - ]) - ]) -fi - -AC_SUBST([GTK_VERSION]) +dnl Check for Gtk 3 library, used by virt-p2v (required). +PKG_CHECK_MODULES([GTK3], [gtk+-3.0]) dnl D-Bus is an optional dependency of virt-p2v. PKG_CHECK_MODULES([DBUS], [dbus-1], [
Laszlo Ersek
2022-Sep-26 08:18 UTC
[Libguestfs] [p2v PATCH 4/7] gui.c: remove line truncation (originally a workaround for a GTK2 bug)
Commit eaa5ce8b43e0 ("p2v: Break long lines when displaying virt-v2v output in GUI.", 2016-01-08) introduced *line breaking* as a workaround for a GTK2 regression, under which the handling of long lines from the virt-v2v log would slow down very much. Commit e09b955bdbbc ("p2v: Use virt-v2v --colours option, support colour in the run dialog (RHBZ#1314244).", 2016-06-18) silently changed the *line breaking* workaround into *line truncation*, also adopting a much shorter cut-off length (replacing 1024 with 256). Now, whether this logic remains useful is untestable today. That's because commit 9b057cc1ac5f ("p2v: Don't display debugging messages in the run dialog.", 2016-06-18), from the same series as the one that commit e09b955bdbbc belonged to [*], had relegated the verbose & trace messages -- IOW, all the long lines -- from the GUI to the conversion log file (except maybe the last 50 lines of a failed conversion's log). [*] https://bugzilla.redhat.com/show_bug.cgi?id=1314244#c4 Therefore, the line truncation workaround may have become effectively useless right at the end of that series, and stays most probably dead code today, regardless of the GTK version used. This is relevant because we want to remove GTK2 support from virt-p2v. Some evidence would be nice as to whether the line truncation is obsolete due to (a) GTK3 not suffering from the long line slowdown, or (b) GTK3 still having the bug, but the bug not being triggered due to commit 9b057cc1ac5f. Either way -- that is, even though this is untestable --, just remove the truncating state from the v2v message parsing automaton. The truncating state is only reachable from the normal state, and it also returns to the normal state, so the removal is not complicated. Remove the "dots" helper variable too. The (static) variable "linelen" is only consumed in the normal->truncating transition condition, so drop that one as well. Signed-off-by: Laszlo Ersek <lersek at redhat.com> --- gui.c | 26 -------------------- 1 file changed, 26 deletions(-) diff --git a/gui.c b/gui.c index 4faaa710ed90..1e2cd3f94c62 100644 --- a/gui.c +++ b/gui.c @@ -2026,7 +2026,6 @@ add_v2v_output (gpointer user_data) { CLEANUP_FREE const char *msg = user_data; const char *p; - static size_t linelen = 0; static enum { state_normal, state_escape1, /* seen ESC, expecting [ */ @@ -2036,13 +2035,11 @@ add_v2v_output (gpointer user_data) state_escape5, /* seen ESC [ 0/1 ; 3, expecting 1/2/4/5 */ state_escape6, /* seen ESC [ 0/1 ; 3 1/2/5/5, expecting m */ state_cr, /* seen CR */ - state_truncating, /* truncating line until next \n */ } state = state_normal; static int colour = 0; static GtkTextTag *tag = NULL; GtkTextBuffer *buf = gtk_text_view_get_buffer (GTK_TEXT_VIEW (v2v_output)); GtkTextIter iter, iter2; - const char *dots = " [...]"; for (p = msg; *p != '\0'; ++p) { char c = *p; @@ -2055,22 +2052,7 @@ add_v2v_output (gpointer user_data) state = state_escape1; colour = 0; } - else if (c != '\n' && linelen >= 256) { - /* Gtk2 (in ~ Fedora 23) has a regression where it takes much - * longer to display long lines, to the point where the - * virt-p2v UI would still be slowly displaying kernel modules - * while the conversion had finished. For this reason, - * arbitrarily truncate very long lines. - */ - gtk_text_buffer_get_end_iter (buf, &iter); - gtk_text_buffer_insert_with_tags (buf, &iter, - dots, strlen (dots), tag, NULL); - state = state_truncating; - colour = 0; - tag = NULL; - } else { /* Treat everything else as a normal char. */ - if (c != '\n') linelen++; else linelen = 0; gtk_text_buffer_get_end_iter (buf, &iter); gtk_text_buffer_insert_with_tags (buf, &iter, &c, 1, tag, NULL); } @@ -2134,7 +2116,6 @@ add_v2v_output (gpointer user_data) /* Process CRLF as single a newline character. */ p--; else { /* Delete current (== last) line. */ - linelen = 0; gtk_text_buffer_get_end_iter (buf, &iter); iter2 = iter; gtk_text_iter_set_line_offset (&iter, 0); @@ -2143,13 +2124,6 @@ add_v2v_output (gpointer user_data) } state = state_normal; break; - - case state_truncating: - if (c == '\n') { - p--; - state = state_normal; - } - break; } /* switch (state) */ } /* for */
Laszlo Ersek
2022-Sep-26 08:18 UTC
[Libguestfs] [p2v PATCH 5/7] gui.c: fix warning label wrapping regression under GTK3
(Note that this issue is reproducible with virt-p2v v1.42.2.) When building virt-p2v with GTK3 (specifically, gtk3-3.24.34-1.fc35.x86_64), the label that warns about too many VCPUs and/or too much guest RAM does not wrap, even though we set it to wrapping. Instead, the (otherwise fixed size) outer window is resized with a sudden jump, to accommodate the (now very long) single-line warning. This issue does not manifest itself under GTK2, which is why I've not noticed it thus far. Under GTK3, we can mitigate the symptom by following the advice at: https://wiki.gnome.org/HowDoI/Labels#Labels_in_non-resizable_windows Namely, set the "max-width-chars" property of the label, specifying the "natural width" of the label, expressed in units of average-width characters. The empirical value 50 seems to do what GTK2 does out of the box. Signed-off-by: Laszlo Ersek <lersek at redhat.com> --- gui.c | 1 + 1 file changed, 1 insertion(+) diff --git a/gui.c b/gui.c index 1e2cd3f94c62..5d1771266605 100644 --- a/gui.c +++ b/gui.c @@ -835,6 +835,7 @@ create_conversion_dialog (struct config *config, gtk_label_set_line_wrap (GTK_LABEL (target_warning_label), TRUE); gtk_label_set_line_wrap_mode (GTK_LABEL (target_warning_label), PANGO_WRAP_WORD); + gtk_label_set_max_width_chars (GTK_LABEL (target_warning_label), 50); gtk_widget_set_size_request (target_warning_label, -1, 7 * 16); gtk_box_pack_end (GTK_BOX (target_vbox), target_warning_label, TRUE, TRUE, 0);
Remove GTK2 compat code. Open-code conditional compilation directives that evaluate to constant values when virt-p2v is built with GTK3. A special note regarding GTK_SPINNER (because the code does not use a version check for the spinner widget's availability): upstream GTK introduced GTK_SPINNER in commit d21700f5105c ("Bug 319607 ? Add a throbber (activity widget) to GTK+", 2009-10-14), which commit was first released in version 2.19.0, and is also contained within release 3.0.0. Even within GTK3, we have multiple compatibility layers. If we only concentrated on RHEL-9+ and Fedora-35+, we could much simplify "gui-gtk3-compat.h" as well (potentially flattening the whole header file into C sources). Given that we build virt-p2v on multiple distro families, establishing a common base version for GTK3, higher than version 3.0.0, is not so simple. So preserve "gui-gtk3-compat.h" for now. Signed-off-by: Laszlo Ersek <lersek at redhat.com> --- Makefile.am | 1 - gui-gtk2-compat.h | 116 -------------------- gui.c | 45 +------- 3 files changed, 3 insertions(+), 159 deletions(-) diff --git a/Makefile.am b/Makefile.am index 126ee726278a..eaa98270fd9a 100644 --- a/Makefile.am +++ b/Makefile.am @@ -106,7 +106,6 @@ virt_p2v_SOURCES = \ cpuid.c \ disks.c \ gui.c \ - gui-gtk2-compat.h \ gui-gtk3-compat.h \ inhibit.c \ kernel.c \ diff --git a/gui-gtk2-compat.h b/gui-gtk2-compat.h deleted file mode 100644 index ac9cb6022154..000000000000 --- a/gui-gtk2-compat.h +++ /dev/null @@ -1,116 +0,0 @@ -/* virt-p2v - * Copyright (C) 2009-2019 Red Hat Inc. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <https://www.gnu.org/licenses/>. - */ - -/* Backwards compatibility for ancient RHEL 5 Gtk 2.10. */ -#ifndef GTK_COMBO_BOX_TEXT -#define GTK_COMBO_BOX_TEXT GTK_COMBO_BOX -#define gtk_combo_box_text_new() gtk_combo_box_new_text() -#define gtk_combo_box_text_append_text(combo, text) \ - gtk_combo_box_append_text((combo), (text)) -#define gtk_combo_box_text_get_active_text(combo) \ - gtk_combo_box_get_active_text((combo)) -#endif - -#if !GTK_CHECK_VERSION(2,12,0) /* gtk < 2.12 */ -#define gtk_widget_set_tooltip_markup(widget, text) /* nothing */ -#endif - -#if !GTK_CHECK_VERSION(2,14,0) /* gtk < 2.14 */ -#define gtk_dialog_get_content_area(dlg) ((dlg)->vbox) -#endif - -#if !GTK_CHECK_VERSION(2,18,0) /* gtk < 2.18 */ -static void -gtk_cell_renderer_set_alignment (GtkCellRenderer *cell, - gfloat xalign, gfloat yalign) -{ - if ((xalign != cell->xalign) || (yalign != cell->yalign)) { - g_object_freeze_notify (G_OBJECT (cell)); - - if (xalign != cell->xalign) { - cell->xalign = xalign; - g_object_notify (G_OBJECT (cell), "xalign"); - } - - if (yalign != cell->yalign) { - cell->yalign = yalign; - g_object_notify (G_OBJECT (cell), "yalign"); - } - - g_object_thaw_notify (G_OBJECT (cell)); - } -} -#endif - -#if !GTK_CHECK_VERSION(2,20,0) /* gtk < 2.20 */ -typedef struct _ResponseData ResponseData; - -struct _ResponseData -{ - gint response_id; -}; - -static void -response_data_free (gpointer data) -{ - g_slice_free (ResponseData, data); -} - -static ResponseData * -get_response_data (GtkWidget *widget, gboolean create) -{ - ResponseData *ad = g_object_get_data (G_OBJECT (widget), - "gtk-dialog-response-data"); - - if (ad == NULL && create) { - ad = g_slice_new (ResponseData); - - g_object_set_data_full (G_OBJECT (widget), - g_intern_static_string ("gtk-dialog-response-data"), - ad, - response_data_free); - } - - return ad; -} - -static GtkWidget * -gtk_dialog_get_widget_for_response (GtkDialog *dialog, gint response_id) -{ - GList *children; - GList *tmp_list; - - children = gtk_container_get_children (GTK_CONTAINER (dialog->action_area)); - - tmp_list = children; - while (tmp_list != NULL) { - GtkWidget *widget = tmp_list->data; - ResponseData *rd = get_response_data (widget, FALSE); - - if (rd && rd->response_id == response_id) { - g_list_free (children); - return widget; - } - - tmp_list = tmp_list->next; - } - - g_list_free (children); - - return NULL; -} -#endif /* gtk < 2.20 */ diff --git a/gui.c b/gui.c index 5d1771266605..6e785497b968 100644 --- a/gui.c +++ b/gui.c @@ -47,12 +47,9 @@ * handled entirely by NetworkManager's L<nm-connection-editor(1)> * program and has nothing to do with this code. * - * This file is written in a kind of "pseudo-Gtk" which is backwards - * compatible from Gtk 2.10 (RHEL 5) through at least Gtk 3.22. This - * is done using a few macros to implement old C<gtk_*> functions or - * map them to newer functions. Supporting ancient Gtk is important - * because we want to provide a virt-p2v binary that can run on very - * old kernels, to support 32 bit and proprietary SCSI drivers. + * This file is written in a kind of "pseudo-Gtk" which is backwards compatible + * from Gtk 3.0 through at least Gtk 3.22. This is done using a few macros to + * implement old C<gtk_*> functions or map them to newer functions. */ #include <config.h> @@ -86,7 +83,6 @@ #include "p2v.h" /* See note about "pseudo-Gtk" above. */ -#include "gui-gtk2-compat.h" #include "gui-gtk3-compat.h" /* Maximum vCPUs and guest memory that we will allow users to set. @@ -116,9 +112,7 @@ static GtkWidget *conn_dlg, *server_entry, *port_entry, *username_entry, *password_entry, *identity_entry, *sudo_button, *spinner_hbox, -#ifdef GTK_SPINNER *spinner, -#endif *spinner_message, *next_button; /* The conversion dialog. */ @@ -138,23 +132,6 @@ static GtkWidget *run_dlg, /* Colour tags used in the v2v_output GtkTextBuffer. */ static GtkTextTag *v2v_output_tags[16]; -#if !GTK_CHECK_VERSION(3,0,0) /* gtk < 3 */ -/* The license of virt-p2v, for the About dialog. */ -static const char gplv2plus[] - "This program is free software; you can redistribute it and/or modify\n" - "it under the terms of the GNU General Public License as published by\n" - "the Free Software Foundation; either version 2 of the License, or\n" - "(at your option) any later version.\n" - "\n" - "This program is distributed in the hope that it will be useful,\n" - "but WITHOUT ANY WARRANTY; without even the implied warranty of\n" - "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n" - "GNU General Public License for more details.\n" - "\n" - "You should have received a copy of the GNU General Public License\n" - "along with this program. If not, see <https://www.gnu.org/licenses/>.\n"; -#endif - /** * The entry point from the main program. * @@ -304,10 +281,8 @@ create_connection_dialog (struct config *config) gtk_box_pack_start (GTK_BOX (test_hbox), test, TRUE, FALSE, 0); hbox_new (spinner_hbox, FALSE, 10); -#ifdef GTK_SPINNER spinner = gtk_spinner_new (); gtk_box_pack_start (GTK_BOX (spinner_hbox), spinner, FALSE, FALSE, 0); -#endif spinner_message = gtk_label_new (NULL); gtk_label_set_line_wrap (GTK_LABEL (spinner_message), TRUE); set_padding (spinner_message, 10, 10); @@ -452,9 +427,7 @@ test_connection_clicked (GtkWidget *w, gpointer data) gtk_label_set_text (GTK_LABEL (spinner_message), ""); gtk_widget_show_all (spinner_hbox); -#ifdef GTK_SPINNER gtk_widget_hide (spinner); -#endif /* Get the fields from the various widgets. */ free (config->remote.server); @@ -550,10 +523,8 @@ start_spinner (gpointer user_data) { gtk_label_set_text (GTK_LABEL (spinner_message), _("Testing the connection to the conversion server ...")); -#ifdef GTK_SPINNER gtk_widget_show (spinner); gtk_spinner_start (GTK_SPINNER (spinner)); -#endif return FALSE; } @@ -564,10 +535,8 @@ start_spinner (gpointer user_data) static gboolean stop_spinner (gpointer user_data) { -#ifdef GTK_SPINNER gtk_spinner_stop (GTK_SPINNER (spinner)); gtk_widget_hide (spinner); -#endif return FALSE; } @@ -652,11 +621,7 @@ about_button_clicked (GtkWidget *w, gpointer data) "copyright", "\u00A9 2009-2019 Red Hat Inc.", "comments", _("Virtualize a physical machine to run on KVM"), -#if GTK_CHECK_VERSION(3,0,0) /* gtk >= 3 */ "license-type", GTK_LICENSE_GPL_2_0, -#else - "license", gplv2plus, -#endif "website", "http://libguestfs.org/", "authors", authors, NULL); @@ -1855,11 +1820,7 @@ create_running_dialog (void) #else PangoFontDescription *font; font = pango_font_description_from_string ("Monospace 11"); -#if GTK_CHECK_VERSION(3,0,0) /* gtk >= 3 */ gtk_widget_override_font (v2v_output, font); -#else - gtk_widget_modify_font (v2v_output, font); -#endif pango_font_description_free (font); #endif
Laszlo Ersek
2022-Sep-26 08:18 UTC
[Libguestfs] [p2v PATCH 7/7] gui.c: annotate GTK_INPUT_PURPOSE_PASSWORD with upstream GTK3 version
GTK_INPUT_PURPOSE_PASSWORD was introduced in upstream GTK3 commit 8a8c43473745 ("enums: Add purpose enum and hints flags.", 2012-08-20), first released in version 3.5.12. For some reason (potentially for accommodating distro backports to GTK3?), virt-p2v does not guard GTK_INPUT_PURPOSE_PASSWORD with GTK_CHECK_VERSION(). Thus, at least add a comment that versions 3.5.12 and higher are sufficient (if not strictly necessary, considering backports) for GTK_INPUT_PURPOSE_PASSWORD to exist. Signed-off-by: Laszlo Ersek <lersek at redhat.com> --- gui.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gui.c b/gui.c index 6e785497b968..42d6ce9c8cfc 100644 --- a/gui.c +++ b/gui.c @@ -247,7 +247,7 @@ create_connection_dialog (struct config *config) password_entry = gtk_entry_new (); gtk_label_set_mnemonic_widget (GTK_LABEL (password_label), password_entry); gtk_entry_set_visibility (GTK_ENTRY (password_entry), FALSE); -#ifdef GTK_INPUT_PURPOSE_PASSWORD +#ifdef GTK_INPUT_PURPOSE_PASSWORD /* guaranteed if gtk >= 3.5.12 */ gtk_entry_set_input_purpose (GTK_ENTRY (password_entry), GTK_INPUT_PURPOSE_PASSWORD); #endif