mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-11 15:27:47 +00:00
network: Report real error if addition of firewall rules fails
If addition of rules in networkAddIptablesRules() failed the real error was masked by error reported when trying to clean up the remaining rules. With this patch the original error message is saved and set back after the removal is complete.
This commit is contained in:
parent
d0b8bc8565
commit
e6d74d8db5
@ -2088,6 +2088,7 @@ networkAddIptablesRules(struct network_driver *driver,
|
||||
{
|
||||
int ii;
|
||||
virNetworkIpDefPtr ipdef;
|
||||
virErrorPtr orig_error;
|
||||
|
||||
/* Add "once per network" rules */
|
||||
if (networkAddGeneralIptablesRules(driver, network) < 0)
|
||||
@ -2104,6 +2105,9 @@ networkAddIptablesRules(struct network_driver *driver,
|
||||
return 0;
|
||||
|
||||
err:
|
||||
/* store the previous error message before attempting removal of rules */
|
||||
orig_error = virSaveLastError();
|
||||
|
||||
/* The final failed call to networkAddIpSpecificIptablesRules will
|
||||
* have removed any rules it created, but we need to remove those
|
||||
* added for previous IP addresses.
|
||||
@ -2113,6 +2117,9 @@ err:
|
||||
networkRemoveIpSpecificIptablesRules(driver, network, ipdef);
|
||||
}
|
||||
networkRemoveGeneralIptablesRules(driver, network);
|
||||
|
||||
/* return the original error */
|
||||
virSetError(orig_error);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user