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

Stoiko Ivanov s.ivanov at proxmox.com
Tue Mar 12 16:07:45 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 uses the 'mac-addr' standard_option defined in PVE::JSONSchema to
ensure only unicast macaddresses are used for netconfig.

[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 | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm
index 546b22e..3158874 100644
--- a/PVE/QemuServer.pm
+++ b/PVE/QemuServer.pm
@@ -802,13 +802,9 @@ The DHCP server assign addresses to the guest starting from 10.0.2.15.
 __EOD__
 
 my $net_fmt = {
-    macaddr => {
-	type => 'string',
-	pattern => qr/[0-9a-f]{2}(?::[0-9a-f]{2}){5}/i,
+    macaddr  => get_standard_option('mac-addr', {
 	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,
-    },
+    }),
     model => {
 	type => 'string',
 	description => "Network Card Model. The 'virtio' model provides the best performance with very low CPU overhead. If your guest does not support this driver, it is usually best to use 'e1000'.",
-- 
2.11.0





More information about the pve-devel mailing list