[libvirt] [PATCHv2] network: fix problems with SRV records
by Laine Stump
A patch submitted by Steven Malin last week pointed out a problem with
libvirt's DNS SRV record configuration:
https://www.redhat.com/archives/libvir-list/2014-March/msg00536.html
When searching for that message later, I found another series that had
been posted by Guannan Ren back in 2012 that somehow slipped between
the cracks:
https://www.redhat.com/archives/libvir-list/2012-July/msg00236.html
That patch was very much out of date, but also pointed out some real
problems.
This patch fixes all the noted problems by refactoring
virNetworkDNSSrvDefParseXML() and networkDnsmasqConfContents(), then
verifies those fixes by added several new records to the test case.
Problems fixed:
* both service and protocol now have an underscore ("_") prepended on
the commandline, as required by RFC2782.
<srv service='sip' protocol='udp' domain='example.com'
target='tests.example.com' port='5060' priority='10'
weight='150'/>
before: srv-host=sip.udp.example.com,tests.example.com,5060,10,150
after: srv-host=_sip._udp.example.com,tests.example.com,5060,10,150
* if "domain" wasn't specified in the <srv> element, the extra
trailing "." will no longer be added to the dnsmasq commandline.
<srv service='sip' protocol='udp' target='tests.example.com'
port='5060' priority='10' weight='150'/>
before: srv-host=sip.udp.,tests.example.com,5060,10,150
after: srv-host=_sip._udp,tests.example.com,5060,10,150
* when optional attributes aren't specified, the separating comma is
also now not placed on the dnsmasq commandline. If optional
attributes in the middle of the line are not specified, they are
replaced with a default value in the commandline (1 for port, 0 for
priority and weight).
<srv service='sip' protocol='udp' target='tests.example.com'
port='5060'/>
before: srv-host=sip.udp.,tests.example.com,5060,,
after: srv-host=_sip._udp,tests.example.com,5060
(actually the would have generated an error, because "optional"
attributes weren't really optional.)
* The allowed characters for both service and protocol are now limited
to alphanumerics, plus a few special characters that are found in
existing names in /etc/services and /etc/protocols. (One exception
is that both of these files contain names with an embedded ".", but
"." can't be used in these fields of an SRV record because it is
used as a field separator and there is no method to escape a "."
into a field.) (Previously only the strings "tcp" and "udp" were
allowed for protocol, but this restriction has been removed, since
RFC2782 specifically says that it isn't limited to those, and that
anyway it is case insensitive.)
* the "domain" attribute is no longer required in order to recognize
the port, priority, and weight attributes during parsing. Only
"target" is required for this.
* if "target" isn't specified, port, priority, and weight are not
allowed (since they are meaningless - an empty target means "this
service is *not available* for this domain").
* port, priority, and weight are now truly optional, as the comments
originally suggested, but which was not actually true.
---
Changes from V1:
https://www.redhat.com/archives/libvir-list/2014-March/msg01172.html
src/conf/network_conf.c | 129 ++++++++++++++-------
src/network/bridge_driver.c | 80 ++++++++-----
.../nat-network-dns-srv-record-minimal.conf | 2 +-
.../nat-network-dns-srv-record.conf | 8 +-
.../nat-network-dns-srv-record.xml | 8 +-
5 files changed, 149 insertions(+), 78 deletions(-)
diff --git a/src/conf/network_conf.c b/src/conf/network_conf.c
index 9be06d3..f1e6243 100644
--- a/src/conf/network_conf.c
+++ b/src/conf/network_conf.c
@@ -924,6 +924,21 @@ error:
return -1;
}
+/* This includes all characters used in the names of current
+ * /etc/services and /etc/protocols files (on Fedora 20), except ".",
+ * which we can't allow because it would conflict with the use of "."
+ * as a field separator in the SRV record, there appears to be no way
+ * to escape it in, and the protocols/services that use "." in the
+ * name are obscure and unlikely to be used anyway.
+ */
+#define PROTOCOL_CHARS \
+ "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789" \
+ "-+/"
+
+#define SERVICE_CHARS \
+ "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789" \
+ "_-+/*"
+
static int
virNetworkDNSSrvDefParseXML(const char *networkName,
xmlNodePtr node,
@@ -931,80 +946,108 @@ virNetworkDNSSrvDefParseXML(const char *networkName,
virNetworkDNSSrvDefPtr def,
bool partialOkay)
{
+ int ret;
+ xmlNodePtr save_ctxt = ctxt->node;
+
+ ctxt->node = node;
+
if (!(def->service = virXMLPropString(node, "service")) && !partialOkay) {
virReportError(VIR_ERR_XML_DETAIL,
_("Missing required service attribute in DNS SRV record "
"of network %s"), networkName);
goto error;
}
- if (def->service && strlen(def->service) > DNS_RECORD_LENGTH_SRV) {
- virReportError(VIR_ERR_XML_DETAIL,
- _("Service name '%s' in network %s is too long, limit is %d bytes"),
- def->service, networkName, DNS_RECORD_LENGTH_SRV);
- goto error;
+ if (def->service) {
+ if (strlen(def->service) > DNS_RECORD_LENGTH_SRV) {
+ virReportError(VIR_ERR_XML_DETAIL,
+ _("service attribute '%s' in network %s is too long, "
+ "limit is %d bytes"),
+ def->service, networkName, DNS_RECORD_LENGTH_SRV);
+ goto error;
+ }
+ if (strspn(def->service, SERVICE_CHARS) < strlen(def->service)) {
+ virReportError(VIR_ERR_XML_DETAIL,
+ _("invalid character in service attribute '%s' "
+ "in network %s DNS SRV record"),
+ def->service, networkName);
+ goto error;
+ }
}
if (!(def->protocol = virXMLPropString(node, "protocol")) && !partialOkay) {
virReportError(VIR_ERR_XML_DETAIL,
_("Missing required protocol attribute "
- "in dns srv record '%s' of network %s"),
+ "in DNS SRV record '%s' of network %s"),
def->service, networkName);
goto error;
}
-
- /* Check whether protocol value is the supported one */
- if (def->protocol && STRNEQ(def->protocol, "tcp") &&
- (STRNEQ(def->protocol, "udp"))) {
+ if (def->protocol &&
+ strspn(def->protocol, PROTOCOL_CHARS) < strlen(def->protocol)) {
virReportError(VIR_ERR_XML_DETAIL,
- _("Invalid protocol attribute value '%s' "
- "in DNS SRV record of network %s"),
+ _("invalid character in protocol attribute '%s' "
+ "in network %s DNS SRV record"),
def->protocol, networkName);
goto error;
}
/* Following attributes are optional */
- if ((def->target = virXMLPropString(node, "target")) &&
- (def->domain = virXMLPropString(node, "domain"))) {
- xmlNodePtr save_ctxt = ctxt->node;
-
- ctxt->node = node;
- if (virXPathUInt("string(./@port)", ctxt, &def->port) < 0 ||
- def->port > 65535) {
- virReportError(VIR_ERR_XML_DETAIL,
- _("Missing or invalid port attribute "
- "in network %s"), networkName);
- goto error;
- }
-
- if (virXPathUInt("string(./@priority)", ctxt, &def->priority) < 0 ||
- def->priority > 65535) {
- virReportError(VIR_ERR_XML_DETAIL,
- _("Missing or invalid priority attribute "
- "in network %s"), networkName);
- goto error;
- }
+ def->domain = virXMLPropString(node, "domain");
+ def->target = virXMLPropString(node, "target");
- if (virXPathUInt("string(./@weight)", ctxt, &def->weight) < 0 ||
- def->weight > 65535) {
- virReportError(VIR_ERR_XML_DETAIL,
- _("Missing or invalid weight attribute "
- "in network %s"), networkName);
- goto error;
- }
+ ret = virXPathUInt("string(./@port)", ctxt, &def->port);
+ if (ret >= 0 && !def->target) {
+ virReportError(VIR_ERR_XML_DETAIL,
+ _("DNS SRV port attribute not permitted without "
+ "target for service %s in network %s"),
+ def->service, networkName);
+ goto error;
+ }
+ if (ret == -2 || (ret >= 0 && (def->port < 1 || def->port > 65535))) {
+ virReportError(VIR_ERR_XML_DETAIL,
+ _("Invalid DNS SRV port attribute "
+ "for service %s in network %s"),
+ def->service, networkName);
+ goto error;
+ }
- ctxt->node = save_ctxt;
+ ret = virXPathUInt("string(./@priority)", ctxt, &def->priority);
+ if (ret >= 0 && !def->target) {
+ virReportError(VIR_ERR_XML_DETAIL,
+ _("DNS SRV priority attribute not permitted without "
+ "target for service %s in network %s"),
+ def->service, networkName);
+ goto error;
+ }
+ if (ret == -2 || (ret >= 0 && def->priority > 65535)) {
+ virReportError(VIR_ERR_XML_DETAIL,
+ _("Invalid DNS SRV priority attribute "
+ "for service %s in network %s"),
+ def->service, networkName);
+ goto error;
}
- if (!(def->service || def->protocol)) {
+ ret = virXPathUInt("string(./@weight)", ctxt, &def->weight);
+ if (ret >= 0 && !def->target) {
virReportError(VIR_ERR_XML_DETAIL,
- _("Missing required service attribute or protocol "
- "in DNS SRV record of network %s"), networkName);
+ _("DNS SRV weight attribute not permitted without "
+ "target for service %s in network %s"),
+ def->service, networkName);
+ goto error;
+ }
+ if (ret == -2 || (ret >= 0 && def->weight > 65535)) {
+ virReportError(VIR_ERR_XML_DETAIL,
+ _("Invalid DNS SRV weight attribute "
+ "for service %s in network %s"),
+ def->service, networkName);
goto error;
}
+
+ ctxt->node = save_ctxt;
return 0;
error:
virNetworkDNSSrvDefClear(def);
+ ctxt->node = save_ctxt;
return -1;
}
diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c
index 59b6c09..e256dba 100644
--- a/src/network/bridge_driver.c
+++ b/src/network/bridge_driver.c
@@ -736,10 +736,6 @@ networkDnsmasqConfContents(virNetworkObjPtr network,
int r, ret = -1;
int nbleases = 0;
size_t i;
- char *record = NULL;
- char *recordPort = NULL;
- char *recordWeight = NULL;
- char *recordPriority = NULL;
virNetworkDNSDefPtr dns = &network->def->dns;
virNetworkIpDefPtr tmpipdef, ipdef, ipv4def, ipv6def;
bool ipv6SLAAC;
@@ -880,33 +876,57 @@ networkDnsmasqConfContents(virNetworkObjPtr network,
}
for (i = 0; i < dns->nsrvs; i++) {
- if (dns->srvs[i].service && dns->srvs[i].protocol) {
- if (dns->srvs[i].port &&
- virAsprintf(&recordPort, "%d", dns->srvs[i].port) < 0)
- goto cleanup;
- if (dns->srvs[i].priority &&
- virAsprintf(&recordPriority, "%d", dns->srvs[i].priority) < 0)
- goto cleanup;
- if (dns->srvs[i].weight &&
- virAsprintf(&recordWeight, "%d", dns->srvs[i].weight) < 0)
- goto cleanup;
+ /* service/protocol are required, and should have been validated
+ * by the parser.
+ */
+ if (!dns->srvs[i].service) {
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Missing required 'service' "
+ "attribute in SRV record of network '%s'"),
+ network->def->name);
+ goto cleanup;
+ }
+ if (!dns->srvs[i].protocol) {
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Missing required 'service' "
+ "attribute in SRV record of network '%s'"),
+ network->def->name);
+ goto cleanup;
+ }
+ /* RFC2782 requires that service and protocol be preceded by
+ * an underscore.
+ */
+ virBufferAsprintf(&configbuf, "srv-host=_%s._%s",
+ dns->srvs[i].service, dns->srvs[i].protocol);
- if (virAsprintf(&record, "%s.%s.%s,%s,%s,%s,%s",
- dns->srvs[i].service,
- dns->srvs[i].protocol,
- dns->srvs[i].domain ? dns->srvs[i].domain : "",
- dns->srvs[i].target ? dns->srvs[i].target : "",
- recordPort ? recordPort : "",
- recordPriority ? recordPriority : "",
- recordWeight ? recordWeight : "") < 0)
- goto cleanup;
+ /* domain is optional - it defaults to the domain of this network */
+ if (dns->srvs[i].domain)
+ virBufferAsprintf(&configbuf, ".%s", dns->srvs[i].domain);
- virBufferAsprintf(&configbuf, "srv-host=%s\n", record);
- VIR_FREE(record);
- VIR_FREE(recordPort);
- VIR_FREE(recordWeight);
- VIR_FREE(recordPriority);
+ /* If target is empty or ".", that means "the service is
+ * decidedly not available at this domain" (RFC2782). In that
+ * case, any port, priority, or weight is irrelevant.
+ */
+ if (dns->srvs[i].target && STRNEQ(dns->srvs[i].target, ".")) {
+
+ virBufferAsprintf(&configbuf, ",%s", dns->srvs[i].target);
+ /* port, priority, and weight are optional, but are
+ * identified by their position in the line. If an item is
+ * unspecified, but something later in the line *is*
+ * specified, we need to give the default value for the
+ * unspecified item. (According to the dnsmasq manpage,
+ * the default for port is 1).
+ */
+ if (dns->srvs[i].port ||
+ dns->srvs[i].priority || dns->srvs[i].weight)
+ virBufferAsprintf(&configbuf, ",%d",
+ dns->srvs[i].port ? dns->srvs[i].port : 1);
+ if (dns->srvs[i].priority || dns->srvs[i].weight)
+ virBufferAsprintf(&configbuf, ",%d", dns->srvs[i].priority);
+ if (dns->srvs[i].weight)
+ virBufferAsprintf(&configbuf, ",%d", dns->srvs[i].weight);
}
+ virBufferAddLit(&configbuf, "\n");
}
/* Find the first dhcp for both IPv4 and IPv6 */
@@ -1082,10 +1102,6 @@ networkDnsmasqConfContents(virNetworkObjPtr network,
cleanup:
virBufferFreeAndReset(&configbuf);
- VIR_FREE(record);
- VIR_FREE(recordPort);
- VIR_FREE(recordWeight);
- VIR_FREE(recordPriority);
return ret;
}
diff --git a/tests/networkxml2confdata/nat-network-dns-srv-record-minimal.conf b/tests/networkxml2confdata/nat-network-dns-srv-record-minimal.conf
index ce4dd6f..e60411b 100644
--- a/tests/networkxml2confdata/nat-network-dns-srv-record-minimal.conf
+++ b/tests/networkxml2confdata/nat-network-dns-srv-record-minimal.conf
@@ -12,7 +12,7 @@ listen-address=192.168.123.1
listen-address=fc00:db8:ac10:fe01::1
listen-address=fc00:db8:ac10:fd01::1
listen-address=10.24.10.1
-srv-host=name.tcp.,,,,
+srv-host=_name._tcp
dhcp-range=192.168.122.2,192.168.122.254
dhcp-no-override
dhcp-leasefile=/var/lib/libvirt/dnsmasq/default.leases
diff --git a/tests/networkxml2confdata/nat-network-dns-srv-record.conf b/tests/networkxml2confdata/nat-network-dns-srv-record.conf
index b47cbe7..16e7dca 100644
--- a/tests/networkxml2confdata/nat-network-dns-srv-record.conf
+++ b/tests/networkxml2confdata/nat-network-dns-srv-record.conf
@@ -8,7 +8,13 @@ strict-order
except-interface=lo
bind-dynamic
interface=virbr0
-srv-host=name.tcp.test-domain-name,.,1024,10,10
+srv-host=_name._tcp.test-domain-name.com,test.example.com,1111,11,111
+srv-host=_name2._udp,test2.example.com,2222,22,222
+srv-host=_name3._tcp.test3.com,test3.example.com,3333,33
+srv-host=_name4._tcp.test4.com,test4.example.com,4444
+srv-host=_name5._udp,test5.example.com,1,55,555
+srv-host=_name6._tcp.test6.com,test6.example.com,6666,0,666
+srv-host=_name7._tcp.test7.com,test7.example.com,1,0,777
dhcp-range=192.168.122.2,192.168.122.254
dhcp-no-override
dhcp-leasefile=/var/lib/libvirt/dnsmasq/default.leases
diff --git a/tests/networkxml2confdata/nat-network-dns-srv-record.xml b/tests/networkxml2confdata/nat-network-dns-srv-record.xml
index 3dd19e6..d01b331 100644
--- a/tests/networkxml2confdata/nat-network-dns-srv-record.xml
+++ b/tests/networkxml2confdata/nat-network-dns-srv-record.xml
@@ -6,7 +6,13 @@
</forward>
<bridge name='virbr0' stp='on' delay='0'/>
<dns>
- <srv service='name' protocol='tcp' domain='test-domain-name' target='.' port='1024' priority='10' weight='10'/>
+ <srv service='name' protocol='tcp' domain='test-domain-name.com' target='test.example.com' port='1111' priority='11' weight='111'/>
+ <srv service='name2' protocol='udp' target='test2.example.com' port='2222' priority='22' weight='222'/>
+ <srv service='name3' protocol='tcp' domain='test3.com' target='test3.example.com' port='3333' priority='33'/>
+ <srv service='name4' protocol='tcp' domain='test4.com' target='test4.example.com' port='4444'/>
+ <srv service='name5' protocol='udp' target='test5.example.com' priority='55' weight='555'/>
+ <srv service='name6' protocol='tcp' domain='test6.com' target='test6.example.com' port='6666' weight='666'/>
+ <srv service='name7' protocol='tcp' domain='test7.com' target='test7.example.com' weight='777'/>
</dns>
<ip address='192.168.122.1' netmask='255.255.255.0'>
<dhcp>
--
1.8.5.3
10 years, 8 months
[libvirt] [PATCH 00/24] Indent top-level labels by one space
by Ján Tomko
Change the existing code and introduce a syntax-check rule.
Ján Tomko (24):
Indent top-level labels by one space in daemon/
Indent top-level labels by one space in examples/
Indent top-level labels by one space in src/conf/
Indent top-level labels by one space in src/cpu/
Indent top-level labels by one space in src/esx/
Indent top-level labels by one space in src/libxl/
Indent top-level labels by one space in libvirt.c
Indent top-level labels by one space in src/locking/
Indent top-level labels by one space in src/lxc/
Indent top-level labels by one space in src/network/
Indent top-level labels by one space in src/nwfilter/
Indent top-level labels by one space in src/parallels/
Indent top-level labels by one space in src/qemu/
Indent top-level labels by one space in src/remote/
Indent top-level labels by one space in src/rpc/
Indent top-level labels by one space in src/storage/
Indent top-level labels by one space in src/test/
Indent top-level labels by one space in src/util/
Indent top-level labels by one space in src/vbox/
Indent top-level labels by one space in src/xen/
Indent top-level labels by one space in the rest of src/
Indent top-level labels by one space in tests/
Indent top-level labels by one space in tools/
Add a rule for indenting labels
HACKING | 31 +-
cfg.mk | 6 +
daemon/libvirtd-config.c | 6 +-
daemon/libvirtd.c | 14 +-
daemon/remote.c | 222 +++++-----
daemon/stream.c | 4 +-
docs/hacking.html.in | 37 +-
examples/dominfo/info1.c | 2 +-
examples/domsuspend/suspend.c | 8 +-
examples/hellolibvirt/hellolibvirt.c | 8 +-
examples/openauth/openauth.c | 10 +-
src/access/viraccessdriverpolkit.c | 4 +-
src/access/viraccessmanager.c | 2 +-
src/bhyve/bhyve_command.c | 4 +-
src/bhyve/bhyve_driver.c | 26 +-
src/bhyve/bhyve_process.c | 4 +-
src/conf/capabilities.c | 6 +-
src/conf/cpu_conf.c | 12 +-
src/conf/device_conf.c | 2 +-
src/conf/domain_audit.c | 18 +-
src/conf/domain_conf.c | 222 +++++-----
src/conf/domain_event.c | 10 +-
src/conf/interface_conf.c | 20 +-
src/conf/netdev_bandwidth_conf.c | 6 +-
src/conf/netdev_vlan_conf.c | 2 +-
src/conf/netdev_vport_profile_conf.c | 4 +-
src/conf/network_conf.c | 84 ++--
src/conf/network_event.c | 2 +-
src/conf/node_device_conf.c | 30 +-
src/conf/nwfilter_conf.c | 22 +-
src/conf/nwfilter_ipaddrmap.c | 4 +-
src/conf/nwfilter_params.c | 14 +-
src/conf/object_event.c | 6 +-
src/conf/snapshot_conf.c | 12 +-
src/conf/storage_conf.c | 38 +-
src/conf/storage_encryption_conf.c | 6 +-
src/conf/virchrdev.c | 8 +-
src/cpu/cpu.c | 8 +-
src/cpu/cpu_generic.c | 6 +-
src/cpu/cpu_map.c | 6 +-
src/cpu/cpu_powerpc.c | 20 +-
src/cpu/cpu_x86.c | 50 +--
src/datatypes.c | 20 +-
src/driver.c | 2 +-
src/esx/esx_driver.c | 110 ++---
src/esx/esx_interface_driver.c | 4 +-
src/esx/esx_network_driver.c | 12 +-
src/esx/esx_storage_backend_iscsi.c | 22 +-
src/esx/esx_storage_backend_vmfs.c | 36 +-
src/esx/esx_storage_driver.c | 2 +-
src/esx/esx_util.c | 6 +-
src/esx/esx_vi.c | 86 ++--
src/esx/esx_vi_methods.c | 2 +-
src/esx/esx_vi_types.c | 18 +-
src/fdstream.c | 16 +-
src/hyperv/hyperv_driver.c | 44 +-
src/hyperv/hyperv_util.c | 2 +-
src/hyperv/hyperv_wmi.c | 4 +-
src/interface/interface_backend_netcf.c | 28 +-
src/interface/interface_backend_udev.c | 26 +-
src/libvirt-lxc.c | 6 +-
src/libvirt-qemu.c | 10 +-
src/libvirt.c | 680 +++++++++++++++---------------
src/libxl/libxl_conf.c | 18 +-
src/libxl/libxl_domain.c | 24 +-
src/libxl/libxl_driver.c | 152 +++----
src/locking/domain_lock.c | 10 +-
src/locking/lock_daemon.c | 26 +-
src/locking/lock_daemon_config.c | 4 +-
src/locking/lock_daemon_dispatch.c | 16 +-
src/locking/lock_driver_lockd.c | 18 +-
src/locking/lock_driver_sanlock.c | 20 +-
src/locking/lock_manager.c | 2 +-
src/locking/sanlock_helper.c | 2 +-
src/lxc/lxc_cgroup.c | 16 +-
src/lxc/lxc_conf.c | 6 +-
src/lxc/lxc_container.c | 42 +-
src/lxc/lxc_controller.c | 54 +--
src/lxc/lxc_driver.c | 136 +++---
src/lxc/lxc_fuse.c | 10 +-
src/lxc/lxc_monitor.c | 4 +-
src/lxc/lxc_native.c | 20 +-
src/lxc/lxc_process.c | 28 +-
src/network/bridge_driver.c | 92 ++--
src/network/bridge_driver_linux.c | 40 +-
src/node_device/node_device_driver.c | 18 +-
src/node_device/node_device_hal.c | 4 +-
src/node_device/node_device_linux_sysfs.c | 2 +-
src/node_device/node_device_udev.c | 46 +-
src/nodeinfo.c | 36 +-
src/nwfilter/nwfilter_dhcpsnoop.c | 42 +-
src/nwfilter/nwfilter_driver.c | 22 +-
src/nwfilter/nwfilter_ebiptables_driver.c | 36 +-
src/nwfilter/nwfilter_gentech_driver.c | 12 +-
src/nwfilter/nwfilter_learnipaddr.c | 8 +-
src/openvz/openvz_conf.c | 26 +-
src/openvz/openvz_driver.c | 74 ++--
src/openvz/openvz_util.c | 2 +-
src/parallels/parallels_driver.c | 64 +--
src/parallels/parallels_network.c | 22 +-
src/parallels/parallels_storage.c | 68 +--
src/parallels/parallels_utils.c | 2 +-
src/phyp/phyp_driver.c | 94 ++---
src/qemu/qemu_agent.c | 26 +-
src/qemu/qemu_capabilities.c | 50 +--
src/qemu/qemu_cgroup.c | 26 +-
src/qemu/qemu_command.c | 162 +++----
src/qemu/qemu_conf.c | 22 +-
src/qemu/qemu_domain.c | 34 +-
src/qemu/qemu_driver.c | 464 ++++++++++----------
src/qemu/qemu_hostdev.c | 6 +-
src/qemu/qemu_hotplug.c | 70 +--
src/qemu/qemu_migration.c | 106 ++---
src/qemu/qemu_monitor.c | 28 +-
src/qemu/qemu_monitor_json.c | 122 +++---
src/qemu/qemu_monitor_text.c | 100 ++---
src/qemu/qemu_process.c | 72 ++--
src/remote/remote_driver.c | 268 ++++++------
src/rpc/virkeepalive.c | 6 +-
src/rpc/virnetclient.c | 22 +-
src/rpc/virnetclientprogram.c | 6 +-
src/rpc/virnetclientstream.c | 14 +-
src/rpc/virnetmessage.c | 18 +-
src/rpc/virnetsaslcontext.c | 28 +-
src/rpc/virnetserver.c | 30 +-
src/rpc/virnetserverclient.c | 18 +-
src/rpc/virnetserverprogram.c | 8 +-
src/rpc/virnetserverservice.c | 12 +-
src/rpc/virnetsocket.c | 36 +-
src/rpc/virnetsshsession.c | 26 +-
src/rpc/virnettlscontext.c | 28 +-
src/secret/secret_driver.c | 34 +-
src/security/security_apparmor.c | 26 +-
src/security/security_dac.c | 10 +-
src/security/security_manager.c | 2 +-
src/security/security_selinux.c | 32 +-
src/security/virt-aa-helper.c | 24 +-
src/storage/storage_backend.c | 20 +-
src/storage/storage_backend_disk.c | 6 +-
src/storage/storage_backend_fs.c | 16 +-
src/storage/storage_backend_gluster.c | 12 +-
src/storage/storage_backend_iscsi.c | 12 +-
src/storage/storage_backend_logical.c | 14 +-
src/storage/storage_backend_mpath.c | 12 +-
src/storage/storage_backend_rbd.c | 14 +-
src/storage/storage_backend_scsi.c | 28 +-
src/storage/storage_backend_sheepdog.c | 10 +-
src/storage/storage_driver.c | 74 ++--
src/test/test_driver.c | 272 ++++++------
src/uml/uml_conf.c | 4 +-
src/uml/uml_driver.c | 74 ++--
src/util/iohelper.c | 6 +-
src/util/virauth.c | 6 +-
src/util/virauthconfig.c | 6 +-
src/util/virbitmap.c | 2 +-
src/util/vircgroup.c | 62 +--
src/util/virclosecallbacks.c | 4 +-
src/util/vircommand.c | 6 +-
src/util/virconf.c | 2 +-
src/util/virdbus.c | 6 +-
src/util/virdnsmasq.c | 8 +-
src/util/virerror.c | 2 +-
src/util/vireventpoll.c | 4 +-
src/util/virfile.c | 36 +-
src/util/virhostdev.c | 38 +-
src/util/viridentity.c | 8 +-
src/util/virinitctl.c | 2 +-
src/util/viriptables.c | 4 +-
src/util/viriscsi.c | 12 +-
src/util/virjson.c | 4 +-
src/util/virkeyfile.c | 8 +-
src/util/virkmod.c | 6 +-
src/util/virlockspace.c | 20 +-
src/util/virlog.c | 12 +-
src/util/virnetdev.c | 50 +--
src/util/virnetdevbandwidth.c | 10 +-
src/util/virnetdevbridge.c | 26 +-
src/util/virnetdevmacvlan.c | 22 +-
src/util/virnetdevopenvswitch.c | 8 +-
src/util/virnetdevtap.c | 10 +-
src/util/virnetdevveth.c | 4 +-
src/util/virnetdevvportprofile.c | 16 +-
src/util/virnetlink.c | 12 +-
src/util/virnodesuspend.c | 8 +-
src/util/virnuma.c | 4 +-
src/util/virobject.c | 2 +-
src/util/virpci.c | 66 +--
src/util/virpidfile.c | 16 +-
src/util/virportallocator.c | 6 +-
src/util/virprocess.c | 16 +-
src/util/virscsi.c | 8 +-
src/util/virsexpr.c | 4 +-
src/util/virsocketaddr.c | 4 +-
src/util/virstoragefile.c | 26 +-
src/util/virstring.c | 4 +-
src/util/virsysinfo.c | 16 +-
src/util/virsystemd.c | 6 +-
src/util/virthread.c | 2 +-
src/util/virthreadpool.c | 6 +-
src/util/virtpm.c | 2 +-
src/util/virtypedparam.c | 24 +-
src/util/viruri.c | 6 +-
src/util/virusb.c | 4 +-
src/util/virutil.c | 30 +-
src/util/virxml.c | 8 +-
src/vbox/vbox_MSCOMGlue.c | 6 +-
src/vbox/vbox_XPCOMCGlue.c | 2 +-
src/vbox/vbox_tmpl.c | 106 ++---
src/vmware/vmware_conf.c | 14 +-
src/vmware/vmware_driver.c | 38 +-
src/vmx/vmx.c | 36 +-
src/xen/xen_driver.c | 112 ++---
src/xen/xen_hypervisor.c | 4 +-
src/xen/xen_inotify.c | 4 +-
src/xen/xend_internal.c | 46 +-
src/xen/xm_internal.c | 28 +-
src/xen/xs_internal.c | 12 +-
src/xenapi/xenapi_driver.c | 12 +-
src/xenapi/xenapi_utils.c | 8 +-
src/xenxs/xen_sxpr.c | 22 +-
src/xenxs/xen_xm.c | 12 +-
tests/commandhelper.c | 2 +-
tests/commandtest.c | 34 +-
tests/cputest.c | 18 +-
tests/domainconftest.c | 2 +-
tests/domainsnapshotxml2xmltest.c | 6 +-
tests/esxutilstest.c | 4 +-
tests/fchosttest.c | 8 +-
tests/fdstreamtest.c | 4 +-
tests/jsontest.c | 4 +-
tests/libvirtdconftest.c | 4 +-
tests/lxcconf2xmltest.c | 4 +-
tests/lxcxml2xmltest.c | 2 +-
tests/metadatatest.c | 4 +-
tests/networkxml2conftest.c | 2 +-
tests/networkxml2xmltest.c | 2 +-
tests/networkxml2xmlupdatetest.c | 6 +-
tests/nodeinfotest.c | 8 +-
tests/nwfilterxml2xmltest.c | 2 +-
tests/objecteventtest.c | 16 +-
tests/openvzutilstest.c | 4 +-
tests/qemuagenttest.c | 18 +-
tests/qemuargv2xmltest.c | 2 +-
tests/qemucapabilitiestest.c | 6 +-
tests/qemuhelptest.c | 2 +-
tests/qemuhotplugtest.c | 4 +-
tests/qemumonitorjsontest.c | 62 +--
tests/qemumonitortestutils.c | 24 +-
tests/qemuxml2argvtest.c | 12 +-
tests/qemuxml2xmltest.c | 2 +-
tests/qemuxmlnstest.c | 2 +-
tests/secretxml2xmltest.c | 4 +-
tests/securityselinuxlabeltest.c | 6 +-
tests/securityselinuxtest.c | 4 +-
tests/sexpr2xmltest.c | 2 +-
tests/storagebackendsheepdogtest.c | 6 +-
tests/storagepoolxml2xmltest.c | 2 +-
tests/storagevolxml2argvtest.c | 4 +-
tests/storagevolxml2xmltest.c | 2 +-
tests/sysinfotest.c | 4 +-
tests/test_conf.c | 2 +-
tests/testutils.c | 2 +-
tests/testutilslxc.c | 2 +-
tests/testutilsqemu.c | 12 +-
tests/testutilsxen.c | 2 +-
tests/virauthconfigtest.c | 2 +-
tests/virbitmaptest.c | 18 +-
tests/virbuftest.c | 4 +-
tests/vircapstest.c | 4 +-
tests/vircgroupmock.c | 4 +-
tests/vircgrouptest.c | 24 +-
tests/virdbustest.c | 12 +-
tests/virendiantest.c | 4 +-
tests/virhashtest.c | 20 +-
tests/virhostdevtest.c | 20 +-
tests/viridentitytest.c | 6 +-
tests/viriscsitest.c | 4 +-
tests/virkeycodetest.c | 4 +-
tests/virkeyfiletest.c | 2 +-
tests/virkmodtest.c | 8 +-
tests/virlockspacetest.c | 14 +-
tests/virnetdevbandwidthtest.c | 2 +-
tests/virnetmessagetest.c | 10 +-
tests/virnetsockettest.c | 14 +-
tests/virnettlscontexttest.c | 2 +-
tests/virnettlssessiontest.c | 2 +-
tests/virpcimock.c | 18 +-
tests/virpcitest.c | 22 +-
tests/virportallocatortest.c | 4 +-
tests/virscsitest.c | 6 +-
tests/virshtest.c | 2 +-
tests/virstoragetest.c | 6 +-
tests/virstringtest.c | 8 +-
tests/viruritest.c | 2 +-
tests/virusbmock.c | 2 +-
tests/virusbtest.c | 4 +-
tests/vmwarevertest.c | 2 +-
tests/vmx2xmltest.c | 8 +-
tests/xmconfigtest.c | 2 +-
tests/xml2sexprtest.c | 2 +-
tests/xml2vmxtest.c | 8 +-
tools/virsh-console.c | 4 +-
tools/virsh-domain-monitor.c | 34 +-
tools/virsh-domain.c | 196 ++++-----
tools/virsh-edit.c | 6 +-
tools/virsh-host.c | 14 +-
tools/virsh-interface.c | 8 +-
tools/virsh-network.c | 14 +-
tools/virsh-nodedev.c | 14 +-
tools/virsh-nwfilter.c | 8 +-
tools/virsh-pool.c | 14 +-
tools/virsh-secret.c | 18 +-
tools/virsh-snapshot.c | 34 +-
tools/virsh-volume.c | 24 +-
tools/virsh.c | 12 +-
tools/virt-login-shell.c | 6 +-
tools/wireshark/src/packet-libvirt.c | 2 +-
317 files changed, 4063 insertions(+), 4061 deletions(-)
--
1.8.3.2
10 years, 8 months
[libvirt] [python PATCHv2 0/2] arbitrary qemu events
by Eric Blake
Changes since v1: rebase to latest code base, address review comments
regarding a leak of dom, add prereq patch to fix bugs that I had
been copying and pasting
Eric Blake (2):
event: fix domain reference bugs
qemu: support arbitrary monitor events
generator.py | 20 +--
libvirt-override.c | 319 +++++++++++++++++++++++++++++------------------
libvirt-qemu-override.c | 223 ++++++++++++++++++++++++++++++++-
libvirt-qemu-override.py | 35 ++++++
4 files changed, 469 insertions(+), 128 deletions(-)
create mode 100644 libvirt-qemu-override.py
--
1.8.5.3
10 years, 8 months
[libvirt] [libvirt-python PATCH] generator: Add virConnectDomainQemuMonitorEventCallback to skipped_types
by Martin Kletzander
Signed-off-by: Martin Kletzander <mkletzan(a)redhat.com>
---
Notes:
pushed as a build-breaker
generator.py | 1 +
1 file changed, 1 insertion(+)
diff --git a/generator.py b/generator.py
index 0e9600f..e409921 100755
--- a/generator.py
+++ b/generator.py
@@ -273,6 +273,7 @@ skipped_types = {
'virConnectDomainEventWatchdogCallback': "No function types in python",
'virConnectDomainEventIOErrorCallback': "No function types in python",
'virConnectDomainEventGraphicsCallback': "No function types in python",
+ 'virConnectDomainQemuMonitorEventCallback': "No function types in python",
'virStreamEventCallback': "No function types in python",
'virEventHandleCallback': "No function types in python",
'virEventTimeoutCallback': "No function types in python",
--
1.9.1
10 years, 8 months
[libvirt] [PATCH 0/2] sanlock: Forbid unsupported lock failure actions
by Jiri Denemark
Some lock failure actions do not make any sense in combination with
sanlock driver. Let's just report an error if someone tries to use them
instead of causing unexpected and possibly quite bad thing to happen.
Jiri Denemark (2):
sanlock: Forbid VIR_DOMAIN_LOCK_FAILURE_IGNORE
sanlock: Forbid VIR_DOMAIN_LOCK_FAILURE_RESTART
src/locking/lock_driver_sanlock.c | 12 +++++++++++-
src/locking/sanlock_helper.c | 28 +++-------------------------
2 files changed, 14 insertions(+), 26 deletions(-)
--
1.9.1
10 years, 8 months
[libvirt] [PATCH 0/4] bhyve integration: pie, blk, MAC, host API
by Wojciech Macek
Hi,
I'm working on enabling OpenStack/libvirt support for FreeBSD hosts. Please
look into some patches I'd like to submit for rewiev.
1. PIE-flag: on some FreeBSD-10 the clang toolchain is broken and cannot build
executables with PIE option, so I added the flag to let the user choose.
2. bhyve MAC: add MAC address configuration for bhyve virtio network adapter
3. bhyve blk: add support for up to 8 blk devices, atapi/sata/virtio bus with
file/block backend
4. bhyve host API: initial support for "host" functions on FreeBSD
Regards,
Wojtek
Wojciech Macek (4):
pie: add Position-Independent-Executable flag
bhyve: MAC address configuration
bhyve: multiple virtio-blk devices support
bhyve: host API support
configure.ac | 14 +++++++-
src/bhyve/bhyve_command.c | 92 ++++++++++++++++++++++++++++++-----------------
src/bhyve/bhyve_command.h | 8 +++++
src/bhyve/bhyve_driver.c | 66 ++++++++++++++++++++++++++++++++++
src/nodeinfo.c | 19 ++++++++++
5 files changed, 165 insertions(+), 34 deletions(-)
--
1.9.0
10 years, 8 months
[libvirt] [PATCHv2] gluster: Fix "key" attribute for gluster volumes
by Peter Krempa
According to our documentation the "key" value has the following
meaning: "Providing an identifier for the volume which identifies a
single volume." The currently used keys for gluster volumes consist of
the gluster volume name and file path. This can't be considered unique
as a different storage server can serve a volume with the same name.
Unfortunately I wasn't able to figure out a way to retrieve the gluster
volume UUID which would avoid the possibility of having two distinct
keys identifying a single volume.
Use the full URI as the key for the volume to avoid the more critical
ambiguity problem and document the possible change to UUID.
---
docs/storage.html.in | 6 ++++--
src/storage/storage_backend_gluster.c | 10 ++++++++--
2 files changed, 12 insertions(+), 4 deletions(-)
diff --git a/docs/storage.html.in b/docs/storage.html.in
index 2706bc5..f75996a 100644
--- a/docs/storage.html.in
+++ b/docs/storage.html.in
@@ -711,8 +711,10 @@
correspond to the files that can be found when mounting the
gluster volume. The <code>name</code> is the path relative to
the effective mount specified for the pool; and
- the <code>key</code> is a path including the gluster volume
- name and any subdirectory specified by the pool.</p>
+ the <code>key</code> is a string that identifies a single volume
+ uniquely. Currently the <code>key</code> attribute consists of the
+ URI of the volume but it may be changed to an UUID of the volume
+ in the future.</p>
<pre>
<volume>
<name>myfile</name>
diff --git a/src/storage/storage_backend_gluster.c b/src/storage/storage_backend_gluster.c
index a22b23a..06292fa 100644
--- a/src/storage/storage_backend_gluster.c
+++ b/src/storage/storage_backend_gluster.c
@@ -187,6 +187,7 @@ virStorageBackendGlusterSetMetadata(virStorageBackendGlusterStatePtr state,
const char *name)
{
int ret = -1;
+ char *path = NULL;
char *tmp;
VIR_FREE(vol->key);
@@ -201,12 +202,12 @@ virStorageBackendGlusterSetMetadata(virStorageBackendGlusterStatePtr state,
goto cleanup;
}
- if (virAsprintf(&vol->key, "%s%s%s", state->volname, state->dir,
+ if (virAsprintf(&path, "%s%s%s", state->volname, state->dir,
vol->name) < 0)
goto cleanup;
tmp = state->uri->path;
- if (virAsprintf(&state->uri->path, "/%s", vol->key) < 0) {
+ if (virAsprintf(&state->uri->path, "/%s", path) < 0) {
state->uri->path = tmp;
goto cleanup;
}
@@ -218,9 +219,14 @@ virStorageBackendGlusterSetMetadata(virStorageBackendGlusterStatePtr state,
VIR_FREE(state->uri->path);
state->uri->path = tmp;
+ /* the path is unique enough to serve as a volume key */
+ if (VIR_STRDUP(vol->key, vol->target.path) < 0)
+ goto cleanup;
+
ret = 0;
cleanup:
+ VIR_FREE(path);
return ret;
}
--
1.9.0
10 years, 8 months
[libvirt] [PATCH] util: Sanitize ATTRIBUTE_NONNULL use in viriscsi.h
by Peter Krempa
Some of the function attributes marked as nonnull actually explicitly
handle the arguments for NULL. All changed functions handle missing
"initiatoriqn" argument well and virISCSIScanTargets also handles well
if the return pointers are missing. Remove some of the liberaly used
ATTRIBUTE_NONNULLs as coverity and possibly other compilers that honor
the attribute fail to compile the code.
Flaw introduced in commit 5e1d5dde
---
src/util/viriscsi.h | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/src/util/viriscsi.h b/src/util/viriscsi.h
index b2dd3f1..f4093f7 100644
--- a/src/util/viriscsi.h
+++ b/src/util/viriscsi.h
@@ -33,14 +33,14 @@ int
virISCSIConnectionLogin(const char *portal,
const char *initiatoriqn,
const char *target)
- ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3)
+ ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(3)
ATTRIBUTE_RETURN_CHECK;
int
virISCSIConnectionLogout(const char *portal,
const char *initiatoriqn,
const char *target)
- ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3)
+ ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(3)
ATTRIBUTE_RETURN_CHECK;
int
@@ -52,8 +52,7 @@ virISCSIScanTargets(const char *portal,
const char *initiatoriqn,
size_t *ntargetsret,
char ***targetsret)
- ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3)
- ATTRIBUTE_NONNULL(4) ATTRIBUTE_RETURN_CHECK;
+ ATTRIBUTE_NONNULL(1) ATTRIBUTE_RETURN_CHECK;
int
virISCSINodeUpdate(const char *portal,
--
1.9.0
10 years, 8 months
[libvirt] [RFC PATCH] Behaviour of topology, vcpus and maxcpus
by Nikunj Dadhania
I have observed the following with libvirt xml:
<vcpu>6</vcpu>
<cpu>
<topology sockets='1' cores='4' threads='2'/>
</cpu>
So according to the topology maximum supported is 8 vcpus, while the
libvirt sets that to 6 - specified in <vcpu> tag. Shouldn't libvirt
error this out as the mismatch between the topology definition and the
vcpu count?
There is an upper bound check already in place where if we have maxcpu >
topology-supported cpus, that errors out. For eg.
<vcpu>12</vcpu>
<cpu>
<topology sockets='1' cores='4' threads='2'/>
</cpu>
The below patch make sures that libvirt does the lower bound check as
well.
Regards
Nikunj
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index f96110b..aa25940 100644
[ 0001-Behaviour-of-topology-vcpus-and-maxcpus.patch: inline patch (as
text/x-diff) ]
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -12933,6 +12933,14 @@ virDomainDefParseXML(xmlDocPtr xml,
goto error;
}
+ if (def->cpu->sockets &&
+ def->maxvcpus <
+ def->cpu->sockets * def->cpu->cores * def->cpu->threads) {
+ virReportError(VIR_ERR_XML_DETAIL, "%s",
+ _("CPUs provided is less than topology"));
+ goto error;
+ }
+
if (def->cpu->cells_cpus > def->maxvcpus) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Number of CPUs in <numa> exceeds the"
10 years, 8 months
[libvirt] [PATCH v3 0/5] Expose FSFreeze/FSThaw within the guest as API
by Tomoki Sekiyama
This is patchset v3 to add FSFreeze/FSThaw API for custom disk snapshotting.
Changes to v2:
* use "@acl: domain:fs_freeze" in remote driver
(also applied to VIR_DOMAIN_SNAPSHOT_CREATE_QUIESCE flag)
* added 'quiesced' attribute in live XML to preserve domains' quiesced state
across libvirtd restarts
* rebased to latest tree
(v2: https://www.redhat.com/archives/libvir-list/2014-March/msg00306.html )
=== Description ===
Currently FSFreeze and FSThaw are supported by qemu guest agent and they are
used internally in snapshot-create command with --quiesce option.
However, when users want to utilize the native snapshot feature of storage
devices (such as LVM over iSCSI, enterprise storage appliances, etc.),
they need to issue fsfreeze command separately from libvirt-driven snapshots.
(OpenStack cinder provides these storages' snapshot feature, but it cannot
quiesce the guest filesystems automatically for now.)
Although virDomainQemuGuestAgent() API could be used for this purpose, it
is only for debugging and is not supported officially.
This patchset adds virDomainFSFreeze()/virDomainFSThaw() APIs and virsh
domfsfreeze/domfsthaw commands to enable the users to freeze and thaw
domain's filesystems cleanly.
The APIs have flags option currently unsupported for future extension.
---
Tomoki Sekiyama (5):
Introduce virDomainFSFreeze() and virDomainFSThaw() public API
remote: Implement virDomainFSFreeze and virDomainFSThaw
qemu: Track domain quiesced status
qemu: Implement virDomainFSFreeze and virDomainFSThaw
virsh: Expose new virDomainFSFreeze and virDomainFSThaw API
include/libvirt/libvirt.h.in | 6 ++
src/access/viraccessperm.c | 2 -
src/access/viraccessperm.h | 6 ++
src/driver.h | 10 +++
src/libvirt.c | 70 ++++++++++++++++++++
src/libvirt_public.syms | 5 +
src/qemu/qemu_domain.c | 5 +
src/qemu/qemu_domain.h | 2 +
src/qemu/qemu_driver.c | 144 ++++++++++++++++++++++++++++++++++++++----
src/remote/remote_driver.c | 2 +
src/remote/remote_protocol.x | 25 +++++++
src/remote_protocol-structs | 9 +++
src/rpc/gendispatch.pl | 2 +
tools/virsh-domain.c | 92 +++++++++++++++++++++++++++
tools/virsh.pod | 15 ++++
15 files changed, 379 insertions(+), 16 deletions(-)
10 years, 8 months