[libvirt] [PATCH 1/2] nwfilter: move code for IP address map into separate file
by Stefan Berger
The goal of this patch is to prepare for support for multiple IP
addresses per interface in the DHCP snooping code.
Move the code for the IP address map that maps interface names to
IP addresses into their own file. Rename the functions on the way
but otherwise leave the code as-is. Initialize this new layer
separately before dependent layers (iplearning, dhcpsnooping)
and shut it down after them.
---
src/Makefile.am | 2
src/nwfilter/nwfilter_driver.c | 11 +-
src/nwfilter/nwfilter_gentech_driver.c | 5
src/nwfilter/nwfilter_ipaddrmap.c | 167
+++++++++++++++++++++++++++++++++
src/nwfilter/nwfilter_ipaddrmap.h | 38 +++++++
src/nwfilter/nwfilter_learnipaddr.c | 127 -------------------------
src/nwfilter/nwfilter_learnipaddr.h | 3
7 files changed, 222 insertions(+), 131 deletions(-)
Index: libvirt-acl/src/nwfilter/nwfilter_ipaddrmap.h
===================================================================
--- /dev/null
+++ libvirt-acl/src/nwfilter/nwfilter_ipaddrmap.h
@@ -0,0 +1,38 @@
+/*
+ * nwfilter_ipaddrmap.h: IP address map for mapping interfaces to their
+ * detected/expected IP addresses
+ *
+ * Copyright (C) 2010, 2012 IBM Corp.
+ *
+ * Author:
+ * Stefan Berger <stefanb(a)linux.vnet.ibm.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ */
+
+#ifndef __VIR_NWFILTER_IPADDRMAP_H
+# define __VIR_NWFILTER_IPADDRMAP_H
+
+int virNWFilterIPAddrMapInit(void);
+void virNWFilterIPAddrMapShutdown(void);
+
+int virNWFilterIPAddrMapAddIPAddrForIfname(const char *ifname, char *addr);
+int virNWFilterIPAddrMapDelIPAddrForIfname(const char *ifname,
+ const char *ipaddr);
+virNWFilterVarValuePtr virNWFilterIPAddrMapGetIPAddrForIfname(
+ const char *ifname);
+
+#endif /* __VIR_NWFILTER_IPADDRMAP_H */
Index: libvirt-acl/src/Makefile.am
===================================================================
--- libvirt-acl.orig/src/Makefile.am
+++ libvirt-acl/src/Makefile.am
@@ -513,6 +513,8 @@ NWFILTER_DRIVER_SOURCES = \
nwfilter/nwfilter_dhcpsnoop.h \
nwfilter/nwfilter_ebiptables_driver.c \
nwfilter/nwfilter_ebiptables_driver.h \
+ nwfilter/nwfilter_ipaddrmap.c \
+ nwfilter/nwfilter_ipaddrmap.h \
nwfilter/nwfilter_learnipaddr.c \
nwfilter/nwfilter_learnipaddr.h
Index: libvirt-acl/src/nwfilter/nwfilter_driver.c
===================================================================
--- libvirt-acl.orig/src/nwfilter/nwfilter_driver.c
+++ libvirt-acl/src/nwfilter/nwfilter_driver.c
@@ -39,6 +39,7 @@
#include "nwfilter_gentech_driver.h"
#include "configmake.h"
+#include "nwfilter_ipaddrmap.h"
#include "nwfilter_dhcpsnoop.h"
#include "nwfilter_learnipaddr.h"
@@ -67,10 +68,12 @@ static int
nwfilterDriverStartup(int privileged) {
char *base = NULL;
- if (virNWFilterDHCPSnoopInit() < 0)
+ if (virNWFilterIPAddrMapInit() < 0)
return -1;
if (virNWFilterLearnInit() < 0)
- return -1;
+ goto err_exit_ipaddrmapshutdown;
+ if (virNWFilterDHCPSnoopInit() < 0)
+ goto err_exit_learnshutdown;
virNWFilterTechDriversInit(privileged);
@@ -131,7 +134,10 @@ alloc_err_exit:
conf_init_err:
virNWFilterTechDriversShutdown();
virNWFilterDHCPSnoopShutdown();
+err_exit_learnshutdown:
virNWFilterLearnShutdown();
+err_exit_ipaddrmapshutdown:
+ virNWFilterIPAddrMapShutdown();
return -1;
}
@@ -210,6 +216,7 @@ nwfilterDriverShutdown(void) {
virNWFilterTechDriversShutdown();
virNWFilterDHCPSnoopShutdown();
virNWFilterLearnShutdown();
+ virNWFilterIPAddrMapShutdown();
nwfilterDriverLock(driverState);
Index: libvirt-acl/src/nwfilter/nwfilter_gentech_driver.c
===================================================================
--- libvirt-acl.orig/src/nwfilter/nwfilter_gentech_driver.c
+++ libvirt-acl/src/nwfilter/nwfilter_gentech_driver.c
@@ -33,6 +33,7 @@
#include "nwfilter_gentech_driver.h"
#include "nwfilter_ebiptables_driver.h"
#include "nwfilter_dhcpsnoop.h"
+#include "nwfilter_ipaddrmap.h"
#include "nwfilter_learnipaddr.h"
#include "virnetdev.h"
#include "datatypes.h"
@@ -870,7 +871,7 @@ __virNWFilterInstantiateFilter(const uns
goto err_exit;
}
- ipaddr = virNWFilterGetIpAddrForIfname(ifname);
+ ipaddr = virNWFilterIPAddrMapGetIPAddrForIfname(ifname);
vars1 = virNWFilterCreateVarHashmap(str_macaddr, ipaddr);
if (!vars1) {
@@ -1132,7 +1133,7 @@ _virNWFilterTeardownFilter(const char *i
techdriver->allTeardown(ifname);
- virNWFilterDelIpAddrForIfname(ifname, NULL);
+ virNWFilterIPAddrMapDelIPAddrForIfname(ifname, NULL);
virNWFilterUnlockIface(ifname);
Index: libvirt-acl/src/nwfilter/nwfilter_ipaddrmap.c
===================================================================
--- /dev/null
+++ libvirt-acl/src/nwfilter/nwfilter_ipaddrmap.c
@@ -0,0 +1,167 @@
+/*
+ * nwfilter_ipaddrmap.c: IP address map for mapping interfaces to their
+ * detected/expected IP addresses
+ *
+ * Copyright (C) 2010, 2012 IBM Corp.
+ *
+ * Author:
+ * Stefan Berger <stefanb(a)linux.vnet.ibm.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include <config.h>
+
+#include "internal.h"
+
+#include "virterror_internal.h"
+#include "datatypes.h"
+#include "nwfilter_params.h"
+#include "nwfilter_ipaddrmap.h"
+
+#define VIR_FROM_THIS VIR_FROM_NWFILTER
+
+static virMutex ipAddressMapLock;
+static virNWFilterHashTablePtr ipAddressMap;
+
+
+/* Add an IP address to the list of IP addresses an interface is
+ * known to use. This function feeds the per-interface cache that
+ * is used to instantiate filters with variable '$IP'.
+ *
+ * @ifname: The name of the (tap) interface
+ * @addr: An IPv4 address in dotted decimal format that the (tap)
+ * interface is known to use.
+ *
+ * This function returns 0 on success, -1 otherwise
+ */
+int
+virNWFilterIPAddrMapAddIPAddrForIfname(const char *ifname, char *addr)
+{
+ int ret = -1;
+ virNWFilterVarValuePtr val;
+
+ virMutexLock(&ipAddressMapLock);
+
+ val = virHashLookup(ipAddressMap->hashTable, ifname);
+ if (!val) {
+ val = virNWFilterVarValueCreateSimple(addr);
+ if (!val) {
+ virReportOOMError();
+ goto cleanup;
+ }
+ ret = virNWFilterHashTablePut(ipAddressMap, ifname, val, 1);
+ goto cleanup;
+ } else {
+ if (virNWFilterVarValueAddValue(val, addr) < 0)
+ goto cleanup;
+ }
+
+ ret = 0;
+
+cleanup:
+ virMutexUnlock(&ipAddressMapLock);
+
+ return ret;
+}
+
+/* Delete all or a specific IP address from an interface. After this
+ * call either all or the given IP address will not be associated
+ * with the interface anymore.
+ *
+ * @ifname: The name of the (tap) interface
+ * @addr: An IPv4 address in dotted decimal format that the (tap)
+ * interface is not using anymore; provide NULL to remove all IP
+ * addresses associated with the given interface
+ *
+ * This function returns the number of IP addresses that are still
+ * known to be associated with this interface, in case of an error
+ * -1 is returned. Error conditions are:
+ * - IP addresses is not known to be associated with the interface
+ */
+int
+virNWFilterIPAddrMapDelIPAddrForIfname(const char *ifname, const char
*ipaddr)
+{
+ int ret = -1;
+ virNWFilterVarValuePtr val = NULL;
+
+ virMutexLock(&ipAddressMapLock);
+
+ if (ipaddr != NULL) {
+ val = virHashLookup(ipAddressMap->hashTable, ifname);
+ if (val) {
+ if (virNWFilterVarValueGetCardinality(val) == 1 &&
+ STREQ(ipaddr,
+ virNWFilterVarValueGetNthValue(val, 0)))
+ goto remove_entry;
+ virNWFilterVarValueDelValue(val, ipaddr);
+ ret = virNWFilterVarValueGetCardinality(val);
+ }
+ } else {
+remove_entry:
+ /* remove whole entry */
+ val = virNWFilterHashTableRemoveEntry(ipAddressMap, ifname);
+ virNWFilterVarValueFree(val);
+ ret = 0;
+ }
+
+ virMutexUnlock(&ipAddressMapLock);
+
+ return ret;
+}
+
+/* Get the list of IP addresses known to be in use by an interface
+ *
+ * This function returns NULL in case no IP address is known to be
+ * associated with the interface, a virNWFilterVarValuePtr otherwise
+ * that then can contain one or multiple entries.
+ */
+virNWFilterVarValuePtr
+virNWFilterIPAddrMapGetIPAddrForIfname(const char *ifname)
+{
+ virNWFilterVarValuePtr res;
+
+ virMutexLock(&ipAddressMapLock);
+
+ res = virHashLookup(ipAddressMap->hashTable, ifname);
+
+ virMutexUnlock(&ipAddressMapLock);
+
+ return res;
+}
+
+int
+virNWFilterIPAddrMapInit(void)
+{
+ ipAddressMap = virNWFilterHashTableCreate(0);
+ if (!ipAddressMap) {
+ virReportOOMError();
+ return -1;
+ }
+
+ if (virMutexInit(&ipAddressMapLock) < 0) {
+ virNWFilterIPAddrMapShutdown();
+ return -1;
+ }
+
+ return 0;
+}
+
+void
+virNWFilterIPAddrMapShutdown(void)
+{
+ virNWFilterHashTableFree(ipAddressMap);
+ ipAddressMap = NULL;
+}
Index: libvirt-acl/src/nwfilter/nwfilter_learnipaddr.c
===================================================================
--- libvirt-acl.orig/src/nwfilter/nwfilter_learnipaddr.c
+++ libvirt-acl/src/nwfilter/nwfilter_learnipaddr.c
@@ -52,6 +52,7 @@
#include "conf/domain_conf.h"
#include "nwfilter_gentech_driver.h"
#include "nwfilter_ebiptables_driver.h"
+#include "nwfilter_ipaddrmap.h"
#include "nwfilter_learnipaddr.h"
#define VIR_FROM_THIS VIR_FROM_NWFILTER
@@ -118,9 +119,6 @@ struct ether_vlan_header
static virMutex pendingLearnReqLock;
static virHashTablePtr pendingLearnReq;
-static virMutex ipAddressMapLock;
-static virNWFilterHashTablePtr ipAddressMap;
-
static virMutex ifaceMapLock;
static virHashTablePtr ifaceLockMap;
@@ -310,113 +308,8 @@ virNWFilterDeregisterLearnReq(int ifinde
return res;
}
-/* Add an IP address to the list of IP addresses an interface is
- * known to use. This function feeds the per-interface cache that
- * is used to instantiate filters with variable '$IP'.
- *
- * @ifname: The name of the (tap) interface
- * @addr: An IPv4 address in dotted decimal format that the (tap)
- * interface is known to use.
- *
- * This function returns 0 on success, -1 otherwise
- */
-static int
-virNWFilterAddIpAddrForIfname(const char *ifname, char *addr)
-{
- int ret = -1;
- virNWFilterVarValuePtr val;
-
- virMutexLock(&ipAddressMapLock);
-
- val = virHashLookup(ipAddressMap->hashTable, ifname);
- if (!val) {
- val = virNWFilterVarValueCreateSimple(addr);
- if (!val) {
- virReportOOMError();
- goto cleanup;
- }
- ret = virNWFilterHashTablePut(ipAddressMap, ifname, val, 1);
- goto cleanup;
- } else {
- if (virNWFilterVarValueAddValue(val, addr) < 0)
- goto cleanup;
- }
-
- ret = 0;
-
-cleanup:
- virMutexUnlock(&ipAddressMapLock);
-
- return ret;
-}
#endif
-/* Delete all or a specific IP address from an interface. After this
- * call either all or the given IP address will not be associated
- * with the interface anymore.
- *
- * @ifname: The name of the (tap) interface
- * @addr: An IPv4 address in dotted decimal format that the (tap)
- * interface is not using anymore; provide NULL to remove all IP
- * addresses associated with the given interface
- *
- * This function returns the number of IP addresses that are still
- * known to be associated with this interface, in case of an error
- * -1 is returned. Error conditions are:
- * - IP addresses is not known to be associated with the interface
- */
-int
-virNWFilterDelIpAddrForIfname(const char *ifname, const char *ipaddr)
-{
- int ret = -1;
- virNWFilterVarValuePtr val = NULL;
-
- virMutexLock(&ipAddressMapLock);
-
- if (ipaddr != NULL) {
- val = virHashLookup(ipAddressMap->hashTable, ifname);
- if (val) {
- if (virNWFilterVarValueGetCardinality(val) == 1 &&
- STREQ(ipaddr,
- virNWFilterVarValueGetNthValue(val, 0)))
- goto remove_entry;
- virNWFilterVarValueDelValue(val, ipaddr);
- ret = virNWFilterVarValueGetCardinality(val);
- }
- } else {
-remove_entry:
- /* remove whole entry */
- val = virNWFilterHashTableRemoveEntry(ipAddressMap, ifname);
- virNWFilterVarValueFree(val);
- ret = 0;
- }
-
- virMutexUnlock(&ipAddressMapLock);
-
- return ret;
-}
-
-/* Get the list of IP addresses known to be in use by an interface
- *
- * This function returns NULL in case no IP address is known to be
- * associated with the interface, a virNWFilterVarValuePtr otherwise
- * that then can contain one or multiple entries.
- */
-virNWFilterVarValuePtr
-virNWFilterGetIpAddrForIfname(const char *ifname)
-{
- virNWFilterVarValuePtr res;
-
- virMutexLock(&ipAddressMapLock);
-
- res = virHashLookup(ipAddressMap->hashTable, ifname);
-
- virMutexUnlock(&ipAddressMapLock);
-
- return res;
-}
-
-
#ifdef HAVE_LIBPCAP
static void
@@ -699,7 +592,8 @@ learnIPAddressThread(void *arg)
char *inetaddr;
if ((inetaddr = virSocketAddrFormat(&sa)) != NULL) {
- if (virNWFilterAddIpAddrForIfname(req->ifname, inetaddr) < 0) {
+ if (virNWFilterIPAddrMapAddIPAddrForIfname(req->ifname,
+ inetaddr) < 0) {
VIR_ERROR(_("Failed to add IP address %s to IP address "
"cache for interface %s"), inetaddr,
req->ifname);
}
@@ -901,18 +795,6 @@ virNWFilterLearnInit(void) {
return -1;
}
- ipAddressMap = virNWFilterHashTableCreate(0);
- if (!ipAddressMap) {
- virReportOOMError();
- virNWFilterLearnShutdown();
- return -1;
- }
-
- if (virMutexInit(&ipAddressMapLock) < 0) {
- virNWFilterLearnShutdown();
- return -1;
- }
-
ifaceLockMap = virHashCreate(0, freeIfaceLock);
if (!ifaceLockMap) {
virNWFilterLearnShutdown();
@@ -954,9 +836,6 @@ virNWFilterLearnShutdown(void)
virHashFree(pendingLearnReq);
pendingLearnReq = NULL;
- virNWFilterHashTableFree(ipAddressMap);
- ipAddressMap = NULL;
-
virHashFree(ifaceLockMap);
ifaceLockMap = NULL;
}
Index: libvirt-acl/src/nwfilter/nwfilter_learnipaddr.h
===================================================================
--- libvirt-acl.orig/src/nwfilter/nwfilter_learnipaddr.h
+++ libvirt-acl/src/nwfilter/nwfilter_learnipaddr.h
@@ -65,9 +65,6 @@ int virNWFilterLearnIPAddress(virNWFilte
virNWFilterIPAddrLearnReqPtr virNWFilterLookupLearnReq(int ifindex);
int virNWFilterTerminateLearnReq(const char *ifname);
-int virNWFilterDelIpAddrForIfname(const char *ifname, const char *ipaddr);
-virNWFilterVarValuePtr virNWFilterGetIpAddrForIfname(const char *ifname);
-
int virNWFilterLockIface(const char *ifname) ATTRIBUTE_RETURN_CHECK;
void virNWFilterUnlockIface(const char *ifname);
13 years, 1 month
[libvirt] [PATCH] LXC: support block devices for container
by Gao feng
This patch allows to config block device for container.
the disk node is used to point out source device and target device
source device is the device path in host,
and target device is the device name in container.
such as
<disk type='block' device='disk'>
<driver name="lxc"/>
<source dev='/dev/sda2'/>
<target dev='sda1'/>
</disk>
Unfortunately it's no use to config readonly in disk node now.
Signed-off-by: Gao feng <gaofeng(a)cn.fujitsu.com>
---
src/lxc/lxc_container.c | 78 ++++++++++++++++++++++++++++++++++++++++++++++
src/lxc/lxc_controller.c | 15 +++++++++
2 files changed, 93 insertions(+), 0 deletions(-)
diff --git a/src/lxc/lxc_container.c b/src/lxc/lxc_container.c
index 9bb6218..062cc8f 100644
--- a/src/lxc/lxc_container.c
+++ b/src/lxc/lxc_container.c
@@ -581,6 +581,80 @@ static int lxcContainerMountFSDevPTS(virDomainFSDefPtr root)
return rc;
}
+static int lxcContainerAddDisk(virDomainDiskDefPtr disk,
+ const char *srcprefix)
+{
+ char *srcPath = NULL;
+ char *dstPath = NULL;
+ struct stat sb;
+ dev_t dev;
+ int ret = -1;
+ switch (disk->device) {
+ case VIR_DOMAIN_DISK_DEVICE_DISK:
+ case VIR_DOMAIN_DISK_DEVICE_LUN:
+ if (virAsprintf(&srcPath, "%s/%s", srcprefix, disk->src) < 0) {
+ virReportOOMError();
+ return ret;
+ }
+ if (virAsprintf(&dstPath, "/dev/%s", disk->dst) < 0) {
+ virReportOOMError();
+ goto cleanup;
+ }
+ if (stat(srcPath, &sb) < 0) {
+ ret = -errno;
+ goto cleanup;
+ }
+ dev = makedev(major(sb.st_rdev), minor(sb.st_rdev));
+ if (mknod(dstPath, S_ISCHR(sb.st_mode) ? S_IFCHR : S_IFBLK, dev) < 0 ||
+ chmod(dstPath, sb.st_mode)) {
+ virReportSystemError(errno,
+ _("Failed to make device %s"),
+ dstPath);
+ goto cleanup;
+ }
+ ret = 0;
+ break;
+ default:
+ lxcError(VIR_ERR_CONFIG_UNSUPPORTED,
+ _("unsupported disk device type '%s'."),
+ virDomainDiskDeviceTypeToString(disk->device));
+ break;
+ }
+
+cleanup:
+ VIR_FREE(srcPath);
+ VIR_FREE(dstPath);
+ return ret;
+}
+static int lxcContainerAddDevices(virDomainDefPtr vmDef,
+ const char *srcprefix)
+{
+ int ret = -1;
+ size_t i;
+
+ for (i=0 ; i<vmDef->ndisks ; i++) {
+ virDomainDiskDefPtr disk = vmDef->disks[i];
+
+ if (disk->driverName !=NULL && !STREQ(disk->driverName, "lxc")) {
+ lxcError(VIR_ERR_CONFIG_UNSUPPORTED,
+ _("unsupported driver name '%s' for disk '%s'"),
+ disk->driverName, disk->src);
+ continue;
+ }
+ if (disk->type != VIR_DOMAIN_DISK_TYPE_BLOCK) {
+ lxcError(VIR_ERR_CONFIG_UNSUPPORTED,
+ _("unsupported disk type '%s'"),
+ virDomainDiskTypeToString(disk->type));
+ continue;
+ }
+ if (lxcContainerAddDisk(disk, srcprefix) < 0)
+ goto cleanup;
+ }
+ ret = 0;
+cleanup:
+ return ret;
+}
+
static int lxcContainerPopulateDevices(char **ttyPaths, size_t nttyPaths)
{
size_t i;
@@ -1144,6 +1218,10 @@ static int lxcContainerSetupPivotRoot(virDomainDefPtr vmDef,
if (lxcContainerMountFSDevPTS(root) < 0)
return -1;
+ /* Create devices */
+ if (lxcContainerAddDevices(vmDef, "/.oldroot") <0)
+ return -1;
+
/* Populates device nodes in /dev/ */
if (lxcContainerPopulateDevices(ttyPaths, nttyPaths) < 0)
return -1;
diff --git a/src/lxc/lxc_controller.c b/src/lxc/lxc_controller.c
index bbc9d9c..5576f99 100644
--- a/src/lxc/lxc_controller.c
+++ b/src/lxc/lxc_controller.c
@@ -545,6 +545,21 @@ static int lxcSetContainerDeviceACL(virCgroupPtr cgroup, virDomainDefPtr def)
}
}
+ for (i = 0 ; i < def->ndisks ; i++) {
+ if (def->disks[i]->type != VIR_DOMAIN_DISK_TYPE_BLOCK)
+ continue;
+
+ rc = virCgroupAllowDevicePath(cgroup,
+ def->disks[i]->src,
+ VIR_CGROUP_DEVICE_RWM);
+ if (rc != 0) {
+ virReportSystemError(-rc,
+ _("Unable to allow device %s for domain %s"),
+ def->disks[i]->src, def->name);
+ goto cleanup;
+ }
+ }
+
rc = virCgroupAllowDeviceMajor(cgroup, 'c', LXC_DEV_MAJ_PTY,
VIR_CGROUP_DEVICE_RWM);
if (rc != 0) {
--
1.7.7.6
13 years, 1 month
[libvirt] Multithreading crash on Win32
by Marcel Müller
Hello everyone,
Im using libvirt 0.9.11 on a Windows machine with java bindings. This works
fine, as long as the application is single threaded. As soon as I switch
over to more threads libvirt crashes most of the time (but not always!).
Ive tried to track down the issue, but Im at a loss now. Please see
attached file for debug info.
What Ive found out so far:
- It looks like this happens only on Win32 (Win 7 x64), Linux
(Debian Squeeze) looks fine so far
- Its crashing in src/rpc/virnetsocket.c at the end of
virNetSocketNewConnectTCP when calling freeaddrinfo(ai). ai is not a
null value here, Ive checked that.
Im not sure how to debug this any further.
Hope someone has an idea on that.
Best Regards,
Marcel
13 years, 1 month
[libvirt] [PATCH] qemu: change rbd auth_supported separation character to ;
by Josh Durgin
This works with newer qemu that doesn't allow escaping spaces.
It's backwards compatible as well.
Signed-off-by: Josh Durgin <josh.durgin(a)dreamhost.com>
---
src/qemu/qemu_command.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index f971a08..ee3bf48 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -1673,8 +1673,8 @@ qemuBuildRBDString(virConnectPtr conn,
virReportOOMError();
goto error;
}
- virBufferEscape(opt, '\\', ":",
- ":key=%s:auth_supported=cephx none",
+ virBufferEscape(opt, '\\', ":;",
+ ":key=%s:auth_supported=cephx;none",
base64);
VIR_FREE(base64);
} else {
--
1.7.5.4
13 years, 1 month
[libvirt] [PATCHv2 00/15] live block migration via virDomainBlockCopy
by Eric Blake
v1 was here:
https://www.redhat.com/archives/libvir-list/2012-April/msg00068.html
changes from v1: Paolo has updated the qemu side of things, and built
a scratch image for RHEL that I was able to test with for the new
semantics. I was actually able to successfully run two different
block copy jobs, one canceled and one pivoted, with SELinux disabled
and this patch series.
Patch 12/15 is for reference only when working with Paolo's build;
it will not go upstream.
Patches 13-15 are optional; the extra flexibility might be nice, but
I haven't yet played with those three enough to know if Paolo's build
behaves like I was expecting.
I obviously have more patches to write, such as supporting the REUSE_EXT
flag to reuse files instead of creating a new one, and fixing several
XXX comments related to SELinux, auditing, and disk locking. But they
can be extra patches on top of this starting series.
Adam Litke (2):
blockjob: add API for async virDomainBlockJobAbort
blockjob: wire up qemu async virDomainBlockJobAbort
Eric Blake (13):
blockjob: allow for fast-finishing job
blockjob: add new API flags
blockjob: add 'blockcopy' to virsh
blockjob: enhance xml to track mirrors across libvirtd restart
blockjob: react to active block copy
blockjob: expose qemu commands for mirrored storage migration
blockjob: return appropriate event and info
blockjob: support pivot operation on cancel
blockjob: implement block copy for qemu
blockjob: accommodate RHEL backport names
blockjob: add virDomainBlockCopy
blockjob: enhance virsh 'blockcopy'
blockjob: wire up qemu and RPC for block copy
docs/apibuild.py | 1 +
docs/formatdomain.html.in | 11 ++
docs/schemas/domaincommon.rng | 19 ++-
include/libvirt/libvirt.h.in | 50 ++++++-
include/libvirt/virterror.h | 1 +
src/conf/domain_conf.c | 54 +++++++
src/conf/domain_conf.h | 6 +
src/driver.h | 5 +
src/libvirt.c | 220 +++++++++++++++++++++++++-
src/libvirt_private.syms | 1 +
src/libvirt_public.syms | 5 +
src/qemu/qemu_capabilities.c | 3 +
src/qemu/qemu_capabilities.h | 2 +
src/qemu/qemu_driver.c | 340 +++++++++++++++++++++++++++++++++++++++--
src/qemu/qemu_hotplug.c | 7 +
src/qemu/qemu_monitor.c | 50 ++++++
src/qemu/qemu_monitor.h | 28 +++-
src/qemu/qemu_monitor_json.c | 154 ++++++++++++++++---
src/qemu/qemu_monitor_json.h | 21 +++-
src/remote/remote_driver.c | 1 +
src/remote/remote_protocol.x | 12 ++-
src/remote_protocol-structs | 9 +
src/rpc/gendispatch.pl | 1 +
src/util/virterror.c | 6 +
tools/virsh.c | 140 ++++++++++++++----
tools/virsh.pod | 40 +++++-
26 files changed, 1099 insertions(+), 88 deletions(-)
--
1.7.7.6
13 years, 1 month
[libvirt] [PATCH] snapshot: fix memory leak on error
by Eric Blake
Leak introduced in commit 0436d32. If we allocate an actions array,
but fail early enough to never consume it with the qemu monitor
transaction call, we leaked memory.
* src/qemu/qemu_driver.c (qemuDomainSnapshotCreateDiskActive):
Free actions array on failure.
---
src/qemu/qemu_driver.c | 2 ++
1 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index b29029e..a214593 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -10132,6 +10132,8 @@ qemuDomainSnapshotCreateDiskActive(virConnectPtr conn,
if (actions) {
if (ret == 0)
ret = qemuMonitorTransaction(priv->mon, actions);
+ else
+ virJSONValueFree(actions);
if (ret < 0) {
/* Transaction failed; undo the changes to vm. */
bool need_unlink = !(flags & VIR_DOMAIN_SNAPSHOT_CREATE_REUSE_EXT);
--
1.7.7.6
13 years, 1 month
[libvirt] [PATCH] qemu_ga: Don't overwrite errors on FSThaw
by Michal Privoznik
We can tell qemuDomainSnapshotFSThaw if we want it to report errors or
not. However, if we don't want to and an error has been already set by
previous qemuReportError() we must keep copy of that error not just a
pointer to it. Otherwise, it get overwritten if FSThaw reports an error.
---
src/qemu/qemu_driver.c | 11 ++++-------
1 files changed, 4 insertions(+), 7 deletions(-)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index dd79973..0880f51 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -9636,16 +9636,13 @@ qemuDomainSnapshotFSThaw(struct qemud_driver *driver,
qemuDomainObjEnterAgent(driver, vm);
if (!report)
- err = virGetLastError();
+ err = virSaveLastError();
thawed = qemuAgentFSThaw(priv->agent);
- if (!report) {
- if (err)
- virResetError(err);
- else
- virResetLastError();
- }
+ if (!report)
+ virSetError(err);
qemuDomainObjExitAgent(driver, vm);
+ virFreeError(err);
return thawed;
}
--
1.7.8.5
13 years, 1 month
[libvirt] [test-API PATCHv2 1/2] utils: Add exception for general test errors
by Peter Krempa
This helper exception helps with reporting test errors that don't
produce a libvirt exception. Eg. comparison of returned and expected
value fails although the api call succeeded.
---
Diff to v1:
-- moved the new exception to the exception module
exception.py | 4 ++++
1 files changed, 4 insertions(+), 0 deletions(-)
diff --git a/exception.py b/exception.py
index 0000aab..d0a772f 100644
--- a/exception.py
+++ b/exception.py
@@ -75,3 +75,7 @@ class CaseConfigfileError(LibvirtException):
class MissingVariable(LibvirtException):
code = 210
message = "Variables missing from env.cfg [variables] section"
+
+class TestError(LibvirtException):
+ code = 211
+ message = "Test failed"
--
1.7.3.4
13 years, 1 month