Last active
March 18, 2023 13:37
-
-
Save junjuew/439d421fcac1482938e5d11c15152ac7 to your computer and use it in GitHub Desktop.
libvirt xml with port forwarding
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Use qemu directly with kvm | |
# sudo qemu-system-i386 -machine accel=kvm -m 2048 mn-trusty64server-170321-14-17-08/mininet-vm-x86_64.vmdk -net nic,model=virtio -net user,net=192.168.101.0/24,hostfwd=tcp::8022-:22 | |
# sample libvirt xml with port forwarding enabled | |
# copy the following | |
<domain type='kvm' xmlns:qemu='http://libvirt.org/schemas/domain/qemu/1.0'> | |
<name>mininet</name> | |
<uuid>cd4dbb45-1628-4310-9a1a-f8bc62ca91c0</uuid> | |
<memory unit='KiB'>4194304</memory> | |
<currentMemory unit='KiB'>4194304</currentMemory> | |
<vcpu placement='static'>2</vcpu> | |
<os> | |
<type arch='x86_64' machine='pc-i440fx-xenial'>hvm</type> | |
<boot dev='hd'/> | |
</os> | |
<features> | |
<acpi/> | |
<apic/> | |
</features> | |
<cpu mode='custom' match='exact'> | |
<model fallback='allow'>Haswell-noTSX-IBRS</model> | |
</cpu> | |
<clock offset='utc'> | |
<timer name='rtc' tickpolicy='catchup'/> | |
<timer name='pit' tickpolicy='delay'/> | |
<timer name='hpet' present='no'/> | |
</clock> | |
<on_poweroff>destroy</on_poweroff> | |
<on_reboot>restart</on_reboot> | |
<on_crash>restart</on_crash> | |
<pm> | |
<suspend-to-mem enabled='no'/> | |
<suspend-to-disk enabled='no'/> | |
</pm> | |
<devices> | |
<emulator>/usr/bin/kvm-spice</emulator> | |
<disk type='file' device='disk'> | |
<driver name='qemu' type='vmdk'/> | |
<source file='/home/junjuew/work/networking/mn-trusty64server-170321-14-17-08/mininet-vm-x86_64.vmdk'/> | |
<target dev='vda' bus='virtio'/> | |
<address type='pci' domain='0x0000' bus='0x00' slot='0x07' function='0x0'/> | |
</disk> | |
<controller type='usb' index='0' model='ich9-ehci1'> | |
<address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x7'/> | |
</controller> | |
<controller type='usb' index='0' model='ich9-uhci1'> | |
<master startport='0'/> | |
<address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x0' multifunction='on'/> | |
</controller> | |
<controller type='usb' index='0' model='ich9-uhci2'> | |
<master startport='2'/> | |
<address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x1'/> | |
</controller> | |
<controller type='usb' index='0' model='ich9-uhci3'> | |
<master startport='4'/> | |
<address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x2'/> | |
</controller> | |
<controller type='pci' index='0' model='pci-root'/> | |
<controller type='virtio-serial' index='0'> | |
<address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/> | |
</controller> | |
<serial type='pty'> | |
<target port='0'/> | |
</serial> | |
<console type='pty'> | |
<target type='serial' port='0'/> | |
</console> | |
<channel type='spicevmc'> | |
<target type='virtio' name='com.redhat.spice.0'/> | |
<address type='virtio-serial' controller='0' bus='0' port='1'/> | |
</channel> | |
<input type='mouse' bus='ps2'/> | |
<input type='keyboard' bus='ps2'/> | |
<graphics type='spice' autoport='yes'> | |
<image compression='off'/> | |
</graphics> | |
<sound model='ich6'> | |
<address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/> | |
</sound> | |
<video> | |
<model type='qxl' ram='65536' vram='65536' vgamem='16384' heads='1'/> | |
<address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/> | |
</video> | |
<redirdev bus='usb' type='spicevmc'> | |
</redirdev> | |
<redirdev bus='usb' type='spicevmc'> | |
</redirdev> | |
<memballoon model='virtio'> | |
<address type='pci' domain='0x0000' bus='0x00' slot='0x08' function='0x0'/> | |
</memballoon> | |
</devices> | |
<qemu:commandline> | |
<qemu:arg value='-netdev'/> | |
<qemu:arg value='user,id=portforwardingnic,net=192.168.101.0/24,hostfwd=tcp:127.0.0.1:8022-:22'/> | |
<qemu:arg value='-device'/> | |
<qemu:arg value='rtl8139,netdev=portforwardingnic,mac=88:88:88:88:88:88'/> | |
</qemu:commandline> | |
</domain> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment