[libvirt] [PATCH] networkGetDHCPLeases: Don't always report error if unable to read leases file
by Michal Privoznik
https://bugzilla.redhat.com/show_bug.cgi?id=1600468
If we are unable to read leases file (no matter what the reason
is), we return 0 - just like if there were no leases. However,
because we use virFileReadAll() an error is printed into the log.
Note that not all networks have leases file - only those for
which we start dnsmasq.
Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
---
src/network/bridge_driver.c | 21 ++++++++++++++-------
1 file changed, 14 insertions(+), 7 deletions(-)
diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c
index a7826e9b63..5839021caf 100644
--- a/src/network/bridge_driver.c
+++ b/src/network/bridge_driver.c
@@ -4235,13 +4235,20 @@ networkGetDHCPLeases(virNetworkPtr net,
custom_lease_file = networkDnsmasqLeaseFileNameCustom(driver, def->bridge);
/* Read entire contents */
- if ((custom_lease_file_len = virFileReadAll(custom_lease_file,
- VIR_NETWORK_DHCP_LEASE_FILE_SIZE_MAX,
- &lease_entries)) < 0) {
- /* Even though src/network/leaseshelper.c guarantees the existence of
- * leases file (even if no leases are present), and the control reaches
- * here, instead of reporting error, return 0 leases */
- rv = 0;
+ if ((custom_lease_file_len = virFileReadAllQuiet(custom_lease_file,
+ VIR_NETWORK_DHCP_LEASE_FILE_SIZE_MAX,
+ &lease_entries)) < 0) {
+ /* Not all networks are guaranteed to have leases file.
+ * Only those which run dnsmasq. Therefore, if we failed
+ * to read the leases file, don't report error. Return 0
+ * leases instead. */
+ if (errno != ENOENT) {
+ virReportSystemError(errno,
+ _("Unable to read leases file: %s"),
+ custom_lease_file);
+ } else {
+ rv = 0;
+ }
goto error;
}
--
2.16.4
6 years, 4 months
[libvirt] [PATCH v1 00/40] use GNU C's cleanup attribute in src/util (batch II)
by Sukrit Bhatnagar
This second series of patches also modifies a few files in src/util
to use VIR_AUTOFREE and VIR_AUTOPTR for automatic freeing of memory
and get rid of some VIR_FREE macro invocations and *Free function
calls.
The argument type of virCgroupFree is changed from virCgroupPtr *
to virCgroupPtr.
Sukrit Bhatnagar (40):
util: cgroup: modify virCgroupFree to take virCgroupPtr
util: error: define cleanup function using VIR_DEFINE_AUTOPTR_FUNC
util: buffer: typedef and Free helper for struct _virBufferEscapePair
util: buffer: define cleanup function using VIR_DEFINE_AUTOPTR_FUNC
util: buffer: use VIR_AUTOFREE instead of VIR_FREE for scalar types
util: buffer: use VIR_AUTOPTR for aggregate types
util: hash: define cleanup function using VIR_DEFINE_AUTOPTR_FUNC
util: cgroup: define cleanup function using VIR_DEFINE_AUTOPTR_FUNC
util: cgroup: use VIR_AUTOFREE instead of VIR_FREE for scalar types
util: cgroup: use VIR_AUTOPTR for aggregate types
util: mdev: define cleanup function using VIR_DEFINE_AUTOPTR_FUNC
util: mdev: use VIR_AUTOFREE instead of VIR_FREE for scalar types
util: mdev: use VIR_AUTOPTR for aggregate types
util: firewall: define cleanup function using VIR_DEFINE_AUTOPTR_FUNC
util: firewall: use VIR_AUTOFREE instead of VIR_FREE for scalar types
util: firewall: use VIR_AUTOPTR for aggregate types
util: hook: use VIR_AUTOFREE instead of VIR_FREE for scalar types
util: hook: use VIR_AUTOPTR for aggregate types
util: pci: define cleanup function using VIR_DEFINE_AUTOPTR_FUNC
util: pci: use VIR_AUTOFREE instead of VIR_FREE for scalar types
util: pci: use VIR_AUTOPTR for aggregate types
util: netdevvlan: define cleanup function using
VIR_DEFINE_AUTOPTR_FUNC
util: usb: define cleanup function using VIR_DEFINE_AUTOPTR_FUNC
util: usb: use VIR_AUTOFREE instead of VIR_FREE for scalar types
util: usb: use VIR_AUTOPTR for aggregate types
util: scsi: define cleanup function using VIR_DEFINE_AUTOPTR_FUNC
util: scsi: use VIR_AUTOFREE instead of VIR_FREE for scalar types
util: scsi: use VIR_AUTOPTR for aggregate types
util: scsivhost: define cleanup function using VIR_DEFINE_AUTOPTR_FUNC
util: scsivhost: use VIR_AUTOPTR for aggregate types
util: hostdev: use VIR_AUTOFREE instead of VIR_FREE for scalar types
util: hostdev: use VIR_AUTOPTR for aggregate types
util: hostmem: use VIR_AUTOFREE instead of VIR_FREE for scalar types
util: iptables: use VIR_AUTOFREE instead of VIR_FREE for scalar types
util: iscsi: use VIR_AUTOFREE instead of VIR_FREE for scalar types
util: iscsi: use VIR_AUTOPTR for aggregate types
util: kmod: use VIR_AUTOFREE instead of VIR_FREE for scalar types
util: kmod: use VIR_AUTOPTR for aggregate types
util: lease: use VIR_AUTOFREE instead of VIR_FREE for scalar types
util: lease: use VIR_AUTOPTR for aggregate types
src/libvirt-lxc.c | 4 +-
src/lxc/lxc_cgroup.c | 4 +-
src/lxc/lxc_container.c | 2 +-
src/lxc/lxc_controller.c | 2 +-
src/lxc/lxc_domain.c | 2 +-
src/lxc/lxc_process.c | 10 +-
src/qemu/qemu_cgroup.c | 16 +-
src/qemu/qemu_domain.c | 2 +-
src/qemu/qemu_driver.c | 34 ++-
src/qemu/qemu_process.c | 2 +-
src/util/virbuffer.c | 34 ++-
src/util/virbuffer.h | 9 +-
src/util/vircgroup.c | 718 +++++++++++++++++------------------------------
src/util/vircgroup.h | 11 +-
src/util/vircgrouppriv.h | 2 +-
src/util/virerror.c | 1 -
src/util/virerror.h | 3 +
src/util/virfirewall.c | 53 ++--
src/util/virfirewall.h | 3 +
src/util/virhash.c | 1 -
src/util/virhash.h | 4 +
src/util/virhook.c | 20 +-
src/util/virhostdev.c | 162 ++++-------
src/util/virhostmem.c | 57 ++--
src/util/viriptables.c | 52 ++--
src/util/viriscsi.c | 89 ++----
src/util/virkmod.c | 38 +--
src/util/virlease.c | 82 ++----
src/util/virmdev.c | 84 ++----
src/util/virmdev.h | 4 +
src/util/virnetdevvlan.c | 1 -
src/util/virnetdevvlan.h | 4 +
src/util/virpci.c | 323 +++++++--------------
src/util/virpci.h | 4 +
src/util/virscsi.c | 64 ++---
src/util/virscsi.h | 3 +
src/util/virscsivhost.c | 8 +-
src/util/virscsivhost.h | 3 +
src/util/virusb.c | 22 +-
src/util/virusb.h | 3 +
tests/vircgrouptest.c | 42 +--
41 files changed, 739 insertions(+), 1243 deletions(-)
--
1.8.3.1
6 years, 4 months
[libvirt] [PATCH] conf: Don't parse edev of non-passthrough input device
by Han Han
In input devices, edev attribute is only for passthrough devices.
Don't parse this for other input devices.
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1591151
Signed-off-by: Han Han <hhan(a)redhat.com>
---
src/conf/domain_conf.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 7396616eda..ea2e796b78 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -13050,7 +13050,8 @@ virDomainInputDefParseXML(virDomainXMLOptionPtr xmlopt,
goto error;
}
- if ((evdev = virXPathString("string(./source/@evdev)", ctxt)))
+ if ((evdev = virXPathString("string(./source/@evdev)", ctxt)) &&
+ (def->type == VIR_DOMAIN_INPUT_TYPE_PASSTHROUGH))
def->source.evdev = virFileSanitizePath(evdev);
if (def->type == VIR_DOMAIN_INPUT_TYPE_PASSTHROUGH && !def->source.evdev) {
virReportError(VIR_ERR_XML_ERROR, "%s",
--
2.17.1
6 years, 4 months
[libvirt] [PATCH] nwfilter: Resolve SEGV for NWFilter Snoop processing
by John Ferlan
https://bugzilla.redhat.com/show_bug.cgi?id=1599973
Commit id fca9afa08 changed the @req->ifname to use
@req->binding->portdevname fillingin the @req->binding
in a similar way that @req->ifname would have been
filled in during virNWFilterDHCPSnoopReq processing.
However, in doing so it did not take into account some
code paths where the @req->binding should be checked
instead of @req->binding->portdevname. These checks
led to SEGVs in some cases during libvirtd reload
processing in virNWFilterSnoopRemAllReqIter (for
stop during nwfilterStateCleanup processing) and
virNWFilterSnoopReqLeaseDel (for start during
nwfilterStateInitialize processing).
In particular, when reading the nwfilter.leases file
a new @req is created, but the @req->binding is not
filled in. That's left to virNWFilterDHCPSnoopReq
processing which checks if the @req already exists
in the @virNWFilterSnoopState.snoopReqs hash table
after adding a virNWFilterSnoopState.ifnameToKey
entry for the @req->binding->portdevname by a
@ref->ikey value.
NB: virNWFilterSnoopIPLeaseInstallRule and
virNWFilterDHCPSnoopThread do not need the
req->binding check since they can only be called
after the filter->binding is created/assigned.
Signed-off-by: John Ferlan <jferlan(a)redhat.com>
---
src/nwfilter/nwfilter_dhcpsnoop.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/src/nwfilter/nwfilter_dhcpsnoop.c b/src/nwfilter/nwfilter_dhcpsnoop.c
index c7fd370598..2330ba0479 100644
--- a/src/nwfilter/nwfilter_dhcpsnoop.c
+++ b/src/nwfilter/nwfilter_dhcpsnoop.c
@@ -846,7 +846,7 @@ virNWFilterSnoopReqLeaseDel(virNWFilterSnoopReqPtr req,
int ret = 0;
virNWFilterSnoopIPLeasePtr ipl;
char *ipstr = NULL;
- int ipAddrLeft;
+ int ipAddrLeft = 0;
/* protect req->start, req->ifname and the lease */
virNWFilterSnoopReqLock(req);
@@ -867,7 +867,8 @@ virNWFilterSnoopReqLeaseDel(virNWFilterSnoopReqPtr req,
if (update_leasefile)
virNWFilterSnoopLeaseFileSave(ipl);
- ipAddrLeft = virNWFilterIPAddrMapDelIPAddr(req->binding->portdevname, ipstr);
+ if (req->binding)
+ ipAddrLeft = virNWFilterIPAddrMapDelIPAddr(req->binding->portdevname, ipstr);
if (!req->threadkey || !instantiate)
goto skip_instantiate;
@@ -2037,7 +2038,7 @@ virNWFilterSnoopRemAllReqIter(const void *payload,
/* protect req->binding->portdevname */
virNWFilterSnoopReqLock(req);
- if (req->binding->portdevname) {
+ if (req->binding && req->binding->portdevname) {
ignore_value(virHashRemoveEntry(virNWFilterSnoopState.ifnameToKey,
req->binding->portdevname));
--
2.17.1
6 years, 4 months
[libvirt] interactions between virDomainSetVcpusFlags and NUMA/pinning?
by Chris Friesen
Hi,
Just wondering about interactions between virDomainSetVcpusFlags() and
virDomainPinVcpuFlags() and the domain XML.
1) If I add a vCPU to a domain, do I need to pin it after or does it respect the
vCPU-to-pCPU mapping specified in the domain XML?
2) Are vCPUs added/removed in strict numerical order such that at any given time
the active vCPUs are numbered 0-(N-1) where N is the number of active vCPUs?
3) Will the newly-added vCPUs respect the NUMA topology specified in the domain XML?
Thanks,
Chris
6 years, 4 months
[libvirt] [PATCH v3 0/3] Alter qemu live/cold device attach algorithm
by John Ferlan
v2: https://www.redhat.com/archives/libvir-list/2018-July/msg00361.html
Differences to v2:
Patch1: NEW - As a result of code review the suggestion was to utilize
the virDomainDefCompatibleDevice in order to make the check more
generic to include <disk>'s which were also afflicted with the
same problem that I was trying to solve with the former patch1
just for <hostdev>'s. However, this led me down into the abyss of
more changes since <disk>'s have multiple <address type='drive'...>
target bus types (IDE and SCSI). That means we need to have a
mechanism to pass the target bus along so that a SCSI drive
address doesn't inadvertently match an IDE drive address. All
that is complicated by the way virDomainDefHasDeviceAddress
iterates through all the device lists. Whether there are more
similar devices I'm assuming will fall out of code review.
Patch2: This moves the virDomainDefHasDeviceAddress into the more
common config checking virDomainDefCompatibleDevice method,
but now needs to also account for the disk bus issue.
This theoretically could be combined with Patch1, but keeping
them separate I would hope makes for simpler code review. I
could also move code out of virDomainDefHasDeviceAddressIterator
into patch2, but if just felt better in patch1.
Patch3: No changes were made (amazingly so).
In the end quite a bit more complicated
John Ferlan (3):
conf: Add @target_bus to virDomainDefHasDeviceAddress
qemu: Check for existing address when cold attach device
qemu: Use the correct vm def on cold attach
src/conf/domain_conf.c | 54 +++++++++++++++++++++++++++++++++++---
src/conf/domain_conf.h | 3 ++-
src/qemu/qemu_driver.c | 59 ++++++++++++++++--------------------------
3 files changed, 75 insertions(+), 41 deletions(-)
--
2.17.1
6 years, 4 months
[libvirt] [PATCH v3 0/2] Support network stats for VF representor interface
by Jai Singh Rana
With availability of switchdev model in linux, it is possible to capture
stats for SR-IOV device with interface_type as 'hostdev' provided device
supports VF represontor in switchdev mode[1] on host.
These stats are supported by adding helper APIs for getting/verifying VF
representor name based on PCI Bus:Device:Function information in domains
'hostdev' structure and querying required net sysfs directory and file
entries on host according to switchdev model. These helper APIs are then
used in qemu/conf to get the interface stats for VF representor on host
of pci SR-IOV device.
[1] https://www.kernel.org/doc/Documentation/networking/switchdev.txt
V2 https://www.redhat.com/archives/libvir-list/2018-February/msg00561.html
Jai Singh Rana (2):
util: Add helper APIs to get/verify VF Representor name
qemu: conf: Network stats support for VF Representors
docs/news.xml | 9 ++
po/POTFILES.in | 1 +
src/conf/domain_conf.c | 15 ++
src/libvirt_private.syms | 7 +
src/qemu/qemu_driver.c | 33 +++-
src/util/Makefile.inc.am | 2 +
src/util/virhostdev.c | 2 +-
src/util/virhostdev.h | 8 +
src/util/virnetdevhostdev.c | 374 ++++++++++++++++++++++++++++++++++++++++++++
src/util/virnetdevhostdev.h | 35 +++++
10 files changed, 481 insertions(+), 5 deletions(-)
create mode 100644 src/util/virnetdevhostdev.c
create mode 100644 src/util/virnetdevhostdev.h
--
2.13.6
6 years, 4 months
[libvirt] [PATCHv3] replace 'if' type conditions with 'switch' for VIR_NETWORK_FORWARD_
by Shi Lei
Signed-off-by: Shi Lei <shilei.massclouds(a)gmx.com>
---
v2 here: https://www.redhat.com/archives/libvir-list/2018-July/msg01423.html
since v2:
- typecast def->forward.type to virNetworkForwardType explicitly
in all the switches rather than change its type to enum in
the struct definition
v1 here: https://www.redhat.com/archives/libvir-list/2018-July/msg01314.html
since v1:
- Change the type declaration of _virNetworkForwardDef.type
from int to virNetworkForwardType
- use the default case to report out of range error with
virReportEnumRangeError
src/conf/domain_conf.c | 49 ++++---
src/conf/network_conf.c | 75 +++++++---
src/conf/virnetworkobj.c | 24 +++-
src/esx/esx_network_driver.c | 19 ++-
src/libvirt_private.syms | 1 +
src/network/bridge_driver.c | 317 ++++++++++++++++++++++++++++---------------
src/qemu/qemu_process.c | 10 +-
7 files changed, 334 insertions(+), 161 deletions(-)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 178c6d2..33b0b4a 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -29975,40 +29975,49 @@ virDomainNetResolveActualType(virDomainNetDefPtr iface)
if (!(def = virNetworkDefParseString(xml)))
goto cleanup;
- if ((def->forward.type == VIR_NETWORK_FORWARD_NONE) ||
- (def->forward.type == VIR_NETWORK_FORWARD_NAT) ||
- (def->forward.type == VIR_NETWORK_FORWARD_ROUTE) ||
- (def->forward.type == VIR_NETWORK_FORWARD_OPEN)) {
+ switch ((virNetworkForwardType) def->forward.type) {
+ case VIR_NETWORK_FORWARD_NONE:
+ case VIR_NETWORK_FORWARD_NAT:
+ case VIR_NETWORK_FORWARD_ROUTE:
+ case VIR_NETWORK_FORWARD_OPEN:
/* for these forward types, the actual net type really *is*
* NETWORK; we just keep the info from the portgroup in
* iface->data.network.actual
*/
ret = VIR_DOMAIN_NET_TYPE_NETWORK;
+ break;
- } else if ((def->forward.type == VIR_NETWORK_FORWARD_BRIDGE) &&
- def->bridge) {
-
- /* <forward type='bridge'/> <bridge name='xxx'/>
- * is VIR_DOMAIN_NET_TYPE_BRIDGE
- */
-
- ret = VIR_DOMAIN_NET_TYPE_BRIDGE;
-
- } else if (def->forward.type == VIR_NETWORK_FORWARD_HOSTDEV) {
-
+ case VIR_NETWORK_FORWARD_HOSTDEV:
ret = VIR_DOMAIN_NET_TYPE_HOSTDEV;
+ break;
- } else if ((def->forward.type == VIR_NETWORK_FORWARD_BRIDGE) ||
- (def->forward.type == VIR_NETWORK_FORWARD_PRIVATE) ||
- (def->forward.type == VIR_NETWORK_FORWARD_VEPA) ||
- (def->forward.type == VIR_NETWORK_FORWARD_PASSTHROUGH)) {
+ case VIR_NETWORK_FORWARD_BRIDGE:
+ if (def->bridge) {
+ /* <forward type='bridge'/> <bridge name='xxx'/>
+ * is VIR_DOMAIN_NET_TYPE_BRIDGE
+ */
+ ret = VIR_DOMAIN_NET_TYPE_BRIDGE;
+ break;
+ }
+
+ /* intentionally fall through to the direct case for
+ * VIR_NETWORK_FORWARD_BRIDGE with no bridge device defined
+ */
+ ATTRIBUTE_FALLTHROUGH;
+ case VIR_NETWORK_FORWARD_PRIVATE:
+ case VIR_NETWORK_FORWARD_VEPA:
+ case VIR_NETWORK_FORWARD_PASSTHROUGH:
/* <forward type='bridge|private|vepa|passthrough'> are all
* VIR_DOMAIN_NET_TYPE_DIRECT.
*/
-
ret = VIR_DOMAIN_NET_TYPE_DIRECT;
+ break;
+ case VIR_NETWORK_FORWARD_LAST:
+ default:
+ virReportEnumRangeError(virNetworkForwardType, def->forward.type);
+ goto cleanup;
}
cleanup:
diff --git a/src/conf/network_conf.c b/src/conf/network_conf.c
index 630a87f..c08456b 100644
--- a/src/conf/network_conf.c
+++ b/src/conf/network_conf.c
@@ -1874,7 +1874,7 @@ virNetworkDefParseXML(xmlXPathContextPtr ctxt)
/* Validate some items in the main NetworkDef that need to align
* with the chosen forward mode.
*/
- switch (def->forward.type) {
+ switch ((virNetworkForwardType) def->forward.type) {
case VIR_NETWORK_FORWARD_NONE:
break;
@@ -1955,21 +1955,40 @@ virNetworkDefParseXML(xmlXPathContextPtr ctxt)
goto error;
}
break;
+
+ case VIR_NETWORK_FORWARD_LAST:
+ default:
+ virReportEnumRangeError(virNetworkForwardType, def->forward.type);
+ goto error;
}
VIR_FREE(stp);
- if (def->mtu &&
- (def->forward.type != VIR_NETWORK_FORWARD_NONE &&
- def->forward.type != VIR_NETWORK_FORWARD_NAT &&
- def->forward.type != VIR_NETWORK_FORWARD_ROUTE &&
- def->forward.type != VIR_NETWORK_FORWARD_OPEN)) {
- virReportError(VIR_ERR_XML_ERROR,
- _("mtu size only allowed in open, route, nat, "
- "and isolated mode, not in %s (network '%s')"),
- virNetworkForwardTypeToString(def->forward.type),
- def->name);
- goto error;
+ if (def->mtu) {
+ switch ((virNetworkForwardType) def->forward.type) {
+ case VIR_NETWORK_FORWARD_NONE:
+ case VIR_NETWORK_FORWARD_NAT:
+ case VIR_NETWORK_FORWARD_ROUTE:
+ case VIR_NETWORK_FORWARD_OPEN:
+ break;
+
+ case VIR_NETWORK_FORWARD_BRIDGE:
+ case VIR_NETWORK_FORWARD_PRIVATE:
+ case VIR_NETWORK_FORWARD_VEPA:
+ case VIR_NETWORK_FORWARD_PASSTHROUGH:
+ case VIR_NETWORK_FORWARD_HOSTDEV:
+ virReportError(VIR_ERR_XML_ERROR,
+ _("mtu size only allowed in open, route, nat, "
+ "and isolated mode, not in %s (network '%s')"),
+ virNetworkForwardTypeToString(def->forward.type),
+ def->name);
+ goto error;
+
+ case VIR_NETWORK_FORWARD_LAST:
+ default:
+ virReportEnumRangeError(virNetworkForwardType, def->forward.type);
+ goto error;
+ }
}
/* Extract custom metadata */
@@ -2349,6 +2368,7 @@ virNetworkDefFormatBuf(virBufferPtr buf,
char uuidstr[VIR_UUID_STRING_BUFLEN];
size_t i;
bool shortforward;
+ bool hasbridge = false;
virBufferAddLit(buf, "<network");
if (!(flags & VIR_NETWORK_XML_INACTIVE) && (def->connections > 0))
@@ -2469,22 +2489,33 @@ virNetworkDefFormatBuf(virBufferPtr buf,
virBufferAddLit(buf, "</forward>\n");
}
+ switch ((virNetworkForwardType) def->forward.type) {
+ case VIR_NETWORK_FORWARD_NONE:
+ case VIR_NETWORK_FORWARD_NAT:
+ case VIR_NETWORK_FORWARD_ROUTE:
+ case VIR_NETWORK_FORWARD_OPEN:
+ hasbridge = true;
+ break;
- if (def->forward.type == VIR_NETWORK_FORWARD_NONE ||
- def->forward.type == VIR_NETWORK_FORWARD_NAT ||
- def->forward.type == VIR_NETWORK_FORWARD_ROUTE ||
- def->forward.type == VIR_NETWORK_FORWARD_OPEN ||
- def->bridge || def->macTableManager) {
+ case VIR_NETWORK_FORWARD_BRIDGE:
+ case VIR_NETWORK_FORWARD_PRIVATE:
+ case VIR_NETWORK_FORWARD_VEPA:
+ case VIR_NETWORK_FORWARD_PASSTHROUGH:
+ case VIR_NETWORK_FORWARD_HOSTDEV:
+ break;
+ case VIR_NETWORK_FORWARD_LAST:
+ default:
+ virReportEnumRangeError(virNetworkForwardType, def->forward.type);
+ goto error;
+ }
+
+ if (hasbridge || def->bridge || def->macTableManager) {
virBufferAddLit(buf, "<bridge");
virBufferEscapeString(buf, " name='%s'", def->bridge);
- if (def->forward.type == VIR_NETWORK_FORWARD_NONE ||
- def->forward.type == VIR_NETWORK_FORWARD_NAT ||
- def->forward.type == VIR_NETWORK_FORWARD_ROUTE ||
- def->forward.type == VIR_NETWORK_FORWARD_OPEN) {
+ if (hasbridge)
virBufferAsprintf(buf, " stp='%s' delay='%ld'",
def->stp ? "on" : "off", def->delay);
- }
if (def->macTableManager) {
virBufferAsprintf(buf, " macTableManager='%s'",
virNetworkBridgeMACTableManagerTypeToString(def->macTableManager));
diff --git a/src/conf/virnetworkobj.c b/src/conf/virnetworkobj.c
index e00c8a7..b13e5a7 100644
--- a/src/conf/virnetworkobj.c
+++ b/src/conf/virnetworkobj.c
@@ -1009,19 +1009,31 @@ virNetworkLoadConfig(virNetworkObjListPtr nets,
goto error;
}
- if (def->forward.type == VIR_NETWORK_FORWARD_NONE ||
- def->forward.type == VIR_NETWORK_FORWARD_NAT ||
- def->forward.type == VIR_NETWORK_FORWARD_ROUTE ||
- def->forward.type == VIR_NETWORK_FORWARD_OPEN) {
-
+ switch ((virNetworkForwardType) def->forward.type) {
+ case VIR_NETWORK_FORWARD_NONE:
+ case VIR_NETWORK_FORWARD_NAT:
+ case VIR_NETWORK_FORWARD_ROUTE:
+ case VIR_NETWORK_FORWARD_OPEN:
if (!def->mac_specified) {
virNetworkSetBridgeMacAddr(def);
virNetworkSaveConfig(configDir, def);
}
- } else {
+ break;
+
+ case VIR_NETWORK_FORWARD_BRIDGE:
+ case VIR_NETWORK_FORWARD_PRIVATE:
+ case VIR_NETWORK_FORWARD_VEPA:
+ case VIR_NETWORK_FORWARD_PASSTHROUGH:
+ case VIR_NETWORK_FORWARD_HOSTDEV:
/* Throw away MAC address for other forward types,
* which could have been generated by older libvirt RPMs */
def->mac_specified = false;
+ break;
+
+ case VIR_NETWORK_FORWARD_LAST:
+ default:
+ virReportEnumRangeError(virNetworkForwardType, def->forward.type);
+ goto error;
}
if (!(obj = virNetworkObjAssignDef(nets, def, 0)))
diff --git a/src/esx/esx_network_driver.c b/src/esx/esx_network_driver.c
index 04118b4..31bceb7 100644
--- a/src/esx/esx_network_driver.c
+++ b/src/esx/esx_network_driver.c
@@ -326,12 +326,27 @@ esxNetworkDefineXML(virConnectPtr conn, const char *xml)
}
/* FIXME: Add support for NAT */
- if (def->forward.type != VIR_NETWORK_FORWARD_NONE &&
- def->forward.type != VIR_NETWORK_FORWARD_BRIDGE) {
+ switch ((virNetworkForwardType) def->forward.type) {
+ case VIR_NETWORK_FORWARD_NONE:
+ case VIR_NETWORK_FORWARD_BRIDGE:
+ break;
+
+ case VIR_NETWORK_FORWARD_NAT:
+ case VIR_NETWORK_FORWARD_ROUTE:
+ case VIR_NETWORK_FORWARD_OPEN:
+ case VIR_NETWORK_FORWARD_PRIVATE:
+ case VIR_NETWORK_FORWARD_VEPA:
+ case VIR_NETWORK_FORWARD_PASSTHROUGH:
+ case VIR_NETWORK_FORWARD_HOSTDEV:
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("Unsupported forward mode '%s'"),
virNetworkForwardTypeToString(def->forward.type));
goto cleanup;
+
+ case VIR_NETWORK_FORWARD_LAST:
+ default:
+ virReportEnumRangeError(virNetworkForwardType, def->forward.type);
+ goto cleanup;
}
/* Verify that specified HostPortGroups don't exist already */
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 1a4cf98..fc386e1 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -2369,6 +2369,7 @@ virNetDevMacVLanCreate;
virNetDevMacVLanCreateWithVPortProfile;
virNetDevMacVLanDelete;
virNetDevMacVLanDeleteWithVPortProfile;
+virNetDevMacVLanModeTypeFromString;
virNetDevMacVLanReleaseName;
virNetDevMacVLanReserveName;
virNetDevMacVLanRestartWithVPortProfile;
diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c
index da3c32e..ed8a8bf 100644
--- a/src/network/bridge_driver.c
+++ b/src/network/bridge_driver.c
@@ -446,7 +446,7 @@ networkUpdateState(virNetworkObjPtr obj,
}
def = virNetworkObjGetDef(obj);
- switch (def->forward.type) {
+ switch ((virNetworkForwardType) def->forward.type) {
case VIR_NETWORK_FORWARD_NONE:
case VIR_NETWORK_FORWARD_NAT:
case VIR_NETWORK_FORWARD_ROUTE:
@@ -485,6 +485,11 @@ networkUpdateState(virNetworkObjPtr obj,
case VIR_NETWORK_FORWARD_HOSTDEV:
/* so far no extra checks */
break;
+
+ case VIR_NETWORK_FORWARD_LAST:
+ default:
+ virReportEnumRangeError(virNetworkForwardType, def->forward.type);
+ goto cleanup;
}
/* Try and read dnsmasq/radvd pids of active networks */
@@ -2088,20 +2093,37 @@ networkRefreshDaemonsHelper(virNetworkObjPtr obj,
virObjectLock(obj);
def = virNetworkObjGetDef(obj);
- if (virNetworkObjIsActive(obj) &&
- ((def->forward.type == VIR_NETWORK_FORWARD_NONE) ||
- (def->forward.type == VIR_NETWORK_FORWARD_NAT) ||
- (def->forward.type == VIR_NETWORK_FORWARD_ROUTE) ||
- (def->forward.type == VIR_NETWORK_FORWARD_OPEN))) {
- /* Only the three L3 network types that are configured by
- * libvirt will have a dnsmasq or radvd daemon associated
- * with them. Here we send a SIGHUP to an existing
- * dnsmasq and/or radvd, or restart them if they've
- * disappeared.
- */
- networkRefreshDhcpDaemon(driver, obj);
- networkRefreshRadvd(driver, obj);
+ if (virNetworkObjIsActive(obj)) {
+ switch ((virNetworkForwardType) def->forward.type) {
+ case VIR_NETWORK_FORWARD_NONE:
+ case VIR_NETWORK_FORWARD_NAT:
+ case VIR_NETWORK_FORWARD_ROUTE:
+ case VIR_NETWORK_FORWARD_OPEN:
+ /* Only the three L3 network types that are configured by
+ * libvirt will have a dnsmasq or radvd daemon associated
+ * with them. Here we send a SIGHUP to an existing
+ * dnsmasq and/or radvd, or restart them if they've
+ * disappeared.
+ */
+ networkRefreshDhcpDaemon(driver, obj);
+ networkRefreshRadvd(driver, obj);
+ break;
+
+ case VIR_NETWORK_FORWARD_BRIDGE:
+ case VIR_NETWORK_FORWARD_PRIVATE:
+ case VIR_NETWORK_FORWARD_VEPA:
+ case VIR_NETWORK_FORWARD_PASSTHROUGH:
+ case VIR_NETWORK_FORWARD_HOSTDEV:
+ break;
+
+ case VIR_NETWORK_FORWARD_LAST:
+ default:
+ virReportEnumRangeError(virNetworkForwardType, def->forward.type);
+ goto cleanup;
+ }
}
+
+ cleanup:
virObjectUnlock(obj);
return 0;
}
@@ -2128,20 +2150,37 @@ networkReloadFirewallRulesHelper(virNetworkObjPtr obj,
virObjectLock(obj);
def = virNetworkObjGetDef(obj);
- if (virNetworkObjIsActive(obj) &&
- ((def->forward.type == VIR_NETWORK_FORWARD_NONE) ||
- (def->forward.type == VIR_NETWORK_FORWARD_NAT) ||
- (def->forward.type == VIR_NETWORK_FORWARD_ROUTE))) {
- /* Only three of the L3 network types that are configured by
- * libvirt need to have iptables rules reloaded. The 4th L3
- * network type, forward='open', doesn't need this because it
- * has no iptables rules.
- */
- networkRemoveFirewallRules(def);
- if (networkAddFirewallRules(def) < 0) {
- /* failed to add but already logged */
+ if (virNetworkObjIsActive(obj)) {
+ switch ((virNetworkForwardType) def->forward.type) {
+ case VIR_NETWORK_FORWARD_NONE:
+ case VIR_NETWORK_FORWARD_NAT:
+ case VIR_NETWORK_FORWARD_ROUTE:
+ /* Only three of the L3 network types that are configured by
+ * libvirt need to have iptables rules reloaded. The 4th L3
+ * network type, forward='open', doesn't need this because it
+ * has no iptables rules.
+ */
+ networkRemoveFirewallRules(def);
+ /* No need to check return value since already logged internally */
+ ignore_value(networkAddFirewallRules(def));
+ break;
+
+ case VIR_NETWORK_FORWARD_OPEN:
+ case VIR_NETWORK_FORWARD_BRIDGE:
+ case VIR_NETWORK_FORWARD_PRIVATE:
+ case VIR_NETWORK_FORWARD_VEPA:
+ case VIR_NETWORK_FORWARD_PASSTHROUGH:
+ case VIR_NETWORK_FORWARD_HOSTDEV:
+ break;
+
+ case VIR_NETWORK_FORWARD_LAST:
+ default:
+ virReportEnumRangeError(virNetworkForwardType, def->forward.type);
+ goto cleanup;
}
}
+
+ cleanup:
virObjectUnlock(obj);
return 0;
}
@@ -2687,7 +2726,7 @@ networkCreateInterfacePool(virNetworkDefPtr netdef)
virNetworkForwardIfDefPtr thisIf
= &netdef->forward.ifs[netdef->forward.nifs];
- switch (netdef->forward.type) {
+ switch ((virNetworkForwardType) netdef->forward.type) {
case VIR_NETWORK_FORWARD_BRIDGE:
case VIR_NETWORK_FORWARD_PRIVATE:
case VIR_NETWORK_FORWARD_VEPA:
@@ -2719,9 +2758,13 @@ networkCreateInterfacePool(virNetworkDefPtr netdef)
case VIR_NETWORK_FORWARD_NAT:
case VIR_NETWORK_FORWARD_ROUTE:
case VIR_NETWORK_FORWARD_OPEN:
- case VIR_NETWORK_FORWARD_LAST:
/* by definition these will never be encountered here */
break;
+
+ case VIR_NETWORK_FORWARD_LAST:
+ default:
+ virReportEnumRangeError(virNetworkForwardType, netdef->forward.type);
+ goto cleanup;
}
}
@@ -2811,7 +2854,7 @@ networkStartNetwork(virNetworkDriverStatePtr driver,
VIR_HOOK_SUBOP_BEGIN) < 0)
goto cleanup;
- switch (def->forward.type) {
+ switch ((virNetworkForwardType) def->forward.type) {
case VIR_NETWORK_FORWARD_NONE:
case VIR_NETWORK_FORWARD_NAT:
@@ -2840,6 +2883,11 @@ networkStartNetwork(virNetworkDriverStatePtr driver,
if (networkStartNetworkExternal(obj) < 0)
goto cleanup;
break;
+
+ case VIR_NETWORK_FORWARD_LAST:
+ default:
+ virReportEnumRangeError(virNetworkForwardType, def->forward.type);
+ goto cleanup;
}
/* finally we can call the 'started' hook script if any */
@@ -2893,7 +2941,7 @@ networkShutdownNetwork(virNetworkDriverStatePtr driver,
unlink(stateFile);
VIR_FREE(stateFile);
- switch (def->forward.type) {
+ switch ((virNetworkForwardType) def->forward.type) {
case VIR_NETWORK_FORWARD_NONE:
case VIR_NETWORK_FORWARD_NAT:
@@ -2919,6 +2967,11 @@ networkShutdownNetwork(virNetworkDriverStatePtr driver,
case VIR_NETWORK_FORWARD_HOSTDEV:
ret = networkShutdownNetworkExternal(obj);
break;
+
+ case VIR_NETWORK_FORWARD_LAST:
+ default:
+ virReportEnumRangeError(virNetworkForwardType, def->forward.type);
+ return -1;
}
/* now that we know it's stopped call the hook if present */
@@ -3273,11 +3326,11 @@ networkValidate(virNetworkDriverStatePtr driver,
/* Only the three L3 network types that are configured by libvirt
* need to have a bridge device name / mac address provided
*/
- if (def->forward.type == VIR_NETWORK_FORWARD_NONE ||
- def->forward.type == VIR_NETWORK_FORWARD_NAT ||
- def->forward.type == VIR_NETWORK_FORWARD_ROUTE ||
- def->forward.type == VIR_NETWORK_FORWARD_OPEN) {
-
+ switch ((virNetworkForwardType) def->forward.type) {
+ case VIR_NETWORK_FORWARD_NONE:
+ case VIR_NETWORK_FORWARD_NAT:
+ case VIR_NETWORK_FORWARD_ROUTE:
+ case VIR_NETWORK_FORWARD_OPEN:
/* if no bridge name was given in the config, find a name
* unused by any other libvirt networks and assign it.
*/
@@ -3285,7 +3338,13 @@ networkValidate(virNetworkDriverStatePtr driver,
return -1;
virNetworkSetBridgeMacAddr(def);
- } else {
+ break;
+
+ case VIR_NETWORK_FORWARD_BRIDGE:
+ case VIR_NETWORK_FORWARD_PRIVATE:
+ case VIR_NETWORK_FORWARD_VEPA:
+ case VIR_NETWORK_FORWARD_PASSTHROUGH:
+ case VIR_NETWORK_FORWARD_HOSTDEV:
/* They are also the only types that currently support setting
* a MAC or IP address for the host-side device (bridge), DNS
* configuration, or network-wide bandwidth limits.
@@ -3331,6 +3390,12 @@ networkValidate(virNetworkDriverStatePtr driver,
return -1;
}
bandwidthAllowed = false;
+ break;
+
+ case VIR_NETWORK_FORWARD_LAST:
+ default:
+ virReportEnumRangeError(virNetworkForwardType, def->forward.type);
+ return -1;
}
/* we support configs with a single PF defined:
@@ -3755,9 +3820,10 @@ networkUpdate(virNetworkPtr net,
/* Take care of anything that must be done before updating the
* live NetworkDef.
*/
- if (def->forward.type == VIR_NETWORK_FORWARD_NONE ||
- def->forward.type == VIR_NETWORK_FORWARD_NAT ||
- def->forward.type == VIR_NETWORK_FORWARD_ROUTE) {
+ switch ((virNetworkForwardType) def->forward.type) {
+ case VIR_NETWORK_FORWARD_NONE:
+ case VIR_NETWORK_FORWARD_NAT:
+ case VIR_NETWORK_FORWARD_ROUTE:
switch (section) {
case VIR_NETWORK_SECTION_FORWARD:
case VIR_NETWORK_SECTION_FORWARD_INTERFACE:
@@ -3768,14 +3834,26 @@ networkUpdate(virNetworkPtr net,
* old rules (and remember to load new ones after the
* update).
*/
- if (def->forward.type != VIR_NETWORK_FORWARD_OPEN) {
- networkRemoveFirewallRules(def);
- needFirewallRefresh = true;
- }
+ networkRemoveFirewallRules(def);
+ needFirewallRefresh = true;
break;
default:
break;
}
+ break;
+
+ case VIR_NETWORK_FORWARD_OPEN:
+ case VIR_NETWORK_FORWARD_BRIDGE:
+ case VIR_NETWORK_FORWARD_PRIVATE:
+ case VIR_NETWORK_FORWARD_VEPA:
+ case VIR_NETWORK_FORWARD_PASSTHROUGH:
+ case VIR_NETWORK_FORWARD_HOSTDEV:
+ break;
+
+ case VIR_NETWORK_FORWARD_LAST:
+ default:
+ virReportEnumRangeError(virNetworkForwardType, def->forward.type);
+ goto cleanup;
}
}
@@ -4440,10 +4518,11 @@ networkAllocateActualDevice(virDomainDefPtr dom,
iface->data.network.actual->trustGuestRxFilters
= netdef->trustGuestRxFilters;
- if ((netdef->forward.type == VIR_NETWORK_FORWARD_NONE) ||
- (netdef->forward.type == VIR_NETWORK_FORWARD_NAT) ||
- (netdef->forward.type == VIR_NETWORK_FORWARD_ROUTE) ||
- (netdef->forward.type == VIR_NETWORK_FORWARD_OPEN)) {
+ switch ((virNetworkForwardType) netdef->forward.type) {
+ case VIR_NETWORK_FORWARD_NONE:
+ case VIR_NETWORK_FORWARD_NAT:
+ case VIR_NETWORK_FORWARD_ROUTE:
+ case VIR_NETWORK_FORWARD_OPEN:
/* for these forward types, the actual net type really *is*
* NETWORK; we just keep the info from the portgroup in
* iface->data.network.actual
@@ -4463,46 +4542,9 @@ networkAllocateActualDevice(virDomainDefPtr dom,
if (networkPlugBandwidth(obj, iface) < 0)
goto error;
+ break;
- } else if ((netdef->forward.type == VIR_NETWORK_FORWARD_BRIDGE) &&
- netdef->bridge) {
-
- /* <forward type='bridge'/> <bridge name='xxx'/>
- * is VIR_DOMAIN_NET_TYPE_BRIDGE
- */
-
- iface->data.network.actual->type = actualType = VIR_DOMAIN_NET_TYPE_BRIDGE;
- if (VIR_STRDUP(iface->data.network.actual->data.bridge.brname,
- netdef->bridge) < 0)
- goto error;
- iface->data.network.actual->data.bridge.macTableManager
- = netdef->macTableManager;
-
- /* merge virtualports from interface, network, and portgroup to
- * arrive at actual virtualport to use
- */
- if (virNetDevVPortProfileMerge3(&iface->data.network.actual->virtPortProfile,
- iface->virtPortProfile,
- netdef->virtPortProfile,
- portgroup
- ? portgroup->virtPortProfile : NULL) < 0) {
- goto error;
- }
- virtport = iface->data.network.actual->virtPortProfile;
- if (virtport) {
- /* only type='openvswitch' is allowed for bridges */
- if (virtport->virtPortType != VIR_NETDEV_VPORT_PROFILE_OPENVSWITCH) {
- virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
- _("<virtualport type='%s'> not supported for network "
- "'%s' which uses a bridge device"),
- virNetDevVPortTypeToString(virtport->virtPortType),
- netdef->name);
- goto error;
- }
- }
-
- } else if (netdef->forward.type == VIR_NETWORK_FORWARD_HOSTDEV) {
-
+ case VIR_NETWORK_FORWARD_HOSTDEV: {
virDomainHostdevSubsysPCIBackendType backend;
iface->data.network.actual->type = actualType = VIR_DOMAIN_NET_TYPE_HOSTDEV;
@@ -4575,32 +4617,67 @@ networkAllocateActualDevice(virDomainDefPtr dom,
goto error;
}
}
+ break;
+ }
+
+ case VIR_NETWORK_FORWARD_BRIDGE:
+ if (netdef->bridge) {
+ /* <forward type='bridge'/> <bridge name='xxx'/>
+ * is VIR_DOMAIN_NET_TYPE_BRIDGE
+ */
+
+ iface->data.network.actual->type = actualType = VIR_DOMAIN_NET_TYPE_BRIDGE;
+ if (VIR_STRDUP(iface->data.network.actual->data.bridge.brname,
+ netdef->bridge) < 0)
+ goto error;
+ iface->data.network.actual->data.bridge.macTableManager
+ = netdef->macTableManager;
+
+ /* merge virtualports from interface, network, and portgroup to
+ * arrive at actual virtualport to use
+ */
+ if (virNetDevVPortProfileMerge3(&iface->data.network.actual->virtPortProfile,
+ iface->virtPortProfile,
+ netdef->virtPortProfile,
+ portgroup
+ ? portgroup->virtPortProfile : NULL) < 0) {
+ goto error;
+ }
+ virtport = iface->data.network.actual->virtPortProfile;
+ if (virtport) {
+ /* only type='openvswitch' is allowed for bridges */
+ if (virtport->virtPortType != VIR_NETDEV_VPORT_PROFILE_OPENVSWITCH) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+ _("<virtualport type='%s'> not supported for network "
+ "'%s' which uses a bridge device"),
+ virNetDevVPortTypeToString(virtport->virtPortType),
+ netdef->name);
+ goto error;
+ }
+ }
+ break;
+ }
- } else if ((netdef->forward.type == VIR_NETWORK_FORWARD_BRIDGE) ||
- (netdef->forward.type == VIR_NETWORK_FORWARD_PRIVATE) ||
- (netdef->forward.type == VIR_NETWORK_FORWARD_VEPA) ||
- (netdef->forward.type == VIR_NETWORK_FORWARD_PASSTHROUGH)) {
+ /* intentionally fall through to the direct case for
+ * VIR_NETWORK_FORWARD_BRIDGE with no bridge device defined
+ */
+ ATTRIBUTE_FALLTHROUGH;
+ case VIR_NETWORK_FORWARD_PRIVATE:
+ case VIR_NETWORK_FORWARD_VEPA:
+ case VIR_NETWORK_FORWARD_PASSTHROUGH:
/* <forward type='bridge|private|vepa|passthrough'> are all
* VIR_DOMAIN_NET_TYPE_DIRECT.
*/
/* Set type=direct and appropriate <source mode='xxx'/> */
iface->data.network.actual->type = actualType = VIR_DOMAIN_NET_TYPE_DIRECT;
- switch (netdef->forward.type) {
- case VIR_NETWORK_FORWARD_BRIDGE:
- iface->data.network.actual->data.direct.mode = VIR_NETDEV_MACVLAN_MODE_BRIDGE;
- break;
- case VIR_NETWORK_FORWARD_PRIVATE:
- iface->data.network.actual->data.direct.mode = VIR_NETDEV_MACVLAN_MODE_PRIVATE;
- break;
- case VIR_NETWORK_FORWARD_VEPA:
- iface->data.network.actual->data.direct.mode = VIR_NETDEV_MACVLAN_MODE_VEPA;
- break;
- case VIR_NETWORK_FORWARD_PASSTHROUGH:
- iface->data.network.actual->data.direct.mode = VIR_NETDEV_MACVLAN_MODE_PASSTHRU;
- break;
- }
+
+ /* NO need to check the value returned from virNetDevMacVLanModeTypeFromString
+ * it must be valid for these forward type(bridge|private|vepa|passthrough)
+ */
+ iface->data.network.actual->data.direct.mode =
+ virNetDevMacVLanModeTypeFromString(virNetworkForwardTypeToString(netdef->forward.type));
/* merge virtualports from interface, network, and portgroup to
* arrive at actual virtualport to use
@@ -4680,6 +4757,12 @@ networkAllocateActualDevice(virDomainDefPtr dom,
dev->device.dev) < 0)
goto error;
}
+ break;
+
+ case VIR_NETWORK_FORWARD_LAST:
+ default:
+ virReportEnumRangeError(virNetworkForwardType, netdef->forward.type);
+ goto error;
}
if (virNetworkObjMacMgrAdd(obj, driver->dnsmasqStateDir,
@@ -5037,13 +5120,27 @@ networkReleaseActualDevice(virDomainDefPtr dom,
}
netdef = virNetworkObjGetDef(obj);
- if (iface->data.network.actual &&
- (netdef->forward.type == VIR_NETWORK_FORWARD_NONE ||
- netdef->forward.type == VIR_NETWORK_FORWARD_NAT ||
- netdef->forward.type == VIR_NETWORK_FORWARD_ROUTE ||
- netdef->forward.type == VIR_NETWORK_FORWARD_OPEN) &&
- networkUnplugBandwidth(obj, iface) < 0)
+ switch ((virNetworkForwardType) netdef->forward.type) {
+ case VIR_NETWORK_FORWARD_NONE:
+ case VIR_NETWORK_FORWARD_NAT:
+ case VIR_NETWORK_FORWARD_ROUTE:
+ case VIR_NETWORK_FORWARD_OPEN:
+ if (iface->data.network.actual && networkUnplugBandwidth(obj, iface) < 0)
+ goto error;
+ break;
+
+ case VIR_NETWORK_FORWARD_BRIDGE:
+ case VIR_NETWORK_FORWARD_PRIVATE:
+ case VIR_NETWORK_FORWARD_VEPA:
+ case VIR_NETWORK_FORWARD_PASSTHROUGH:
+ case VIR_NETWORK_FORWARD_HOSTDEV:
+ break;
+
+ case VIR_NETWORK_FORWARD_LAST:
+ default:
+ virReportEnumRangeError(virNetworkForwardType, netdef->forward.type);
goto error;
+ }
if ((!iface->data.network.actual) ||
((actualType != VIR_DOMAIN_NET_TYPE_DIRECT) &&
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index bba157b..27bd8b9 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -4545,7 +4545,7 @@ qemuProcessGetNetworkAddress(const char *netname,
if (!netdef)
goto cleanup;
- switch (netdef->forward.type) {
+ switch ((virNetworkForwardType) netdef->forward.type) {
case VIR_NETWORK_FORWARD_NONE:
case VIR_NETWORK_FORWARD_NAT:
case VIR_NETWORK_FORWARD_ROUTE:
@@ -4582,6 +4582,14 @@ qemuProcessGetNetworkAddress(const char *netname,
goto cleanup;
}
break;
+
+ case VIR_NETWORK_FORWARD_HOSTDEV:
+ break;
+
+ case VIR_NETWORK_FORWARD_LAST:
+ default:
+ virReportEnumRangeError(virNetworkForwardType, netdef->forward.type);
+ goto cleanup;
}
if (dev_name) {
--
2.7.4
6 years, 4 months
[libvirt] [go PATCH] travis: update some of the test matrix versions to moderize coverage
by Daniel P. Berrangé
Add latest go 1.10 to matrix and (arbitrarily) trim out 1.6 and 1.8
Add libvirt 4.5.0 and (arbitrarily) trim out 1.2.10
Signed-off-by: Daniel P. Berrangé <berrange(a)redhat.com>
---
.travis.yml | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/.travis.yml b/.travis.yml
index 1bdb48f..7cd7587 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -5,17 +5,16 @@ sudo: require
go:
- 1.5
- - 1.6
- 1.7
- - 1.8
- 1.9
+ - 1.10
env:
- LIBVIRT=1.2.0 EXT=gz
- - LIBVIRT=1.2.10 EXT=gz
- LIBVIRT=1.2.20 EXT=gz
- LIBVIRT=2.5.0 EXT=xz
- LIBVIRT=3.6.0 EXT=xz
+ - LIBVIRT=4.5.0 EXT=xz
install:
- sudo apt-get -qqy build-dep libvirt
--
2.17.1
6 years, 4 months