Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package libblockdev for openSUSE:Factory checked in at 2023-10-02 20:04:12 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/libblockdev (Old) and /work/SRC/openSUSE:Factory/.libblockdev.new.28202 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "libblockdev" Mon Oct 2 20:04:12 2023 rev:21 rq:1114648 version:3.0.3 Changes: -------- --- /work/SRC/openSUSE:Factory/libblockdev/libblockdev.changes 2023-09-25 19:59:46.654750334 +0200 +++ /work/SRC/openSUSE:Factory/.libblockdev.new.28202/libblockdev.changes 2023-10-02 20:04:44.575085539 +0200 @@ -1,0 +2,18 @@ +Fri Sep 29 07:48:57 UTC 2023 - Bjørn Lie <bjorn....@gmail.com> + +- Update to version 3.0.3: + * Always use "--fs ignore" with lvresize + * nvme: + - Use interim buffer for nvme_get_log_sanitize() + - Generate HostID when missing + * tests: + - Specificy required versions when importing GLib and BlockDev + introspection + - Minor NVMe HostNQN fixes + - Replace deprecated unittest assert calls + * fs: + - Fix leaking directories with temporary mounts + - Fix memory leak + * crypto: Correctly convert passphrases from Python to C + +------------------------------------------------------------------- Old: ---- libblockdev-3.0.2.tar.gz New: ---- libblockdev-3.0.3.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ libblockdev.spec ++++++ --- /var/tmp/diff_new_pack.6Ii7Kb/_old 2023-10-02 20:04:45.851131429 +0200 +++ /var/tmp/diff_new_pack.6Ii7Kb/_new 2023-10-02 20:04:45.855131573 +0200 @@ -41,7 +41,7 @@ %define soversion 3 Name: libblockdev -Version: 3.0.2 +Version: 3.0.3 Release: 0 Summary: A library for low-level manipulation with block devices License: LGPL-2.1-only ++++++ NEWS.rst ++++++ --- /var/tmp/diff_new_pack.6Ii7Kb/_old 2023-10-02 20:04:45.891132868 +0200 +++ /var/tmp/diff_new_pack.6Ii7Kb/_new 2023-10-02 20:04:45.891132868 +0200 @@ -1,3 +1,33 @@ +Libblockdev 3.0.3 +------------------ + +New bugfix release of the libblockdev library with multiple fixes. See below +for details. + +**Full list of changes** + +Marius Vollmer (1): + +- Always use "--fs ignore" with lvresize + +Michael Biebl (1): + +- tests: Specificy required versions when importing GLib and BlockDev + introspection + +Tomas Bzatek (3): + +- nvme: Use interim buffer for nvme_get_log_sanitize() +- nvme: Generate HostID when missing +- tests: Minor NVMe HostNQN fixes + +Vojtech Trefny (4): + +- tests: Replace deprecated unittest assert calls +- fs: Fix leaking directories with temporary mounts +- fs: Fix memory leak +- crypto: Correctly convert passphrases from Python to C + Libblockdev 3.0.2 ------------------ ++++++ libblockdev-3.0.2.tar.gz -> libblockdev-3.0.3.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libblockdev-3.0.2/configure new/libblockdev-3.0.3/configure --- old/libblockdev-3.0.2/configure 2023-07-20 08:38:26.000000000 +0200 +++ new/libblockdev-3.0.3/configure 2023-08-31 13:28:24.000000000 +0200 @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.71 for libblockdev 3.0.2. +# Generated by GNU Autoconf 2.71 for libblockdev 3.0.3. # # # Copyright (C) 1992-1996, 1998-2017, 2020-2021 Free Software Foundation, @@ -618,8 +618,8 @@ # Identity of this package. PACKAGE_NAME='libblockdev' PACKAGE_TARNAME='libblockdev' -PACKAGE_VERSION='3.0.2' -PACKAGE_STRING='libblockdev 3.0.2' +PACKAGE_VERSION='3.0.3' +PACKAGE_STRING='libblockdev 3.0.3' PACKAGE_BUGREPORT='' PACKAGE_URL='https://github.com/storaged-project/libblockdev' @@ -1531,7 +1531,7 @@ # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures libblockdev 3.0.2 to adapt to many kinds of systems. +\`configure' configures libblockdev 3.0.3 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1602,7 +1602,7 @@ if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of libblockdev 3.0.2:";; + short | recursive ) echo "Configuration of libblockdev 3.0.3:";; esac cat <<\_ACEOF @@ -1799,7 +1799,7 @@ test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -libblockdev configure 3.0.2 +libblockdev configure 3.0.3 generated by GNU Autoconf 2.71 Copyright (C) 2021 Free Software Foundation, Inc. @@ -2017,7 +2017,7 @@ This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by libblockdev $as_me 3.0.2, which was +It was created by libblockdev $as_me 3.0.3, which was generated by GNU Autoconf 2.71. Invocation command line was $ $0$ac_configure_args_raw @@ -3322,7 +3322,7 @@ # Define the identity of the package. PACKAGE='libblockdev' - VERSION='3.0.2' + VERSION='3.0.3' printf "%s\n" "#define PACKAGE \"$PACKAGE\"" >>confdefs.h @@ -17822,7 +17822,7 @@ # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by libblockdev $as_me 3.0.2, which was +This file was extended by libblockdev $as_me 3.0.3, which was generated by GNU Autoconf 2.71. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -17882,7 +17882,7 @@ cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config='$ac_cs_config_escaped' ac_cs_version="\\ -libblockdev config.status 3.0.2 +libblockdev config.status 3.0.3 configured by $0, generated by GNU Autoconf 2.71, with options \\"\$ac_cs_config\\" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libblockdev-3.0.2/configure.ac new/libblockdev-3.0.3/configure.ac --- old/libblockdev-3.0.2/configure.ac 2023-07-20 08:37:20.000000000 +0200 +++ new/libblockdev-3.0.3/configure.ac 2023-08-31 13:27:24.000000000 +0200 @@ -1,6 +1,6 @@ # configure.ac for libblockdev -AC_INIT([libblockdev], [3.0.2], [], [], [https://github.com/storaged-project/libblockdev]) +AC_INIT([libblockdev], [3.0.3], [], [], [https://github.com/storaged-project/libblockdev]) # Disable building static libraries. # This needs to be set before initializing automake diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libblockdev-3.0.2/dist/libblockdev.spec new/libblockdev-3.0.3/dist/libblockdev.spec --- old/libblockdev-3.0.2/dist/libblockdev.spec 2023-07-20 08:38:29.000000000 +0200 +++ new/libblockdev-3.0.3/dist/libblockdev.spec 2023-08-31 13:28:26.000000000 +0200 @@ -77,7 +77,7 @@ %define configure_opts %{?python3_copts} %{?lvm_dbus_copts} %{?btrfs_copts} %{?crypto_copts} %{?dm_copts} %{?loop_copts} %{?lvm_copts} %{?lvm_dbus_copts} %{?mdraid_copts} %{?mpath_copts} %{?swap_copts} %{?part_copts} %{?fs_copts} %{?nvdimm_copts} %{?tools_copts} %{?gi_copts} %{?nvme_copts} Name: libblockdev -Version: 3.0.2 +Version: 3.0.3 Release: 1%{?dist} Summary: A library for low-level manipulation with block devices License: LGPL-2.1-or-later @@ -845,6 +845,17 @@ %files plugins-all %changelog +* Thu Aug 31 2023 Vojtech Trefny <vtre...@redhat.com> - 3.0.3-1 +- crypto: Correctly convert passphrases from Python to C (vtrefny) +- tests: Minor NVMe HostNQN fixes (tbzatek) +- nvme: Generate HostID when missing (tbzatek) +- Always use "--fs ignore" with lvresize (mvollmer) +- nvme: Use interim buffer for nvme_get_log_sanitize() (tbzatek) +- fs: Fix memory leak (vtrefny) +- fs: Fix leaking directories with temporary mounts (vtrefny) +- tests: Specificy required versions when importing GLib and BlockDev introspection (biebl) +- tests: Replace deprecated unittest assert calls (vtrefny) + * Thu Jul 20 2023 Vojtech Trefny <vtre...@redhat.com> - 3.0.2-1 - fs: Avoid excess logging in extract_e2fsck_progress (vtrefny) - loop: Report BD_LOOP_ERROR_DEVICE on empty loop devices (tbzatek) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libblockdev-3.0.2/dist/libblockdev.spec.in new/libblockdev-3.0.3/dist/libblockdev.spec.in --- old/libblockdev-3.0.2/dist/libblockdev.spec.in 2023-07-20 08:36:48.000000000 +0200 +++ new/libblockdev-3.0.3/dist/libblockdev.spec.in 2023-08-31 13:26:53.000000000 +0200 @@ -77,7 +77,7 @@ %define configure_opts %{?python3_copts} %{?lvm_dbus_copts} %{?btrfs_copts} %{?crypto_copts} %{?dm_copts} %{?loop_copts} %{?lvm_copts} %{?lvm_dbus_copts} %{?mdraid_copts} %{?mpath_copts} %{?swap_copts} %{?part_copts} %{?fs_copts} %{?nvdimm_copts} %{?tools_copts} %{?gi_copts} %{?nvme_copts} Name: libblockdev -Version: 3.0.2 +Version: 3.0.3 Release: 1%{?dist} Summary: A library for low-level manipulation with block devices License: LGPL-2.1-or-later @@ -845,6 +845,17 @@ %files plugins-all %changelog +* Thu Aug 31 2023 Vojtech Trefny <vtre...@redhat.com> - 3.0.3-1 +- crypto: Correctly convert passphrases from Python to C (vtrefny) +- tests: Minor NVMe HostNQN fixes (tbzatek) +- nvme: Generate HostID when missing (tbzatek) +- Always use "--fs ignore" with lvresize (mvollmer) +- nvme: Use interim buffer for nvme_get_log_sanitize() (tbzatek) +- fs: Fix memory leak (vtrefny) +- fs: Fix leaking directories with temporary mounts (vtrefny) +- tests: Specificy required versions when importing GLib and BlockDev introspection (biebl) +- tests: Replace deprecated unittest assert calls (vtrefny) + * Thu Jul 20 2023 Vojtech Trefny <vtre...@redhat.com> - 3.0.2-1 - fs: Avoid excess logging in extract_e2fsck_progress (vtrefny) - loop: Report BD_LOOP_ERROR_DEVICE on empty loop devices (tbzatek) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libblockdev-3.0.2/docs/libblockdev-docs.xml new/libblockdev-3.0.3/docs/libblockdev-docs.xml --- old/libblockdev-3.0.2/docs/libblockdev-docs.xml 2023-07-20 08:38:29.000000000 +0200 +++ new/libblockdev-3.0.3/docs/libblockdev-docs.xml 2023-08-31 13:28:26.000000000 +0200 @@ -6,7 +6,7 @@ ]> <book id="index"> <bookinfo> - <title>libblockdev Reference Manual for libblockdev 3.0.2.</title> + <title>libblockdev Reference Manual for libblockdev 3.0.3.</title> <releaseinfo> <para> The latest version of this documentation can be found on-line at diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libblockdev-3.0.2/src/plugins/fs/generic.c new/libblockdev-3.0.3/src/plugins/fs/generic.c --- old/libblockdev-3.0.2/src/plugins/fs/generic.c 2023-07-19 09:58:25.000000000 +0200 +++ new/libblockdev-3.0.3/src/plugins/fs/generic.c 2023-08-23 11:44:58.000000000 +0200 @@ -639,8 +639,7 @@ if (!mountpoint) { if (l_error == NULL) { /* device is not mounted -- we need to mount it */ - mountpoint = g_build_path (G_DIR_SEPARATOR_S, g_get_tmp_dir (), "blockdev.XXXXXX", NULL); - mountpoint = g_mkdtemp (mountpoint); + mountpoint = g_dir_make_tmp ("blockdev.XXXXXX", NULL); if (!mountpoint) { g_set_error (error, BD_FS_ERROR, BD_FS_ERROR_FAIL, "Failed to create temporary directory for mounting '%s'.", device); @@ -649,6 +648,7 @@ ret = bd_fs_mount (device, mountpoint, fstype, read_only ? "ro" : NULL, NULL, &l_error); if (!ret) { g_propagate_prefixed_error (error, l_error, "Failed to mount '%s': ", device); + g_rmdir (mountpoint); g_free (mountpoint); return NULL; } else @@ -686,15 +686,15 @@ GError *local_error = NULL; BDFSXfsInfo* xfs_info = NULL; - mountpoint = fs_mount (device, "xfs", FALSE, &unmount, error); - if (!mountpoint) - return FALSE; - xfs_info = bd_fs_xfs_get_info (device, error); if (!xfs_info) { return FALSE; } + mountpoint = fs_mount (device, "xfs", FALSE, &unmount, error); + if (!mountpoint) + return FALSE; + new_size = (new_size + xfs_info->block_size - 1) / xfs_info->block_size; bd_fs_xfs_info_free (xfs_info); @@ -715,7 +715,8 @@ from the resize is more important so just ignore the unmount error */ g_clear_error (&local_error); - } + } else + g_rmdir (mountpoint); } return success; @@ -769,7 +770,8 @@ from the resize is more important so just ignore the unmount error */ g_clear_error (&local_error); - } + } else + g_rmdir (mountpoint); } return success; @@ -804,7 +806,8 @@ from the info is more important so just ignore the unmount error */ g_clear_error (&local_error); - } + } else + g_rmdir (mountpoint); } return btrfs_info; @@ -838,7 +841,8 @@ from the resize is more important so just ignore the unmount error */ g_clear_error (&local_error); - } + } else + g_rmdir (mountpoint); } return success; @@ -872,7 +876,8 @@ from the set label is more important so just ignore the unmount error */ g_clear_error (&local_error); - } + } else + g_rmdir (mountpoint); } return success; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libblockdev-3.0.2/src/plugins/lvm-dbus.c new/libblockdev-3.0.3/src/plugins/lvm-dbus.c --- old/libblockdev-3.0.2/src/plugins/lvm-dbus.c 2023-07-04 15:25:25.000000000 +0200 +++ new/libblockdev-3.0.3/src/plugins/lvm-dbus.c 2023-08-23 11:44:58.000000000 +0200 @@ -2653,12 +2653,6 @@ GVariant *params = NULL; GVariant *extra_params = NULL; gboolean success = FALSE; - BDLVMLVdata *lvinfo = NULL; - - lvinfo = bd_lvm_lvinfo (vg_name, lv_name, error); - if (!lvinfo) - /* error is already populated */ - return FALSE; g_variant_builder_init (&builder, G_VARIANT_TYPE_TUPLE); g_variant_builder_add_value (&builder, g_variant_new ("t", size)); @@ -2668,20 +2662,18 @@ params = g_variant_builder_end (&builder); g_variant_builder_clear (&builder); - if (lvinfo->attr[4] != 'a') { - /* starting with 2.03.19 we need to add extra option to allow resizing of inactive LVs */ - success = bd_utils_check_util_version (deps[DEPS_LVM].name, LVM_VERSION_FSRESIZE, - deps[DEPS_LVM].ver_arg, deps[DEPS_LVM].ver_regexp, NULL); - if (success) { - g_variant_builder_init (&builder, G_VARIANT_TYPE_DICTIONARY); - g_variant_builder_add (&builder, "{sv}", "--fs", g_variant_new ("s", "ignore")); - extra_params = g_variant_builder_end (&builder); - g_variant_builder_clear (&builder); - } + /* Starting with 2.03.19 we need to add an extra option to avoid + any filesystem related checks by lvresize. + */ + success = bd_utils_check_util_version (deps[DEPS_LVM].name, LVM_VERSION_FSRESIZE, + deps[DEPS_LVM].ver_arg, deps[DEPS_LVM].ver_regexp, NULL); + if (success) { + g_variant_builder_init (&builder, G_VARIANT_TYPE_DICTIONARY); + g_variant_builder_add (&builder, "{sv}", "--fs", g_variant_new ("s", "ignore")); + extra_params = g_variant_builder_end (&builder); + g_variant_builder_clear (&builder); } - bd_lvm_lvdata_free (lvinfo); - return call_lv_method_sync (vg_name, lv_name, "Resize", params, extra_params, extra, TRUE, error); } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libblockdev-3.0.2/src/plugins/lvm.c new/libblockdev-3.0.3/src/plugins/lvm.c --- old/libblockdev-3.0.2/src/plugins/lvm.c 2023-07-04 15:25:25.000000000 +0200 +++ new/libblockdev-3.0.3/src/plugins/lvm.c 2023-08-23 11:44:58.000000000 +0200 @@ -1920,27 +1920,19 @@ gboolean success = FALSE; guint8 next_arg = 4; g_autofree gchar *lvspec = NULL; - BDLVMLVdata *lvinfo = NULL; - - lvinfo = bd_lvm_lvinfo (vg_name, lv_name, error); - if (!lvinfo) - /* error is already populated */ - return FALSE; args[3] = g_strdup_printf ("%"G_GUINT64_FORMAT"K", size/1024); - if (lvinfo->attr[4] != 'a') { - /* starting with 2.03.19 we need to add extra option to allow resizing of inactive LVs */ - success = bd_utils_check_util_version (deps[DEPS_LVM].name, LVM_VERSION_FSRESIZE, - deps[DEPS_LVM].ver_arg, deps[DEPS_LVM].ver_regexp, NULL); - if (success) { - args[next_arg++] = "--fs"; - args[next_arg++] = "ignore"; - } + /* Starting with 2.03.19 we need to add an extra option to avoid + any filesystem related checks by lvresize. + */ + success = bd_utils_check_util_version (deps[DEPS_LVM].name, LVM_VERSION_FSRESIZE, + deps[DEPS_LVM].ver_arg, deps[DEPS_LVM].ver_regexp, NULL); + if (success) { + args[next_arg++] = "--fs"; + args[next_arg++] = "ignore"; } - bd_lvm_lvdata_free (lvinfo); - lvspec = g_strdup_printf ("%s/%s", vg_name, lv_name); args[next_arg++] = lvspec; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libblockdev-3.0.2/src/plugins/nvme/nvme-fabrics.c new/libblockdev-3.0.3/src/plugins/nvme/nvme-fabrics.c --- old/libblockdev-3.0.2/src/plugins/nvme/nvme-fabrics.c 2023-07-04 15:25:25.000000000 +0200 +++ new/libblockdev-3.0.3/src/plugins/nvme/nvme-fabrics.c 2023-08-23 11:44:58.000000000 +0200 @@ -161,7 +161,7 @@ * @host_iface: (nullable): The network interface used on the host to connect to the Controller (e.g. IP `eth1`, `enp2s0`). This forces the connection to be made on a specific interface instead of letting the system decide. * @host_nqn: (nullable): Overrides the default Host NQN that identifies the NVMe Host. If this option is %NULL, the default is read from `/etc/nvme/hostnqn` first. * If that does not exist, the autogenerated NQN value from the NVMe Host kernel module is used next. The Host NQN uniquely identifies the NVMe Host. - * @host_id: (nullable): User-defined host UUID or %NULL to use default (as defined in `/etc/nvme/hostid`) + * @host_id: (nullable): User-defined host UUID or %NULL to use default (as defined in `/etc/nvme/hostid`). * @extra: (nullable) (array zero-terminated=1): Additional arguments. * @error: (out) (nullable): Place to store error (if any). * @@ -244,18 +244,41 @@ return FALSE; } - /* parse extra arguments */ - nvmf_default_config (&cfg); - parse_extra_args (extra, &cfg, &config_file, &hostkey, &ctrlkey, &hostsymname); - + /* HostNQN checks */ host_nqn_val = g_strdup (host_nqn); + host_id_val = g_strdup (host_id); if (host_nqn_val == NULL) host_nqn_val = nvmf_hostnqn_from_file (); - if (host_nqn_val == NULL) - host_nqn_val = nvmf_hostnqn_generate (); - host_id_val = g_strdup (host_id); if (host_id_val == NULL) host_id_val = nvmf_hostid_from_file (); + if (host_nqn_val == NULL) + host_nqn_val = nvmf_hostnqn_generate (); + if (host_nqn_val == NULL) { + g_set_error_literal (error, BD_NVME_ERROR, BD_NVME_ERROR_INVALID_ARGUMENT, + "Could not determine HostNQN"); + g_free (host_nqn_val); + g_free (host_id_val); + return FALSE; + } + if (host_id_val == NULL) { + /* derive hostid from hostnqn, newer kernels refuse empty hostid */ + host_id_val = g_strrstr (host_nqn_val, "uuid:"); + if (host_id_val) + host_id_val = g_strdup (host_id_val + strlen ("uuid:")); + /* TODO: in theory generating arbitrary uuid might work as a fallback */ + } + if (host_id_val == NULL) { + g_set_error (error, BD_NVME_ERROR, BD_NVME_ERROR_INVALID_ARGUMENT, + "Could not determine HostID value from HostNQN '%s'", + host_nqn_val); + g_free (host_nqn_val); + g_free (host_id_val); + return FALSE; + } + + /* parse extra arguments */ + nvmf_default_config (&cfg); + parse_extra_args (extra, &cfg, &config_file, &hostkey, &ctrlkey, &hostsymname); root = nvme_scan (config_file); g_assert (root != NULL); @@ -263,7 +286,7 @@ host = nvme_lookup_host (root, host_nqn_val, host_id_val); if (host == NULL) { g_set_error (error, BD_NVME_ERROR, BD_NVME_ERROR_FAILED, - "Unable to lookup host for nqn '%s' and id '%s'", + "Unable to lookup host for HostNQN '%s' and HostID '%s'", host_nqn_val, host_id_val); g_free (host_nqn_val); g_free (host_id_val); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libblockdev-3.0.2/src/plugins/nvme/nvme-info.c new/libblockdev-3.0.3/src/plugins/nvme/nvme-info.c --- old/libblockdev-3.0.2/src/plugins/nvme/nvme-info.c 2023-07-04 15:25:25.000000000 +0200 +++ new/libblockdev-3.0.3/src/plugins/nvme/nvme-info.c 2023-08-31 13:16:25.000000000 +0200 @@ -1026,7 +1026,8 @@ BDNVMESanitizeLog * bd_nvme_get_sanitize_log (const gchar *device, GError **error) { int ret; int fd; - struct nvme_sanitize_log_page sanitize_log = ZERO_INIT; + char buf[65536] = ZERO_INIT; + struct nvme_sanitize_log_page *sanitize_log; BDNVMESanitizeLog *log; __u16 sstat; @@ -1036,7 +1037,7 @@ return NULL; /* send the NVME_LOG_LID_SANITIZE ioctl */ - ret = nvme_get_log_sanitize (fd, FALSE /* rae */, &sanitize_log); + ret = nvme_get_log_sanitize (fd, FALSE /* rae */, (struct nvme_sanitize_log_page *) &buf); if (ret != 0) { _nvme_status_to_error (ret, FALSE, error); g_prefix_error (error, "NVMe Get Log Page - Sanitize Status Log command error: "); @@ -1045,12 +1046,16 @@ } close (fd); - sstat = GUINT16_FROM_LE (sanitize_log.sstat); + /* need to use interim buffer that is large enough for broken drives + * returning more data than expected + */ + sanitize_log = (struct nvme_sanitize_log_page *) &buf; log = g_new0 (BDNVMESanitizeLog, 1); log->sanitize_progress = 0; + sstat = GUINT16_FROM_LE (sanitize_log->sstat); if ((sstat & NVME_SANITIZE_SSTAT_STATUS_MASK) == NVME_SANITIZE_SSTAT_STATUS_IN_PROGESS) - log->sanitize_progress = ((gdouble) GUINT16_FROM_LE (sanitize_log.sprog) * 100) / 0x10000; + log->sanitize_progress = ((gdouble) GUINT16_FROM_LE (sanitize_log->sprog) * 100) / 0x10000; log->global_data_erased = sstat & NVME_SANITIZE_SSTAT_GLOBAL_DATA_ERASED; log->overwrite_passes = (sstat >> NVME_SANITIZE_SSTAT_COMPLETED_PASSES_SHIFT) & NVME_SANITIZE_SSTAT_COMPLETED_PASSES_MASK; @@ -1073,12 +1078,12 @@ break; } - log->time_for_overwrite = (GUINT32_FROM_LE (sanitize_log.eto) == 0xffffffff) ? -1 : (gint64) GUINT32_FROM_LE (sanitize_log.eto); - log->time_for_block_erase = (GUINT32_FROM_LE (sanitize_log.etbe) == 0xffffffff) ? -1 : (gint64) GUINT32_FROM_LE (sanitize_log.etbe); - log->time_for_crypto_erase = (GUINT32_FROM_LE (sanitize_log.etce) == 0xffffffff) ? -1 : (gint64) GUINT32_FROM_LE (sanitize_log.etce); - log->time_for_overwrite_nd = (GUINT32_FROM_LE (sanitize_log.etond) == 0xffffffff) ? -1 : (gint64) GUINT32_FROM_LE (sanitize_log.etond); - log->time_for_block_erase_nd = (GUINT32_FROM_LE (sanitize_log.etbend) == 0xffffffff) ? -1 : (gint64) GUINT32_FROM_LE (sanitize_log.etbend); - log->time_for_crypto_erase_nd = (GUINT32_FROM_LE (sanitize_log.etcend) == 0xffffffff) ? -1 : (gint64) GUINT32_FROM_LE (sanitize_log.etcend); + log->time_for_overwrite = (GUINT32_FROM_LE (sanitize_log->eto) == 0xffffffff) ? -1 : (gint64) GUINT32_FROM_LE (sanitize_log->eto); + log->time_for_block_erase = (GUINT32_FROM_LE (sanitize_log->etbe) == 0xffffffff) ? -1 : (gint64) GUINT32_FROM_LE (sanitize_log->etbe); + log->time_for_crypto_erase = (GUINT32_FROM_LE (sanitize_log->etce) == 0xffffffff) ? -1 : (gint64) GUINT32_FROM_LE (sanitize_log->etce); + log->time_for_overwrite_nd = (GUINT32_FROM_LE (sanitize_log->etond) == 0xffffffff) ? -1 : (gint64) GUINT32_FROM_LE (sanitize_log->etond); + log->time_for_block_erase_nd = (GUINT32_FROM_LE (sanitize_log->etbend) == 0xffffffff) ? -1 : (gint64) GUINT32_FROM_LE (sanitize_log->etbend); + log->time_for_crypto_erase_nd = (GUINT32_FROM_LE (sanitize_log->etcend) == 0xffffffff) ? -1 : (gint64) GUINT32_FROM_LE (sanitize_log->etcend); return log; } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libblockdev-3.0.2/src/python/gi/overrides/BlockDev.py new/libblockdev-3.0.3/src/python/gi/overrides/BlockDev.py --- old/libblockdev-3.0.2/src/python/gi/overrides/BlockDev.py 2023-07-04 15:25:25.000000000 +0200 +++ new/libblockdev-3.0.3/src/python/gi/overrides/BlockDev.py 2023-08-31 13:16:25.000000000 +0200 @@ -267,7 +267,7 @@ raise ValueError("Exactly one of 'passphrase', 'keyfile', 'keyring' and 'volume_key' must be specified") if passphrase: if isinstance(passphrase, str): - ret = BlockDev.CryptoKeyslotContext.new_passphrase([ord(c) for c in passphrase]) + ret = BlockDev.CryptoKeyslotContext.new_passphrase(passphrase.encode("utf-8")) else: ret = BlockDev.CryptoKeyslotContext.new_passphrase(passphrase) if keyfile: @@ -313,7 +313,7 @@ @override(BlockDev.crypto_tc_open) def crypto_tc_open(device, name, passphrase, read_only=False, keyfiles=None, hidden=False, system=False, veracrypt=False, veracrypt_pim=0): if isinstance(passphrase, str): - passphrase = [ord(c) for c in passphrase] + passphrase = passphrase.encode("utf-8") return _crypto_tc_open(device, name, passphrase, keyfiles, hidden, system, veracrypt, veracrypt_pim, read_only) __all__.append("crypto_tc_open") @@ -321,7 +321,7 @@ @override(BlockDev.crypto_bitlk_open) def crypto_bitlk_open(device, name, passphrase, read_only=False): if isinstance(passphrase, str): - passphrase = [ord(c) for c in passphrase] + passphrase = passphrase.encode("utf-8") return _crypto_bitlk_open(device, name, passphrase, read_only) __all__.append("crypto_bitlk_open") @@ -329,7 +329,7 @@ @override(BlockDev.crypto_fvault2_open) def crypto_fvault2_open(device, name, passphrase, read_only=False): if isinstance(passphrase, str): - passphrase = [ord(c) for c in passphrase] + passphrase = passphrase.encode("utf-8") return _crypto_fvault2_open(device, name, passphrase, read_only) __all__.append("crypto_fvault2_open") @@ -338,7 +338,7 @@ @override(BlockDev.crypto_keyring_add_key) def crypto_keyring_add_key(key_desc, key): if isinstance(key, str): - key = [ord(c) for c in key] + key = key.encode("utf-8") return _crypto_keyring_add_key(key_desc, key) __all__.append("crypto_keyring_add_key") diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libblockdev-3.0.2/tests/btrfs_test.py new/libblockdev-3.0.3/tests/btrfs_test.py --- old/libblockdev-3.0.2/tests/btrfs_test.py 2023-07-04 15:25:25.000000000 +0200 +++ new/libblockdev-3.0.3/tests/btrfs_test.py 2023-07-26 09:28:06.000000000 +0200 @@ -10,6 +10,10 @@ import overrides_hack from utils import create_sparse_tempfile, create_lio_device, delete_lio_device, fake_utils, fake_path, mount, umount, run_command, TestTags, tag_test + +import gi +gi.require_version('GLib', '2.0') +gi.require_version('BlockDev', '3.0') from gi.repository import GLib, BlockDev TEST_MNT = "/tmp/libblockdev_test_mnt" @@ -567,12 +571,12 @@ with fake_utils("tests/fake_utils/btrfs_low_version/"): # too low version of BTRFS available - with self.assertRaisesRegexp(GLib.GError, "Too low version of btrfs"): + with self.assertRaisesRegex(GLib.GError, "Too low version of btrfs"): BlockDev.btrfs_is_tech_avail(BlockDev.BtrfsTech.FS, 0) with fake_path(all_but="btrfs"): # no btrfs tool available - with self.assertRaisesRegexp(GLib.GError, "The 'btrfs' utility is not available"): + with self.assertRaisesRegex(GLib.GError, "The 'btrfs' utility is not available"): BlockDev.btrfs_is_tech_avail(BlockDev.BtrfsTech.FS, 0) # check that new version format is correctly parsed diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libblockdev-3.0.2/tests/crypto_test.py new/libblockdev-3.0.3/tests/crypto_test.py --- old/libblockdev-3.0.2/tests/crypto_test.py 2023-07-04 15:25:25.000000000 +0200 +++ new/libblockdev-3.0.3/tests/crypto_test.py 2023-08-31 13:16:25.000000000 +0200 @@ -10,7 +10,11 @@ import tarfile from utils import create_sparse_tempfile, create_lio_device, delete_lio_device, get_avail_locales, requires_locales, run_command, read_file, TestTags, tag_test -from gi.repository import BlockDev, GLib + +import gi +gi.require_version('GLib', '2.0') +gi.require_version('BlockDev', '3.0') +from gi.repository import GLib, BlockDev PASSWD = "myshinylittlepassword" PASSWD2 = "myshinylittlepassword2" @@ -444,6 +448,43 @@ def test_luks2_open_close(self): self._luks_open_close(self._luks2_format) + @tag_test(TestTags.SLOW, TestTags.CORE) + def test_luks2_open_close_non_ascii_passphrase(self): + passphrase = "šššššššš" + + self._luks2_format(self.loop_dev, passphrase) + + ctx = BlockDev.CryptoKeyslotContext(passphrase=passphrase) + succ = BlockDev.crypto_luks_open(self.loop_dev, "libblockdevTestLUKS", ctx, False) + self.assertTrue(succ) + + succ = BlockDev.crypto_luks_close("libblockdevTestLUKS") + self.assertTrue(succ) + + # lets try with keyfile + with tempfile.NamedTemporaryFile(mode="w") as f: + f.write(passphrase) + f.flush() + + ctx = BlockDev.CryptoKeyslotContext(keyfile=f.name) + succ = BlockDev.crypto_luks_open(self.loop_dev, "libblockdevTestLUKS", ctx, False) + self.assertTrue(succ) + + succ = BlockDev.crypto_luks_close("libblockdevTestLUKS") + self.assertTrue(succ) + + # and keyring too + succ = BlockDev.crypto_keyring_add_key("myshinylittlekey", passphrase) + self.assertTrue(succ) + + ctx = BlockDev.CryptoKeyslotContext(keyring="myshinylittlekey") + succ = BlockDev.crypto_luks_open(self.loop_dev, "libblockdevTestLUKS", ctx) + self.assertTrue(succ) + + succ = BlockDev.crypto_luks_close("libblockdevTestLUKS") + self.assertTrue(succ) + + class CryptoTestAddKey(CryptoTestCase): def _add_key(self, create_fn): """Verify that adding key to LUKS device works""" @@ -948,7 +989,7 @@ self.fail("Failed to get LUKS 2 offset information from %s:\n%s %s" % (self.loop_dev, out, err)) offset = int(m.group(1)) - self.assertEquals(info.metadata_size, offset) + self.assertEqual(info.metadata_size, offset) @tag_test(TestTags.SLOW, TestTags.CORE) def test_luks_info(self): diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libblockdev-3.0.2/tests/dm_test.py new/libblockdev-3.0.3/tests/dm_test.py --- old/libblockdev-3.0.2/tests/dm_test.py 2023-07-04 15:25:25.000000000 +0200 +++ new/libblockdev-3.0.3/tests/dm_test.py 2023-07-26 09:28:06.000000000 +0200 @@ -3,7 +3,11 @@ import overrides_hack from utils import run, create_sparse_tempfile, create_lio_device, delete_lio_device, fake_utils, fake_path, TestTags, tag_test -from gi.repository import BlockDev, GLib + +import gi +gi.require_version('GLib', '2.0') +gi.require_version('BlockDev', '3.0') +from gi.repository import GLib, BlockDev class DevMapperTest(unittest.TestCase): diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libblockdev-3.0.2/tests/fs_tests/generic_test.py new/libblockdev-3.0.3/tests/fs_tests/generic_test.py --- old/libblockdev-3.0.2/tests/fs_tests/generic_test.py 2023-07-04 15:25:25.000000000 +0200 +++ new/libblockdev-3.0.3/tests/fs_tests/generic_test.py 2023-08-23 11:44:58.000000000 +0200 @@ -1045,7 +1045,39 @@ """Test generic resize function with an btrfs file system""" if not self.btrfs_avail: self.skipTest("skipping Btrfs: not available") + + temps1 = set([temp for temp in os.listdir("/tmp") if temp.startswith("blockdev.")]) self._test_generic_resize(mkfs_function=BlockDev.fs_btrfs_mkfs, min_size=300*1024**2, fstype="btrfs") + temps2 = set([temp for temp in os.listdir("/tmp") if temp.startswith("blockdev.")]) + + # make sure we didn't leak a temporary mount directory + self.assertFalse(temps2 - temps1) + + def test_btrfs_generic_resize_mounted(self): + """Test generic resize function with a mounted btrfs file system""" + if not self.btrfs_avail: + self.skipTest("skipping Btrfs: not available") + + # clean the device + succ = BlockDev.fs_clean(self.loop_dev) + + succ = BlockDev.fs_btrfs_mkfs(self.loop_dev, None) + self.assertTrue(succ) + size = BlockDev.fs_get_size(self.loop_dev) + + with mounted(self.loop_dev, self.mount_dir): + # shrink + succ = BlockDev.fs_resize(self.loop_dev, 300*1024**2) + self.assertTrue(succ) + new_size = BlockDev.fs_get_size(self.loop_dev) + self.assertAlmostEqual(new_size, 300*1024**2) + + # resize to maximum size + succ = BlockDev.fs_resize(self.loop_dev, 0, "btrfs") + self.assertTrue(succ) + new_size = BlockDev.fs_get_size(self.loop_dev) + # should be back to original size + self.assertAlmostEqual(new_size, size) def test_udf_generic_resize(self): """Test generic resize function with an udf file system""" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libblockdev-3.0.2/tests/library_test.py new/libblockdev-3.0.3/tests/library_test.py --- old/libblockdev-3.0.2/tests/library_test.py 2023-07-04 15:25:25.000000000 +0200 +++ new/libblockdev-3.0.3/tests/library_test.py 2023-07-26 09:28:06.000000000 +0200 @@ -4,6 +4,9 @@ import overrides_hack from utils import fake_path, TestTags, tag_test +import gi +gi.require_version('GLib', '2.0') +gi.require_version('BlockDev', '3.0') from gi.repository import GLib, BlockDev diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libblockdev-3.0.2/tests/loop_test.py new/libblockdev-3.0.3/tests/loop_test.py --- old/libblockdev-3.0.2/tests/loop_test.py 2023-07-04 15:25:25.000000000 +0200 +++ new/libblockdev-3.0.3/tests/loop_test.py 2023-07-26 09:28:06.000000000 +0200 @@ -4,8 +4,11 @@ import overrides_hack from utils import create_sparse_tempfile, TestTags, tag_test -from gi.repository import BlockDev, GLib +import gi +gi.require_version('GLib', '2.0') +gi.require_version('BlockDev', '3.0') +from gi.repository import GLib, BlockDev class LoopTestCase(unittest.TestCase): diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libblockdev-3.0.2/tests/lvm_dbus_tests.py new/libblockdev-3.0.3/tests/lvm_dbus_tests.py --- old/libblockdev-3.0.2/tests/lvm_dbus_tests.py 2023-07-04 15:25:25.000000000 +0200 +++ new/libblockdev-3.0.3/tests/lvm_dbus_tests.py 2023-07-26 09:28:06.000000000 +0200 @@ -12,7 +12,11 @@ import sys from utils import create_sparse_tempfile, create_lio_device, delete_lio_device, run_command, TestTags, tag_test, read_file -from gi.repository import BlockDev, GLib + +import gi +gi.require_version('GLib', '2.0') +gi.require_version('BlockDev', '3.0') +from gi.repository import GLib, BlockDev import dbus sb = dbus.SystemBus() diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libblockdev-3.0.2/tests/lvm_test.py new/libblockdev-3.0.3/tests/lvm_test.py --- old/libblockdev-3.0.2/tests/lvm_test.py 2023-07-04 15:25:25.000000000 +0200 +++ new/libblockdev-3.0.3/tests/lvm_test.py 2023-07-26 09:28:06.000000000 +0200 @@ -10,7 +10,11 @@ from packaging.version import Version from utils import create_sparse_tempfile, create_lio_device, delete_lio_device, fake_utils, fake_path, TestTags, tag_test, run_command, read_file -from gi.repository import BlockDev, GLib + +import gi +gi.require_version('GLib', '2.0') +gi.require_version('BlockDev', '3.0') +from gi.repository import GLib, BlockDev @contextmanager diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libblockdev-3.0.2/tests/mdraid_test.py new/libblockdev-3.0.3/tests/mdraid_test.py --- old/libblockdev-3.0.2/tests/mdraid_test.py 2023-07-04 15:25:25.000000000 +0200 +++ new/libblockdev-3.0.3/tests/mdraid_test.py 2023-07-26 09:28:06.000000000 +0200 @@ -6,7 +6,11 @@ import overrides_hack from utils import create_sparse_tempfile, create_lio_device, delete_lio_device, fake_utils, fake_path, TestTags, tag_test, run_command -from gi.repository import BlockDev, GLib + +import gi +gi.require_version('GLib', '2.0') +gi.require_version('BlockDev', '3.0') +from gi.repository import GLib, BlockDev @contextmanager diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libblockdev-3.0.2/tests/mpath_test.py new/libblockdev-3.0.3/tests/mpath_test.py --- old/libblockdev-3.0.2/tests/mpath_test.py 2023-07-04 15:25:25.000000000 +0200 +++ new/libblockdev-3.0.3/tests/mpath_test.py 2023-07-26 09:28:06.000000000 +0200 @@ -4,7 +4,11 @@ import shutil from utils import create_sparse_tempfile, create_lio_device, delete_lio_device, fake_utils, fake_path, get_version, TestTags, tag_test -from gi.repository import BlockDev, GLib + +import gi +gi.require_version('GLib', '2.0') +gi.require_version('BlockDev', '3.0') +from gi.repository import GLib, BlockDev class MpathTest(unittest.TestCase): diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libblockdev-3.0.2/tests/nvdimm_test.py new/libblockdev-3.0.3/tests/nvdimm_test.py --- old/libblockdev-3.0.2/tests/nvdimm_test.py 2023-07-04 15:25:25.000000000 +0200 +++ new/libblockdev-3.0.3/tests/nvdimm_test.py 2023-07-26 09:28:06.000000000 +0200 @@ -7,7 +7,11 @@ from packaging.version import Version from utils import run_command, read_file, fake_path, TestTags, tag_test -from gi.repository import BlockDev, GLib + +import gi +gi.require_version('GLib', '2.0') +gi.require_version('BlockDev', '3.0') +from gi.repository import GLib, BlockDev class NVDIMMTestCase(unittest.TestCase): diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libblockdev-3.0.2/tests/nvme_test.py new/libblockdev-3.0.3/tests/nvme_test.py --- old/libblockdev-3.0.2/tests/nvme_test.py 2023-07-04 15:25:25.000000000 +0200 +++ new/libblockdev-3.0.3/tests/nvme_test.py 2023-08-23 11:44:58.000000000 +0200 @@ -5,8 +5,11 @@ import overrides_hack from utils import create_sparse_tempfile, create_nvmet_device, delete_nvmet_device, setup_nvme_target, teardown_nvme_target, find_nvme_ctrl_devs_for_subnqn, find_nvme_ns_devs_for_subnqn, get_nvme_hostnqn, run_command, TestTags, tag_test, read_file, write_file -from gi.repository import BlockDev, GLib +import gi +gi.require_version('GLib', '2.0') +gi.require_version('BlockDev', '3.0') +from gi.repository import GLib, BlockDev class NVMeTest(unittest.TestCase): requested_plugins = BlockDev.plugin_specs_from_names(("nvme", "loop")) @@ -67,10 +70,10 @@ def test_ns_info(self): """Test namespace info""" - with self.assertRaisesRegexp(GLib.GError, r".*Failed to open device .*': No such file or directory"): + with self.assertRaisesRegex(GLib.GError, r".*Failed to open device .*': No such file or directory"): BlockDev.nvme_get_namespace_info("/dev/nonexistent") - with self.assertRaisesRegexp(GLib.GError, r"Error getting Namespace Identifier \(NSID\): Inappropriate ioctl for device"): + with self.assertRaisesRegex(GLib.GError, r"Error getting Namespace Identifier \(NSID\): Inappropriate ioctl for device"): BlockDev.nvme_get_namespace_info(self.nvme_dev) # not much information can be gathered from loop-based NVMe target devices... @@ -97,7 +100,7 @@ def test_ctrl_info(self): """Test controller info""" - with self.assertRaisesRegexp(GLib.GError, r".*Failed to open device .*': No such file or directory"): + with self.assertRaisesRegex(GLib.GError, r".*Failed to open device .*': No such file or directory"): BlockDev.nvme_get_controller_info("/dev/nonexistent") info = BlockDev.nvme_get_controller_info(self.nvme_dev) @@ -140,7 +143,7 @@ def test_smart_log(self): """Test SMART health log""" - with self.assertRaisesRegexp(GLib.GError, r".*Failed to open device .*': No such file or directory"): + with self.assertRaisesRegex(GLib.GError, r".*Failed to open device .*': No such file or directory"): BlockDev.nvme_get_smart_log("/dev/nonexistent") log = BlockDev.nvme_get_smart_log(self.nvme_dev) @@ -173,7 +176,7 @@ def test_error_log(self): """Test error log retrieval""" - with self.assertRaisesRegexp(GLib.GError, r".*Failed to open device .*': No such file or directory"): + with self.assertRaisesRegex(GLib.GError, r".*Failed to open device .*': No such file or directory"): BlockDev.nvme_get_error_log_entries("/dev/nonexistent") log = BlockDev.nvme_get_error_log_entries(self.nvme_dev) @@ -185,11 +188,11 @@ def test_self_test_log(self): """Test self-test log retrieval""" - with self.assertRaisesRegexp(GLib.GError, r".*Failed to open device .*': No such file or directory"): + with self.assertRaisesRegex(GLib.GError, r".*Failed to open device .*': No such file or directory"): BlockDev.nvme_get_self_test_log("/dev/nonexistent") message = r"NVMe Get Log Page - Device Self-test Log command error: Invalid Field in Command: A reserved coded value or an unsupported value in a defined field|NVMe Get Log Page - Device Self-test Log command error: unrecognized" - with self.assertRaisesRegexp(GLib.GError, message): + with self.assertRaisesRegex(GLib.GError, message): # Cannot retrieve self-test log on a nvme target loop devices BlockDev.nvme_get_self_test_log(self.nvme_dev) @@ -209,34 +212,34 @@ def test_self_test(self): """Test issuing the self-test command""" - with self.assertRaisesRegexp(GLib.GError, r".*Failed to open device .*': No such file or directory"): + with self.assertRaisesRegex(GLib.GError, r".*Failed to open device .*': No such file or directory"): BlockDev.nvme_device_self_test("/dev/nonexistent", BlockDev.NVMESelfTestAction.SHORT) message = r"Invalid value specified for the self-test action" - with self.assertRaisesRegexp(GLib.GError, message): + with self.assertRaisesRegex(GLib.GError, message): BlockDev.nvme_device_self_test(self.nvme_dev, BlockDev.NVMESelfTestAction.NOT_RUNNING) - with self.assertRaisesRegexp(GLib.GError, message): + with self.assertRaisesRegex(GLib.GError, message): BlockDev.nvme_device_self_test(self.nvme_ns_dev, BlockDev.NVMESelfTestAction.NOT_RUNNING) message = r"NVMe Device Self-test command error: Invalid Command Opcode: A reserved coded value or an unsupported value in the command opcode field|NVMe Device Self-test command error: Invalid Queue Identifier: The creation of the I/O Completion Queue failed due to an invalid queue identifier specified as part of the command" - with self.assertRaisesRegexp(GLib.GError, message): + with self.assertRaisesRegex(GLib.GError, message): BlockDev.nvme_device_self_test(self.nvme_dev, BlockDev.NVMESelfTestAction.SHORT) - with self.assertRaisesRegexp(GLib.GError, message): + with self.assertRaisesRegex(GLib.GError, message): BlockDev.nvme_device_self_test(self.nvme_ns_dev, BlockDev.NVMESelfTestAction.SHORT) - with self.assertRaisesRegexp(GLib.GError, message): + with self.assertRaisesRegex(GLib.GError, message): BlockDev.nvme_device_self_test(self.nvme_dev, BlockDev.NVMESelfTestAction.EXTENDED) - with self.assertRaisesRegexp(GLib.GError, message): + with self.assertRaisesRegex(GLib.GError, message): BlockDev.nvme_device_self_test(self.nvme_ns_dev, BlockDev.NVMESelfTestAction.EXTENDED) - with self.assertRaisesRegexp(GLib.GError, message): + with self.assertRaisesRegex(GLib.GError, message): BlockDev.nvme_device_self_test(self.nvme_dev, BlockDev.NVMESelfTestAction.VENDOR_SPECIFIC) - with self.assertRaisesRegexp(GLib.GError, message): + with self.assertRaisesRegex(GLib.GError, message): BlockDev.nvme_device_self_test(self.nvme_ns_dev, BlockDev.NVMESelfTestAction.VENDOR_SPECIFIC) - with self.assertRaisesRegexp(GLib.GError, message): + with self.assertRaisesRegex(GLib.GError, message): BlockDev.nvme_device_self_test(self.nvme_dev, BlockDev.NVMESelfTestAction.ABORT) - with self.assertRaisesRegexp(GLib.GError, message): + with self.assertRaisesRegex(GLib.GError, message): BlockDev.nvme_device_self_test(self.nvme_ns_dev, BlockDev.NVMESelfTestAction.ABORT) @@ -244,20 +247,20 @@ def test_format(self): """Test issuing the format command""" - with self.assertRaisesRegexp(GLib.GError, r".*Failed to open device .*': No such file or directory"): + with self.assertRaisesRegex(GLib.GError, r".*Failed to open device .*': No such file or directory"): BlockDev.nvme_format("/dev/nonexistent", 0, 0, BlockDev.NVMEFormatSecureErase.NONE) message = r"Couldn't match desired LBA data block size in a device supported LBA format data sizes" - with self.assertRaisesRegexp(GLib.GError, message): + with self.assertRaisesRegex(GLib.GError, message): BlockDev.nvme_format(self.nvme_ns_dev, 123, 0, BlockDev.NVMEFormatSecureErase.NONE) - with self.assertRaisesRegexp(GLib.GError, message): + with self.assertRaisesRegex(GLib.GError, message): BlockDev.nvme_format(self.nvme_dev, 123, 0, BlockDev.NVMEFormatSecureErase.NONE) # format doesn't really work on the kernel loop target message = r"Format NVM command error: Invalid Command Opcode: A reserved coded value or an unsupported value in the command opcode field|Format NVM command error: Invalid Queue Identifier: The creation of the I/O Completion Queue failed due to an invalid queue identifier specified as part of the command" - with self.assertRaisesRegexp(GLib.GError, message): + with self.assertRaisesRegex(GLib.GError, message): BlockDev.nvme_format(self.nvme_ns_dev, 0, 0, BlockDev.NVMEFormatSecureErase.NONE) - with self.assertRaisesRegexp(GLib.GError, message): + with self.assertRaisesRegex(GLib.GError, message): BlockDev.nvme_format(self.nvme_dev, 0, 0, BlockDev.NVMEFormatSecureErase.NONE) @@ -265,14 +268,14 @@ def test_sanitize_log(self): """Test sanitize log retrieval""" - with self.assertRaisesRegexp(GLib.GError, r".*Failed to open device .*': No such file or directory"): + with self.assertRaisesRegex(GLib.GError, r".*Failed to open device .*': No such file or directory"): BlockDev.nvme_get_sanitize_log("/dev/nonexistent") message = r"NVMe Get Log Page - Sanitize Status Log command error: Invalid Field in Command: A reserved coded value or an unsupported value in a defined field|NVMe Get Log Page - Sanitize Status Log command error: unrecognized" - with self.assertRaisesRegexp(GLib.GError, message): + with self.assertRaisesRegex(GLib.GError, message): # Cannot retrieve sanitize log on a nvme target loop devices BlockDev.nvme_get_sanitize_log(self.nvme_dev) - with self.assertRaisesRegexp(GLib.GError, message): + with self.assertRaisesRegex(GLib.GError, message): BlockDev.nvme_get_sanitize_log(self.nvme_ns_dev) @@ -281,14 +284,14 @@ """Test issuing the sanitize command""" message = r".*Failed to open device .*': No such file or directory" - with self.assertRaisesRegexp(GLib.GError, message): + with self.assertRaisesRegex(GLib.GError, message): BlockDev.nvme_sanitize("/dev/nonexistent", BlockDev.NVMESanitizeAction.BLOCK_ERASE, False, 0, 0, False) message = r"Sanitize command error: Invalid Command Opcode: A reserved coded value or an unsupported value in the command opcode field|Sanitize command error: Invalid Queue Identifier: The creation of the I/O Completion Queue failed due to an invalid queue identifier specified as part of the command" for i in [BlockDev.NVMESanitizeAction.BLOCK_ERASE, BlockDev.NVMESanitizeAction.CRYPTO_ERASE, BlockDev.NVMESanitizeAction.OVERWRITE, BlockDev.NVMESanitizeAction.EXIT_FAILURE]: - with self.assertRaisesRegexp(GLib.GError, message): + with self.assertRaisesRegex(GLib.GError, message): BlockDev.nvme_sanitize(self.nvme_dev, i, False, 0, 0, False) - with self.assertRaisesRegexp(GLib.GError, message): + with self.assertRaisesRegex(GLib.GError, message): BlockDev.nvme_sanitize(self.nvme_ns_dev, i, False, 0, 0, False) @@ -349,22 +352,22 @@ self.assertEqual(len(ctrls), 0) # nothing to disconnect - with self.assertRaisesRegexp(GLib.GError, r"No subsystems matching '.*' NQN found."): + with self.assertRaisesRegex(GLib.GError, r"No subsystems matching '.*' NQN found."): BlockDev.nvme_disconnect(self.SUBNQN) # nothing to connect to msg = r'Error connecting the controller: ' - with self.assertRaisesRegexp(GLib.GError, msg): + with self.assertRaisesRegex(GLib.GError, msg): BlockDev.nvme_connect(self.SUBNQN, 'loop', None, None, None, None, self.hostnqn, None) - with self.assertRaisesRegexp(GLib.GError, msg): + with self.assertRaisesRegex(GLib.GError, msg): BlockDev.nvme_connect(self.SUBNQN, 'loop', '127.0.0.1', None, None, None, self.hostnqn, None) - with self.assertRaisesRegexp(GLib.GError, msg): + with self.assertRaisesRegex(GLib.GError, msg): BlockDev.nvme_connect(self.SUBNQN, 'loop', None, None, None, None, None, None) self._setup_target(1) # make a connection - ret = BlockDev.nvme_connect(self.SUBNQN, 'loop', None, None, None, None, self.hostnqn, None) + ret = BlockDev.nvme_connect(self.SUBNQN, 'loop', None, None, None, None, None, None) self.addCleanup(self._nvme_disconnect, self.SUBNQN, ignore_errors=True) self.assertTrue(ret) @@ -380,7 +383,7 @@ self.assertTrue(os.path.exists(ns)) # make a duplicate connection - ret = BlockDev.nvme_connect(self.SUBNQN, 'loop', None, None, None, None, self.hostnqn, None) + ret = BlockDev.nvme_connect(self.SUBNQN, 'loop', None, None, None, None, None, None) self.assertTrue(ret) # should see two controllers now @@ -391,9 +394,9 @@ self.assertTrue(os.path.exists(c)) # disconnect - with self.assertRaisesRegexp(GLib.GError, r"No subsystems matching '.*' NQN found."): + with self.assertRaisesRegex(GLib.GError, r"No subsystems matching '.*' NQN found."): BlockDev.nvme_disconnect(self.SUBNQN + "xx") - with self.assertRaisesRegexp(GLib.GError, r"No controllers matching the /dev/nvme.*xx device name found."): + with self.assertRaisesRegex(GLib.GError, r"No controllers matching the /dev/nvme.*xx device name found."): BlockDev.nvme_disconnect_by_path(ctrls[0] + "xx") # should disconnect both connections as long the SUBNQN matches BlockDev.nvme_disconnect(self.SUBNQN) @@ -494,8 +497,8 @@ HOSTID_PATH = '/etc/nvme/hostid' FAKE_HOSTNQN1 = 'nqn.2014-08.org.nvmexpress:uuid:ffffffff-ffff-ffff-ffff-ffffffffffff' FAKE_HOSTNQN2 = 'nqn.2014-08.org.nvmexpress:uuid:beefbeef-beef-beef-beef-beefdeadbeef' - FAKE_HOSTID1 = 'eeeeeeee-eeee-eeee-eeee-eeeeeeeeeeee' - FAKE_HOSTID2 = 'beefbeef-beef-beef-beef-beefdeadbeef' + FAKE_HOSTID1 = 'aaaaaaaa-ffff-ffff-ffff-ffffffffffff' + FAKE_HOSTID2 = 'beeeeeef-beef-beef-beef-beefdeadbeef' # libnvme might have been configured with a different prefix than libblockdev sysconf_dir = self._get_sysconf_dir() diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libblockdev-3.0.2/tests/overrides_test.py new/libblockdev-3.0.3/tests/overrides_test.py --- old/libblockdev-3.0.2/tests/overrides_test.py 2023-07-04 15:25:25.000000000 +0200 +++ new/libblockdev-3.0.3/tests/overrides_test.py 2023-07-26 09:28:06.000000000 +0200 @@ -1,6 +1,9 @@ import unittest import math import overrides_hack + +import gi +gi.require_version('BlockDev', '3.0') from gi.repository import BlockDev from utils import TestTags, tag_test diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libblockdev-3.0.2/tests/part_test.py new/libblockdev-3.0.3/tests/part_test.py --- old/libblockdev-3.0.2/tests/part_test.py 2023-07-04 15:25:25.000000000 +0200 +++ new/libblockdev-3.0.3/tests/part_test.py 2023-07-26 09:28:06.000000000 +0200 @@ -4,10 +4,13 @@ from utils import create_sparse_tempfile, create_lio_device, delete_lio_device, TestTags, tag_test, run_command import overrides_hack -from gi.repository import BlockDev, GLib from bytesize.bytesize import Size, ROUND_UP from packaging.version import Version +import gi +gi.require_version('GLib', '2.0') +gi.require_version('BlockDev', '3.0') +from gi.repository import GLib, BlockDev class PartTestCase(unittest.TestCase): diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libblockdev-3.0.2/tests/s390_test.py new/libblockdev-3.0.3/tests/s390_test.py --- old/libblockdev-3.0.2/tests/s390_test.py 2023-07-04 15:25:25.000000000 +0200 +++ new/libblockdev-3.0.3/tests/s390_test.py 2023-07-26 09:28:06.000000000 +0200 @@ -3,7 +3,11 @@ import overrides_hack from utils import fake_path, TestTags, tag_test -from gi.repository import BlockDev, GLib + +import gi +gi.require_version('GLib', '2.0') +gi.require_version('BlockDev', '3.0') +from gi.repository import GLib, BlockDev @unittest.skipUnless(os.uname()[4].startswith('s390'), "s390x architecture required") class S390TestCase(unittest.TestCase): diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libblockdev-3.0.2/tests/swap_test.py new/libblockdev-3.0.3/tests/swap_test.py --- old/libblockdev-3.0.2/tests/swap_test.py 2023-07-04 15:25:25.000000000 +0200 +++ new/libblockdev-3.0.3/tests/swap_test.py 2023-07-26 09:28:06.000000000 +0200 @@ -4,8 +4,11 @@ import overrides_hack from utils import create_sparse_tempfile, create_lio_device, delete_lio_device, fake_utils, fake_path, run_command, run, TestTags, tag_test -from gi.repository import BlockDev, GLib +import gi +gi.require_version('GLib', '2.0') +gi.require_version('BlockDev', '3.0') +from gi.repository import GLib, BlockDev class SwapTest(unittest.TestCase): requested_plugins = BlockDev.plugin_specs_from_names(("swap",)) @@ -191,21 +194,21 @@ with fake_utils("tests/fake_utils/swap_low_version/"): # too low version of mkswap available - with self.assertRaisesRegexp(GLib.GError, "Too low version of mkswap"): + with self.assertRaisesRegex(GLib.GError, "Too low version of mkswap"): BlockDev.swap_is_tech_avail(BlockDev.SwapTech.SWAP, BlockDev.SwapTechMode.CREATE) with fake_path(all_but="mkswap"): # no mkswap available - with self.assertRaisesRegexp(GLib.GError, "The 'mkswap' utility is not available"): + with self.assertRaisesRegex(GLib.GError, "The 'mkswap' utility is not available"): BlockDev.swap_is_tech_avail(BlockDev.SwapTech.SWAP, BlockDev.SwapTechMode.CREATE) with fake_path(all_but="swaplabel"): # no swaplabel available - with self.assertRaisesRegexp(GLib.GError, "The 'swaplabel' utility is not available"): + with self.assertRaisesRegex(GLib.GError, "The 'swaplabel' utility is not available"): BlockDev.swap_is_tech_avail(BlockDev.SwapTech.SWAP, BlockDev.SwapTechMode.SET_LABEL) with fake_path(all_but="mkswap"): - with self.assertRaisesRegexp(GLib.GError, "The 'mkswap' utility is not available"): + with self.assertRaisesRegex(GLib.GError, "The 'mkswap' utility is not available"): # the device shouldn't matter, the function should return an # error before any other checks or actions BlockDev.swap_mkswap("/dev/device", "LABEL", None) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libblockdev-3.0.2/tests/utils.py new/libblockdev-3.0.3/tests/utils.py --- old/libblockdev-3.0.2/tests/utils.py 2023-07-18 09:25:21.000000000 +0200 +++ new/libblockdev-3.0.3/tests/utils.py 2023-08-23 11:44:58.000000000 +0200 @@ -16,6 +16,8 @@ from enum import Enum from itertools import chain +import gi +gi.require_version('GLib', '2.0') from gi.repository import GLib try: @@ -428,12 +430,11 @@ """ SUBNQN = 'libblockdev_subnqn' - hostnqn = get_nvme_hostnqn() setup_nvme_target([dev_path], SUBNQN) # connect initiator to the newly created target - (ret, out, err) = run_command("nvme connect --transport=loop --hostnqn=%s --nqn=%s" % (hostnqn, SUBNQN)) + (ret, out, err) = run_command("nvme connect --transport=loop --nqn=%s" % SUBNQN) if ret != 0: raise RuntimeError("Error connecting to the NVMe target: '%s %s'" % (out, err)) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libblockdev-3.0.2/tests/utils_test.py new/libblockdev-3.0.3/tests/utils_test.py --- old/libblockdev-3.0.2/tests/utils_test.py 2023-07-04 15:25:25.000000000 +0200 +++ new/libblockdev-3.0.3/tests/utils_test.py 2023-07-26 09:28:06.000000000 +0200 @@ -4,7 +4,10 @@ import overrides_hack from utils import fake_utils, create_sparse_tempfile, create_lio_device, delete_lio_device, run_command, TestTags, tag_test, read_file -from gi.repository import BlockDev, GLib +import gi +gi.require_version('GLib', '2.0') +gi.require_version('BlockDev', '3.0') +from gi.repository import GLib, BlockDev class UtilsTestCase(unittest.TestCase): @@ -216,11 +219,11 @@ cnt = 65536 succ, out = BlockDev.utils_exec_and_capture_output(["bash", "-c", "for i in {1..%d}; do echo -n .; done" % cnt]) self.assertTrue(succ) - self.assertEquals(len(out), cnt) + self.assertEqual(len(out), cnt) succ, out = BlockDev.utils_exec_and_capture_output(["bash", "-c", "for i in {1..%d}; do echo -n .; echo -n \# >&2; done" % cnt]) self.assertTrue(succ) - self.assertEquals(len(out), cnt) + self.assertEqual(len(out), cnt) # now exceed the system pipe buffer size # pipe(7): The maximum size (in bytes) of individual pipes that can be set by users without the CAP_SYS_RESOURCE capability. @@ -229,11 +232,11 @@ succ, out = BlockDev.utils_exec_and_capture_output(["bash", "-c", "for i in {1..%d}; do echo -n .; done" % cnt]) self.assertTrue(succ) - self.assertEquals(len(out), cnt) + self.assertEqual(len(out), cnt) succ, out = BlockDev.utils_exec_and_capture_output(["bash", "-c", "for i in {1..%d}; do echo -n .; echo -n \# >&2; done" % cnt]) self.assertTrue(succ) - self.assertEquals(len(out), cnt) + self.assertEqual(len(out), cnt) # make use of some newlines succ, out = BlockDev.utils_exec_and_capture_output(["bash", "-c", "for i in {1..%d}; do echo -n .; if [ $(($i%%500)) -eq 0 ]; then echo ''; fi; done" % cnt])