mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2025-12-27 12:50:09 +01:00
ifcfg-rh: fix persisting sriov setting
The writer should write all properties of the sriov setting when the setting exists without additional logic. Likewise, the reader should instantiate a sriov setting when any sriov key is present and blindly set properties from keys. The old code did not always preserve the presence of a sriov setting after a write/read cycle. Fixes:c02d1c488f(cherry picked from commitd48f389cbf)
This commit is contained in:
parent
6ae1f64351
commit
9deca176f8
2 changed files with 21 additions and 13 deletions
|
|
@ -2226,20 +2226,19 @@ make_sriov_setting (shvarFile *ifcfg)
|
|||
{
|
||||
gs_unref_hashtable GHashTable *keys = NULL;
|
||||
gs_unref_ptrarray GPtrArray *vfs = NULL;
|
||||
NMTernary autoprobe_drivers;
|
||||
int autoprobe_drivers;
|
||||
NMSettingSriov *s_sriov;
|
||||
int total_vfs;
|
||||
gint64 total_vfs;
|
||||
|
||||
total_vfs = svGetValueInt64 (ifcfg, "SRIOV_TOTAL_VFS", 10, 0, G_MAXINT32, 0);
|
||||
if (!total_vfs)
|
||||
return NULL;
|
||||
|
||||
total_vfs = svGetValueInt64 (ifcfg, "SRIOV_TOTAL_VFS", 10, 0, G_MAXUINT32, -1);
|
||||
|
||||
autoprobe_drivers = svGetValueInt64 (ifcfg,
|
||||
"SRIOV_AUTOPROBE_DRIVERS",
|
||||
10,
|
||||
NM_TERNARY_FALSE,
|
||||
NM_TERNARY_DEFAULT,
|
||||
NM_TERNARY_TRUE,
|
||||
NM_TERNARY_DEFAULT);
|
||||
-2);
|
||||
|
||||
keys = svGetKeys (ifcfg, SV_KEY_TYPE_SRIOV_VF);
|
||||
if (keys) {
|
||||
|
|
@ -2273,11 +2272,21 @@ make_sriov_setting (shvarFile *ifcfg)
|
|||
}
|
||||
}
|
||||
|
||||
/* Create the setting when at least one key is set */
|
||||
if ( total_vfs < 0
|
||||
&& !vfs
|
||||
&& autoprobe_drivers < NM_TERNARY_DEFAULT)
|
||||
return NULL;
|
||||
|
||||
s_sriov = (NMSettingSriov *) nm_setting_sriov_new ();
|
||||
|
||||
autoprobe_drivers = NM_MAX (autoprobe_drivers, NM_TERNARY_DEFAULT);
|
||||
total_vfs = NM_MAX (total_vfs, 0);
|
||||
|
||||
g_object_set (s_sriov,
|
||||
NM_SETTING_SRIOV_TOTAL_VFS, total_vfs,
|
||||
NM_SETTING_SRIOV_VFS, vfs,
|
||||
NM_SETTING_SRIOV_AUTOPROBE_DRIVERS, (int) autoprobe_drivers,
|
||||
NM_SETTING_SRIOV_AUTOPROBE_DRIVERS, autoprobe_drivers,
|
||||
NULL);
|
||||
|
||||
return (NMSetting *) s_sriov;
|
||||
|
|
|
|||
|
|
@ -2223,16 +2223,15 @@ write_sriov_setting (NMConnection *connection, shvarFile *ifcfg)
|
|||
|
||||
svUnsetAll (ifcfg, SV_KEY_TYPE_SRIOV_VF);
|
||||
|
||||
s_sriov = NM_SETTING_SRIOV (nm_connection_get_setting (connection, NM_TYPE_SETTING_SRIOV));
|
||||
if (s_sriov)
|
||||
num = nm_setting_sriov_get_total_vfs (s_sriov);
|
||||
if (num == 0) {
|
||||
s_sriov = NM_SETTING_SRIOV (nm_connection_get_setting (connection,
|
||||
NM_TYPE_SETTING_SRIOV));
|
||||
if (!s_sriov) {
|
||||
svUnsetValue (ifcfg, "SRIOV_TOTAL_VFS");
|
||||
svUnsetValue (ifcfg, "SRIOV_AUTOPROBE_DRIVERS");
|
||||
return;
|
||||
}
|
||||
|
||||
svSetValueInt64 (ifcfg, "SRIOV_TOTAL_VFS", num);
|
||||
svSetValueInt64 (ifcfg, "SRIOV_TOTAL_VFS", nm_setting_sriov_get_total_vfs (s_sriov));
|
||||
|
||||
b = nm_setting_sriov_get_autoprobe_drivers (s_sriov);
|
||||
if (b != NM_TERNARY_DEFAULT)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue