[libvirt] [REPOST PATCH] util: Clean up consumers of virJSONValueArraySize
by John Ferlan
Rather than have virJSONValueArraySize return a -1 when the input
is not an array and then splat an error message, let's check for
an array before calling and then change the return to be a size_t
instead of ssize_t.
That means using the helper virJSONValueIsArray as well as using a
more generic error message such as "Malformed <something> array".
In some cases we can remove stack variables and when we cannot,
those variables should be size_t not ssize_t. Alter a few references
of if (!value) to be if (value == 0) instead as well.
Some callers can already assume an array is being worked on based
on the previous call, so there's less to do.
Signed-off-by: John Ferlan <jferlan(a)redhat.com>
---
Original:
https://www.redhat.com/archives/libvir-list/2018-April/msg02003.html
Reposting as I found a recent upstream changes created some simple
merge conflicts and it's never clear if applying what was there can
be applied on top even with git am -3, so I figured I would just repost.
As noted previously, based off a review of the Coverity work from Peter:
https://www.redhat.com/archives/libvir-list/2018-April/msg01613.html
src/locking/lock_daemon.c | 7 ++--
src/logging/log_handler.c | 7 ++--
src/network/bridge_driver.c | 7 ++--
src/qemu/qemu_agent.c | 35 ++++++++++--------
src/qemu/qemu_monitor_json.c | 85 ++++++++++++++++++++-----------------------
src/rpc/virnetdaemon.c | 7 +---
src/rpc/virnetserver.c | 15 +++-----
src/rpc/virnetserverservice.c | 7 ++--
src/util/virjson.c | 5 +--
src/util/virjson.h | 2 +-
src/util/virlockspace.c | 16 ++++----
src/util/virstoragefile.c | 3 +-
tests/testutilsqemuschema.c | 18 +++------
tools/nss/libvirt_nss.c | 3 +-
14 files changed, 97 insertions(+), 120 deletions(-)
diff --git a/src/locking/lock_daemon.c b/src/locking/lock_daemon.c
index 7afff42246..78c33bd29c 100644
--- a/src/locking/lock_daemon.c
+++ b/src/locking/lock_daemon.c
@@ -248,7 +248,6 @@ virLockDaemonNewPostExecRestart(virJSONValuePtr object, bool privileged)
virJSONValuePtr child;
virJSONValuePtr lockspaces;
size_t i;
- ssize_t n;
const char *serverNames[] = { "virtlockd" };
if (VIR_ALLOC(lockd) < 0)
@@ -281,13 +280,13 @@ virLockDaemonNewPostExecRestart(virJSONValuePtr object, bool privileged)
goto error;
}
- if ((n = virJSONValueArraySize(lockspaces)) < 0) {
+ if (!virJSONValueIsArray(lockspaces)) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
- _("Malformed lockspaces data from JSON file"));
+ _("Malformed lockspaces array"));
goto error;
}
- for (i = 0; i < n; i++) {
+ for (i = 0; i < virJSONValueArraySize(lockspaces); i++) {
virLockSpacePtr lockspace;
child = virJSONValueArrayGet(lockspaces, i);
diff --git a/src/logging/log_handler.c b/src/logging/log_handler.c
index 40dfa8ecae..5364e06dff 100644
--- a/src/logging/log_handler.c
+++ b/src/logging/log_handler.c
@@ -292,7 +292,6 @@ virLogHandlerNewPostExecRestart(virJSONValuePtr object,
{
virLogHandlerPtr handler;
virJSONValuePtr files;
- ssize_t n;
size_t i;
if (!(handler = virLogHandlerNew(privileged,
@@ -308,13 +307,13 @@ virLogHandlerNewPostExecRestart(virJSONValuePtr object,
goto error;
}
- if ((n = virJSONValueArraySize(files)) < 0) {
+ if (!virJSONValueIsArray(files)) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
- _("Malformed files data from JSON file"));
+ _("Malformed files array"));
goto error;
}
- for (i = 0; i < n; i++) {
+ for (i = 0; i < virJSONValueArraySize(files); i++) {
virLogHandlerLogFilePtr file;
virJSONValuePtr child = virJSONValueArrayGet(files, i);
diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c
index ece7e41d35..4b33e12b30 100644
--- a/src/network/bridge_driver.c
+++ b/src/network/bridge_driver.c
@@ -4124,7 +4124,7 @@ networkGetDHCPLeases(virNetworkPtr net,
size_t i, j;
size_t nleases = 0;
int rv = -1;
- ssize_t size = 0;
+ size_t size = 0;
int custom_lease_file_len = 0;
bool need_results = !!leases;
long long currtime = 0;
@@ -4179,11 +4179,12 @@ networkGetDHCPLeases(virNetworkPtr net,
goto error;
}
- if ((size = virJSONValueArraySize(leases_array)) < 0) {
+ if (!virJSONValueIsArray(leases_array)) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
- _("couldn't fetch array of leases"));
+ _("Malformed lease_entries array"));
goto error;
}
+ size = virJSONValueArraySize(leases_array);
}
currtime = (long long)time(NULL);
diff --git a/src/qemu/qemu_agent.c b/src/qemu/qemu_agent.c
index 4df1bde458..eeede645ef 100644
--- a/src/qemu/qemu_agent.c
+++ b/src/qemu/qemu_agent.c
@@ -1490,7 +1490,7 @@ qemuAgentGetVCPUs(qemuAgentPtr mon,
virJSONValuePtr cmd;
virJSONValuePtr reply = NULL;
virJSONValuePtr data = NULL;
- ssize_t ndata;
+ size_t ndata;
if (!(cmd = qemuAgentMakeCommand("guest-get-vcpus", NULL)))
return -1;
@@ -1505,6 +1505,12 @@ qemuAgentGetVCPUs(qemuAgentPtr mon,
goto cleanup;
}
+ if (!virJSONValueIsArray(data)) {
+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("Malformed guest-get-vcpus data array"));
+ goto cleanup;
+ }
+
ndata = virJSONValueArraySize(data);
if (VIR_ALLOC_N(*info, ndata) < 0)
@@ -1869,15 +1875,14 @@ qemuAgentGetFSInfo(qemuAgentPtr mon, virDomainFSInfoPtr **info,
goto cleanup;
}
- if (virJSONValueGetType(data) != VIR_JSON_TYPE_ARRAY) {
+ if (!virJSONValueIsArray(data)) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
- _("guest-get-fsinfo return information was not "
- "an array"));
+ _("Malformed guest-get-fsinfo data array"));
goto cleanup;
}
ndata = virJSONValueArraySize(data);
- if (!ndata) {
+ if (ndata == 0) {
ret = 0;
*info = NULL;
goto cleanup;
@@ -1928,14 +1933,14 @@ qemuAgentGetFSInfo(qemuAgentPtr mon, virDomainFSInfoPtr **info,
goto cleanup;
}
- if (virJSONValueGetType(entry) != VIR_JSON_TYPE_ARRAY) {
+ if (!virJSONValueIsArray(entry)) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
- _("guest-get-fsinfo 'disk' data was not an array"));
+ _("Malformed guest-get-fsinfo 'disk' data array"));
goto cleanup;
}
ndisk = virJSONValueArraySize(entry);
- if (!ndisk)
+ if (ndisk == 0)
continue;
if (VIR_ALLOC_N(info_ret[i]->devAlias, ndisk) < 0)
goto cleanup;
@@ -2035,7 +2040,6 @@ qemuAgentGetInterfaces(qemuAgentPtr mon,
{
int ret = -1;
size_t i, j;
- ssize_t size = -1;
virJSONValuePtr cmd = NULL;
virJSONValuePtr reply = NULL;
virJSONValuePtr ret_array = NULL;
@@ -2065,17 +2069,16 @@ qemuAgentGetInterfaces(qemuAgentPtr mon,
goto cleanup;
}
- if ((size = virJSONValueArraySize(ret_array)) < 0) {
+ if (!virJSONValueIsArray(ret_array)) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("qemu agent didn't return an array of interfaces"));
goto cleanup;
}
- for (i = 0; i < size; i++) {
+ for (i = 0; i < virJSONValueArraySize(ret_array); i++) {
virJSONValuePtr tmp_iface = virJSONValueArrayGet(ret_array, i);
virJSONValuePtr ip_addr_arr = NULL;
const char *hwaddr, *ifname_s, *name = NULL;
- ssize_t ip_addr_arr_size;
virDomainInterfacePtr iface = NULL;
/* Shouldn't happen but doesn't hurt to check neither */
@@ -2131,14 +2134,16 @@ qemuAgentGetInterfaces(qemuAgentPtr mon,
if (!ip_addr_arr)
continue;
- if ((ip_addr_arr_size = virJSONValueArraySize(ip_addr_arr)) < 0)
- /* Mmm, empty 'ip-address'? */
+ if (!virJSONValueIsArray(ip_addr_arr)) {
+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("Malformed ip-addresses array"));
goto error;
+ }
/* If current iface already exists, continue with the count */
addrs_count = iface->naddrs;
- for (j = 0; j < ip_addr_arr_size; j++) {
+ for (j = 0; j < virJSONValueArraySize(ip_addr_arr); j++) {
const char *type, *addr;
virJSONValuePtr ip_addr_obj = virJSONValueArrayGet(ip_addr_arr, j);
virDomainIPAddressPtr ip_addr;
diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
index 8176175894..e0ea553c41 100644
--- a/src/qemu/qemu_monitor_json.c
+++ b/src/qemu/qemu_monitor_json.c
@@ -1627,9 +1627,9 @@ qemuMonitorJSONExtractCPUInfo(virJSONValuePtr data,
struct qemuMonitorQueryCpusEntry *cpus = NULL;
int ret = -1;
size_t i;
- ssize_t ncpus;
+ size_t ncpus;
- if ((ncpus = virJSONValueArraySize(data)) <= 0)
+ if ((ncpus = virJSONValueArraySize(data)) == 0)
return -2;
if (VIR_ALLOC_N(cpus, ncpus) < 0)
@@ -3595,7 +3595,7 @@ qemuMonitorJSONQueryRxFilterParse(virJSONValuePtr msg,
int ret = -1;
const char *tmp;
virJSONValuePtr returnArray, entry, table, element;
- ssize_t nTable;
+ size_t nTable;
size_t i;
virNetDevRxFilterPtr fil = virNetDevRxFilterNew();
@@ -3656,12 +3656,13 @@ qemuMonitorJSONQueryRxFilterParse(virJSONValuePtr msg,
goto cleanup;
}
if ((!(table = virJSONValueObjectGet(entry, "unicast-table"))) ||
- ((nTable = virJSONValueArraySize(table)) < 0)) {
+ (!virJSONValueIsArray(table))) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Missing or invalid 'unicast-table' array "
"in query-rx-filter response"));
goto cleanup;
}
+ nTable = virJSONValueArraySize(table);
if (VIR_ALLOC_N(fil->unicast.table, nTable))
goto cleanup;
for (i = 0; i < nTable; i++) {
@@ -3697,12 +3698,13 @@ qemuMonitorJSONQueryRxFilterParse(virJSONValuePtr msg,
goto cleanup;
}
if ((!(table = virJSONValueObjectGet(entry, "multicast-table"))) ||
- ((nTable = virJSONValueArraySize(table)) < 0)) {
+ (!virJSONValueIsArray(table))) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Missing or invalid 'multicast-table' array "
"in query-rx-filter response"));
goto cleanup;
}
+ nTable = virJSONValueArraySize(table);
if (VIR_ALLOC_N(fil->multicast.table, nTable))
goto cleanup;
for (i = 0; i < nTable; i++) {
@@ -3731,12 +3733,13 @@ qemuMonitorJSONQueryRxFilterParse(virJSONValuePtr msg,
goto cleanup;
}
if ((!(table = virJSONValueObjectGet(entry, "vlan-table"))) ||
- ((nTable = virJSONValueArraySize(table)) < 0)) {
+ (!virJSONValueIsArray(table))) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Missing or invalid 'vlan-table' array "
"in query-rx-filter response"));
goto cleanup;
}
+ nTable = virJSONValueArraySize(table);
if (VIR_ALLOC_N(fil->vlan.table, nTable))
goto cleanup;
for (i = 0; i < nTable; i++) {
@@ -4575,7 +4578,7 @@ qemuMonitorJSONGetAllBlockJobInfo(qemuMonitorPtr mon)
virJSONValuePtr cmd = NULL;
virJSONValuePtr reply = NULL;
virJSONValuePtr data;
- ssize_t nr_results;
+ size_t nr_results;
size_t i;
virHashTablePtr blockJobs = NULL;
@@ -4591,12 +4594,7 @@ qemuMonitorJSONGetAllBlockJobInfo(qemuMonitorPtr mon)
goto cleanup;
}
- if ((nr_results = virJSONValueArraySize(data)) < 0) {
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
- _("unable to determine array size"));
- goto cleanup;
- }
-
+ nr_results = virJSONValueArraySize(data);
if (!(blockJobs = virHashCreate(nr_results, virHashValueFree)))
goto cleanup;
@@ -5114,7 +5112,7 @@ int qemuMonitorJSONGetMachines(qemuMonitorPtr mon,
virJSONValuePtr reply = NULL;
virJSONValuePtr data;
qemuMonitorMachineInfoPtr *infolist = NULL;
- ssize_t n = 0;
+ size_t n = 0;
size_t i;
*machines = NULL;
@@ -5206,7 +5204,7 @@ qemuMonitorJSONGetCPUDefinitions(qemuMonitorPtr mon,
virJSONValuePtr reply = NULL;
virJSONValuePtr data;
qemuMonitorCPUDefInfoPtr *cpulist = NULL;
- int n = 0;
+ size_t n = 0;
size_t i;
*cpus = NULL;
@@ -5257,7 +5255,7 @@ qemuMonitorJSONGetCPUDefinitions(qemuMonitorPtr mon,
if (virJSONValueObjectHasKey(child, "unavailable-features")) {
virJSONValuePtr blockers;
size_t j;
- int len;
+ size_t len;
blockers = virJSONValueObjectGetArray(child,
"unavailable-features");
@@ -5494,7 +5492,7 @@ int qemuMonitorJSONGetCommands(qemuMonitorPtr mon,
virJSONValuePtr reply = NULL;
virJSONValuePtr data;
char **commandlist = NULL;
- ssize_t n = 0;
+ size_t n = 0;
size_t i;
*commands = NULL;
@@ -5550,7 +5548,7 @@ int qemuMonitorJSONGetEvents(qemuMonitorPtr mon,
virJSONValuePtr reply = NULL;
virJSONValuePtr data;
char **eventlist = NULL;
- ssize_t n = 0;
+ size_t n = 0;
size_t i;
*events = NULL;
@@ -5614,7 +5612,7 @@ qemuMonitorJSONGetCommandLineOptionParameters(qemuMonitorPtr mon,
virJSONValuePtr data = NULL;
virJSONValuePtr array = NULL;
char **paramlist = NULL;
- ssize_t n = 0;
+ size_t n = 0;
size_t i;
*params = NULL;
@@ -5646,17 +5644,17 @@ qemuMonitorJSONGetCommandLineOptionParameters(qemuMonitorPtr mon,
"return data"));
goto cleanup;
}
- qemuMonitorSetOptions(mon, array);
- }
- if ((n = virJSONValueArraySize(array)) < 0) {
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
- _("query-command-line-options reply data was not "
- "an array"));
- goto cleanup;
+ if (!virJSONValueIsArray(array)) {
+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("Malformed query-cmmand-line-options array"));
+ goto cleanup;
+ }
+
+ qemuMonitorSetOptions(mon, array);
}
- for (i = 0; i < n; i++) {
+ for (i = 0; i < virJSONValueArraySize(array); i++) {
virJSONValuePtr child = virJSONValueArrayGet(array, i);
const char *tmp;
@@ -5681,12 +5679,12 @@ qemuMonitorJSONGetCommandLineOptionParameters(qemuMonitorPtr mon,
if (found)
*found = true;
- if ((n = virJSONValueArraySize(data)) < 0) {
+ if (!virJSONValueIsArray(data)) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
- _("query-command-line-options parameter data was not "
- "an array"));
+ _("Malformed query-cmmand-line-options parameters array"));
goto cleanup;
}
+ n = virJSONValueArraySize(data);
/* null-terminated list */
if (VIR_ALLOC_N(paramlist, n + 1) < 0)
@@ -5776,7 +5774,7 @@ int qemuMonitorJSONGetObjectTypes(qemuMonitorPtr mon,
virJSONValuePtr reply = NULL;
virJSONValuePtr data;
char **typelist = NULL;
- ssize_t n = 0;
+ size_t n = 0;
size_t i;
*types = NULL;
@@ -5832,7 +5830,7 @@ int qemuMonitorJSONGetObjectListPaths(qemuMonitorPtr mon,
virJSONValuePtr reply = NULL;
virJSONValuePtr data;
qemuMonitorJSONListPathPtr *pathlist = NULL;
- ssize_t n = 0;
+ size_t n = 0;
size_t i;
*paths = NULL;
@@ -6062,7 +6060,7 @@ int qemuMonitorJSONGetDeviceProps(qemuMonitorPtr mon,
virJSONValuePtr reply = NULL;
virJSONValuePtr data;
char **proplist = NULL;
- ssize_t n = 0;
+ size_t n = 0;
size_t i;
*props = NULL;
@@ -6161,7 +6159,7 @@ qemuMonitorJSONGetMigrationCapabilities(qemuMonitorPtr mon,
virJSONValuePtr caps;
char **list = NULL;
size_t i;
- ssize_t n;
+ size_t n;
*capabilities = NULL;
@@ -6272,7 +6270,7 @@ qemuMonitorJSONGetGICCapabilities(qemuMonitorPtr mon,
virJSONValuePtr caps;
virGICCapability *list = NULL;
size_t i;
- ssize_t n;
+ size_t n;
*capabilities = NULL;
@@ -6495,7 +6493,7 @@ qemuMonitorJSONGetStringArray(qemuMonitorPtr mon, const char *qmpCmd,
virJSONValuePtr reply = NULL;
virJSONValuePtr data;
char **list = NULL;
- ssize_t n = 0;
+ size_t n = 0;
size_t i;
*array = NULL;
@@ -6892,14 +6890,11 @@ qemuMonitorJSONParseCPUx86Features(virJSONValuePtr data)
virCPUDataPtr cpudata = NULL;
virCPUx86CPUID cpuid;
size_t i;
- ssize_t n;
-
- n = virJSONValueArraySize(data);
if (!(cpudata = virCPUDataNew(VIR_ARCH_X86_64)))
goto error;
- for (i = 0; i < n; i++) {
+ for (i = 0; i < virJSONValueArraySize(data); i++) {
if (qemuMonitorJSONParseCPUx86FeatureWord(virJSONValueArrayGet(data, i),
&cpuid) < 0 ||
virCPUx86DataAddCPUID(cpudata, &cpuid) < 0)
@@ -6960,7 +6955,7 @@ qemuMonitorJSONCheckCPUx86(qemuMonitorPtr mon)
virJSONValuePtr reply = NULL;
virJSONValuePtr data;
size_t i;
- ssize_t n;
+ size_t n;
int ret = -1;
if (!(cmd = qemuMonitorJSONMakeCommand("qom-list",
@@ -7098,7 +7093,7 @@ qemuMonitorJSONGetIOThreads(qemuMonitorPtr mon,
virJSONValuePtr reply = NULL;
virJSONValuePtr data;
qemuMonitorIOThreadInfoPtr *infolist = NULL;
- ssize_t n = 0;
+ size_t n = 0;
size_t i;
*iothreads = NULL;
@@ -7180,7 +7175,6 @@ qemuMonitorJSONGetMemoryDeviceInfo(qemuMonitorPtr mon,
virJSONValuePtr reply = NULL;
virJSONValuePtr data = NULL;
qemuMonitorMemoryDeviceInfoPtr meminfo = NULL;
- ssize_t n;
size_t i;
if (!(cmd = qemuMonitorJSONMakeCommand("query-memory-devices", NULL)))
@@ -7198,9 +7192,8 @@ qemuMonitorJSONGetMemoryDeviceInfo(qemuMonitorPtr mon,
goto cleanup;
data = virJSONValueObjectGetArray(reply, "return");
- n = virJSONValueArraySize(data);
- for (i = 0; i < n; i++) {
+ for (i = 0; i < virJSONValueArraySize(data); i++) {
virJSONValuePtr elem = virJSONValueArrayGet(data, i);
const char *type;
@@ -7666,7 +7659,7 @@ qemuMonitorJSONGetHotpluggableCPUs(qemuMonitorPtr mon,
size_t *nentries)
{
struct qemuMonitorQueryHotpluggableCpusEntry *info = NULL;
- ssize_t ninfo = 0;
+ size_t ninfo = 0;
int ret = -1;
size_t i;
virJSONValuePtr data;
diff --git a/src/rpc/virnetdaemon.c b/src/rpc/virnetdaemon.c
index eb0b822545..31b687de12 100644
--- a/src/rpc/virnetdaemon.c
+++ b/src/rpc/virnetdaemon.c
@@ -322,12 +322,7 @@ virNetDaemonNewPostExecRestart(virJSONValuePtr object,
goto error;
} else if (virJSONValueIsArray(servers)) {
size_t i;
- ssize_t n = virJSONValueArraySize(servers);
- if (n < 0) {
- virReportError(VIR_ERR_INTERNAL_ERROR,
- _("Server count %zd should be positive"), n);
- goto error;
- }
+ size_t n = virJSONValueArraySize(servers);
if (n > nDefServerNames) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Server count %zd greater than default name count %zu"),
diff --git a/src/rpc/virnetserver.c b/src/rpc/virnetserver.c
index f4105b1394..5aeb188900 100644
--- a/src/rpc/virnetserver.c
+++ b/src/rpc/virnetserver.c
@@ -411,7 +411,6 @@ virNetServerPtr virNetServerNewPostExecRestart(virJSONValuePtr object,
virJSONValuePtr clients;
virJSONValuePtr services;
size_t i;
- ssize_t n;
unsigned int min_workers;
unsigned int max_workers;
unsigned int priority_workers;
@@ -492,14 +491,13 @@ virNetServerPtr virNetServerNewPostExecRestart(virJSONValuePtr object,
goto error;
}
- n = virJSONValueArraySize(services);
- if (n < 0) {
+ if (!virJSONValueIsArray(services)) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
- _("Malformed services data in JSON document"));
+ _("Malformed services array"));
goto error;
}
- for (i = 0; i < n; i++) {
+ for (i = 0; i < virJSONValueArraySize(services); i++) {
virNetServerServicePtr service;
virJSONValuePtr child = virJSONValueArrayGet(services, i);
if (!child) {
@@ -525,14 +523,13 @@ virNetServerPtr virNetServerNewPostExecRestart(virJSONValuePtr object,
goto error;
}
- n = virJSONValueArraySize(clients);
- if (n < 0) {
+ if (!virJSONValueIsArray(clients)) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
- _("Malformed clients data in JSON document"));
+ _("Malformed clients array"));
goto error;
}
- for (i = 0; i < n; i++) {
+ for (i = 0; i < virJSONValueArraySize(clients); i++) {
virNetServerClientPtr client;
virJSONValuePtr child = virJSONValueArrayGet(clients, i);
if (!child) {
diff --git a/src/rpc/virnetserverservice.c b/src/rpc/virnetserverservice.c
index fb19d09dda..23fc23cab4 100644
--- a/src/rpc/virnetserverservice.c
+++ b/src/rpc/virnetserverservice.c
@@ -325,7 +325,7 @@ virNetServerServicePtr virNetServerServiceNewPostExecRestart(virJSONValuePtr obj
virNetServerServicePtr svc;
virJSONValuePtr socks;
size_t i;
- ssize_t n;
+ size_t n;
unsigned int max;
if (virNetServerServiceInitialize() < 0)
@@ -358,12 +358,13 @@ virNetServerServicePtr virNetServerServiceNewPostExecRestart(virJSONValuePtr obj
goto error;
}
- if ((n = virJSONValueArraySize(socks)) < 0) {
+ if (!virJSONValueIsArray(socks)) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
- _("socks field in JSON was not an array"));
+ _("Malformed socks array"));
goto error;
}
+ n = virJSONValueArraySize(socks);
if (VIR_ALLOC_N(svc->socks, n) < 0)
goto error;
svc->nsocks = n;
diff --git a/src/util/virjson.c b/src/util/virjson.c
index dfe00d9280..bb4e3c257b 100644
--- a/src/util/virjson.c
+++ b/src/util/virjson.c
@@ -971,12 +971,9 @@ virJSONValueIsArray(virJSONValuePtr array)
}
-ssize_t
+size_t
virJSONValueArraySize(const virJSONValue *array)
{
- if (array->type != VIR_JSON_TYPE_ARRAY)
- return -1;
-
return array->data.array.nvalues;
}
diff --git a/src/util/virjson.h b/src/util/virjson.h
index 0f098892b4..e4a82bdbc8 100644
--- a/src/util/virjson.h
+++ b/src/util/virjson.h
@@ -81,7 +81,7 @@ virJSONValuePtr virJSONValueObjectGetByType(virJSONValuePtr object,
bool virJSONValueIsObject(virJSONValuePtr object);
bool virJSONValueIsArray(virJSONValuePtr array);
-ssize_t virJSONValueArraySize(const virJSONValue *array);
+size_t virJSONValueArraySize(const virJSONValue *array);
virJSONValuePtr virJSONValueArrayGet(virJSONValuePtr object, unsigned int element);
virJSONValuePtr virJSONValueArraySteal(virJSONValuePtr object, unsigned int element);
typedef int (*virJSONArrayIteratorFunc)(size_t pos,
diff --git a/src/util/virlockspace.c b/src/util/virlockspace.c
index 41af0cdb6d..3364c843aa 100644
--- a/src/util/virlockspace.c
+++ b/src/util/virlockspace.c
@@ -293,7 +293,6 @@ virLockSpacePtr virLockSpaceNewPostExecRestart(virJSONValuePtr object)
{
virLockSpacePtr lockspace;
virJSONValuePtr resources;
- ssize_t n;
size_t i;
VIR_DEBUG("object=%p", object);
@@ -324,19 +323,19 @@ virLockSpacePtr virLockSpaceNewPostExecRestart(virJSONValuePtr object)
goto error;
}
- if ((n = virJSONValueArraySize(resources)) < 0) {
+ if (!virJSONValueIsArray(resources)) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
- _("Malformed resources value in JSON document"));
+ _("Malformed resources array"));
goto error;
}
- for (i = 0; i < n; i++) {
+ for (i = 0; i < virJSONValueArraySize(resources); i++) {
virJSONValuePtr child = virJSONValueArrayGet(resources, i);
virLockSpaceResourcePtr res;
const char *tmp;
virJSONValuePtr owners;
size_t j;
- ssize_t m;
+ size_t m;
if (VIR_ALLOC(res) < 0)
goto error;
@@ -396,18 +395,19 @@ virLockSpacePtr virLockSpaceNewPostExecRestart(virJSONValuePtr object)
goto error;
}
- if ((m = virJSONValueArraySize(owners)) < 0) {
+ if (!virJSONValueIsArray(owners)) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
- _("Malformed owners value in JSON document"));
+ _("Malformed owners array"));
virLockSpaceResourceFree(res);
goto error;
}
- res->nOwners = m;
+ m = virJSONValueArraySize(owners);
if (VIR_ALLOC_N(res->owners, res->nOwners) < 0) {
virLockSpaceResourceFree(res);
goto error;
}
+ res->nOwners = m;
for (j = 0; j < res->nOwners; j++) {
unsigned long long int owner;
diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c
index eae1dc01dc..275ab9b54b 100644
--- a/src/util/virstoragefile.c
+++ b/src/util/virstoragefile.c
@@ -2928,8 +2928,7 @@ virStorageSourceParseBackingJSONGluster(virStorageSourcePtr src,
return -1;
nservers = virJSONValueArraySize(server);
-
- if (nservers < 1) {
+ if (nservers == 0) {
virReportError(VIR_ERR_INVALID_ARG, "%s",
_("at least 1 server is necessary in "
"JSON backing definition for gluster volume"));
diff --git a/tests/testutilsqemuschema.c b/tests/testutilsqemuschema.c
index 21f5d119e8..46bbc4f1e5 100644
--- a/tests/testutilsqemuschema.c
+++ b/tests/testutilsqemuschema.c
@@ -101,11 +101,9 @@ testQEMUSchemaStealObjectMemberByName(const char *name,
{
virJSONValuePtr member;
virJSONValuePtr ret = NULL;
- size_t n;
size_t i;
- n = virJSONValueArraySize(members);
- for (i = 0; i < n; i++) {
+ for (i = 0; i < virJSONValueArraySize(members); i++) {
member = virJSONValueArrayGet(members, i);
if (STREQ_NULLABLE(name, virJSONValueObjectGetString(member, "name"))) {
@@ -188,7 +186,6 @@ testQEMUSchemaValidateObjectMergeVariant(virJSONValuePtr root,
virHashTablePtr schema,
virBufferPtr debug)
{
- size_t n;
size_t i;
virJSONValuePtr variants = NULL;
virJSONValuePtr variant;
@@ -203,8 +200,7 @@ testQEMUSchemaValidateObjectMergeVariant(virJSONValuePtr root,
return -2;
}
- n = virJSONValueArraySize(variants);
- for (i = 0; i < n; i++) {
+ for (i = 0; i < virJSONValueArraySize(variants); i++) {
variant = virJSONValueArrayGet(variants, i);
if (STREQ_NULLABLE(variantname,
@@ -342,7 +338,6 @@ testQEMUSchemaValidateEnum(virJSONValuePtr obj,
const char *objstr;
virJSONValuePtr values = NULL;
virJSONValuePtr value;
- size_t n;
size_t i;
if (virJSONValueGetType(obj) != VIR_JSON_TYPE_STRING) {
@@ -358,8 +353,7 @@ testQEMUSchemaValidateEnum(virJSONValuePtr obj,
return -2;
}
- n = virJSONValueArraySize(values);
- for (i = 0; i < n; i++) {
+ for (i = 0; i < virJSONValueArraySize(values); i++) {
value = virJSONValueArrayGet(values, i);
if (STREQ_NULLABLE(objstr, virJSONValueGetString(value))) {
@@ -383,7 +377,6 @@ testQEMUSchemaValidateArray(virJSONValuePtr objs,
const char *elemtypename = virJSONValueObjectGetString(root, "element-type");
virJSONValuePtr elementschema;
virJSONValuePtr obj;
- size_t n;
size_t i;
if (virJSONValueGetType(objs) != VIR_JSON_TYPE_ARRAY) {
@@ -401,8 +394,7 @@ testQEMUSchemaValidateArray(virJSONValuePtr objs,
virBufferAddLit(debug, "[\n");
virBufferAdjustIndent(debug, 3);
- n = virJSONValueArraySize(objs);
- for (i = 0; i < n; i++) {
+ for (i = 0; i < virJSONValueArraySize(objs); i++) {
obj = virJSONValueArrayGet(objs, i);
if (testQEMUSchemaValidateRecurse(obj, elementschema, schema, debug) < 0)
@@ -423,8 +415,8 @@ testQEMUSchemaValidateAlternate(virJSONValuePtr obj,
{
virJSONValuePtr members;
virJSONValuePtr member;
- size_t n;
size_t i;
+ size_t n;
const char *membertype;
virJSONValuePtr memberschema;
int indent;
diff --git a/tools/nss/libvirt_nss.c b/tools/nss/libvirt_nss.c
index 62fe589bed..ec73ea575a 100644
--- a/tools/nss/libvirt_nss.c
+++ b/tools/nss/libvirt_nss.c
@@ -309,8 +309,7 @@ findLease(const char *name,
}
VIR_DIR_CLOSE(dir);
- if ((nleases = virJSONValueArraySize(leases_array)) < 0)
- goto cleanup;
+ nleases = virJSONValueArraySize(leases_array);
DEBUG("Read %zd leases", nleases);
#if !defined(LIBVIRT_NSS_GUEST)
--
2.14.3
6 years, 5 months
[libvirt] [jenkins-ci PATCH] Revert "projects: Drop explicit --enable-gtk-doc"
by Andrea Bolognani
Turns out using --enable-gtk-doc *is* required, as otherwise
the *-rpm jobs for projects using gtk-doc fail with
*** gtk-doc must be installed and enabled in order to make dist
Interestingly, libosinfo doesn't seem to be affected by this
issue despite it, too, using gtk-doc. Fixing libvirt-sandbox
and libvirt-glib so they don't need this either is left as an
exercise for the reader.
This reverts commit 14f444fec9ca7aa670ce7a8db62ba44cad2df6fd.
Signed-off-by: Andrea Bolognani <abologna(a)redhat.com>
---
Pushed under the "would be a build-breaker if I didn't" rule.
projects/libvirt-glib.yaml | 1 +
projects/libvirt-sandbox.yaml | 1 +
2 files changed, 2 insertions(+)
diff --git a/projects/libvirt-glib.yaml b/projects/libvirt-glib.yaml
index 5a1cb37..286d25b 100644
--- a/projects/libvirt-glib.yaml
+++ b/projects/libvirt-glib.yaml
@@ -6,6 +6,7 @@
jobs:
- autotools-build-job:
parent_jobs: 'libvirt-master-build'
+ autogen_args: --enable-gtk-doc
- autotools-syntax-check-job:
parent_jobs: 'libvirt-glib-master-build'
- autotools-check-job:
diff --git a/projects/libvirt-sandbox.yaml b/projects/libvirt-sandbox.yaml
index 9117f50..bb8bda6 100644
--- a/projects/libvirt-sandbox.yaml
+++ b/projects/libvirt-sandbox.yaml
@@ -10,6 +10,7 @@
jobs:
- autotools-build-job:
parent_jobs: 'libvirt-glib-master-build'
+ autogen_args: --enable-gtk-doc
- autotools-syntax-check-job:
parent_jobs: 'libvirt-sandbox-master-build'
- autotools-check-job:
--
2.17.0
6 years, 5 months
[libvirt] [PATCH] qemu: Remove parameter 'driver' from qemuBlockJobUpdate
by Roland Schulz
The pointer to the qemu driver is already included in domain object's
private data, so does not need to be passed as yet another parameter
when the domain object is already passed.
Also removes parameter 'driver' from functions which had it just because of
qemuBlockJobUpdate.
Signed-off-by: Roland Schulz <schullzroll(a)gmail.com>
---
Follow up on BiteSizeTask
https://wiki.libvirt.org/page/BiteSizedTasks#Clean_up_virQEMUDriverPtr_pa...
src/qemu/qemu_blockjob.c | 13 +++++--------
src/qemu/qemu_blockjob.h | 6 ++----
src/qemu/qemu_driver.c | 6 +++---
src/qemu/qemu_migration.c | 29 +++++++++++++----------------
4 files changed, 23 insertions(+), 31 deletions(-)
diff --git a/src/qemu/qemu_blockjob.c b/src/qemu/qemu_blockjob.c
index 617e4ee56..e0dfb88c1 100644
--- a/src/qemu/qemu_blockjob.c
+++ b/src/qemu/qemu_blockjob.c
@@ -44,7 +44,6 @@ VIR_LOG_INIT("qemu.qemu_blockjob");
/**
* qemuBlockJobUpdate:
- * @driver: qemu driver
* @vm: domain
* @disk: domain disk
* @error: error (output parameter)
@@ -55,20 +54,20 @@ VIR_LOG_INIT("qemu.qemu_blockjob");
* Returns the block job event processed or -1 if there was no pending event.
*/
int
-qemuBlockJobUpdate(virQEMUDriverPtr driver,
- virDomainObjPtr vm,
+qemuBlockJobUpdate(virDomainObjPtr vm,
qemuDomainAsyncJob asyncJob,
virDomainDiskDefPtr disk,
char **error)
{
qemuDomainDiskPrivatePtr diskPriv = QEMU_DOMAIN_DISK_PRIVATE(disk);
+ qemuDomainObjPrivatePtr priv = vm->privateData;
int status = diskPriv->blockJobStatus;
if (error)
*error = NULL;
if (status != -1) {
- qemuBlockJobEventProcess(driver, vm, disk, asyncJob,
+ qemuBlockJobEventProcess(priv->driver, vm, disk, asyncJob,
diskPriv->blockJobType,
diskPriv->blockJobStatus);
diskPriv->blockJobStatus = -1;
@@ -244,7 +243,6 @@ qemuBlockJobSyncBegin(virDomainDiskDefPtr disk)
/**
* qemuBlockJobSyncEnd:
- * @driver: qemu driver
* @vm: domain
* @disk: domain disk
*
@@ -252,12 +250,11 @@ qemuBlockJobSyncBegin(virDomainDiskDefPtr disk)
* for the disk is processed.
*/
void
-qemuBlockJobSyncEnd(virQEMUDriverPtr driver,
- virDomainObjPtr vm,
+qemuBlockJobSyncEnd(virDomainObjPtr vm,
qemuDomainAsyncJob asyncJob,
virDomainDiskDefPtr disk)
{
VIR_DEBUG("disk=%s", disk->dst);
- qemuBlockJobUpdate(driver, vm, asyncJob, disk, NULL);
+ qemuBlockJobUpdate(vm, asyncJob, disk, NULL);
QEMU_DOMAIN_DISK_PRIVATE(disk)->blockJobSync = false;
}
diff --git a/src/qemu/qemu_blockjob.h b/src/qemu/qemu_blockjob.h
index e71d691c9..cee3ee21c 100644
--- a/src/qemu/qemu_blockjob.h
+++ b/src/qemu/qemu_blockjob.h
@@ -26,8 +26,7 @@
# include "qemu_conf.h"
# include "qemu_domain.h"
-int qemuBlockJobUpdate(virQEMUDriverPtr driver,
- virDomainObjPtr vm,
+int qemuBlockJobUpdate(virDomainObjPtr vm,
qemuDomainAsyncJob asyncJob,
virDomainDiskDefPtr disk,
char **error);
@@ -39,8 +38,7 @@ void qemuBlockJobEventProcess(virQEMUDriverPtr driver,
int status);
void qemuBlockJobSyncBegin(virDomainDiskDefPtr disk);
-void qemuBlockJobSyncEnd(virQEMUDriverPtr driver,
- virDomainObjPtr vm,
+void qemuBlockJobSyncEnd(virDomainObjPtr vm,
qemuDomainAsyncJob asyncJob,
virDomainDiskDefPtr disk);
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index c129321a5..b03eb3042 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -16934,19 +16934,19 @@ qemuDomainBlockJobAbort(virDomainPtr dom,
* block jobs from confusing us. */
if (!async) {
qemuDomainDiskPrivatePtr diskPriv = QEMU_DOMAIN_DISK_PRIVATE(disk);
- qemuBlockJobUpdate(driver, vm, QEMU_ASYNC_JOB_NONE, disk, NULL);
+ qemuBlockJobUpdate(vm, QEMU_ASYNC_JOB_NONE, disk, NULL);
while (diskPriv->blockjob) {
if (virDomainObjWait(vm) < 0) {
ret = -1;
goto endjob;
}
- qemuBlockJobUpdate(driver, vm, QEMU_ASYNC_JOB_NONE, disk, NULL);
+ qemuBlockJobUpdate(vm, QEMU_ASYNC_JOB_NONE, disk, NULL);
}
}
endjob:
if (disk)
- qemuBlockJobSyncEnd(driver, vm, QEMU_ASYNC_JOB_NONE, disk);
+ qemuBlockJobSyncEnd(vm, QEMU_ASYNC_JOB_NONE, disk);
qemuDomainObjEndJob(driver, vm);
cleanup:
diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
index 7602a304c..f01bb64f6 100644
--- a/src/qemu/qemu_migration.c
+++ b/src/qemu/qemu_migration.c
@@ -464,7 +464,6 @@ qemuMigrationDstStopNBDServer(virQEMUDriverPtr driver,
/**
* qemuMigrationSrcDriveMirrorReady:
- * @driver: qemu driver
* @vm: domain
*
* Check the status of all drive-mirrors started by
@@ -476,8 +475,7 @@ qemuMigrationDstStopNBDServer(virQEMUDriverPtr driver,
* -1 on error.
*/
static int
-qemuMigrationSrcDriveMirrorReady(virQEMUDriverPtr driver,
- virDomainObjPtr vm,
+qemuMigrationSrcDriveMirrorReady(virDomainObjPtr vm,
qemuDomainAsyncJob asyncJob)
{
size_t i;
@@ -492,7 +490,7 @@ qemuMigrationSrcDriveMirrorReady(virQEMUDriverPtr driver,
if (!diskPriv->migrating)
continue;
- status = qemuBlockJobUpdate(driver, vm, asyncJob, disk, &error);
+ status = qemuBlockJobUpdate(vm, asyncJob, disk, &error);
if (status == VIR_DOMAIN_BLOCK_JOB_FAILED) {
if (error) {
virReportError(VIR_ERR_OPERATION_FAILED,
@@ -532,8 +530,7 @@ qemuMigrationSrcDriveMirrorReady(virQEMUDriverPtr driver,
* -2 all mirrors are gone but some of them failed.
*/
static int
-qemuMigrationDriveMirrorCancelled(virQEMUDriverPtr driver,
- virDomainObjPtr vm,
+qemuMigrationDriveMirrorCancelled(virDomainObjPtr vm,
qemuDomainAsyncJob asyncJob,
bool check)
{
@@ -552,7 +549,7 @@ qemuMigrationDriveMirrorCancelled(virQEMUDriverPtr driver,
if (!diskPriv->migrating)
continue;
- status = qemuBlockJobUpdate(driver, vm, asyncJob, disk, &error);
+ status = qemuBlockJobUpdate(vm, asyncJob, disk, &error);
switch (status) {
case VIR_DOMAIN_BLOCK_JOB_FAILED:
if (check) {
@@ -569,7 +566,7 @@ qemuMigrationDriveMirrorCancelled(virQEMUDriverPtr driver,
ATTRIBUTE_FALLTHROUGH;
case VIR_DOMAIN_BLOCK_JOB_CANCELED:
case VIR_DOMAIN_BLOCK_JOB_COMPLETED:
- qemuBlockJobSyncEnd(driver, vm, asyncJob, disk);
+ qemuBlockJobSyncEnd(vm, asyncJob, disk);
diskPriv->migrating = false;
break;
@@ -633,7 +630,7 @@ qemuMigrationSrcCancelOneDriveMirror(virQEMUDriverPtr driver,
int status;
int rv;
- status = qemuBlockJobUpdate(driver, vm, asyncJob, disk, &error);
+ status = qemuBlockJobUpdate(vm, asyncJob, disk, &error);
switch (status) {
case VIR_DOMAIN_BLOCK_JOB_FAILED:
case VIR_DOMAIN_BLOCK_JOB_CANCELED:
@@ -716,12 +713,12 @@ qemuMigrationSrcCancelDriveMirror(virQEMUDriverPtr driver,
err = virSaveLastError();
failed = true;
}
- qemuBlockJobSyncEnd(driver, vm, asyncJob, disk);
+ qemuBlockJobSyncEnd(vm, asyncJob, disk);
diskPriv->migrating = false;
}
}
- while ((rv = qemuMigrationDriveMirrorCancelled(driver, vm, asyncJob,
+ while ((rv = qemuMigrationDriveMirrorCancelled(vm, asyncJob,
check)) != 1) {
if (check && !failed &&
dconn && virConnectIsAlive(dconn) <= 0) {
@@ -848,7 +845,7 @@ qemuMigrationSrcDriveMirror(virQEMUDriverPtr driver,
VIR_FREE(nbd_dest);
if (qemuDomainObjExitMonitor(driver, vm) < 0 || mon_ret < 0) {
- qemuBlockJobSyncEnd(driver, vm, QEMU_ASYNC_JOB_MIGRATION_OUT, disk);
+ qemuBlockJobSyncEnd(vm, QEMU_ASYNC_JOB_MIGRATION_OUT, disk);
goto cleanup;
}
diskPriv->migrating = true;
@@ -859,7 +856,7 @@ qemuMigrationSrcDriveMirror(virQEMUDriverPtr driver,
}
}
- while ((rv = qemuMigrationSrcDriveMirrorReady(driver, vm,
+ while ((rv = qemuMigrationSrcDriveMirrorReady(vm,
QEMU_ASYNC_JOB_MIGRATION_OUT)) != 1) {
if (rv < 0)
goto cleanup;
@@ -1366,7 +1363,7 @@ qemuMigrationAnyCompleted(virQEMUDriverPtr driver,
/* This flag should only be set when run on src host */
if (flags & QEMU_MIGRATION_COMPLETED_CHECK_STORAGE &&
- qemuMigrationSrcDriveMirrorReady(driver, vm, asyncJob) < 0)
+ qemuMigrationSrcDriveMirrorReady(vm, asyncJob) < 0)
goto error;
if (flags & QEMU_MIGRATION_COMPLETED_ABORT_ON_ERROR &&
@@ -5273,7 +5270,7 @@ qemuMigrationSrcCancel(virQEMUDriverPtr driver,
VIR_DEBUG("Drive mirror on disk %s is still running", disk->dst);
} else {
VIR_DEBUG("Drive mirror on disk %s is gone", disk->dst);
- qemuBlockJobSyncEnd(driver, vm, QEMU_ASYNC_JOB_NONE, disk);
+ qemuBlockJobSyncEnd(vm, QEMU_ASYNC_JOB_NONE, disk);
diskPriv->migrating = false;
}
}
@@ -5295,7 +5292,7 @@ qemuMigrationSrcCancel(virQEMUDriverPtr driver,
qemuDomainDiskPrivatePtr diskPriv = QEMU_DOMAIN_DISK_PRIVATE(disk);
if (diskPriv->migrating) {
- qemuBlockJobSyncEnd(driver, vm, QEMU_ASYNC_JOB_NONE, disk);
+ qemuBlockJobSyncEnd(vm, QEMU_ASYNC_JOB_NONE, disk);
diskPriv->migrating = false;
}
}
--
2.14.3
6 years, 5 months
[libvirt] [go-xml PATCH] test: Clone libvirt.git via https:// instead of git://
by Andrea Bolognani
The git:// protocol can cause issues when the client is
behind a corporate firewall; https:// works in pretty much
any scenario, and these days it's basically as efficient.
Signed-off-by: Andrea Bolognani <abologna(a)redhat.com>
---
xml_test.go | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/xml_test.go b/xml_test.go
index dcec589..2a2e16f 100644
--- a/xml_test.go
+++ b/xml_test.go
@@ -388,7 +388,7 @@ func syncGit(t *testing.T) {
_, err := os.Stat("testdata/libvirt/tests")
if err != nil {
if os.IsNotExist(err) {
- msg, err := exec.Command("git", "clone", "--depth", "1", "git://libvirt.org/libvirt.git", "testdata/libvirt").CombinedOutput()
+ msg, err := exec.Command("git", "clone", "--depth", "1", "https://libvirt.org/git/libvirt.git", "testdata/libvirt").CombinedOutput()
if err != nil {
t.Fatal(fmt.Errorf("Unable to clone libvirt.git: %s: %s", err, msg))
}
--
2.17.0
6 years, 5 months
[libvirt] [jenkins-ci PATCH] projects: Drop explicit --enable-gtk-doc
by Andrea Bolognani
We rely on autodetection for all other features, no reason
to treat gtk-doc any differently; the gtk-doc package will
have been installed on the worker in any case.
Signed-off-by: Andrea Bolognani <abologna(a)redhat.com>
---
projects/libvirt-glib.yaml | 1 -
projects/libvirt-sandbox.yaml | 1 -
2 files changed, 2 deletions(-)
diff --git a/projects/libvirt-glib.yaml b/projects/libvirt-glib.yaml
index 286d25b..5a1cb37 100644
--- a/projects/libvirt-glib.yaml
+++ b/projects/libvirt-glib.yaml
@@ -6,7 +6,6 @@
jobs:
- autotools-build-job:
parent_jobs: 'libvirt-master-build'
- autogen_args: --enable-gtk-doc
- autotools-syntax-check-job:
parent_jobs: 'libvirt-glib-master-build'
- autotools-check-job:
diff --git a/projects/libvirt-sandbox.yaml b/projects/libvirt-sandbox.yaml
index bb8bda6..9117f50 100644
--- a/projects/libvirt-sandbox.yaml
+++ b/projects/libvirt-sandbox.yaml
@@ -10,7 +10,6 @@
jobs:
- autotools-build-job:
parent_jobs: 'libvirt-glib-master-build'
- autogen_args: --enable-gtk-doc
- autotools-syntax-check-job:
parent_jobs: 'libvirt-sandbox-master-build'
- autotools-check-job:
--
2.17.0
6 years, 5 months
[libvirt] [jenkins-ci PATCH] projects: Reduce scope for local_env
by Andrea Bolognani
The TEST_ARGS environment variable is only used when running
the test suite, which means that local_env can be moved to the
*-check-job instead of being at the top level.
Signed-off-by: Andrea Bolognani <abologna(a)redhat.com>
---
projects/libvirt-go-xml.yaml | 4 ++--
projects/libvirt-go.yaml | 4 ++--
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/projects/libvirt-go-xml.yaml b/projects/libvirt-go-xml.yaml
index 1f26751..8d9c16d 100644
--- a/projects/libvirt-go-xml.yaml
+++ b/projects/libvirt-go-xml.yaml
@@ -3,10 +3,10 @@
name: libvirt-go-xml
machines: '{all_machines}'
title: Libvirt Go XML
- local_env: |
- export TEST_ARGS="-tags xmlroundtrip"
jobs:
- go-build-job:
parent_jobs: 'libvirt-master-build'
- go-check-job:
parent_jobs: 'libvirt-go-xml-master-build'
+ local_env: |
+ export TEST_ARGS="-tags xmlroundtrip"
diff --git a/projects/libvirt-go.yaml b/projects/libvirt-go.yaml
index f40f523..f2eb87e 100644
--- a/projects/libvirt-go.yaml
+++ b/projects/libvirt-go.yaml
@@ -3,10 +3,10 @@
name: libvirt-go
machines: '{all_machines}'
title: Libvirt Go
- local_env: |
- export TEST_ARGS="-tags api"
jobs:
- go-build-job:
parent_jobs: 'libvirt-master-build'
- go-check-job:
parent_jobs: 'libvirt-go-master-build'
+ local_env: |
+ export TEST_ARGS="-tags api"
--
2.17.0
6 years, 5 months
[libvirt] [dbus PATCH 0/4] Implement domain APIs with file descriptors
by Pavel Hrdina
Pavel Hrdina (4):
gdbus: fix memory and FD leak in virtDBusGDBusHandleMethod
domain: Implement CreateWithFiles method
domain: Implement OpenGraphicsFD method
connect: Implement DomainCreateXMLWithFiles method
data/org.libvirt.Connect.xml | 8 +++++
data/org.libvirt.Domain.xml | 13 ++++++++
src/connect.c | 40 ++++++++++++++++++++++
src/domain.c | 64 ++++++++++++++++++++++++++++++++++++
src/gdbus.c | 3 +-
5 files changed, 127 insertions(+), 1 deletion(-)
--
2.17.0
6 years, 5 months
[libvirt] [dbus PATCH] docs: Introduce man file for libvirt-dbus daemon
by Pavel Hrdina
Signed-off-by: Pavel Hrdina <phrdina(a)redhat.com>
---
.gitignore | 2 ++
Makefile.am | 2 +-
configure.ac | 1 +
docs/Makefile.am | 13 +++++++++
docs/libvirt-dbus.pod | 66 +++++++++++++++++++++++++++++++++++++++++++
libvirt-dbus.spec.in | 1 +
6 files changed, 84 insertions(+), 1 deletion(-)
create mode 100644 docs/Makefile.am
create mode 100644 docs/libvirt-dbus.pod
diff --git a/.gitignore b/.gitignore
index c6d9754..0bf09cf 100644
--- a/.gitignore
+++ b/.gitignore
@@ -29,6 +29,8 @@ vgcore.*
/data/system/libvirt-dbus.rules
/data/system/org.libvirt.conf
+/docs/*.1
+
/src/.deps/
/src/libvirt-dbus
/src/org.libvirt.service
diff --git a/Makefile.am b/Makefile.am
index 16f57b2..bb5ff5c 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,5 +1,5 @@
-SUBDIRS = data src tests
+SUBDIRS = data docs src tests
ACLOCAL_AMFLAGS = -I m4
diff --git a/configure.ac b/configure.ac
index cc8947c..707a03e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -74,6 +74,7 @@ AC_CONFIG_FILES([run],
[chmod +x,-w run])
AC_OUTPUT(Makefile
data/Makefile
+ docs/Makefile
src/Makefile
tests/Makefile
libvirt-dbus.spec)
diff --git a/docs/Makefile.am b/docs/Makefile.am
new file mode 100644
index 0000000..c41ffae
--- /dev/null
+++ b/docs/Makefile.am
@@ -0,0 +1,13 @@
+POD2MAN = pod2man -c "Virtualization Support" -r "$(PACKAGE)-$(VERSION)"
+
+PODFILES = libvirt-dbus.pod
+
+%.8: %.pod
+ $(AM_V_GEN)$(POD2MAN) -s 8 $< $@ \
+ && if grep 'POD ERROR' $@; then rm $@; exit 1; fi
+
+man8_MANS = libvirt-dbus.8
+
+EXTRA_DIST = $(PODFILES)
+
+CLEANFILES = $(man8_MANS)
diff --git a/docs/libvirt-dbus.pod b/docs/libvirt-dbus.pod
new file mode 100644
index 0000000..49de044
--- /dev/null
+++ b/docs/libvirt-dbus.pod
@@ -0,0 +1,66 @@
+=head1 NAME
+
+libvirt-dbus - D-Bus daemon exporting libvirt API
+
+=head1 SYNOPSIS
+
+B<libvirt-dbus> [I<OPTION>]...
+
+=head1 DESCRIPTION
+
+libvirt-dbus wraps libvirt API to provide a high-level object-oriented
+API better suited for dbus-based applications.
+
+Normally libvirt-dbus is started by D-Bus daemon on demand.
+
+=head1 OPTIONS
+
+=over
+
+=item B<-h --help>
+
+Display command line help usage then exit.
+
+=item B<--system>
+
+Connect to the system bus.
+
+=item B<--session>
+
+Connect to the session bus.
+
+=item B<-t --threads> I<NUM>
+
+Configure maximal number of worker threads.
+
+=back
+
+=head1 BUGS
+
+Please report all bugs you discover. This should be done via either:
+
+=over
+
+=item a) the mailing list
+
+L<https://libvirt.org/contact.html>
+
+=item b) the bug tracker
+
+L<https://libvirt.org/bugs.html>
+
+=back
+
+Alternatively, you may report bugs to your software distribution / vendor.
+
+=head1 AUTHORS
+
+Please refer to the AUTHORS file distributed with libvirt-dbus.
+
+=head1 LICENSE
+
+libvirt-dbus is Free Software and licenced under LGPLv2+.
+
+=head1 SEE ALSO
+
+L<https://libvirt.org/dbus.html>, L<https://libvirt.org/>
diff --git a/libvirt-dbus.spec.in b/libvirt-dbus.spec.in
index 1543197..45cc617 100644
--- a/libvirt-dbus.spec.in
+++ b/libvirt-dbus.spec.in
@@ -55,5 +55,6 @@ exit 0
%{_datadir}/dbus-1/system-services/org.libvirt.service
%{_datadir}/dbus-1/system.d/org.libvirt.conf
%{_datadir}/dbus-1/interfaces/org.libvirt.*.xml
+%{_mandir}/man8/libvirt-dbus.8*
%changelog
--
2.17.0
6 years, 5 months
[libvirt] [dbus PATCH 00/13] Secret APIs
by Katerina Koukiou
Katerina Koukiou (13):
Introduce Secret Interface
Implement ListSecrets method for Connect Interface
Register Secret Lifecycle Events
Implement UUID property for Secret Interface
Implement UsageID property for Secret Interface
Implement UsageType property for Secret Interface
Implement GetXMLDesc method for Secret Interface
Implement SecretLookupByUUID method for Connect Interface
Implement SecretLookupByUsage method for Connect Interface
Implement Undefine method for Secret Interface
Implement GetValue method for Secret Interface
Implement SetValue method for Secret Interface
Implement SecretDefineXML method for Connect Interface
data/Makefile.am | 1 +
data/org.libvirt.Connect.xml | 33 ++++++
data/org.libvirt.Secret.xml | 44 +++++++
src/Makefile.am | 1 +
src/connect.c | 145 +++++++++++++++++++++++
src/connect.h | 2 +
src/events.c | 42 +++++++
src/secret.c | 270 +++++++++++++++++++++++++++++++++++++++++++
src/secret.h | 9 ++
src/util.c | 33 ++++++
src/util.h | 16 +++
11 files changed, 596 insertions(+)
create mode 100644 data/org.libvirt.Secret.xml
create mode 100644 src/secret.c
create mode 100644 src/secret.h
--
2.15.0
6 years, 5 months
[libvirt] [PATCH] qemu: add sdl opengl support
by Maciej Wolny
Add SDL graphics gl attribute, modify the domain XML schema, add a
test, modify the documentation to include the new option.
Signed-off-by: Maciej Wolny <maciej.wolny(a)codethink.co.uk>
---
docs/schemas/domaincommon.rng | 8 +++++
src/conf/domain_conf.c | 41 ++++++++++++++++++++++
src/conf/domain_conf.h | 1 +
src/qemu/qemu_capabilities.c | 2 ++
src/qemu/qemu_capabilities.h | 1 +
src/qemu/qemu_command.c | 19 ++++++++++
.../qemuxml2argvdata/video-virtio-gpu-sdl-gl.args | 28 +++++++++++++++
tests/qemuxml2argvdata/video-virtio-gpu-sdl-gl.xml | 38 ++++++++++++++++++++
tests/qemuxml2argvtest.c | 5 +++
9 files changed, 143 insertions(+)
create mode 100644 tests/qemuxml2argvdata/video-virtio-gpu-sdl-gl.args
create mode 100644 tests/qemuxml2argvdata/video-virtio-gpu-sdl-gl.xml
diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
index 3569b9212..a2ef93c09 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -3031,6 +3031,14 @@
<ref name="virYesNo"/>
</attribute>
</optional>
+ <optional>
+ <element name="gl">
+ <attribute name="enable">
+ <ref name="virYesNo"/>
+ </attribute>
+ <empty/>
+ </element>
+ </optional>
</group>
<group>
<attribute name="type">
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index b0257068d..7d65ca9df 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -13448,6 +13448,7 @@ static int
virDomainGraphicsDefParseXMLSDL(virDomainGraphicsDefPtr def,
xmlNodePtr node)
{
+ xmlNodePtr cur;
char *fullscreen = virXMLPropString(node, "fullscreen");
int ret = -1;
@@ -13468,6 +13469,34 @@ virDomainGraphicsDefParseXMLSDL(virDomainGraphicsDefPtr def,
def->data.sdl.xauth = virXMLPropString(node, "xauth");
def->data.sdl.display = virXMLPropString(node, "display");
+ cur = node->children;
+ while (cur != NULL) {
+ if (cur->type == XML_ELEMENT_NODE) {
+ if (virXMLNodeNameEqual(cur, "gl")) {
+ char *enable = virXMLPropString(cur, "enable");
+ int enableVal;
+
+ if (!enable) {
+ virReportError(VIR_ERR_XML_ERROR, "%s",
+ _("sdl gl element missing enable"));
+ goto cleanup;
+ }
+
+ enableVal = virTristateBoolTypeFromString(enable);
+ if (enableVal < 0) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+ _("unknown enable value '%s'"), enable);
+ VIR_FREE(enable);
+ goto cleanup;
+ }
+ VIR_FREE(enable);
+
+ def->data.sdl.gl = enableVal;
+ }
+ }
+ cur = cur->next;
+ }
+
ret = 0;
cleanup:
VIR_FREE(fullscreen);
@@ -25652,6 +25681,18 @@ virDomainGraphicsDefFormat(virBufferPtr buf,
if (def->data.sdl.fullscreen)
virBufferAddLit(buf, " fullscreen='yes'");
+ if (!children && def->data.sdl.gl) {
+ virBufferAddLit(buf, ">\n");
+ virBufferAdjustIndent(buf, 2);
+ children = true;
+ }
+
+ if (def->data.sdl.gl) {
+ virBufferAsprintf(buf, "<gl enable='%s'",
+ virTristateBoolTypeToString(def->data.sdl.gl));
+ virBufferAddLit(buf, "/>\n");
+ }
+
break;
case VIR_DOMAIN_GRAPHICS_TYPE_RDP:
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 3c7eccb8c..90071d9c0 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -1601,6 +1601,7 @@ struct _virDomainGraphicsDef {
char *display;
char *xauth;
bool fullscreen;
+ virTristateBool gl;
} sdl;
struct {
int port;
diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index aa8d350f5..02680502e 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -474,6 +474,7 @@ VIR_ENUM_IMPL(virQEMUCaps, QEMU_CAPS_LAST,
"query-cpus-fast",
"disk-write-cache",
"nbd-tls",
+ "sdl-gl",
);
@@ -2451,6 +2452,7 @@ static struct virQEMUCapsCommandLineProps virQEMUCapsCommandLine[] = {
{ "vnc", "vnc", QEMU_CAPS_VNC_MULTI_SERVERS },
{ "chardev", "reconnect", QEMU_CAPS_CHARDEV_RECONNECT },
{ "sandbox", "elevateprivileges", QEMU_CAPS_SECCOMP_BLACKLIST },
+ { "sdl", "gl", QEMU_CAPS_SDL_GL },
};
static int
diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h
index 2afe7ef58..e36611e2a 100644
--- a/src/qemu/qemu_capabilities.h
+++ b/src/qemu/qemu_capabilities.h
@@ -458,6 +458,7 @@ typedef enum { /* virQEMUCapsFlags grouping marker for syntax-check */
QEMU_CAPS_QUERY_CPUS_FAST, /* query-cpus-fast command */
QEMU_CAPS_DISK_WRITE_CACHE, /* qemu block frontends support write-cache param */
QEMU_CAPS_NBD_TLS, /* NBD server supports TLS transport */
+ QEMU_CAPS_SDL_GL, /* -sdl gl */
QEMU_CAPS_LAST /* this must always be the last item */
} virQEMUCapsFlags;
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 418729b98..29214e806 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -7988,6 +7988,7 @@ qemuBuildGraphicsCommandLine(virQEMUDriverConfigPtr cfg,
virQEMUCapsPtr qemuCaps,
virDomainGraphicsDefPtr graphics)
{
+ virBuffer opt = VIR_BUFFER_INITIALIZER;
switch (graphics->type) {
case VIR_DOMAIN_GRAPHICS_TYPE_SDL:
if (graphics->data.sdl.xauth)
@@ -8009,6 +8010,24 @@ qemuBuildGraphicsCommandLine(virQEMUDriverConfigPtr cfg,
* default, since the default changes :-( */
virCommandAddArg(cmd, "-sdl");
+ if (graphics->data.sdl.gl == VIR_TRISTATE_BOOL_YES) {
+ if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_SDL_GL)) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+ _("This QEMU doesn't support SDL OpenGL"));
+ return -1;
+
+ }
+
+ virBufferAsprintf(&opt, "gl=%s",
+ virTristateSwitchTypeToString(graphics->data.sdl.gl));
+ }
+
+ {
+ const char *optContent = virBufferCurrentContent(&opt);
+ if (optContent && STRNEQ(optContent, ""))
+ virCommandAddArgBuffer(cmd, &opt);
+ }
+
break;
case VIR_DOMAIN_GRAPHICS_TYPE_VNC:
diff --git a/tests/qemuxml2argvdata/video-virtio-gpu-sdl-gl.args b/tests/qemuxml2argvdata/video-virtio-gpu-sdl-gl.args
new file mode 100644
index 000000000..4172320ed
--- /dev/null
+++ b/tests/qemuxml2argvdata/video-virtio-gpu-sdl-gl.args
@@ -0,0 +1,28 @@
+LC_ALL=C \
+PATH=/bin \
+HOME=/home/test \
+USER=test \
+LOGNAME=test \
+/usr/bin/qemu-system-i686 \
+-name QEMUGuest1 \
+-S \
+-machine pc,accel=tcg,usb=off,dump-guest-core=off \
+-m 1024 \
+-smp 1,sockets=1,cores=1,threads=1 \
+-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \
+-no-user-config \
+-nodefaults \
+-chardev socket,id=charmonitor,path=/tmp/lib/domain--1-QEMUGuest1/monitor.sock,\
+server,nowait \
+-mon chardev=charmonitor,id=monitor,mode=control \
+-rtc base=utc \
+-no-shutdown \
+-no-acpi \
+-boot c \
+-usb \
+-drive file=/var/lib/libvirt/images/QEMUGuest1,format=qcow2,if=none,\
+id=drive-ide0-0-0,cache=none \
+-device ide-drive,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0 \
+-sdl gl=on \
+-device virtio-gpu-pci,id=video0,virgl=on,bus=pci.0,addr=0x2 \
+-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3
diff --git a/tests/qemuxml2argvdata/video-virtio-gpu-sdl-gl.xml b/tests/qemuxml2argvdata/video-virtio-gpu-sdl-gl.xml
new file mode 100644
index 000000000..9dea73fbe
--- /dev/null
+++ b/tests/qemuxml2argvdata/video-virtio-gpu-sdl-gl.xml
@@ -0,0 +1,38 @@
+<domain type='qemu'>
+ <name>QEMUGuest1</name>
+ <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+ <memory unit='KiB'>1048576</memory>
+ <currentMemory unit='KiB'>1048576</currentMemory>
+ <vcpu placement='static'>1</vcpu>
+ <os>
+ <type arch='i686' machine='pc'>hvm</type>
+ <boot dev='hd'/>
+ </os>
+ <clock offset='utc'/>
+ <on_poweroff>destroy</on_poweroff>
+ <on_reboot>restart</on_reboot>
+ <on_crash>destroy</on_crash>
+ <devices>
+ <emulator>/usr/bin/qemu-system-i686</emulator>
+ <disk type='file' device='disk'>
+ <driver name='qemu' type='qcow2' cache='none'/>
+ <source file='/var/lib/libvirt/images/QEMUGuest1'/>
+ <target dev='hda' bus='ide'/>
+ <address type='drive' controller='0' bus='0' target='0' unit='0'/>
+ </disk>
+ <controller type='ide' index='0'/>
+ <controller type='usb' index='0'/>
+ <controller type='pci' index='0' model='pci-root'/>
+ <input type='mouse' bus='ps2'/>
+ <input type='keyboard' bus='ps2'/>
+ <graphics type='sdl'>
+ <gl enable='yes'/>
+ </graphics>
+ <video>
+ <model type='virtio' heads='1'>
+ <acceleration accel3d='yes'/>
+ </model>
+ </video>
+ <memballoon model='virtio'/>
+ </devices>
+</domain>
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index 5b3bd4a99..0b06699f0 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -1924,6 +1924,11 @@ mymain(void)
QEMU_CAPS_SPICE_GL,
QEMU_CAPS_SPICE_RENDERNODE,
QEMU_CAPS_DEVICE_VIDEO_PRIMARY);
+ DO_TEST("video-virtio-gpu-sdl-gl",
+ QEMU_CAPS_DEVICE_VIRTIO_GPU,
+ QEMU_CAPS_VIRTIO_GPU_VIRGL,
+ QEMU_CAPS_SDL_GL,
+ QEMU_CAPS_DEVICE_VIDEO_PRIMARY);
DO_TEST("video-virtio-gpu-secondary",
QEMU_CAPS_DEVICE_VIRTIO_GPU,
QEMU_CAPS_DEVICE_VIDEO_PRIMARY);
--
2.11.0
6 years, 5 months