From 6a9c7468de7be6b2ffc45100af544523d27b4fd8 Mon Sep 17 00:00:00 2001 From: Roman Bogorodskiy Date: Fri, 6 Jan 2017 21:06:23 +0400 Subject: [PATCH] bhyve: fix interface type handling for argv2xml When generating a domain XML from native command (i.e. via the connectDomainXMLFromNative call), we should use interface type 'bridge' rather than 'ethernet' because we only support bridges at this point. As we don't have bridge name explicitly specified on the command line, just use 'virbr0' as a default. --- src/bhyve/bhyve_parse_command.c | 9 ++++++--- tests/bhyveargv2xmldata/bhyveargv2xml-virtio-net.xml | 6 ++++-- tests/bhyveargv2xmldata/bhyveargv2xml-virtio-net4.xml | 3 ++- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/bhyve/bhyve_parse_command.c b/src/bhyve/bhyve_parse_command.c index 6190042983..e31f5fbd14 100644 --- a/src/bhyve/bhyve_parse_command.c +++ b/src/bhyve/bhyve_parse_command.c @@ -507,9 +507,12 @@ bhyveParsePCINet(virDomainDefPtr def, if (VIR_ALLOC(net) < 0) goto cleanup; - /* Let's just assume it is VIR_DOMAIN_NET_TYPE_ETHERNET, it could also be - * a bridge, but this is the most generic option. */ - net->type = VIR_DOMAIN_NET_TYPE_ETHERNET; + /* As we only support interface type='bridge' and cannot + * guess the actual bridge name from the command line, + * try to come up with some reasonable defaults */ + net->type = VIR_DOMAIN_NET_TYPE_BRIDGE; + if (VIR_STRDUP(net->data.bridge.brname, "virbr0") < 0) + goto error; net->info.type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI; net->info.addr.pci.slot = pcislot; diff --git a/tests/bhyveargv2xmldata/bhyveargv2xml-virtio-net.xml b/tests/bhyveargv2xmldata/bhyveargv2xml-virtio-net.xml index 09cc79b923..5895c8c53b 100644 --- a/tests/bhyveargv2xmldata/bhyveargv2xml-virtio-net.xml +++ b/tests/bhyveargv2xmldata/bhyveargv2xml-virtio-net.xml @@ -12,13 +12,15 @@ destroy destroy - + +
- + +
diff --git a/tests/bhyveargv2xmldata/bhyveargv2xml-virtio-net4.xml b/tests/bhyveargv2xmldata/bhyveargv2xml-virtio-net4.xml index e1bda46a16..5f19720804 100644 --- a/tests/bhyveargv2xmldata/bhyveargv2xml-virtio-net4.xml +++ b/tests/bhyveargv2xmldata/bhyveargv2xml-virtio-net4.xml @@ -12,8 +12,9 @@ destroy destroy - + +