Skip to content

Commit cb61435

Browse files
committed
docs: add SSH access guide for guest networking
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]>
1 parent aef0538 commit cb61435

2 files changed

Lines changed: 88 additions & 0 deletions

File tree

docs/en/cosim-usage-guide.md

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,50 @@ screen -r qemu-cosim
271271
# Detach from screen: Ctrl-A D
272272
```
273273

274+
#### 4.5 SSH Access to Guest
275+
276+
The `cosim_launch.sh` script enables user networking and SSH port forwarding by default (`-netdev user,id=net0,hostfwd=tcp::2222-:22` + `virtio-net-pci`). To use SSH access to the guest, configure networking inside the guest first.
277+
278+
**1. Identify the network interface name:**
279+
280+
```bash
281+
ip a
282+
```
283+
284+
Look for the virtio NIC interface (e.g., `enp0s2`). The exact name may vary depending on the PCI topology.
285+
286+
**2. Configure netplan:**
287+
288+
Edit `/etc/netplan/50-cloud-init.yaml`:
289+
290+
```yaml
291+
network:
292+
version: 2
293+
ethernets:
294+
enp0s2:
295+
dhcp4: true
296+
```
297+
298+
> **Note:** Replace `enp0s2` with the actual interface name from the `ip a` output.
299+
300+
**3. Apply the configuration:**
301+
302+
```bash
303+
netplan apply
304+
```
305+
306+
**4. SSH from the host:**
307+
308+
Open another terminal on the host and connect:
309+
310+
```bash
311+
ssh -p 2222 gem5@localhost
312+
```
313+
314+
Default password: `12345`.
315+
316+
> **Tip:** SSH access is much more convenient than the QEMU serial console for interactive use, file transfers (`scp -P 2222`), and running multiple sessions.
317+
274318
---
275319

276320
## Step 5: Load the GPU Driver

docs/zh/cosim-usage-guide.md

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,50 @@ screen -r qemu-cosim
271271
# 退出 screen: Ctrl-A D(分离)
272272
```
273273

274+
#### 4.5 SSH 访问 Guest
275+
276+
`cosim_launch.sh` 脚本默认启用了用户态网络和 SSH 端口转发(`-netdev user,id=net0,hostfwd=tcp::2222-:22` + `virtio-net-pci`)。要通过 SSH 访问 Guest,需要先在 Guest 内配置网络。
277+
278+
**1. 查看网卡名称:**
279+
280+
```bash
281+
ip a
282+
```
283+
284+
找到 virtio 网卡接口(如 `enp0s2`),具体名称取决于 PCI 拓扑,可能不同。
285+
286+
**2. 配置 netplan:**
287+
288+
编辑 `/etc/netplan/50-cloud-init.yaml`
289+
290+
```yaml
291+
network:
292+
version: 2
293+
ethernets:
294+
enp0s2:
295+
dhcp4: true
296+
```
297+
298+
> **注意:** 将 `enp0s2` 替换为 `ip a` 输出中的实际接口名称。
299+
300+
**3. 应用配置:**
301+
302+
```bash
303+
netplan apply
304+
```
305+
306+
**4. 从宿主机 SSH 登录:**
307+
308+
在宿主机上打开另一个终端,执行:
309+
310+
```bash
311+
ssh -p 2222 gem5@localhost
312+
```
313+
314+
默认密码:`12345`。
315+
316+
> **提示:** 相比 QEMU 串口控制台,SSH 访问在交互操作、文件传输(`scp -P 2222`)以及多会话场景下更加方便。
317+
274318
---
275319

276320
## 第五步:加载 GPU 驱动

0 commit comments

Comments
 (0)