libvirt-9.10.0-1
Update to version 9.10.0
This commit is contained in:
parent
f8539fae13
commit
8556d44e84
@ -1,39 +0,0 @@
|
||||
From b049f42dda977b094895acdf348304ba2f4f1cd4 Mon Sep 17 00:00:00 2001
|
||||
From: Pavel Hrdina <phrdina@redhat.com>
|
||||
Date: Fri, 3 Nov 2023 14:03:55 +0100
|
||||
Subject: [PATCH 1/8] qemu_process: fix crash in
|
||||
qemuSaveImageDecompressionStart
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
Commit changing the code to allow passing NULL as @data into
|
||||
qemuSaveImageDecompressionStart() was not correct as it left the
|
||||
original call into the function as well.
|
||||
|
||||
Introduced-by: 2f3e582a1ac1008eba8d43c751cdba8712dd1614
|
||||
Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=2247754
|
||||
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
|
||||
Reviewed-by: Ján Tomko <jtomko@redhat.com>
|
||||
(cherry picked from commit 4f4a8dce944e05311565b690a84f6bb1ef67c086)
|
||||
---
|
||||
src/qemu/qemu_process.c | 3 ---
|
||||
1 file changed, 3 deletions(-)
|
||||
|
||||
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
|
||||
index 1ef032dbd2..b9267d8699 100644
|
||||
--- a/src/qemu/qemu_process.c
|
||||
+++ b/src/qemu/qemu_process.c
|
||||
@@ -8208,9 +8208,6 @@ qemuProcessStartWithMemoryState(virConnectPtr conn,
|
||||
}
|
||||
}
|
||||
|
||||
- if (qemuSaveImageDecompressionStart(data, fd, &intermediatefd, &errbuf, &cmd) < 0)
|
||||
- return -1;
|
||||
-
|
||||
/* No cookie means libvirt which saved the domain was too old to mess up
|
||||
* the CPU definitions.
|
||||
*/
|
||||
--
|
||||
2.43.0
|
||||
|
@ -1,109 +0,0 @@
|
||||
From 982184d57fff654c1cccf0d4a4a5d1631058819d Mon Sep 17 00:00:00 2001
|
||||
From: Michal Privoznik <mprivozn@redhat.com>
|
||||
Date: Mon, 20 Nov 2023 04:49:53 +0100
|
||||
Subject: [PATCH 2/8] vbox_snapshot_conf: Parse XMLs without net access
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
When working with VirtualBox's snapshots, the snapshot XML is
|
||||
firstly parsed, stored in memory (with some parts being stored as
|
||||
verbatim XML snippets, strings), requested changes are made and
|
||||
then this modified XML is formatted via
|
||||
virVBoxSnapshotConfSaveVboxFile() which calls
|
||||
xmlParseInNodeContext() to format those previously stored XML
|
||||
snippets.
|
||||
|
||||
The first parse of whole VirtualBox snapshot file is done using
|
||||
virXMLParse() (in virVBoxSnapshotConfLoadVboxFile()) and thus
|
||||
with XML_PARSE_NONET specified.
|
||||
|
||||
But those ad-hoc parsings when formatting the XML back pass zero
|
||||
flags mask: xmlParseInNodeContext(..., options = 0, ...);
|
||||
|
||||
This is potentially dangerous.
|
||||
|
||||
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
|
||||
Reviewed-by: Ján Tomko <jtomko@redhat.com>
|
||||
(cherry picked from commit d8cb1cd50c608eb647fcb17c4347a2e9d5004e8d)
|
||||
---
|
||||
src/vbox/vbox_snapshot_conf.c | 14 ++++++++------
|
||||
1 file changed, 8 insertions(+), 6 deletions(-)
|
||||
|
||||
diff --git a/src/vbox/vbox_snapshot_conf.c b/src/vbox/vbox_snapshot_conf.c
|
||||
index 84f7aceac2..467255f77f 100644
|
||||
--- a/src/vbox/vbox_snapshot_conf.c
|
||||
+++ b/src/vbox/vbox_snapshot_conf.c
|
||||
@@ -369,6 +369,7 @@ virVBoxSnapshotConfSerializeSnapshot(xmlNodePtr node,
|
||||
int firstRegexResult = 0;
|
||||
g_auto(GStrv) secondRegex = NULL;
|
||||
int secondRegexResult = 0;
|
||||
+ const int parseFlags = XML_PARSE_NONET;
|
||||
|
||||
uuid = g_strdup_printf("{%s}", snapshot->uuid);
|
||||
|
||||
@@ -406,7 +407,7 @@ virVBoxSnapshotConfSerializeSnapshot(xmlNodePtr node,
|
||||
parseError = xmlParseInNodeContext(node,
|
||||
snapshot->hardware,
|
||||
(int)strlen(snapshot->hardware),
|
||||
- 0,
|
||||
+ parseFlags,
|
||||
&hardwareNode);
|
||||
if (parseError != XML_ERR_OK) {
|
||||
virReportError(VIR_ERR_XML_ERROR, "%s",
|
||||
@@ -418,7 +419,7 @@ virVBoxSnapshotConfSerializeSnapshot(xmlNodePtr node,
|
||||
/* storageController */
|
||||
if (xmlParseInNodeContext(node, snapshot->storageController,
|
||||
(int)strlen(snapshot->storageController),
|
||||
- 0,
|
||||
+ parseFlags,
|
||||
&storageControllerNode) != XML_ERR_OK) {
|
||||
virReportError(VIR_ERR_XML_ERROR, "%s",
|
||||
_("Unable to add the snapshot storageController"));
|
||||
@@ -944,6 +945,7 @@ virVBoxSnapshotConfSaveVboxFile(virVBoxSnapshotConfMachine *machine,
|
||||
int firstRegexResult = 0;
|
||||
g_auto(GStrv) secondRegex = NULL;
|
||||
int secondRegexResult = 0;
|
||||
+ const int parseFlags = XML_PARSE_NONET;
|
||||
|
||||
if (machine == NULL) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||
@@ -1051,7 +1053,7 @@ virVBoxSnapshotConfSaveVboxFile(virVBoxSnapshotConfMachine *machine,
|
||||
parseError = xmlParseInNodeContext(mediaRegistryNode,
|
||||
machine->mediaRegistry->otherMedia[i],
|
||||
(int)strlen(machine->mediaRegistry->otherMedia[i]),
|
||||
- 0,
|
||||
+ parseFlags,
|
||||
&cur);
|
||||
if (parseError != XML_ERR_OK) {
|
||||
virReportError(VIR_ERR_XML_ERROR, "%s",
|
||||
@@ -1071,7 +1073,7 @@ virVBoxSnapshotConfSaveVboxFile(virVBoxSnapshotConfMachine *machine,
|
||||
parseError = xmlParseInNodeContext(machineNode,
|
||||
machine->hardware,
|
||||
(int)strlen(machine->hardware),
|
||||
- 0,
|
||||
+ parseFlags,
|
||||
&cur);
|
||||
if (parseError != XML_ERR_OK) {
|
||||
virReportError(VIR_ERR_XML_ERROR, "%s",
|
||||
@@ -1084,7 +1086,7 @@ virVBoxSnapshotConfSaveVboxFile(virVBoxSnapshotConfMachine *machine,
|
||||
parseError = xmlParseInNodeContext(xmlDocGetRootElement(xml),
|
||||
machine->extraData,
|
||||
(int)strlen(machine->extraData),
|
||||
- 0,
|
||||
+ parseFlags,
|
||||
&cur);
|
||||
if (parseError != XML_ERR_OK) {
|
||||
virReportError(VIR_ERR_XML_ERROR, "%s",
|
||||
@@ -1097,7 +1099,7 @@ virVBoxSnapshotConfSaveVboxFile(virVBoxSnapshotConfMachine *machine,
|
||||
parseError = xmlParseInNodeContext(machineNode,
|
||||
machine->storageController,
|
||||
(int)strlen(machine->storageController),
|
||||
- 0,
|
||||
+ parseFlags,
|
||||
&cur);
|
||||
if (parseError != XML_ERR_OK) {
|
||||
virReportError(VIR_ERR_XML_ERROR, "%s",
|
||||
--
|
||||
2.43.0
|
||||
|
@ -1,76 +0,0 @@
|
||||
From ee3f790a24ec16308e016f9e7dc1cc5e29a6a525 Mon Sep 17 00:00:00 2001
|
||||
From: Michal Privoznik <mprivozn@redhat.com>
|
||||
Date: Tue, 21 Nov 2023 10:40:36 +0100
|
||||
Subject: [PATCH 3/8] vbox_snapshot_conf: Keep indent in snapshot XML
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
As mentioned in previous commit, VirtualBox has its own snapshot
|
||||
XML which we parse, change and then format back. During this, we
|
||||
ought to keep the indentation to produce better looking result
|
||||
(especially when we want to compare the output in tests later on,
|
||||
like we do in vboxsnapshotxmltest).
|
||||
|
||||
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
|
||||
Reviewed-by: Ján Tomko <jtomko@redhat.com>
|
||||
(cherry picked from commit d1f58b10f687050dd097c5a60becf62c35deee68)
|
||||
---
|
||||
src/vbox/vbox_snapshot_conf.c | 12 ++++++++----
|
||||
1 file changed, 8 insertions(+), 4 deletions(-)
|
||||
|
||||
diff --git a/src/vbox/vbox_snapshot_conf.c b/src/vbox/vbox_snapshot_conf.c
|
||||
index 467255f77f..89cd685954 100644
|
||||
--- a/src/vbox/vbox_snapshot_conf.c
|
||||
+++ b/src/vbox/vbox_snapshot_conf.c
|
||||
@@ -25,6 +25,7 @@
|
||||
#include "virstring.h"
|
||||
#include "virxml.h"
|
||||
|
||||
+#include <libxml/xmlsave.h>
|
||||
#include <libxml/xpathInternals.h>
|
||||
|
||||
#define VIR_FROM_THIS VIR_FROM_VBOX
|
||||
@@ -364,12 +365,11 @@ virVBoxSnapshotConfSerializeSnapshot(xmlNodePtr node,
|
||||
xmlParserErrors parseError = XML_ERR_OK;
|
||||
char *uuid = NULL;
|
||||
char *timeStamp = NULL;
|
||||
-
|
||||
g_auto(GStrv) firstRegex = NULL;
|
||||
int firstRegexResult = 0;
|
||||
g_auto(GStrv) secondRegex = NULL;
|
||||
int secondRegexResult = 0;
|
||||
- const int parseFlags = XML_PARSE_NONET;
|
||||
+ const int parseFlags = XML_PARSE_NONET | XML_PARSE_NOBLANKS;
|
||||
|
||||
uuid = g_strdup_printf("{%s}", snapshot->uuid);
|
||||
|
||||
@@ -940,12 +940,14 @@ virVBoxSnapshotConfSaveVboxFile(virVBoxSnapshotConfMachine *machine,
|
||||
xmlParserErrors parseError = XML_ERR_OK;
|
||||
char *currentSnapshot = NULL;
|
||||
char *timeStamp = NULL;
|
||||
-
|
||||
g_auto(GStrv) firstRegex = NULL;
|
||||
int firstRegexResult = 0;
|
||||
g_auto(GStrv) secondRegex = NULL;
|
||||
int secondRegexResult = 0;
|
||||
- const int parseFlags = XML_PARSE_NONET;
|
||||
+ const int parseFlags = XML_PARSE_NONET | XML_PARSE_NOBLANKS;
|
||||
+ int oldIndentTreeOutput = xmlIndentTreeOutput;
|
||||
+
|
||||
+ xmlIndentTreeOutput = 1;
|
||||
|
||||
if (machine == NULL) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||
@@ -1127,6 +1129,8 @@ virVBoxSnapshotConfSaveVboxFile(virVBoxSnapshotConfMachine *machine,
|
||||
ret = 0;
|
||||
|
||||
cleanup:
|
||||
+ xmlIndentTreeOutput = oldIndentTreeOutput;
|
||||
+
|
||||
VIR_FREE(currentSnapshot);
|
||||
VIR_FREE(timeStamp);
|
||||
|
||||
--
|
||||
2.43.0
|
||||
|
@ -1,36 +0,0 @@
|
||||
From 09f06f6286f864fefdf4877b5792999e0d4e89d1 Mon Sep 17 00:00:00 2001
|
||||
From: Michal Privoznik <mprivozn@redhat.com>
|
||||
Date: Mon, 20 Nov 2023 03:18:12 +0100
|
||||
Subject: [PATCH 4/8] virxml: include <libxml/xmlsave.h> for
|
||||
xmlIndentTreeOutput declaration
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
After libxml2's commit of v2.12.0~101 we no longer get
|
||||
xmlIndentTreeOutput declaration by us including just
|
||||
libxml/xpathInternals.h and libxml2's header files leakage.
|
||||
|
||||
Resolves: https://bugs.gentoo.org/917516
|
||||
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
|
||||
Reviewed-by: Ján Tomko <jtomko@redhat.com>
|
||||
(cherry picked from commit 7a5f232be2269e74943a029c0e8b1b0124674a6c)
|
||||
---
|
||||
src/util/virxml.c | 1 +
|
||||
1 file changed, 1 insertion(+)
|
||||
|
||||
diff --git a/src/util/virxml.c b/src/util/virxml.c
|
||||
index 0c1eae8c3c..4f215a0e59 100644
|
||||
--- a/src/util/virxml.c
|
||||
+++ b/src/util/virxml.c
|
||||
@@ -24,6 +24,7 @@
|
||||
#include <math.h> /* for isnan() */
|
||||
#include <sys/stat.h>
|
||||
|
||||
+#include <libxml/xmlsave.h>
|
||||
#include <libxml/xpathInternals.h>
|
||||
|
||||
#include "virerror.h"
|
||||
--
|
||||
2.43.0
|
||||
|
@ -1,51 +0,0 @@
|
||||
From 68a14369033486ad9e02cb144cde2aced7351ce2 Mon Sep 17 00:00:00 2001
|
||||
From: Michal Privoznik <mprivozn@redhat.com>
|
||||
Date: Sat, 18 Nov 2023 04:17:47 +0100
|
||||
Subject: [PATCH 5/8] virXMLParseHelper: Store XML parsing flags in a variable
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
The virXMLParseHelper() can work in two modes: either it parses a
|
||||
file or a string. Either way, the same set of flags is specified
|
||||
in call of corresponding function. Save flags in a local variable
|
||||
instead.
|
||||
|
||||
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
|
||||
Reviewed-by: Ján Tomko <jtomko@redhat.com>
|
||||
(cherry picked from commit 1beb69df877596fe57efc8d8a117a30a72e5d04e)
|
||||
---
|
||||
src/util/virxml.c | 9 +++------
|
||||
1 file changed, 3 insertions(+), 6 deletions(-)
|
||||
|
||||
diff --git a/src/util/virxml.c b/src/util/virxml.c
|
||||
index 4f215a0e59..027cdb97b9 100644
|
||||
--- a/src/util/virxml.c
|
||||
+++ b/src/util/virxml.c
|
||||
@@ -1136,6 +1136,7 @@ virXMLParseHelper(int domcode,
|
||||
g_autoptr(xmlDoc) xml = NULL;
|
||||
xmlNodePtr rootnode;
|
||||
const char *docname;
|
||||
+ const int parseFlags = XML_PARSE_NONET | XML_PARSE_NOWARNING;
|
||||
|
||||
if (filename)
|
||||
docname = filename;
|
||||
@@ -1154,13 +1155,9 @@ virXMLParseHelper(int domcode,
|
||||
pctxt->sax->error = catchXMLError;
|
||||
|
||||
if (filename) {
|
||||
- xml = xmlCtxtReadFile(pctxt, filename, NULL,
|
||||
- XML_PARSE_NONET |
|
||||
- XML_PARSE_NOWARNING);
|
||||
+ xml = xmlCtxtReadFile(pctxt, filename, NULL, parseFlags);
|
||||
} else {
|
||||
- xml = xmlCtxtReadDoc(pctxt, BAD_CAST xmlStr, url, NULL,
|
||||
- XML_PARSE_NONET |
|
||||
- XML_PARSE_NOWARNING);
|
||||
+ xml = xmlCtxtReadDoc(pctxt, BAD_CAST xmlStr, url, NULL, parseFlags);
|
||||
}
|
||||
|
||||
if (!xml) {
|
||||
--
|
||||
2.43.0
|
||||
|
@ -1,123 +0,0 @@
|
||||
From 6371a0d85b6febd8e034eeec02d70c551535ad5b Mon Sep 17 00:00:00 2001
|
||||
From: Michal Privoznik <mprivozn@redhat.com>
|
||||
Date: Tue, 21 Nov 2023 10:39:58 +0100
|
||||
Subject: [PATCH 6/8] virxml: Introduce parsing APIs that keep indentation
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
When parsing an XML it may be important to keep indentation to
|
||||
produce a better looking result when formatting the XML back.
|
||||
Just look at all those xmlKeepBlanksDefault() calls just before
|
||||
virXMLParse() is called.
|
||||
|
||||
Anyway, as of libxml2 commit v2.12.0~108 xmlKeepBlanksDefault()
|
||||
is deprecated. Therefore, introduce virXMLParse...WithIndent()
|
||||
variants which would do exactly xmlKeepBlanksDefault() did but
|
||||
with non-deprecated APIs.
|
||||
|
||||
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
|
||||
Reviewed-by: Ján Tomko <jtomko@redhat.com>
|
||||
(cherry picked from commit 69958ba3102810bb4f90a91d2f6d9032e1a1da2d)
|
||||
---
|
||||
src/util/virxml.c | 9 +++++++--
|
||||
src/util/virxml.h | 29 +++++++++++++++++++++++++----
|
||||
2 files changed, 32 insertions(+), 6 deletions(-)
|
||||
|
||||
diff --git a/src/util/virxml.c b/src/util/virxml.c
|
||||
index 027cdb97b9..6d0c8f0311 100644
|
||||
--- a/src/util/virxml.c
|
||||
+++ b/src/util/virxml.c
|
||||
@@ -1129,14 +1129,15 @@ virXMLParseHelper(int domcode,
|
||||
const char *rootelement,
|
||||
xmlXPathContextPtr *ctxt,
|
||||
const char *schemafile,
|
||||
- bool validate)
|
||||
+ bool validate,
|
||||
+ bool keepindent)
|
||||
{
|
||||
struct virParserData private;
|
||||
g_autoptr(xmlParserCtxt) pctxt = NULL;
|
||||
g_autoptr(xmlDoc) xml = NULL;
|
||||
xmlNodePtr rootnode;
|
||||
const char *docname;
|
||||
- const int parseFlags = XML_PARSE_NONET | XML_PARSE_NOWARNING;
|
||||
+ int parseFlags = XML_PARSE_NONET | XML_PARSE_NOWARNING;
|
||||
|
||||
if (filename)
|
||||
docname = filename;
|
||||
@@ -1154,6 +1155,10 @@ virXMLParseHelper(int domcode,
|
||||
pctxt->_private = &private;
|
||||
pctxt->sax->error = catchXMLError;
|
||||
|
||||
+ if (keepindent) {
|
||||
+ parseFlags |= XML_PARSE_NOBLANKS;
|
||||
+ }
|
||||
+
|
||||
if (filename) {
|
||||
xml = xmlCtxtReadFile(pctxt, filename, NULL, parseFlags);
|
||||
} else {
|
||||
diff --git a/src/util/virxml.h b/src/util/virxml.h
|
||||
index 7af47437bd..03a85bfb25 100644
|
||||
--- a/src/util/virxml.h
|
||||
+++ b/src/util/virxml.h
|
||||
@@ -199,7 +199,8 @@ virXMLParseHelper(int domcode,
|
||||
const char *rootelement,
|
||||
xmlXPathContextPtr *ctxt,
|
||||
const char *schemafile,
|
||||
- bool validate);
|
||||
+ bool validate,
|
||||
+ bool keepindent);
|
||||
|
||||
const char *
|
||||
virXMLPickShellSafeComment(const char *str1,
|
||||
@@ -219,7 +220,17 @@ virXMLPickShellSafeComment(const char *str1,
|
||||
* Return the parsed document object, or NULL on failure.
|
||||
*/
|
||||
#define virXMLParse(filename, xmlStr, url, rootelement, ctxt, schemafile, validate) \
|
||||
- virXMLParseHelper(VIR_FROM_THIS, filename, xmlStr, url, rootelement, ctxt, schemafile, validate)
|
||||
+ virXMLParseHelper(VIR_FROM_THIS, filename, xmlStr, url, rootelement, ctxt, schemafile, validate, false)
|
||||
+
|
||||
+/**
|
||||
+ * virXMLParseWithIndent:
|
||||
+ *
|
||||
+ * Just like virXMLParse, except indentation is preserved. Should be used when
|
||||
+ * facing an user provided XML which may be formatted back and keeping verbatim
|
||||
+ * spacing is necessary (e.g. due to <metadata/>).
|
||||
+ */
|
||||
+#define virXMLParseWithIndent(filename, xmlStr, url, rootelement, ctxt, schemafile, validate) \
|
||||
+ virXMLParseHelper(VIR_FROM_THIS, filename, xmlStr, url, rootelement, ctxt, schemafile, validate, true)
|
||||
|
||||
/**
|
||||
* virXMLParseStringCtxt:
|
||||
@@ -233,7 +244,17 @@ virXMLPickShellSafeComment(const char *str1,
|
||||
* Return the parsed document object, or NULL on failure.
|
||||
*/
|
||||
#define virXMLParseStringCtxt(xmlStr, url, pctxt) \
|
||||
- virXMLParseHelper(VIR_FROM_THIS, NULL, xmlStr, url, NULL, pctxt, NULL, false)
|
||||
+ virXMLParseHelper(VIR_FROM_THIS, NULL, xmlStr, url, NULL, pctxt, NULL, false, false)
|
||||
+
|
||||
+/**
|
||||
+ * virXMLParseStringCtxtWithIndent:
|
||||
+ *
|
||||
+ * Just like virXMLParseStringCtxt, except indentation is preserved. Should be
|
||||
+ * used when facing an user provided XML which may be formatted back and
|
||||
+ * keeping verbatim spacing is necessary (e.g. due to <metadata/>).
|
||||
+ */
|
||||
+#define virXMLParseStringCtxtWithIndent(xmlStr, url, pctxt) \
|
||||
+ virXMLParseHelper(VIR_FROM_THIS, NULL, xmlStr, url, NULL, pctxt, NULL, false, true)
|
||||
|
||||
/**
|
||||
* virXMLParseFileCtxt:
|
||||
@@ -246,7 +267,7 @@ virXMLPickShellSafeComment(const char *str1,
|
||||
* Return the parsed document object, or NULL on failure.
|
||||
*/
|
||||
#define virXMLParseFileCtxt(filename, pctxt) \
|
||||
- virXMLParseHelper(VIR_FROM_THIS, filename, NULL, NULL, NULL, pctxt, NULL, false)
|
||||
+ virXMLParseHelper(VIR_FROM_THIS, filename, NULL, NULL, NULL, pctxt, NULL, false, false)
|
||||
|
||||
int
|
||||
virXMLSaveFile(const char *path,
|
||||
--
|
||||
2.43.0
|
||||
|
@ -1,162 +0,0 @@
|
||||
From 215a4afe93c051e35d09fabea19172ab51959737 Mon Sep 17 00:00:00 2001
|
||||
From: Michal Privoznik <mprivozn@redhat.com>
|
||||
Date: Mon, 20 Nov 2023 16:20:51 +0100
|
||||
Subject: [PATCH 7/8] lib: Replace xmlKeepBlanksDefault() with
|
||||
virXMLParseWithIndent()
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
Now that we have virXMLParseWithIndent() and
|
||||
virXMLParseStringCtxtWithIndent(), we can use them directly and
|
||||
drop calls to xmlKeepBlanksDefault().
|
||||
|
||||
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
|
||||
Reviewed-by: Ján Tomko <jtomko@redhat.com>
|
||||
(cherry picked from commit 1fdca3083b52507d7a99f6e9b84e91d8df68013e)
|
||||
---
|
||||
src/conf/backup_conf.c | 8 +++-----
|
||||
src/conf/checkpoint_conf.c | 8 +++-----
|
||||
src/conf/domain_conf.c | 11 +++--------
|
||||
src/conf/network_conf.c | 6 ++----
|
||||
src/conf/snapshot_conf.c | 8 +++-----
|
||||
tools/virsh-util.c | 5 +----
|
||||
6 files changed, 15 insertions(+), 31 deletions(-)
|
||||
|
||||
diff --git a/src/conf/backup_conf.c b/src/conf/backup_conf.c
|
||||
index e151c29738..1fea6a2be7 100644
|
||||
--- a/src/conf/backup_conf.c
|
||||
+++ b/src/conf/backup_conf.c
|
||||
@@ -276,13 +276,11 @@ virDomainBackupDefParseString(const char *xmlStr,
|
||||
{
|
||||
g_autoptr(xmlDoc) xml = NULL;
|
||||
g_autoptr(xmlXPathContext) ctxt = NULL;
|
||||
- int keepBlanksDefault = xmlKeepBlanksDefault(0);
|
||||
bool validate = !(flags & VIR_DOMAIN_BACKUP_PARSE_INTERNAL);
|
||||
|
||||
- xml = virXMLParse(NULL, xmlStr, _("(domain_backup)"),
|
||||
- "domainbackup", &ctxt, "domainbackup.rng", validate);
|
||||
-
|
||||
- xmlKeepBlanksDefault(keepBlanksDefault);
|
||||
+ xml = virXMLParseWithIndent(NULL, xmlStr, _("(domain_backup)"),
|
||||
+ "domainbackup", &ctxt, "domainbackup.rng",
|
||||
+ validate);
|
||||
|
||||
if (!xml)
|
||||
return NULL;
|
||||
diff --git a/src/conf/checkpoint_conf.c b/src/conf/checkpoint_conf.c
|
||||
index 89f8675235..3c797f0f5b 100644
|
||||
--- a/src/conf/checkpoint_conf.c
|
||||
+++ b/src/conf/checkpoint_conf.c
|
||||
@@ -192,12 +192,10 @@ virDomainCheckpointDefParseString(const char *xmlStr,
|
||||
{
|
||||
g_autoptr(xmlDoc) xml = NULL;
|
||||
g_autoptr(xmlXPathContext) ctxt = NULL;
|
||||
- int keepBlanksDefault = xmlKeepBlanksDefault(0);
|
||||
|
||||
- xml = virXMLParse(NULL, xmlStr, _("(domain_checkpoint)"),
|
||||
- "domaincheckpoint", &ctxt, "domaincheckpoint.rng", true);
|
||||
-
|
||||
- xmlKeepBlanksDefault(keepBlanksDefault);
|
||||
+ xml = virXMLParseWithIndent(NULL, xmlStr, _("(domain_checkpoint)"),
|
||||
+ "domaincheckpoint", &ctxt,
|
||||
+ "domaincheckpoint.rng", true);
|
||||
|
||||
if (!xml)
|
||||
return NULL;
|
||||
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
|
||||
index 80f467ae7a..2b6f765b6d 100644
|
||||
--- a/src/conf/domain_conf.c
|
||||
+++ b/src/conf/domain_conf.c
|
||||
@@ -19503,13 +19503,10 @@ virDomainDefParse(const char *xmlStr,
|
||||
{
|
||||
g_autoptr(xmlDoc) xml = NULL;
|
||||
g_autoptr(xmlXPathContext) ctxt = NULL;
|
||||
- int keepBlanksDefault = xmlKeepBlanksDefault(0);
|
||||
bool validate = flags & VIR_DOMAIN_DEF_PARSE_VALIDATE_SCHEMA;
|
||||
|
||||
- xml = virXMLParse(filename, xmlStr, _("(domain_definition)"),
|
||||
- "domain", &ctxt, "domain.rng", validate);
|
||||
-
|
||||
- xmlKeepBlanksDefault(keepBlanksDefault);
|
||||
+ xml = virXMLParseWithIndent(filename, xmlStr, _("(domain_definition)"),
|
||||
+ "domain", &ctxt, "domain.rng", validate);
|
||||
|
||||
if (!xml)
|
||||
return NULL;
|
||||
@@ -19566,10 +19563,8 @@ virDomainObjParseFile(const char *filename,
|
||||
{
|
||||
g_autoptr(xmlDoc) xml = NULL;
|
||||
g_autoptr(xmlXPathContext) ctxt = NULL;
|
||||
- int keepBlanksDefault = xmlKeepBlanksDefault(0);
|
||||
|
||||
- xml = virXMLParse(filename, NULL, NULL, "domstatus", &ctxt, NULL, false);
|
||||
- xmlKeepBlanksDefault(keepBlanksDefault);
|
||||
+ xml = virXMLParseWithIndent(filename, NULL, NULL, "domstatus", &ctxt, NULL, false);
|
||||
|
||||
if (!xml)
|
||||
return NULL;
|
||||
diff --git a/src/conf/network_conf.c b/src/conf/network_conf.c
|
||||
index 1a6fd86180..0449b6f07c 100644
|
||||
--- a/src/conf/network_conf.c
|
||||
+++ b/src/conf/network_conf.c
|
||||
@@ -1962,11 +1962,9 @@ virNetworkDefParse(const char *xmlStr,
|
||||
{
|
||||
g_autoptr(xmlDoc) xml = NULL;
|
||||
g_autoptr(xmlXPathContext) ctxt = NULL;
|
||||
- int keepBlanksDefault = xmlKeepBlanksDefault(0);
|
||||
|
||||
- xml = virXMLParse(filename, xmlStr, _("(network_definition)"),
|
||||
- "network", &ctxt, "network.rng", validate);
|
||||
- xmlKeepBlanksDefault(keepBlanksDefault);
|
||||
+ xml = virXMLParseWithIndent(filename, xmlStr, _("(network_definition)"),
|
||||
+ "network", &ctxt, "network.rng", validate);
|
||||
|
||||
if (!xml)
|
||||
return NULL;
|
||||
diff --git a/src/conf/snapshot_conf.c b/src/conf/snapshot_conf.c
|
||||
index 4b0555eb8c..d7fcded302 100644
|
||||
--- a/src/conf/snapshot_conf.c
|
||||
+++ b/src/conf/snapshot_conf.c
|
||||
@@ -426,13 +426,11 @@ virDomainSnapshotDefParseString(const char *xmlStr,
|
||||
{
|
||||
g_autoptr(xmlXPathContext) ctxt = NULL;
|
||||
g_autoptr(xmlDoc) xml = NULL;
|
||||
- int keepBlanksDefault = xmlKeepBlanksDefault(0);
|
||||
bool validate = flags & VIR_DOMAIN_SNAPSHOT_PARSE_VALIDATE;
|
||||
|
||||
- xml = virXMLParse(NULL, xmlStr, _("(domain_snapshot)"),
|
||||
- "domainsnapshot", &ctxt, "domainsnapshot.rng", validate);
|
||||
-
|
||||
- xmlKeepBlanksDefault(keepBlanksDefault);
|
||||
+ xml = virXMLParseWithIndent(NULL, xmlStr, _("(domain_snapshot)"),
|
||||
+ "domainsnapshot", &ctxt, "domainsnapshot.rng",
|
||||
+ validate);
|
||||
|
||||
if (!xml)
|
||||
return NULL;
|
||||
diff --git a/tools/virsh-util.c b/tools/virsh-util.c
|
||||
index fb6327613a..a6026eed53 100644
|
||||
--- a/tools/virsh-util.c
|
||||
+++ b/tools/virsh-util.c
|
||||
@@ -474,16 +474,13 @@ virshDumpXML(vshControl *ctl,
|
||||
g_autofree xmlNodePtr *nodes = NULL;
|
||||
int nnodes = 0;
|
||||
size_t i;
|
||||
- int oldblanks;
|
||||
|
||||
if (xpath == NULL) {
|
||||
vshPrint(ctl, "%s", xml);
|
||||
return true;
|
||||
}
|
||||
|
||||
- oldblanks = xmlKeepBlanksDefault(0);
|
||||
- doc = virXMLParseStringCtxt(xml, url, &ctxt);
|
||||
- xmlKeepBlanksDefault(oldblanks);
|
||||
+ doc = virXMLParseStringCtxtWithIndent(xml, url, &ctxt);
|
||||
if (!doc)
|
||||
return false;
|
||||
|
||||
--
|
||||
2.43.0
|
||||
|
@ -1,976 +0,0 @@
|
||||
From e1973fb24917234e552a711de16e2fc19f477b63 Mon Sep 17 00:00:00 2001
|
||||
From: Michal Privoznik <mprivozn@redhat.com>
|
||||
Date: Wed, 22 Nov 2023 14:58:49 +0100
|
||||
Subject: [PATCH 8/8] 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>
|
||||
(cherry picked from commit cfcbba4c2b8a2062dec36072a34209229b6c3277)
|
||||
---
|
||||
build-aux/Makefile.nonreentrant | 1 -
|
||||
build-aux/syntax-check.mk | 2 +-
|
||||
src/conf/capabilities.c | 8 ++++---
|
||||
src/conf/domain_conf.c | 6 +++--
|
||||
src/cpu/cpu.c | 7 +++---
|
||||
src/cpu/cpu_x86.c | 15 +++++++-----
|
||||
src/lxc/lxc_container.c | 3 ++-
|
||||
src/nwfilter/nwfilter_ebiptables_driver.c | 29 +++++++++++++++--------
|
||||
src/qemu/qemu_monitor_json.c | 6 +++--
|
||||
src/qemu/qemu_process.c | 7 +++---
|
||||
src/security/security_manager.c | 9 ++++---
|
||||
src/util/virfile.c | 8 ++++---
|
||||
src/util/virhash.c | 9 ++++---
|
||||
src/util/virresctrl.c | 9 ++++---
|
||||
src/util/virstring.c | 12 ++++++----
|
||||
src/util/virstring.h | 8 +++++--
|
||||
src/util/virtypedparam.c | 9 ++++---
|
||||
tests/commandhelper.c | 6 +++--
|
||||
tests/virstringtest.c | 8 +++----
|
||||
tools/virsh-checkpoint.c | 10 ++++----
|
||||
tools/virsh-domain-monitor.c | 11 +++++----
|
||||
tools/virsh-host.c | 7 ++++--
|
||||
tools/virsh-interface.c | 11 +++++----
|
||||
tools/virsh-network.c | 29 +++++++++++++++--------
|
||||
tools/virsh-nodedev.c | 11 +++++----
|
||||
tools/virsh-nwfilter.c | 22 ++++++++++-------
|
||||
tools/virsh-pool.c | 11 +++++----
|
||||
tools/virsh-secret.c | 11 +++++----
|
||||
tools/virsh-snapshot.c | 10 ++++----
|
||||
tools/virsh-volume.c | 10 +++++---
|
||||
30 files changed, 195 insertions(+), 110 deletions(-)
|
||||
|
||||
diff --git a/build-aux/Makefile.nonreentrant b/build-aux/Makefile.nonreentrant
|
||||
index 87bb9db20e..b869c645ce 100644
|
||||
--- a/build-aux/Makefile.nonreentrant
|
||||
+++ b/build-aux/Makefile.nonreentrant
|
||||
@@ -21,7 +21,6 @@
|
||||
# | grep '_r$' \
|
||||
# | awk '{print $3}' \
|
||||
# | grep -v __ \
|
||||
-# | grep -v qsort \ # Red herring since we don't need to pass extra args to qsort comparator
|
||||
# | grep -v readdir \ # This is safe as long as each DIR * instance is only used by one thread
|
||||
# | sort \
|
||||
# | uniq \
|
||||
diff --git a/build-aux/syntax-check.mk b/build-aux/syntax-check.mk
|
||||
index 7af7d20d70..ad2ecd50c7 100644
|
||||
--- a/build-aux/syntax-check.mk
|
||||
+++ b/build-aux/syntax-check.mk
|
||||
@@ -380,7 +380,7 @@ sc_prohibit_unsigned_pid:
|
||||
# Many of the function names below came from this filter:
|
||||
# git grep -B2 '\<_('|grep -E '\.c- *[[:alpha:]_][[:alnum:]_]* ?\(.*[,;]$' \
|
||||
# |sed 's/.*\.c- *//'|perl -pe 's/ ?\(.*//'|sort -u \
|
||||
-# |grep -vE '^(qsort|if|close|assert|fputc|free|N_|vir.*GetName|.*Unlock|virNodeListDevices|virHashRemoveEntry|freeaddrinfo|.*[fF]ree|xdrmem_create|xmlXPathFreeObject|virUUIDFormat|openvzSetProgramSentinal|polkit_action_unref)$'
|
||||
+# |grep -vE '^(if|close|assert|fputc|free|N_|vir.*GetName|.*Unlock|virNodeListDevices|virHashRemoveEntry|freeaddrinfo|.*[fF]ree|xdrmem_create|xmlXPathFreeObject|virUUIDFormat|openvzSetProgramSentinal|polkit_action_unref)$'
|
||||
|
||||
msg_gen_function =
|
||||
msg_gen_function += VIR_ERROR
|
||||
diff --git a/src/conf/capabilities.c b/src/conf/capabilities.c
|
||||
index 34f04cb7d3..32badee7b3 100644
|
||||
--- a/src/conf/capabilities.c
|
||||
+++ b/src/conf/capabilities.c
|
||||
@@ -2073,7 +2073,8 @@ virCapsHostCacheBankFree(virCapsHostCacheBank *ptr)
|
||||
|
||||
static int
|
||||
virCapsHostCacheBankSorter(const void *a,
|
||||
- const void *b)
|
||||
+ const void *b,
|
||||
+ void *opaque G_GNUC_UNUSED)
|
||||
{
|
||||
virCapsHostCacheBank *ca = *(virCapsHostCacheBank **)a;
|
||||
virCapsHostCacheBank *cb = *(virCapsHostCacheBank **)b;
|
||||
@@ -2273,8 +2274,9 @@ virCapabilitiesInitCaches(virCaps *caps)
|
||||
* still traverse the directory instead of guessing names (in case there is
|
||||
* 'index1' and 'index3' but no 'index2'). */
|
||||
if (caps->host.cache.banks) {
|
||||
- qsort(caps->host.cache.banks, caps->host.cache.nbanks,
|
||||
- sizeof(*caps->host.cache.banks), virCapsHostCacheBankSorter);
|
||||
+ g_qsort_with_data(caps->host.cache.banks, caps->host.cache.nbanks,
|
||||
+ sizeof(*caps->host.cache.banks),
|
||||
+ virCapsHostCacheBankSorter, NULL);
|
||||
}
|
||||
|
||||
if (virCapabilitiesInitResctrlMemory(caps) < 0)
|
||||
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
|
||||
index 2b6f765b6d..aede47a130 100644
|
||||
--- a/src/conf/domain_conf.c
|
||||
+++ b/src/conf/domain_conf.c
|
||||
@@ -15703,7 +15703,9 @@ virDomainDefParseBootXML(xmlXPathContextPtr ctxt,
|
||||
}
|
||||
|
||||
|
||||
-static int virDomainIdMapEntrySort(const void *a, const void *b)
|
||||
+static int virDomainIdMapEntrySort(const void *a,
|
||||
+ const void *b,
|
||||
+ void *opaque G_GNUC_UNUSED)
|
||||
{
|
||||
const virDomainIdMapEntry *entrya = a;
|
||||
const virDomainIdMapEntry *entryb = b;
|
||||
@@ -15746,7 +15748,7 @@ virDomainIdmapDefParseXML(xmlXPathContextPtr ctxt,
|
||||
}
|
||||
}
|
||||
|
||||
- qsort(idmap, num, sizeof(idmap[0]), virDomainIdMapEntrySort);
|
||||
+ g_qsort_with_data(idmap, num, sizeof(idmap[0]), virDomainIdMapEntrySort, NULL);
|
||||
|
||||
return idmap;
|
||||
}
|
||||
diff --git a/src/cpu/cpu.c b/src/cpu/cpu.c
|
||||
index bb5737e938..bc43aa4e93 100644
|
||||
--- a/src/cpu/cpu.c
|
||||
+++ b/src/cpu/cpu.c
|
||||
@@ -1045,7 +1045,8 @@ virCPUConvertLegacy(virArch arch,
|
||||
|
||||
static int
|
||||
virCPUFeatureCompare(const void *p1,
|
||||
- const void *p2)
|
||||
+ const void *p2,
|
||||
+ void *opaque G_GNUC_UNUSED)
|
||||
{
|
||||
const virCPUFeatureDef *f1 = p1;
|
||||
const virCPUFeatureDef *f2 = p2;
|
||||
@@ -1085,8 +1086,8 @@ virCPUExpandFeatures(virArch arch,
|
||||
driver->expandFeatures(cpu) < 0)
|
||||
return -1;
|
||||
|
||||
- qsort(cpu->features, cpu->nfeatures, sizeof(*cpu->features),
|
||||
- virCPUFeatureCompare);
|
||||
+ g_qsort_with_data(cpu->features, cpu->nfeatures, sizeof(*cpu->features),
|
||||
+ virCPUFeatureCompare, NULL);
|
||||
|
||||
VIR_DEBUG("nfeatures=%zu", cpu->nfeatures);
|
||||
return 0;
|
||||
diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c
|
||||
index 7a7f3b409d..8d0e3947ce 100644
|
||||
--- a/src/cpu/cpu_x86.c
|
||||
+++ b/src/cpu/cpu_x86.c
|
||||
@@ -393,7 +393,9 @@ x86FeatureFindInternal(const char *name)
|
||||
|
||||
|
||||
static int
|
||||
-virCPUx86DataSorter(const void *a, const void *b)
|
||||
+virCPUx86DataSorter(const void *a,
|
||||
+ const void *b,
|
||||
+ void *opaque G_GNUC_UNUSED)
|
||||
{
|
||||
virCPUx86DataItem *da = (virCPUx86DataItem *) a;
|
||||
virCPUx86DataItem *db = (virCPUx86DataItem *) b;
|
||||
@@ -437,7 +439,7 @@ static int
|
||||
virCPUx86DataItemCmp(const virCPUx86DataItem *item1,
|
||||
const virCPUx86DataItem *item2)
|
||||
{
|
||||
- return virCPUx86DataSorter(item1, item2);
|
||||
+ return virCPUx86DataSorter(item1, item2, NULL);
|
||||
}
|
||||
|
||||
|
||||
@@ -541,8 +543,9 @@ virCPUx86DataAddItem(virCPUx86Data *data,
|
||||
VIR_APPEND_ELEMENT_COPY(data->items, data->len,
|
||||
*((virCPUx86DataItem *)item));
|
||||
|
||||
- qsort(data->items, data->len,
|
||||
- sizeof(virCPUx86DataItem), virCPUx86DataSorter);
|
||||
+ g_qsort_with_data(data->items, data->len,
|
||||
+ sizeof(virCPUx86DataItem),
|
||||
+ virCPUx86DataSorter, NULL);
|
||||
}
|
||||
|
||||
return 0;
|
||||
@@ -3465,8 +3468,8 @@ virCPUx86DataGetHost(void)
|
||||
}
|
||||
|
||||
/* the rest of the code expects the function to be in order */
|
||||
- qsort(cpuid->data.x86.items, cpuid->data.x86.len,
|
||||
- sizeof(virCPUx86DataItem), virCPUx86DataSorter);
|
||||
+ g_qsort_with_data(cpuid->data.x86.items, cpuid->data.x86.len,
|
||||
+ sizeof(virCPUx86DataItem), virCPUx86DataSorter, NULL);
|
||||
|
||||
return cpuid;
|
||||
}
|
||||
diff --git a/src/lxc/lxc_container.c b/src/lxc/lxc_container.c
|
||||
index 35a882171b..652697890f 100644
|
||||
--- a/src/lxc/lxc_container.c
|
||||
+++ b/src/lxc/lxc_container.c
|
||||
@@ -791,7 +791,8 @@ static int lxcContainerSetReadOnly(void)
|
||||
if (!mounts)
|
||||
return 0;
|
||||
|
||||
- qsort(mounts, nmounts, sizeof(mounts[0]), virStringSortRevCompare);
|
||||
+ g_qsort_with_data(mounts, nmounts,
|
||||
+ sizeof(mounts[0]), virStringSortRevCompare, NULL);
|
||||
|
||||
/* turn 'mounts' into a proper GStrv */
|
||||
VIR_EXPAND_N(mounts, nmounts, 1);
|
||||
diff --git a/src/nwfilter/nwfilter_ebiptables_driver.c b/src/nwfilter/nwfilter_ebiptables_driver.c
|
||||
index 1c5da2ae05..56bddb9097 100644
|
||||
--- a/src/nwfilter/nwfilter_ebiptables_driver.c
|
||||
+++ b/src/nwfilter/nwfilter_ebiptables_driver.c
|
||||
@@ -3087,7 +3087,9 @@ virNWFilterRuleInstSort(const void *a, const void *b)
|
||||
|
||||
|
||||
static int
|
||||
-virNWFilterRuleInstSortPtr(const void *a, const void *b)
|
||||
+virNWFilterRuleInstSortPtr(const void *a,
|
||||
+ const void *b,
|
||||
+ void *opaque G_GNUC_UNUSED)
|
||||
{
|
||||
virNWFilterRuleInst * const *insta = a;
|
||||
virNWFilterRuleInst * const *instb = b;
|
||||
@@ -3097,7 +3099,8 @@ virNWFilterRuleInstSortPtr(const void *a, const void *b)
|
||||
|
||||
static int
|
||||
ebiptablesFilterOrderSort(const void *va,
|
||||
- const void *vb)
|
||||
+ const void *vb,
|
||||
+ void *opaque G_GNUC_UNUSED)
|
||||
{
|
||||
const virHashKeyValuePair *a = va;
|
||||
const virHashKeyValuePair *b = vb;
|
||||
@@ -3244,7 +3247,9 @@ struct _ebtablesSubChainInst {
|
||||
|
||||
|
||||
static int
|
||||
-ebtablesSubChainInstSort(const void *a, const void *b)
|
||||
+ebtablesSubChainInstSort(const void *a,
|
||||
+ const void *b,
|
||||
+ void *opaque G_GNUC_UNUSED)
|
||||
{
|
||||
const ebtablesSubChainInst **insta = (const ebtablesSubChainInst **)a;
|
||||
const ebtablesSubChainInst **instb = (const ebtablesSubChainInst **)b;
|
||||
@@ -3268,7 +3273,8 @@ ebtablesGetSubChainInsts(GHashTable *chains,
|
||||
if (filter_names == NULL)
|
||||
return -1;
|
||||
|
||||
- qsort(filter_names, nfilter_names, sizeof(*filter_names), ebiptablesFilterOrderSort);
|
||||
+ g_qsort_with_data(filter_names, nfilter_names,
|
||||
+ sizeof(*filter_names), ebiptablesFilterOrderSort, NULL);
|
||||
|
||||
for (i = 0; filter_names[i].key; i++) {
|
||||
g_autofree ebtablesSubChainInst *inst = NULL;
|
||||
@@ -3306,9 +3312,10 @@ ebiptablesApplyNewRules(const char *ifname,
|
||||
size_t nsubchains = 0;
|
||||
int ret = -1;
|
||||
|
||||
- if (nrules)
|
||||
- qsort(rules, nrules, sizeof(rules[0]),
|
||||
- virNWFilterRuleInstSortPtr);
|
||||
+ if (nrules) {
|
||||
+ g_qsort_with_data(rules, nrules, sizeof(rules[0]),
|
||||
+ virNWFilterRuleInstSortPtr, NULL);
|
||||
+ }
|
||||
|
||||
/* cleanup whatever may exist */
|
||||
virFirewallStartTransaction(fw, VIR_FIREWALL_TRANSACTION_IGNORE_ERRORS);
|
||||
@@ -3388,9 +3395,11 @@ ebiptablesApplyNewRules(const char *ifname,
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
- if (nsubchains > 0)
|
||||
- qsort(subchains, nsubchains, sizeof(subchains[0]),
|
||||
- ebtablesSubChainInstSort);
|
||||
+ if (nsubchains > 0) {
|
||||
+ g_qsort_with_data(subchains, nsubchains,
|
||||
+ sizeof(subchains[0]),
|
||||
+ ebtablesSubChainInstSort, NULL);
|
||||
+ }
|
||||
|
||||
for (i = 0, j = 0; i < nrules; i++) {
|
||||
if (virNWFilterRuleIsProtocolEthernet(rules[i]->def)) {
|
||||
diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
|
||||
index 105d729d7c..6f1dffe8f7 100644
|
||||
--- a/src/qemu/qemu_monitor_json.c
|
||||
+++ b/src/qemu/qemu_monitor_json.c
|
||||
@@ -7607,7 +7607,8 @@ qemuMonitorJSONProcessHotpluggableCpusReply(virJSONValue *vcpu,
|
||||
|
||||
static int
|
||||
qemuMonitorQueryHotpluggableCpusEntrySort(const void *p1,
|
||||
- const void *p2)
|
||||
+ const void *p2,
|
||||
+ void *opaque G_GNUC_UNUSED)
|
||||
{
|
||||
const struct qemuMonitorQueryHotpluggableCpusEntry *a = p1;
|
||||
const struct qemuMonitorQueryHotpluggableCpusEntry *b = p2;
|
||||
@@ -7659,7 +7660,8 @@ qemuMonitorJSONGetHotpluggableCPUs(qemuMonitor *mon,
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
- qsort(info, ninfo, sizeof(*info), qemuMonitorQueryHotpluggableCpusEntrySort);
|
||||
+ g_qsort_with_data(info, ninfo, sizeof(*info),
|
||||
+ qemuMonitorQueryHotpluggableCpusEntrySort, NULL);
|
||||
|
||||
*entries = g_steal_pointer(&info);
|
||||
*nentries = ninfo;
|
||||
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
|
||||
index b9267d8699..f32e82bbd1 100644
|
||||
--- a/src/qemu/qemu_process.c
|
||||
+++ b/src/qemu/qemu_process.c
|
||||
@@ -6093,7 +6093,8 @@ qemuDomainHasHotpluggableStartupVcpus(virDomainDef *def)
|
||||
|
||||
static int
|
||||
qemuProcessVcpusSortOrder(const void *a,
|
||||
- const void *b)
|
||||
+ const void *b,
|
||||
+ void *opaque G_GNUC_UNUSED)
|
||||
{
|
||||
virDomainVcpuDef *vcpua = *((virDomainVcpuDef **)a);
|
||||
virDomainVcpuDef *vcpub = *((virDomainVcpuDef **)b);
|
||||
@@ -6133,8 +6134,8 @@ qemuProcessSetupHotpluggableVcpus(virDomainObj *vm,
|
||||
if (nbootHotplug == 0)
|
||||
return 0;
|
||||
|
||||
- qsort(bootHotplug, nbootHotplug, sizeof(*bootHotplug),
|
||||
- qemuProcessVcpusSortOrder);
|
||||
+ g_qsort_with_data(bootHotplug, nbootHotplug,
|
||||
+ sizeof(*bootHotplug), qemuProcessVcpusSortOrder, NULL);
|
||||
|
||||
if (virDomainCgroupEmulatorAllNodesAllow(priv->cgroup, &emulatorCgroup) < 0)
|
||||
goto cleanup;
|
||||
diff --git a/src/security/security_manager.c b/src/security/security_manager.c
|
||||
index 5df0cd3419..afd41f1c20 100644
|
||||
--- a/src/security/security_manager.c
|
||||
+++ b/src/security/security_manager.c
|
||||
@@ -1247,7 +1247,9 @@ virSecurityManagerRestoreNetdevLabel(virSecurityManager *mgr,
|
||||
|
||||
|
||||
static int
|
||||
-cmpstringp(const void *p1, const void *p2)
|
||||
+cmpstringp(const void *p1,
|
||||
+ const void *p2,
|
||||
+ void *opaque G_GNUC_UNUSED)
|
||||
{
|
||||
const char *s1 = *(char * const *) p1;
|
||||
const char *s2 = *(char * const *) p2;
|
||||
@@ -1303,8 +1305,9 @@ virSecurityManagerMetadataLock(virSecurityManager *mgr G_GNUC_UNUSED,
|
||||
* paths in the same order and thus no deadlock can occur.
|
||||
* Lastly, it makes searching for duplicate paths below
|
||||
* simpler. */
|
||||
- if (paths)
|
||||
- qsort(paths, npaths, sizeof(*paths), cmpstringp);
|
||||
+ if (paths) {
|
||||
+ g_qsort_with_data(paths, npaths, sizeof(*paths), cmpstringp, NULL);
|
||||
+ }
|
||||
|
||||
for (i = 0; i < npaths; i++) {
|
||||
const char *p = paths[i];
|
||||
diff --git a/src/util/virfile.c b/src/util/virfile.c
|
||||
index 54708652fb..007b6cf512 100644
|
||||
--- a/src/util/virfile.c
|
||||
+++ b/src/util/virfile.c
|
||||
@@ -2193,9 +2193,11 @@ virFileGetMountSubtreeImpl(const char *mtabpath,
|
||||
mounts[nmounts - 2] = g_strdup(mntent.mnt_dir);
|
||||
}
|
||||
|
||||
- if (mounts)
|
||||
- qsort(mounts, nmounts - 1, sizeof(mounts[0]),
|
||||
- reverse ? virStringSortRevCompare : virStringSortCompare);
|
||||
+ if (mounts) {
|
||||
+ g_qsort_with_data(mounts, nmounts - 1, sizeof(mounts[0]),
|
||||
+ reverse ? virStringSortRevCompare : virStringSortCompare,
|
||||
+ NULL);
|
||||
+ }
|
||||
|
||||
*mountsret = mounts;
|
||||
*nmountsret = nmounts ? nmounts - 1 : 0;
|
||||
diff --git a/src/util/virhash.c b/src/util/virhash.c
|
||||
index 8365f51eb3..19908c9412 100644
|
||||
--- a/src/util/virhash.c
|
||||
+++ b/src/util/virhash.c
|
||||
@@ -514,7 +514,8 @@ void *virHashSearch(GHashTable *table,
|
||||
|
||||
static int
|
||||
virHashGetItemsKeySorter(const void *va,
|
||||
- const void *vb)
|
||||
+ const void *vb,
|
||||
+ void *opaque G_GNUC_UNUSED)
|
||||
{
|
||||
const virHashKeyValuePair *a = va;
|
||||
const virHashKeyValuePair *b = vb;
|
||||
@@ -552,8 +553,10 @@ virHashGetItems(GHashTable *table,
|
||||
i++;
|
||||
}
|
||||
|
||||
- if (sortKeys)
|
||||
- qsort(items, *nitems, sizeof(*items), virHashGetItemsKeySorter);
|
||||
+ if (sortKeys) {
|
||||
+ g_qsort_with_data(items, *nitems,
|
||||
+ sizeof(*items), virHashGetItemsKeySorter, NULL);
|
||||
+ }
|
||||
|
||||
return items;
|
||||
}
|
||||
diff --git a/src/util/virresctrl.c b/src/util/virresctrl.c
|
||||
index 8ca58f5d10..30ae25c487 100644
|
||||
--- a/src/util/virresctrl.c
|
||||
+++ b/src/util/virresctrl.c
|
||||
@@ -2522,7 +2522,8 @@ virResctrlMonitorRemove(virResctrlMonitor *monitor)
|
||||
|
||||
static int
|
||||
virResctrlMonitorStatsSorter(const void *a,
|
||||
- const void *b)
|
||||
+ const void *b,
|
||||
+ void *opaque G_GNUC_UNUSED)
|
||||
{
|
||||
return (*(virResctrlMonitorStats **)a)->id
|
||||
- (*(virResctrlMonitorStats **)b)->id;
|
||||
@@ -2625,8 +2626,10 @@ virResctrlMonitorGetStats(virResctrlMonitor *monitor,
|
||||
}
|
||||
|
||||
/* Sort in id's ascending order */
|
||||
- if (*nstats)
|
||||
- qsort(*stats, *nstats, sizeof(**stats), virResctrlMonitorStatsSorter);
|
||||
+ if (*nstats) {
|
||||
+ g_qsort_with_data(*stats, *nstats, sizeof(**stats),
|
||||
+ virResctrlMonitorStatsSorter, NULL);
|
||||
+ }
|
||||
|
||||
ret = 0;
|
||||
cleanup:
|
||||
diff --git a/src/util/virstring.c b/src/util/virstring.c
|
||||
index 6b728ff047..81c9aff304 100644
|
||||
--- a/src/util/virstring.c
|
||||
+++ b/src/util/virstring.c
|
||||
@@ -518,9 +518,11 @@ virStringIsEmpty(const char *str)
|
||||
* virStringSortCompare:
|
||||
*
|
||||
* A comparator function for sorting strings in
|
||||
- * normal order with qsort().
|
||||
+ * normal order with g_qsort_with_data().
|
||||
*/
|
||||
-int virStringSortCompare(const void *a, const void *b)
|
||||
+int virStringSortCompare(const void *a,
|
||||
+ const void *b,
|
||||
+ void *opaque G_GNUC_UNUSED)
|
||||
{
|
||||
const char **sa = (const char**)a;
|
||||
const char **sb = (const char**)b;
|
||||
@@ -532,9 +534,11 @@ int virStringSortCompare(const void *a, const void *b)
|
||||
* virStringSortRevCompare:
|
||||
*
|
||||
* A comparator function for sorting strings in
|
||||
- * reverse order with qsort().
|
||||
+ * reverse order with g_qsort_with_data().
|
||||
*/
|
||||
-int virStringSortRevCompare(const void *a, const void *b)
|
||||
+int virStringSortRevCompare(const void *a,
|
||||
+ const void *b,
|
||||
+ void *opaque G_GNUC_UNUSED)
|
||||
{
|
||||
const char **sa = (const char**)a;
|
||||
const char **sb = (const char**)b;
|
||||
diff --git a/src/util/virstring.h b/src/util/virstring.h
|
||||
index 16dcce98f4..8f9b1edc8f 100644
|
||||
--- a/src/util/virstring.h
|
||||
+++ b/src/util/virstring.h
|
||||
@@ -83,8 +83,12 @@ bool virStringIsEmpty(const char *str);
|
||||
int virStrcpy(char *dest, const char *src, size_t destbytes);
|
||||
#define virStrcpyStatic(dest, src) virStrcpy((dest), (src), sizeof(dest))
|
||||
|
||||
-int virStringSortCompare(const void *a, const void *b);
|
||||
-int virStringSortRevCompare(const void *a, const void *b);
|
||||
+int virStringSortCompare(const void *a,
|
||||
+ const void *b,
|
||||
+ void *opaque);
|
||||
+int virStringSortRevCompare(const void *a,
|
||||
+ const void *b,
|
||||
+ void *opaque);
|
||||
int virStringToUpper(char **dst, const char *src);
|
||||
|
||||
ssize_t virStringSearch(const char *str,
|
||||
diff --git a/src/util/virtypedparam.c b/src/util/virtypedparam.c
|
||||
index ef3b8052f6..1be249d855 100644
|
||||
--- a/src/util/virtypedparam.c
|
||||
+++ b/src/util/virtypedparam.c
|
||||
@@ -43,7 +43,9 @@ VIR_ENUM_IMPL(virTypedParameter,
|
||||
);
|
||||
|
||||
static int
|
||||
-virTypedParamsSortName(const void *left, const void *right)
|
||||
+virTypedParamsSortName(const void *left,
|
||||
+ const void *right,
|
||||
+ void *opaque G_GNUC_UNUSED)
|
||||
{
|
||||
const virTypedParameter *param_left = left, *param_right = right;
|
||||
return strcmp(param_left->field, param_right->field);
|
||||
@@ -78,7 +80,8 @@ virTypedParamsValidate(virTypedParameterPtr params, int nparams, ...)
|
||||
|
||||
/* Here we intentionally don't copy values */
|
||||
memcpy(sorted, params, sizeof(*params) * nparams);
|
||||
- qsort(sorted, nparams, sizeof(*sorted), virTypedParamsSortName);
|
||||
+ g_qsort_with_data(sorted, nparams,
|
||||
+ sizeof(*sorted), virTypedParamsSortName, NULL);
|
||||
|
||||
name = va_arg(ap, const char *);
|
||||
while (name) {
|
||||
@@ -102,7 +105,7 @@ virTypedParamsValidate(virTypedParameterPtr params, int nparams, ...)
|
||||
|
||||
va_end(ap);
|
||||
|
||||
- qsort(keys, nkeys, sizeof(*keys), virTypedParamsSortName);
|
||||
+ g_qsort_with_data(keys, nkeys, sizeof(*keys), virTypedParamsSortName, NULL);
|
||||
|
||||
for (i = 0, j = 0; i < nparams && j < nkeys;) {
|
||||
if (STRNEQ(sorted[i].field, keys[j].field)) {
|
||||
diff --git a/tests/commandhelper.c b/tests/commandhelper.c
|
||||
index 9b56feb120..9f28aa7674 100644
|
||||
--- a/tests/commandhelper.c
|
||||
+++ b/tests/commandhelper.c
|
||||
@@ -129,7 +129,9 @@ static void printArguments(FILE *log, int argc, char** argv)
|
||||
}
|
||||
}
|
||||
|
||||
-static int envsort(const void *a, const void *b)
|
||||
+static int envsort(const void *a,
|
||||
+ const void *b,
|
||||
+ void *opaque G_GNUC_UNUSED)
|
||||
{
|
||||
const char *astr = *(const char**)a;
|
||||
const char *bstr = *(const char**)b;
|
||||
@@ -165,7 +167,7 @@ static int printEnvironment(FILE *log)
|
||||
newenv[i] = environ[i];
|
||||
}
|
||||
|
||||
- qsort(newenv, length, sizeof(newenv[0]), envsort);
|
||||
+ g_qsort_with_data(newenv, length, sizeof(newenv[0]), envsort, NULL);
|
||||
|
||||
for (i = 0; i < length; i++) {
|
||||
/* Ignore the variables used to instruct the loader into
|
||||
diff --git a/tests/virstringtest.c b/tests/virstringtest.c
|
||||
index 6e697cc240..f4976890db 100644
|
||||
--- a/tests/virstringtest.c
|
||||
+++ b/tests/virstringtest.c
|
||||
@@ -89,10 +89,10 @@ testStringSortCompare(const void *opaque G_GNUC_UNUSED)
|
||||
};
|
||||
size_t i;
|
||||
|
||||
- qsort(randlist, G_N_ELEMENTS(randlist), sizeof(randlist[0]),
|
||||
- virStringSortCompare);
|
||||
- qsort(randrlist, G_N_ELEMENTS(randrlist), sizeof(randrlist[0]),
|
||||
- virStringSortRevCompare);
|
||||
+ g_qsort_with_data(randlist, G_N_ELEMENTS(randlist),
|
||||
+ sizeof(randlist[0]), virStringSortCompare, NULL);
|
||||
+ g_qsort_with_data(randrlist, G_N_ELEMENTS(randrlist),
|
||||
+ sizeof(randrlist[0]), virStringSortRevCompare, NULL);
|
||||
|
||||
for (i = 0; i < G_N_ELEMENTS(randlist); i++) {
|
||||
if (STRNEQ(randlist[i], sortlist[i])) {
|
||||
diff --git a/tools/virsh-checkpoint.c b/tools/virsh-checkpoint.c
|
||||
index 727de34abb..34bae34f9a 100644
|
||||
--- a/tools/virsh-checkpoint.c
|
||||
+++ b/tools/virsh-checkpoint.c
|
||||
@@ -526,7 +526,8 @@ virshCheckpointListFree(struct virshCheckpointList *checkpointlist)
|
||||
|
||||
static int
|
||||
virshChkSorter(const void *a,
|
||||
- const void *b)
|
||||
+ const void *b,
|
||||
+ void *opaque G_GNUC_UNUSED)
|
||||
{
|
||||
const struct virshChk *sa = a;
|
||||
const struct virshChk *sb = b;
|
||||
@@ -594,9 +595,10 @@ virshCheckpointListCollect(vshControl *ctl,
|
||||
}
|
||||
|
||||
if (!(orig_flags & VIR_DOMAIN_CHECKPOINT_LIST_TOPOLOGICAL) &&
|
||||
- checkpointlist->chks)
|
||||
- qsort(checkpointlist->chks, checkpointlist->nchks,
|
||||
- sizeof(*checkpointlist->chks), virshChkSorter);
|
||||
+ checkpointlist->chks) {
|
||||
+ g_qsort_with_data(checkpointlist->chks, checkpointlist->nchks,
|
||||
+ sizeof(*checkpointlist->chks), virshChkSorter, NULL);
|
||||
+ }
|
||||
|
||||
ret = g_steal_pointer(&checkpointlist);
|
||||
|
||||
diff --git a/tools/virsh-domain-monitor.c b/tools/virsh-domain-monitor.c
|
||||
index 89fdc7a050..a2c56fc090 100644
|
||||
--- a/tools/virsh-domain-monitor.c
|
||||
+++ b/tools/virsh-domain-monitor.c
|
||||
@@ -1483,7 +1483,9 @@ static const vshCmdInfo info_list[] = {
|
||||
|
||||
/* compare domains, pack NULLed ones at the end */
|
||||
static int
|
||||
-virshDomainSorter(const void *a, const void *b)
|
||||
+virshDomainSorter(const void *a,
|
||||
+ const void *b,
|
||||
+ void *opaque G_GNUC_UNUSED)
|
||||
{
|
||||
virDomainPtr *da = (virDomainPtr *) a;
|
||||
virDomainPtr *db = (virDomainPtr *) b;
|
||||
@@ -1741,9 +1743,10 @@ virshDomainListCollect(vshControl *ctl, unsigned int flags)
|
||||
|
||||
finished:
|
||||
/* sort the list */
|
||||
- if (list->domains && list->ndomains)
|
||||
- qsort(list->domains, list->ndomains, sizeof(*list->domains),
|
||||
- virshDomainSorter);
|
||||
+ if (list->domains && list->ndomains) {
|
||||
+ g_qsort_with_data(list->domains, list->ndomains,
|
||||
+ sizeof(*list->domains), virshDomainSorter, NULL);
|
||||
+ }
|
||||
|
||||
/* truncate the list if filter simulation deleted entries */
|
||||
if (deleted)
|
||||
diff --git a/tools/virsh-host.c b/tools/virsh-host.c
|
||||
index 4116481978..6c14be865f 100644
|
||||
--- a/tools/virsh-host.c
|
||||
+++ b/tools/virsh-host.c
|
||||
@@ -300,7 +300,9 @@ static const vshCmdOptDef opts_freepages[] = {
|
||||
};
|
||||
|
||||
static int
|
||||
-vshPageSizeSorter(const void *a, const void *b)
|
||||
+vshPageSizeSorter(const void *a,
|
||||
+ const void *b,
|
||||
+ void *opaque G_GNUC_UNUSED)
|
||||
{
|
||||
unsigned int pa = *(unsigned int *)a;
|
||||
unsigned int pb = *(unsigned int *)b;
|
||||
@@ -377,7 +379,8 @@ cmdFreepages(vshControl *ctl, const vshCmd *cmd)
|
||||
* @pagesize array will contain duplicates. We should
|
||||
* remove them otherwise not very nice output will be
|
||||
* produced. */
|
||||
- qsort(pagesize, nodes_cnt, sizeof(*pagesize), vshPageSizeSorter);
|
||||
+ g_qsort_with_data(pagesize, nodes_cnt,
|
||||
+ sizeof(*pagesize), vshPageSizeSorter, NULL);
|
||||
|
||||
for (i = 0; i < nodes_cnt - 1;) {
|
||||
if (pagesize[i] == pagesize[i + 1]) {
|
||||
diff --git a/tools/virsh-interface.c b/tools/virsh-interface.c
|
||||
index 77c0fff847..09a3668438 100644
|
||||
--- a/tools/virsh-interface.c
|
||||
+++ b/tools/virsh-interface.c
|
||||
@@ -141,7 +141,9 @@ cmdInterfaceEdit(vshControl *ctl, const vshCmd *cmd)
|
||||
}
|
||||
|
||||
static int
|
||||
-virshInterfaceSorter(const void *a, const void *b)
|
||||
+virshInterfaceSorter(const void *a,
|
||||
+ const void *b,
|
||||
+ void *opaque G_GNUC_UNUSED)
|
||||
{
|
||||
virInterfacePtr *ia = (virInterfacePtr *) a;
|
||||
virInterfacePtr *ib = (virInterfacePtr *) b;
|
||||
@@ -281,9 +283,10 @@ virshInterfaceListCollect(vshControl *ctl,
|
||||
|
||||
finished:
|
||||
/* sort the list */
|
||||
- if (list->ifaces && list->nifaces)
|
||||
- qsort(list->ifaces, list->nifaces,
|
||||
- sizeof(*list->ifaces), virshInterfaceSorter);
|
||||
+ if (list->ifaces && list->nifaces) {
|
||||
+ g_qsort_with_data(list->ifaces, list->nifaces,
|
||||
+ sizeof(*list->ifaces), virshInterfaceSorter, NULL);
|
||||
+ }
|
||||
|
||||
/* truncate the list if filter simulation deleted entries */
|
||||
if (deleted)
|
||||
diff --git a/tools/virsh-network.c b/tools/virsh-network.c
|
||||
index 998e7e15e3..68c7543863 100644
|
||||
--- a/tools/virsh-network.c
|
||||
+++ b/tools/virsh-network.c
|
||||
@@ -791,7 +791,9 @@ cmdNetworkInfo(vshControl *ctl, const vshCmd *cmd)
|
||||
}
|
||||
|
||||
static int
|
||||
-virshNetworkSorter(const void *a, const void *b)
|
||||
+virshNetworkSorter(const void *a,
|
||||
+ const void *b,
|
||||
+ void *opaque G_GNUC_UNUSED)
|
||||
{
|
||||
virNetworkPtr *na = (virNetworkPtr *) a;
|
||||
virNetworkPtr *nb = (virNetworkPtr *) b;
|
||||
@@ -982,9 +984,10 @@ virshNetworkListCollect(vshControl *ctl,
|
||||
|
||||
finished:
|
||||
/* sort the list */
|
||||
- if (list->nets && list->nnets)
|
||||
- qsort(list->nets, list->nnets,
|
||||
- sizeof(*list->nets), virshNetworkSorter);
|
||||
+ if (list->nets && list->nnets) {
|
||||
+ g_qsort_with_data(list->nets, list->nnets,
|
||||
+ sizeof(*list->nets), virshNetworkSorter, NULL);
|
||||
+ }
|
||||
|
||||
/* truncate the list if filter simulation deleted entries */
|
||||
if (deleted)
|
||||
@@ -1801,7 +1804,9 @@ static const vshCmdOptDef opts_network_dhcp_leases[] = {
|
||||
};
|
||||
|
||||
static int
|
||||
-virshNetworkDHCPLeaseSorter(const void *a, const void *b)
|
||||
+virshNetworkDHCPLeaseSorter(const void *a,
|
||||
+ const void *b,
|
||||
+ void *opaque G_GNUC_UNUSED)
|
||||
{
|
||||
virNetworkDHCPLeasePtr *lease1 = (virNetworkDHCPLeasePtr *) a;
|
||||
virNetworkDHCPLeasePtr *lease2 = (virNetworkDHCPLeasePtr *) b;
|
||||
@@ -1840,7 +1845,8 @@ cmdNetworkDHCPLeases(vshControl *ctl, const vshCmd *cmd)
|
||||
}
|
||||
|
||||
/* Sort the list according to MAC Address/IAID */
|
||||
- qsort(leases, nleases, sizeof(*leases), virshNetworkDHCPLeaseSorter);
|
||||
+ g_qsort_with_data(leases, nleases,
|
||||
+ sizeof(*leases), virshNetworkDHCPLeaseSorter, NULL);
|
||||
|
||||
table = vshTableNew(_("Expiry Time"), _("MAC address"), _("Protocol"),
|
||||
_("IP address"), _("Hostname"), _("Client ID or DUID"),
|
||||
@@ -2068,7 +2074,9 @@ cmdNetworkPortDelete(vshControl *ctl, const vshCmd *cmd)
|
||||
|
||||
|
||||
static int
|
||||
-virshNetworkPortSorter(const void *a, const void *b)
|
||||
+virshNetworkPortSorter(const void *a,
|
||||
+ const void *b,
|
||||
+ void *opaque G_GNUC_UNUSED)
|
||||
{
|
||||
virNetworkPortPtr *na = (virNetworkPortPtr *) a;
|
||||
virNetworkPortPtr *nb = (virNetworkPortPtr *) b;
|
||||
@@ -2129,9 +2137,10 @@ virshNetworkPortListCollect(vshControl *ctl,
|
||||
list->nports = ret;
|
||||
|
||||
/* sort the list */
|
||||
- if (list->ports && list->nports)
|
||||
- qsort(list->ports, list->nports,
|
||||
- sizeof(*list->ports), virshNetworkPortSorter);
|
||||
+ if (list->ports && list->nports) {
|
||||
+ g_qsort_with_data(list->ports, list->nports,
|
||||
+ sizeof(*list->ports), virshNetworkPortSorter, NULL);
|
||||
+ }
|
||||
|
||||
success = true;
|
||||
|
||||
diff --git a/tools/virsh-nodedev.c b/tools/virsh-nodedev.c
|
||||
index 82b8fb44fc..fb38fd7fcc 100644
|
||||
--- a/tools/virsh-nodedev.c
|
||||
+++ b/tools/virsh-nodedev.c
|
||||
@@ -183,7 +183,9 @@ virshNodeListLookup(int devid, bool parent, void *opaque)
|
||||
}
|
||||
|
||||
static int
|
||||
-virshNodeDeviceSorter(const void *a, const void *b)
|
||||
+virshNodeDeviceSorter(const void *a,
|
||||
+ const void *b,
|
||||
+ void *opaque G_GNUC_UNUSED)
|
||||
{
|
||||
virNodeDevicePtr *na = (virNodeDevicePtr *) a;
|
||||
virNodeDevicePtr *nb = (virNodeDevicePtr *) b;
|
||||
@@ -334,9 +336,10 @@ virshNodeDeviceListCollect(vshControl *ctl,
|
||||
|
||||
finished:
|
||||
/* sort the list */
|
||||
- if (list->devices && list->ndevices)
|
||||
- qsort(list->devices, list->ndevices,
|
||||
- sizeof(*list->devices), virshNodeDeviceSorter);
|
||||
+ if (list->devices && list->ndevices) {
|
||||
+ g_qsort_with_data(list->devices, list->ndevices,
|
||||
+ sizeof(*list->devices), virshNodeDeviceSorter, NULL);
|
||||
+ }
|
||||
|
||||
/* truncate the list if filter simulation deleted entries */
|
||||
if (deleted)
|
||||
diff --git a/tools/virsh-nwfilter.c b/tools/virsh-nwfilter.c
|
||||
index 92b2b7b3bc..fa52d020e4 100644
|
||||
--- a/tools/virsh-nwfilter.c
|
||||
+++ b/tools/virsh-nwfilter.c
|
||||
@@ -220,7 +220,9 @@ cmdNWFilterDumpXML(vshControl *ctl, const vshCmd *cmd)
|
||||
}
|
||||
|
||||
static int
|
||||
-virshNWFilterSorter(const void *a, const void *b)
|
||||
+virshNWFilterSorter(const void *a,
|
||||
+ const void *b,
|
||||
+ void *opaque G_GNUC_UNUSED)
|
||||
{
|
||||
virNWFilterPtr *fa = (virNWFilterPtr *) a;
|
||||
virNWFilterPtr *fb = (virNWFilterPtr *) b;
|
||||
@@ -323,9 +325,10 @@ virshNWFilterListCollect(vshControl *ctl,
|
||||
|
||||
finished:
|
||||
/* sort the list */
|
||||
- if (list->filters && list->nfilters)
|
||||
- qsort(list->filters, list->nfilters,
|
||||
- sizeof(*list->filters), virshNWFilterSorter);
|
||||
+ if (list->filters && list->nfilters) {
|
||||
+ g_qsort_with_data(list->filters, list->nfilters,
|
||||
+ sizeof(*list->filters), virshNWFilterSorter, NULL);
|
||||
+ }
|
||||
|
||||
/* truncate the list for not found filter objects */
|
||||
if (deleted)
|
||||
@@ -644,7 +647,9 @@ cmdNWFilterBindingDumpXML(vshControl *ctl, const vshCmd *cmd)
|
||||
|
||||
|
||||
static int
|
||||
-virshNWFilterBindingSorter(const void *a, const void *b)
|
||||
+virshNWFilterBindingSorter(const void *a,
|
||||
+ const void *b,
|
||||
+ void *opaque G_GNUC_UNUSED)
|
||||
{
|
||||
virNWFilterBindingPtr *fa = (virNWFilterBindingPtr *) a;
|
||||
virNWFilterBindingPtr *fb = (virNWFilterBindingPtr *) b;
|
||||
@@ -702,9 +707,10 @@ virshNWFilterBindingListCollect(vshControl *ctl,
|
||||
list->nbindings = ret;
|
||||
|
||||
/* sort the list */
|
||||
- if (list->bindings && list->nbindings > 1)
|
||||
- qsort(list->bindings, list->nbindings,
|
||||
- sizeof(*list->bindings), virshNWFilterBindingSorter);
|
||||
+ if (list->bindings && list->nbindings > 1) {
|
||||
+ g_qsort_with_data(list->bindings, list->nbindings,
|
||||
+ sizeof(*list->bindings), virshNWFilterBindingSorter, NULL);
|
||||
+ }
|
||||
|
||||
success = true;
|
||||
|
||||
diff --git a/tools/virsh-pool.c b/tools/virsh-pool.c
|
||||
index 5803530d79..36f00cf643 100644
|
||||
--- a/tools/virsh-pool.c
|
||||
+++ b/tools/virsh-pool.c
|
||||
@@ -814,7 +814,9 @@ cmdPoolDumpXML(vshControl *ctl, const vshCmd *cmd)
|
||||
}
|
||||
|
||||
static int
|
||||
-virshStoragePoolSorter(const void *a, const void *b)
|
||||
+virshStoragePoolSorter(const void *a,
|
||||
+ const void *b,
|
||||
+ void *opaque G_GNUC_UNUSED)
|
||||
{
|
||||
virStoragePoolPtr *pa = (virStoragePoolPtr *) a;
|
||||
virStoragePoolPtr *pb = (virStoragePoolPtr *) b;
|
||||
@@ -1005,9 +1007,10 @@ virshStoragePoolListCollect(vshControl *ctl,
|
||||
|
||||
finished:
|
||||
/* sort the list */
|
||||
- if (list->pools && list->npools)
|
||||
- qsort(list->pools, list->npools,
|
||||
- sizeof(*list->pools), virshStoragePoolSorter);
|
||||
+ if (list->pools && list->npools) {
|
||||
+ g_qsort_with_data(list->pools, list->npools,
|
||||
+ sizeof(*list->pools), virshStoragePoolSorter, NULL);
|
||||
+ }
|
||||
|
||||
/* truncate the list if filter simulation deleted entries */
|
||||
if (deleted)
|
||||
diff --git a/tools/virsh-secret.c b/tools/virsh-secret.c
|
||||
index 694e16c5cb..e54712ba78 100644
|
||||
--- a/tools/virsh-secret.c
|
||||
+++ b/tools/virsh-secret.c
|
||||
@@ -399,7 +399,9 @@ cmdSecretUndefine(vshControl *ctl, const vshCmd *cmd)
|
||||
}
|
||||
|
||||
static int
|
||||
-virshSecretSorter(const void *a, const void *b)
|
||||
+virshSecretSorter(const void *a,
|
||||
+ const void *b,
|
||||
+ void *opaque G_GNUC_UNUSED)
|
||||
{
|
||||
virSecretPtr *sa = (virSecretPtr *) a;
|
||||
virSecretPtr *sb = (virSecretPtr *) b;
|
||||
@@ -509,9 +511,10 @@ virshSecretListCollect(vshControl *ctl,
|
||||
|
||||
finished:
|
||||
/* sort the list */
|
||||
- if (list->secrets && list->nsecrets)
|
||||
- qsort(list->secrets, list->nsecrets,
|
||||
- sizeof(*list->secrets), virshSecretSorter);
|
||||
+ if (list->secrets && list->nsecrets) {
|
||||
+ g_qsort_with_data(list->secrets, list->nsecrets,
|
||||
+ sizeof(*list->secrets), virshSecretSorter, NULL);
|
||||
+ }
|
||||
|
||||
/* truncate the list for not found secret objects */
|
||||
if (deleted)
|
||||
diff --git a/tools/virsh-snapshot.c b/tools/virsh-snapshot.c
|
||||
index c85258c09a..2049872322 100644
|
||||
--- a/tools/virsh-snapshot.c
|
||||
+++ b/tools/virsh-snapshot.c
|
||||
@@ -982,7 +982,9 @@ virshSnapshotListFree(struct virshSnapshotList *snaplist)
|
||||
}
|
||||
|
||||
static int
|
||||
-virshSnapSorter(const void *a, const void *b)
|
||||
+virshSnapSorter(const void *a,
|
||||
+ const void *b,
|
||||
+ void *opaque G_GNUC_UNUSED)
|
||||
{
|
||||
const struct virshSnap *sa = a;
|
||||
const struct virshSnap *sb = b;
|
||||
@@ -1232,7 +1234,7 @@ virshSnapshotListCollect(vshControl *ctl, virDomainPtr dom,
|
||||
* still in list. We mark known descendants by clearing
|
||||
* snaps[i].parents. Sorry, this is O(n^3) - hope your
|
||||
* hierarchy isn't huge. XXX Is it worth making O(n^2 log n)
|
||||
- * by using qsort and bsearch? */
|
||||
+ * by using g_qsort_with_data and bsearch? */
|
||||
if (start_index < 0) {
|
||||
vshError(ctl, _("snapshot %1$s disappeared from list"), fromname);
|
||||
goto cleanup;
|
||||
@@ -1312,8 +1314,8 @@ virshSnapshotListCollect(vshControl *ctl, virDomainPtr dom,
|
||||
}
|
||||
if (!(orig_flags & VIR_DOMAIN_SNAPSHOT_LIST_TOPOLOGICAL) &&
|
||||
snaplist->snaps && snaplist->nsnaps) {
|
||||
- qsort(snaplist->snaps, snaplist->nsnaps, sizeof(*snaplist->snaps),
|
||||
- virshSnapSorter);
|
||||
+ g_qsort_with_data(snaplist->snaps, snaplist->nsnaps,
|
||||
+ sizeof(*snaplist->snaps), virshSnapSorter, NULL);
|
||||
}
|
||||
snaplist->nsnaps -= deleted;
|
||||
|
||||
diff --git a/tools/virsh-volume.c b/tools/virsh-volume.c
|
||||
index 9a2b21d3f3..329ca3a66c 100644
|
||||
--- a/tools/virsh-volume.c
|
||||
+++ b/tools/virsh-volume.c
|
||||
@@ -1200,7 +1200,9 @@ cmdVolDumpXML(vshControl *ctl, const vshCmd *cmd)
|
||||
}
|
||||
|
||||
static int
|
||||
-virshStorageVolSorter(const void *a, const void *b)
|
||||
+virshStorageVolSorter(const void *a,
|
||||
+ const void *b,
|
||||
+ void *opaque G_GNUC_UNUSED)
|
||||
{
|
||||
virStorageVolPtr *va = (virStorageVolPtr *) a;
|
||||
virStorageVolPtr *vb = (virStorageVolPtr *) b;
|
||||
@@ -1299,8 +1301,10 @@ virshStorageVolListCollect(vshControl *ctl,
|
||||
|
||||
finished:
|
||||
/* sort the list */
|
||||
- if (list->vols && list->nvols)
|
||||
- qsort(list->vols, list->nvols, sizeof(*list->vols), virshStorageVolSorter);
|
||||
+ if (list->vols && list->nvols) {
|
||||
+ g_qsort_with_data(list->vols, list->nvols,
|
||||
+ sizeof(*list->vols), virshStorageVolSorter, NULL);
|
||||
+ }
|
||||
|
||||
if (deleted)
|
||||
VIR_SHRINK_N(list->vols, list->nvols, deleted);
|
||||
--
|
||||
2.43.0
|
||||
|
498
libvirt.spec
498
libvirt.spec
File diff suppressed because it is too large
Load Diff
2
sources
2
sources
@ -1 +1 @@
|
||||
SHA512 (libvirt-9.9.0.tar.xz) = 77cea28acf4f3e8c92fbd5bd72ad084be183c07f14e3a9ce35d6d9d62d36ee97a30cef55fb204b3e43f282890ecd7d5827a784a517e7f4ed8b22ee502c3f09d7
|
||||
SHA512 (libvirt-9.10.0.tar.xz) = d35d14810a29aef9319d894e60d493c9011930e0b45d832861c8f8669ee66c0539cdd49f8e0a94801b510ae0f1ed150e4d6a03ea03cc23e8cb2e5456edd76f68
|
||||
|
Loading…
Reference in New Issue
Block a user