[CentOS] Cloning bridged VMs : VirtualBox vs. KVM

Wed Mar 24 16:51:06 UTC 2021
Nicolas Kovacs <info at microlinux.fr>

Hi,

(tl;dr : how can I clone a KVM-based bridged virtual machine and force a
duplicate MAC address ?)

Up until recently I've been using VirtualBox on my workstation to test various
local setups. Usually I would setup a basic CentOS installation, and whenever I
wanted to fiddle around, I would just clone that system and play around with
it. So whenever I shot myself in the foot on that VM, I would simply erase it
and start over again with a new clone. Think of it as a disposable VM.

All my VMs under VirtualBox used bridged mode, so they were in the same
network. And in my local proxy server, I have Dnsmasq that assigns static IP
addresses and meaningful hostnames to these VMs. Here's what the corresponding
lines in dnsmasq.conf look like:

dhcp-host=08:00:27:00:00:01,suse-lp151,192.168.2.10
dhcp-host=08:00:27:00:00:02,suse-lp152,192.168.2.11
dhcp-host=08:00:27:00:00:03,ce7-server,192.168.2.12
dhcp-host=08:00:27:00:00:04,ce8-server,192.168.2.13
dhcp-host=08:00:27:00:00:05,ol7-server,192.168.2.14
dhcp-host=08:00:27:00:00:06,ol8-server,192.168.2.15
dhcp-host=08:00:27:00:00:07,rh7-server,192.168.2.16
dhcp-host=08:00:27:00:00:08,rh8-server,192.168.2.17

Over the last two weeks, I decided to migrate from VirtualBox to KVM even for
local configurations and virtualized desktop configurations. So far, everything
works nice... except one problem I can't seem to solve (yet).

I'm using KVM in bridged mode, over a br0 bridge on my workstation. Like with
VirtualBox, all my KVM virtual machines are part of my local 192.168.2.0/24
network.

Unfortunately there is no way to simply make a perfect clone of a virtual
machine using virt-manager. It insists on assigning my cloned VM a different
MAC address. And whenever I want to manually create a NIC with the same MAC
address as the original, Virtual Machine Manager tells me I can't do that. Same
player shoot again.

Now I know that is normally a good thing. You don't want MAC address conflicts
in your network. But here's the thing: I don't intend to fire up both copies at
once. As with VirtualBox, I only intend to use one VM at a time, for testing
purposes. Now how can I "explain" this to Virtual Machine Manager without
having to jump through burning loops ?

Cheers,

Niki

-- 
Microlinux - Solutions informatiques durables
7, place de l'église - 30730 Montpezat
Site : https://www.microlinux.fr
Blog : https://blog.microlinux.fr
Mail : info at microlinux.fr
Tél. : 04 66 63 10 32
Mob. : 06 51 80 12 12