mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06:00
qemu: Rewrite code to the pattern
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@redhat.com> Signed-off-by: Michal Privoznik <mprivozn@redhat.com> Reviewed-by: Martin Kletzander <mkletzan@redhat.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
b85cef1b2d
commit
46caf6bac9
@ -16220,15 +16220,13 @@ qemuDomainSetBlockIoTune(virDomainPtr dom,
|
|||||||
* once new media is inserted */
|
* once new media is inserted */
|
||||||
if (!virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_BLOCKDEV) ||
|
if (!virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_BLOCKDEV) ||
|
||||||
!virStorageSourceIsEmpty(disk->src)) {
|
!virStorageSourceIsEmpty(disk->src)) {
|
||||||
|
int rc = 0;
|
||||||
|
|
||||||
qemuDomainObjEnterMonitor(driver, vm);
|
qemuDomainObjEnterMonitor(driver, vm);
|
||||||
ret = qemuMonitorSetBlockIoThrottle(priv->mon, drivealias, qdevid,
|
rc = qemuMonitorSetBlockIoThrottle(priv->mon, drivealias, qdevid, &info);
|
||||||
&info);
|
|
||||||
if (qemuDomainObjExitMonitor(driver, vm) < 0)
|
if (qemuDomainObjExitMonitor(driver, vm) < 0 || rc < 0)
|
||||||
ret = -1;
|
|
||||||
if (ret < 0)
|
|
||||||
goto endjob;
|
goto endjob;
|
||||||
ret = -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
virDomainDiskSetBlockIOTune(disk, &info);
|
virDomainDiskSetBlockIOTune(disk, &info);
|
||||||
@ -16340,6 +16338,8 @@ qemuDomainGetBlockIoTune(virDomainPtr dom,
|
|||||||
*nparams = 0;
|
*nparams = 0;
|
||||||
|
|
||||||
if (def) {
|
if (def) {
|
||||||
|
int rc = 0;
|
||||||
|
|
||||||
if (!(disk = qemuDomainDiskByName(def, path)))
|
if (!(disk = qemuDomainDiskByName(def, path)))
|
||||||
goto endjob;
|
goto endjob;
|
||||||
|
|
||||||
@ -16354,10 +16354,9 @@ qemuDomainGetBlockIoTune(virDomainPtr dom,
|
|||||||
goto endjob;
|
goto endjob;
|
||||||
}
|
}
|
||||||
qemuDomainObjEnterMonitor(driver, vm);
|
qemuDomainObjEnterMonitor(driver, vm);
|
||||||
ret = qemuMonitorGetBlockIoThrottle(priv->mon, drivealias, qdevid, &reply);
|
rc = qemuMonitorGetBlockIoThrottle(priv->mon, drivealias, qdevid, &reply);
|
||||||
if (qemuDomainObjExitMonitor(driver, vm) < 0)
|
|
||||||
goto endjob;
|
if (qemuDomainObjExitMonitor(driver, vm) < 0 || rc < 0)
|
||||||
if (ret < 0)
|
|
||||||
goto endjob;
|
goto endjob;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -17368,10 +17367,8 @@ qemuDomainSetTime(virDomainPtr dom,
|
|||||||
if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_RTC_RESET_REINJECTION)) {
|
if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_RTC_RESET_REINJECTION)) {
|
||||||
qemuDomainObjEnterMonitor(driver, vm);
|
qemuDomainObjEnterMonitor(driver, vm);
|
||||||
rv = qemuMonitorRTCResetReinjection(priv->mon);
|
rv = qemuMonitorRTCResetReinjection(priv->mon);
|
||||||
if (qemuDomainObjExitMonitor(driver, vm) < 0)
|
|
||||||
goto endjob;
|
|
||||||
|
|
||||||
if (rv < 0)
|
if (qemuDomainObjExitMonitor(driver, vm) < 0 || rv < 0)
|
||||||
goto endjob;
|
goto endjob;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user