Skip to content

Commit

Permalink
add network to guest to make it accessible via IP (#239)
Browse files Browse the repository at this point in the history
* add network card with dhcp ip
  • Loading branch information
hector-cao authored Oct 3, 2024
1 parent 70e06d0 commit 82cd552
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 3 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -243,10 +243,11 @@ TD, PID: 111924, SSH : ssh -p 10022 root@localhost
```console
Id Name State
---------------------------------------------------------------------------
1 tdvirsh-trust_domain-f7210c2b-2657-4f30-adf3-639b573ea39f running (ssh:32855, cid:3)
1 tdvirsh-trust_domain-f7210c2b-2657-4f30-adf3-639b573ea39f running (ip:192.168.122.212, hostfwd:32855, cid:3)
```

NOTE: `32855` in `ssh:32855` is the port number a user can use to connect to the TD via `ssh`.
NOTE: `32855` in `hostfwd:32855` is the port number a user can use to connect to the TD via `ssh -p 32855 root@localhost`.
You can also connect to the guest using its IP address : `ssh [email protected]`.

* A TD can be removed with the following command:

Expand Down
5 changes: 5 additions & 0 deletions guest-tools/regular_vm.xml.template
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@
</backingStore>
<target dev="vda" bus="virtio"/>
</disk>
<interface type='network'>
<source network='default'/>
<model type='virtio'/>
<address type='pci' domain='0x0000' bus='0x06' slot='0x00' function='0x0'/>
</interface>
<console type='pty'>
<target type='virtio' port='1'/>
</console>
Expand Down
11 changes: 10 additions & 1 deletion guest-tools/tdvirsh
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,16 @@ print_all() {
--hmp info qtree 2>&1 |
awk '/guest-cid/ {print $3}'
)
extra_info="(ssh:$host_port, cid:${guest_cid})"
host_ip=$(
virsh domifaddr ${td_domain} 2>&1 |
awk '/vnet/ {print $4}'
)
if [[ "${host_ip}" != */* ]]; then
host_ip="unknown"
else
host_ip="${host_ip%/*}"
fi
extra_info="(ip:${host_ip}, hostfwd:$host_port, cid:${guest_cid})"
fi
echo "$line $extra_info"
done < <(virsh "list --all")
Expand Down
5 changes: 5 additions & 0 deletions guest-tools/trust_domain-sb.xml.template
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@
</backingStore>
<target dev="vda" bus="virtio"/>
</disk>
<interface type='network'>
<source network='default'/>
<model type='virtio'/>
<address type='pci' domain='0x0000' bus='0x06' slot='0x00' function='0x0'/>
</interface>
<console type='pty'>
<target type='virtio' port='1'/>
</console>
Expand Down
5 changes: 5 additions & 0 deletions guest-tools/trust_domain.xml.template
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@
</backingStore>
<target dev="vda" bus="virtio"/>
</disk>
<interface type='network'>
<source network='default'/>
<model type='virtio'/>
<address type='pci' domain='0x0000' bus='0x06' slot='0x00' function='0x0'/>
</interface>
<console type='pty'>
<target type='virtio' port='1'/>
</console>
Expand Down

0 comments on commit 82cd552

Please sign in to comment.