[PATCH v2] qemu: Rewrite code to the pattern
by Kristina Hanicova
I have seen this pattern a lot in the project, so I decided to
rewrite code I stumbled upon to the same pattern as well.
Signed-off-by: Kristina Hanicova <khanicov(a)redhat.com>
---
This is v2 of: https://listman.redhat.com/archives/libvir-list/2021-November/msg00747.html
Diff to v1:
* adding variable 'rc' to fix buggy code and keep the code
equivalent (suggested by Jano)
src/qemu/qemu_driver.c | 22 +++++++++-------------
1 file changed, 9 insertions(+), 13 deletions(-)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 1959b639da..5c4b493f64 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -15975,6 +15975,7 @@ qemuDomainSetBlockIoTune(virDomainPtr dom,
g_autofree char *drivealias = NULL;
const char *qdevid = NULL;
int ret = -1;
+ int rc = 0;
size_t i;
virDomainDiskDef *conf_disk = NULL;
virDomainDiskDef *disk;
@@ -16229,13 +16230,10 @@ qemuDomainSetBlockIoTune(virDomainPtr dom,
!virStorageSourceIsEmpty(disk->src)) {
qemuDomainObjEnterMonitor(driver, vm);
- ret = qemuMonitorSetBlockIoThrottle(priv->mon, drivealias, qdevid,
- &info);
- if (qemuDomainObjExitMonitor(driver, vm) < 0)
- ret = -1;
- if (ret < 0)
+ rc = qemuMonitorSetBlockIoThrottle(priv->mon, drivealias, qdevid, &info);
+
+ if (qemuDomainObjExitMonitor(driver, vm) < 0 || rc < 0)
goto endjob;
- ret = -1;
}
virDomainDiskSetBlockIOTune(disk, &info);
@@ -16310,6 +16308,7 @@ qemuDomainGetBlockIoTune(virDomainPtr dom,
g_autofree char *drivealias = NULL;
const char *qdevid = NULL;
int ret = -1;
+ int rc = 0;
int maxparams;
virCheckFlags(VIR_DOMAIN_AFFECT_LIVE |
@@ -16361,10 +16360,9 @@ qemuDomainGetBlockIoTune(virDomainPtr dom,
goto endjob;
}
qemuDomainObjEnterMonitor(driver, vm);
- ret = qemuMonitorGetBlockIoThrottle(priv->mon, drivealias, qdevid, &reply);
- if (qemuDomainObjExitMonitor(driver, vm) < 0)
- goto endjob;
- if (ret < 0)
+ rc = qemuMonitorGetBlockIoThrottle(priv->mon, drivealias, qdevid, &reply);
+
+ if (qemuDomainObjExitMonitor(driver, vm) < 0 || rc < 0)
goto endjob;
}
@@ -17375,10 +17373,8 @@ qemuDomainSetTime(virDomainPtr dom,
if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_RTC_RESET_REINJECTION)) {
qemuDomainObjEnterMonitor(driver, vm);
rv = qemuMonitorRTCResetReinjection(priv->mon);
- if (qemuDomainObjExitMonitor(driver, vm) < 0)
- goto endjob;
- if (rv < 0)
+ if (qemuDomainObjExitMonitor(driver, vm) < 0 || rv < 0)
goto endjob;
}
--
2.31.1
3 years, 1 month
[PATCH] util: fix cache invalidation of swtpm capabilities
by Daniel P. Berrangé
The check for whether the swtpm binary was modified is checking pointers
to the mtime field in two distinct structs, so will always compare
different. This resulted in re-probing swtpm capabilities every time,
as many as 20 times for a single VM launch.
Fixes:
commit 01cf7a1bb9f1da27ad8bcbaa82c4f7a948c6a793
Author: Stefan Berger <stefanb(a)us.ibm.com>
Date: Thu Jul 25 14:22:04 2019 -0400
tpm: Check whether previously found executables were updated
Signed-off-by: Daniel P. Berrangé <berrange(a)redhat.com>
---
src/util/virtpm.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/util/virtpm.c b/src/util/virtpm.c
index 8a77ba98ff..ffec23a535 100644
--- a/src/util/virtpm.c
+++ b/src/util/virtpm.c
@@ -301,7 +301,7 @@ virTPMEmulatorInit(void)
findit = true;
if (!findit &&
- &statbuf.st_mtime != &prgs[i].stat->st_mtime)
+ statbuf.st_mtime != prgs[i].stat->st_mtime)
findit = true;
}
--
2.33.1
3 years, 1 month
[PATCH] qemu: Rewrite code to the pattern
by Kristina Hanicova
I have seen this pattern a lot in the project, so I decided to
rewrite code I stumbled upon to the same pattern as well.
Signed-off-by: Kristina Hanicova <khanicov(a)redhat.com>
---
src/qemu/qemu_driver.c | 14 ++++----------
1 file changed, 4 insertions(+), 10 deletions(-)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 1959b639da..b938687189 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -16231,10 +16231,9 @@ qemuDomainSetBlockIoTune(virDomainPtr dom,
qemuDomainObjEnterMonitor(driver, vm);
ret = qemuMonitorSetBlockIoThrottle(priv->mon, drivealias, qdevid,
&info);
- if (qemuDomainObjExitMonitor(driver, vm) < 0)
- ret = -1;
- if (ret < 0)
+ if (qemuDomainObjExitMonitor(driver, vm) < 0 || ret < 0)
goto endjob;
+
ret = -1;
}
@@ -16362,9 +16361,7 @@ qemuDomainGetBlockIoTune(virDomainPtr dom,
}
qemuDomainObjEnterMonitor(driver, vm);
ret = qemuMonitorGetBlockIoThrottle(priv->mon, drivealias, qdevid, &reply);
- if (qemuDomainObjExitMonitor(driver, vm) < 0)
- goto endjob;
- if (ret < 0)
+ if (qemuDomainObjExitMonitor(driver, vm) < 0 || ret < 0)
goto endjob;
}
@@ -17375,10 +17372,7 @@ qemuDomainSetTime(virDomainPtr dom,
if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_RTC_RESET_REINJECTION)) {
qemuDomainObjEnterMonitor(driver, vm);
rv = qemuMonitorRTCResetReinjection(priv->mon);
- if (qemuDomainObjExitMonitor(driver, vm) < 0)
- goto endjob;
-
- if (rv < 0)
+ if (qemuDomainObjExitMonitor(driver, vm) < 0 || rv < 0)
goto endjob;
}
--
2.31.1
3 years, 1 month
[libvirt PATCH 0/3] Expose TPM availability in domain capabilities
by Daniel P. Berrangé
If we can report whuether TPM is available, then mgmt apps can enable it
by default for new VMs. This is important because OS like Win11 consider
TPM to be mandatory.
Daniel P. Berrangé (3):
conf: add TPM devices to domain capabilities
qemu: fill in domain capabilities for TPMs
qemu: mock swtpm initialization in tests
docs/schemas/domaincaps.rng | 10 ++++++
src/conf/domain_capabilities.c | 14 ++++++++
src/conf/domain_capabilities.h | 10 ++++++
src/qemu/qemu_capabilities.c | 32 +++++++++++++++++++
src/qemu/qemu_capabilities.h | 3 ++
.../domaincapsdata/qemu_2.11.0-q35.x86_64.xml | 9 ++++++
.../domaincapsdata/qemu_2.11.0-tcg.x86_64.xml | 9 ++++++
tests/domaincapsdata/qemu_2.11.0.s390x.xml | 6 ++++
tests/domaincapsdata/qemu_2.11.0.x86_64.xml | 9 ++++++
.../domaincapsdata/qemu_2.12.0-q35.x86_64.xml | 10 ++++++
.../domaincapsdata/qemu_2.12.0-tcg.x86_64.xml | 10 ++++++
.../qemu_2.12.0-virt.aarch64.xml | 6 ++++
tests/domaincapsdata/qemu_2.12.0.aarch64.xml | 6 ++++
tests/domaincapsdata/qemu_2.12.0.ppc64.xml | 6 ++++
tests/domaincapsdata/qemu_2.12.0.s390x.xml | 6 ++++
tests/domaincapsdata/qemu_2.12.0.x86_64.xml | 10 ++++++
.../domaincapsdata/qemu_3.0.0-q35.x86_64.xml | 10 ++++++
.../domaincapsdata/qemu_3.0.0-tcg.x86_64.xml | 10 ++++++
tests/domaincapsdata/qemu_3.0.0.ppc64.xml | 6 ++++
tests/domaincapsdata/qemu_3.0.0.s390x.xml | 6 ++++
tests/domaincapsdata/qemu_3.0.0.x86_64.xml | 10 ++++++
.../domaincapsdata/qemu_3.1.0-q35.x86_64.xml | 10 ++++++
.../domaincapsdata/qemu_3.1.0-tcg.x86_64.xml | 10 ++++++
tests/domaincapsdata/qemu_3.1.0.ppc64.xml | 6 ++++
tests/domaincapsdata/qemu_3.1.0.x86_64.xml | 10 ++++++
.../domaincapsdata/qemu_4.0.0-q35.x86_64.xml | 10 ++++++
.../domaincapsdata/qemu_4.0.0-tcg.x86_64.xml | 10 ++++++
.../qemu_4.0.0-virt.aarch64.xml | 4 +++
tests/domaincapsdata/qemu_4.0.0.aarch64.xml | 4 +++
tests/domaincapsdata/qemu_4.0.0.ppc64.xml | 4 +++
tests/domaincapsdata/qemu_4.0.0.s390x.xml | 4 +++
tests/domaincapsdata/qemu_4.0.0.x86_64.xml | 10 ++++++
.../domaincapsdata/qemu_4.1.0-q35.x86_64.xml | 10 ++++++
.../domaincapsdata/qemu_4.1.0-tcg.x86_64.xml | 10 ++++++
tests/domaincapsdata/qemu_4.1.0.x86_64.xml | 10 ++++++
.../domaincapsdata/qemu_4.2.0-q35.x86_64.xml | 10 ++++++
.../domaincapsdata/qemu_4.2.0-tcg.x86_64.xml | 10 ++++++
.../qemu_4.2.0-virt.aarch64.xml | 4 +++
tests/domaincapsdata/qemu_4.2.0.aarch64.xml | 4 +++
tests/domaincapsdata/qemu_4.2.0.ppc64.xml | 6 ++++
tests/domaincapsdata/qemu_4.2.0.s390x.xml | 4 +++
tests/domaincapsdata/qemu_4.2.0.x86_64.xml | 10 ++++++
.../domaincapsdata/qemu_5.0.0-q35.x86_64.xml | 10 ++++++
.../domaincapsdata/qemu_5.0.0-tcg.x86_64.xml | 10 ++++++
.../qemu_5.0.0-virt.aarch64.xml | 9 ++++++
tests/domaincapsdata/qemu_5.0.0.aarch64.xml | 9 ++++++
tests/domaincapsdata/qemu_5.0.0.ppc64.xml | 10 ++++++
tests/domaincapsdata/qemu_5.0.0.x86_64.xml | 10 ++++++
.../domaincapsdata/qemu_5.1.0-q35.x86_64.xml | 10 ++++++
.../domaincapsdata/qemu_5.1.0-tcg.x86_64.xml | 10 ++++++
tests/domaincapsdata/qemu_5.1.0.sparc.xml | 4 +++
tests/domaincapsdata/qemu_5.1.0.x86_64.xml | 10 ++++++
.../domaincapsdata/qemu_5.2.0-q35.x86_64.xml | 10 ++++++
.../domaincapsdata/qemu_5.2.0-tcg.x86_64.xml | 10 ++++++
.../qemu_5.2.0-virt.aarch64.xml | 9 ++++++
tests/domaincapsdata/qemu_5.2.0.aarch64.xml | 9 ++++++
tests/domaincapsdata/qemu_5.2.0.ppc64.xml | 10 ++++++
tests/domaincapsdata/qemu_5.2.0.s390x.xml | 4 +++
tests/domaincapsdata/qemu_5.2.0.x86_64.xml | 10 ++++++
.../domaincapsdata/qemu_6.0.0-q35.x86_64.xml | 10 ++++++
.../domaincapsdata/qemu_6.0.0-tcg.x86_64.xml | 10 ++++++
.../qemu_6.0.0-virt.aarch64.xml | 9 ++++++
tests/domaincapsdata/qemu_6.0.0.aarch64.xml | 9 ++++++
tests/domaincapsdata/qemu_6.0.0.s390x.xml | 4 +++
tests/domaincapsdata/qemu_6.0.0.x86_64.xml | 10 ++++++
.../domaincapsdata/qemu_6.1.0-q35.x86_64.xml | 10 ++++++
.../domaincapsdata/qemu_6.1.0-tcg.x86_64.xml | 10 ++++++
tests/domaincapsdata/qemu_6.1.0.x86_64.xml | 10 ++++++
.../domaincapsdata/qemu_6.2.0-q35.x86_64.xml | 10 ++++++
.../domaincapsdata/qemu_6.2.0-tcg.x86_64.xml | 10 ++++++
.../qemu_6.2.0-virt.aarch64.xml | 9 ++++++
tests/domaincapsdata/qemu_6.2.0.aarch64.xml | 9 ++++++
tests/domaincapsdata/qemu_6.2.0.ppc64.xml | 10 ++++++
tests/domaincapsdata/qemu_6.2.0.x86_64.xml | 10 ++++++
tests/domaincapstest.c | 9 ++++++
75 files changed, 661 insertions(+)
--
2.33.1
3 years, 1 month
[PATCH] util: virExec may blocked by reading pipe if grandchild prematurely exit
by Yi Wang
From: Xu Chao <xu.chao6(a)zte.com.cn>
When VIR_EXEC_DAEMON is set, if virPidFileAcquirePath/virSetInherit failed,
then pipesync[0] can not be closed when granchild process exit, because
pipesync[1] still opened in child process. and then saferead in child
process may blocked forever, and left grandchild process in defunct state.
Signed-off-by: Xu Chao <xu.chao6(a)zte.com.cn>
Signed-off-by: Yi Wang <wang.yi59(a)zte.com.cn>
---
src/util/vircommand.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/src/util/vircommand.c b/src/util/vircommand.c
index fead373729..fa71f40d81 100644
--- a/src/util/vircommand.c
+++ b/src/util/vircommand.c
@@ -782,6 +782,9 @@ virExec(virCommand *cmd)
}
if (pid > 0) {
+ /* close pipe[1], then the pipe can be closed if grandchild
+ * died prematurely */
+ VIR_FORCE_CLOSE(pipesync[1]);
/* The parent expect us to have written the pid file before
* exiting. Wait here for the child to write it and signal us. */
if (cmd->pidfile &&
--
2.27.0
3 years, 1 month
[PATCH 0/4] virXXXListAdd: Transfer definition ownership
by Michal Privoznik
At a lot of places we have the following pattern:
virXXXDef *def = parseDef();
if (!(obj = virXXXObjListAdd(def)))
goto clenaup;
def = NULL;
cleanup:
virXXXDefFree(def);
The 'def = NULL' step is necessary because the ownership of the
definition was transferred onto the object. Well, this approach is
fragile as it relies on developers remembering to set the variable
explicitly.
If the virXXXObjListAdd() would take address of @def then the explicit
set to NULL can be left out.
Please note, I've reworked only a few virXXXObjListAdd() functions to
see whether these are desired or not. If merged, I can post patches for
the rest.
Michal Prívozník (4):
virInterfaceObjListAssignDef: Transfer definition ownership
virSecretObjListAdd: Transfer definition ownership
virStoragePoolObjListAdd: Transfer definition ownership
virDomainObjListAdd: Transfer definition ownership
src/bhyve/bhyve_driver.c | 6 ++----
src/ch/ch_driver.c | 7 ++-----
src/conf/domain_conf.c | 8 ++++----
src/conf/domain_conf.h | 2 +-
src/conf/virdomainobjlist.c | 22 +++++++++++++---------
src/conf/virdomainobjlist.h | 2 +-
src/conf/virinterfaceobj.c | 25 +++++++++++++++++++------
src/conf/virinterfaceobj.h | 2 +-
src/conf/virsecretobj.c | 26 ++++++++++++++------------
src/conf/virsecretobj.h | 2 +-
src/conf/virstorageobj.c | 29 ++++++++++++++++-------------
src/conf/virstorageobj.h | 2 +-
src/libxl/libxl_domain.c | 3 +--
src/libxl/libxl_driver.c | 30 ++++++++++--------------------
src/libxl/libxl_migration.c | 6 ++----
src/lxc/lxc_driver.c | 24 ++++++++----------------
src/openvz/openvz_conf.c | 3 +--
src/openvz/openvz_driver.c | 10 ++++------
src/qemu/qemu_driver.c | 30 ++++++++++--------------------
src/qemu/qemu_migration.c | 3 +--
src/qemu/qemu_snapshot.c | 9 +++------
src/secret/secret_driver.c | 4 ++--
src/storage/storage_driver.c | 5 ++---
src/test/test_driver.c | 31 ++++++++++++-------------------
src/vmware/vmware_conf.c | 6 ++----
src/vmware/vmware_driver.c | 10 ++++------
26 files changed, 137 insertions(+), 170 deletions(-)
--
2.32.0
3 years, 1 month
[PATCH 0/2] libxl: Remove dead code
by Jim Fehlig
I was too lazy to dig through history, but I think 1/2 was the result
of too much copy and paste when originally implementing jobs in the
libxl driver. For 2/2, I think there was some ill-conceived locking of
the libxlDomainObjPrivate in the past. Its use was killed but the
object remained virObjectLockable.
Jim Fehlig (2):
libxl: Remove unused macros
libxl: Don't derive libxlDomainObjPrivate from virObjectLockable
src/libxl/libxl_domain.c | 38 ++++++--------------------------------
src/libxl/libxl_domain.h | 7 -------
2 files changed, 6 insertions(+), 39 deletions(-)
--
2.33.0
3 years, 1 month
[PATCH] qemu: Remove 'else' branches after 'return' or 'goto'
by Kristina Hanicova
I think it makes no sense to have else branches after return or
goto as it will never reach them in cases it should not. This
patch makes the code more readable (at least to me).
Signed-off-by: Kristina Hanicova <khanicov(a)redhat.com>
---
src/libvirt.c | 3 ++-
src/qemu/qemu_agent.c | 6 +++---
src/qemu/qemu_alias.c | 9 +++++----
src/qemu/qemu_capabilities.c | 4 ++--
src/qemu/qemu_cgroup.c | 9 +++------
src/qemu/qemu_conf.c | 11 +++++------
src/qemu/qemu_domain_address.c | 11 +++++------
src/qemu/qemu_domainjob.c | 3 +--
src/qemu/qemu_driver.c | 32 ++++++++++++++++----------------
9 files changed, 42 insertions(+), 46 deletions(-)
diff --git a/src/libvirt.c b/src/libvirt.c
index 80bdcd1db3..ef9fc403d0 100644
--- a/src/libvirt.c
+++ b/src/libvirt.c
@@ -663,7 +663,8 @@ virStateInitialize(bool privileged,
virStateDriverTab[i]->name,
virGetLastErrorMessage());
return -1;
- } else if (ret == VIR_DRV_STATE_INIT_SKIPPED && mandatory) {
+ }
+ if (ret == VIR_DRV_STATE_INIT_SKIPPED && mandatory) {
VIR_ERROR(_("Initialization of mandatory %s state driver skipped"),
virStateDriverTab[i]->name);
return -1;
diff --git a/src/qemu/qemu_agent.c b/src/qemu/qemu_agent.c
index c3b02569cd..75eb1620c0 100644
--- a/src/qemu/qemu_agent.c
+++ b/src/qemu/qemu_agent.c
@@ -989,8 +989,7 @@ qemuAgentCommandName(virJSONValue *cmd)
const char *name = virJSONValueObjectGetString(cmd, "execute");
if (name)
return name;
- else
- return "<unknown>";
+ return "<unknown>";
}
static int
@@ -1029,7 +1028,8 @@ qemuAgentCheckError(virJSONValue *cmd,
qemuAgentStringifyError(error));
return -1;
- } else if (!virJSONValueObjectHasKey(reply, "return")) {
+ }
+ if (!virJSONValueObjectHasKey(reply, "return")) {
g_autofree char *cmdstr = virJSONValueToString(cmd, false);
g_autofree char *replystr = virJSONValueToString(reply, false);
diff --git a/src/qemu/qemu_alias.c b/src/qemu/qemu_alias.c
index a36f346592..5b525415de 100644
--- a/src/qemu/qemu_alias.c
+++ b/src/qemu/qemu_alias.c
@@ -137,7 +137,8 @@ qemuAssignDeviceControllerAlias(virDomainDef *domainDef,
*/
controller->info.alias = g_strdup("pci");
return 0;
- } else if (controller->model == VIR_DOMAIN_CONTROLLER_MODEL_PCIE_ROOT) {
+ }
+ if (controller->model == VIR_DOMAIN_CONTROLLER_MODEL_PCIE_ROOT) {
/* The pcie-root controller on Q35 machinetypes uses a
* different naming convention ("pcie.0"), because it is
* hardcoded that way in qemu.
@@ -151,7 +152,8 @@ qemuAssignDeviceControllerAlias(virDomainDef *domainDef,
*/
controller->info.alias = g_strdup_printf("pci.%d", controller->idx);
return 0;
- } else if (controller->type == VIR_DOMAIN_CONTROLLER_TYPE_IDE) {
+ }
+ if (controller->type == VIR_DOMAIN_CONTROLLER_TYPE_IDE) {
/* for any machine based on e.g. I440FX or G3Beige, the
* first (and currently only) IDE controller is an integrated
* controller hardcoded with id "ide"
@@ -821,8 +823,7 @@ qemuAliasForSecret(const char *parentalias,
{
if (obj)
return g_strdup_printf("%s-%s-secret0", parentalias, obj);
- else
- return g_strdup_printf("%s-secret0", parentalias);
+ return g_strdup_printf("%s-secret0", parentalias);
}
/* qemuAliasTLSObjFromSrcAlias
diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index a4c492dde2..3b63996170 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -773,9 +773,9 @@ const char *virQEMUCapsArchToString(virArch arch)
{
if (arch == VIR_ARCH_I686)
return "i386";
- else if (arch == VIR_ARCH_ARMV6L || arch == VIR_ARCH_ARMV7L)
+ if (arch == VIR_ARCH_ARMV6L || arch == VIR_ARCH_ARMV7L)
return "arm";
- else if (arch == VIR_ARCH_OR32)
+ if (arch == VIR_ARCH_OR32)
return "or32";
return virArchToString(arch);
diff --git a/src/qemu/qemu_cgroup.c b/src/qemu/qemu_cgroup.c
index 1e7b562b33..bcdfa90759 100644
--- a/src/qemu/qemu_cgroup.c
+++ b/src/qemu/qemu_cgroup.c
@@ -608,9 +608,8 @@ qemuSetupBlkioCgroup(virDomainObj *vm)
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("Block I/O tuning is not available on this host"));
return -1;
- } else {
- return 0;
}
+ return 0;
}
return virDomainCgroupSetupBlkio(priv->cgroup, vm->def->blkio);
@@ -629,9 +628,8 @@ qemuSetupMemoryCgroup(virDomainObj *vm)
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("Memory cgroup is not available on this host"));
return -1;
- } else {
- return 0;
}
+ return 0;
}
return virDomainCgroupSetupMemtune(priv->cgroup, vm->def->mem);
@@ -891,9 +889,8 @@ qemuSetupCpuCgroup(virDomainObj *vm)
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("CPU tuning is not available on this host"));
return -1;
- } else {
- return 0;
}
+ return 0;
}
if (vm->def->cputune.sharesSpecified) {
diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
index 0451bc70ac..bbb05a4e81 100644
--- a/src/qemu/qemu_conf.c
+++ b/src/qemu/qemu_conf.c
@@ -1001,12 +1001,12 @@ virQEMUDriverConfigLoadMemoryEntry(virQEMUDriverConfig *cfg,
g_autofree char *dir = NULL;
int rc;
- if ((rc = virConfGetValueString(conf, "memory_backing_dir", &dir)) < 0) {
+ if ((rc = virConfGetValueString(conf, "memory_backing_dir", &dir)) < 0)
return -1;
- } else if (rc > 0) {
+
+ if (rc > 0) {
VIR_FREE(cfg->memoryBackingDir);
cfg->memoryBackingDir = g_strdup_printf("%s/libvirt/qemu", dir);
- return 0;
}
return 0;
@@ -1777,11 +1777,10 @@ qemuSharedDeviceAddRemoveInternal(virQEMUDriver *driver,
if (dev->type == VIR_DOMAIN_DEVICE_DISK)
return qemuSharedDiskAddRemoveInternal(driver, dev->data.disk,
name, addDevice);
- else if (dev->type == VIR_DOMAIN_DEVICE_HOSTDEV)
+ if (dev->type == VIR_DOMAIN_DEVICE_HOSTDEV)
return qemuSharedHostdevAddRemoveInternal(driver, dev->data.hostdev,
name, addDevice);
- else
- return 0;
+ return 0;
}
diff --git a/src/qemu/qemu_domain_address.c b/src/qemu/qemu_domain_address.c
index 9abe2b84c8..2948630b75 100644
--- a/src/qemu/qemu_domain_address.c
+++ b/src/qemu/qemu_domain_address.c
@@ -58,13 +58,13 @@ qemuDomainGetSCSIControllerModel(const virDomainDef *def,
if (qemuDomainIsPSeries(def))
return VIR_DOMAIN_CONTROLLER_MODEL_SCSI_IBMVSCSI;
- else if (ARCH_IS_S390(def->os.arch))
+ if (ARCH_IS_S390(def->os.arch))
return VIR_DOMAIN_CONTROLLER_MODEL_SCSI_VIRTIO_SCSI;
- else if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_SCSI_LSI))
+ if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_SCSI_LSI))
return VIR_DOMAIN_CONTROLLER_MODEL_SCSI_LSILOGIC;
- else if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_SCSI))
+ if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_SCSI))
return VIR_DOMAIN_CONTROLLER_MODEL_SCSI_VIRTIO_SCSI;
- else if (qemuDomainHasBuiltinESP(def))
+ if (qemuDomainHasBuiltinESP(def))
return VIR_DOMAIN_CONTROLLER_MODEL_SCSI_NCR53C90;
virReportError(VIR_ERR_INTERNAL_ERROR,
@@ -1589,9 +1589,8 @@ qemuDomainCollectPCIAddress(virDomainDef *def G_GNUC_UNUSED,
_("Bus 0 must be PCI for integrated PIIX3 "
"USB or IDE controllers"));
return -1;
- } else {
- return 0;
}
+ return 0;
}
}
diff --git a/src/qemu/qemu_domainjob.c b/src/qemu/qemu_domainjob.c
index 03a8d9ba5f..cff8d7bb83 100644
--- a/src/qemu/qemu_domainjob.c
+++ b/src/qemu/qemu_domainjob.c
@@ -1036,8 +1036,7 @@ int qemuDomainObjBeginJob(virQEMUDriver *driver,
QEMU_AGENT_JOB_NONE,
QEMU_ASYNC_JOB_NONE, false) < 0)
return -1;
- else
- return 0;
+ return 0;
}
/**
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 16d449913c..437bf63cd4 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -1819,7 +1819,8 @@ static int qemuDomainSuspend(virDomainPtr dom)
virReportError(VIR_ERR_OPERATION_INVALID,
"%s", _("domain is pmsuspended"));
goto endjob;
- } else if (state != VIR_DOMAIN_PAUSED) {
+ }
+ if (state != VIR_DOMAIN_PAUSED) {
if (qemuProcessStopCPUs(driver, vm, reason, QEMU_ASYNC_JOB_NONE) < 0)
goto endjob;
}
@@ -1861,13 +1862,15 @@ static int qemuDomainResume(virDomainPtr dom)
virReportError(VIR_ERR_OPERATION_INVALID,
"%s", _("domain is pmsuspended"));
goto endjob;
- } else if (state == VIR_DOMAIN_RUNNING) {
+ }
+ if (state == VIR_DOMAIN_RUNNING) {
virReportError(VIR_ERR_OPERATION_INVALID,
"%s", _("domain is already running"));
goto endjob;
- } else if ((state == VIR_DOMAIN_CRASHED &&
- reason == VIR_DOMAIN_CRASHED_PANICKED) ||
- state == VIR_DOMAIN_PAUSED) {
+ }
+ if ((state == VIR_DOMAIN_CRASHED &&
+ reason == VIR_DOMAIN_CRASHED_PANICKED) ||
+ state == VIR_DOMAIN_PAUSED) {
if (qemuProcessStartCPUs(driver, vm,
VIR_DOMAIN_RUNNING_UNPAUSED,
QEMU_ASYNC_JOB_NONE) < 0) {
@@ -16358,9 +16361,9 @@ qemuDomainGetBlockIoTune(virDomainPtr dom,
*nparams = maxparams;
ret = 0;
goto endjob;
- } else if (*nparams < maxparams) {
- maxparams = *nparams;
}
+ if (*nparams < maxparams)
+ maxparams = *nparams;
*nparams = 0;
@@ -20428,29 +20431,26 @@ qemuDomainGetGuestInfo(virDomainPtr dom,
if (supportedTypes & VIR_DOMAIN_GUEST_INFO_FILESYSTEM) {
rc = qemuAgentGetFSInfo(agent, &agentfsinfo, report_unsupported);
- if (rc == -1) {
+ if (rc == -1)
goto exitagent;
- } else if (rc >= 0) {
+ if (rc >= 0)
nfs = rc;
- }
}
if (supportedTypes & VIR_DOMAIN_GUEST_INFO_DISKS) {
rc = qemuAgentGetDisks(agent, &agentdiskinfo, report_unsupported);
- if (rc == -1) {
+ if (rc == -1)
goto exitagent;
- } else if (rc >= 0) {
+ if (rc >= 0)
ndisks = rc;
- }
}
if (supportedTypes & VIR_DOMAIN_GUEST_INFO_INTERFACES) {
rc = qemuAgentGetInterfaces(agent, &ifaces, report_unsupported);
- if (rc == -1) {
+ if (rc == -1)
goto exitagent;
- } else if (rc >= 0) {
+ if (rc >= 0)
nifaces = rc;
- }
}
qemuDomainObjExitAgent(vm, agent);
--
2.31.1
3 years, 1 month
[RFC PATCH 0/3] Add virDomainInjectLaunchSecret API
by Jim Fehlig
Hi All!
This series is an RFC impl for the missing API needed for SEV attestation as
discussed here
https://listman.redhat.com/archives/libvir-list/2021-May/msg00196.html
I pinged about the status a few weeks back, found it had stalled, and agreed
to work on an impl after returning from vacation
https://listman.redhat.com/archives/libvir-list/2021-October/msg01052.html
Although the series is only compile tested, I wanted to share it early in
case others are considering the task.
While discussing the missing API, Daniel suggested virDomainSetLaunchSecurityInfo
https://listman.redhat.com/archives/libvir-list/2021-October/msg01074.html
but noted the asymmetry with virDomainGetLaunchSecurityInfo. I decided to go
with virDomainInjectLaunchSecret, which better describes the function IMO.
I also decided to go with an explicit set of parameters, following in the
footsteps of virDrvDomainAuthorizedSSHKeys*. It wasn't until patch 3 that I
realized virTypedParameter is definitely a better approach for an API that
may need future support for other types of secrets. I'll make that change in
a V1 after collecting feedback on this RFC.
Regards,
Jim
Jim Fehlig (3):
libvirt: Introduce virDomainInjectLaunchSecret public API
remote: Implement domain inject launch secret API
qemu: Implement the virDomainInjectLaunchSecret API
include/libvirt/libvirt-domain.h | 6 ++++
src/driver-hypervisor.h | 8 +++++
src/libvirt-domain.c | 50 +++++++++++++++++++++++++++
src/libvirt_public.syms | 5 +++
src/qemu/qemu_driver.c | 53 +++++++++++++++++++++++++++++
src/qemu/qemu_monitor.c | 12 +++++++
src/qemu/qemu_monitor.h | 6 ++++
src/qemu/qemu_monitor_json.c | 34 ++++++++++++++++++
src/qemu/qemu_monitor_json.h | 5 +++
src/remote/remote_daemon_dispatch.c | 27 +++++++++++++++
src/remote/remote_driver.c | 32 +++++++++++++++++
src/remote/remote_protocol.x | 16 ++++++++-
src/remote_protocol-structs | 8 +++++
13 files changed, 261 insertions(+), 1 deletion(-)
--
2.33.0
3 years, 1 month
[PATCH] qemu: Remove unnecessary variables and labels
by Kristina Hanicova
This patch removes variables such as 'ret', 'rc' and others which
are easily replaced. Therefore, making the code look cleaner and
easier to understand.
Signed-off-by: Kristina Hanicova <khanicov(a)redhat.com>
---
src/driver.c | 4 +--
src/qemu/qemu_agent.c | 4 +--
src/qemu/qemu_alias.c | 14 +++-----
src/qemu/qemu_capabilities.c | 21 +++++------
src/qemu/qemu_cgroup.c | 7 ++--
src/qemu/qemu_conf.c | 15 ++++----
src/qemu/qemu_domain_address.c | 9 ++---
src/qemu/qemu_driver.c | 64 ++++++++++++----------------------
8 files changed, 48 insertions(+), 90 deletions(-)
diff --git a/src/driver.c b/src/driver.c
index 329d493a50..9ae95cb4c3 100644
--- a/src/driver.c
+++ b/src/driver.c
@@ -52,7 +52,6 @@ virDriverLoadModule(const char *name,
bool required)
{
g_autofree char *modfile = NULL;
- int ret;
VIR_DEBUG("Module load %s", name);
@@ -64,8 +63,7 @@ virDriverLoadModule(const char *name,
"LIBVIRT_DRIVER_DIR")))
return -1;
- ret = virModuleLoad(modfile, regfunc, required);
- return ret;
+ return virModuleLoad(modfile, regfunc, required);
}
diff --git a/src/qemu/qemu_agent.c b/src/qemu/qemu_agent.c
index c3b02569cd..08436a9705 100644
--- a/src/qemu/qemu_agent.c
+++ b/src/qemu/qemu_agent.c
@@ -176,7 +176,6 @@ qemuAgentOpenUnix(const char *socketpath)
{
struct sockaddr_un addr;
int agentfd;
- int ret = -1;
if ((agentfd = socket(AF_UNIX, SOCK_STREAM, 0)) < 0) {
virReportSystemError(errno,
@@ -199,8 +198,7 @@ qemuAgentOpenUnix(const char *socketpath)
goto error;
}
- ret = connect(agentfd, (struct sockaddr *)&addr, sizeof(addr));
- if (ret < 0) {
+ if (connect(agentfd, (struct sockaddr *)&addr, sizeof(addr)) < 0) {
virReportSystemError(errno, "%s",
_("failed to connect to agent socket"));
goto error;
diff --git a/src/qemu/qemu_alias.c b/src/qemu/qemu_alias.c
index a36f346592..5e35f43614 100644
--- a/src/qemu/qemu_alias.c
+++ b/src/qemu/qemu_alias.c
@@ -744,16 +744,13 @@ qemuAssignDeviceAliases(virDomainDef *def, virQEMUCaps *qemuCaps)
char *
qemuAliasDiskDriveFromDisk(const virDomainDiskDef *disk)
{
- char *ret;
-
if (!disk->info.alias) {
virReportError(VIR_ERR_INVALID_ARG, "%s",
_("disk does not have an alias"));
return NULL;
}
- ret = g_strdup_printf("%s%s", QEMU_DRIVE_HOST_PREFIX, disk->info.alias);
- return ret;
+ return g_strdup_printf("%s%s", QEMU_DRIVE_HOST_PREFIX, disk->info.alias);
}
@@ -780,18 +777,15 @@ qemuAliasDiskDriveSkipPrefix(const char *dev_name)
char *
qemuAliasFromHostdev(const virDomainHostdevDef *hostdev)
{
- char *ret;
-
if (!hostdev->info->alias) {
virReportError(VIR_ERR_INVALID_ARG, "%s",
_("hostdev does not have an alias"));
return NULL;
}
- ret = g_strdup_printf("%s-%s",
- virDomainDeviceAddressTypeToString(hostdev->info->type),
- hostdev->info->alias);
- return ret;
+ return g_strdup_printf("%s-%s",
+ virDomainDeviceAddressTypeToString(hostdev->info->type),
+ hostdev->info->alias);
}
diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index a4c492dde2..33797469a6 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -3070,7 +3070,6 @@ virQEMUCapsGetCPUFeatures(virQEMUCaps *qemuCaps,
g_auto(GStrv) list = NULL;
size_t i;
size_t n;
- int ret = -1;
*features = NULL;
modelInfo = virQEMUCapsGetCPUModelInfo(qemuCaps, virtType);
@@ -3091,12 +3090,10 @@ virQEMUCapsGetCPUFeatures(virQEMUCaps *qemuCaps,
}
*features = g_steal_pointer(&list);
- if (migratable && !modelInfo->migratability)
- ret = 1;
- else
- ret = 0;
- return ret;
+ if (migratable && !modelInfo->migratability)
+ return 1;
+ return 0;
}
@@ -5237,15 +5234,13 @@ virQEMUCapsProbeQMPSchemaCapabilities(virQEMUCaps *qemuCaps,
virDomainVirtType
virQEMUCapsGetVirtType(virQEMUCaps *qemuCaps)
{
- virDomainVirtType type;
if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_KVM))
- type = VIR_DOMAIN_VIRT_KVM;
- else if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_TCG))
- type = VIR_DOMAIN_VIRT_QEMU;
- else
- type = VIR_DOMAIN_VIRT_NONE;
+ return VIR_DOMAIN_VIRT_KVM;
+
+ if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_TCG))
+ return VIR_DOMAIN_VIRT_QEMU;
- return type;
+ return VIR_DOMAIN_VIRT_NONE;
}
int
diff --git a/src/qemu/qemu_cgroup.c b/src/qemu/qemu_cgroup.c
index 1e7b562b33..c07058d2f8 100644
--- a/src/qemu/qemu_cgroup.c
+++ b/src/qemu/qemu_cgroup.c
@@ -336,18 +336,15 @@ static int
qemuSetupTPMCgroup(virDomainObj *vm,
virDomainTPMDef *dev)
{
- int ret = 0;
-
switch (dev->type) {
case VIR_DOMAIN_TPM_TYPE_PASSTHROUGH:
- ret = qemuSetupChrSourceCgroup(vm, dev->data.passthrough.source);
- break;
+ return qemuSetupChrSourceCgroup(vm, dev->data.passthrough.source);
case VIR_DOMAIN_TPM_TYPE_EMULATOR:
case VIR_DOMAIN_TPM_TYPE_LAST:
break;
}
- return ret;
+ return 0;
}
diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
index 0451bc70ac..d31cd05ab4 100644
--- a/src/qemu/qemu_conf.c
+++ b/src/qemu/qemu_conf.c
@@ -1915,16 +1915,13 @@ qemuGetBaseHugepagePath(virQEMUDriver *driver,
virHugeTLBFS *hugepage)
{
const char *root = driver->embeddedRoot;
- char *ret;
if (root && !STRPREFIX(hugepage->mnt_dir, root)) {
g_autofree char * hash = virDomainDriverGenerateRootHash("qemu", root);
- ret = g_strdup_printf("%s/libvirt/%s", hugepage->mnt_dir, hash);
- } else {
- ret = g_strdup_printf("%s/libvirt/qemu", hugepage->mnt_dir);
+ return g_strdup_printf("%s/libvirt/%s", hugepage->mnt_dir, hash);
}
- return ret;
+ return g_strdup_printf("%s/libvirt/qemu", hugepage->mnt_dir);
}
@@ -1935,11 +1932,11 @@ qemuGetDomainHugepagePath(virQEMUDriver *driver,
{
g_autofree char *base = qemuGetBaseHugepagePath(driver, hugepage);
g_autofree char *domPath = virDomainDefGetShortName(def);
- char *ret = NULL;
- if (base && domPath)
- ret = g_strdup_printf("%s/%s", base, domPath);
- return ret;
+ if (!base || !domPath)
+ return NULL;
+
+ return g_strdup_printf("%s/%s", base, domPath);
}
diff --git a/src/qemu/qemu_domain_address.c b/src/qemu/qemu_domain_address.c
index 9abe2b84c8..22bf5d3b54 100644
--- a/src/qemu/qemu_domain_address.c
+++ b/src/qemu/qemu_domain_address.c
@@ -2465,7 +2465,6 @@ static int
qemuDomainAddressFindNewTargetIndex(virDomainDef *def)
{
int targetIndex;
- int ret = -1;
/* Try all indexes between 1 and 31 - QEMU only supports 32
* PHBs, and 0 is reserved for the default, implicit one */
@@ -2490,13 +2489,11 @@ qemuDomainAddressFindNewTargetIndex(virDomainDef *def)
/* If no existing PCI controller uses this index, great,
* it means it's free and we can return it to the caller */
- if (!found) {
- ret = targetIndex;
- break;
- }
+ if (!found)
+ return targetIndex;
}
- return ret;
+ return -1;
}
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index d954635dde..860c5b70a8 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -1332,7 +1332,6 @@ qemuGetSchedInfo(unsigned long long *cpuWait,
g_autofree char *data = NULL;
g_auto(GStrv) lines = NULL;
size_t i;
- int ret = -1;
double val;
*cpuWait = 0;
@@ -1344,21 +1343,19 @@ qemuGetSchedInfo(unsigned long long *cpuWait,
else
proc = g_strdup_printf("/proc/%d/sched", (int)pid);
if (!proc)
- goto cleanup;
- ret = -1;
+ return -1;
/* The file is not guaranteed to exist (needs CONFIG_SCHED_DEBUG) */
if (access(proc, R_OK) < 0) {
- ret = 0;
- goto cleanup;
+ return 0;
}
if (virFileReadAll(proc, (1<<16), &data) < 0)
- goto cleanup;
+ return -1;
lines = g_strsplit(data, "\n", 0);
if (!lines)
- goto cleanup;
+ return -1;
for (i = 0; lines[i] != NULL; i++) {
const char *line = lines[i];
@@ -1372,7 +1369,7 @@ qemuGetSchedInfo(unsigned long long *cpuWait,
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Missing separator in sched info '%s'"),
lines[i]);
- goto cleanup;
+ return -1;
}
line++;
while (*line == ' ')
@@ -1382,7 +1379,7 @@ qemuGetSchedInfo(unsigned long long *cpuWait,
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Unable to parse sched info value '%s'"),
line);
- goto cleanup;
+ return -1;
}
*cpuWait = (unsigned long long)(val * 1000000);
@@ -1390,10 +1387,7 @@ qemuGetSchedInfo(unsigned long long *cpuWait,
}
}
- ret = 0;
-
- cleanup:
- return ret;
+ return 0;
}
@@ -3178,7 +3172,6 @@ doCoreDump(virQEMUDriver *driver,
{
int fd = -1;
int ret = -1;
- int rc = -1;
virFileWrapperFd *wrapperFd = NULL;
int directFlag = 0;
bool needUnlink = false;
@@ -3224,8 +3217,9 @@ doCoreDump(virQEMUDriver *driver,
if (STREQ(memory_dump_format, "elf"))
memory_dump_format = NULL;
- rc = qemuDumpToFd(driver, vm, fd, QEMU_ASYNC_JOB_DUMP,
- memory_dump_format);
+ if (qemuDumpToFd(driver, vm, fd, QEMU_ASYNC_JOB_DUMP,
+ memory_dump_format) < 0)
+ goto cleanup;
} else {
if (dumpformat != VIR_DOMAIN_CORE_DUMP_FORMAT_RAW) {
virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
@@ -3237,13 +3231,11 @@ doCoreDump(virQEMUDriver *driver,
if (!qemuMigrationSrcIsAllowed(driver, vm, false, 0))
goto cleanup;
- rc = qemuMigrationSrcToFile(driver, vm, fd, compressor,
- QEMU_ASYNC_JOB_DUMP);
+ if (qemuMigrationSrcToFile(driver, vm, fd, compressor,
+ QEMU_ASYNC_JOB_DUMP) < 0)
+ goto cleanup;
}
- if (rc < 0)
- goto cleanup;
-
if (VIR_CLOSE(fd) < 0) {
virReportSystemError(errno,
_("unable to close file %s"),
@@ -7225,14 +7217,12 @@ qemuDomainUpdateDeviceLive(virDomainObj *vm,
{
virQEMUDriver *driver = dom->conn->privateData;
virDomainDeviceDef oldDev = { .type = dev->type };
- int ret = -1;
int idx;
switch ((virDomainDeviceType)dev->type) {
case VIR_DOMAIN_DEVICE_DISK:
qemuDomainObjCheckDiskTaint(driver, vm, dev->data.disk, NULL);
- ret = qemuDomainChangeDiskLive(vm, dev, driver, force);
- break;
+ return qemuDomainChangeDiskLive(vm, dev, driver, force);
case VIR_DOMAIN_DEVICE_GRAPHICS:
if ((idx = qemuDomainFindGraphicsIndex(vm->def, dev->data.graphics)) >= 0) {
@@ -7243,8 +7233,7 @@ qemuDomainUpdateDeviceLive(virDomainObj *vm,
return -1;
}
- ret = qemuDomainChangeGraphics(driver, vm, dev->data.graphics);
- break;
+ return qemuDomainChangeGraphics(driver, vm, dev->data.graphics);
case VIR_DOMAIN_DEVICE_NET:
if ((idx = virDomainNetFindIdx(vm->def, dev->data.net)) >= 0) {
@@ -7255,12 +7244,10 @@ qemuDomainUpdateDeviceLive(virDomainObj *vm,
return -1;
}
- ret = qemuDomainChangeNet(driver, vm, dev);
- break;
+ return qemuDomainChangeNet(driver, vm, dev);
case VIR_DOMAIN_DEVICE_MEMORY:
- ret = qemuDomainChangeMemoryLive(driver, vm, dev);
- break;
+ return qemuDomainChangeMemoryLive(driver, vm, dev);
case VIR_DOMAIN_DEVICE_FS:
case VIR_DOMAIN_DEVICE_INPUT:
@@ -7288,10 +7275,10 @@ qemuDomainUpdateDeviceLive(virDomainObj *vm,
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("live update of device '%s' is not supported"),
virDomainDeviceTypeToString(dev->type));
- break;
+ return -1;
}
- return ret;
+ return -1;
}
@@ -9681,13 +9668,11 @@ qemuGetVcpusBWLive(virDomainObj *vm,
{
g_autoptr(virCgroup) cgroup_vcpu = NULL;
qemuDomainObjPrivate *priv = NULL;
- int rc;
priv = vm->privateData;
if (!qemuDomainHasVcpuPids(vm)) {
/* We do not create sub dir for each vcpu */
- rc = qemuGetVcpuBWLive(priv->cgroup, period, quota);
- if (rc < 0)
+ if (qemuGetVcpuBWLive(priv->cgroup, period, quota) < 0)
return -1;
if (*quota > 0)
@@ -9700,8 +9685,7 @@ qemuGetVcpusBWLive(virDomainObj *vm,
false, &cgroup_vcpu) < 0)
return -1;
- rc = qemuGetVcpuBWLive(cgroup_vcpu, period, quota);
- if (rc < 0)
+ if (qemuGetVcpuBWLive(cgroup_vcpu, period, quota) < 0)
return -1;
return 0;
@@ -9731,12 +9715,11 @@ qemuGetIOThreadsBWLive(virDomainObj *vm,
{
g_autoptr(virCgroup) cgroup_iothread = NULL;
qemuDomainObjPrivate *priv = NULL;
- int rc;
priv = vm->privateData;
if (!vm->def->niothreadids) {
/* We do not create sub dir for each iothread */
- if ((rc = qemuGetVcpuBWLive(priv->cgroup, period, quota)) < 0)
+ if (qemuGetVcpuBWLive(priv->cgroup, period, quota) < 0)
return -1;
return 0;
@@ -9748,8 +9731,7 @@ qemuGetIOThreadsBWLive(virDomainObj *vm,
false, &cgroup_iothread) < 0)
return -1;
- rc = qemuGetVcpuBWLive(cgroup_iothread, period, quota);
- if (rc < 0)
+ if (qemuGetVcpuBWLive(cgroup_iothread, period, quota) < 0)
return -1;
return 0;
--
2.31.1
3 years, 1 month