[PATCH] virjson: Change virJSONValueObjectHasKey() signature
by Michal Privoznik
Currently, virJSONValueObjectHasKey() can return one of three
values:
-1 if passed object type is not VIR_JSON_TYPE_OBJECT,
0 if the key is not present, and finally
1 if the key is present.
But, neither of callers is interested in the -1 case. In fact,
some callers call this function treating -1 and 1 cases the same.
Therefore, make the function return just true/false and fix few
callers that explicitly checked for == 1 case.
Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
---
src/qemu/qemu_agent.c | 8 ++++----
src/qemu/qemu_monitor_json.c | 10 +++++-----
src/util/virjson.c | 8 ++++----
src/util/virjson.h | 2 +-
4 files changed, 14 insertions(+), 14 deletions(-)
diff --git a/src/qemu/qemu_agent.c b/src/qemu/qemu_agent.c
index d81f01ba77..0d77a2f90d 100644
--- a/src/qemu/qemu_agent.c
+++ b/src/qemu/qemu_agent.c
@@ -231,12 +231,12 @@ qemuAgentIOProcessLine(qemuAgent *agent,
return -1;
}
- if (virJSONValueObjectHasKey(obj, "QMP") == 1) {
+ if (virJSONValueObjectHasKey(obj, "QMP")) {
return 0;
- } else if (virJSONValueObjectHasKey(obj, "event") == 1) {
+ } else if (virJSONValueObjectHasKey(obj, "event")) {
return qemuAgentIOProcessEvent(agent, obj);
- } else if (virJSONValueObjectHasKey(obj, "error") == 1 ||
- virJSONValueObjectHasKey(obj, "return") == 1) {
+ } else if (virJSONValueObjectHasKey(obj, "error") ||
+ virJSONValueObjectHasKey(obj, "return")) {
if (msg) {
if (msg->sync) {
unsigned long long id;
diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
index 941596563a..2469165728 100644
--- a/src/qemu/qemu_monitor_json.c
+++ b/src/qemu/qemu_monitor_json.c
@@ -203,14 +203,14 @@ qemuMonitorJSONIOProcessLine(qemuMonitor *mon,
return -1;
}
- if (virJSONValueObjectHasKey(obj, "QMP") == 1) {
+ if (virJSONValueObjectHasKey(obj, "QMP")) {
return 0;
- } else if (virJSONValueObjectHasKey(obj, "event") == 1) {
+ } else if (virJSONValueObjectHasKey(obj, "event")) {
PROBE(QEMU_MONITOR_RECV_EVENT,
"mon=%p event=%s", mon, line);
return qemuMonitorJSONIOProcessEvent(mon, obj);
- } else if (virJSONValueObjectHasKey(obj, "error") == 1 ||
- virJSONValueObjectHasKey(obj, "return") == 1) {
+ } else if (virJSONValueObjectHasKey(obj, "error") ||
+ virJSONValueObjectHasKey(obj, "return")) {
PROBE(QEMU_MONITOR_RECV_REPLY,
"mon=%p reply=%s", mon, line);
if (msg) {
@@ -270,7 +270,7 @@ qemuMonitorJSONCommandWithFd(qemuMonitor *mon,
memset(&msg, 0, sizeof(msg));
- if (virJSONValueObjectHasKey(cmd, "execute") == 1) {
+ if (virJSONValueObjectHasKey(cmd, "execute")) {
g_autofree char *id = qemuMonitorNextCommandID(mon);
if (virJSONValueObjectAppendString(cmd, "id", id) < 0) {
diff --git a/src/util/virjson.c b/src/util/virjson.c
index 53f8cdff95..ef59b5deb4 100644
--- a/src/util/virjson.c
+++ b/src/util/virjson.c
@@ -798,21 +798,21 @@ virJSONValueArrayConcat(virJSONValue *a,
}
-int
+bool
virJSONValueObjectHasKey(virJSONValue *object,
const char *key)
{
size_t i;
if (object->type != VIR_JSON_TYPE_OBJECT)
- return -1;
+ return false;
for (i = 0; i < object->data.object.npairs; i++) {
if (STREQ(object->data.object.pairs[i].key, key))
- return 1;
+ return true;
}
- return 0;
+ return false;
}
diff --git a/src/util/virjson.h b/src/util/virjson.h
index aced48a538..ce181dcb82 100644
--- a/src/util/virjson.h
+++ b/src/util/virjson.h
@@ -88,7 +88,7 @@ int
virJSONValueArrayConcat(virJSONValue *a,
virJSONValue *c);
-int
+bool
virJSONValueObjectHasKey(virJSONValue *object,
const char *key);
virJSONValue *
--
2.35.1
2 years, 3 months
[libvirt PATCH] qemu: Restore original memory locking limit on reconnect
by Jiri Denemark
Commit v8.4.0-287-gd4d3bb8130 tried to make sure the original
pre-migration memory locking limit is restored at the end of migration,
but it missed the case when libvirt daemon is restarted during
migration which needs to be aborted on reconnect.
And if this was not enough, I forgot to actually save the status XML
after setting the field in priv (in the commit mentioned above and also
in v8.4.0-291-gd375993ab3).
https://bugzilla.redhat.com/show_bug.cgi?id=2107424
Signed-off-by: Jiri Denemark <jdenemar(a)redhat.com>
---
src/qemu/qemu_migration.c | 13 +++++++++----
src/qemu/qemu_process.c | 2 ++
2 files changed, 11 insertions(+), 4 deletions(-)
diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
index 8e9428a5bb..e1f5e49683 100644
--- a/src/qemu/qemu_migration.c
+++ b/src/qemu/qemu_migration.c
@@ -4672,10 +4672,12 @@ qemuMigrationSrcStart(virDomainObj *vm,
switch (spec->destType) {
case MIGRATION_DEST_HOST:
if (STREQ(spec->dest.host.protocol, "rdma") &&
- virMemoryLimitIsSet(vm->def->mem.hard_limit) &&
- qemuDomainSetMaxMemLock(vm, vm->def->mem.hard_limit << 10,
- &priv->preMigrationMemlock) < 0) {
- return -1;
+ virMemoryLimitIsSet(vm->def->mem.hard_limit)) {
+ if (qemuDomainSetMaxMemLock(vm, vm->def->mem.hard_limit << 10,
+ &priv->preMigrationMemlock) < 0)
+ return -1;
+ /* Store the original memory locking limit */
+ qemuDomainSaveStatus(vm);
}
return qemuMonitorMigrateToHost(priv->mon, migrateFlags,
spec->dest.host.protocol,
@@ -4868,6 +4870,9 @@ qemuMigrationSrcRun(virQEMUDriver *driver,
if (qemuDomainSetMaxMemLock(vm, limit << 10, &priv->preMigrationMemlock) < 0)
goto error;
+
+ /* Store the original memory locking limit */
+ qemuDomainSaveStatus(vm);
}
if (storageMigration) {
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index d42333195a..137dcf5cf4 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -3678,6 +3678,7 @@ qemuProcessRecoverMigration(virQEMUDriver *driver,
{
virDomainJobStatus migStatus = VIR_DOMAIN_JOB_STATUS_NONE;
qemuDomainJobPrivate *jobPriv = job->privateData;
+ qemuDomainObjPrivate *priv = vm->privateData;
virDomainState state;
int reason;
int rc;
@@ -3727,6 +3728,7 @@ qemuProcessRecoverMigration(virQEMUDriver *driver,
qemuMigrationParamsReset(driver, vm, VIR_ASYNC_JOB_NONE,
jobPriv->migParams, job->apiFlags);
+ qemuDomainSetMaxMemLock(vm, 0, &priv->preMigrationMemlock);
return 0;
}
--
2.35.1
2 years, 3 months
[PATCH] qemu: don't call qemuMigrationSrcIsAllowedHostdev() from qemuMigrationDstPrepareFresh()
by Laine Stump
This call to qemuMigrationSrcIsAllowedHostdev() (which does a
hardcoded fail of the migration if there is any PCI or mdev hostdev
device in the domain) while doing the destination side of migration
prep was found once the call to that same function was removed from
the source side migration prep (commit 25883cd5).
According to jdenemar, for the V2 migration protocol, prep of the
destination is the first step, so this *was* the proper place to do
the check, but for V3 migration this is in a way redundant (since we
will have already done the check on the source side (updated by
25883cd5 to query QEMU rather than do a hardcoded fail)).
Of course it's possible that the source could support migration of a
particular VFIO device, but the destination doesn't. But the current
check on the destination side is worthless even in that case, since it
is just *always* failing rather than querying QEMU; and QEMU can't be
queried at the point where the destination check is happening, since
it isn't yet running.
Anyway QEMU should complain when it's started if it's going to fail,
so removing this check should just move the failure to happen a bit
later. So the best solution to this problem is to simply remove the
hardcoded check/fail from qemuMigrationDstPrepareFresh() and rely on
QEMU to fail if it needs to.
Fixes: 25883cd5f0b188f2417f294b7d219a77b219f7c2
Signed-off-by: Laine Stump <laine(a)redhat.com>
---
src/qemu/qemu_migration.c | 3 ---
1 file changed, 3 deletions(-)
diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
index 20dc91f1ce..85b6b12f92 100644
--- a/src/qemu/qemu_migration.c
+++ b/src/qemu/qemu_migration.c
@@ -3379,9 +3379,6 @@ qemuMigrationDstPrepareFresh(virQEMUDriver *driver,
QEMU_MIGRATION_COOKIE_CAPS;
}
- if (!qemuMigrationSrcIsAllowedHostdev(*def))
- goto cleanup;
-
/* Let migration hook filter domain XML */
if (virHookPresent(VIR_HOOK_DRIVER_QEMU)) {
g_autofree char *xml = NULL;
--
2.35.3
2 years, 3 months
[libvirt PATCH for 8.6.0] qemu: Properly release job in qemuDomainSaveInternal
by Jiri Denemark
The function would fail to release the job in case
qemuMigrationSrcIsAllowed failed.
Fixes v8.5.0-157-g69e0e33873
Signed-off-by: Jiri Denemark <jdenemar(a)redhat.com>
---
src/qemu/qemu_driver.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 9013e6fb8d..019ec4a035 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -2656,7 +2656,7 @@ qemuDomainSaveInternal(virQEMUDriver *driver,
goto cleanup;
if (!qemuMigrationSrcIsAllowed(driver, vm, false, VIR_ASYNC_JOB_SAVE, 0))
- goto cleanup;
+ goto endjob;
if (!virDomainObjIsActive(vm)) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
--
2.35.1
2 years, 3 months
[PATCH v2 0/2] docs: Document reviewing and issue handling
by Peter Krempa
Following changes to the respective v1 versions of these patches:
Peter Krempa (2):
docs: patches: Add a note about reviews and contacting developers
- followed Erik's suggestion to add bulletpoint instead of a blob
of text
docs: Add article about handling upstream issues
(previously not reviewed)
- fixed spelling and re-formulated some sentences
docs/docs.rst | 3 +
docs/issue-handling.rst | 174 ++++++++++++++++++++++++++++++++++++
docs/meson.build | 1 +
docs/submitting-patches.rst | 22 +++++
4 files changed, 200 insertions(+)
create mode 100644 docs/issue-handling.rst
--
2.36.1
2 years, 3 months
[PATCH 0/3] qemu: add an API for "query-stats" QMP command
by Amneesh Singh
QEMU is gaining introspectable statistics which can be queried via the
"query-stats" QMP command. This patchset aims to add an API for the
same.
The returned JSON for "query-stats" is an array of objects containing
their own respective array of statistics.
Patch 1 adds the API which returns the deserialized JSON in the form of
a GPtrArray of GHashTables.
Patch 2 adds the "query-stats" to QEMU capabilities.
Patch 3 uses the API to query the halt poll success time and the halt
poll failure time.
v2 -> v3
========
Sorry for the late patchset, I was under the impression I had sent it on
Monday but apparently, I did not.
[1/3]:
- use a single enum for all the statistics.
- use QEMU_MONITOR_QUERY_STATS_NAME_LAST as the sentinel value for the
provider constructor.
- relevant changes to enum values.
[2/3]:
- fix comment spacing
[3/3]
- better checks
v1 -> v2
========
I have been tinkering with the v1 patchset and have rewrote the v2
patches a couple of times. I believe the current patchset is still not
perfect and would appreciate some reviews.
I have another patch or two written but they do not make any significant
changes to the current patchset.
[1/3]:
- use virBitmap instead of an array of strings for statistics.
- add enums for the stat names and add
qemuMonitorQueryStatsNameTypeToString to switch between the
"ToString" functions based on the target type.
- change qemuMonitorQueryStatsProviderNew to a variadic function that
takes stat enum values with the sentinel value being -1.
[2/3]:
- No changes
[3/3]:
- Add relevant monitor related checks to check if the domain is
active.
- Acquire and release qemuMonitorObj lock before and after calling
qemuMonitorQueryStats respectively.
- Add the check for privileged access.
Relevant QEMU patches can be found here:
https://lore.kernel.org/all/20220530150714.756954-1-pbonzini@redhat.com/
This patchset is part of the 2022 GSOC contributor project.
Amneesh Singh (3):
qemu_monitor: add qemuMonitorQueryStats
qemu_capabilities: add "query-stats" QMP command to the QEMU
capabilities
qemu_driver: use qemuMonitorQueryStats to extract halt poll time
src/qemu/qemu_capabilities.c | 2 +
src/qemu/qemu_capabilities.h | 1 +
src/qemu/qemu_driver.c | 69 ++++++++++++++++---
src/qemu/qemu_monitor.c | 70 +++++++++++++++++++
src/qemu/qemu_monitor.h | 45 ++++++++++++
src/qemu/qemu_monitor_json.c | 130 +++++++++++++++++++++++++++++++++++
src/qemu/qemu_monitor_json.h | 6 ++
7 files changed, 315 insertions(+), 8 deletions(-)
--
2.36.1
2 years, 3 months
[libvirt][PATCH v13 0/6] Support query and use SGX
by Lin Yang
This patch series provides support for enabling Intel's Software Guard
Extensions (SGX) feature in guest VM.
Giving the SGX support in QEMU had been merged. Intel SGX is a set of
instructions that increases the security of application code and data,
giving them more protection from disclosure or modification.
Developers can partition sensitive information into enclaves, which
are areas of execution in memory with more security protection.
The typical flow looks below at very high level:
1. Calls virConnectGetDomainCapabilities API to domain capabilities
that includes the following SGX information.
<feature>
...
<sgx supported='yes'>
<flc>no</flc>
<sgx1>yes</sgx1>
<sgx2>no</sgx2>
<section_size>2</section_size>
<sections>
<section node='0' size='1'/>
<section node='1' size='1'/>
</sections>
</sgx>
...
</feature>
2. User requests to start a guest calling virCreateXML() with SGX
requirement. It supports both non-NUMA SGX interface in QEMU 6.2.0
and NUMA SGX interface in QEMU 7.0.0 and later version.
Without NUMA info:
<devices>
...
<memory model='sgx-epc'>
<target>
<size unit='KiB'>N</size>
</target>
</memory>
...
</devices>
With NUMA info:
<devices>
...
<memory model='sgx-epc'>
<source>
<nodemask>0-1</nodemask>
</source>
<target>
<size unit='KiB'>16384</size>
<node>0</node>
</target>
</memory>
...
</devices>
Please note that it assumes EPC target node in guest VM (.node
attribute) is not required in SGX related parameter in QEMU command
if QEMU didn't provide any SGX NUMA info, like QEMU 6.2.0 version.
Haibin Huang (4):
Define SGX capabilities structs
Get SGX capabilities form QMP
Convert QMP capabilities to domain capabilities
conf: expose SGX feature in domain capabilities
Lin Yang (2):
conf: Introduce SGX EPC element into device memory xml
qemu: Add command-line to generate SGX EPC memory backend
docs/formatdomain.rst | 27 +-
docs/formatdomaincaps.rst | 40 +++
src/conf/domain_capabilities.c | 58 ++++
src/conf/domain_capabilities.h | 24 ++
src/conf/domain_conf.c | 27 ++
src/conf/domain_conf.h | 1 +
src/conf/domain_validate.c | 9 +
src/conf/schemas/domaincaps.rng | 42 +++
src/conf/schemas/domaincommon.rng | 1 +
src/libvirt_private.syms | 1 +
src/qemu/qemu_alias.c | 6 +-
src/qemu/qemu_capabilities.c | 258 ++++++++++++++++++
src/qemu/qemu_capabilities.h | 4 +
src/qemu/qemu_command.c | 87 +++++-
src/qemu/qemu_domain.c | 48 +++-
src/qemu/qemu_domain_address.c | 6 +
src/qemu/qemu_driver.c | 1 +
src/qemu/qemu_monitor.c | 10 +
src/qemu/qemu_monitor.h | 3 +
src/qemu/qemu_monitor_json.c | 154 ++++++++++-
src/qemu/qemu_monitor_json.h | 4 +
src/qemu/qemu_process.c | 2 +
src/qemu/qemu_validate.c | 8 +
src/security/security_apparmor.c | 1 +
src/security/security_dac.c | 2 +
src/security/security_selinux.c | 2 +
tests/domaincapsdata/bhyve_basic.x86_64.xml | 1 +
tests/domaincapsdata/bhyve_fbuf.x86_64.xml | 1 +
tests/domaincapsdata/bhyve_uefi.x86_64.xml | 1 +
tests/domaincapsdata/empty.xml | 1 +
tests/domaincapsdata/libxl-xenfv.xml | 1 +
tests/domaincapsdata/libxl-xenpv.xml | 1 +
.../domaincapsdata/qemu_2.11.0-q35.x86_64.xml | 1 +
.../domaincapsdata/qemu_2.11.0-tcg.x86_64.xml | 1 +
tests/domaincapsdata/qemu_2.11.0.s390x.xml | 1 +
tests/domaincapsdata/qemu_2.11.0.x86_64.xml | 1 +
.../domaincapsdata/qemu_2.12.0-q35.x86_64.xml | 1 +
.../domaincapsdata/qemu_2.12.0-tcg.x86_64.xml | 1 +
.../qemu_2.12.0-virt.aarch64.xml | 1 +
tests/domaincapsdata/qemu_2.12.0.aarch64.xml | 1 +
tests/domaincapsdata/qemu_2.12.0.ppc64.xml | 1 +
tests/domaincapsdata/qemu_2.12.0.s390x.xml | 1 +
tests/domaincapsdata/qemu_2.12.0.x86_64.xml | 1 +
.../domaincapsdata/qemu_3.0.0-q35.x86_64.xml | 1 +
.../domaincapsdata/qemu_3.0.0-tcg.x86_64.xml | 1 +
tests/domaincapsdata/qemu_3.0.0.ppc64.xml | 1 +
tests/domaincapsdata/qemu_3.0.0.s390x.xml | 1 +
tests/domaincapsdata/qemu_3.0.0.x86_64.xml | 1 +
.../domaincapsdata/qemu_3.1.0-q35.x86_64.xml | 1 +
.../domaincapsdata/qemu_3.1.0-tcg.x86_64.xml | 1 +
tests/domaincapsdata/qemu_3.1.0.ppc64.xml | 1 +
tests/domaincapsdata/qemu_3.1.0.x86_64.xml | 1 +
.../domaincapsdata/qemu_4.0.0-q35.x86_64.xml | 1 +
.../domaincapsdata/qemu_4.0.0-tcg.x86_64.xml | 1 +
.../qemu_4.0.0-virt.aarch64.xml | 1 +
tests/domaincapsdata/qemu_4.0.0.aarch64.xml | 1 +
tests/domaincapsdata/qemu_4.0.0.ppc64.xml | 1 +
tests/domaincapsdata/qemu_4.0.0.s390x.xml | 1 +
tests/domaincapsdata/qemu_4.0.0.x86_64.xml | 1 +
.../domaincapsdata/qemu_4.1.0-q35.x86_64.xml | 1 +
.../domaincapsdata/qemu_4.1.0-tcg.x86_64.xml | 1 +
tests/domaincapsdata/qemu_4.1.0.x86_64.xml | 1 +
.../domaincapsdata/qemu_4.2.0-q35.x86_64.xml | 1 +
.../domaincapsdata/qemu_4.2.0-tcg.x86_64.xml | 1 +
.../qemu_4.2.0-virt.aarch64.xml | 1 +
tests/domaincapsdata/qemu_4.2.0.aarch64.xml | 1 +
tests/domaincapsdata/qemu_4.2.0.ppc64.xml | 1 +
tests/domaincapsdata/qemu_4.2.0.s390x.xml | 1 +
tests/domaincapsdata/qemu_4.2.0.x86_64.xml | 1 +
.../domaincapsdata/qemu_5.0.0-q35.x86_64.xml | 1 +
.../domaincapsdata/qemu_5.0.0-tcg.x86_64.xml | 1 +
.../qemu_5.0.0-virt.aarch64.xml | 1 +
tests/domaincapsdata/qemu_5.0.0.aarch64.xml | 1 +
tests/domaincapsdata/qemu_5.0.0.ppc64.xml | 1 +
tests/domaincapsdata/qemu_5.0.0.x86_64.xml | 1 +
.../domaincapsdata/qemu_5.1.0-q35.x86_64.xml | 1 +
.../domaincapsdata/qemu_5.1.0-tcg.x86_64.xml | 1 +
tests/domaincapsdata/qemu_5.1.0.sparc.xml | 1 +
tests/domaincapsdata/qemu_5.1.0.x86_64.xml | 1 +
.../domaincapsdata/qemu_5.2.0-q35.x86_64.xml | 1 +
.../domaincapsdata/qemu_5.2.0-tcg.x86_64.xml | 1 +
.../qemu_5.2.0-virt.aarch64.xml | 1 +
tests/domaincapsdata/qemu_5.2.0.aarch64.xml | 1 +
tests/domaincapsdata/qemu_5.2.0.ppc64.xml | 1 +
tests/domaincapsdata/qemu_5.2.0.s390x.xml | 1 +
tests/domaincapsdata/qemu_5.2.0.x86_64.xml | 1 +
.../domaincapsdata/qemu_6.0.0-q35.x86_64.xml | 1 +
.../domaincapsdata/qemu_6.0.0-tcg.x86_64.xml | 1 +
.../qemu_6.0.0-virt.aarch64.xml | 1 +
tests/domaincapsdata/qemu_6.0.0.aarch64.xml | 1 +
tests/domaincapsdata/qemu_6.0.0.s390x.xml | 1 +
tests/domaincapsdata/qemu_6.0.0.x86_64.xml | 1 +
.../domaincapsdata/qemu_6.1.0-q35.x86_64.xml | 1 +
.../domaincapsdata/qemu_6.1.0-tcg.x86_64.xml | 1 +
tests/domaincapsdata/qemu_6.1.0.x86_64.xml | 1 +
.../domaincapsdata/qemu_6.2.0-q35.x86_64.xml | 6 +
.../domaincapsdata/qemu_6.2.0-tcg.x86_64.xml | 6 +
.../qemu_6.2.0-virt.aarch64.xml | 1 +
tests/domaincapsdata/qemu_6.2.0.aarch64.xml | 1 +
tests/domaincapsdata/qemu_6.2.0.ppc64.xml | 1 +
tests/domaincapsdata/qemu_6.2.0.x86_64.xml | 6 +
.../domaincapsdata/qemu_7.0.0-q35.x86_64.xml | 10 +
.../domaincapsdata/qemu_7.0.0-tcg.x86_64.xml | 10 +
.../qemu_7.0.0-virt.aarch64.xml | 1 +
tests/domaincapsdata/qemu_7.0.0.aarch64.xml | 1 +
tests/domaincapsdata/qemu_7.0.0.ppc64.xml | 1 +
tests/domaincapsdata/qemu_7.0.0.x86_64.xml | 10 +
.../domaincapsdata/qemu_7.1.0-q35.x86_64.xml | 10 +
.../domaincapsdata/qemu_7.1.0-tcg.x86_64.xml | 10 +
tests/domaincapsdata/qemu_7.1.0.x86_64.xml | 10 +
.../caps_6.2.0.x86_64.replies | 30 +-
.../caps_6.2.0.x86_64.xml | 7 +
.../caps_7.0.0.x86_64.replies | 34 ++-
.../caps_7.0.0.x86_64.xml | 11 +
.../caps_7.1.0.x86_64.replies | 34 ++-
.../caps_7.1.0.x86_64.xml | 11 +
.../sgx-epc-numa.x86_64-latest.args | 40 +++
tests/qemuxml2argvdata/sgx-epc-numa.xml | 50 ++++
.../sgx-epc.x86_64-6.2.0.args | 37 +++
tests/qemuxml2argvdata/sgx-epc.xml | 36 +++
tests/qemuxml2argvtest.c | 3 +
.../sgx-epc-numa.x86_64-latest.xml | 64 +++++
.../sgx-epc.x86_64-6.2.0.xml | 52 ++++
tests/qemuxml2xmltest.c | 3 +
124 files changed, 1349 insertions(+), 42 deletions(-)
create mode 100644 tests/qemuxml2argvdata/sgx-epc-numa.x86_64-latest.args
create mode 100644 tests/qemuxml2argvdata/sgx-epc-numa.xml
create mode 100644 tests/qemuxml2argvdata/sgx-epc.x86_64-6.2.0.args
create mode 100644 tests/qemuxml2argvdata/sgx-epc.xml
create mode 100644 tests/qemuxml2xmloutdata/sgx-epc-numa.x86_64-latest.xml
create mode 100644 tests/qemuxml2xmloutdata/sgx-epc.x86_64-6.2.0.xml
--
2.25.1
2 years, 3 months
[PATCH v2] coding-style: Allow some use of ternary operators
by Michal Privoznik
While we all understand that excessive use of ternary operator
may worsen code readability (e.g. nested, multi-line expression),
there are few cases where using it actually improves code
readability. For instance, when a function takes a long list of
arguments out of which one depends on a boolean expression, or
when formatting "yes"/"no" or "on"/"off" values based on a
boolean variable (although one can argue that the latter is a
subset of the former). Just consider alternatives to:
virBufferAsprintf(buf, "<elem>%s</elem>\n", boolVar ? "yes" : "no");
In fact, this pattern occurs plenty in our code. Exempt it from
our "no ternary operators" rule.
Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
Reviewed-by: Claudio Fontana <cfontana(a)suse.de>
---
v2 of:
https://listman.redhat.com/archives/libvir-list/2022-July/233150.html
diff to v1:
- Changed wording, as suggested by Daniel.
docs/coding-style.rst | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/docs/coding-style.rst b/docs/coding-style.rst
index bf0a80fbc5..81bd4474f1 100644
--- a/docs/coding-style.rst
+++ b/docs/coding-style.rst
@@ -470,7 +470,9 @@ Pointer comparisons may be shortened. All long forms are okay.
if (!foo) # or: if (foo == NULL)
New code should avoid the ternary operator as much as possible.
-Specifically it must never span more than one line or nest:
+Its usage in basic cases is warranted (e.g. when deciding between
+two constant strings), however, it must never span more than one
+line or nest.
::
@@ -481,6 +483,9 @@ Specifically it must never span more than one line or nest:
char *foo = bar ? bar->baz ? bar->baz->foo : "nobaz" : "nobar";
+ GOOD:
+ virBufferAsprintf(buf, "<element>%s</element>\n", boolVar ? "yes" : "no");
+
Preprocessor
------------
--
2.35.1
2 years, 4 months
[PATCH 0/5] qemu: Migration code (ternary operator) cleanups
by Peter Krempa
I've noticed few things that could be improved during review of Jirka's
post copy migration changes but didn't want to interfer with the series
at that point.
Peter Krempa (5):
qemuMigrationDstFinishFresh: Avoid multi-line ternary operator in
function call
qemuMigrationDstPersist: Avoid multi-line ternary operator in function
call
qemu: migration: Overwrite 'dname' only when NULL
qemuMigrationSrcIOFunc: Avoid unnecessary string construction
qemu: monitor: Split up enum strings definitions
src/qemu/qemu_migration.c | 37 +++++++++++++++++++++++--------------
src/qemu/qemu_monitor.c | 35 ++++++++++++++++++++++++++---------
2 files changed, 49 insertions(+), 23 deletions(-)
--
2.36.1
2 years, 4 months