[pve-devel] [PATCH qemu-server v2 1/1] enforce unicast MAC for $net_fmt

Stoiko Ivanov s.ivanov at proxmox.com
Mon Mar 11 22:50:15 CET 2019


creating a VM with a NIC with multicast mac (see [1]) is possible, but setting
the interface's link up inside the guest fails (tested on Debian stable).
The issue was noted with LXC first (see [0,2]) and then tested with Qemu.

This patch adapts the regex for matching the mac_prefix to only allow even
second hexdigits in the first octet.

[0] https://lists.linuxcontainers.org/pipermail/lxc-users/2010-August/000783.html
[1] https://en.wikipedia.org/wiki/MAC_address
[2] https://pve.proxmox.com/pipermail/pve-devel/2019-March/035996.html

Signed-off-by: Stoiko Ivanov <s.ivanov at proxmox.com>
---
 PVE/QemuServer.pm | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm
index 546b22e..c24359b 100644
--- a/PVE/QemuServer.pm
+++ b/PVE/QemuServer.pm
@@ -804,7 +804,7 @@ __EOD__
 my $net_fmt = {
     macaddr => {
 	type => 'string',
-	pattern => qr/[0-9a-f]{2}(?::[0-9a-f]{2}){5}/i,
+	pattern => qr/[a-f0-9][02468ace](?::[a-f0-9]{2}){5}/i,
 	description => "MAC address. That address must be unique withing your network. This is automatically generated if not specified.",
 	format_description => "XX:XX:XX:XX:XX:XX",
 	optional => 1,
-- 
2.11.0





More information about the pve-devel mailing list