[libvirt] [PATCH] Fix virCgroupNewMachine prototype on non-Linux
by Ján Tomko
Commit 318df5a changed the prototype of virCgroupNewMachine
without adjusting the stub function for platforms without
cgroups.
---
Pushed as a trivial build fix.
src/util/vircgroup.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c
index f5f617e..fe34290 100644
--- a/src/util/vircgroup.c
+++ b/src/util/vircgroup.c
@@ -4073,6 +4073,8 @@ virCgroupNewMachine(const char *name ATTRIBUTE_UNUSED,
const char *rootdir ATTRIBUTE_UNUSED,
pid_t pidleader ATTRIBUTE_UNUSED,
bool isContainer ATTRIBUTE_UNUSED,
+ size_t nnicindexes ATTRIBUTE_UNUSED,
+ int *nicindexes ATTRIBUTE_UNUSED,
const char *partition ATTRIBUTE_UNUSED,
int controllers ATTRIBUTE_UNUSED,
virCgroupPtr *group ATTRIBUTE_UNUSED)
--
2.0.4
9 years, 9 months
[libvirt] glibc detected invalid pointer
by shaowt
hi all:
when i use vnc to connect VM, sometimes in libvirt logs, i found
glibc detected invalid pointer error,and then this vm will be shutdown .
“The information (including any attachments) contained in this e-mail is confidential and may be legally privileged . The message is intended solely for the addressee(s). If this e-mail is not originally intended for you, or received by you in error, please contact the sender by return e-mail and do not disclose its content to anyone and destroy all copies of the original message immediately. If you are not the intended recipient, you are hereby notified that any use, dissemination, or reproduction is strictly prohibited and may be unlawful.
本邮件(包括任何附件)包含机密信息,并受法律保护。此信息意在使收件人明确以下内容:如果您并非该收件人或错收此邮件,请联系发件人并退还此邮件,请不要向任何人泄露邮件内容,请立即删除所有邮件及其附件。严禁任何使用,传播或复制此邮件的行为,这些行为可能违反法律。“
9 years, 9 months
[libvirt] [PATCH v2] network: Let domains be restricted to local DNS
by Josh Stone
This adds a new "localOnly" attribute on the domain element of the
network xml. With this set to "yes", DNS requests under that domain
will only be resolved by libvirt's dnsmasq, never forwarded upstream.
This was how it worked before commit f69a6b987d616, and I found that
functionality useful. For example, I have my host's NetworkManager
dnsmasq configured to forward that domain to libvirt's dnsmasq, so I can
easily resolve guest names from outside. But if libvirt's dnsmasq
doesn't know a name and forwards it to the host, I'd get an endless
forwarding loop. Now I can set localOnly="yes" to prevent the loop.
Signed-off-by: Josh Stone <jistone(a)redhat.com>
Cc: Laine Stump <laine(a)laine.org>
---
docs/formatnetwork.html.in | 12 +++++++-
docs/schemas/network.rng | 3 ++
src/conf/network_conf.c | 32 ++++++++++++++++++++--
src/conf/network_conf.h | 1 +
src/network/bridge_driver.c | 5 ++++
.../nat-network-dns-local-domain.conf | 14 ++++++++++
.../nat-network-dns-local-domain.xml | 9 ++++++
tests/networkxml2conftest.c | 1 +
8 files changed, 74 insertions(+), 3 deletions(-)
create mode 100644 tests/networkxml2confdata/nat-network-dns-local-domain.conf
create mode 100644 tests/networkxml2confdata/nat-network-dns-local-domain.xml
diff --git a/docs/formatnetwork.html.in b/docs/formatnetwork.html.in
index dc438aee8622..defcdba00930 100644
--- a/docs/formatnetwork.html.in
+++ b/docs/formatnetwork.html.in
@@ -82,7 +82,7 @@
<pre>
...
<bridge name="virbr0" stp="on" delay="5"/>
- <domain name="example.com"/>
+ <domain name="example.com" localOnly="no"/>
<forward mode="nat" dev="eth0"/>
...</pre>
@@ -113,6 +113,16 @@
a <code><forward></code> mode of "nat" or "route" (or an
isolated network with no <code><forward></code>
element). <span class="since">Since 0.4.5</span>
+
+ <p>
+ If the optional <code>localOnly</code> attribute on the
+ <code>domain</code> element is "yes", then DNS requests under
+ this domain will only be resolved by the virtual network's own
+ DNS server - they will not be forwarded to the host's upstream
+ DNS server. If <code>localOnly</code> is "no", and by
+ default, unresolved requests <b>will</b> be forwarded.
+ <span class="since">Since 1.2.11</span>
+ </p>
</dd>
<dt><code>forward</code></dt>
<dd>Inclusion of the <code>forward</code> element indicates that
diff --git a/docs/schemas/network.rng b/docs/schemas/network.rng
index 4546f8037580..a1da28092375 100644
--- a/docs/schemas/network.rng
+++ b/docs/schemas/network.rng
@@ -225,6 +225,9 @@
<optional>
<element name="domain">
<attribute name="name"><ref name="dnsName"/></attribute>
+ <optional>
+ <attribute name="localOnly"><ref name="virYesNo"/></attribute>
+ </optional>
</element>
</optional>
diff --git a/src/conf/network_conf.c b/src/conf/network_conf.c
index 97719ed536de..31b765ff2c51 100644
--- a/src/conf/network_conf.c
+++ b/src/conf/network_conf.c
@@ -2083,6 +2083,18 @@ virNetworkDefParseXML(xmlXPathContextPtr ctxt)
/* Parse network domain information */
def->domain = virXPathString("string(./domain[1]/@name)", ctxt);
+ tmp = virXPathString("string(./domain[1]/@localOnly)", ctxt);
+ if (tmp) {
+ def->domain_local = virTristateBoolTypeFromString(tmp);
+ if (def->domain_local <= 0) {
+ virReportError(VIR_ERR_XML_ERROR,
+ _("Invalid domain localOnly setting '%s' "
+ "in network '%s'"),
+ tmp, def->name);
+ goto error;
+ }
+ VIR_FREE(tmp);
+ }
if ((bandwidthNode = virXPathNode("./bandwidth", ctxt)) != NULL &&
(def->bandwidth = virNetDevBandwidthParse(bandwidthNode, -1)) == NULL)
@@ -2805,8 +2817,24 @@ virNetworkDefFormatBuf(virBufferPtr buf,
virBufferAsprintf(buf, "<mac address='%s'/>\n", macaddr);
}
- if (def->domain)
- virBufferAsprintf(buf, "<domain name='%s'/>\n", def->domain);
+ if (def->domain) {
+ virBufferAsprintf(buf, "<domain name='%s'", def->domain);
+
+ /* default to "no", but don't format it in the XML */
+ if (def->domain_local) {
+ const char *local = virTristateBoolTypeToString(def->domain_local);
+
+ if (!local) {
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Unknown localOnly type %d in network"),
+ def->domain_local);
+ return -1;
+ }
+ virBufferAsprintf(buf, " localOnly='%s'", local);
+ }
+
+ virBufferAddLit(buf, "/>\n");
+ }
if (virNetworkDNSDefFormat(buf, &def->dns) < 0)
goto error;
diff --git a/src/conf/network_conf.h b/src/conf/network_conf.h
index 660cd2d10cd1..bb9724fddbb8 100644
--- a/src/conf/network_conf.h
+++ b/src/conf/network_conf.h
@@ -232,6 +232,7 @@ struct _virNetworkDef {
char *bridge; /* Name of bridge device */
char *domain;
+ int domain_local; /* enum virTristateBool: yes disables dns forwarding */
unsigned long delay; /* Bridge forward delay (ms) */
bool stp; /* Spanning tree protocol */
virMacAddr mac; /* mac address of bridge device */
diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c
index 9ccc9f8f8de6..f4158517c573 100644
--- a/src/network/bridge_driver.c
+++ b/src/network/bridge_driver.c
@@ -928,6 +928,11 @@ networkDnsmasqConfContents(virNetworkObjPtr network,
}
if (network->def->domain) {
+ if (network->def->domain_local == VIR_TRISTATE_BOOL_YES) {
+ virBufferAsprintf(&configbuf,
+ "local=/%s/\n",
+ network->def->domain);
+ }
virBufferAsprintf(&configbuf,
"domain=%s\n"
"expand-hosts\n",
diff --git a/tests/networkxml2confdata/nat-network-dns-local-domain.conf b/tests/networkxml2confdata/nat-network-dns-local-domain.conf
new file mode 100644
index 000000000000..5f41b9186cbc
--- /dev/null
+++ b/tests/networkxml2confdata/nat-network-dns-local-domain.conf
@@ -0,0 +1,14 @@
+##WARNING: THIS IS AN AUTO-GENERATED FILE. CHANGES TO IT ARE LIKELY TO BE
+##OVERWRITTEN AND LOST. Changes to this configuration should be made using:
+## virsh net-edit default
+## or other application using the libvirt API.
+##
+## dnsmasq conf file created by libvirt
+strict-order
+local=/example.com/
+domain=example.com
+expand-hosts
+except-interface=lo
+bind-dynamic
+interface=virbr0
+addn-hosts=/var/lib/libvirt/dnsmasq/default.addnhosts
diff --git a/tests/networkxml2confdata/nat-network-dns-local-domain.xml b/tests/networkxml2confdata/nat-network-dns-local-domain.xml
new file mode 100644
index 000000000000..a92d71f1f2f6
--- /dev/null
+++ b/tests/networkxml2confdata/nat-network-dns-local-domain.xml
@@ -0,0 +1,9 @@
+<network>
+ <name>default</name>
+ <uuid>81ff0d90-c91e-6742-64da-4a736edb9a9c</uuid>
+ <forward dev='eth0' mode='nat'/>
+ <bridge name='virbr0' stp='on' delay='0' />
+ <domain name='example.com' localOnly='yes'/>
+ <ip address='192.168.122.1' netmask='255.255.255.0'>
+ </ip>
+</network>
diff --git a/tests/networkxml2conftest.c b/tests/networkxml2conftest.c
index 267513f6372c..280db306b6d6 100644
--- a/tests/networkxml2conftest.c
+++ b/tests/networkxml2conftest.c
@@ -134,6 +134,7 @@ mymain(void)
DO_TEST("nat-network-dns-hosts", full);
DO_TEST("nat-network-dns-forward-plain", full);
DO_TEST("nat-network-dns-forwarders", full);
+ DO_TEST("nat-network-dns-local-domain", full);
DO_TEST("dhcp6-network", dhcpv6);
DO_TEST("dhcp6-nat-network", dhcpv6);
DO_TEST("dhcp6host-routed-network", dhcpv6);
--
2.1.0
9 years, 9 months
[libvirt] [java] [PATCH] JNA: add missing flags parameter to wrapped functions
by Claudio Bley
Some functions of the Libvirt interface were missing a required flags
parameter as defined by the libvirt C API, namely:
* virInterfaceCreate
* virInterfaceDestroy
* virNodeDeviceGetXMLDesc
Calling these functions without the flags parameter would result in
undefined behaviour, at best in an "unsupported flags" error.
---
Reported by Matt Russell via personal email. Thanks, Matt!
Pushing under the trivial rule.
src/main/java/org/libvirt/Device.java | 2 +-
src/main/java/org/libvirt/Interface.java | 4 ++--
src/main/java/org/libvirt/jna/Libvirt.java | 6 +++---
3 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/src/main/java/org/libvirt/Device.java b/src/main/java/org/libvirt/Device.java
index a3b20b8..3c876c6 100644
--- a/src/main/java/org/libvirt/Device.java
+++ b/src/main/java/org/libvirt/Device.java
@@ -118,7 +118,7 @@ public class Device {
* @throws LibvirtException
*/
public String getXMLDescription() throws LibvirtException {
- return processError(libvirt.virNodeDeviceGetXMLDesc(VDP));
+ return processError(libvirt.virNodeDeviceGetXMLDesc(VDP, 0));
}
/**
diff --git a/src/main/java/org/libvirt/Interface.java b/src/main/java/org/libvirt/Interface.java
index e0ddc3f..4c9670c 100644
--- a/src/main/java/org/libvirt/Interface.java
+++ b/src/main/java/org/libvirt/Interface.java
@@ -52,7 +52,7 @@ public class Interface {
* @throws LibvirtException
*/
public int create() throws LibvirtException {
- return processError(libvirt.virInterfaceCreate(VIP));
+ return processError(libvirt.virInterfaceCreate(VIP, 0));
}
/**
@@ -71,7 +71,7 @@ public class Interface {
* @throws LibvirtException
*/
public int destroy() throws LibvirtException {
- return processError(libvirt.virInterfaceDestroy(VIP));
+ return processError(libvirt.virInterfaceDestroy(VIP, 0));
}
@Override
diff --git a/src/main/java/org/libvirt/jna/Libvirt.java b/src/main/java/org/libvirt/jna/Libvirt.java
index 4d76071..a17bfc7 100644
--- a/src/main/java/org/libvirt/jna/Libvirt.java
+++ b/src/main/java/org/libvirt/jna/Libvirt.java
@@ -350,7 +350,7 @@ public interface Libvirt extends Library {
String virNodeDeviceGetParent(DevicePointer virDevicePointer);
int virNodeDeviceNumOfCaps(DevicePointer virDevicePointer);
int virNodeDeviceListCaps(DevicePointer virDevicePointer, Pointer[] names, int maxNames);
- String virNodeDeviceGetXMLDesc(DevicePointer virDevicePointer);
+ String virNodeDeviceGetXMLDesc(DevicePointer virDevicePointer, int flags);
int virNodeDeviceFree(DevicePointer virDevicePointer);
int virNodeDeviceDettach(DevicePointer virDevicePointer);
int virNodeDeviceReAttach(DevicePointer virDevicePointer);
@@ -402,9 +402,9 @@ public interface Libvirt extends Library {
int virStorageVolResize(StorageVolPointer storageVolPtr, long capacity, int flags);
// Interface Methods
- int virInterfaceCreate(InterfacePointer virDevicePointer);
+ int virInterfaceCreate(InterfacePointer virDevicePointer, int flags);
InterfacePointer virInterfaceDefineXML(ConnectionPointer virConnectPtr, String xml, int flags);
- int virInterfaceDestroy(InterfacePointer virDevicePointer);
+ int virInterfaceDestroy(InterfacePointer virDevicePointer, int flags);
int virInterfaceFree(InterfacePointer virDevicePointer);
String virInterfaceGetName(InterfacePointer virInterfacePtr);
String virInterfaceGetMACString(InterfacePointer virInterfacePtr);
--
2.2.2
9 years, 9 months
[libvirt] libvirt 1.2.10 and latest EL6 qemu-kvm
by liedekef@telenet.be
Hi all,
I had libvirt 1.2.10 running without issues together with the qemu package
qemu-kvm-0.12.1.2-2.415.el6_5.14.x86_64.rpm
Now, after updating my server, qemu-kvm became version
qemu-kvm-0.12.1.2-2.448.el6_6.x86_64
And as a result, when doing 'virsh start' (virsh define worked ok), the following error occured:
2015-01-19 15:05:26.539+0000: 4347: error : qemuMonitorJSONCheckError:379 : internal error: unable to execute QEMU command 'qom-list': The command qom-list has not been
The only thing I could do (even downgrading libvirt to 1.2.9 didn't work), was to downgrade qemu-kvm to the older version again ...
Any hints on this?
Franky
9 years, 9 months
[libvirt] [python PATCH] sanitytest: fix mapping test for virDomainDefineXMLFlags
by Pavel Hrdina
The libvirt API has in the name "virDomain" but it's correctly mapped
into "virConnect" class. Create an exception in the sanity test.
Signed-off-by: Pavel Hrdina <phrdina(a)redhat.com>
---
Pushed as build(test) breaker.
sanitytest.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/sanitytest.py b/sanitytest.py
index 9907f3d..f021e5a 100644
--- a/sanitytest.py
+++ b/sanitytest.py
@@ -230,7 +230,7 @@ for name in sorted(basicklassmap):
"LookupByID", "LookupByName", "LookupByKey", "LookupByPath",
"LookupByMACString", "LookupByUsage", "LookupByVolume",
"LookupSCSIHostByWWN", "Restore", "RestoreFlags",
- "SaveImageDefineXML", "SaveImageGetXMLDesc"]:
+ "SaveImageDefineXML", "SaveImageGetXMLDesc", "DefineXMLFlags"]:
if klass != "virDomain":
func = klass[3:] + func
--
2.0.5
9 years, 9 months
[libvirt] [PATCH v2] Make ZFS storage pool XML tests optional
by Gary R Hook
From: Gary R Hook <grhookatwork(a)gmail.com>
Do not run ZFS tests when ZFS is unsupported in the environment.
The recent patch b4af40226d09adeaf9e33a1d6594c4e8ce7f771d adds tests
to storagepoolxml2xmltest for the optional ZFS feature. When ZFS is
not included in the configuration these tests should not / cannot be
run. Modify the test source file to check for use of the feature and
compile in the tests accordingly.
Signed-off-by: Gary R Hook <gary.hook(a)nimboxx.com>
---
tests/storagepoolxml2xmltest.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/tests/storagepoolxml2xmltest.c b/tests/storagepoolxml2xmltest.c
index 52e2193..270f75d 100644
--- a/tests/storagepoolxml2xmltest.c
+++ b/tests/storagepoolxml2xmltest.c
@@ -106,8 +106,10 @@ mymain(void)
DO_TEST("pool-gluster");
DO_TEST("pool-gluster-sub");
DO_TEST("pool-scsi-type-scsi-host-stable");
+#ifdef WITH_STORAGE_ZFS
DO_TEST("pool-zfs");
DO_TEST("pool-zfs-sourcedev");
+#endif
return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
}
--
1.9.1
9 years, 9 months
[libvirt] [PATCH] systemd: fix build without dbus
by Daniel P. Berrange
The virDBusMethodCall method has a DBusError as one of its
parameters. If the caller wants to pass a non-NULL value
for this, it immediately makes the calling code require
DBus at build time. This has led to breakage of non-DBus
builds several times. It is desirable that only the virdbus.c
file should need WITH_DBUS conditionals, so we must ideally
remove the DBusError parameter from the method.
We can't simply raise a libvirt error, since the whole point
of this parameter is to give the callers a way to check if
the error is one they want to ignore, without having the logs
polluted with an error message. So, we add a virErrorPtr
parameter which the caller can then either ignore or raise
using virSetError.
Signed-off-by: Daniel P. Berrange <berrange(a)redhat.com>
---
src/util/virdbus.c | 31 +++++++++++++++++++------------
src/util/virdbus.h | 4 ++--
src/util/virfirewall.c | 34 ++++++++++------------------------
src/util/virsystemd.c | 15 +++++++--------
4 files changed, 38 insertions(+), 46 deletions(-)
This is a build-breaker fix, but I'm not pushing since the
fix is too complicated to go in without some review.
diff --git a/src/util/virdbus.c b/src/util/virdbus.c
index d9665c1..3522ae0 100644
--- a/src/util/virdbus.c
+++ b/src/util/virdbus.c
@@ -1522,7 +1522,7 @@ static int
virDBusCall(DBusConnection *conn,
DBusMessage *call,
DBusMessage **replyout,
- DBusError *error)
+ virErrorPtr error)
{
DBusMessage *reply = NULL;
@@ -1530,8 +1530,9 @@ virDBusCall(DBusConnection *conn,
int ret = -1;
const char *iface, *member, *path, *dest;
- if (!error)
- dbus_error_init(&localerror);
+ dbus_error_init(&localerror);
+ if (error)
+ memset(error, 0, sizeof(*error));
iface = dbus_message_get_interface(call);
member = dbus_message_get_member(call);
@@ -1545,13 +1546,20 @@ virDBusCall(DBusConnection *conn,
if (!(reply = dbus_connection_send_with_reply_and_block(conn,
call,
VIR_DBUS_METHOD_CALL_TIMEOUT_MILLIS,
- error ? error : &localerror))) {
+ &localerror))) {
PROBE(DBUS_METHOD_ERROR,
"'%s.%s' on '%s' at '%s' error %s: %s",
iface, member, path, dest,
- error ? error->name : localerror.name,
- error ? error->message : localerror.message);
+ localerror.name,
+ localerror.message);
if (error) {
+ error->level = VIR_ERR_ERROR;
+ error->code = VIR_ERR_DBUS_SERVICE;
+ error->domain = VIR_FROM_DBUS;
+ if (VIR_STRDUP(error->message, localerror.message) < 0)
+ goto cleanup;
+ if (VIR_STRDUP(error->str1, localerror.name) < 0)
+ goto cleanup;
ret = 0;
} else {
virReportError(VIR_ERR_DBUS_SERVICE, _("%s: %s"), member,
@@ -1567,8 +1575,9 @@ virDBusCall(DBusConnection *conn,
ret = 0;
cleanup:
- if (!error)
- dbus_error_free(&localerror);
+ if (ret < 0 && error)
+ virResetError(error);
+ dbus_error_free(&localerror);
if (reply) {
if (ret == 0 && replyout)
*replyout = reply;
@@ -1616,7 +1625,7 @@ virDBusCall(DBusConnection *conn,
*/
int virDBusCallMethod(DBusConnection *conn,
DBusMessage **replyout,
- DBusError *error,
+ virErrorPtr error,
const char *destination,
const char *path,
const char *iface,
@@ -1634,8 +1643,6 @@ int virDBusCallMethod(DBusConnection *conn,
if (ret < 0)
goto cleanup;
- ret = -1;
-
ret = virDBusCall(conn, call, replyout, error);
cleanup:
@@ -1832,7 +1839,7 @@ int virDBusCreateReply(DBusMessage **reply ATTRIBUTE_UNUSED,
int virDBusCallMethod(DBusConnection *conn ATTRIBUTE_UNUSED,
DBusMessage **reply ATTRIBUTE_UNUSED,
- DBusError *error ATTRIBUTE_UNUSED,
+ virErrorPtr error ATTRIBUTE_UNUSED,
const char *destination ATTRIBUTE_UNUSED,
const char *path ATTRIBUTE_UNUSED,
const char *iface ATTRIBUTE_UNUSED,
diff --git a/src/util/virdbus.h b/src/util/virdbus.h
index d0c7de2..e2b8d2b 100644
--- a/src/util/virdbus.h
+++ b/src/util/virdbus.h
@@ -28,7 +28,7 @@
# else
# define DBusConnection void
# define DBusMessage void
-# define DBusError void
+# define dbus_message_unref(m) do {} while (0)
# endif
# include "internal.h"
@@ -62,7 +62,7 @@ int virDBusCreateReplyV(DBusMessage **reply,
int virDBusCallMethod(DBusConnection *conn,
DBusMessage **reply,
- DBusError *error,
+ virErrorPtr error,
const char *destination,
const char *path,
const char *iface,
diff --git a/src/util/virfirewall.c b/src/util/virfirewall.c
index b536912..a01b703 100644
--- a/src/util/virfirewall.c
+++ b/src/util/virfirewall.c
@@ -156,7 +156,6 @@ static int
virFirewallValidateBackend(virFirewallBackend backend)
{
VIR_DEBUG("Validating backend %d", backend);
-#if WITH_DBUS
if (backend == VIR_FIREWALL_BACKEND_AUTOMATIC ||
backend == VIR_FIREWALL_BACKEND_FIREWALLD) {
int rv = virDBusIsServiceRegistered(VIR_FIREWALL_FIREWALLD_SERVICE);
@@ -180,16 +179,6 @@ virFirewallValidateBackend(virFirewallBackend backend)
backend = VIR_FIREWALL_BACKEND_FIREWALLD;
}
}
-#else
- if (backend == VIR_FIREWALL_BACKEND_AUTOMATIC) {
- VIR_DEBUG("DBus support disabled, trying direct backend");
- backend = VIR_FIREWALL_BACKEND_DIRECT;
- } else if (backend == VIR_FIREWALL_BACKEND_FIREWALLD) {
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
- _("firewalld firewall backend requested, but DBus support disabled"));
- return -1;
- }
-#endif
if (backend == VIR_FIREWALL_BACKEND_DIRECT) {
const char *commands[] = {
@@ -755,7 +744,6 @@ virFirewallApplyRuleDirect(virFirewallRulePtr rule,
}
-#ifdef WITH_DBUS
static int
virFirewallApplyRuleFirewallD(virFirewallRulePtr rule,
bool ignoreErrors,
@@ -764,13 +752,13 @@ virFirewallApplyRuleFirewallD(virFirewallRulePtr rule,
const char *ipv = virFirewallLayerFirewallDTypeToString(rule->layer);
DBusConnection *sysbus = virDBusGetSystemBus();
DBusMessage *reply = NULL;
- DBusError error;
+ virError error;
int ret = -1;
if (!sysbus)
return -1;
- dbus_error_init(&error);
+ memset(&error, 0, sizeof(error));
if (!ipv) {
virReportError(VIR_ERR_INTERNAL_ERROR,
@@ -789,10 +777,13 @@ virFirewallApplyRuleFirewallD(virFirewallRulePtr rule,
"sa&s",
ipv,
(int)rule->argsLen,
- rule->args) < 0)
+ rule->args) < 0) {
+ VIR_ERROR("Here fail");
goto cleanup;
+ }
- if (dbus_error_is_set(&error)) {
+ VIR_ERROR("Error %d: %s\n", error.level, error.message);
+ if (error.level == VIR_ERR_ERROR) {
/*
* As of firewalld-0.3.9.3-1.fc20.noarch the name and
* message fields in the error look like
@@ -820,11 +811,9 @@ virFirewallApplyRuleFirewallD(virFirewallRulePtr rule,
*/
if (ignoreErrors) {
VIR_DEBUG("Ignoring error '%s': '%s'",
- error.name, error.message);
+ error.str1, error.message);
} else {
- virReportError(VIR_ERR_INTERNAL_ERROR,
- _("Unable to apply rule '%s'"),
- error.message);
+ virSetError(&error);
goto cleanup;
}
} else {
@@ -835,12 +824,11 @@ virFirewallApplyRuleFirewallD(virFirewallRulePtr rule,
ret = 0;
cleanup:
- dbus_error_free(&error);
+ virResetError(&error);
if (reply)
dbus_message_unref(reply);
return ret;
}
-#endif
static int
virFirewallApplyRule(virFirewallPtr firewall,
@@ -862,12 +850,10 @@ virFirewallApplyRule(virFirewallPtr firewall,
if (virFirewallApplyRuleDirect(rule, ignoreErrors, &output) < 0)
return -1;
break;
-#if WITH_DBUS
case VIR_FIREWALL_BACKEND_FIREWALLD:
if (virFirewallApplyRuleFirewallD(rule, ignoreErrors, &output) < 0)
return -1;
break;
-#endif
default:
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Unexpected firewall engine backend"));
diff --git a/src/util/virsystemd.c b/src/util/virsystemd.c
index 3eea5c2..0b71b26 100644
--- a/src/util/virsystemd.c
+++ b/src/util/virsystemd.c
@@ -252,8 +252,8 @@ int virSystemdCreateMachine(const char *name,
VIR_DEBUG("Attempting to create machine via systemd");
if (virAtomicIntGet(&hasCreateWithNetwork)) {
- DBusError error;
- dbus_error_init(&error);
+ virError error;
+ memset(&error, 0, sizeof(error));
if (virDBusCallMethod(conn,
NULL,
@@ -280,21 +280,20 @@ int virSystemdCreateMachine(const char *name,
"Before", "as", 1, "libvirt-guests.service") < 0)
goto cleanup;
- if (dbus_error_is_set(&error)) {
+ if (error.level == VIR_ERR_ERROR) {
if (STREQ_NULLABLE("org.freedesktop.DBus.Error.UnknownMethod",
- error.name)) {
+ error.str1)) {
VIR_INFO("CreateMachineWithNetwork isn't supported, switching "
"to legacy CreateMachine method for systemd-machined");
- dbus_error_free(&error);
+ virResetError(&error);
virAtomicIntSet(&hasCreateWithNetwork, 0);
/* Could re-structure without Using goto, but this
* avoids another atomic read which would trigger
* another memory barrier */
goto fallback;
}
- virReportError(VIR_ERR_DBUS_SERVICE,
- _("CreateMachineWithNetwork: %s"),
- error.message ? error.message : _("unknown error"));
+ virSetError(&error);
+ virResetError(&error);
goto cleanup;
}
} else {
--
2.1.0
9 years, 9 months
[libvirt] [PATCH] docs: Fix docs about python bindings package
by Martin Kletzander
Since the day we removed python bindings from the core repository, the
documentation was missing that information.
Reported-by: Lingyu Zhu <lynuszhu(a)gmail.com>
Signed-off-by: Martin Kletzander <mkletzan(a)redhat.com>
---
docs/bindings.html.in | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/docs/bindings.html.in b/docs/bindings.html.in
index 13b7d71..95cfe25 100644
--- a/docs/bindings.html.in
+++ b/docs/bindings.html.in
@@ -44,8 +44,10 @@
</li>
<li>
<p>
- <strong>Python</strong>: Libvirt comes with direct support for
- the Python language.
+ <strong>Python</strong>: Libvirt's python bindings are split to a
+ separate <a href="http://libvirt.org/git/?p=libvirt-python.git">package</a>
+ since version 1.2.0, older versions came with direct support for the
+ Python language.
</p>
<p>
If your libvirt is installed as packages, rather than compiled
--
2.2.1
9 years, 9 months
[libvirt] [PATCH] qemu_conf: check for duplicate security drivers
by Ján Tomko
Using the same driver multiple times is pointless and
it can result in confusing errors:
$ virsh start test
error: Failed to start domain test
error: internal error: security label already defined for VM
https://bugzilla.redhat.com/show_bug.cgi?id=1153891
---
src/qemu/qemu_conf.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
index 9539231..a24c5c5 100644
--- a/src/qemu/qemu_conf.c
+++ b/src/qemu/qemu_conf.c
@@ -460,7 +460,7 @@ int virQEMUDriverConfigLoadFile(virQEMUDriverConfigPtr cfg,
p = virConfGetValue(conf, "security_driver");
if (p && p->type == VIR_CONF_LIST) {
- size_t len;
+ size_t len, j;
virConfValuePtr pp;
/* Calc length and check items */
@@ -476,6 +476,13 @@ int virQEMUDriverConfigLoadFile(virQEMUDriverConfigPtr cfg,
goto cleanup;
for (i = 0, pp = p->list; pp; i++, pp = pp->next) {
+ for (j = 0; j < i; j++) {
+ if (STREQ(pp->str, cfg->securityDriverNames[j])) {
+ virReportError(VIR_ERR_CONF_SYNTAX,
+ _("Duplicate security driver %s"), pp->str);
+ goto cleanup;
+ }
+ }
if (VIR_STRDUP(cfg->securityDriverNames[i], pp->str) < 0)
goto cleanup;
}
--
2.0.4
9 years, 9 months