diff options
author | Devi Sravani Simhadri <dsimhadri@nvidia.com> | 2017-12-19 09:11:30 -0800 |
---|---|---|
committer | Aaron Plattner <aplattner@nvidia.com> | 2018-01-04 10:29:56 -0800 |
commit | 5ab3031eb03181af72bfa323703e042b7839a8d3 (patch) | |
tree | 24b2880c4796bb8d34de41d5c16bda89345231bf | |
parent | 2f557912102d3792b123de197c8e9fbe5ec6bc80 (diff) |
Fixing nvidia-settings to update config parameters into gridd.conf file correctly once the user clicks apply.
Issue : By default, EnableUI config parameter is true for 5.0 drivers.
nvidia-settings writes "EnableUI=TRUE" to gridd.conf file if the user
has applied license via UI. Since the user config options in gridd.conf
persist on driver upgrade we see the UI is enabled with 5.1 drivers.
The same issue is also encountered on driver upgrade from 5.0 to 6.0
Fix : User has to manually delete the gridd.conf file and create a new one with
the gridd.conf.template file provided.
Made the following changes:
1. On launching nvidia-settings, if there is no gridd.conf file available,
no new gridd.conf file will be created. A new gridd.conf file will be
created only when user clicks apply button via UI.
2. While updating the griddConfig structure with the user provided values
from UI, the corresponding config parameter will be updated only if it
differs from the currently provided value by the user.
-rw-r--r-- | src/gtk+-2.x/ctkgridlicense.c | 152 |
1 files changed, 80 insertions, 72 deletions
diff --git a/src/gtk+-2.x/ctkgridlicense.c b/src/gtk+-2.x/ctkgridlicense.c index dbb4914..f995d0a 100644 --- a/src/gtk+-2.x/ctkgridlicense.c +++ b/src/gtk+-2.x/ctkgridlicense.c @@ -371,6 +371,9 @@ static void UpdateConfigFileLinesFromGriddConfig( /* Update the lines in pLines */ for (i = 0; i < pLines->nLines; i++) { + /* TODO: "EnableUI" config parameter will never be + * set by the user through UI, so skip updating the + * pLines with "EnableUI" parameter */ pLines->lines[i] = UpdateLineWithGriddConfig(griddConfig, pLines->lines[i], itemIsPresent); @@ -396,22 +399,25 @@ static void UpdateGriddConfigFromGui( /* serverAddress */ - nvfree(griddConfig->str[NV_GRIDD_SERVER_ADDRESS]); tmp = gtk_entry_get_text(GTK_ENTRY( ctk_manage_grid_license->txt_server_address)); - griddConfig->str[NV_GRIDD_SERVER_ADDRESS] = nvstrdup(tmp ? tmp : ""); + if (strcmp(tmp, griddConfig->str[NV_GRIDD_SERVER_ADDRESS]) != 0) { + nvfree(griddConfig->str[NV_GRIDD_SERVER_ADDRESS]); + griddConfig->str[NV_GRIDD_SERVER_ADDRESS] = nvstrdup(tmp ? tmp : ""); + } /* serverPort */ - nvfree(griddConfig->str[NV_GRIDD_SERVER_PORT]); tmp = gtk_entry_get_text(GTK_ENTRY( ctk_manage_grid_license->txt_server_port)); - griddConfig->str[NV_GRIDD_SERVER_PORT] = - nvstrdup((strcmp(tmp, "") != 0) ? tmp : "7070"); + if (strcmp(tmp, griddConfig->str[NV_GRIDD_SERVER_PORT]) != 0) { + nvfree(griddConfig->str[NV_GRIDD_SERVER_PORT]); + griddConfig->str[NV_GRIDD_SERVER_PORT] = + nvstrdup((strcmp(tmp, "") != 0) ? tmp : "7070"); + } /* featureType */ - nvfree(griddConfig->str[NV_GRIDD_FEATURE_TYPE]); switch (ctk_manage_grid_license->feature_type) { case NV_GRID_LICENSE_FEATURE_TYPE_VAPP: tmp = "0"; @@ -425,23 +431,30 @@ static void UpdateGriddConfigFromGui( default: tmp = "0"; } - griddConfig->str[NV_GRIDD_FEATURE_TYPE] = nvstrdup(tmp); + if (strcmp(tmp, griddConfig->str[NV_GRIDD_FEATURE_TYPE]) != 0) { + nvfree(griddConfig->str[NV_GRIDD_FEATURE_TYPE]); + griddConfig->str[NV_GRIDD_FEATURE_TYPE] = nvstrdup(tmp); + } /* note: nothing in the UI will alter enableUI */ /* backupServerAddress */ - nvfree(griddConfig->str[NV_GRIDD_BACKUP_SERVER_ADDRESS]); tmp = gtk_entry_get_text(GTK_ENTRY( ctk_manage_grid_license->txt_secondary_server_address)); - griddConfig->str[NV_GRIDD_BACKUP_SERVER_ADDRESS] = nvstrdup(tmp ? tmp : ""); + if (strcmp(tmp, griddConfig->str[NV_GRIDD_BACKUP_SERVER_ADDRESS]) != 0) { + nvfree(griddConfig->str[NV_GRIDD_BACKUP_SERVER_ADDRESS]); + griddConfig->str[NV_GRIDD_BACKUP_SERVER_ADDRESS] = nvstrdup(tmp ? tmp : ""); + } /* backupServerPort */ - nvfree(griddConfig->str[NV_GRIDD_BACKUP_SERVER_PORT]); tmp = gtk_entry_get_text(GTK_ENTRY( ctk_manage_grid_license->txt_secondary_server_port)); - griddConfig->str[NV_GRIDD_BACKUP_SERVER_PORT] = nvstrdup(tmp ? tmp : ""); + if (strcmp(tmp, griddConfig->str[NV_GRIDD_BACKUP_SERVER_PORT]) != 0) { + nvfree(griddConfig->str[NV_GRIDD_BACKUP_SERVER_PORT]); + griddConfig->str[NV_GRIDD_BACKUP_SERVER_PORT] = nvstrdup(tmp ? tmp : ""); + } } /* @@ -517,7 +530,6 @@ static int UpdateConfigFile(CtkManageGridLicense *ctk_manage_grid_license) /* Read gridd.conf */ retErr = ReadConfigFile(&pLines); - if (retErr != 0) { goto done; } @@ -556,16 +568,15 @@ static NvGriddConfigParams *GetNvGriddConfigParams(void) NvGriddConfigParams *griddConfig = NULL; int retErr; + /* Create a griddConfig */ + griddConfig = AllocNvGriddConfigParams(); + /* Read gridd.conf */ retErr = ReadConfigFile(&pLines); - if (retErr != 0) { goto done; } - /* Create a griddConfig */ - griddConfig = AllocNvGriddConfigParams(); - /* Update the griddConfig with the lines from gridd.conf */ UpdateGriddConfigFromConfigFileLines(griddConfig, pLines); @@ -944,33 +955,62 @@ static void apply_clicked(GtkWidget *widget, gpointer user_data) gboolean ret; int err = 0; gint status = 0; + gboolean configFileAvailable; + gboolean writable = FALSE; - /* Add information to gridd.conf file */ - err = UpdateConfigFile(ctk_manage_grid_license); - - if (err == 0) { - /* Send update request to nvidia-gridd */ - ret = send_message_to_gridd(ctk_manage_grid_license, - LICENSE_DETAILS_UPDATE_REQUEST, - &status); - if ((!ret) || (status != LICENSE_DETAILS_UPDATE_SUCCESS)) { + /* Check available config file */ + configFileAvailable = checkConfigfile(&writable); + if (configFileAvailable && writable) { + /* Add information to gridd.conf file */ + err = UpdateConfigFile(ctk_manage_grid_license); + if (err == 0) { + /* Send update request to nvidia-gridd */ + ret = send_message_to_gridd(ctk_manage_grid_license, + LICENSE_DETAILS_UPDATE_REQUEST, + &status); + if ((!ret) || (status != LICENSE_DETAILS_UPDATE_SUCCESS)) { + GtkWidget *dlg, *parent; + + parent = ctk_get_parent_window(GTK_WIDGET(ctk_manage_grid_license)); + + dlg = gtk_message_dialog_new(GTK_WINDOW(parent), + GTK_DIALOG_MODAL, + GTK_MESSAGE_WARNING, + GTK_BUTTONS_OK, + "Unable to send license information " + "update request to the NVIDIA GRID " + "licensing daemon.\n" + "Please make sure nvidia-gridd and " + "dbus-daemon are running and retry applying the " + "license settings.\n"); + gtk_dialog_run(GTK_DIALOG(dlg)); + gtk_widget_destroy(dlg); + } + } else { GtkWidget *dlg, *parent; parent = ctk_get_parent_window(GTK_WIDGET(ctk_manage_grid_license)); - dlg = gtk_message_dialog_new(GTK_WINDOW(parent), GTK_DIALOG_MODAL, - GTK_MESSAGE_WARNING, + GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, - "Unable to send license information " - "update request to the NVIDIA GRID " - "licensing daemon.\n" - "Please make sure nvidia-gridd and " - "dbus-daemon are running and retry applying the " - "license settings.\n"); + "Unable to update GRID license configuration " + "file (%s): %s", GRID_CONFIG_FILE, strerror(err)); gtk_dialog_run(GTK_DIALOG(dlg)); gtk_widget_destroy(dlg); } + } else if (configFileAvailable && !(writable)) { + GtkWidget *dlg, *parent; + + parent = ctk_get_parent_window(GTK_WIDGET(ctk_manage_grid_license)); + dlg = gtk_message_dialog_new(GTK_WINDOW(parent), + GTK_DIALOG_MODAL, + GTK_MESSAGE_ERROR, + GTK_BUTTONS_OK, + "You do not have enough " + "permissions to edit '%s' file.", GRID_CONFIG_FILE); + gtk_dialog_run(GTK_DIALOG(dlg)); + gtk_widget_destroy(dlg); } else { GtkWidget *dlg, *parent; @@ -979,8 +1019,8 @@ static void apply_clicked(GtkWidget *widget, gpointer user_data) GTK_DIALOG_MODAL, GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, - "Unable to update GRID license configuration " - "file (%s): %s", GRID_CONFIG_FILE, strerror(err)); + "'%s' file does not exist.\n You do not have " + "permissions to create this file.", GRID_CONFIG_FILE); gtk_dialog_run(GTK_DIALOG(dlg)); gtk_widget_destroy(dlg); } @@ -1255,24 +1295,21 @@ static gboolean checkConfigfile(gboolean *writable) if ((fstat(fileno(configFile), &st) == 0) && (st.st_size == 0)) { if (*writable) { ConfigFileLines *pLines; - templateFile = fopen(GRID_CONFIG_FILE_TEMPLATE, "r"); if (templateFile == NULL) { nv_error_msg("Config file '%s' had size zero.", GRID_CONFIG_FILE); - goto done; - } - - pLines = ReadConfigFileStream(templateFile); + } else { + pLines = ReadConfigFileStream(templateFile); - WriteConfigFileStream(configFile, pLines); + WriteConfigFileStream(configFile, pLines); - FreeConfigFileLines(pLines); + FreeConfigFileLines(pLines); + } } else { nv_error_msg("Config file '%s' had size zero.", GRID_CONFIG_FILE); - goto done; } } ret = TRUE; @@ -1302,11 +1339,9 @@ GtkWidget* ctk_manage_grid_license_new(CtrlTarget *target, GtkWidget *button1 = NULL, *button2 = NULL; GSList *slist = NULL; gint ret; - gboolean configFileAvailable; DBusError err; DBusConnection* conn; DbusData *dbusData; - gboolean writable = FALSE; int64_t gridLicenseSupported; NvGriddConfigParams *griddConfig; @@ -1378,12 +1413,8 @@ GtkWidget* ctk_manage_grid_license_new(CtrlTarget *target, dbusData->dbus.dbusErrorFree(&err); } - /* Check available config file */ - configFileAvailable = checkConfigfile(&writable); - /* Initialize config parameters */ griddConfig = GetNvGriddConfigParams(); - if (griddConfig && (strcmp(griddConfig->str[NV_GRIDD_ENABLE_UI], "TRUE") != 0)) { return NULL; @@ -1437,21 +1468,6 @@ GtkWidget* ctk_manage_grid_license_new(CtrlTarget *target, gtk_box_pack_start(GTK_BOX(vbox), frame, FALSE, FALSE, 0); gtk_container_add(GTK_CONTAINER(frame), vbox1); - /* Show message if config file not available and user do not have - * permissions to create new file. - */ - if (!configFileAvailable && !griddConfig) { - str = g_strdup_printf("'%s' file does not exist.\n You do not have " - "permissions to create this file.", GRID_CONFIG_FILE); - label = gtk_label_new(str); - g_free(str); - hbox = gtk_hbox_new(FALSE, 0); - gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, TRUE, 5); - gtk_box_pack_start(GTK_BOX(vbox1), hbox, FALSE, FALSE, 5); - - goto done; - } - if (mode == NV_CTRL_ATTR_NVML_GPU_VIRTUALIZATION_MODE_PASSTHROUGH) { label = gtk_label_new("License Edition:"); hbox = gtk_hbox_new(FALSE, 0); @@ -1486,13 +1502,6 @@ GtkWidget* ctk_manage_grid_license_new(CtrlTarget *target, } - /* Only users with sufficient privileges can update server address - * and port number. - */ - if (!writable) { - gtk_widget_set_sensitive(GTK_WIDGET(vbox2), FALSE); - } - /* Show current license status message */ ctk_manage_grid_license->label_license_state = gtk_label_new("Unknown"); hbox = gtk_hbox_new(FALSE, 0); @@ -1716,7 +1725,6 @@ GtkWidget* ctk_manage_grid_license_new(CtrlTarget *target, g_free(str); FreeNvGriddConfigParams(griddConfig); -done: gtk_widget_show_all(GTK_WIDGET(ctk_manage_grid_license)); return GTK_WIDGET(ctk_manage_grid_license); |