[libvirt] [PATCH 0/7] Fix resource leaks detected by coverity
by Osier Yang
RHBZ: https://bugzilla.redhat.com/show_bug.cgi?id=771021
For more details, please refer to the coverity logs attached
in the BZ.
There is still one error which I don't understand:
Error: RESOURCE_LEAK:
/builddir/build/BUILD/libvirt-0.9.10/src/uml/uml_driver.c:325: alloc_fn: Calling allocation function "virDomainEventNewFromObj".
/builddir/build/BUILD/libvirt-0.9.10/src/conf/domain_event.c:723: alloc_fn: Storage is returned from allocation function "virDomainEventNewFromDef".
/builddir/build/BUILD/libvirt-0.9.10/src/conf/domain_event.c:728: alloc_fn: Storage is returned from allocation function "virDomainEventNew".
/builddir/build/BUILD/libvirt-0.9.10/src/conf/domain_event.c:705: alloc_fn: Storage is returned from allocation function "virDomainEventNewInternal".
/builddir/build/BUILD/libvirt-0.9.10/src/conf/domain_event.c:684: alloc_arg: "virAlloc" allocates memory that is stored into "event".
/builddir/build/BUILD/libvirt-0.9.10/src/util/memory.c:101: alloc_fn: Storage is returned from allocation function "calloc".
/builddir/build/BUILD/libvirt-0.9.10/src/util/memory.c:101: var_assign: Assigning: "*((void **)ptrptr)" = "calloc(1UL, size)".
/builddir/build/BUILD/libvirt-0.9.10/src/conf/domain_event.c:698: return_alloc: Returning allocated memory "event".
/builddir/build/BUILD/libvirt-0.9.10/src/conf/domain_event.c:705: var_assign: Assigning: "event" = "virDomainEventNewInternal(0, id, name, uuid)".
/builddir/build/BUILD/libvirt-0.9.10/src/conf/domain_event.c:713: return_alloc: Returning allocated memory "event".
/builddir/build/BUILD/libvirt-0.9.10/src/conf/domain_event.c:728: return_alloc_fn: Directly returning storage allocated by "virDomainEventNew".
/builddir/build/BUILD/libvirt-0.9.10/src/conf/domain_event.c:723: return_alloc_fn: Directly returning storage allocated by "virDomainEventNewFromDef".
/builddir/build/BUILD/libvirt-0.9.10/src/uml/uml_driver.c:325: var_assign: Assigning: "event" = storage returned from "virDomainEventNewFromObj(dom, 5, 0)".
/builddir/build/BUILD/libvirt-0.9.10/src/uml/uml_driver.c:325: overwrite_var: Overwriting "event" in call "event = virDomainEventNewFromObj(dom, 5, 0)" leaks the storage that "event" points to.
I can't see how it's overwrote. And I'd persuade myself it's
mistake of coverage. But appreciated if anybody could kill
it if I blindly bypass the porblem.
Osier Yang (7):
Coverity: Fix the forward_null error in Python binding codes
Coverity: Fix resource leaks in phyp driver
Coverity: Fix resource leak in esx driver
Coverity: Fix resource leak in xen driver
Coverity: Fix resource leak in test driver
Coverity: Fix resource leak in nodeinfo.c
Coverity: Fix resource leak in virnetlink.c
python/libvirt-override.c | 10 +++++-----
src/esx/esx_vi.c | 4 ++++
src/nodeinfo.c | 1 +
src/phyp/phyp_driver.c | 34 ++++++++++++++++++++--------------
src/test/test_driver.c | 1 +
src/util/virnetlink.c | 9 +++++----
src/xen/xen_hypervisor.c | 5 +++--
src/xen/xen_inotify.c | 1 +
8 files changed, 40 insertions(+), 25 deletions(-)
Regards,
Osier
--
1.7.7.3
12 years, 6 months
[libvirt] [PATCH 2/2] Modify interface qemuDefaultScsiControllerModel().
by Li Zhang
Now, the libvirt sets the default module as 'ibmvscsi'
for pseries, and 'lsi' for other platforms.The controller
model should be set according to controller type, not
only just the platform, otherwise, it will have to set
controller's model externally to select right model
for specific controller type.
This patch is to modify the qemuDefaultScsiControllerModel()
interface to set right controller model according to the
controller's type.
For pseries guest, PCI scsi controller is also supported.
So the default scsi controller model is set according to
the contrller type. If it is PCI scsi controller, the
default model is set as lsi, and if it is VSCSI controller,
the default model is set as ibmvscsi.
Signed-off-by: Li Zhang <zhlcindy(a)linux.vnet.ibm.com>
---
src/conf/domain_conf.c | 4 ++--
src/qemu/qemu_command.c | 51 +++++++++++++++++++++++++++++++----------------
src/qemu/qemu_command.h | 3 +--
src/qemu/qemu_hotplug.c | 2 +-
4 files changed, 38 insertions(+), 22 deletions(-)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 99005b7..44130c7 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -4097,7 +4097,7 @@ virDomainControllerDefParseXML(xmlNodePtr node,
def->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_SPAPRVIO &&
def->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI) {
virDomainReportError(VIR_ERR_INTERNAL_ERROR, "%s",
- _("Controllers must use the 'pci' address type"));
+ _("Controllers must use the 'pci' or 'spapr-vio' address type"));
goto error;
}
@@ -4549,7 +4549,7 @@ virDomainNetDefParseXML(virCapsPtr caps,
def->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_SPAPRVIO &&
def->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI) {
virDomainReportError(VIR_ERR_INTERNAL_ERROR, "%s",
- _("Network interfaces must use 'pci' address type"));
+ _("Network interfaces must use 'pci' or 'spapr-vio' address type"));
goto error;
}
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index bb3be17..d31dae2 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -463,9 +463,8 @@ static int qemuAssignDeviceDiskAliasFixed(virDomainDiskDefPtr disk)
}
static int
-qemuDefaultScsiControllerModel(virDomainDefPtr def) {
- if (STREQ(def->os.arch, "ppc64") &&
- STREQ(def->os.machine, "pseries")) {
+qemuDefaultScsiControllerModel(int ctlType) {
+ if (ctlType == VIR_DOMAIN_CONTROLLER_TYPE_VSCSI) {
return VIR_DOMAIN_CONTROLLER_MODEL_SCSI_IBMVSCSI;
} else {
return VIR_DOMAIN_CONTROLLER_MODEL_SCSI_LSILOGIC;
@@ -479,19 +478,30 @@ qemuAssignDeviceDiskAliasCustom(virDomainDefPtr def,
{
const char *prefix = virDomainDiskBusTypeToString(disk->bus);
int controllerModel = -1;
+ int controllerType = -1;
if (disk->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_DRIVE) {
if (disk->bus == VIR_DOMAIN_DISK_BUS_SCSI) {
- controllerModel =
- virDomainDiskFindControllerModel(def, disk,
- VIR_DOMAIN_CONTROLLER_TYPE_SCSI);
+ controllerType = VIR_DOMAIN_CONTROLLER_TYPE_SCSI;
+ } else if (disk->bus == VIR_DOMAIN_DISK_BUS_VSCSI) {
+ controllerType = VIR_DOMAIN_CONTROLLER_TYPE_VSCSI;
+ } else {
+ qemuReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+ _("Unsupported disk bus type '%s'"),
+ virDomainDiskBusTypeToString(disk->bus));
+ return -1;
}
+ controllerModel =
+ virDomainDiskFindControllerModel(def, disk,
+ controllerType);
+
if (controllerModel == -1 ||
controllerModel == VIR_DOMAIN_CONTROLLER_MODEL_SCSI_AUTO)
- controllerModel = qemuDefaultScsiControllerModel(def);
+ controllerModel = qemuDefaultScsiControllerModel(controllerType);
- if (disk->bus != VIR_DOMAIN_DISK_BUS_SCSI ||
+ if ((disk->bus != VIR_DOMAIN_DISK_BUS_SCSI &&
+ disk->bus != VIR_DOMAIN_DISK_BUS_VSCSI) ||
controllerModel == VIR_DOMAIN_CONTROLLER_MODEL_SCSI_LSILOGIC) {
if (virAsprintf(&disk->info.alias, "%s%d-%d-%d", prefix,
disk->info.addr.drive.controller,
@@ -2173,6 +2183,7 @@ qemuBuildDriveDevStr(virDomainDefPtr def,
const char *bus = virDomainDiskQEMUBusTypeToString(disk->bus);
int idx = virDiskNameToIndex(disk->dst);
int controllerModel;
+ int controllerType;
if (idx < 0) {
qemuReportError(VIR_ERR_INTERNAL_ERROR,
@@ -2236,12 +2247,18 @@ qemuBuildDriveDevStr(virDomainDefPtr def,
}
}
- controllerModel =
- virDomainDiskFindControllerModel(def, disk,
- VIR_DOMAIN_CONTROLLER_TYPE_SCSI);
+ if (disk->bus == VIR_DOMAIN_DISK_BUS_SCSI)
+ controllerType = VIR_DOMAIN_CONTROLLER_TYPE_SCSI;
+ else
+ controllerType = VIR_DOMAIN_CONTROLLER_TYPE_VSCSI;
+
+ controllerModel =
+ virDomainDiskFindControllerModel(def, disk,
+ controllerType);
+
if (controllerModel == -1 ||
controllerModel == VIR_DOMAIN_CONTROLLER_MODEL_SCSI_AUTO)
- controllerModel = qemuDefaultScsiControllerModel(def);
+ controllerModel = qemuDefaultScsiControllerModel(controllerType);
if (controllerModel == VIR_DOMAIN_CONTROLLER_MODEL_SCSI_LSILOGIC) {
if (disk->info.addr.drive.target != 0) {
@@ -2547,8 +2564,7 @@ qemuBuildUSBControllerDevStr(virDomainControllerDefPtr def,
}
char *
-qemuBuildControllerDevStr(virDomainDefPtr domainDef,
- virDomainControllerDefPtr def,
+qemuBuildControllerDevStr(virDomainControllerDefPtr def,
virBitmapPtr qemuCaps,
int *nusbcontroller)
{
@@ -2557,10 +2573,11 @@ qemuBuildControllerDevStr(virDomainDefPtr domainDef,
switch (def->type) {
case VIR_DOMAIN_CONTROLLER_TYPE_SCSI:
+ case VIR_DOMAIN_CONTROLLER_TYPE_VSCSI:
model = def->model;
if (model == -1 ||
model == VIR_DOMAIN_CONTROLLER_MODEL_SCSI_AUTO) {
- model = qemuDefaultScsiControllerModel(domainDef);
+ model = qemuDefaultScsiControllerModel(def->type);
}
switch (model) {
case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_VIRTIO_SCSI:
@@ -4551,7 +4568,7 @@ qemuBuildCommandLine(virConnectPtr conn,
char *devstr;
virCommandAddArg(cmd, "-device");
- if (!(devstr = qemuBuildControllerDevStr(def, cont, qemuCaps, NULL)))
+ if (!(devstr = qemuBuildControllerDevStr(cont, qemuCaps, NULL)))
goto error;
virCommandAddArg(cmd, devstr);
@@ -4570,7 +4587,7 @@ qemuBuildCommandLine(virConnectPtr conn,
virCommandAddArg(cmd, "-device");
char *devstr;
- if (!(devstr = qemuBuildControllerDevStr(def, def->controllers[i], qemuCaps,
+ if (!(devstr = qemuBuildControllerDevStr(def->controllers[i], qemuCaps,
&usbcontroller)))
goto error;
diff --git a/src/qemu/qemu_command.h b/src/qemu/qemu_command.h
index 1eafeb3..13d9cb8 100644
--- a/src/qemu/qemu_command.h
+++ b/src/qemu/qemu_command.h
@@ -97,8 +97,7 @@ char * qemuBuildDriveDevStr(virDomainDefPtr def,
char * qemuBuildFSDevStr(virDomainFSDefPtr fs,
virBitmapPtr qemuCaps);
/* Current, best practice */
-char * qemuBuildControllerDevStr(virDomainDefPtr domainDef,
- virDomainControllerDefPtr def,
+char * qemuBuildControllerDevStr(virDomainControllerDefPtr def,
virBitmapPtr qemuCaps,
int *nusbcontroller);
diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
index 7cf7b90..5b1dee2 100644
--- a/src/qemu/qemu_hotplug.c
+++ b/src/qemu/qemu_hotplug.c
@@ -340,7 +340,7 @@ int qemuDomainAttachPciControllerDevice(struct qemud_driver *driver,
goto cleanup;
}
- if (!(devstr = qemuBuildControllerDevStr(vm->def, controller, priv->qemuCaps, NULL))) {
+ if (!(devstr = qemuBuildControllerDevStr(controller, priv->qemuCaps, NULL))) {
goto cleanup;
}
}
--
1.7.9.5
12 years, 6 months
[libvirt] [PATCH 1/1] Correct indent errors in the function qemuDomainNetsRestart
by Li Zhang
There are three spapces for a indent every line in the
function qemuDomainNetsRestart.
This patch is to correct it.
Signed-off-by: Li Zhang <zhlcindy(a)linux.vnet.ibm.com>
---
src/qemu/qemu_driver.c | 42 +++++++++++++++++++++---------------------
1 file changed, 21 insertions(+), 21 deletions(-)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 86e82d6..bed8edb 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -420,28 +420,28 @@ static void qemuDomainNetsRestart(void *payload,
const void *name ATTRIBUTE_UNUSED,
void *data ATTRIBUTE_UNUSED)
{
- int i;
- virDomainObjPtr vm = (virDomainObjPtr)payload;
- virDomainDefPtr def = vm->def;
-
- virDomainObjLock(vm);
-
- for (i = 0; i < def->nnets; i++) {
- virDomainNetDefPtr net = def->nets[i];
- if (virDomainNetGetActualType(net) == VIR_DOMAIN_NET_TYPE_DIRECT &&
- virDomainNetGetActualDirectMode(net) == VIR_NETDEV_MACVLAN_MODE_VEPA) {
- VIR_DEBUG("VEPA mode device %s active in domain %s. Reassociating.",
- net->ifname, def->name);
- ignore_value(virNetDevMacVLanRestartWithVPortProfile(net->ifname,
- net->mac,
- virDomainNetGetActualDirectDev(net),
- def->uuid,
- virDomainNetGetActualVirtPortProfile(net),
- VIR_NETDEV_VPORT_PROFILE_OP_CREATE));
- }
- }
+ int i;
+ virDomainObjPtr vm = (virDomainObjPtr)payload;
+ virDomainDefPtr def = vm->def;
+
+ virDomainObjLock(vm);
- virDomainObjUnlock(vm);
+ for (i = 0; i < def->nnets; i++) {
+ virDomainNetDefPtr net = def->nets[i];
+ if (virDomainNetGetActualType(net) == VIR_DOMAIN_NET_TYPE_DIRECT &&
+ virDomainNetGetActualDirectMode(net) == VIR_NETDEV_MACVLAN_MODE_VEPA) {
+ VIR_DEBUG("VEPA mode device %s active in domain %s. Reassociating.",
+ net->ifname, def->name);
+ ignore_value(virNetDevMacVLanRestartWithVPortProfile(net->ifname,
+ net->mac,
+ virDomainNetGetActualDirectDev(net),
+ def->uuid,
+ virDomainNetGetActualVirtPortProfile(net),
+ VIR_NETDEV_VPORT_PROFILE_OP_CREATE));
+ }
+ }
+
+ virDomainObjUnlock(vm);
}
/**
--
1.7.9.5
12 years, 6 months
[libvirt] [PATCH] qemu: avoid 32-bit compiler warning
by Eric Blake
On 32-bit platforms, gcc warns that the comparison between a long
and (ULLONG_MAX/1024/1024) is always false; throwing in a type
conversion shuts up the warning.
* src/qemu/qemu_monitor.c (qemuMonitorBlockJob): Shut gcc up.
---
Pushing under the build-breaker rule.
src/qemu/qemu_monitor.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c
index ca1c7aa..0d4319d 100644
--- a/src/qemu/qemu_monitor.c
+++ b/src/qemu/qemu_monitor.c
@@ -2785,7 +2785,7 @@ int qemuMonitorBlockJob(qemuMonitorPtr mon,
modern);
/* Convert bandwidth MiB to bytes */
- if (bandwidth > ULLONG_MAX / 1024 / 1024) {
+ if (bandwidth * 1ULL > ULLONG_MAX / 1024 / 1024) {
qemuReportError(VIR_ERR_OVERFLOW,
_("bandwidth must be less than %llu"),
ULLONG_MAX / 1024 / 1024);
--
1.7.7.6
12 years, 6 months
[libvirt] [PATCH 1/1] Support libnl-3 as well as libnl-1
by Serge Hallyn
configure.ac:
Check for libnl-3. If found, find libnl-route-3. If not found,
do the original check to look for libnl-1.
src/util/virnetlink.c:
support libnl3 api. I could play games to make the patch smaller,
but this would just hide what is actually needing to be done at
the expense of clarity.
src/Makefile.am and daemon/Makefile.am:
Add LIBNL_ROUTE3_{LIBS,CFLAGS}
Unfortunately libnl3 moves netlink/msg.h to /usr/include/libnl3/netlink/msg.h,
which is the reason why the LIBNL_CFLAGS need to be added to a bunch of
places where they weren't needed with libnl1. Those spots probaby don't
actually need to also have LIBNL*LIBS added, but while I may be looking at
it wrong, it seemed right to do so.
I haven't gotten as far as to compile this into a package on
ubuntu, but the source does build with libnl-3 as well as with
libnl-1.
Signed-off-by: Serge Hallyn <serge.hallyn(a)canonical.com>
---
configure.ac | 24 ++++++++++++-----
daemon/Makefile.am | 5 +++-
src/Makefile.am | 25 ++++++++++++------
src/util/virnetlink.c | 70 +++++++++++++++++++++++++++++++++++++++++++++++++
4 files changed, 108 insertions(+), 16 deletions(-)
diff --git a/configure.ac b/configure.ac
index a819898..ab40e1d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2626,19 +2626,29 @@ AM_CONDITIONAL([WITH_VIRTUALPORT], [test "$with_virtualport" = "yes"])
dnl netlink library
+LIBNL_ROUTE3_CFLAGS=""
+LIBNL_ROUTE3_LIBS=""
LIBNL_CFLAGS=""
LIBNL_LIBS=""
have_libnl=no
if test "$with_linux" = "yes"; then
- PKG_CHECK_MODULES([LIBNL], [libnl-1 >= $LIBNL_REQUIRED], [
+ PKG_CHECK_MODULES([LIBNL],[libnl-3.0],[
have_libnl=yes
- AC_DEFINE_UNQUOTED([HAVE_LIBNL], 1, [whether the netlink library is available])
- ], [
- if test "$with_macvtap" = "yes"; then
- AC_MSG_ERROR([libnl-devel >= $LIBNL_REQUIRED is required for macvtap support])
- fi
- ])
+ AC_DEFINE([HAVE_LIBNL3], [1], [Use libnl-3.0])
+ AC_DEFINE([HAVE_LIBNL], [1], [whether the netlink library is available])
+ PKG_CHECK_MODULES([LIBNL_ROUTE3],[libnl-route-3.0])
+ ],
+ PKG_CHECK_MODULES([LIBNL], [libnl-1 >= $LIBNL_REQUIRED], [
+ have_libnl=yes
+ AC_DEFINE_UNQUOTED([HAVE_LIBNL], 1, [whether the netlink library is available])
+ AC_DEFINE_UNQUOTED([HAVE_LIBNL1], 1, [whether the netlink v1 library is available])
+ ], [
+ if test "$with_macvtap" = "yes"; then
+ AC_MSG_ERROR([libnl-devel >= $LIBNL_REQUIRED is required for macvtap support])
+ fi
+ ])
+ )
fi
AM_CONDITIONAL([HAVE_LIBNL], [test "$have_libnl" = "yes"])
diff --git a/daemon/Makefile.am b/daemon/Makefile.am
index 24cce8f..8074803 100644
--- a/daemon/Makefile.am
+++ b/daemon/Makefile.am
@@ -95,6 +95,7 @@ libvirtd_SOURCES = $(DAEMON_SOURCES)
libvirtd_CFLAGS = \
$(LIBXML_CFLAGS) $(GNUTLS_CFLAGS) $(SASL_CFLAGS) \
$(XDR_CFLAGS) $(POLKIT_CFLAGS) $(DBUS_CFLAGS) \
+ $(LIBNL_CFLAGS) $(LIBNL_ROUTE3_CFLAGS) \
$(WARN_CFLAGS) \
$(COVERAGE_CFLAGS) \
-DQEMUD_PID_FILE="\"$(QEMUD_PID_FILE)\"" \
@@ -109,7 +110,9 @@ libvirtd_LDADD = \
$(GNUTLS_LIBS) \
$(SASL_LIBS) \
$(DBUS_LIBS) \
- $(POLKIT_LIBS)
+ $(POLKIT_LIBS) \
+ $(LIBNL_LIBS) \
+ $(LIBNL_ROUTE3_LIBS)
if WITH_DTRACE_PROBES
libvirtd_LDADD += ../src/probes.o
diff --git a/src/Makefile.am b/src/Makefile.am
index e48dfa5..c159c1e 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -576,10 +576,10 @@ libvirt_util_la_SOURCES = \
$(UTIL_SOURCES)
libvirt_util_la_CFLAGS = $(CAPNG_CFLAGS) $(YAJL_CFLAGS) $(LIBNL_CFLAGS) \
$(AM_CFLAGS) $(AUDIT_CFLAGS) $(DEVMAPPER_CFLAGS) \
- $(DBUS_CFLAGS)
+ $(DBUS_CFLAGS) $(LIBNL_ROUTE3_CFLAGS)
libvirt_util_la_LIBADD = $(CAPNG_LIBS) $(YAJL_LIBS) $(LIBNL_LIBS) \
$(THREAD_LIBS) $(AUDIT_LIBS) $(DEVMAPPER_LIBS) \
- $(RT_LIBS) $(DBUS_LIBS)
+ $(RT_LIBS) $(DBUS_LIBS) $(LIBNL_ROUTE3_LIBS)
noinst_LTLIBRARIES += libvirt_conf.la
@@ -809,12 +809,16 @@ endif
libvirt_driver_qemu_la_CFLAGS = $(NUMACTL_CFLAGS) \
$(GNUTLS_CFLAGS) \
$(LIBXML_CFLAGS) \
+ $(LIBNL_CFLAGS) \
+ $(LIBNL_ROUTE3_CFLAGS) \
-I$(top_srcdir)/src/conf $(AM_CFLAGS)
libvirt_driver_qemu_la_LDFLAGS = $(AM_LDFLAGS)
libvirt_driver_qemu_la_LIBADD = $(NUMACTL_LIBS) \
$(CAPNG_LIBS) \
$(GNUTLS_LIBS) \
- $(LIBXML_LIBS)
+ $(LIBXML_LIBS) \
+ $(LIBNL_LIBS) \
+ $(LIBNL_ROUTE3_LIBS)
if WITH_DRIVER_MODULES
libvirt_driver_qemu_la_LIBADD += ../gnulib/lib/libgnu.la
libvirt_driver_qemu_la_LDFLAGS += -module -avoid-version
@@ -840,8 +844,9 @@ noinst_LTLIBRARIES += libvirt_driver_lxc.la
#libvirt_la_BUILT_LIBADD += libvirt_driver_lxc.la
endif
libvirt_driver_lxc_la_CFLAGS = \
+ $(LIBNL_CFLAGS) $(LIBNL_ROUTE3_CFLAGS) \
-I$(top_srcdir)/src/conf $(AM_CFLAGS)
-libvirt_driver_lxc_la_LIBADD = $(CAPNG_LIBS)
+libvirt_driver_lxc_la_LIBADD = $(CAPNG_LIBS) $(LIBNL_LIBS) $(LIBNL_ROUTE3_LIBS)
if WITH_SECDRIVER_SELINUX
libvirt_driver_lxc_la_LIBADD += $(SELINUX_LIBS)
endif
@@ -941,9 +946,10 @@ noinst_LTLIBRARIES += libvirt_driver_network.la
#libvirt_la_BUILT_LIBADD += libvirt_driver_network.la
endif
libvirt_driver_network_la_CFLAGS = \
+ $(LIBNL_CFLAGS) $(LIBNL_ROUTE3_CFLAGS) \
-I$(top_srcdir)/src/conf $(AM_CFLAGS)
if WITH_DRIVER_MODULES
-libvirt_driver_network_la_LIBADD = ../gnulib/lib/libgnu.la
+libvirt_driver_network_la_LIBADD = ../gnulib/lib/libgnu.la $(LIBNL_LIBS) $(LIBNL_ROUTE3_LIBS)
libvirt_driver_network_la_LDFLAGS = -module -avoid-version $(AM_LDFLAGS)
endif
libvirt_driver_network_la_SOURCES = $(NETWORK_DRIVER_SOURCES)
@@ -1086,9 +1092,10 @@ libvirt_la_BUILT_LIBADD += libvirt_driver_nwfilter.la
noinst_LTLIBRARIES += libvirt_driver_nwfilter.la
endif
libvirt_driver_nwfilter_la_CFLAGS = $(LIBPCAP_CFLAGS) \
- -I$(top_srcdir)/src/conf $(AM_CFLAGS)
+ -I$(top_srcdir)/src/conf $(LIBNL_CFLAGS) \
+ $(LIBNL_ROUTE3_CFLAGS) $(AM_CFLAGS)
libvirt_driver_nwfilter_la_LDFLAGS = $(LD_AMFLAGS)
-libvirt_driver_nwfilter_la_LIBADD = $(LIBPCAP_LIBS)
+libvirt_driver_nwfilter_la_LIBADD = $(LIBPCAP_LIBS) $(LIBNL_LIBS) $(LIBNL_ROUTE3_LIBS)
if WITH_DRIVER_MODULES
libvirt_driver_nwfilter_la_LIBADD += ../gnulib/lib/libgnu.la
libvirt_driver_nwfilter_la_LDFLAGS += -module -avoid-version
@@ -1522,7 +1529,7 @@ libvirt_lxc_LDFLAGS = $(WARN_CFLAGS) $(AM_LDFLAGS)
libvirt_lxc_LDADD = $(CAPNG_LIBS) $(YAJL_LIBS) \
$(LIBXML_LIBS) $(NUMACTL_LIBS) $(THREAD_LIBS) \
$(LIBNL_LIBS) $(AUDIT_LIBS) $(DEVMAPPER_LIBS) \
- $(RT_LIBS) $(DBUS_LIBS) \
+ $(RT_LIBS) $(DBUS_LIBS) $(LIBNL_ROUTE3_LIBS) \
../gnulib/lib/libgnu.la
if WITH_DTRACE_PROBES
libvirt_lxc_LDADD += probes.o
@@ -1540,6 +1547,8 @@ libvirt_lxc_CFLAGS = \
$(YAJL_CFLAGS) \
$(AUDIT_CFLAGS) \
$(DBUS_CFLAGS) \
+ $(LIBNL_CFLAGS) \
+ $(LIBNL_ROUTE3_CFLAGS) \
-I$(top_srcdir)/src/conf \
$(AM_CFLAGS)
if HAVE_LIBBLKID
diff --git a/src/util/virnetlink.c b/src/util/virnetlink.c
index b2e9d51..1d3cd2e 100644
--- a/src/util/virnetlink.c
+++ b/src/util/virnetlink.c
@@ -67,7 +67,11 @@ struct _virNetlinkEventSrvPrivate {
virMutex lock;
int eventwatch;
int netlinkfd;
+#ifdef HAVE_LIBNL1
struct nl_handle *netlinknh;
+#else
+ struct nl_sock *netlinksock;
+#endif
/*Events*/
int handled;
size_t handlesCount;
@@ -121,15 +125,31 @@ int virNetlinkCommand(struct nl_msg *nl_msg,
int fd;
int n;
struct nlmsghdr *nlmsg = nlmsg_hdr(nl_msg);
+#ifdef HAVE_LIBNL1
struct nl_handle *nlhandle = nl_handle_alloc();
+#else
+ struct nl_sock *nlsock = nl_socket_alloc();
+#endif
+#ifdef HAVE_LIBNL1
if (!nlhandle) {
+#else
+ if (!nlsock) {
+#endif
virReportSystemError(errno,
+#ifdef HAVE_LIBNL1
"%s", _("cannot allocate nlhandle for netlink"));
+#else
+ "%s", _("cannot allocate nlsock for netlink"));
+#endif
return -1;
}
+#ifdef HAVE_LIBNL1
if (nl_connect(nlhandle, NETLINK_ROUTE) < 0) {
+#else
+ if (nl_connect(nlsock, NETLINK_ROUTE) < 0) {
+#endif
virReportSystemError(errno,
"%s", _("cannot connect to netlink socket"));
rc = -1;
@@ -140,7 +160,11 @@ int virNetlinkCommand(struct nl_msg *nl_msg,
nlmsg->nlmsg_pid = getpid();
+#ifdef HAVE_LIBNL1
nbytes = nl_send_auto_complete(nlhandle, nl_msg);
+#else
+ nbytes = nl_send_auto_complete(nlsock, nl_msg);
+#endif
if (nbytes < 0) {
virReportSystemError(errno,
"%s", _("cannot send to netlink socket"));
@@ -148,7 +172,11 @@ int virNetlinkCommand(struct nl_msg *nl_msg,
goto error;
}
+#ifdef HAVE_LIBNL1
fd = nl_socket_get_fd(nlhandle);
+#else
+ fd = nl_socket_get_fd(nlsock);
+#endif
FD_ZERO(&readfds);
FD_SET(fd, &readfds);
@@ -165,7 +193,11 @@ int virNetlinkCommand(struct nl_msg *nl_msg,
goto error;
}
+#ifdef HAVE_LIBNL1
*respbuflen = nl_recv(nlhandle, &nladdr, respbuf, NULL);
+#else
+ *respbuflen = nl_recv(nlsock, &nladdr, respbuf, NULL);
+#endif
if (*respbuflen <= 0) {
virReportSystemError(errno,
"%s", _("nl_recv failed"));
@@ -178,7 +210,11 @@ error:
*respbuflen = 0;
}
+#ifdef HAVE_LIBNL1
nl_handle_destroy(nlhandle);
+#else
+ nl_socket_free(nlsock);
+#endif
return rc;
}
@@ -233,7 +269,11 @@ virNetlinkEventCallback(int watch,
int i, length;
bool handled = false;
+#ifdef HAVE_LIBNL1
length = nl_recv(srv->netlinknh, &peer, &msg, &creds);
+#else
+ length = nl_recv(srv->netlinksock, &peer, &msg, &creds);
+#endif
if (length == 0)
return;
@@ -284,8 +324,13 @@ virNetlinkEventServiceStop(void)
return 0;
virNetlinkEventServerLock(srv);
+#ifdef HAVE_LIBNL1
nl_close(srv->netlinknh);
nl_handle_destroy(srv->netlinknh);
+#else
+ nl_close(srv->netlinksock);
+ nl_socket_free(srv->netlinksock);
+#endif
virEventRemoveHandle(srv->eventwatch);
/* free any remaining clients on the list */
@@ -346,21 +391,37 @@ virNetlinkEventServiceStart(void)
virNetlinkEventServerLock(srv);
/* Allocate a new socket and get fd */
+#ifdef HAVE_LIBNL1
srv->netlinknh = nl_handle_alloc();
+#else
+ srv->netlinksock = nl_socket_alloc();
+#endif
+#ifdef HAVE_LIBNL1
if (!srv->netlinknh) {
+#else
+ if (!srv->netlinksock) {
+#endif
virReportSystemError(errno,
"%s", _("cannot allocate nlhandle for virNetlinkEvent server"));
goto error_locked;
}
+#ifdef HAVE_LIBNL1
if (nl_connect(srv->netlinknh, NETLINK_ROUTE) < 0) {
+#else
+ if (nl_connect(srv->netlinksock, NETLINK_ROUTE) < 0) {
+#endif
virReportSystemError(errno,
"%s", _("cannot connect to netlink socket"));
goto error_server;
}
+#ifdef HAVE_LIBNL1
fd = nl_socket_get_fd(srv->netlinknh);
+#else
+ fd = nl_socket_get_fd(srv->netlinksock);
+#endif
if (fd < 0) {
virReportSystemError(errno,
@@ -368,7 +429,11 @@ virNetlinkEventServiceStart(void)
goto error_server;
}
+#ifdef HAVE_LIBNL1
if (nl_socket_set_nonblocking(srv->netlinknh)) {
+#else
+ if (nl_socket_set_nonblocking(srv->netlinksock)) {
+#endif
virReportSystemError(errno, "%s",
_("cannot set netlink socket nonblocking"));
goto error_server;
@@ -391,8 +456,13 @@ virNetlinkEventServiceStart(void)
error_server:
if (ret < 0) {
+#ifdef HAVE_LIBNL1
nl_close(srv->netlinknh);
nl_handle_destroy(srv->netlinknh);
+#else
+ nl_close(srv->netlinksock);
+ nl_socket_free(srv->netlinksock);
+#endif
}
error_locked:
virNetlinkEventServerUnlock(srv);
--
1.7.9.5
12 years, 6 months
[libvirt] [PATCH] build: fix build on cygwin
by Eric Blake
Now that tests are built unconditionally, this cases 'make' to fail
on cygwin (previously, only 'make check' failed), since on cygwin,
<rpc/rpc.h> lives in a different directory than /usr/include.
* tests/Makefile.am (virnetmessagetest_CFLAGS): Find rpc headers.
---
Pushing under the build-breaker rule.
tests/Makefile.am | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/tests/Makefile.am b/tests/Makefile.am
index c4d550f..fbb756a 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -458,7 +458,8 @@ endif
virnetmessagetest_SOURCES = \
virnetmessagetest.c testutils.h testutils.c
-virnetmessagetest_CFLAGS = -Dabs_builddir="\"$(abs_builddir)\"" $(AM_CFLAGS)
+virnetmessagetest_CFLAGS = -Dabs_builddir="\"$(abs_builddir)\"" \
+ $(XDR_CFLAGS) $(AM_CFLAGS)
virnetmessagetest_LDADD = ../src/libvirt-net-rpc.la $(LDADDS)
virnetsockettest_SOURCES = \
--
1.7.7.6
12 years, 6 months
[libvirt] [PATCH v6 0/9] Add basic driver for Parallels Virtuozzo Server
by Dmitry Guryanov
Parallels Virtuozzo Server is a cloud-ready virtualization
solution that allows users to simultaneously run multiple virtual
machines and containers on the same physical server.
Current name of this product is Parallels Server Bare Metal and
more information about it can be found here -
http://www.parallels.com/products/server/baremetal/sp/.
This driver will work with PVS version 6.0 , beta version
scheduled at 2012 Q2.
Dmitry Guryanov (9):
pvs: add driver skeleton
util: add functions for interating over json object
pvs: add functions to list domains and get info
pvs: implement functions for domain life cycle management
pvs: get info about serial ports
pvs: add support of VNC remote display
pvs: implement virDomainDefineXML operation for existing domains
pvs: add storage driver
pvs: implement VM creation
AUTHORS | 1 +
cfg.mk | 1 +
configure.ac | 23 +
docs/drvpvs.html.in | 28 +
include/libvirt/virterror.h | 1 +
libvirt.spec.in | 7 +
mingw32-libvirt.spec.in | 6 +
po/POTFILES.in | 4 +
src/Makefile.am | 23 +
src/conf/domain_conf.c | 3 +-
src/conf/domain_conf.h | 1 +
src/driver.h | 1 +
src/libvirt.c | 12 +
src/pvs/pvs_driver.c | 1309 ++++++++++++++++++++++++++++++++++++++
src/pvs/pvs_driver.h | 75 +++
src/pvs/pvs_storage.c | 1458 +++++++++++++++++++++++++++++++++++++++++++
src/pvs/pvs_utils.c | 131 ++++
src/util/json.c | 30 +
src/util/json.h | 4 +
src/util/virterror.c | 3 +
20 files changed, 3120 insertions(+), 1 deletions(-)
create mode 100644 docs/drvpvs.html.in
create mode 100644 src/pvs/pvs_driver.c
create mode 100644 src/pvs/pvs_driver.h
create mode 100644 src/pvs/pvs_storage.c
create mode 100644 src/pvs/pvs_utils.c
12 years, 6 months
[libvirt] [PATCH] util: remove error log from stub versions of virNetlinkEventServiceStart|Stop
by Laine Stump
These two functions are called from main() on all platforms, and
always return success on platforms that don't support libnl. They
still log an error message, though, which doesn't make sense - they
should just be NOPs on those platforms.
---
src/util/virnetlink.c | 2 --
1 file changed, 2 deletions(-)
diff --git a/src/util/virnetlink.c b/src/util/virnetlink.c
index a249e94..34d56ef 100644
--- a/src/util/virnetlink.c
+++ b/src/util/virnetlink.c
@@ -615,7 +615,6 @@ int virNetlinkCommand(struct nl_msg *nl_msg ATTRIBUTE_UNUSED,
*/
int virNetlinkEventServiceStop(void)
{
- netlinkError(VIR_ERR_INTERNAL_ERROR, "%s", _(unsupported));
return 0;
}
@@ -625,7 +624,6 @@ int virNetlinkEventServiceStop(void)
*/
int virNetlinkEventServiceStart(void)
{
- netlinkError(VIR_ERR_INTERNAL_ERROR, "%s", _(unsupported));
return 0;
}
--
1.7.10
12 years, 6 months
[libvirt] [PATCH - 2 alternatives] util: fix libvirtd startup failure due to netlink error
by Laine Stump
The two following patches fix the same problem (described in
https://bugzilla.redhat.com/show_bug.cgi?id=816465) in two alternate
ways - one by retrying the failing operation after a delay, the other by
using knowledge of how libnl works internally to artificially "reserve"
a particular address so libnl doesn't attempt to bind to it.
You might think that libnl is the right place to fix this bug.
Unfortunately, that isn't possible, because it would involve changing
libnl's API - currently libnl decides what address to use for future
binds of a netlink socket at the time nl_handle_alloc() is called, but
doesn't actually attempt to bind it. Later, during nl_connect(), it
calls bind() with the address it had earlier decided. It would be nice
if we could just retry the bind with a different address when the first
attempt failed, but libnl allows client applications to retrieve the
bind address *before nl_connect() is called*, so an application may have
already gotten the address prior to calling nl_connect(), and changing
it would render the applications information incorrect.
So the best we can do (for now at least) is work around the problem, and
these are two possible workarounds.
12 years, 6 months
[libvirt] [PATCH] [libvirt-test-API] Use YABOOT instead of ISOLINUX to create bootable ISO.
by Lin Qing
Yaboot is the bootloader of PowerPC (ISOLINUX on AMD64/x86 systems, yaboot on PowerPC),
so should change the yaboot.conf firstly,then use mkiso command to create bootable ISO.
Signed-off-by: Qing Lin<qinglbj(a)linux.vnet.ibm.com>
---
utils/ksiso.sh | 57 ++++++++++++++++++++++++++++++++++---------------------
1 files changed, 35 insertions(+), 22 deletions(-)
diff --git a/utils/ksiso.sh b/utils/ksiso.sh
index 7cf30fc..8b3186c 100755
--- a/utils/ksiso.sh
+++ b/utils/ksiso.sh
@@ -23,28 +23,41 @@ cp -rf ${boot_iso_dir}/* $custom_iso_dir
chmod -R 777 ${custom_iso_dir}/*
umount $boot_iso_dir
-echo "- copy kickstart to custom work directory"
-cp $kscfg $custom_iso_dir
-
-echo "- edit isolinux.cfg and add kickstart entry"
-WORKING_ISO="${custom_iso_dir}/isolinux/isolinux.cfg"
-
-echo "label custom_ks
- kernel vmlinuz $kernel_args
- append initrd=initrd.img ks=cdrom:/$kscfg ramdisk_size=20000">> $WORKING_ISO
-
-# change default boot target and timeout
-DEFAULT_LINE=`cat $WORKING_ISO | grep default | head -1`
-TIMEOUT_LINE=`cat $WORKING_ISO | grep timeout | head -1`
-
-cat $WORKING_ISO | sed "s/${DEFAULT_LINE}/default custom_ks/" | sed "s/${TIMEOUT_LINE}/timeout 5/"> isocfgtmp
-
-mv -f isocfgtmp $WORKING_ISO
-
-# cd to custom_iso_dir, otherwise mkisofs seems to bomb...
-cd $custom_iso_dir
-mkisofs -R -b isolinux/isolinux.bin -no-emul-boot -boot-load-size 4 -boot-info-table -o $cwd/$custom_iso .
-
+vlmid=`isoinfo -d -i $boot_iso |grep 'Volume id:'`
+vlmid=${vlmid#"Volume id: "}
+if [ -n "`echo $vlmid|grep ppc`" ];then
+ echo "- edit yaboot.conf and add kickstart entry"
+ WORKING_ISO="${custom_iso_dir}/etc/yaboot.conf"
+ # change timeout and add kickstart entry
+ TIMEOUT_LINE=`cat $WORKING_ISO | grep timeout | head -1`
+ APPEND_LINE=`cat $WORKING_ISO | grep append | head -1`
+ cat $WORKING_ISO | sed "s#${TIMEOUT_LINE}#timeout=5#" | sed "s#${APPEND_LINE}#append= \"root=live:CDLABEL=$vlmid ks=cdrom:/$kscfg \"#"> isocfgtmp
+ mv -f isocfgtmp $WORKING_ISO
+ cd $custom_iso_dir
+ mkisofs -R -V "$vlmid" -sysid PPC -chrp-boot -U -prep-boot ppc/chrp/yaboot -hfs-bless ppc/mac -no-desktop -allow-multidot -volset 4 -volset-size 1 -volset-seqno 1 -hfs-volid 4 -o $cwd/$custom_iso .
+else
+ echo "- copy kickstart to custom work directory"
+ cp $kscfg $custom_iso_dir
+
+ echo "- edit isolinux.cfg and add kickstart entry"
+ WORKING_ISO="${custom_iso_dir}/isolinux/isolinux.cfg"
+
+ echo "label custom_ks
+ kernel vmlinuz $kernel_args
+ append initrd=initrd.img ks=cdrom:/$kscfg ramdisk_size=20000">> $WORKING_ISO
+
+ # change default boot target and timeout
+ DEFAULT_LINE=`cat $WORKING_ISO | grep default | head -1`
+ TIMEOUT_LINE=`cat $WORKING_ISO | grep timeout | head -1`
+
+ cat $WORKING_ISO | sed "s/${DEFAULT_LINE}/default custom_ks/" | sed "s/${TIMEOUT_LINE}/timeout 5/"> isocfgtmp
+
+ mv -f isocfgtmp $WORKING_ISO
+
+ # cd to custom_iso_dir, otherwise mkisofs seems to bomb...
+ cd $custom_iso_dir
+ mkisofs -R -b isolinux/isolinux.bin -no-emul-boot -boot-load-size 4 -boot-info-table -o $cwd/$custom_iso .
+fi
EXITVAL=$?
if [ $EXITVAL -ne '0' ] ; then
echo -e "\n mkisofs exited with $EXITVAL!"
--
12 years, 6 months