diff --git a/src/conf/network_conf.c b/src/conf/network_conf.c index 8803143d985907b75a143772f77cc654298b2305..e59938cb561e0336e5f69320fcf9683f107911bb 100644 --- a/src/conf/network_conf.c +++ b/src/conf/network_conf.c @@ -1,7 +1,7 @@ /* * network_conf.c: network XML handling * - * Copyright (C) 2006-2013 Red Hat, Inc. + * Copyright (C) 2006-2014 Red Hat, Inc. * Copyright (C) 2006-2008 Daniel P. Berrange * * This library is free software; you can redistribute it and/or @@ -66,6 +66,12 @@ VIR_ENUM_IMPL(virNetworkForwardDriverName, "kvm", "vfio") +VIR_ENUM_IMPL(virNetworkDNSForwardPlainNames, + VIR_NETWORK_DNS_FORWARD_PLAIN_NAMES_LAST, + "default", + "yes", + "no") + virNetworkObjPtr virNetworkFindByUUID(virNetworkObjListPtr nets, const unsigned char *uuid) { @@ -1053,9 +1059,9 @@ virNetworkDNSDefParseXML(const char *networkName, forwardPlainNames = virXPathString("string(./@forwardPlainNames)", ctxt); if (forwardPlainNames) { - if (STREQ(forwardPlainNames, "yes")) { - def->forwardPlainNames = true; - } else if (STRNEQ(forwardPlainNames, "no")) { + def->forwardPlainNames + = virNetworkDNSForwardPlainNamesTypeFromString(forwardPlainNames); + if (def->forwardPlainNames <= 0) { virReportError(VIR_ERR_XML_ERROR, _("Invalid dns forwardPlainNames setting '%s' " "in network '%s'"), @@ -2295,19 +2301,26 @@ static int virNetworkDNSDefFormat(virBufferPtr buf, const virNetworkDNSDef *def) { - int result = 0; size_t i, j; if (!(def->forwardPlainNames || def->forwarders || def->nhosts || def->nsrvs || def->ntxts)) - goto out; + return 0; virBufferAddLit(buf, "forwardPlainNames) { - virBufferAddLit(buf, " forwardPlainNames='yes'"); + const char *fwd = virNetworkDNSForwardPlainNamesTypeToString(def->forwardPlainNames); + + if (!fwd) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Unknown forwardPlainNames type %d in network"), + def->forwardPlainNames); + return -1; + } + virBufferAsprintf(buf, " forwardPlainNames='%s'", fwd); if (!(def->forwarders || def->nhosts || def->nsrvs || def->ntxts)) { virBufferAddLit(buf, "/>\n"); - goto out; + return 0; } } @@ -2363,8 +2376,7 @@ virNetworkDNSDefFormat(virBufferPtr buf, } virBufferAdjustIndent(buf, -2); virBufferAddLit(buf, "\n"); -out: - return result; + return 0; } static int diff --git a/src/conf/network_conf.h b/src/conf/network_conf.h index e3ef2851d22a1438f2d6c6aa670fb7ea783fff49..b84762a765ed68639a4753ef32e2e6bc517b6ff1 100644 --- a/src/conf/network_conf.h +++ b/src/conf/network_conf.h @@ -1,7 +1,7 @@ /* * network_conf.h: network XML handling * - * Copyright (C) 2006-2013 Red Hat, Inc. + * Copyright (C) 2006-2014 Red Hat, Inc. * Copyright (C) 2006-2008 Daniel P. Berrange * * This library is free software; you can redistribute it and/or @@ -112,10 +112,23 @@ struct _virNetworkDNSHostDef { char **names; }; +/* If forwardPlainNames is 0 (default), that is equivalent to "yes", + * but won't be encoded in newly formatted XML. + */ +typedef enum { + VIR_NETWORK_DNS_FORWARD_PLAIN_NAMES_DEFAULT = 0, /* silent "yes" */ + VIR_NETWORK_DNS_FORWARD_PLAIN_NAMES_YES, + VIR_NETWORK_DNS_FORWARD_PLAIN_NAMES_NO, + + VIR_NETWORK_DNS_FORWARD_PLAIN_NAMES_LAST, +} virNetworkDNSForwardPlainNamesType; + +VIR_ENUM_DECL(virNetworkDNSForwardPlainNames) + typedef struct _virNetworkDNSDef virNetworkDNSDef; typedef virNetworkDNSDef *virNetworkDNSDefPtr; struct _virNetworkDNSDef { - bool forwardPlainNames; + int forwardPlainNames; /* enum virNetworkDNSForwardPlainNamesType */ size_t ntxts; virNetworkDNSTxtDefPtr txts; size_t nhosts; diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c index 43f2ae274ee57928ea19a57ae62715fd741556be..c8b167bd293414342482046a5489b0332207f8f5 100644 --- a/src/network/bridge_driver.c +++ b/src/network/bridge_driver.c @@ -725,7 +725,8 @@ networkDnsmasqConfContents(virNetworkObjPtr network, network->def->domain); } - if (!network->def->dns.forwardPlainNames) { + if (network->def->dns.forwardPlainNames + == VIR_NETWORK_DNS_FORWARD_PLAIN_NAMES_NO) { virBufferAddLit(&configbuf, "domain-needed\n"); /* need to specify local=// whether or not a domain is * specified, unless the config says we should forward "plain" diff --git a/tests/networkxml2confdata/dhcp6-nat-network.conf b/tests/networkxml2confdata/dhcp6-nat-network.conf index 050f3dbecc396153aef9d53471b0bae5efcb7b6d..f270a4372d6bfeff5daecdd29a337a2c5457e520 100644 --- a/tests/networkxml2confdata/dhcp6-nat-network.conf +++ b/tests/networkxml2confdata/dhcp6-nat-network.conf @@ -5,8 +5,6 @@ ## ## dnsmasq conf file created by libvirt strict-order -domain-needed -local=// except-interface=lo bind-dynamic interface=virbr0 diff --git a/tests/networkxml2confdata/dhcp6-network.conf b/tests/networkxml2confdata/dhcp6-network.conf index 92ea2a4caa53c07c6a865ef490a2da400a4f1724..f0a96609752a1b510dd8a4cb6f2dd36d72283472 100644 --- a/tests/networkxml2confdata/dhcp6-network.conf +++ b/tests/networkxml2confdata/dhcp6-network.conf @@ -7,8 +7,6 @@ strict-order domain=mynet expand-hosts -domain-needed -local=// except-interface=lo bind-dynamic interface=virbr0 diff --git a/tests/networkxml2confdata/dhcp6host-routed-network.conf b/tests/networkxml2confdata/dhcp6host-routed-network.conf index f8f05c24c356fedb279a133d881413235e34ba13..ad6db36dfcf1ae237c58f88992f4ccc0e32bac78 100644 --- a/tests/networkxml2confdata/dhcp6host-routed-network.conf +++ b/tests/networkxml2confdata/dhcp6host-routed-network.conf @@ -5,8 +5,6 @@ ## ## dnsmasq conf file created by libvirt strict-order -domain-needed -local=// except-interface=lo bind-dynamic interface=virbr1 diff --git a/tests/networkxml2confdata/isolated-network.conf b/tests/networkxml2confdata/isolated-network.conf index f8997bda58a8d7348c57f78648391755807f56df..6ba34ae56e36430f8716ebf1069a7fbc648ecd3b 100644 --- a/tests/networkxml2confdata/isolated-network.conf +++ b/tests/networkxml2confdata/isolated-network.conf @@ -5,8 +5,6 @@ ## ## dnsmasq conf file created by libvirt strict-order -domain-needed -local=// except-interface=lo bind-interfaces listen-address=192.168.152.1 diff --git a/tests/networkxml2confdata/nat-network-dns-forwarders.conf b/tests/networkxml2confdata/nat-network-dns-forwarders.conf index 5f95f77b02fa78bfb232f38fc89d20ab62c09189..8bf3b9c360080e2ea323270bef6f0e60d80f0f1b 100644 --- a/tests/networkxml2confdata/nat-network-dns-forwarders.conf +++ b/tests/networkxml2confdata/nat-network-dns-forwarders.conf @@ -8,8 +8,6 @@ strict-order no-resolv server=8.8.8.8 server=8.8.4.4 -domain-needed -local=// except-interface=lo bind-dynamic interface=virbr0 diff --git a/tests/networkxml2confdata/nat-network-dns-srv-record-minimal.conf b/tests/networkxml2confdata/nat-network-dns-srv-record-minimal.conf index 1e9b59c512e6863ab8d2b99aea22eaef058b373b..ce4dd6f5c49adf71007c4e95cdfcdd1315d46191 100644 --- a/tests/networkxml2confdata/nat-network-dns-srv-record-minimal.conf +++ b/tests/networkxml2confdata/nat-network-dns-srv-record-minimal.conf @@ -5,8 +5,6 @@ ## ## dnsmasq conf file created by libvirt strict-order -domain-needed -local=// except-interface=lo bind-interfaces listen-address=192.168.122.1 diff --git a/tests/networkxml2confdata/nat-network-dns-srv-record.conf b/tests/networkxml2confdata/nat-network-dns-srv-record.conf index 53d044a40c8a1e9546f500620eef5a66d0400643..b47cbe7d32c1298a9a4770c843497463e16099fe 100644 --- a/tests/networkxml2confdata/nat-network-dns-srv-record.conf +++ b/tests/networkxml2confdata/nat-network-dns-srv-record.conf @@ -5,8 +5,6 @@ ## ## dnsmasq conf file created by libvirt strict-order -domain-needed -local=// except-interface=lo bind-dynamic interface=virbr0 diff --git a/tests/networkxml2confdata/nat-network-dns-txt-record.conf b/tests/networkxml2confdata/nat-network-dns-txt-record.conf index 921cae1607154682abc2d60f1d8e2abbb2a44d91..ff53f4e4f73d6738157e4ba54532a58e0a2b7c89 100644 --- a/tests/networkxml2confdata/nat-network-dns-txt-record.conf +++ b/tests/networkxml2confdata/nat-network-dns-txt-record.conf @@ -5,8 +5,6 @@ ## ## dnsmasq conf file created by libvirt strict-order -domain-needed -local=// except-interface=lo bind-dynamic interface=virbr0 diff --git a/tests/networkxml2confdata/nat-network.conf b/tests/networkxml2confdata/nat-network.conf index beb714b134c3401281ad76e3713cf51537308406..ced4123a96fc8fc8a634c296e81a5e239232aae0 100644 --- a/tests/networkxml2confdata/nat-network.conf +++ b/tests/networkxml2confdata/nat-network.conf @@ -5,8 +5,6 @@ ## ## dnsmasq conf file created by libvirt strict-order -domain-needed -local=// except-interface=lo bind-dynamic interface=virbr0 diff --git a/tests/networkxml2confdata/netboot-network.conf b/tests/networkxml2confdata/netboot-network.conf index ce33176e15bfcfc85b00a931b6dfdacbe033bb2a..8ea1f67de9e770f67717281300221fe364d25dea 100644 --- a/tests/networkxml2confdata/netboot-network.conf +++ b/tests/networkxml2confdata/netboot-network.conf @@ -7,8 +7,6 @@ strict-order domain=example.com expand-hosts -domain-needed -local=// except-interface=lo bind-interfaces listen-address=192.168.122.1 diff --git a/tests/networkxml2confdata/netboot-proxy-network.conf b/tests/networkxml2confdata/netboot-proxy-network.conf index f4d3880210d9178fc3f75c948bd7d464e731af31..4774a92dd6a9733862c4b41be3ca7d34daf146cc 100644 --- a/tests/networkxml2confdata/netboot-proxy-network.conf +++ b/tests/networkxml2confdata/netboot-proxy-network.conf @@ -7,8 +7,6 @@ strict-order domain=example.com expand-hosts -domain-needed -local=// except-interface=lo bind-interfaces listen-address=192.168.122.1 diff --git a/tests/networkxml2confdata/routed-network.conf b/tests/networkxml2confdata/routed-network.conf index 62ffd7a29a9d985300c5ae25c392321b2c1a8413..970aa3cd35008cd469dfc397601ae1985bcfd899 100644 --- a/tests/networkxml2confdata/routed-network.conf +++ b/tests/networkxml2confdata/routed-network.conf @@ -5,8 +5,6 @@ ## ## dnsmasq conf file created by libvirt strict-order -domain-needed -local=// except-interface=lo bind-dynamic interface=virbr1 diff --git a/tests/networkxml2xmlout/nat-network-dns-hosts.xml b/tests/networkxml2xmlout/nat-network-dns-hosts.xml index a2f46da8c15144d8dacf63f19dc8b325d81a6325..17e269710b54b4a19b02539d06fe3165c703a738 100644 --- a/tests/networkxml2xmlout/nat-network-dns-hosts.xml +++ b/tests/networkxml2xmlout/nat-network-dns-hosts.xml @@ -5,7 +5,7 @@ - + host gateway diff --git a/tests/networkxml2xmlupdateout/nat-network-dns-more-hosts.xml b/tests/networkxml2xmlupdateout/nat-network-dns-more-hosts.xml index 6554c07f323751f9250e4577414fc3a1183bab56..5464d90ab95b29743f5278a4f703816d927605ad 100644 --- a/tests/networkxml2xmlupdateout/nat-network-dns-more-hosts.xml +++ b/tests/networkxml2xmlupdateout/nat-network-dns-more-hosts.xml @@ -5,7 +5,7 @@ - + pudding diff --git a/tests/networkxml2xmlupdateout/nat-network-no-hosts.xml b/tests/networkxml2xmlupdateout/nat-network-no-hosts.xml index bc9e4193fbf1e7914d208ba5d4d36f1cc03a106b..ee2d7737296b84b419b5d49193cfecd1047c70ea 100644 --- a/tests/networkxml2xmlupdateout/nat-network-no-hosts.xml +++ b/tests/networkxml2xmlupdateout/nat-network-no-hosts.xml @@ -5,6 +5,7 @@ +