mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-11 15:27:47 +00:00
lxc: Fix error handlings in lxcContainerRenameAndEnableInterfaces
The function is expected to return negative value on failure, however, it returns positive value when either setInterfaceName or vethInterfaceUpOrDown fails. Because the function returns the return value of either as is, however, the two functions may return positive value on failure. The patch fixes the defects and add error messages.
This commit is contained in:
parent
b3a96d9049
commit
df8225ac54
@ -255,13 +255,20 @@ static int lxcContainerRenameAndEnableInterfaces(unsigned int nveths,
|
||||
|
||||
DEBUG("Renaming %s to %s", veths[i], newname);
|
||||
rc = setInterfaceName(veths[i], newname);
|
||||
if (0 != rc)
|
||||
if (0 != rc) {
|
||||
VIR_ERROR(_("Failed to rename %s to %s (%d)"),
|
||||
veths[i], newname, rc);
|
||||
rc = -1;
|
||||
goto error_out;
|
||||
}
|
||||
|
||||
DEBUG("Enabling %s", newname);
|
||||
rc = vethInterfaceUpOrDown(newname, 1);
|
||||
if (0 != rc)
|
||||
rc = vethInterfaceUpOrDown(newname, 1);
|
||||
if (0 != rc) {
|
||||
VIR_ERROR(_("Failed to enable %s (%d)"), newname, rc);
|
||||
rc = -1;
|
||||
goto error_out;
|
||||
}
|
||||
VIR_FREE(newname);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user