Commit d48f389c authored by Beniamino Galvani's avatar Beniamino Galvani

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: c02d1c48
parent 529533a5
......@@ -2228,20 +2228,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) {
......@@ -2275,11 +2274,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)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment