KVM Virtual Machines -- Host access from the VM


  1. Posts : 11,247
    Windows / Linux : Arch Linux
       #1

    KVM Virtual Machines -- Host access from the VM


    Hi there

    Don't do this on a LIVE distro though as these aren't persistent so you won't be able to save changes !!!!

    A good way of playing with this stuff without touching any Internal HDD's is to install the Linux system on an external HDD (SSD is better) connected via USB3-->SATA to computer -- response time is perfectly good enough even for the VM !!) -- This way it won't mess up any boot records on the HDD.

    For people using KVM/QEMU for creating VM's there's often a problem with the Virtual Machine's being able to access the HOST (the VM's can access Internet and other machines on your LAN OK of course).

    (I assume you've installed KVM/QEMU etc and know how to create a basic Virtual Machine first. - There's loads of info in the internet on how to do that if you aren't sure)

    The usual way around that is to create a Bridge which can be fiddly and currently these often don't work on a lot of Wireless NIC's

    So the easiest way is to create a separated "isolated" network and use 2 Virtual NIC's

    1) create an Isolated network on the Host say in any directory for example /tmp/isolated.xml (XML file) and give it a fixed IP address e.g as shown. (Use any decent text editor to create the XML file - you don't need a special XML editor --Windows Notepad is fine too.)

    In the example I've defined my network with the name isolated and the file is on /tmp.isolated.xml (note to create an empty file in Linux simply use the command touch e.g touch /tmp/isolated.xml - now you can edit it).

    <network>
    <name>isolated</name>
    <ip address="192.168.254.1" netmask="255.255.255.0">
    <dhcp>
    <range start="192.168.254.2" end="192.168.254.254"/>
    </dhcp>
    </ip>
    </network>

    2) Define it to the Host system : sudo virsh net-define /tmp/isolated.xml
    3) Start it : sudo virsh net-start isolated
    4) to start automatically at HOST boot : sudo virsh net-autostart isolated
    you should see console message : Network isolated marked as autostarted
    5) restart the libvirtd service. (sudo systemctl restart libvirtd) -- to automatically start the libvirtd service at HOST boot : sudo systemctl enable libvirtd)
    6)Now for the NICS for the VM in the VM config file -- nic 1 as <nic inteface e.g ethx or empxx or whatever>:macvtap source mode bridge, and the second one as Virtual network <name --in my case isolated> device model virtio -- you can use any hardware for the model - I'm using the paravirtualised stuff for windows VM's on the downloadable winvirtio iso from fedora site -- works with other distros without issue.

    7) start guest -- For guest access to the HOST the address will be fixed at 192.168.254.1 (note that's not the HOST's real IP address which is accessible as normal by rest of your LAN).

    KVM Virtual Machines -- Host access from the VM-screenshot_20200806_091711.png

    The XML file will look something like this for NIC 2 --depending on your hardware - it's automatically generated after you've defined the basic setup/

    <interface type="network">
    <mac address="52:54:00:b0:3c:94"/>
    <source network="isolated" portid="4afe495d-53a4-49fa-84e1-85d5c658bf78" bridge="virbr0"/>
    <target dev="vnet0"/>
    <model type="virtio"/>
    <alias name="net0"/>
    <address type="pci" domain="0x0000" bus="0x01" slot="0x00" function="0x0"/>
    </interface>

    To RDP (From another computer on your lan) to the Windows VM the HOSTNAME of the Windows machine should work properly --it does BTW on my systems--if not (then there's something wrong with name resolution) then use the IP address that's on the same subnet as your Lan --in this case the first IP address here

    KVM Virtual Machines -- Host access from the VM-screenshot_20200806_120842.png

    Works on Wifi cards as well if you want to mess about with this stuff on a Laptop !!!! - Always backup a Main Windows image though if installing a linux distro on your main Windows machine so you can restore again. Probably the best way to test this is to install the Linux system to external SSD/HDD rather than Dual boot -- remember though to allow enough HDD space for the Windows VM -- the actual Linux distro will sit quite happily with 10 - 20 GB depending on what you install.


    Cheers
    jimbo
    Last edited by jimbo45; 06 Aug 2020 at 06:16. Reason: suggest iinstall to external SSD/HDD rather than Dual boot
      My Computer


 

  Related Discussions
Our Sites
Site Links
About Us
Windows 10 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 10" and related materials are trademarks of Microsoft Corp.

© Designer Media Ltd
All times are GMT -5. The time now is 20:58.
Find Us




Windows 10 Forums