Skip to content

chore: enable user networking and ssh port forwarding for QEMU#6

Merged
zevorn merged 1 commit intozevorn:mainfrom
LoserJL:patch-1
Apr 10, 2026
Merged

chore: enable user networking and ssh port forwarding for QEMU#6
zevorn merged 1 commit intozevorn:mainfrom
LoserJL:patch-1

Conversation

@LoserJL
Copy link
Copy Markdown
Contributor

@LoserJL LoserJL commented Apr 10, 2026

Add params for QEMU:
-netdev "user,id=net0,hostfwd=tcp::2222-:22"
-device "virtio-net-pci,netdev=net0"
to enable user networking and ssh port forwarding.

@zevorn
Copy link
Copy Markdown
Owner

zevorn commented Apr 10, 2026

LGTM, Thanks for the contribution!

@zevorn zevorn merged commit 92dd4bb into zevorn:main Apr 10, 2026
4 checks passed
@LoserJL LoserJL deleted the patch-1 branch April 11, 2026 10:49
@LoserJL
Copy link
Copy Markdown
Contributor Author

LoserJL commented Apr 14, 2026

Run the cmd in qemu guest:
ip a
output:
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host noprefixroute
valid_lft forever preferred_lft forever
2: enp0s2: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
<cut here>
then modify /etc/netplan/50-cloud-init.yaml:
network:
version: 2
ethernets:
enp0s2:
hcp4: true
Note that enp0s2 is the output on my end, and you should modify it according to your own actual output.
After restarting QEMU or the network, the network connection will work properly.The QEMU terminal is rather inconvenient to use; you can open another terminal and run the following command:
ssh -p 2222 gem5@localhost
Enter the default password 12345 and you will be able to use it.

@zevorn
Copy link
Copy Markdown
Owner

zevorn commented Apr 14, 2026

Run the cmd in qemu guest: ip a output: 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000 link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo valid_lft forever preferred_lft forever inet6 ::1/128 scope host noprefixroute valid_lft forever preferred_lft forever 2: enp0s2: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000 <cut here> then modify /etc/netplan/50-cloud-init.yaml: network: version: 2 ethernets: enp0s2: hcp4: true Note that enp0s2 is the output on my end, and you should modify it according to your own actual output. After restarting QEMU or the network, the network connection will work properly.The QEMU terminal is rather inconvenient to use; you can open another terminal and run the following command: ssh -p 2222 gem5@localhost Enter the default password 12345 and you will be able to use it.

Thanks for the reply, I will update the user manual.

zevorn added a commit that referenced this pull request Apr 15, 2026
Add section 4.5 to the cosim usage guide (both en/zh) documenting
how to configure guest networking and SSH into the guest via the
port forwarding enabled in PR #6.

Steps: identify NIC name with `ip a`, configure netplan DHCP,
then `ssh -p 2222 gem5@localhost` from the host.

Signed-off-by: Chao Liu <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants