Skip to contentSkip to conversation

hwsim: add NoVirtualInterface option to DBus API

PATCH In review James Prestwood 2 participants 6 messages Apr 5, 2022

lore
Share & tools
lore

James Prestwood

author
#0 lore raw

PATCH 1/5 hwsim: add NoVirtualInterface option to DBus API

This was available with --no-interface but no such option existed for the DBus API.

---
 tools/hwsim.c | 8 ++++++++
 1 file changed, 8 insertions(+)
tools/hwsim.c +8 -0
index de808074..8dcb75c4 100644
@@ -1707,6 +1707,7 @@ static struct l_dbus_message *radio_manager_create(struct l_dbus *dbus,
 	bool p2p = false;
 	const char *disabled_iftypes = NULL;
 	const char *disabled_ciphers = NULL;
+	bool no_vif = false;
 	struct radio_info_rec *radio;
 
 	if (!l_dbus_message_get_arguments(message, "a{sv}", &dict))
@@ -1727,6 +1728,10 @@ static struct l_dbus_message *radio_manager_create(struct l_dbus *dbus,
 		else if (!strcmp(key, "CipherTypeDisable"))
 			ret = l_dbus_message_iter_get_variant(&variant, "s",
 							&disabled_ciphers);
+		else if (!strcmp(key, "NoVirtualInterface"))
+			ret = l_dbus_message_iter_get_variant(&variant, "b",
+							&no_vif);
+
 		if (!ret)
 			goto invalid;
 	}
@@ -1765,6 +1770,9 @@ static struct l_dbus_message *radio_manager_create(struct l_dbus *dbus,
 
 	}
 
+	if (no_vif)
+		l_genl_msg_append_attr(new_msg, HWSIM_ATTR_NO_VIF, 0, NULL);
+
 	radio = l_new(struct radio_info_rec, 1);
 	radio->pending = l_dbus_message_ref(message);
 	radio->name = l_strdup(name);
Signature · 1 line
2.34.1
author
#1 lore raw

PATCH 2/5 auto-t: hwsim.py: set NoVirtualInterface by default

There is really no reason to have hwsim create interfaces automatically for test-runner. test-runner already does this for wpa_supplicant and hostapd, and IWD can create the interface itself.

---
 autotests/util/hwsim.py | 1 +
 1 file changed, 1 insertion(+)
autotests/util/hwsim.py +1 -0
index ce85f43d..80a847ad 100755
@@ -314,6 +314,7 @@ class RadioList(collections.Mapping):
         args = dbus.Dictionary({
             'Name': name,
             'P2P': p2p_device,
+            'NoVirtualInterface': True,
         }, signature='sv')
 
         if iftype_disable:
Signature · 1 line
2.34.1
author
#2 lore raw

PATCH 3/5 test-runner: resolve absolute path for --start argument

In reply to James Prestwood
---
 tools/runner.py | 2 ++
 1 file changed, 2 insertions(+)
tools/runner.py +2 -0
index f244016f..fc1cab44 100644
@@ -211,6 +211,8 @@ class Runner:
 				args.start = os.path.abspath('tools/run-tests')
 			else:
 				raise Exception("Cannot locate run-tests binary")
+		else:
+			args.start = os.path.abspath(args.start)
 
 		# If no runner is specified but we have a kernel image assume
 		# if the kernel is executable its UML, otherwise qemu
Signature · 1 line
2.34.1
author
#3 lore raw

PATCH 4/5 test-runner: enable scripts to be executed as init

In reply to James Prestwood

This enables CONFIG_BINFMT_SCRIPT which allows the init process to interpret #! and execute the script rather than requiring a binary for init.

---
 tools/test_runner_kernel_config | 1 +
 1 file changed, 1 insertion(+)
tools/test_runner_kernel_config +1 -0
index 7806fdb2..c7049edd 100755
@@ -51,3 +51,4 @@ scripts/config --enable CONFIG_SECURITYFS
 scripts/config --enable CONFIG_BINFMT_ELF
 scripts/config --enable CONFIG_HOSTFS
 scripts/config --enable CONFIG_UML_TIME_TRAVEL_SUPPORT
+scripts/config --enable CONFIG_BINFMT_SCRIPT
Signature · 1 line
2.34.1
author
#4 lore raw

PATCH 5/5 test-runner: fix --help and unknown options

In reply to James Prestwood

If --help or unknown options were supplied to test-runner python would thrown a maximum recusion depth exception. This was due to the way ArgumentParser was subclassed.

To fix this call ArgumentParser.__init__() rather than using the super() method. And do this also for the RunnerCoreArgParse subclass as well. In addition the namespace argument was removed from parse_args since its not used, and instead supplied directly to the parents parse_args method.

---
 tools/runner.py | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
tools/runner.py +5 -5
index fc1cab44..0068c74f 100644
@@ -92,7 +92,7 @@ class RunnerNamespace(Namespace):
 #
 class RunnerCoreArgParse(ArgumentParser):
 	def __init__(self, *args, **kwargs):
-		super().__init__(self, *args, **kwargs)
+		ArgumentParser.__init__(self, *args, **kwargs)
 
 		self.add_argument('--start', '-s',
 				help='Custom init process in virtual environment',
@@ -154,23 +154,23 @@ class RunnerCoreArgParse(ArgumentParser):
 				dest='valgrind')
 
 	# Overwrite to use a custom namespace class and parse from env
-	def parse_args(self, *args, namespace=RunnerNamespace()):
+	def parse_args(self, *args):
 		if len(sys.argv) > 1:
-			return super().parse_args(*args, namespace=namespace)
+			return super().parse_args(*args, namespace=RunnerNamespace())
 
 		options = []
 		for k, v in os.environ.items():
 			options.append('--' + k)
 			options.append(v)
 
-		return self.parse_known_args(args=options, namespace=namespace)[0]
+		return self.parse_known_args(args=options, namespace=RunnerNamespace())[0]
 
 #
 # Arguments only needed outside the test environment
 #
 class RunnerArgParse(RunnerCoreArgParse):
 	def __init__(self, *args, **kwargs):
-		super().__init__(*args, **kwargs)
+		RunnerCoreArgParse.__init__(self, *args, **kwargs)
 
 		self.add_argument('--runner', '-r',
 				metavar='<runner type>',
Signature · 1 line
2.34.1
#5 lore raw
In reply to James Prestwood

Hi James,

Quoted 6 lines · James Prestwood

This was available with --no-interface but no such option existed for the DBus API.

---
  tools/hwsim.c | 8 ++++++++
  1 file changed, 8 insertions(+)

All applied, thanks.

Regards,
-Denis