Re: Network connection of a qemu guest.
From: Reco Date: Fri, 12 Mar 2021 08:26:51 +0300 > No, it does not work that way. Got the network connection and added documention here. https://en.wikibooks.org/wiki/Oberon/ETH_Oberon/QEMUinstall#Network_Connection_on_a_Virtual_Machine Further tips always welcome. Thanks,... P. -- cell: +1 236 464 1479Bcc: peter at easthope. ca VoIP: +1 604 670 0140
Re: Network connection of a qemu guest.
Hi. On Thu, Mar 11, 2021 at 02:19:28PM -0800, pe...@easthope.ca wrote: > There's no mention of shutting off the built-in DHCP server. That's because there's no need to. Unless guess OS requests a DHCP less, a DHCP server will remain dormant. > Maybe a specific ip address shuts it off. No, it does not work that way. > > If you don't like guest OS to be configured by DHCP, you're welcome to > > use /e/n/i snippet that I referenced in my previous e-mail. > > I added this stanza to /e/n/i . > > # An interface for subnet to qemu guest. > auto qemunic It should not work this way, and it did not. You're supposed to use the interface name your guest OS sees (as in - "ifconfig", "ip a"), not QEMU label ("qemunic" in this case). > The qemu -nic option above has "id=qemunic" and the stanza above > has qemunic. An "id" option has nothing to do with guest OS interface name. It's merely a label to distinguish between several instances of virtual hardware of the same type. For instance, one can specify several NICs for the quest this way: qemu-system-x86_64 -name ... \ -netdev tap,id=hostnet0,fd=3 -device \ virtio-net-pci,netdev=hostnet0,id=net0,mac=$MAC0 \ -netdev tap,id=hostnet1,fd=4 -device \ virtio-net-pci,netdev=hostnet1,id=net1,mac=$MAC1 \ -netdev tap,id=hostnet2,fd=5 -device \ virtio-net-pci,netdev=hostnet2,id=net2,mac=$MAC2 \ -netdev tap,id=hostnet3,fd=6 \ -device virtio-net-pci,netdev=hostnet3,id=net3,mac=$MAC3 \ And it does not make guest OS network interfaces to be called hostnet0 or net0, for instance. Reco
Re: Network connection of a qemu guest.
P.s. I added this stanza to host:/e/n/i . # An interface for subnet to qemu guest. auto qemunic allow-hotplug qemunic iface qemunic inet static address 10.0.2.1 netmask 255.255.255.0 Not guest:/e/n/i . Thanks,... P. -- cell: +1 236 464 1479Bcc: peter at easthope. ca VoIP: +1 604 670 0140
Re: Network connection of a qemu guest.
From: Reco Date: Thu, 11 Mar 2021 21:01:01 +0300 > DHCP is an option for a network configuration, not a requirement. >From the qemu manual. peter@joule:/home/peter/MY$ man qemu-system-i386 | grep DHCP Specifies the client hostname reported by the built-in DHCP Specify the first of the 16 IPs the built-in DHCP server can in DHCP server. More than one domain suffix can be transmitted Specifies the client domain name reported by the built-in DHCP (default first address given by the built-in DHCP server). By peter@joule:/home/peter/MY$ man qemu-system-i386 | grep dhcp dhcpstart=addr There's no mention of shutting off the built-in DHCP server. Maybe a specific ip address shuts it off. qemu-system-i386 \ -nic user,model=ne2k_pci,ipv6=off,id=qemunic,net=10.0.2.2/24 \ ... Qemu works. The options aren't catastrophic. > If you don't like guest OS to be configured by DHCP, you're welcome to > use /e/n/i snippet that I referenced in my previous e-mail. I added this stanza to /e/n/i . # An interface for subnet to qemu guest. auto qemunic allow-hotplug qemunic iface qemunic inet static address 10.0.2.1 netmask 255.255.255.0 root@joule:~# /etc/init.d/networking restart Restarting networking (via systemctl): networking.serviceJob for networking.serv ice failed because the control process exited with error code. See "systemctl status networking.service" and "journalctl -xe" for details. failed! > Ok, but surely it's a little problem to replace "eth0" with > "enx", isn't it? The qemu -nic option above has "id=qemunic" and the stanza above has qemunic. Nevertheless, host networking isn't happy with it. " -nic tap, ..." might be a better bet than " -nic user, ...". Other tips? Thanks,... P. -- cell: +1 236 464 1479Bcc: peter at easthope. ca VoIP: +1 604 670 0140
Re: Network connection of a qemu guest.
Hi. On Thu, Mar 11, 2021 at 07:25:30AM -0800, pe...@easthope.ca wrote: > All the QEMU documentation I've found focusses on DHCP. Imagine the > guest system tries to set a static address and QEMU offers DHCP. Seems > unlikely to succeed. DHCP is an option for a network configuration, not a requirement. If you don't like guest OS to be configured by DHCP, you're welcome to use /e/n/i snippet that I referenced in my previous e-mail. > Should be a way to configure qemu to provide a > subnet to the guest on an interface with a static address. (?) Please clarify. Where exactly you need a static address to be configured? At the guest OS's NIC? At the QEMU's emulated gateway? Elsewhere? > > Of course, as it's not a point-to-point connection. > > Yes, but a stanza in /etc/network/interfaces refers to an interface > name. The Debian 10 here for example, includes interface > enx0050b60be9be which is used for a subnet. Ok, but surely it's a little problem to replace "eth0" with "enx", isn't it? > To make a valid stanza for the qemu guest an interface name is > essential. I agree. > Either qemu must invent a name It's definitely does not work this way. QEMU has no way to specify an exact name for the guest OS. > or the qemu configuration will have to specify it. Nope. QEMU's job is to run unmodified guest OS, no more and no less. Specific OS implementation details (such as NIC names) are left to the specific OS to handle. > Another detail I haven't found in the documentation. QEMU's documentation is an unsuitable place to describe OS-specific implementation details. Try [1], chapter 4, instead. Reco [1] https://wiki.debian.org/NetworkInterfaceNames
Re: Network connection of a qemu guest.
Reco, Thanks for the reply. > In this case QEMU uses built-in DHCP server to provide 10.0.2/24 network > to the guest OS. If you need another network it should be changed in > QEMU's commandline. Thanks. I'm trying to set a _static_ address for the guest. https://en.wikipedia.org/wiki/Static_ip_address Ref. https://lists.debian.org/debian-user/2021/03/msg00546.html All the QEMU documentation I've found focusses on DHCP. Imagine the guest system tries to set a static address and QEMU offers DHCP. Seems unlikely to succeed. Should be a way to configure qemu to provide a subnet to the guest on an interface with a static address. (?) > Of course, as it's not a point-to-point connection. Yes, but a stanza in /etc/network/interfaces refers to an interface name. The Debian 10 here for example, includes interface enx0050b60be9be which is used for a subnet. To make a valid stanza for the qemu guest an interface name is essential. Either qemu must invent a name or the qemu configuration will have to specify it. Another detail I haven't found in the documentation. Thanks,... P. -- cell: +1 236 464 1479Bcc: peter at easthope. ca VoIP: +1 604 670 0140
Re: Network connection of a qemu guest.
Hi. On Wed, Mar 10, 2021 at 02:56:30PM -0800, pe...@easthope.ca wrote: > qemu-system-i386 -nic user,ipv6=off,model=ne2k_pci ... In this case QEMU uses built-in DHCP server to provide 10.0.2/24 network to the guest OS. If you need another network it should be changed in QEMU's commandline. > How is a static IP address set? For the quest OS it is like this: auto eth0 iface eth0 static address 10.0.2.15 netmask 24 gateway 10.0.2.2 10.0.2.1 and 10.0.2.2 are "special" and are used by QEMU itself. Anything else is to be used by the quest OS. > Should a subnet be specified in /etc/network/interfaces? Of course, as it's not a point-to-point connection. Reco
Re: Network connection of a qemu guest.
pe...@easthope.ca wrote: > Will be happy with telnet or ssh or ftp from the guest to the host. (I > know telnet and ftp aren't secure but all is within one machine which > runs shorewall.) No other machine is involved, for now at least. > > Thanks again, https://wiki.qemu.org/Documentation/Networking there are different ways to set up networking in the qemu. I actually choose to take the "bridge" way so that I can set the IP via DHCP on the local network (still not sure if it were possible the other way around). At the end it looked like this sudo qemu-system-aarch64 -nographic -no-reboot \ -boot n \ -machine virt,gic-version=max -m 2048 -cpu cortex-a53 -smp 4 \ -device virtio-net-pci,netdev=vnet,mac=52:54:00:12:xx:xx \ -netdev user,id=vnet,type=tap \ -device virtio-blk-pci,drive=hd \ -drive if=none,file=swap.qcow2,format=qcow2,id=hd \ -kernel vmlinuz-4.19.0-13-arm64 \ -initrd initrd.img-4.19.0-13-arm64 \ -append "root=/dev/nfs rw \ nfsroot=192.168.xx.xx:/opt/remote/nfsroot/rpi4b-arm64 ip=dhcp"
Re: Network connection of a qemu guest.
Nate, Thanks for the reply. From: Nate Bargmann Date: Wed, 10 Mar 2021 19:43:58 -0600 > I rely on the Qemu system to setup the IP address from the 10.x.x.x > block but that seems only to be accessible from inside the VM: So, for example, the host might set 10.3.3.1 on its interface to the guest? The same address after rebooting the guest? Rebooting the host? Then in the guest system you can configure 10.3.3.2? So the guest is on the 10.3.3.x subnet? > Host buster > HostName localhost > Port > user "user" > IdentityFile /home/"user"/.ssh/id_buster > > Then a simple 'ssh buster' allows me to SSH from the host the VM is > running on. > Hopefully this can help you get started so you can make it > accessible from hosts on your LAN if that is what you're looking to > do. Will be happy with telnet or ssh or ftp from the guest to the host. (I know telnet and ftp aren't secure but all is within one machine which runs shorewall.) No other machine is involved, for now at least. Thanks again,... P. -- cell: +1 236 464 1479Bcc: peter at easthope. ca VoIP: +1 604 670 0140
Re: Network connection of a qemu guest.
* On 2021 10 Mar 17:36 -0600, pe...@easthope.ca wrote: > Hi again, > > https://wiki.qemu.org/Documentation/Networking > and > http://en.wikibooks.org/wiki/QEMU/Networking > refer to qemu options -net, -netdev and -device whereas the manual for > qemu 1:3.1+dfsg-8+deb10u8 describes -nic as current. > > For an virtual NE 2000 NIC this is my trial configuration. > > qemu-system-i386 -nic user,ipv6=off,model=ne2k_pci ... > > How is a static IP address set? Should a subnet be specified in > /etc/network/interfaces? Analogous to a real machine subnetted on an > Ethernet cable? I rely on the Qemu system to setup the IP address from the 10.x.x.x block but that seems only to be accessible from inside the VM: qemu-system-i386 \ -enable-kvm \ -smp cpus=2 \ -m 2G \ -device intel-hda \ -device hda-duplex \ -net nic,model=e1000 \ -net user,hostfwd=tcp::-:22 \ -hda ${HOME}/Qemu/buster/buster.qcow2 The '-ner user' line sets up port forwarding to the port on the host machine from port 22 on the VM. Then to SSH into the guest when I need to I have the following set in ~/.ssh/config: Host buster HostName localhost Port user "user" IdentityFile /home/"user"/.ssh/id_buster Then a simple 'ssh buster' allows me to SSH from the host the VM is running on. Hopefully this can help you get started so you can make it accessible from hosts on your LAN if that is what you're looking to do. - Nate -- "The optimist proclaims that we live in the best of all possible worlds. The pessimist fears this is true." Web: https://www.n0nb.us Projects: https://github.com/N0NB GPG fingerprint: 82D6 4F6B 0E67 CD41 F689 BBA6 FB2C 5130 D55A 8819 signature.asc Description: PGP signature
Network connection of a qemu guest.
Hi again, https://wiki.qemu.org/Documentation/Networking and http://en.wikibooks.org/wiki/QEMU/Networking refer to qemu options -net, -netdev and -device whereas the manual for qemu 1:3.1+dfsg-8+deb10u8 describes -nic as current. For an virtual NE 2000 NIC this is my trial configuration. qemu-system-i386 -nic user,ipv6=off,model=ne2k_pci ... How is a static IP address set? Should a subnet be specified in /etc/network/interfaces? Analogous to a real machine subnetted on an Ethernet cable? Thx,... P. -- cell: +1 236 464 1479Bcc: peter at easthope. ca VoIP: +1 604 670 0140