Custom patches for GNS3 network topology simulator & planning software.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

432 lines
16 KiB

Author: Pekka Helenius <pekka.helenius@fjordtek.com>
Date: Sun, 6 Jun 2021 15:10:45 +0200
Subject: [PATCH] GNS3 GUI: QEMU environment variables.
Add support for QEMU environment variables for GNS3 GUI.
--- a/tests/test_local_config.py
+++ b/tests/test_local_config.py
@@ -285,6 +285,7 @@
"enable_kvm": True,
"vms": [
{
+ "env_vars": "",
"kernel_image": "",
"kernel_command_line": "",
"first_port_name": "",
@@ -323,6 +324,7 @@
"platform": ""
},
{
+ "env_vars": "",
"kernel_image": "",
"kernel_command_line": "",
"server": "vm",
--- a/gns3/modules/qemu/settings.py
+++ b/gns3/modules/qemu/settings.py
@@ -27,6 +27,7 @@
}
QEMU_VM_SETTINGS = {
+ "env_vars": "",
"name": "",
"default_name_format": "{name}-{0}",
"usage": "",
--- a/gns3/modules/qemu/qemu_vm.py
+++ b/gns3/modules/qemu/qemu_vm.py
@@ -42,7 +42,8 @@
self._linked_clone = True
- qemu_vm_settings = {"usage": "",
+ qemu_vm_settings = {"env_vars": "",
+ "usage": "",
"qemu_path": "",
"hda_disk_image": "",
"hdb_disk_image": "",
--- a/gns3/modules/qemu/ui/qemu_vm_configuration_page_ui.py
+++ b/gns3/modules/qemu/ui/qemu_vm_configuration_page_ui.py
@@ -63,6 +63,12 @@
self.uiCPULabel = QtWidgets.QLabel(self.uiGeneralSettingsTab)
self.uiCPULabel.setObjectName("uiCPULabel")
self.gridLayout_4.addWidget(self.uiCPULabel, 5, 0, 1, 1)
+ self.uiEnvvarLabel = QtWidgets.QLabel(self.uiGeneralSettingsTab)
+ self.uiEnvvarLabel.setObjectName("uiEnvvarLabel")
+ self.gridLayout_4.addWidget(self.uiEnvvarLabel, 9, 0, 1, 1)
+ self.uiEnvvarLineEdit = QtWidgets.QLineEdit(self.uiGeneralSettingsTab)
+ self.uiEnvvarLineEdit.setObjectName("uiEnvvarLineEdit")
+ self.gridLayout_4.addWidget(self.uiEnvvarLineEdit, 9, 1, 1, 1)
self.uiCPUSpinBox = QtWidgets.QSpinBox(self.uiGeneralSettingsTab)
self.uiCPUSpinBox.setMinimum(1)
self.uiCPUSpinBox.setMaximum(255)
@@ -93,7 +99,7 @@
self.gridLayout_4.addWidget(self.uiOnCloseComboBox, 8, 1, 1, 1)
self.uiConsoleTypeLabel = QtWidgets.QLabel(self.uiGeneralSettingsTab)
self.uiConsoleTypeLabel.setObjectName("uiConsoleTypeLabel")
- self.gridLayout_4.addWidget(self.uiConsoleTypeLabel, 9, 0, 1, 1)
+ self.gridLayout_4.addWidget(self.uiConsoleTypeLabel, 10, 0, 1, 1)
self.horizontalLayout_2 = QtWidgets.QHBoxLayout()
self.horizontalLayout_2.setObjectName("horizontalLayout_2")
self.uiConsoleTypeComboBox = QtWidgets.QComboBox(self.uiGeneralSettingsTab)
@@ -107,9 +113,9 @@
self.uiConsoleAutoStartCheckBox = QtWidgets.QCheckBox(self.uiGeneralSettingsTab)
self.uiConsoleAutoStartCheckBox.setObjectName("uiConsoleAutoStartCheckBox")
self.horizontalLayout_2.addWidget(self.uiConsoleAutoStartCheckBox)
- self.gridLayout_4.addLayout(self.horizontalLayout_2, 9, 1, 1, 1)
+ self.gridLayout_4.addLayout(self.horizontalLayout_2, 10, 1, 1, 1)
spacerItem = QtWidgets.QSpacerItem(263, 94, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding)
- self.gridLayout_4.addItem(spacerItem, 10, 1, 1, 1)
+ self.gridLayout_4.addItem(spacerItem, 11, 1, 1, 1)
self.uiQemutabWidget.addTab(self.uiGeneralSettingsTab, "")
self.uiHddTab = QtWidgets.QWidget()
self.uiHddTab.setObjectName("uiHddTab")
@@ -462,6 +468,7 @@
self.uiRamLabel.setText(_translate("QemuVMConfigPageWidget", "RAM:"))
self.uiRamSpinBox.setSuffix(_translate("QemuVMConfigPageWidget", " MB"))
self.uiCPULabel.setText(_translate("QemuVMConfigPageWidget", "vCPUs:"))
+ self.uiEnvvarLabel.setText(_translate("QemuVMConfigPageWidget", "Environment variables:"))
self.uiQemuListLabel.setText(_translate("QemuVMConfigPageWidget", "Qemu binary:"))
self.uiBootPriorityLabel.setText(_translate("QemuVMConfigPageWidget", "Boot priority:"))
self.uiOnCloseLabel.setText(_translate("QemuVMConfigPageWidget", "On close:"))
--- a/gns3/modules/qemu/ui/qemu_vm_configuration_page.ui
+++ b/gns3/modules/qemu/ui/qemu_vm_configuration_page.ui
@@ -24,26 +24,23 @@
<string>General settings</string>
</attribute>
<layout class="QGridLayout" name="gridLayout_4">
- <item row="0" column="0">
- <widget class="QLabel" name="uiNameLabel">
+ <item row="1" column="0">
+ <widget class="QLabel" name="uiDefaultNameFormatLabel">
<property name="text">
- <string>Name:</string>
+ <string>Default name format:</string>
</property>
</widget>
</item>
- <item row="0" column="1">
- <widget class="QLineEdit" name="uiNameLineEdit"/>
+ <item row="8" column="2">
+ <widget class="QComboBox" name="uiOnCloseComboBox"/>
</item>
- <item row="1" column="0">
- <widget class="QLabel" name="uiDefaultNameFormatLabel">
+ <item row="0" column="0">
+ <widget class="QLabel" name="uiNameLabel">
<property name="text">
- <string>Default name format:</string>
+ <string>Name:</string>
</property>
</widget>
</item>
- <item row="1" column="1">
- <widget class="QLineEdit" name="uiDefaultNameFormatLineEdit"/>
- </item>
<item row="2" column="0">
<widget class="QLabel" name="uiSymbolLabel">
<property name="text">
@@ -51,64 +48,23 @@
</property>
</widget>
</item>
- <item row="2" column="1">
- <layout class="QHBoxLayout" name="horizontalLayout_7">
- <item>
- <widget class="QLineEdit" name="uiSymbolLineEdit"/>
- </item>
- <item>
- <widget class="QToolButton" name="uiSymbolToolButton">
- <property name="text">
- <string>&amp;Browse...</string>
- </property>
- <property name="toolButtonStyle">
- <enum>Qt::ToolButtonTextOnly</enum>
- </property>
- </widget>
- </item>
- </layout>
+ <item row="7" column="2">
+ <widget class="QComboBox" name="uiBootPriorityComboBox"/>
</item>
- <item row="3" column="0">
- <widget class="QLabel" name="uiCategoryLabel">
- <property name="text">
- <string>Category:</string>
+ <item row="6" column="2">
+ <widget class="QComboBox" name="uiQemuListComboBox">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Expanding" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
</property>
</widget>
</item>
- <item row="3" column="1">
+ <item row="3" column="2">
<widget class="QComboBox" name="uiCategoryComboBox"/>
</item>
- <item row="4" column="0">
- <widget class="QLabel" name="uiRamLabel">
- <property name="text">
- <string>RAM:</string>
- </property>
- </widget>
- </item>
- <item row="4" column="1">
- <widget class="QSpinBox" name="uiRamSpinBox">
- <property name="suffix">
- <string> MB</string>
- </property>
- <property name="minimum">
- <number>32</number>
- </property>
- <property name="maximum">
- <number>65535</number>
- </property>
- <property name="value">
- <number>256</number>
- </property>
- </widget>
- </item>
- <item row="5" column="0">
- <widget class="QLabel" name="uiCPULabel">
- <property name="text">
- <string>vCPUs:</string>
- </property>
- </widget>
- </item>
- <item row="5" column="1">
+ <item row="5" column="2">
<widget class="QSpinBox" name="uiCPUSpinBox">
<property name="minimum">
<number>1</number>
@@ -125,16 +81,33 @@
</property>
</widget>
</item>
- <item row="6" column="1">
- <widget class="QComboBox" name="uiQemuListComboBox">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Expanding" vsizetype="Fixed">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
+ <item row="8" column="0">
+ <widget class="QLabel" name="uiOnCloseLabel">
+ <property name="text">
+ <string>On close:</string>
</property>
</widget>
</item>
+ <item row="9" column="0">
+ <widget class="QLabel" name="uiConsoleTypeLabel">
+ <property name="text">
+ <string>Console type:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="11" column="2">
+ <spacer name="spacer">
+ <property name="orientation">
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>263</width>
+ <height>94</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
<item row="7" column="0">
<widget class="QLabel" name="uiBootPriorityLabel">
<property name="text">
@@ -142,27 +115,67 @@
</property>
</widget>
</item>
- <item row="7" column="1">
- <widget class="QComboBox" name="uiBootPriorityComboBox"/>
+ <item row="4" column="2">
+ <widget class="QSpinBox" name="uiRamSpinBox">
+ <property name="suffix">
+ <string> MB</string>
+ </property>
+ <property name="minimum">
+ <number>32</number>
+ </property>
+ <property name="maximum">
+ <number>65535</number>
+ </property>
+ <property name="value">
+ <number>256</number>
+ </property>
+ </widget>
</item>
- <item row="8" column="0">
- <widget class="QLabel" name="uiOnCloseLabel">
+ <item row="0" column="2">
+ <widget class="QLineEdit" name="uiNameLineEdit"/>
+ </item>
+ <item row="3" column="0">
+ <widget class="QLabel" name="uiCategoryLabel">
<property name="text">
- <string>On close:</string>
+ <string>Category:</string>
</property>
</widget>
</item>
- <item row="8" column="1">
- <widget class="QComboBox" name="uiOnCloseComboBox"/>
+ <item row="1" column="2">
+ <widget class="QLineEdit" name="uiDefaultNameFormatLineEdit"/>
</item>
- <item row="9" column="0">
- <widget class="QLabel" name="uiConsoleTypeLabel">
+ <item row="4" column="0">
+ <widget class="QLabel" name="uiRamLabel">
<property name="text">
- <string>Console type:</string>
+ <string>RAM:</string>
</property>
</widget>
</item>
- <item row="9" column="1">
+ <item row="2" column="2">
+ <layout class="QHBoxLayout" name="horizontalLayout_7">
+ <item>
+ <widget class="QLineEdit" name="uiSymbolLineEdit"/>
+ </item>
+ <item>
+ <widget class="QToolButton" name="uiSymbolToolButton">
+ <property name="text">
+ <string>&amp;Browse...</string>
+ </property>
+ <property name="toolButtonStyle">
+ <enum>Qt::ToolButtonTextOnly</enum>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item row="5" column="0">
+ <widget class="QLabel" name="uiCPULabel">
+ <property name="text">
+ <string>vCPUs:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="9" column="2">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QComboBox" name="uiConsoleTypeComboBox">
@@ -202,18 +215,15 @@
</item>
</layout>
</item>
- <item row="10" column="1">
- <spacer name="spacer">
- <property name="orientation">
- <enum>Qt::Vertical</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>263</width>
- <height>94</height>
- </size>
+ <item row="10" column="2">
+ <widget class="QLineEdit" name="uiEnvvarLineEdit"/>
+ </item>
+ <item row="10" column="0">
+ <widget class="QLabel" name="uiEnvvarLabel">
+ <property name="text">
+ <string>Environment variables:</string>
</property>
- </spacer>
+ </widget>
</item>
</layout>
</widget>
@@ -470,7 +480,16 @@
<string>CD/DVD</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_4">
- <property name="margin">
+ <property name="leftMargin">
+ <number>10</number>
+ </property>
+ <property name="topMargin">
+ <number>10</number>
+ </property>
+ <property name="rightMargin">
+ <number>10</number>
+ </property>
+ <property name="bottomMargin">
<number>10</number>
</property>
<item>
--- a/gns3/modules/qemu/pages/qemu_vm_configuration_page.py
+++ b/gns3/modules/qemu/pages/qemu_vm_configuration_page.py
@@ -444,6 +444,8 @@
self.uiInitrdLineEdit.setText(settings["initrd"])
self.uiKernelImageLineEdit.setText(settings["kernel_image"])
else:
+ self.uiEnvvarLabel.hide()
+ self.uiEnvvarLineEdit.hide()
self.uiNameLabel.hide()
self.uiNameLineEdit.hide()
self.uiHddTab.hide()
@@ -542,6 +544,7 @@
self.uiProcessPriorityComboBox.setCurrentIndex(index)
self.uiQemuOptionsLineEdit.setText(settings["options"])
self.uiUsageTextEdit.setPlainText(settings["usage"])
+ self.uiEnvvarLineEdit.setText(settings["env_vars"])
def saveSettings(self, settings, node=None, group=False):
"""
@@ -653,4 +656,5 @@
settings["process_priority"] = self.uiProcessPriorityComboBox.currentText().lower()
settings["options"] = self.uiQemuOptionsLineEdit.text()
settings["usage"] = self.uiUsageTextEdit.toPlainText()
+ settings["env_vars"] = self.uiEnvvarLineEdit.text()
return settings
--- a/gns3/modules/qemu/pages/qemu_vm_preferences_page.py
+++ b/gns3/modules/qemu/pages/qemu_vm_preferences_page.py
@@ -117,7 +117,7 @@
QtWidgets.QTreeWidgetItem(section_item, ["Base MAC address:", qemu_vm["mac_address"]])
# fill out the Linux boot section
- if qemu_vm["initrd"] or qemu_vm["kernel_image"] or qemu_vm["kernel_command_line"]:
+ if qemu_vm["initrd"] or qemu_vm["kernel_image"] or qemu_vm["kernel_command_line"] or qemu_vm["env_vars"]:
section_item = self._createSectionItem("Linux boot")
if qemu_vm["initrd"]:
QtWidgets.QTreeWidgetItem(section_item, ["Initial RAM disk:", qemu_vm["initrd"]])
@@ -125,6 +125,8 @@
QtWidgets.QTreeWidgetItem(section_item, ["Kernel image:", qemu_vm["kernel_image"]])
if qemu_vm["kernel_command_line"]:
QtWidgets.QTreeWidgetItem(section_item, ["Kernel command line:", qemu_vm["kernel_command_line"]])
+ if qemu_vm["env_vars"]:
+ QtWidgets.QTreeWidgetItem(section_item, ["Environment variables:", qemu_vm["env_vars"]])
# performance section
section_item = self._createSectionItem("Optimizations")
--- a/gns3/schemas/appliance.json
+++ b/gns3/schemas/appliance.json
@@ -329,6 +329,10 @@
"title": "KVM requirements",
"enum": ["require", "allow", "disable"]
},
+ "env_vars": {
+ "type": "string",
+ "title": "Environment variables"
+ },
"options": {
"type": "string",
"title": "Optional additional qemu command line options"