SLIRP networking in bhyve doesn't support MAC and IP addresses configuration, so update the validation code to check that these options are not specified.
Signed-off-by: Roman Bogorodskiy <[email protected]> --- src/bhyve/bhyve_domain.c | 17 +++++++++++++- .../bhyvexml2argv-slirp-ip.xml | 22 +++++++++++++++++++ .../bhyvexml2argv-slirp-mac-addr.xml | 22 +++++++++++++++++++ tests/bhyvexml2argvtest.c | 2 ++ 4 files changed, 62 insertions(+), 1 deletion(-) create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-slirp-ip.xml create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-slirp-mac-addr.xml diff --git a/src/bhyve/bhyve_domain.c b/src/bhyve/bhyve_domain.c index 4c9ed29333..5c1ed86df6 100644 --- a/src/bhyve/bhyve_domain.c +++ b/src/bhyve/bhyve_domain.c @@ -325,6 +325,22 @@ bhyveDomainDeviceDefValidate(const virDomainDeviceDef *dev, break; } + case VIR_DOMAIN_DEVICE_NET: { + virDomainNetDef *net = dev->data.net; + + if (net->type == VIR_DOMAIN_NET_TYPE_USER) { + if (!net->mac_generated) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("setting MAC address for SLIRP networking is not supported")); + return -1; + } + if (net->guestIP.nips) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("setting IP addresses for SLIRP networking is not supported")); + return -1; + } + } + } case VIR_DOMAIN_DEVICE_AUDIO: case VIR_DOMAIN_DEVICE_CRYPTO: case VIR_DOMAIN_DEVICE_FS: @@ -337,7 +353,6 @@ bhyveDomainDeviceDefValidate(const virDomainDeviceDef *dev, case VIR_DOMAIN_DEVICE_LEASE: case VIR_DOMAIN_DEVICE_MEMBALLOON: case VIR_DOMAIN_DEVICE_MEMORY: - case VIR_DOMAIN_DEVICE_NET: case VIR_DOMAIN_DEVICE_NONE: case VIR_DOMAIN_DEVICE_NVRAM: case VIR_DOMAIN_DEVICE_PANIC: diff --git a/tests/bhyvexml2argvdata/bhyvexml2argv-slirp-ip.xml b/tests/bhyvexml2argvdata/bhyvexml2argv-slirp-ip.xml new file mode 100644 index 0000000000..0152066b4f --- /dev/null +++ b/tests/bhyvexml2argvdata/bhyvexml2argv-slirp-ip.xml @@ -0,0 +1,22 @@ +<domain type='bhyve'> + <name>bhyve</name> + <uuid>df3be7e7-a104-11e3-aeb0-50e5492bd3dc</uuid> + <memory>219136</memory> + <vcpu>1</vcpu> + <os> + <type>hvm</type> + </os> + <devices> + <disk type='file'> + <driver name='file' type='raw'/> + <source file='/tmp/freebsd.img'/> + <target dev='hda' bus='sata'/> + <address type='drive' controller='0' bus='0' target='2' unit='0'/> + </disk> + <interface type='user'> + <model type='e1000'/> + <ip family='ipv4' address='172.17.1.1' prefix='16'/> + <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/> + </interface> + </devices> +</domain> diff --git a/tests/bhyvexml2argvdata/bhyvexml2argv-slirp-mac-addr.xml b/tests/bhyvexml2argvdata/bhyvexml2argv-slirp-mac-addr.xml new file mode 100644 index 0000000000..b573d725d4 --- /dev/null +++ b/tests/bhyvexml2argvdata/bhyvexml2argv-slirp-mac-addr.xml @@ -0,0 +1,22 @@ +<domain type='bhyve'> + <name>bhyve</name> + <uuid>df3be7e7-a104-11e3-aeb0-50e5492bd3dc</uuid> + <memory>219136</memory> + <vcpu>1</vcpu> + <os> + <type>hvm</type> + </os> + <devices> + <disk type='file'> + <driver name='file' type='raw'/> + <source file='/tmp/freebsd.img'/> + <target dev='hda' bus='sata'/> + <address type='drive' controller='0' bus='0' target='2' unit='0'/> + </disk> + <interface type='user'> + <model type='e1000'/> + <mac address="00:11:22:33:44:56"/> + <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/> + </interface> + </devices> +</domain> diff --git a/tests/bhyvexml2argvtest.c b/tests/bhyvexml2argvtest.c index ee3d677947..645bcb876c 100644 --- a/tests/bhyvexml2argvtest.c +++ b/tests/bhyvexml2argvtest.c @@ -271,6 +271,8 @@ mymain(void) DO_TEST_FAILURE("disk-virtio-rotation-rate"); DO_TEST_FAILURE("disk-virtio-queue-opts"); DO_TEST("slirp"); + DO_TEST_FAILURE("slirp-mac-addr"); + DO_TEST_FAILURE("slirp-ip"); /* Address allocation tests */ DO_TEST("addr-single-sata-disk"); -- 2.51.2
