libvirt/tools
Michal Privoznik cfcbba4c2b lib: Replace qsort() with g_qsort_with_data()
While glibc provides qsort(), which usually is just a mergesort,
until sorting arrays so huge that temporary array used by
mergesort would not fit into physical memory (which in our case
is never), we are not guaranteed it'll use mergesort. The
advantage of mergesort is clear - it's stable. IOW, if we have an
array of values parsed from XML, qsort() it and produce some
output based on those values, we can then compare the output with
some expected output, line by line.

But with newer glibc this is all history. After [1], qsort() is
no longer mergesort but introsort instead, which is not stable.
This is suboptimal, because in some cases we want to preserve
order of equal items. For instance, in ebiptablesApplyNewRules(),
nwfilter rules are sorted by their priority. But if two rules
have the same priority, we want to keep them in the order they
appear in the XML. Since it's hard/needless work to identify
places where stable or unstable sorting is needed, let's just
play it safe and use stable sorting everywhere.

Fortunately, glib provides g_qsort_with_data() which indeed
implement mergesort and it's a drop in replacement for qsort(),
almost. It accepts fifth argument (pointer to opaque data), that
is passed to comparator function, which then accepts three
arguments.

We have to keep one occurance of qsort() though - in NSS module
which deliberately does not link with glib.

