Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

qemudriver: add support for netdev option in add_port_forward #1391

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ New Features in 24.0
used to pass additional options for the disk directly to QEMU
- labgrid-client now has a ``write-files`` subcommand to copy files onto mass
storage devices.
- The `QEMUDriver` now supports a ``netdev`` argumet which can be added to the
``tadd_port_forward`` in case there are more than one network interfaces
defined.


Bug fixes in 24.0
~~~~~~~~~~~~~~~~~
Expand Down
10 changes: 5 additions & 5 deletions labgrid/driver/qemudriver.py
Original file line number Diff line number Diff line change
Expand Up @@ -310,15 +310,15 @@ def monitor_command(self, command, arguments={}):
"Can't use monitor command on non-running target")
return self.qmp.execute(command, arguments)

def _add_port_forward(self, proto, local_address, local_port, remote_address, remote_port):
def _add_port_forward(self, proto, local_address, local_port, remote_address, remote_port, netdev):
self.monitor_command(
"human-monitor-command",
{"command-line": f"hostfwd_add {proto}:{local_address}:{local_port}-{remote_address}:{remote_port}"},
{"command-line": f"hostfwd_add {netdev} {proto}:{local_address}:{local_port}-{remote_address}:{remote_port}" },
)

def add_port_forward(self, proto, local_address, local_port, remote_address, remote_port):
self._add_port_forward(proto, local_address, local_port, remote_address, remote_port)
self._forwarded_ports[(proto, local_address, local_port)] = (proto, local_address, local_port, remote_address, remote_port)
def add_port_forward(self, proto, local_address, local_port, remote_address, remote_port, netdev=""):
self._add_port_forward(proto, local_address, local_port, remote_address, remote_port, netdev)
self._forwarded_ports[(proto, local_address, local_port)] = (proto, local_address, local_port, remote_address, remote_port, netdev)

def remove_port_forward(self, proto, local_address, local_port):
del self._forwarded_ports[(proto, local_address, local_port)]
Expand Down