mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-23 06:05:27 +00:00
qemu: Refactor qemuDomainAttachChrDevice error paths
Refactor the error paths for attaching char device (it's about to be more complicated). Signed-off-by: John Ferlan <jferlan@redhat.com>
This commit is contained in:
parent
323d5bdc94
commit
55931292c9
@ -1524,17 +1524,12 @@ int qemuDomainAttachChrDevice(virQEMUDriverPtr driver,
|
||||
goto cleanup;
|
||||
|
||||
qemuDomainObjEnterMonitor(driver, vm);
|
||||
if (qemuMonitorAttachCharDev(priv->mon, charAlias, &chr->source) < 0) {
|
||||
ignore_value(qemuDomainObjExitMonitor(driver, vm));
|
||||
goto audit;
|
||||
}
|
||||
if (qemuMonitorAttachCharDev(priv->mon, charAlias, &chr->source) < 0)
|
||||
goto failchardev;
|
||||
|
||||
if (qemuMonitorAddDevice(priv->mon, devstr) < 0)
|
||||
goto failadddev;
|
||||
|
||||
if (devstr && qemuMonitorAddDevice(priv->mon, devstr) < 0) {
|
||||
/* detach associated chardev on error */
|
||||
qemuMonitorDetachCharDev(priv->mon, charAlias);
|
||||
ignore_value(qemuDomainObjExitMonitor(driver, vm));
|
||||
goto audit;
|
||||
}
|
||||
if (qemuDomainObjExitMonitor(driver, vm) < 0)
|
||||
goto audit;
|
||||
|
||||
@ -1550,6 +1545,13 @@ int qemuDomainAttachChrDevice(virQEMUDriverPtr driver,
|
||||
VIR_FREE(charAlias);
|
||||
VIR_FREE(devstr);
|
||||
return ret;
|
||||
|
||||
failadddev:
|
||||
/* detach associated chardev on error */
|
||||
qemuMonitorDetachCharDev(priv->mon, charAlias);
|
||||
failchardev:
|
||||
ignore_value(qemuDomainObjExitMonitor(driver, vm));
|
||||
goto audit;
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user