1: https://sourceware.org/git/?p=glibc.git;a=commitdiff;h=03bf8357e8291857a435afcc3048e0b697b6cc04
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2023-11-24 09:53:14 +01:00
..
bash-completion meson: Use dicts to initialize cfg_data objects 2022-04-01 15:33:19 +02:00
nss nss: aiforaf: Decrease stack size by scoping off large buffers 2023-09-04 10:31:53 +02:00
wireshark meson: Replace meson.source_root() with meson.project_source_root() 2022-10-10 15:06:09 +02:00
libvirt_recover_xattrs.sh tools: fix iterating over argv when recovering xattr 2021-11-30 10:45:35 +00:00
libvirt_win_icon_16x16.ico Move virsh into tools/ directory 2009-09-21 14:41:45 +01:00
libvirt_win_icon_32x32.ico Move virsh into tools/ directory 2009-09-21 14:41:45 +01:00
libvirt_win_icon_48x48.ico Move virsh into tools/ directory 2009-09-21 14:41:45 +01:00
libvirt_win_icon_64x64.ico Move virsh into tools/ directory 2009-09-21 14:41:45 +01:00
libvirt-guests.service.in systemd: More tweaks to Description and Documentation lines 2023-11-06 23:45:04 +01:00
libvirt-guests.sh.in libvirt-guests: Remove unused variable 'libvirtd' 2023-08-01 10:46:11 -06:00
meson.build build: suppress "ignoring duplicate libraries" warning on macOS 2023-11-03 15:56:37 -04:00
virsh_win_icon.rc Move virsh into tools/ directory 2009-09-21 14:41:45 +01:00
virsh-backup.c virsh: Require --xpath for *dumpxml 2022-07-25 09:50:21 +02:00
virsh-backup.h backup: Implement virsh support for backup 2019-12-10 12:41:56 +01:00
virsh-checkpoint.c lib: Replace qsort() with g_qsort_with_data() 2023-11-24 09:53:14 +01:00
virsh-checkpoint.h backup: Implement virsh support for checkpoints 2019-07-26 16:48:58 -05:00
virsh-completer-checkpoint.c tools: Remove unused includes 2022-06-16 06:43:58 +02:00
virsh-completer-checkpoint.h virsh-completer*.h: Use modern header style 2021-09-17 09:40:46 +02:00
virsh-completer-domain.c tools: Remove unused includes 2022-06-16 06:43:58 +02:00
virsh-completer-domain.h virsh: Move 'cmdEvent' and all of its machinery to virsh-domain-event.c 2022-03-03 11:06:56 +01:00
virsh-completer-host.c virsh: Add completer for hypervisor-cpu-baseline --model 2022-10-10 14:31:43 +02:00
virsh-completer-host.h virsh: Add completer for hypervisor-cpu-baseline --model 2022-10-10 14:31:43 +02:00
virsh-completer-interface.c tools: Remove unused includes 2022-06-16 06:43:58 +02:00
virsh-completer-interface.h virsh-completer*.h: Use modern header style 2021-09-17 09:40:46 +02:00
virsh-completer-network.c tools: Remove unused includes 2022-06-16 06:43:58 +02:00
virsh-completer-network.h virsh: Introduce net-update --section completer 2022-01-19 16:48:33 +01:00
virsh-completer-nodedev.c tools: Remove unused includes 2022-06-16 06:43:58 +02:00
virsh-completer-nodedev.h virsh: Provide completer for PCI backend drivers 2022-04-04 16:30:48 +02:00
virsh-completer-nwfilter.c tools: Remove unused includes 2022-06-16 06:43:58 +02:00
virsh-completer-nwfilter.h virsh-completer*.h: Use modern header style 2021-09-17 09:40:46 +02:00
virsh-completer-pool.c tools: Remove unused includes 2022-06-16 06:43:58 +02:00
virsh-completer-pool.h virsh-completer*.h: Use modern header style 2021-09-17 09:40:46 +02:00
virsh-completer-secret.c tools: Remove unused includes 2022-06-16 06:43:58 +02:00
virsh-completer-secret.h virsh-completer*.h: Use modern header style 2021-09-17 09:40:46 +02:00
virsh-completer-snapshot.c tools: Remove unused includes 2022-06-16 06:43:58 +02:00
virsh-completer-snapshot.h virsh-completer*.h: Use modern header style 2021-09-17 09:40:46 +02:00
virsh-completer-volume.c tools: Remove unused includes 2022-06-16 06:43:58 +02:00
virsh-completer-volume.h virsh: Provide completer for vol-wipe algorithms 2022-03-11 09:10:24 +01:00
virsh-completer.c tools: Remove unused includes 2022-06-16 06:43:58 +02:00
virsh-completer.h virsh: Introduce virshEnumComplete() 2022-03-15 13:36:56 +01:00
virsh-console.c virsh: add console --resume support 2023-10-24 13:51:32 +02:00
virsh-console.h virsh: add console --resume support 2023-10-24 13:51:32 +02:00
virsh-domain-event.c tools: Move error messages onto a single line 2023-09-04 09:35:36 +02:00
virsh-domain-event.h virsh: Move 'cmdEvent' and all of its machinery to virsh-domain-event.c 2022-03-03 11:06:56 +01:00
virsh-domain-monitor.c lib: Replace qsort() with g_qsort_with_data() 2023-11-24 09:53:14 +01:00
virsh-domain-monitor.h virsh: Fix virshDomainInterfaceSourceCompleter 2020-01-07 16:12:55 +01:00
virsh-domain.c Improve virsh create --console behavior 2023-10-24 14:10:09 +02:00
virsh-domain.h virsh: Add mode option to domdirtyrate-calc virsh api 2022-02-21 13:34:16 +01:00
virsh-edit.c tools: Update format strings in translated messages (part 1) 2023-04-01 11:40:35 +02:00
virsh-host.c lib: Replace qsort() with g_qsort_with_data() 2023-11-24 09:53:14 +01:00
virsh-host.h virsh-host: Avoid 'vir' prefix for locally declared VIR_ENUM* helpers 2021-07-23 09:59:12 +02:00
virsh-interface.c lib: Replace qsort() with g_qsort_with_data() 2023-11-24 09:53:14 +01:00
virsh-interface.h tools: use #pragma once in headers 2019-06-19 17:12:34 +02:00
virsh-network.c lib: Replace qsort() with g_qsort_with_data() 2023-11-24 09:53:14 +01:00
virsh-network.h virsh: Introduce net-update --section completer 2022-01-19 16:48:33 +01:00
virsh-nodedev.c lib: Replace qsort() with g_qsort_with_data() 2023-11-24 09:53:14 +01:00
virsh-nodedev.h tools: s/Nodedev/NodeDevice/ 2019-08-09 09:03:53 +02:00
virsh-nwfilter.c lib: Replace qsort() with g_qsort_with_data() 2023-11-24 09:53:14 +01:00
virsh-nwfilter.h tools: use #pragma once in headers 2019-06-19 17:12:34 +02:00
virsh-pool.c lib: Replace qsort() with g_qsort_with_data() 2023-11-24 09:53:14 +01:00
virsh-pool.h virsh-pool: Remove static from virshStoragePoolList{Free,Collect} 2021-06-16 10:32:33 +02:00
virsh-secret.c lib: Replace qsort() with g_qsort_with_data() 2023-11-24 09:53:14 +01:00
virsh-secret.h tools: remove unnecessary includes 2020-08-03 15:30:40 +02:00
virsh-snapshot.c lib: Replace qsort() with g_qsort_with_data() 2023-11-24 09:53:14 +01:00
virsh-snapshot.h tools: remove unnecessary includes 2020-08-03 15:30:40 +02:00
virsh-util.c lib: Replace xmlKeepBlanksDefault() with virXMLParseWithIndent() 2023-11-21 14:43:39 +01:00
virsh-util.h virsh exposure of Network Metadata APIs 2023-08-25 12:36:37 +02:00
virsh-volume.c lib: Replace qsort() with g_qsort_with_data() 2023-11-24 09:53:14 +01:00
virsh-volume.h virsh: Provide completer for vol-wipe algorithms 2022-03-11 09:10:24 +01:00
virsh.c tools: Reformat --help output of virsh and virt-admin 2023-09-04 11:59:38 +02:00
virsh.h virsh: Add --model option for hypervisor-cpu-baseline 2022-10-10 14:31:43 +02:00
virt-admin-completer.c lib: Drop internal virXXXPtr typedefs 2021-04-13 17:00:38 +02:00
virt-admin-completer.h tools: use #pragma once in headers 2019-06-19 17:12:34 +02:00
virt-admin.c tools: Reformat --help output of virsh and virt-admin 2023-09-04 11:59:38 +02:00
virt-admin.h lib: Drop internal virXXXPtr typedefs 2021-04-13 17:00:38 +02:00
virt-host-validate-bhyve.c virHostValidateBhyve: Heap allocate massive 'struct kld_file_stat' 2023-09-04 10:31:53 +02:00
virt-host-validate-bhyve.h tools: use #pragma once in headers 2019-06-19 17:12:34 +02:00
virt-host-validate-ch.c tools: Move error messages onto a single line 2023-09-04 09:35:36 +02:00
virt-host-validate-ch.h tools: add virt-host-validate-ch for ch driver 2021-10-12 17:28:35 +02:00
virt-host-validate-common.c virt-host-validate: Detect SMMU presence on ARMs by parsing IORT table 2023-04-06 12:48:22 +02:00
virt-host-validate-common.h tools: only fail validations if VIR_HOST_VALIDATE_FAIL is set 2021-06-08 08:52:07 +02:00
virt-host-validate-lxc.c virt-host-validate: require freezer for LXC 2018-10-05 15:53:29 +02:00
virt-host-validate-lxc.h tools: use #pragma once in headers 2019-06-19 17:12:34 +02:00
virt-host-validate-qemu.c tools: Move error messages onto a single line 2023-09-04 09:35:36 +02:00
virt-host-validate-qemu.h tools: use #pragma once in headers 2019-06-19 17:12:34 +02:00
virt-host-validate.c tools: Update format strings in translated messages (part 2) 2023-04-01 11:40:36 +02:00
virt-login-shell-helper.c tools: Update format strings in translated messages (part 2) 2023-04-01 11:40:36 +02:00
virt-login-shell.c Use G_N_ELEMENTS() more 2023-03-13 13:29:07 +01:00
virt-login-shell.conf virt-login-shell: add ability to auto-detect shell from container 2016-06-10 11:03:02 +01:00
virt-pki-query-dn.c tools: Update format strings in translated messages (part 2) 2023-04-01 11:40:36 +02:00
virt-pki-validate.in meson: Use initconfdir 2023-05-05 15:08:25 +02:00
virt-qemu-qmp-proxy scripts: Fix the flake8 syntax-check failures 2023-06-29 11:51:27 +02:00
virt-qemu-sev-validate tools: fix VMSA construction with explicit CPU family/model/stepping 2023-08-29 11:44:59 +01:00
virt-sanlock-cleanup.in build: Extract pod from source files 2016-04-25 15:40:43 +02:00
virt-xml-validate.in virt-xml-validate: Fix incorrect wildcards for XML roots 2022-07-07 12:21:16 +02:00
vsh-table.c lib: use struct zero initializer instead of memset 2023-08-03 16:41:19 +02:00
vsh-table.h vsh-table: Ensure NULL terminated arguments to vshTable*() 2021-12-17 15:05:58 +01:00
vsh.c tools: Move error messages onto a single line 2023-09-04 09:35:36 +02:00
vsh.h vshPrint: Add version using 'va_list' 2023-04-14 15:22:02 +02:00