Devel
Threads by month
- ----- 2026 -----
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2006 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2005 -----
- December
- 40 participants
- 40674 discussions
The virtual network has never supported NAT with IPv6 since this feature
didn't exist at the time. NAT has been available since RHEL-7 vintage
though, and it is desirable to be able to use it.
This series enables it with
<forward mode=3D"nat">
<nat ipv6=3D"yes"/>
</forward>
Note that I do NOT actually change the default.xml to enable use of IPv6
because that will cause failure if the user has force disabled IPv6 on
their host kernel.
Of course our current default.xml is already broken if someone has done
the reverse and force disabled IPv4.
We've also long had a problem with guests bringing up the default
network with the same subnet as the host. We'll have this same issue
with IPv6 too.
On my prompting Laine proposed a way to deal with the clash by tearing
down a network, if we see a real host NIC get assigned the same subnet.
Meanwhile we also have complaints about the fact that libvirt does
anything todo with networking in the %post of the RPM.
I'm thinking that we can do something entirely different by introducing
a concept of "automatic subnet selection" into the virtual network.
Consider if we made default.xml be able to contain only:
<network>
<name>default</name>
<forward/>
<ip family=3D"ipv4" autoaddr=3D"yes">
<dhcp/>
</ip>
<ip family=3D"ipv6" autoaddr=3D"yes"/>
</network>
Conceptually this means
- Try to gimme a subnet with IPv4 and DHCP
- Try to gimme a subnet with IPv6 and RAs
Now when we start the virtual network
- If IPv4 is not enabled on host, don't assign addr
- Else
- Iterate N=3D1..254 to find a free range for IPv4
- Use 192.168.N.0/24 for subnet
- Use 192.168.N.1 for host IP
- Use 192.168.N.2 -> 192.168.N.254 for guest DHCP
- If IPv6 is not enabled on host, don't assign addr
- Else
- Generate NNNN:NNNN as 4 random bytes
- Use fd00:add:f00d:NNNN:NNNN::0/64 for IPv6 subnet
- Use fd00:add:f00d:NNNN:NNNN::1 for host IP
- Use route advertizement for IPv6 zero-conf
With NNNN:NNNN, even with 1000 guests running, we have just a 0.02%
chance of clashing with a guest for IPv6.
The "live" XML would always reflect the currently assigned addresses
Proactively monitor the address allocations of the host. If we see
a conflicting address appear, take down the dnsmasq intance, generate
a new subnet, bring dnsmasq back online.
Ideally we would have to bring the guest network links offline and
then online again to force DHCP re-assignment immediately.
In v2:
- Fix short circuit XML closing tag
- Fix error checking in enum conversion
- Fix docs typos
- Improve RNG schema
Daniel P. Berrang=C3=A9 (3):
util: add support for IPv6 masquerade rules
conf: add an attribute to turn on NAT for IPv6 virtual networks
network: wire up support for IPv6 NAT rules
docs/formatnetwork.html.in | 14 ++
docs/schemas/network.rng | 5 +
src/conf/network_conf.c | 30 ++-
src/conf/network_conf.h | 2 +
src/network/bridge_driver_linux.c | 23 +-
src/util/viriptables.c | 33 +--
.../nat-ipv6-masquerade-linux.args | 228 ++++++++++++++++++
.../nat-ipv6-masquerade.xml | 17 ++
tests/networkxml2firewalltest.c | 1 +
.../nat-network-forward-nat-ipv6.xml | 10 +
.../nat-network-forward-nat-ipv6.xml | 10 +
tests/networkxml2xmltest.c | 1 +
12 files changed, 342 insertions(+), 32 deletions(-)
create mode 100644 tests/networkxml2firewalldata/nat-ipv6-masquerade-linux.a=
rgs
create mode 100644 tests/networkxml2firewalldata/nat-ipv6-masquerade.xml
create mode 100644 tests/networkxml2xmlin/nat-network-forward-nat-ipv6.xml
create mode 100644 tests/networkxml2xmlout/nat-network-forward-nat-ipv6.xml
--=20
2.26.2
3
8
This was mostly boilerplate conversion, but in one case I needed to
define several differently named char* to take the place of a single
char *tmp that was re-used multiple times, and in another place there
was a single char* that was used at the toplevel of the function, and
then later used repeatedly inside a for loop, so I defined a new
separate char* inside the loop.
Signed-off-by: Laine Stump <laine(a)redhat.com>
---
This should be applied on top of Dan's IPv6 NAT patch series (it was
reviewing that series that showed me this file hadn't yet been
converted).
src/conf/network_conf.c | 613 +++++++++++++++++-----------------------
src/conf/network_conf.h | 1 +
src/util/virxml.h | 1 +
3 files changed, 259 insertions(+), 356 deletions(-)
diff --git a/src/conf/network_conf.c b/src/conf/network_conf.c
index 1b89e2985d..ebe8a03262 100644
--- a/src/conf/network_conf.c
+++ b/src/conf/network_conf.c
@@ -306,8 +306,7 @@ virNetworkDefCopy(virNetworkDefPtr def,
virNetworkXMLOptionPtr xmlopt,
unsigned int flags)
{
- char *xml = NULL;
- virNetworkDefPtr newDef = NULL;
+ g_autofree char *xml = NULL;
if (!def) {
virReportError(VIR_ERR_INTERNAL_ERROR,
@@ -317,11 +316,9 @@ virNetworkDefCopy(virNetworkDefPtr def,
/* deep copy with a format/parse cycle */
if (!(xml = virNetworkDefFormat(def, xmlopt, flags)))
- goto cleanup;
- newDef = virNetworkDefParseString(xml, xmlopt);
- cleanup:
- VIR_FREE(xml);
- return newDef;
+ return NULL;
+
+ return virNetworkDefParseString(xml, xmlopt);
}
@@ -465,48 +462,43 @@ virNetworkDHCPRangeDefParseXML(const char *networkName,
{
virSocketAddrRangePtr addr = &range->addr;
xmlNodePtr cur = node->children;
- char *start = NULL, *end = NULL;
- int ret = -1;
+ g_autofree char *start = NULL;
+ g_autofree char *end = NULL;
if (!(start = virXMLPropString(node, "start"))) {
virReportError(VIR_ERR_XML_ERROR,
_("Missing 'start' attribute in dhcp range for network '%s'"),
networkName);
- goto cleanup;
+ return -1;
}
if (virSocketAddrParse(&addr->start, start, AF_UNSPEC) < 0)
- goto cleanup;
+ return -1;
if (!(end = virXMLPropString(node, "end"))) {
virReportError(VIR_ERR_XML_ERROR,
_("Missing 'end' attribute in dhcp range for network '%s'"),
networkName);
- goto cleanup;
+ return -1;
}
if (virSocketAddrParse(&addr->end, end, AF_UNSPEC) < 0)
- goto cleanup;
+ return -1;
/* do a sanity check of the range */
if (virSocketAddrGetRange(&addr->start, &addr->end, &ipdef->address,
virNetworkIPDefPrefix(ipdef)) < 0)
- goto cleanup;
+ return -1;
while (cur != NULL) {
if (cur->type == XML_ELEMENT_NODE &&
virXMLNodeNameEqual(cur, "lease")) {
if (virNetworkDHCPLeaseTimeDefParseXML(&range->lease, cur) < 0)
- goto cleanup;
+ return -1;
}
cur = cur->next;
}
- ret = 0;
-
- cleanup:
- VIR_FREE(start);
- VIR_FREE(end);
- return ret;
+ return 0;
}
@@ -517,11 +509,13 @@ virNetworkDHCPHostDefParseXML(const char *networkName,
virNetworkDHCPHostDefPtr host,
bool partialOkay)
{
- char *mac = NULL, *name = NULL, *ip = NULL, *id = NULL;
+ g_autofree char *mac = NULL;
+ g_autofree char *name = NULL;
+ g_autofree char *ip = NULL;
+ g_autofree char *id = NULL;
virMacAddr addr;
virSocketAddr inaddr;
xmlNodePtr cur = node->children;
- int ret = -1;
mac = virXMLPropString(node, "mac");
if (mac != NULL) {
@@ -530,20 +524,20 @@ virNetworkDHCPHostDefParseXML(const char *networkName,
_("Invalid to specify MAC address '%s' "
"in network '%s' IPv6 static host definition"),
mac, networkName);
- goto cleanup;
+ return -1;
}
if (virMacAddrParse(mac, &addr) < 0) {
virReportError(VIR_ERR_XML_ERROR,
_("Cannot parse MAC address '%s' in network '%s'"),
mac, networkName);
- goto cleanup;
+ return -1;
}
if (virMacAddrIsMulticast(&addr)) {
virReportError(VIR_ERR_XML_ERROR,
_("expected unicast mac address, found "
"multicast '%s' in network '%s'"),
(const char *)mac, networkName);
- goto cleanup;
+ return -1;
}
}
@@ -554,7 +548,7 @@ virNetworkDHCPHostDefParseXML(const char *networkName,
virReportError(VIR_ERR_XML_ERROR,
_("Invalid character '%c' in id '%s' of network '%s'"),
*cp, id, networkName);
- goto cleanup;
+ return -1;
}
}
@@ -563,7 +557,7 @@ virNetworkDHCPHostDefParseXML(const char *networkName,
virReportError(VIR_ERR_XML_ERROR,
_("Cannot use host name '%s' in network '%s'"),
name, networkName);
- goto cleanup;
+ return -1;
}
ip = virXMLPropString(node, "ip");
@@ -572,7 +566,7 @@ virNetworkDHCPHostDefParseXML(const char *networkName,
_("Invalid IP address in static host definition "
"for network '%s'"),
networkName);
- goto cleanup;
+ return -1;
}
if (partialOkay) {
@@ -583,7 +577,7 @@ virNetworkDHCPHostDefParseXML(const char *networkName,
"must be specified for static host definition "
"in network '%s' "),
networkName);
- goto cleanup;
+ return -1;
}
} else {
/* normal usage - you need at least name (IPv6) or one of MAC
@@ -595,21 +589,21 @@ virNetworkDHCPHostDefParseXML(const char *networkName,
_("Static host definition in IPv6 network '%s' "
"must have id or name attribute"),
networkName);
- goto cleanup;
+ return -1;
}
} else if (!(mac || name)) {
virReportError(VIR_ERR_XML_ERROR,
_("Static host definition in IPv4 network '%s' "
"must have mac or name attribute"),
networkName);
- goto cleanup;
+ return -1;
}
if (!ip) {
virReportError(VIR_ERR_XML_ERROR,
_("Missing IP address in static host definition "
"for network '%s'"),
networkName);
- goto cleanup;
+ return -1;
}
}
@@ -618,7 +612,7 @@ virNetworkDHCPHostDefParseXML(const char *networkName,
virXMLNodeNameEqual(cur, "lease")) {
if (virNetworkDHCPLeaseTimeDefParseXML(&host->lease, cur) < 0)
- goto cleanup;
+ return -1;
}
cur = cur->next;
}
@@ -631,14 +625,9 @@ virNetworkDHCPHostDefParseXML(const char *networkName,
name = NULL;
if (ip)
host->ip = inaddr;
- ret = 0;
- cleanup:
- VIR_FREE(mac);
- VIR_FREE(id);
- VIR_FREE(name);
- VIR_FREE(ip);
- return ret;
+ return 0;
+
}
@@ -676,8 +665,8 @@ virNetworkDHCPDefParseXML(const char *networkName,
} else if (VIR_SOCKET_ADDR_IS_FAMILY(&def->address, AF_INET) &&
cur->type == XML_ELEMENT_NODE &&
virXMLNodeNameEqual(cur, "bootp")) {
- char *file;
- char *server;
+ g_autofree char *file = NULL;
+ g_autofree char *server = NULL;
virSocketAddr inaddr;
memset(&inaddr, 0, sizeof(inaddr));
@@ -689,14 +678,12 @@ virNetworkDHCPDefParseXML(const char *networkName,
if (server &&
virSocketAddrParse(&inaddr, server, AF_UNSPEC) < 0) {
- VIR_FREE(file);
- VIR_FREE(server);
goto cleanup;
}
def->bootfile = file;
+ file = NULL;
def->bootserver = inaddr;
- VIR_FREE(server);
}
cur = cur->next;
@@ -716,7 +703,7 @@ virNetworkDNSHostDefParseXML(const char *networkName,
bool partialOkay)
{
xmlNodePtr cur;
- char *ip;
+ g_autofree char *ip = NULL;
if (!(ip = virXMLPropString(node, "ip")) && !partialOkay) {
virReportError(VIR_ERR_XML_DETAIL,
@@ -729,17 +716,15 @@ virNetworkDNSHostDefParseXML(const char *networkName,
virReportError(VIR_ERR_XML_DETAIL,
_("Invalid IP address in network '%s' DNS HOST record"),
networkName);
- VIR_FREE(ip);
goto error;
}
- VIR_FREE(ip);
cur = node->children;
while (cur != NULL) {
if (cur->type == XML_ELEMENT_NODE &&
virXMLNodeNameEqual(cur, "hostname")) {
if (cur->children != NULL) {
- char *name = (char *) xmlNodeGetContent(cur);
+ g_autofree char *name = (char *) xmlNodeGetContent(cur);
if (!name) {
virReportError(VIR_ERR_XML_DETAIL,
@@ -747,10 +732,8 @@ virNetworkDNSHostDefParseXML(const char *networkName,
networkName);
goto error;
}
- if (VIR_APPEND_ELEMENT(def->names, def->nnames, name) < 0) {
- VIR_FREE(name);
+ if (VIR_APPEND_ELEMENT(def->names, def->nnames, name) < 0)
goto error;
- }
}
}
cur = cur->next;
@@ -950,15 +933,14 @@ virNetworkDNSDefParseXML(const char *networkName,
xmlXPathContextPtr ctxt,
virNetworkDNSDefPtr def)
{
- xmlNodePtr *hostNodes = NULL;
- xmlNodePtr *srvNodes = NULL;
- xmlNodePtr *txtNodes = NULL;
- xmlNodePtr *fwdNodes = NULL;
- char *forwardPlainNames = NULL;
- char *enable = NULL;
+ g_autofree xmlNodePtr *hostNodes = NULL;
+ g_autofree xmlNodePtr *srvNodes = NULL;
+ g_autofree xmlNodePtr *txtNodes = NULL;
+ g_autofree xmlNodePtr *fwdNodes = NULL;
+ g_autofree char *forwardPlainNames = NULL;
+ g_autofree char *enable = NULL;
int nhosts, nsrvs, ntxts, nfwds;
size_t i;
- int ret = -1;
VIR_XPATH_NODE_AUTORESTORE(ctxt);
ctxt->node = node;
@@ -971,7 +953,7 @@ virNetworkDNSDefParseXML(const char *networkName,
_("Invalid dns enable setting '%s' "
"in network '%s'"),
enable, networkName);
- goto cleanup;
+ return -1;
}
}
@@ -983,7 +965,7 @@ virNetworkDNSDefParseXML(const char *networkName,
_("Invalid dns forwardPlainNames setting '%s' "
"in network '%s'"),
forwardPlainNames, networkName);
- goto cleanup;
+ return -1;
}
}
@@ -992,14 +974,14 @@ virNetworkDNSDefParseXML(const char *networkName,
virReportError(VIR_ERR_XML_ERROR,
_("invalid <forwarder> element found in <dns> of network %s"),
networkName);
- goto cleanup;
+ return -1;
}
if (nfwds > 0) {
if (VIR_ALLOC_N(def->forwarders, nfwds) < 0)
- goto cleanup;
+ return -1;
for (i = 0; i < nfwds; i++) {
- char *addr = virXMLPropString(fwdNodes[i], "addr");
+ g_autofree char *addr = virXMLPropString(fwdNodes[i], "addr");
if (addr && virSocketAddrParse(&def->forwarders[i].addr,
addr, AF_UNSPEC) < 0) {
@@ -1007,17 +989,15 @@ virNetworkDNSDefParseXML(const char *networkName,
_("Invalid forwarder IP address '%s' "
"in network '%s'"),
addr, networkName);
- VIR_FREE(addr);
- goto cleanup;
+ return -1;
}
def->forwarders[i].domain = virXMLPropString(fwdNodes[i], "domain");
if (!(addr || def->forwarders[i].domain)) {
virReportError(VIR_ERR_XML_ERROR, "%s",
_("Invalid forwarder element, must contain "
"at least one of addr or domain"));
- goto cleanup;
+ return -1;
}
- VIR_FREE(addr);
def->nfwds++;
}
}
@@ -1027,16 +1007,16 @@ virNetworkDNSDefParseXML(const char *networkName,
virReportError(VIR_ERR_XML_ERROR,
_("invalid <host> element found in <dns> of network %s"),
networkName);
- goto cleanup;
+ return -1;
}
if (nhosts > 0) {
if (VIR_ALLOC_N(def->hosts, nhosts) < 0)
- goto cleanup;
+ return -1;
for (i = 0; i < nhosts; i++) {
if (virNetworkDNSHostDefParseXML(networkName, hostNodes[i],
&def->hosts[def->nhosts], false) < 0) {
- goto cleanup;
+ return -1;
}
def->nhosts++;
}
@@ -1047,16 +1027,16 @@ virNetworkDNSDefParseXML(const char *networkName,
virReportError(VIR_ERR_XML_ERROR,
_("invalid <srv> element found in <dns> of network %s"),
networkName);
- goto cleanup;
+ return -1;
}
if (nsrvs > 0) {
if (VIR_ALLOC_N(def->srvs, nsrvs) < 0)
- goto cleanup;
+ return -1;
for (i = 0; i < nsrvs; i++) {
if (virNetworkDNSSrvDefParseXML(networkName, srvNodes[i], ctxt,
&def->srvs[def->nsrvs], false) < 0) {
- goto cleanup;
+ return -1;
}
def->nsrvs++;
}
@@ -1067,16 +1047,16 @@ virNetworkDNSDefParseXML(const char *networkName,
virReportError(VIR_ERR_XML_ERROR,
_("invalid <txt> element found in <dns> of network %s"),
networkName);
- goto cleanup;
+ return -1;
}
if (ntxts > 0) {
if (VIR_ALLOC_N(def->txts, ntxts) < 0)
- goto cleanup;
+ return -1;
for (i = 0; i < ntxts; i++) {
if (virNetworkDNSTxtDefParseXML(networkName, txtNodes[i],
&def->txts[def->ntxts], false) < 0) {
- goto cleanup;
+ return -1;
}
def->ntxts++;
}
@@ -1087,18 +1067,10 @@ virNetworkDNSDefParseXML(const char *networkName,
virReportError(VIR_ERR_XML_ERROR,
_("Extra data in disabled network '%s'"),
networkName);
- goto cleanup;
+ return -1;
}
- ret = 0;
- cleanup:
- VIR_FREE(enable);
- VIR_FREE(forwardPlainNames);
- VIR_FREE(fwdNodes);
- VIR_FREE(hostNodes);
- VIR_FREE(srvNodes);
- VIR_FREE(txtNodes);
- return ret;
+ return 0;
}
@@ -1115,11 +1087,12 @@ virNetworkIPDefParseXML(const char *networkName,
VIR_XPATH_NODE_AUTORESTORE(ctxt);
xmlNodePtr dhcp;
- char *address = NULL, *netmask = NULL;
+ g_autofree char *address = NULL;
+ g_autofree char *netmask = NULL;
+ g_autofree char *localPtr = NULL;
unsigned long prefix = 0;
int prefixRc;
- int result = -1;
- char *localPtr = NULL;
+ int ret = -1;
ctxt->node = node;
@@ -1243,16 +1216,13 @@ virNetworkIPDefParseXML(const char *networkName,
def->tftproot = virXPathString("string(./tftp[1]/@root)", ctxt);
}
- result = 0;
+ ret = 0;
cleanup:
- if (result < 0)
+ if (ret < 0)
virNetworkIPDefClear(def);
- VIR_FREE(address);
- VIR_FREE(netmask);
- VIR_FREE(localPtr);
- return result;
+ return ret;
}
@@ -1290,10 +1260,10 @@ virNetworkPortGroupParseXML(virPortGroupDefPtr def,
xmlNodePtr virtPortNode;
xmlNodePtr vlanNode;
xmlNodePtr bandwidth_node;
- char *isDefault = NULL;
- char *trustGuestRxFilters = NULL;
+ g_autofree char *isDefault = NULL;
+ g_autofree char *trustGuestRxFilters = NULL;
- int result = -1;
+ int ret = -1;
ctxt->node = node;
@@ -1335,14 +1305,12 @@ virNetworkPortGroupParseXML(virPortGroupDefPtr def,
if (vlanNode && virNetDevVlanParse(vlanNode, ctxt, &def->vlan) < 0)
goto cleanup;
- result = 0;
+ ret = 0;
cleanup:
- if (result < 0)
+ if (ret < 0)
virPortGroupDefClear(def);
- VIR_FREE(isDefault);
- VIR_FREE(trustGuestRxFilters);
- return result;
+ return ret;
}
@@ -1352,13 +1320,12 @@ virNetworkForwardNatDefParseXML(const char *networkName,
xmlXPathContextPtr ctxt,
virNetworkForwardDefPtr def)
{
- int ret = -1;
- xmlNodePtr *natAddrNodes = NULL;
- xmlNodePtr *natPortNodes = NULL;
int nNatAddrs, nNatPorts;
- char *addrStart = NULL;
- char *addrEnd = NULL;
- char *ipv6 = NULL;
+ g_autofree xmlNodePtr *natAddrNodes = NULL;
+ g_autofree xmlNodePtr *natPortNodes = NULL;
+ g_autofree char *addrStart = NULL;
+ g_autofree char *addrEnd = NULL;
+ g_autofree char *ipv6 = NULL;
VIR_XPATH_NODE_AUTORESTORE(ctxt);
ctxt->node = node;
@@ -1367,7 +1334,7 @@ virNetworkForwardNatDefParseXML(const char *networkName,
virReportError(VIR_ERR_XML_ERROR,
_("The <nat> element can only be used when <forward> 'mode' is 'nat' in network %s"),
networkName);
- goto cleanup;
+ return -1;
}
ipv6 = virXMLPropString(node, "ipv6");
@@ -1378,10 +1345,9 @@ virNetworkForwardNatDefParseXML(const char *networkName,
_("Invalid ipv6 setting '%s' "
"in network '%s' NAT"),
ipv6, networkName);
- goto cleanup;
+ return -1;
}
def->natIPv6 = natIPv6;
- VIR_FREE(ipv6);
}
/* addresses for SNAT */
@@ -1390,26 +1356,26 @@ virNetworkForwardNatDefParseXML(const char *networkName,
virReportError(VIR_ERR_XML_ERROR,
_("invalid <address> element found in <forward> of "
"network %s"), networkName);
- goto cleanup;
+ return -1;
} else if (nNatAddrs > 1) {
virReportError(VIR_ERR_XML_ERROR,
_("Only one <address> element is allowed in <nat> in "
"<forward> in network %s"), networkName);
- goto cleanup;
+ return -1;
} else if (nNatAddrs == 1) {
addrStart = virXMLPropString(*natAddrNodes, "start");
if (addrStart == NULL) {
virReportError(VIR_ERR_XML_ERROR,
_("missing 'start' attribute in <address> element in <nat> in "
"<forward> in network %s"), networkName);
- goto cleanup;
+ return -1;
}
addrEnd = virXMLPropString(*natAddrNodes, "end");
if (addrEnd == NULL) {
virReportError(VIR_ERR_XML_ERROR,
_("missing 'end' attribute in <address> element in <nat> in "
"<forward> in network %s"), networkName);
- goto cleanup;
+ return -1;
}
}
@@ -1417,34 +1383,34 @@ virNetworkForwardNatDefParseXML(const char *networkName,
virReportError(VIR_ERR_XML_ERROR,
_("Bad ipv4 start address '%s' in <nat> in <forward> in "
"network '%s'"), addrStart, networkName);
- goto cleanup;
+ return -1;
}
if (addrEnd && virSocketAddrParse(&def->addr.end, addrEnd, AF_INET) < 0) {
virReportError(VIR_ERR_XML_ERROR,
_("Bad ipv4 end address '%s' in <nat> in <forward> in "
"network '%s'"), addrEnd, networkName);
- goto cleanup;
+ return -1;
}
if (addrStart && addrEnd) {
/* verify that start <= end */
if (virSocketAddrGetRange(&def->addr.start, &def->addr.end, NULL, 0) < 0)
- goto cleanup;
+ return -1;
} else {
if (addrStart) {
virReportError(VIR_ERR_XML_ERROR,
_("Only start address '%s' specified in <nat> in "
"<forward> in network '%s'"),
addrStart, networkName);
- goto cleanup;
+ return -1;
}
if (addrEnd) {
virReportError(VIR_ERR_XML_ERROR,
_("Only end address '%s' specified in <nat> in "
"<forward> in network '%s'"),
addrEnd, networkName);
- goto cleanup;
+ return -1;
}
}
@@ -1454,12 +1420,12 @@ virNetworkForwardNatDefParseXML(const char *networkName,
virReportError(VIR_ERR_XML_ERROR,
_("invalid <port> element found in <forward> of "
"network %s"), networkName);
- goto cleanup;
+ return -1;
} else if (nNatPorts > 1) {
virReportError(VIR_ERR_XML_ERROR,
_("Only one <port> element is allowed in <nat> in "
"<forward> in network %s"), networkName);
- goto cleanup;
+ return -1;
} else if (nNatPorts == 1) {
if (virXPathUInt("string(./port[1]/@start)", ctxt, &def->port.start) < 0
|| def->port.start > 65535) {
@@ -1468,24 +1434,17 @@ virNetworkForwardNatDefParseXML(const char *networkName,
_("Missing or invalid 'start' attribute in <port> "
"in <nat> in <forward> in network %s"),
networkName);
- goto cleanup;
+ return -1;
}
if (virXPathUInt("string(./port[1]/@end)", ctxt, &def->port.end) < 0
|| def->port.end > 65535 || def->port.end < def->port.start) {
virReportError(VIR_ERR_XML_DETAIL,
_("Missing or invalid 'end' attribute in <port> in "
"<nat> in <forward> in network %s"), networkName);
- goto cleanup;
+ return -1;
}
}
- ret = 0;
-
- cleanup:
- VIR_FREE(addrStart);
- VIR_FREE(addrEnd);
- VIR_FREE(natAddrNodes);
- VIR_FREE(natPortNodes);
- return ret;
+ return 0;
}
@@ -1496,16 +1455,15 @@ virNetworkForwardDefParseXML(const char *networkName,
virNetworkForwardDefPtr def)
{
size_t i, j;
- int ret = -1;
- xmlNodePtr *forwardIfNodes = NULL;
- xmlNodePtr *forwardPfNodes = NULL;
- xmlNodePtr *forwardAddrNodes = NULL;
- xmlNodePtr *forwardNatNodes = NULL;
int nForwardIfs, nForwardAddrs, nForwardPfs, nForwardNats;
- char *forwardDev = NULL;
- char *forwardManaged = NULL;
- char *forwardDriverName = NULL;
- char *type = NULL;
+ g_autofree xmlNodePtr *forwardIfNodes = NULL;
+ g_autofree xmlNodePtr *forwardPfNodes = NULL;
+ g_autofree xmlNodePtr *forwardAddrNodes = NULL;
+ g_autofree xmlNodePtr *forwardNatNodes = NULL;
+ g_autofree char *forwardDev = NULL;
+ g_autofree char *forwardManaged = NULL;
+ g_autofree char *forwardDriverName = NULL;
+ g_autofree char *type = NULL;
VIR_XPATH_NODE_AUTORESTORE(ctxt);
ctxt->node = node;
@@ -1516,9 +1474,8 @@ virNetworkForwardDefParseXML(const char *networkName,
if ((def->type = virNetworkForwardTypeFromString(type)) < 0) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("unknown forwarding type '%s'"), type);
- goto cleanup;
+ return -1;
}
- VIR_FREE(type);
}
forwardManaged = virXPathString("string(./@managed)", ctxt);
@@ -1537,7 +1494,7 @@ virNetworkForwardDefParseXML(const char *networkName,
_("Unknown forward <driver name='%s'/> "
"in network %s"),
forwardDriverName, networkName);
- goto cleanup;
+ return -1;
}
def->driverName = driverName;
}
@@ -1548,7 +1505,7 @@ virNetworkForwardDefParseXML(const char *networkName,
virReportError(VIR_ERR_XML_ERROR,
_("invalid <interface> element found in <forward> of network %s"),
networkName);
- goto cleanup;
+ return -1;
}
nForwardAddrs = virXPathNodeSet("./address", ctxt, &forwardAddrNodes);
@@ -1556,7 +1513,7 @@ virNetworkForwardDefParseXML(const char *networkName,
virReportError(VIR_ERR_XML_ERROR,
_("invalid <address> element found in <forward> of network %s"),
networkName);
- goto cleanup;
+ return -1;
}
nForwardPfs = virXPathNodeSet("./pf", ctxt, &forwardPfNodes);
@@ -1564,7 +1521,7 @@ virNetworkForwardDefParseXML(const char *networkName,
virReportError(VIR_ERR_XML_ERROR,
_("invalid <pf> element found in <forward> of network %s"),
networkName);
- goto cleanup;
+ return -1;
}
nForwardNats = virXPathNodeSet("./nat", ctxt, &forwardNatNodes);
@@ -1572,17 +1529,17 @@ virNetworkForwardDefParseXML(const char *networkName,
virReportError(VIR_ERR_XML_ERROR,
_("invalid <nat> element found in <forward> of network %s"),
networkName);
- goto cleanup;
+ return -1;
} else if (nForwardNats > 1) {
virReportError(VIR_ERR_XML_ERROR,
_("Only one <nat> element is allowed in <forward> of network %s"),
networkName);
- goto cleanup;
+ return -1;
} else if (nForwardNats == 1) {
if (virNetworkForwardNatDefParseXML(networkName,
*forwardNatNodes,
ctxt, def) < 0)
- goto cleanup;
+ return -1;
}
forwardDev = virXPathString("string(./@dev)", ctxt);
@@ -1591,12 +1548,12 @@ virNetworkForwardDefParseXML(const char *networkName,
_("the <forward> 'dev' attribute cannot be used when "
"<address> or <pf> sub-elements are present "
"in network %s"));
- goto cleanup;
+ return -1;
}
if (nForwardIfs > 0 || forwardDev) {
if (VIR_ALLOC_N(def->ifs, MAX(nForwardIfs, 1)) < 0)
- goto cleanup;
+ return -1;
if (forwardDev) {
def->ifs[0].device.dev = forwardDev;
@@ -1607,64 +1564,66 @@ virNetworkForwardDefParseXML(const char *networkName,
/* parse each <interface> */
for (i = 0; i < nForwardIfs; i++) {
- forwardDev = virXMLPropString(forwardIfNodes[i], "dev");
- if (!forwardDev) {
+ g_autofree char *forwardDevi = virXMLPropString(forwardIfNodes[i], "dev");
+
+ if (!forwardDevi) {
virReportError(VIR_ERR_XML_ERROR,
_("Missing required dev attribute in "
"<forward> <interface> element of network %s"),
networkName);
- goto cleanup;
+ return -1;
}
if ((i == 0) && (def->nifs == 1)) {
/* both <forward dev='x'> and <interface dev='x'/> are
* present. If they don't match, it's an error.
*/
- if (STRNEQ(forwardDev, def->ifs[0].device.dev)) {
+ if (STRNEQ(forwardDevi, def->ifs[0].device.dev)) {
virReportError(VIR_ERR_XML_ERROR,
_("<forward dev='%s'> must match first "
"<interface dev='%s'/> in network %s"),
def->ifs[0].device.dev,
- forwardDev, networkName);
- goto cleanup;
+ forwardDevi, networkName);
+ return -1;
}
- VIR_FREE(forwardDev);
continue;
}
for (j = 0; j < i; j++) {
- if (STREQ_NULLABLE(def->ifs[j].device.dev, forwardDev)) {
+ if (STREQ_NULLABLE(def->ifs[j].device.dev, forwardDevi)) {
virReportError(VIR_ERR_XML_ERROR,
_("interface '%s' can only be "
"listed once in network %s"),
- forwardDev, networkName);
- goto cleanup;
+ forwardDevi, networkName);
+ return -1;
}
}
- def->ifs[i].device.dev = forwardDev;
- forwardDev = NULL;
+ def->ifs[i].device.dev = forwardDevi;
+ forwardDevi = NULL;
def->ifs[i].type = VIR_NETWORK_FORWARD_HOSTDEV_DEVICE_NETDEV;
def->nifs++;
}
} else if (nForwardAddrs > 0) {
if (VIR_ALLOC_N(def->ifs, nForwardAddrs) < 0)
- goto cleanup;
+ return -1;
for (i = 0; i < nForwardAddrs; i++) {
- if (!(type = virXMLPropString(forwardAddrNodes[i], "type"))) {
+ g_autofree char *addrType = NULL;
+
+ if (!(addrType = virXMLPropString(forwardAddrNodes[i], "type"))) {
virReportError(VIR_ERR_XML_ERROR,
_("missing address type in network %s"),
networkName);
- goto cleanup;
+ return -1;
}
- if ((def->ifs[i].type = virNetworkForwardHostdevDeviceTypeFromString(type)) < 0) {
+ if ((def->ifs[i].type = virNetworkForwardHostdevDeviceTypeFromString(addrType)) < 0) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("unknown address type '%s' in network %s"),
- type, networkName);
- goto cleanup;
+ addrType, networkName);
+ return -1;
}
switch (def->ifs[i].type) {
@@ -1673,7 +1632,7 @@ virNetworkForwardDefParseXML(const char *networkName,
virPCIDeviceAddressPtr addr = &def->ifs[i].device.pci;
if (virPCIDeviceAddressParseXML(forwardAddrNodes[i], addr) < 0)
- goto cleanup;
+ return -1;
for (j = 0; j < i; j++) {
if (virPCIDeviceAddressEqual(addr, &def->ifs[j].device.pci)) {
@@ -1683,7 +1642,7 @@ virNetworkForwardDefParseXML(const char *networkName,
addr->domain, addr->bus,
addr->slot, addr->function,
networkName);
- goto cleanup;
+ return -1;
}
}
break;
@@ -1693,10 +1652,9 @@ virNetworkForwardDefParseXML(const char *networkName,
default:
virReportError(VIR_ERR_XML_ERROR,
_("unsupported address type '%s' in network %s"),
- type, networkName);
- goto cleanup;
+ addrType, networkName);
+ return -1;
}
- VIR_FREE(type);
def->nifs++;
}
@@ -1704,10 +1662,10 @@ virNetworkForwardDefParseXML(const char *networkName,
virReportError(VIR_ERR_XML_ERROR,
_("Only one <pf> element is allowed in <forward> of network %s"),
networkName);
- goto cleanup;
+ return -1;
} else if (nForwardPfs == 1) {
if (VIR_ALLOC_N(def->pfs, nForwardPfs) < 0)
- goto cleanup;
+ return -1;
forwardDev = virXMLPropString(*forwardPfNodes, "dev");
if (!forwardDev) {
@@ -1715,7 +1673,7 @@ virNetworkForwardDefParseXML(const char *networkName,
_("Missing required dev attribute "
"in <pf> element of network '%s'"),
networkName);
- goto cleanup;
+ return -1;
}
def->pfs->dev = forwardDev;
@@ -1723,17 +1681,7 @@ virNetworkForwardDefParseXML(const char *networkName,
def->npfs++;
}
- ret = 0;
- cleanup:
- VIR_FREE(type);
- VIR_FREE(forwardDev);
- VIR_FREE(forwardManaged);
- VIR_FREE(forwardDriverName);
- VIR_FREE(forwardPfNodes);
- VIR_FREE(forwardIfNodes);
- VIR_FREE(forwardAddrNodes);
- VIR_FREE(forwardNatNodes);
- return ret;
+ return 0;
}
@@ -1741,18 +1689,23 @@ virNetworkDefPtr
virNetworkDefParseXML(xmlXPathContextPtr ctxt,
virNetworkXMLOptionPtr xmlopt)
{
- virNetworkDefPtr def;
- char *tmp = NULL;
- char *stp = NULL;
- xmlNodePtr *ipNodes = NULL;
- xmlNodePtr *routeNodes = NULL;
- xmlNodePtr *portGroupNodes = NULL;
+ g_autoptr(virNetworkDef) def = NULL;
+ g_autofree char *uuid = NULL;
+ g_autofree char *localOnly = NULL;
+ g_autofree char *stp = NULL;
+ g_autofree char *stpDelay = NULL;
+ g_autofree char *macTableManager = NULL;
+ g_autofree char *macAddr = NULL;
+ g_autofree char *mtuSize = NULL;
+ g_autofree xmlNodePtr *ipNodes = NULL;
+ g_autofree xmlNodePtr *routeNodes = NULL;
+ g_autofree xmlNodePtr *portGroupNodes = NULL;
int nips, nPortGroups, nRoutes;
xmlNodePtr dnsNode = NULL;
xmlNodePtr virtPortNode = NULL;
xmlNodePtr forwardNode = NULL;
- char *ipv6nogwStr = NULL;
- char *trustGuestRxFilters = NULL;
+ g_autofree char *ipv6nogwStr = NULL;
+ g_autofree char *trustGuestRxFilters = NULL;
VIR_XPATH_NODE_AUTORESTORE(ctxt);
xmlNodePtr bandwidthNode = NULL;
xmlNodePtr vlanNode;
@@ -1765,27 +1718,26 @@ virNetworkDefParseXML(xmlXPathContextPtr ctxt,
def->name = virXPathString("string(./name[1])", ctxt);
if (!def->name) {
virReportError(VIR_ERR_NO_NAME, NULL);
- goto error;
+ return NULL;
}
if (virXMLCheckIllegalChars("name", def->name, "/") < 0)
- goto error;
+ return NULL;
/* Extract network uuid */
- tmp = virXPathString("string(./uuid[1])", ctxt);
- if (!tmp) {
+ uuid = virXPathString("string(./uuid[1])", ctxt);
+ if (!uuid) {
if (virUUIDGenerate(def->uuid) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR,
"%s", _("Failed to generate UUID"));
- goto error;
+ return NULL;
}
} else {
- if (virUUIDParse(tmp, def->uuid) < 0) {
+ if (virUUIDParse(uuid, def->uuid) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR,
"%s", _("malformed uuid element"));
- goto error;
+ return NULL;
}
- VIR_FREE(tmp);
def->uuid_specified = true;
}
@@ -1798,9 +1750,8 @@ virNetworkDefParseXML(xmlXPathContextPtr ctxt,
virReportError(VIR_ERR_XML_ERROR,
_("Invalid ipv6 setting '%s' in network '%s'"),
ipv6nogwStr, def->name);
- goto error;
+ return NULL;
}
- VIR_FREE(ipv6nogwStr);
}
trustGuestRxFilters
@@ -1812,36 +1763,34 @@ virNetworkDefParseXML(xmlXPathContextPtr ctxt,
_("Invalid trustGuestRxFilters setting '%s' "
"in network '%s'"),
trustGuestRxFilters, def->name);
- goto error;
+ return NULL;
}
- VIR_FREE(trustGuestRxFilters);
}
/* Parse network domain information */
def->domain = virXPathString("string(./domain[1]/@name)", ctxt);
- tmp = virXPathString("string(./domain[1]/@localOnly)", ctxt);
- if (tmp) {
- def->domainLocalOnly = virTristateBoolTypeFromString(tmp);
+ localOnly = virXPathString("string(./domain[1]/@localOnly)", ctxt);
+ if (localOnly) {
+ def->domainLocalOnly = virTristateBoolTypeFromString(localOnly);
if (def->domainLocalOnly <= 0) {
virReportError(VIR_ERR_XML_ERROR,
_("Invalid domain localOnly setting '%s' "
"in network '%s'"),
- tmp, def->name);
- goto error;
+ localOnly, def->name);
+ return NULL;
}
- VIR_FREE(tmp);
}
if ((bandwidthNode = virXPathNode("./bandwidth", ctxt)) &&
virNetDevBandwidthParse(&def->bandwidth, NULL, bandwidthNode, false) < 0)
- goto error;
+ return NULL;
vlanNode = virXPathNode("./vlan", ctxt);
if (vlanNode && virNetDevVlanParse(vlanNode, ctxt, &def->vlan) < 0)
- goto error;
+ return NULL;
if (virNetworkPortOptionsParseXML(ctxt, &def->isolatedPort) < 0)
- goto error;
+ return NULL;
/* Parse bridge information */
def->bridge = virXPathString("string(./bridge[1]/@name)", ctxt);
@@ -1849,124 +1798,118 @@ virNetworkDefParseXML(xmlXPathContextPtr ctxt,
stp = virXPathString("string(./bridge[1]/@stp)", ctxt);
def->stp = (stp && STREQ(stp, "off")) ? false : true;
- tmp = virXPathString("string(./bridge[1]/@delay)", ctxt);
- if (tmp) {
- if (virStrToLong_ulp(tmp, NULL, 10, &def->delay) < 0) {
+ stpDelay = virXPathString("string(./bridge[1]/@delay)", ctxt);
+ if (stpDelay) {
+ if (virStrToLong_ulp(stpDelay, NULL, 10, &def->delay) < 0) {
virReportError(VIR_ERR_XML_ERROR,
_("Invalid delay value in network '%s'"),
def->name);
- goto error;
+ return NULL;
}
}
- VIR_FREE(tmp);
- tmp = virXPathString("string(./bridge[1]/@macTableManager)", ctxt);
- if (tmp) {
+ macTableManager = virXPathString("string(./bridge[1]/@macTableManager)", ctxt);
+ if (macTableManager) {
if ((def->macTableManager
- = virNetworkBridgeMACTableManagerTypeFromString(tmp)) <= 0) {
+ = virNetworkBridgeMACTableManagerTypeFromString(macTableManager)) <= 0) {
virReportError(VIR_ERR_XML_ERROR,
_("Invalid macTableManager setting '%s' "
- "in network '%s'"), tmp, def->name);
- goto error;
+ "in network '%s'"), macTableManager, def->name);
+ return NULL;
}
- VIR_FREE(tmp);
}
- tmp = virXPathString("string(./mac[1]/@address)", ctxt);
- if (tmp) {
- if (virMacAddrParse(tmp, &def->mac) < 0) {
+ macAddr = virXPathString("string(./mac[1]/@address)", ctxt);
+ if (macAddr) {
+ if (virMacAddrParse(macAddr, &def->mac) < 0) {
virReportError(VIR_ERR_XML_ERROR,
_("Invalid bridge mac address '%s' in network '%s'"),
- tmp, def->name);
- goto error;
+ macAddr, def->name);
+ return NULL;
}
if (virMacAddrIsMulticast(&def->mac)) {
virReportError(VIR_ERR_XML_ERROR,
_("Invalid multicast bridge mac address '%s' in network '%s'"),
- tmp, def->name);
- goto error;
+ macAddr, def->name);
+ return NULL;
}
- VIR_FREE(tmp);
def->mac_specified = true;
}
- tmp = virXPathString("string(./mtu/@size)", ctxt);
- if (tmp) {
- if (virStrToLong_ui(tmp, NULL, 10, &def->mtu) < 0) {
+ mtuSize = virXPathString("string(./mtu/@size)", ctxt);
+ if (mtuSize) {
+ if (virStrToLong_ui(mtuSize, NULL, 10, &def->mtu) < 0) {
virReportError(VIR_ERR_XML_ERROR,
_("Invalid mtu size '%s' in network '%s'"),
- tmp, def->name);
- goto error;
+ mtuSize, def->name);
+ return NULL;
}
}
- VIR_FREE(tmp);
dnsNode = virXPathNode("./dns", ctxt);
if (dnsNode != NULL &&
virNetworkDNSDefParseXML(def->name, dnsNode, ctxt, &def->dns) < 0) {
- goto error;
+ return NULL;
}
virtPortNode = virXPathNode("./virtualport", ctxt);
if (virtPortNode &&
(!(def->virtPortProfile = virNetDevVPortProfileParse(virtPortNode,
VIR_VPORT_XML_REQUIRE_TYPE)))) {
- goto error;
+ return NULL;
}
nPortGroups = virXPathNodeSet("./portgroup", ctxt, &portGroupNodes);
if (nPortGroups < 0)
- goto error;
+ return NULL;
if (nPortGroups > 0) {
size_t i;
/* allocate array to hold all the portgroups */
if (VIR_ALLOC_N(def->portGroups, nPortGroups) < 0)
- goto error;
+ return NULL;
/* parse each portgroup */
for (i = 0; i < nPortGroups; i++) {
if (virNetworkPortGroupParseXML(&def->portGroups[i],
portGroupNodes[i],
ctxt) < 0)
- goto error;
+ return NULL;
def->nPortGroups++;
}
}
- VIR_FREE(portGroupNodes);
nips = virXPathNodeSet("./ip", ctxt, &ipNodes);
if (nips < 0)
- goto error;
+ return NULL;
if (nips > 0) {
size_t i;
/* allocate array to hold all the addrs */
if (VIR_ALLOC_N(def->ips, nips) < 0)
- goto error;
+ return NULL;
/* parse each addr */
for (i = 0; i < nips; i++) {
if (virNetworkIPDefParseXML(def->name,
ipNodes[i],
ctxt,
&def->ips[i]) < 0)
- goto error;
+ return NULL;
def->nips++;
}
}
- VIR_FREE(ipNodes);
nRoutes = virXPathNodeSet("./route", ctxt, &routeNodes);
if (nRoutes < 0)
- goto error;
+ return NULL;
if (nRoutes > 0) {
size_t i;
/* allocate array to hold all the route definitions */
if (VIR_ALLOC_N(def->routes, nRoutes) < 0)
- goto error;
+ return NULL;
/* parse each definition */
for (i = 0; i < nRoutes; i++) {
virNetDevIPRoutePtr route = NULL;
@@ -1974,7 +1917,7 @@ virNetworkDefParseXML(xmlXPathContextPtr ctxt,
if (!(route = virNetDevIPRouteParseXML(def->name,
routeNodes[i],
ctxt)))
- goto error;
+ return NULL;
def->routes[i] = route;
def->nroutes++;
}
@@ -2011,21 +1954,19 @@ virNetworkDefParseXML(xmlXPathContextPtr ctxt,
}
}
if (!addrMatch) {
- char *gw = virSocketAddrFormat(gateway);
+ g_autofree char *gw = virSocketAddrFormat(gateway);
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("unreachable static route gateway '%s' specified for network '%s'"),
gw, def->name);
- VIR_FREE(gw);
- goto error;
+ return NULL;
}
}
}
- VIR_FREE(routeNodes);
forwardNode = virXPathNode("./forward", ctxt);
if (forwardNode &&
virNetworkForwardDefParseXML(def->name, forwardNode, ctxt, &def->forward) < 0) {
- goto error;
+ return NULL;
}
/* Validate some items in the main NetworkDef that need to align
@@ -2047,14 +1988,14 @@ virNetworkDefParseXML(xmlXPathContextPtr ctxt,
"but no IP address provided for network '%s'"),
virNetworkForwardTypeToString(def->forward.type),
def->name);
- goto error;
+ return NULL;
}
if (def->forward.nifs > 1) {
virReportError(VIR_ERR_XML_ERROR,
_("multiple forwarding interfaces specified "
"for network '%s', only one is supported"),
def->name);
- goto error;
+ return NULL;
}
if (def->forward.type == VIR_NETWORK_FORWARD_OPEN && def->forward.nifs) {
@@ -2067,7 +2008,7 @@ virNetworkDefParseXML(xmlXPathContextPtr ctxt,
"network '%s' with forward mode='%s'"),
def->name,
virNetworkForwardTypeToString(def->forward.type));
- goto error;
+ return NULL;
}
break;
@@ -2080,14 +2021,14 @@ virNetworkDefParseXML(xmlXPathContextPtr ctxt,
_("bridge name not allowed in %s mode (network '%s')"),
virNetworkForwardTypeToString(def->forward.type),
def->name);
- goto error;
+ return NULL;
}
if (def->bridgeZone) {
virReportError(VIR_ERR_XML_ERROR,
_("bridge zone not allowed in %s mode (network '%s')"),
virNetworkForwardTypeToString(def->forward.type),
def->name);
- goto error;
+ return NULL;
}
if (def->macTableManager) {
virReportError(VIR_ERR_XML_ERROR,
@@ -2095,7 +2036,7 @@ virNetworkDefParseXML(xmlXPathContextPtr ctxt,
"in %s mode (network '%s')"),
virNetworkForwardTypeToString(def->forward.type),
def->name);
- goto error;
+ return NULL;
}
G_GNUC_FALLTHROUGH;
@@ -2107,7 +2048,7 @@ virNetworkDefParseXML(xmlXPathContextPtr ctxt,
"(network '%s')"),
virNetworkForwardTypeToString(def->forward.type),
def->name);
- goto error;
+ return NULL;
}
if (def->bridge && (def->forward.nifs || def->forward.npfs)) {
virReportError(VIR_ERR_XML_ERROR,
@@ -2116,18 +2057,16 @@ virNetworkDefParseXML(xmlXPathContextPtr ctxt,
"both (network '%s')"),
virNetworkForwardTypeToString(def->forward.type),
def->name);
- goto error;
+ return NULL;
}
break;
case VIR_NETWORK_FORWARD_LAST:
default:
virReportEnumRangeError(virNetworkForwardType, def->forward.type);
- goto error;
+ return NULL;
}
- VIR_FREE(stp);
-
if (def->mtu) {
switch ((virNetworkForwardType) def->forward.type) {
case VIR_NETWORK_FORWARD_NONE:
@@ -2146,12 +2085,12 @@ virNetworkDefParseXML(xmlXPathContextPtr ctxt,
"and isolated mode, not in %s (network '%s')"),
virNetworkForwardTypeToString(def->forward.type),
def->name);
- goto error;
+ return NULL;
case VIR_NETWORK_FORWARD_LAST:
default:
virReportEnumRangeError(virNetworkForwardType, def->forward.type);
- goto error;
+ return NULL;
}
}
@@ -2165,23 +2104,12 @@ virNetworkDefParseXML(xmlXPathContextPtr ctxt,
def->ns = xmlopt->ns;
if (def->ns.parse) {
if (virXMLNamespaceRegister(ctxt, &def->ns) < 0)
- goto error;
+ return NULL;
if ((def->ns.parse)(ctxt, &def->namespaceData) < 0)
- goto error;
+ return NULL;
}
- return def;
-
- error:
- VIR_FREE(tmp);
- VIR_FREE(routeNodes);
- VIR_FREE(stp);
- virNetworkDefFree(def);
- VIR_FREE(ipNodes);
- VIR_FREE(portGroupNodes);
- VIR_FREE(ipv6nogwStr);
- VIR_FREE(trustGuestRxFilters);
- return NULL;
+ return g_steal_pointer(&def);
}
@@ -2190,14 +2118,12 @@ virNetworkDefParse(const char *xmlStr,
const char *filename,
virNetworkXMLOptionPtr xmlopt)
{
- xmlDocPtr xml;
+ g_autoptr(xmlDoc) xml = NULL;
virNetworkDefPtr def = NULL;
int keepBlanksDefault = xmlKeepBlanksDefault(0);
- if ((xml = virXMLParse(filename, xmlStr, _("(network_definition)")))) {
+ if ((xml = virXMLParse(filename, xmlStr, _("(network_definition)"))))
def = virNetworkDefParseNode(xml, xmlDocGetRootElement(xml), xmlopt);
- xmlFreeDoc(xml);
- }
xmlKeepBlanksDefault(keepBlanksDefault);
return def;
@@ -2292,13 +2218,12 @@ virNetworkDNSDefFormat(virBufferPtr buf,
def->forwarders[i].domain);
}
if (VIR_SOCKET_ADDR_VALID(&def->forwarders[i].addr)) {
- char *addr = virSocketAddrFormat(&def->forwarders[i].addr);
+ g_autofree char *addr = virSocketAddrFormat(&def->forwarders[i].addr);
- if (!addr)
- return -1;
+ if (!addr)
+ return -1;
- virBufferAsprintf(buf, " addr='%s'", addr);
- VIR_FREE(addr);
+ virBufferAsprintf(buf, " addr='%s'", addr);
}
virBufferAddLit(buf, "/>\n");
}
@@ -2331,7 +2256,7 @@ virNetworkDNSDefFormat(virBufferPtr buf,
if (def->nhosts) {
for (i = 0; i < def->nhosts; i++) {
- char *ip = virSocketAddrFormat(&def->hosts[i].ip);
+ g_autofree char *ip = virSocketAddrFormat(&def->hosts[i].ip);
virBufferAsprintf(buf, "<host ip='%s'>\n", ip);
virBufferAdjustIndent(buf, 2);
@@ -2341,7 +2266,6 @@ virNetworkDNSDefFormat(virBufferPtr buf,
virBufferAdjustIndent(buf, -2);
virBufferAddLit(buf, "</host>\n");
- VIR_FREE(ip);
}
}
virBufferAdjustIndent(buf, -2);
@@ -2359,18 +2283,16 @@ virNetworkIPDefFormat(virBufferPtr buf,
if (def->family)
virBufferAsprintf(buf, " family='%s'", def->family);
if (VIR_SOCKET_ADDR_VALID(&def->address)) {
- char *addr = virSocketAddrFormat(&def->address);
+ g_autofree char *addr = virSocketAddrFormat(&def->address);
if (!addr)
return -1;
virBufferAsprintf(buf, " address='%s'", addr);
- VIR_FREE(addr);
}
if (VIR_SOCKET_ADDR_VALID(&def->netmask)) {
- char *addr = virSocketAddrFormat(&def->netmask);
+ g_autofree char *addr = virSocketAddrFormat(&def->netmask);
if (!addr)
return -1;
virBufferAsprintf(buf, " netmask='%s'", addr);
- VIR_FREE(addr);
}
if (def->prefix > 0)
virBufferAsprintf(buf, " prefix='%u'", def->prefix);
@@ -2395,15 +2317,15 @@ virNetworkIPDefFormat(virBufferPtr buf,
for (i = 0; i < def->nranges; i++) {
virSocketAddrRange addr = def->ranges[i].addr;
virNetworkDHCPLeaseTimeDefPtr lease = def->ranges[i].lease;
+ g_autofree char *saddr = NULL;
+ g_autofree char *eaddr = NULL;
- char *saddr = virSocketAddrFormat(&addr.start);
- if (!saddr)
+ if (!(saddr = virSocketAddrFormat(&addr.start)))
return -1;
- char *eaddr = virSocketAddrFormat(&addr.end);
- if (!eaddr) {
- VIR_FREE(saddr);
+
+ if (!(eaddr = virSocketAddrFormat(&addr.end)))
return -1;
- }
+
virBufferAsprintf(buf, "<range start='%s' end='%s'",
saddr, eaddr);
if (lease) {
@@ -2421,8 +2343,6 @@ virNetworkIPDefFormat(virBufferPtr buf,
} else {
virBufferAddLit(buf, "/>\n");
}
- VIR_FREE(saddr);
- VIR_FREE(eaddr);
}
for (i = 0; i < def->nhosts; i++) {
virNetworkDHCPLeaseTimeDefPtr lease = def->hosts[i].lease;
@@ -2434,11 +2354,11 @@ virNetworkIPDefFormat(virBufferPtr buf,
if (def->hosts[i].name)
virBufferAsprintf(buf, " name='%s'", def->hosts[i].name);
if (VIR_SOCKET_ADDR_VALID(&def->hosts[i].ip)) {
- char *ipaddr = virSocketAddrFormat(&def->hosts[i].ip);
+ g_autofree char *ipaddr = virSocketAddrFormat(&def->hosts[i].ip);
if (!ipaddr)
return -1;
+
virBufferAsprintf(buf, " ip='%s'", ipaddr);
- VIR_FREE(ipaddr);
}
if (lease) {
virBufferAddLit(buf, ">\n");
@@ -2460,11 +2380,11 @@ virNetworkIPDefFormat(virBufferPtr buf,
virBufferEscapeString(buf, "<bootp file='%s'",
def->bootfile);
if (VIR_SOCKET_ADDR_VALID(&def->bootserver)) {
- char *ipaddr = virSocketAddrFormat(&def->bootserver);
+ g_autofree char *ipaddr = virSocketAddrFormat(&def->bootserver);
if (!ipaddr)
return -1;
+
virBufferEscapeString(buf, " server='%s'", ipaddr);
- VIR_FREE(ipaddr);
}
virBufferAddLit(buf, "/>\n");
@@ -2515,20 +2435,19 @@ static int
virNetworkForwardNatDefFormat(virBufferPtr buf,
const virNetworkForwardDef *fwd)
{
- char *addrStart = NULL;
- char *addrEnd = NULL;
- int ret = -1;
+ g_autofree char *addrStart = NULL;
+ g_autofree char *addrEnd = NULL;
if (VIR_SOCKET_ADDR_VALID(&fwd->addr.start)) {
addrStart = virSocketAddrFormat(&fwd->addr.start);
if (!addrStart)
- goto cleanup;
+ return -1;
}
if (VIR_SOCKET_ADDR_VALID(&fwd->addr.end)) {
addrEnd = virSocketAddrFormat(&fwd->addr.end);
if (!addrEnd)
- goto cleanup;
+ return -1;
}
if (!addrEnd && !addrStart && !fwd->port.start && !fwd->port.end && !fwd->natIPv6)
@@ -2561,12 +2480,7 @@ virNetworkForwardNatDefFormat(virBufferPtr buf,
virBufferAdjustIndent(buf, -2);
virBufferAddLit(buf, "</nat>\n");
- ret = 0;
-
- cleanup:
- VIR_FREE(addrStart);
- VIR_FREE(addrEnd);
- return ret;
+ return 0;
}
@@ -2856,27 +2770,22 @@ virNetworkSaveXML(const char *configDir,
const char *xml)
{
char uuidstr[VIR_UUID_STRING_BUFLEN];
- char *configFile = NULL;
- int ret = -1;
+ g_autofree char *configFile = NULL;
if ((configFile = virNetworkConfigFile(configDir, def->name)) == NULL)
- goto cleanup;
+ return -1;
if (virFileMakePath(configDir) < 0) {
virReportSystemError(errno,
_("cannot create config directory '%s'"),
configDir);
- goto cleanup;
+ return -1;
}
virUUIDFormat(def->uuid, uuidstr);
- ret = virXMLSaveFile(configFile,
- virXMLPickShellSafeComment(def->name, uuidstr),
- "net-edit", xml);
-
- cleanup:
- VIR_FREE(configFile);
- return ret;
+ return virXMLSaveFile(configFile,
+ virXMLPickShellSafeComment(def->name, uuidstr),
+ "net-edit", xml);
}
@@ -2885,19 +2794,15 @@ virNetworkSaveConfig(const char *configDir,
virNetworkDefPtr def,
virNetworkXMLOptionPtr xmlopt)
{
- int ret = -1;
- char *xml;
+ g_autofree char *xml = NULL;
if (!(xml = virNetworkDefFormat(def, xmlopt, VIR_NETWORK_XML_INACTIVE)))
- goto cleanup;
+ return -1;
if (virNetworkSaveXML(configDir, def, xml))
- goto cleanup;
+ return -1;
- ret = 0;
- cleanup:
- VIR_FREE(xml);
- return ret;
+ return 0;
}
@@ -3113,14 +3018,13 @@ virNetworkDefUpdateIPDHCPHost(virNetworkDefPtr def,
}
if (i == ipdef->nhosts) {
- char *ip = virSocketAddrFormat(&host.ip);
+ g_autofree char *ip = virSocketAddrFormat(&host.ip);
virReportError(VIR_ERR_OPERATION_INVALID,
_("couldn't locate an existing dhcp host entry with "
"\"mac='%s'\" \"name='%s'\" \"ip='%s'\" in"
" network '%s'"),
host.mac ? host.mac : _("unknown"), host.name,
ip ? ip : _("unknown"), def->name);
- VIR_FREE(ip);
goto cleanup;
}
@@ -3146,7 +3050,7 @@ virNetworkDefUpdateIPDHCPHost(virNetworkDefPtr def,
STREQ_NULLABLE(host.name, ipdef->hosts[i].name)) ||
(VIR_SOCKET_ADDR_VALID(&host.ip) &&
virSocketAddrEqual(&host.ip, &ipdef->hosts[i].ip))) {
- char *ip = virSocketAddrFormat(&host.ip);
+ g_autofree char *ip = virSocketAddrFormat(&host.ip);
virReportError(VIR_ERR_OPERATION_INVALID,
_("there is an existing dhcp host entry in "
@@ -3154,7 +3058,6 @@ virNetworkDefUpdateIPDHCPHost(virNetworkDefPtr def,
"\"<host mac='%s' name='%s' ip='%s'/>\""),
def->name, host.mac ? host.mac : _("unknown"),
host.name, ip ? ip : _("unknown"));
- VIR_FREE(ip);
goto cleanup;
}
}
@@ -3258,8 +3161,8 @@ virNetworkDefUpdateIPDHCPRange(virNetworkDefPtr def,
return -1;
if (i < ipdef->nranges) {
- char *startip = virSocketAddrFormat(&range.addr.start);
- char *endip = virSocketAddrFormat(&range.addr.end);
+ g_autofree char *startip = virSocketAddrFormat(&range.addr.start);
+ g_autofree char *endip = virSocketAddrFormat(&range.addr.end);
virReportError(VIR_ERR_OPERATION_INVALID,
_("there is an existing dhcp range entry in "
@@ -3268,8 +3171,6 @@ virNetworkDefUpdateIPDHCPRange(virNetworkDefPtr def,
def->name,
startip ? startip : "unknown",
endip ? endip : "unknown");
- VIR_FREE(startip);
- VIR_FREE(endip);
return -1;
}
diff --git a/src/conf/network_conf.h b/src/conf/network_conf.h
index e3a61c62ea..34b9aa9505 100644
--- a/src/conf/network_conf.h
+++ b/src/conf/network_conf.h
@@ -321,6 +321,7 @@ typedef enum {
} virNetworkTaintFlags;
void virNetworkDefFree(virNetworkDefPtr def);
+G_DEFINE_AUTOPTR_CLEANUP_FUNC(virNetworkDef, virNetworkDefFree);
enum {
VIR_NETWORK_OBJ_LIST_ADD_LIVE = (1 << 0),
diff --git a/src/util/virxml.h b/src/util/virxml.h
index 26ab9f9c2d..ed178105f6 100644
--- a/src/util/virxml.h
+++ b/src/util/virxml.h
@@ -247,6 +247,7 @@ G_DEFINE_AUTO_CLEANUP_CLEAR_FUNC(virXPathContextNodeSave, virXPathContextNodeRes
G_DEFINE_AUTOPTR_CLEANUP_FUNC(xmlDoc, xmlFreeDoc);
G_DEFINE_AUTOPTR_CLEANUP_FUNC(xmlXPathContext, xmlXPathFreeContext);
+G_DEFINE_AUTOPTR_CLEANUP_FUNC(xmlBuffer, xmlBufferFree);
typedef int (*virXMLNamespaceParse)(xmlXPathContextPtr ctxt, void **nsdata);
typedef void (*virXMLNamespaceFree)(void *nsdata);
--
2.25.4
2
4
On Wed, Jun 03, 2020 at 12:24:27PM +0100, Daniel P. Berrangé wrote:
> On Tue, Jun 02, 2020 at 03:30:00PM +0300, K. Kahurani wrote:
> > ---------- Forwarded message ---------
> > From: K. Kahurani <k.kahurani(a)gmail.com>
> > Date: Sun, May 31, 2020 at 2:26 PM
> > Subject: Hello
> > To: <eblake(a)redhat.com>
> >
> >
> > Hello,
> >
> > Hopefully this finds you well.
> >
> > This is not a bug report but more or less an inquiry as based on the
> > information acquired from Jim Fehlig a while back, it is possible you would
> > have some important information regarding this.
> >
> > It is currently not possible for me to compile libvirt right from the word
> > go while configuring with the error [1]. From the look of it and a bit of
> > searching on the internet, it does look like the package portablexdr is
> > obsolete.
> >
> > Could it be that this is a known issue? Could it be there already is a
> > workaround this? Do you suppose this should go into the mailing list?
> >
> > [1]
> > checking for WIRESHARK_DISSECTOR... no
> > checking for xdrmem_create in -lportablexdr... no
> > checking for library containing xdrmem_create... no
> > configure: error: Cannot find a XDR library
>
> You're missing a build pre-requisite library for XDR. On Linux distros
> this is provided by "tirpc" these days, try libtirpc-devel RPM or
> libtirpc-dev Debian package.
Thanks a lot!
My distribution/distro is openSUSE.
Posting this here, for list purposes as someone might find it worthwhile.
$zypper in libpciaccess-devel device-mapper-devel rst2html5 libtirpc-devel rpcgen
Other packages were probably already installed.
$zypper addrepo https://download.opensuse.org/repositories/Publishing/openSUSE_Tumbleweed/P…
Had to add the above repo for package rst2html5
Sincerely,
David
>
>
> Regards,
> Daniel
> --
> |: https://berrange.com -o- https://www.flickr.com/photos/dberrange :|
> |: https://libvirt.org -o- https://fstop138.berrange.com :|
> |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
>
1
0
11 Jun '20
Recent commit showed that compilers are not able to detect unused
variables when passed to VIR_FREE, so I fixed all the other instances
the patch didn't fix.
Peter Krempa (7):
libxlDomainMigrationDstPrepareDef: remove use of temporary variable
testVirFindSCSIHostByPCI: Remove unused 'path_addr'
cputest: Avoid use of temporary variable in DO_TEST macro
virTPMEmulatorInit: Don't use temporary variable to free path
remoteDispatchDomainMigratePrepare: Don't pass uninitialized variable
to VIR_FREE
vboxDomainScreenshot: Don't pass uninitialized 'screenData' to
VIR_FREE
Remove use of variables passed only to 'VIR_FREE'
src/libxl/libxl_migration.c | 4 +---
src/locking/sanlock_helper.c | 2 --
src/logging/log_daemon.c | 2 --
src/nwfilter/nwfilter_ebiptables_driver.c | 2 --
src/openvz/openvz_driver.c | 2 --
src/remote/remote_daemon_dispatch.c | 2 +-
src/security/security_selinux.c | 2 --
src/test/test_driver.c | 2 --
src/util/virstorageencryption.c | 4 ----
src/util/virsysinfo.c | 2 --
src/util/virtpm.c | 5 +----
src/vbox/vbox_common.c | 2 +-
src/vmware/vmware_conf.c | 4 ----
src/vmware/vmware_driver.c | 4 ----
tests/cputest.c | 4 +---
tests/networkxml2firewalltest.c | 2 --
tests/scsihosttest.c | 4 ----
tests/xmconfigtest.c | 2 --
tools/virsh-checkpoint.c | 2 --
19 files changed, 5 insertions(+), 48 deletions(-)
--
2.26.2
2
16
Changes from [v2]:
* use $CI_COMMIT_REF_SLUG instead of 'master' as tag name, so that
it's possible to test changes to the Dockerfiles that affect the
subsequent build jobs in a feature branch;
* add CentOS Stream;
* rename 'preliminary_checks' stage to 'sanity_checks'.
Changes from [v1]:
* only build containers necessary for extra jobs when said jobs
are actually going to run;
* rename container build jobs to '$arch-$os-container';
* rename 'other' stage to 'preliminary_checks' and move it before
native builds;
* simplify build system integration.
[v1] https://www.redhat.com/archives/libvir-list/2020-May/msg01183.html
[v2] https://www.redhat.com/archives/libvir-list/2020-June/msg00067.html
Andrea Bolognani (4):
ci: Use variables to build image names
ci: Add 'sanity_checks' stage
ci: Use GitLab container registry
ci: Update build system integration
.gitlab-ci.yml | 333 ++++++++++++++++--
ci/Makefile | 10 +-
ci/containers/README.rst | 14 +
ci/containers/ci-centos-7.Dockerfile | 137 +++++++
ci/containers/ci-centos-8.Dockerfile | 108 ++++++
ci/containers/ci-centos-stream.Dockerfile | 109 ++++++
.../ci-debian-10-cross-aarch64.Dockerfile | 122 +++++++
.../ci-debian-10-cross-armv6l.Dockerfile | 120 +++++++
.../ci-debian-10-cross-armv7l.Dockerfile | 121 +++++++
.../ci-debian-10-cross-i686.Dockerfile | 121 +++++++
.../ci-debian-10-cross-mips.Dockerfile | 121 +++++++
.../ci-debian-10-cross-mips64el.Dockerfile | 121 +++++++
.../ci-debian-10-cross-mipsel.Dockerfile | 121 +++++++
.../ci-debian-10-cross-ppc64le.Dockerfile | 121 +++++++
.../ci-debian-10-cross-s390x.Dockerfile | 121 +++++++
ci/containers/ci-debian-10.Dockerfile | 112 ++++++
.../ci-debian-9-cross-aarch64.Dockerfile | 126 +++++++
.../ci-debian-9-cross-armv6l.Dockerfile | 124 +++++++
.../ci-debian-9-cross-armv7l.Dockerfile | 125 +++++++
.../ci-debian-9-cross-mips.Dockerfile | 125 +++++++
.../ci-debian-9-cross-mips64el.Dockerfile | 125 +++++++
.../ci-debian-9-cross-mipsel.Dockerfile | 125 +++++++
.../ci-debian-9-cross-ppc64le.Dockerfile | 125 +++++++
.../ci-debian-9-cross-s390x.Dockerfile | 125 +++++++
ci/containers/ci-debian-9.Dockerfile | 116 ++++++
.../ci-debian-sid-cross-aarch64.Dockerfile | 122 +++++++
.../ci-debian-sid-cross-armv6l.Dockerfile | 120 +++++++
.../ci-debian-sid-cross-armv7l.Dockerfile | 121 +++++++
.../ci-debian-sid-cross-i686.Dockerfile | 121 +++++++
.../ci-debian-sid-cross-mips.Dockerfile | 121 +++++++
.../ci-debian-sid-cross-mips64el.Dockerfile | 121 +++++++
.../ci-debian-sid-cross-mipsel.Dockerfile | 120 +++++++
.../ci-debian-sid-cross-ppc64le.Dockerfile | 121 +++++++
.../ci-debian-sid-cross-s390x.Dockerfile | 121 +++++++
ci/containers/ci-debian-sid.Dockerfile | 112 ++++++
ci/containers/ci-fedora-31.Dockerfile | 109 ++++++
ci/containers/ci-fedora-32.Dockerfile | 109 ++++++
...ci-fedora-rawhide-cross-mingw32.Dockerfile | 130 +++++++
...ci-fedora-rawhide-cross-mingw64.Dockerfile | 130 +++++++
ci/containers/ci-fedora-rawhide.Dockerfile | 110 ++++++
ci/containers/ci-opensuse-151.Dockerfile | 109 ++++++
ci/containers/ci-ubuntu-1804.Dockerfile | 117 ++++++
ci/containers/ci-ubuntu-2004.Dockerfile | 113 ++++++
ci/containers/refresh | 43 +++
ci/list-images.sh | 24 +-
45 files changed, 5173 insertions(+), 49 deletions(-)
create mode 100644 ci/containers/README.rst
create mode 100644 ci/containers/ci-centos-7.Dockerfile
create mode 100644 ci/containers/ci-centos-8.Dockerfile
create mode 100644 ci/containers/ci-centos-stream.Dockerfile
create mode 100644 ci/containers/ci-debian-10-cross-aarch64.Dockerfile
create mode 100644 ci/containers/ci-debian-10-cross-armv6l.Dockerfile
create mode 100644 ci/containers/ci-debian-10-cross-armv7l.Dockerfile
create mode 100644 ci/containers/ci-debian-10-cross-i686.Dockerfile
create mode 100644 ci/containers/ci-debian-10-cross-mips.Dockerfile
create mode 100644 ci/containers/ci-debian-10-cross-mips64el.Dockerfile
create mode 100644 ci/containers/ci-debian-10-cross-mipsel.Dockerfile
create mode 100644 ci/containers/ci-debian-10-cross-ppc64le.Dockerfile
create mode 100644 ci/containers/ci-debian-10-cross-s390x.Dockerfile
create mode 100644 ci/containers/ci-debian-10.Dockerfile
create mode 100644 ci/containers/ci-debian-9-cross-aarch64.Dockerfile
create mode 100644 ci/containers/ci-debian-9-cross-armv6l.Dockerfile
create mode 100644 ci/containers/ci-debian-9-cross-armv7l.Dockerfile
create mode 100644 ci/containers/ci-debian-9-cross-mips.Dockerfile
create mode 100644 ci/containers/ci-debian-9-cross-mips64el.Dockerfile
create mode 100644 ci/containers/ci-debian-9-cross-mipsel.Dockerfile
create mode 100644 ci/containers/ci-debian-9-cross-ppc64le.Dockerfile
create mode 100644 ci/containers/ci-debian-9-cross-s390x.Dockerfile
create mode 100644 ci/containers/ci-debian-9.Dockerfile
create mode 100644 ci/containers/ci-debian-sid-cross-aarch64.Dockerfile
create mode 100644 ci/containers/ci-debian-sid-cross-armv6l.Dockerfile
create mode 100644 ci/containers/ci-debian-sid-cross-armv7l.Dockerfile
create mode 100644 ci/containers/ci-debian-sid-cross-i686.Dockerfile
create mode 100644 ci/containers/ci-debian-sid-cross-mips.Dockerfile
create mode 100644 ci/containers/ci-debian-sid-cross-mips64el.Dockerfile
create mode 100644 ci/containers/ci-debian-sid-cross-mipsel.Dockerfile
create mode 100644 ci/containers/ci-debian-sid-cross-ppc64le.Dockerfile
create mode 100644 ci/containers/ci-debian-sid-cross-s390x.Dockerfile
create mode 100644 ci/containers/ci-debian-sid.Dockerfile
create mode 100644 ci/containers/ci-fedora-31.Dockerfile
create mode 100644 ci/containers/ci-fedora-32.Dockerfile
create mode 100644 ci/containers/ci-fedora-rawhide-cross-mingw32.Dockerfile
create mode 100644 ci/containers/ci-fedora-rawhide-cross-mingw64.Dockerfile
create mode 100644 ci/containers/ci-fedora-rawhide.Dockerfile
create mode 100644 ci/containers/ci-opensuse-151.Dockerfile
create mode 100644 ci/containers/ci-ubuntu-1804.Dockerfile
create mode 100644 ci/containers/ci-ubuntu-2004.Dockerfile
create mode 100755 ci/containers/refresh
--
2.25.4
2
8
11 Jun '20
This needs to be set for every repository for Cirrus CI integration
to work.
Signed-off-by: Andrea Bolognani <abologna(a)redhat.com>
---
docs/newreposetup.rst | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/docs/newreposetup.rst b/docs/newreposetup.rst
index f81e26747b..ac2e6a15f1 100644
--- a/docs/newreposetup.rst
+++ b/docs/newreposetup.rst
@@ -83,6 +83,22 @@ required under the **Settings** page:
* *Shared runners*: Enable shared runners
+ * **Variables**
+
+ * *Key*: ``CIRRUS_GITHUB_REPO``
+
+ * *Value*: ``libvirt/$repo``
+
+ * *Protect variable*: enabled
+
+ * *Mask variable*: disabled
+
+ * *Key*: ``CIRRUS_API_TOKEN``
+
+ * No need to set this at the project level: it's already set for the
+ libvirt organization and will be inherited from there.
+
+
GitHub configuration
====================
--
2.25.4
2
1
Signed-off-by: Yi Li <yili(a)winhong.com>
---
src/conf/snapshot_conf.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/src/conf/snapshot_conf.c b/src/conf/snapshot_conf.c
index 857d04c476..f73eeb06c7 100644
--- a/src/conf/snapshot_conf.c
+++ b/src/conf/snapshot_conf.c
@@ -231,7 +231,7 @@ virDomainSnapshotDefParse(xmlXPathContextPtr ctxt,
xmlNodePtr inactiveDomNode = NULL;
size_t i;
int n;
- char *creation = NULL, *state = NULL;
+ char *state = NULL;
int active;
char *tmp;
char *memorySnapshot = NULL;
@@ -404,7 +404,6 @@ virDomainSnapshotDefParse(xmlXPathContextPtr ctxt,
ret = g_steal_pointer(&def);
cleanup:
- VIR_FREE(creation);
VIR_FREE(state);
VIR_FREE(nodes);
VIR_FREE(memorySnapshot);
--
2.25.3
2
1
Right now we're dividing the jobs into three stages: prebuild, which
includes DCO checking as well as building artifacts such as the
website, and native_build/cross_build, which do exactly what you'd
expect based on their names.
This organization is nice from the logical point of view, but results
in poor utilization of the available CI resources: in particular, the
fact that cross_build jobs can only start after all native_build jobs
have finished means that if even a single one of the latter takes a
bit longer the pipeline will stall, and with native builds taking
anywhere from less than 10 minutes to more than 20, this happens all
the time.
Building artifacts in a separate pipeline stage also doesn't have any
advantages, and only delays further stages by a couple of minutes.
The only job that really makes sense in its own stage is the DCO
check, because it's extremely fast (less than 1 minute) and, if that
fails, we can avoid kicking off all other jobs.
Reducing the number of stages results in significant speedups:
specifically, going from three stages to two stages reduces the
overall completion time for a full CI pipeline from ~45 minutes[1]
to ~30 minutes[2].
[1] https://gitlab.com/abologna/libvirt/-/pipelines/154751893
[2] https://gitlab.com/abologna/libvirt/-/pipelines/154771173
Signed-off-by: Andrea Bolognani <abologna(a)redhat.com>
---
.gitlab-ci.yml | 19 +++++++++----------
1 file changed, 9 insertions(+), 10 deletions(-)
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 7a8142b506..8d9313e415 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -2,9 +2,8 @@ variables:
GIT_DEPTH: 100
stages:
- - prebuild
- - native_build
- - cross_build
+ - sanity_checks
+ - builds
.script_variables: &script_variables |
export MAKEFLAGS="-j$(getconf _NPROCESSORS_ONLN)"
@@ -17,7 +16,7 @@ stages:
# Default native build jobs that are always run
.native_build_default_job_template: &native_build_default_job_definition
- stage: native_build
+ stage: builds
cache:
paths:
- ccache/
@@ -42,7 +41,7 @@ stages:
# system other than Linux. These jobs will only run if the required
# setup has been performed on the GitLab account (see ci/README.rst).
.cirrus_build_default_job_template: &cirrus_build_default_job_definition
- stage: native_build
+ stage: builds
image: registry.gitlab.com/libvirt/libvirt-ci/cirrus-run:master
script:
- cirrus-run ci/cirrus/$NAME.yml.j2
@@ -64,7 +63,7 @@ stages:
# Default cross build jobs that are always run
.cross_build_default_job_template: &cross_build_default_job_definition
- stage: cross_build
+ stage: builds
cache:
paths:
- ccache/
@@ -194,7 +193,7 @@ mingw64-fedora-rawhide:
# be deployed to the web root:
# https://gitlab.com/libvirt/libvirt/-/jobs/artifacts/master/download?job=web…
website:
- stage: prebuild
+ stage: builds
before_script:
- *script_variables
script:
@@ -216,7 +215,7 @@ website:
codestyle:
- stage: prebuild
+ stage: builds
before_script:
- *script_variables
script:
@@ -231,7 +230,7 @@ codestyle:
# for translation usage:
# https://gitlab.com/libvirt/libvirt/-/jobs/artifacts/master/download?job=pot…
potfile:
- stage: prebuild
+ stage: builds
only:
- master
before_script:
@@ -259,7 +258,7 @@ potfile:
# this test on developer's personal forks from which
# merge requests are submitted
check-dco:
- stage: prebuild
+ stage: sanity_checks
image: registry.gitlab.com/libvirt/libvirt-ci/check-dco:master
script:
- /check-dco
--
2.25.4
4
8
10 Jun '20
This needs to be set for every repository for Cirrus CI integration
to work.
Signed-off-by: Andrea Bolognani <abologna(a)redhat.com>
---
docs/newreposetup.rst | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/docs/newreposetup.rst b/docs/newreposetup.rst
index f81e26747b..dd86535c9a 100644
--- a/docs/newreposetup.rst
+++ b/docs/newreposetup.rst
@@ -83,6 +83,17 @@ required under the **Settings** page:
* *Shared runners*: Enable shared runners
+ * **Variables**
+
+ * *Key*: ``CIRRUS_GITHUB_REPO``
+
+ * *Value*: ``libvirt/$repo``
+
+ * *Protect variable*: enabled
+
+ * *Mask variable*: disabled
+
+
GitHub configuration
====================
--
2.25.4
2
1
Multiple video elements lead to erratic mouse behavior through spice
by Christian Ehrhardt 10 Jun '20
by Christian Ehrhardt 10 Jun '20
10 Jun '20
Hi,
with a guest set up as in the following example mouse behavior breaks:
<graphics type='spice' port='5901' autoport='no' listen='0.0.0.0'>
<listen type='address' address='0.0.0.0'/>
<gl enable='no'/>
</graphics>
<video>
<model type='qxl' ram='65536' vram='16384' vgamem='16384' heads='1'
primary='yes'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x01'
function='0x0'/>
</video>
<video>
<model type='qxl' ram='65536' vram='16384' vgamem='16384' heads='1'/>
<address type='pci' domain='0x0000' bus='0x08' slot='0x01'
function='0x0'/>
</video>
Please note that this is for illustration purposes as this everyone can
easily retry.
I originally had QXL + GPU as mediated device, where the behavior is the
same.
If I know connect to that via spice, spice is smart and opens both displays:
$ virt-viewer --connect qemu+ssh://ubuntu@10.246.115.255/system guestname
But while with one display mouse integration (to move in/out smoothly) and
positioning of the mouse pointer is fine.
It is broken with this double display setup.
What I see is:
- no mouse integration anymore (falls back to capture the mouse)
- often the mouse can not move upwards anymore
- sometimes "left" also doesn't work
Let me know if someone wants a video in case the description is still too
odd.
I have tried spice-client-gtk and virt-viewer, but both behave the same way.
If I take away one of the displays it works well again.
So I'm wondering how virtual-multi-monitor is supposed to work, are there
known bugs or tweaks that would apply here?
In my original case I wanted to take away the QXL device, to jst keep the
Mdev as one screen (and the one I really want).
But due to [1] the video section is re-added automatically.
Maybe this comes down to not re-adding that default video entry if a
hostdev has display=on set?
I'd appreciate any pointers if this rings a bell or a discussion on
not-auto-adding-video if display=on is present.
Kind Regards,
Christian
P.S. I tried VNC but that just has "other" issues. It only shows 1 of 2
displays and on the one I see over amplifies the mouse movement by the
amount the other display adds to ther overall desktop size.
P.P.S. Sorry for cross posting, at least I avoided cross posting even
further (spice-devel / qemu-devel) hoping that libvirt & virt-tools would
be involved enough that if someone recognizes this he can point me to the
right place.
[1]: https://bugzilla.redhat.com/show_bug.cgi?id=707439
4
3