[libvirt] [PATCHv3 1/2] build: define WITH_INTERFACE for the driver
by Doug Goldstein
Based exclusively on work by Eric Blake in a patch posted with the same
subject. However some modifications related to comments and my plans to
add another backend.
Added WITH_INTERFACE as the only automake variable deciding whether to
build the driver and using WITH_NETCF to identify that we're wanting to
use the netcf library as the backend.
* configure.ac: Added with_interface
* src/interface/netcf_driver.c: Renamed..
* src/interface/interface_backend_netcf.c: ..to this to match storage.
* src/interface/netcf_driver.h: Renamed..
* src/interface/interface_driver.h: ..to this.
* daemon/Makefile.am: Respect WITH_INTERFACE and WITH_NETCF.
* libvirt.spec.in: Add RPM support for --with-interface
---
Change from v2:
* rebase against master
* v2 conditionally ACK'd by Laine if Eric ACK'd it
Change from v1:
* rebased against master
* Fixed copyright header
* Added libvirt.spec.in modification
* Changed virsh -V output
configure.ac | 33 ++++++++++++++++++-
daemon/Makefile.am | 2 +-
daemon/libvirtd.c | 8 ++--
libvirt.spec.in | 13 ++++---
src/Makefile.am | 24 +++++++++++---
.../{netcf_driver.c => interface_backend_netcf.c} | 2 +-
.../{netcf_driver.h => interface_driver.h} | 0
tests/virdrivermoduletest.c | 2 +-
tools/virsh.c | 5 ++-
9 files changed, 67 insertions(+), 22 deletions(-)
rename src/interface/{netcf_driver.c => interface_backend_netcf.c} (99%)
rename src/interface/{netcf_driver.h => interface_driver.h} (100%)
diff --git a/configure.ac b/configure.ac
index 2090e5f..1a44d21 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1948,7 +1948,6 @@ AM_CONDITIONAL([WITH_NETCF], [test "$with_netcf" = "yes"])
AC_SUBST([NETCF_CFLAGS])
AC_SUBST([NETCF_LIBS])
-
AC_ARG_WITH([secrets],
AC_HELP_STRING([--with-secrets], [with local secrets management driver @<:@default=yes@:>@]),[],[with_secrets=yes])
@@ -2787,6 +2786,36 @@ if test "$with_nwfilter" = "yes" ; then
fi
AM_CONDITIONAL([WITH_NWFILTER], [test "$with_nwfilter" = "yes"])
+dnl check if the interface driver should be compiled
+AC_ARG_WITH([interface],
+ AC_HELP_STRING([--with-interface],
+ [with host interface driver @<:@default=check@:>@]), [],
+ [with_interface=check])
+
+dnl Don't compile the interface driver without libvirtd
+if test "$with_libvirtd" = "no" ; then
+ with_interface=no
+fi
+
+dnl The interface driver depends on the netcf library
+if test "$with_interface:$with_netcf" = "check:yes" ; then
+ with_interface=yes
+fi
+
+if test "$with_interface:$with_netcf" = "check:no" ; then
+ with_interface=no
+fi
+
+if test "$with_interface:$with_netcf" = "yes:no" ; then
+ AC_MSG_ERROR([Requested the Interface driver without netcf support])
+fi
+
+if test "$with_interface" = "yes" ; then
+ AC_DEFINE_UNQUOTED([WITH_INTERFACE], [1],
+ [whether the interface driver is enabled])
+fi
+AM_CONDITIONAL([WITH_INTERFACE], [test "$with_interface" = "yes"])
+
dnl libblkid is used by several storage drivers; therefore we probe
dnl for it unconditionally.
AC_ARG_WITH([libblkid],
@@ -3016,7 +3045,7 @@ AC_MSG_NOTICE([ Test: $with_test])
AC_MSG_NOTICE([ Remote: $with_remote])
AC_MSG_NOTICE([ Network: $with_network])
AC_MSG_NOTICE([ Libvirtd: $with_libvirtd])
-AC_MSG_NOTICE([ netcf: $with_netcf])
+AC_MSG_NOTICE([Interface: $with_interface])
AC_MSG_NOTICE([ macvtap: $with_macvtap])
AC_MSG_NOTICE([ virtport: $with_virtualport])
AC_MSG_NOTICE([])
diff --git a/daemon/Makefile.am b/daemon/Makefile.am
index b45349c..3405c67 100644
--- a/daemon/Makefile.am
+++ b/daemon/Makefile.am
@@ -151,7 +151,7 @@ if WITH_NETWORK
libvirtd_LDADD += ../src/libvirt_driver_network.la
endif
-if WITH_NETCF
+if WITH_INTERFACE
libvirtd_LDADD += ../src/libvirt_driver_interface.la
endif
diff --git a/daemon/libvirtd.c b/daemon/libvirtd.c
index 6973df6..1156bd6 100644
--- a/daemon/libvirtd.c
+++ b/daemon/libvirtd.c
@@ -78,8 +78,8 @@
# ifdef WITH_NETWORK
# include "network/bridge_driver.h"
# endif
-# ifdef WITH_NETCF
-# include "interface/netcf_driver.h"
+# ifdef WITH_INTERFACE
+# include "interface/interface_driver.h"
# endif
# ifdef WITH_STORAGE
# include "storage/storage_driver.h"
@@ -382,7 +382,7 @@ static void daemonInitialize(void)
# ifdef WITH_NWFILTER
virDriverLoadModule("nwfilter");
# endif
-# ifdef WITH_NETCF
+# ifdef WITH_INTERFACE
virDriverLoadModule("interface");
# endif
# ifdef WITH_XEN
@@ -404,7 +404,7 @@ static void daemonInitialize(void)
# ifdef WITH_NETWORK
networkRegister();
# endif
-# ifdef WITH_NETCF
+# ifdef WITH_INTERFACE
interfaceRegister();
# endif
# ifdef WITH_STORAGE
diff --git a/libvirt.spec.in b/libvirt.spec.in
index 8c4c08d..853cef7 100644
--- a/libvirt.spec.in
+++ b/libvirt.spec.in
@@ -92,6 +92,7 @@
# A few optional bits off by default, we enable later
%define with_polkit 0%{!?_without_polkit:0}
%define with_capng 0%{!?_without_capng:0}
+%define with_interface 0%{!?_without_interface:0}
%define with_netcf 0%{!?_without_netcf:0}
%define with_udev 0%{!?_without_udev:0}
%define with_hal 0%{!?_without_hal:0}
@@ -200,6 +201,12 @@
%define with_netcf 0%{!?_without_netcf:%{server_drivers}}
%endif
+# interface is the driver that wraps netcf or udev interface management
+# backends in Fedora 18 / RHEL-7 or newer
+%if 0%{?fedora} >= 18 || 0%{?rhel} >= 7
+%define with_interface 0%{!?_without_interface:%{server_drivers}}
+%endif
+
# udev is used to manage host devices in Fedora 12 / RHEL-6 or newer
%if 0%{?fedora} >= 12 || 0%{?rhel} >= 6
%define with_udev 0%{!?_without_udev:%{server_drivers}}
@@ -281,12 +288,6 @@
%define with_nodedev 0
%endif
-%if %{with_netcf}
-%define with_interface 1
-%else
-%define with_interface 0
-%endif
-
%if %{with_storage_fs} || %{with_storage_mpath} || %{with_storage_iscsi} || %{with_storage_lvm} || %{with_storage_disk}
%define with_storage 1
%else
diff --git a/src/Makefile.am b/src/Makefile.am
index 9f27fcf..4ae741b 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -552,8 +552,17 @@ PARALLELS_DRIVER_SOURCES = \
NETWORK_DRIVER_SOURCES = \
network/bridge_driver.h network/bridge_driver.c
-INTERFACE_DRIVER_SOURCES = \
- interface/netcf_driver.h interface/netcf_driver.c
+INTERFACE_DRIVER_SOURCES =
+
+if WITH_INTERFACE
+INTERFACE_DRIVER_SOURCES += \
+ interface/interface_driver.h
+endif
+
+if WITH_NETCF
+INTERFACE_DRIVER_SOURCES += \
+ interface/interface_backend_netcf.c
+endif
SECRET_DRIVER_SOURCES = \
secret/secret_driver.h secret/secret_driver.c
@@ -1021,7 +1030,7 @@ endif
EXTRA_DIST += network/default.xml
-if WITH_NETCF
+if WITH_INTERFACE
if WITH_DRIVER_MODULES
mod_LTLIBRARIES += libvirt_driver_interface.la
else
@@ -1029,10 +1038,13 @@ noinst_LTLIBRARIES += libvirt_driver_interface.la
# Stateful, so linked to daemon instead
#libvirt_la_BUILT_LIBADD += libvirt_driver_interface.la
endif
-libvirt_driver_interface_la_CFLAGS = $(NETCF_CFLAGS) \
- -I$(top_srcdir)/src/conf $(AM_CFLAGS)
+libvirt_driver_interface_la_CFLAGS = -I$(top_srcdir)/src/conf $(AM_CFLAGS)
libvirt_driver_interface_la_LDFLAGS = $(AM_LDFLAGS)
-libvirt_driver_interface_la_LIBADD = $(NETCF_LIBS)
+libvirt_driver_interface_la_LIBADD =
+if WITH_NETCF
+libvirt_driver_interface_la_CFLAGS += $(NETCF_CFLAGS)
+libvirt_driver_interface_la_LIBADD += $(NETCF_LIBS)
+endif
if WITH_DRIVER_MODULES
libvirt_driver_interface_la_LIBADD += ../gnulib/lib/libgnu.la
libvirt_driver_interface_la_LDFLAGS += -module -avoid-version
diff --git a/src/interface/netcf_driver.c b/src/interface/interface_backend_netcf.c
similarity index 99%
rename from src/interface/netcf_driver.c
rename to src/interface/interface_backend_netcf.c
index 6e429db..3b4ee11 100644
--- a/src/interface/netcf_driver.c
+++ b/src/interface/interface_backend_netcf.c
@@ -27,7 +27,7 @@
#include "virterror_internal.h"
#include "datatypes.h"
-#include "netcf_driver.h"
+#include "interface_driver.h"
#include "interface_conf.h"
#include "memory.h"
#include "logging.h"
diff --git a/src/interface/netcf_driver.h b/src/interface/interface_driver.h
similarity index 100%
rename from src/interface/netcf_driver.h
rename to src/interface/interface_driver.h
diff --git a/tests/virdrivermoduletest.c b/tests/virdrivermoduletest.c
index 4d6e91e..8762de4 100644
--- a/tests/virdrivermoduletest.c
+++ b/tests/virdrivermoduletest.c
@@ -79,7 +79,7 @@ mymain(void)
#ifdef WITH_NWFILTER
TEST("nwfilter", NULL);
#endif
-#ifdef WITH_NETCF
+#ifdef WITH_INTERFACE
TEST("interface", NULL);
#endif
#ifdef WITH_QEMU
diff --git a/tools/virsh.c b/tools/virsh.c
index d0b302a..6a7b89d 100644
--- a/tools/virsh.c
+++ b/tools/virsh.c
@@ -2707,8 +2707,11 @@ vshShowVersion(vshControl *ctl ATTRIBUTE_UNUSED)
#ifdef WITH_BRIDGE
vshPrint(ctl, " Bridging");
#endif
-#ifdef WITH_NETCF
+#if defined(WITH_INTERFACE)
vshPrint(ctl, " Interface");
+#if defined(WITH_NETCF)
+ vshPrint(ctl, " netcf");
+#endif
#endif
#ifdef WITH_NWFILTER
vshPrint(ctl, " Nwfilter");
--
1.7.8.6
12 years, 7 months
[libvirt] [PATCH 1/2] virsh: Move daemon to misc since its not a network
by Doug Goldstein
Move the 'Daemon' entry to the Miscellaneous section since its not a
networking driver or component.
---
tools/virsh.c | 6 +++---
1 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/tools/virsh.c b/tools/virsh.c
index 242f789..8592df9 100644
--- a/tools/virsh.c
+++ b/tools/virsh.c
@@ -2696,9 +2696,6 @@ vshShowVersion(vshControl *ctl ATTRIBUTE_UNUSED)
#ifdef WITH_REMOTE
vshPrint(ctl, " Remote");
#endif
-#ifdef WITH_LIBVIRTD
- vshPrint(ctl, " Daemon");
-#endif
#ifdef WITH_NETWORK
vshPrint(ctl, " Network");
#endif
@@ -2747,6 +2744,9 @@ vshShowVersion(vshControl *ctl ATTRIBUTE_UNUSED)
vshPrint(ctl, "\n");
vshPrint(ctl, "%s", _(" Miscellaneous:"));
+#ifdef WITH_LIBVIRTD
+ vshPrint(ctl, " Daemon");
+#endif
#ifdef WITH_NODE_DEVICES
vshPrint(ctl, " Nodedev");
#endif
--
1.7.8.6
12 years, 7 months
[libvirt] [PATCH 0/3] Add further testing of SELinux security driver
by Daniel P. Berrange
This patch series expands on previous work to test the SELinux
security driver via a LD_PRELOAD hack. This time we are testing
the file labelling, by setting/getting private xattrs, instead
of the actual SELinux xattrs.
In doing this I had need to use libattr, and got fed up with
duplicating the usual m4 black magic. Thus I wrote a helper
macro for simplifying library checks, and then a further
macro for the actual libattr check. The configure.ac file
thus only gains two lines
LIBVIRT_CHECK_LIBATTR
...
LIBVIRT_RESULT_LIBATTR
In the long run, I'd like to replace all our existing library
checks with these macros, to try & get our configure.ac script
back to a reasonable level of sanity.
12 years, 7 months
[libvirt] [PATCH v2 0/4] qemu SPICE migration
by Michal Privoznik
With the latest qemu, we are a step closer to seamless migration.
However, libvirt needs to lend a helping hand.
Michal Privoznik (4):
config: Introduce <migration> for SPICE graphics
qemu: Implement new seamless attribute
qemu: Create SPICE migration test
qemu: wait for SPICE to migrate
docs/formatdomain.html.in | 10 ++++
docs/schemas/domaincommon.rng | 11 ++++
src/conf/domain_conf.c | 31 +++++++++++-
src/conf/domain_conf.h | 10 ++++
src/libvirt_private.syms | 2 +
src/qemu/qemu_capabilities.c | 3 +
src/qemu/qemu_capabilities.h | 1 +
src/qemu/qemu_command.c | 14 +++++
src/qemu/qemu_migration.c | 38 +++++++++++++--
src/qemu/qemu_monitor.c | 22 ++++++++
src/qemu/qemu_monitor.h | 3 +
src/qemu/qemu_monitor_json.c | 52 ++++++++++++++++++++
src/qemu/qemu_monitor_json.h | 3 +
.../qemuxml2argv-graphics-spice-migration.args | 7 +++
.../qemuxml2argv-graphics-spice-migration.xml | 36 ++++++++++++++
tests/qemuxml2argvtest.c | 4 ++
16 files changed, 242 insertions(+), 5 deletions(-)
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-migration.args
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-migration.xml
--
1.7.8.6
12 years, 7 months
[libvirt] NFS over RDMA small block DIRECT_IO bug
by Andrew Holway
Hello.
# Avi Kivity avi(a)redhat recommended I copy kvm in on this. It would also seem relevent to libvirt. #
I have a Centos 6.2 server and Centos 6.2 client.
[root@store ~]# cat /etc/exports
/dev/shm 10.149.0.0/16(rw,fsid=1,no_root_squash,insecure) (I have tried with non tempfs targets also)
[root@node001 ~]# cat /etc/fstab
store.ibnet:/dev/shm /mnt nfs rdma,port=2050,defaults 0 0
I wrote a little for loop one liner that dd'd the centos net install image to a file called 'hello' then checksummed that file. Each iteration uses a different block size.
Non DIRECT_IO seems to work fine. DIRECT_IO with 512byte, 1K and 2K block sizes get corrupted.
I want to run my KVM guests on top of NFS over RDMA. My guests cannot create filesystems.
Thanks,
Andrew.
bug report: https://bugzilla.linux-nfs.org/show_bug.cgi?id=228
[root@node001 mnt]# for f in 512 1024 2048 4096 8192 16384 32768 65536 131072; do dd bs="$f" if=CentOS-6.3-x86_64-netinstall.iso of=hello iflag=direct oflag=direct && md5sum hello && rm -f hello; done
409600+0 records in
409600+0 records out
209715200 bytes (210 MB) copied, 62.3649 s, 3.4 MB/s
aadd0ffe3c9dfa35d8354e99ecac9276 hello -- 512 byte block
204800+0 records in
204800+0 records out
209715200 bytes (210 MB) copied, 41.3876 s, 5.1 MB/s
336f6da78f93dab591edc18da81f002e hello -- 1K block
102400+0 records in
102400+0 records out
209715200 bytes (210 MB) copied, 21.1712 s, 9.9 MB/s
f4cefe0a05c9b47ba68effdb17dc95d6 hello -- 2k block
51200+0 records in
51200+0 records out
209715200 bytes (210 MB) copied, 10.9631 s, 19.1 MB/s
690138908de516b6e5d7d180d085c3f3 hello -- 4k block
25600+0 records in
25600+0 records out
209715200 bytes (210 MB) copied, 5.4136 s, 38.7 MB/s
690138908de516b6e5d7d180d085c3f3 hello
12800+0 records in
12800+0 records out
209715200 bytes (210 MB) copied, 3.1448 s, 66.7 MB/s
690138908de516b6e5d7d180d085c3f3 hello
6400+0 records in
6400+0 records out
209715200 bytes (210 MB) copied, 1.77304 s, 118 MB/s
690138908de516b6e5d7d180d085c3f3 hello
3200+0 records in
3200+0 records out
209715200 bytes (210 MB) copied, 1.4331 s, 146 MB/s
690138908de516b6e5d7d180d085c3f3 hello
1600+0 records in
1600+0 records out
209715200 bytes (210 MB) copied, 0.922167 s, 227 MB/s
690138908de516b6e5d7d180d085c3f3 hello
12 years, 7 months
[libvirt] [PATCH] build: force libnl1 if netcf also used libnl1
by Eric Blake
Recent spec file changes ensure that in distro situations, netcf
and libvirt will link against the same libnl in order to avoid
dumping core. But for every-day development, if you are F17 and
have the libnl3-devel headers available, libvirt was blindly
linking against libnl3 even though F17 netcf still links against
libnl1, making testing a self-built binary on F17 impossible.
By making configure a little bit smarter, we can avoid this
situation. I intentionally wrote the test so that we still favor
libnl-3 if netcf is not installed or if we couldn't use ldd
to determine which library netcf linked against.
* configure.ac (LIBNL): Don't probe libnl3 if netcf doesn't use it.
---
Does this patch look safe enough to use? It was sufficient to
let me resume self-tests on my F17 box, where I had intentionally
installed libnl3-devel.
configure.ac | 28 +++++++++++++++++++---------
1 file changed, 19 insertions(+), 9 deletions(-)
diff --git a/configure.ac b/configure.ac
index 47a72b9..7528894 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2902,14 +2902,24 @@ LIBNL_LIBS=""
have_libnl=no
if test "$with_linux" = "yes"; then
- PKG_CHECK_MODULES([LIBNL], [libnl-3.0], [
- have_libnl=yes
- 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])
- LIBNL_CFLAGS="$LIBNL_CFLAGS $LIBNL_ROUTE3_CFLAGS"
- LIBNL_LIBS="$LIBNL_LIBS $LIBNL_ROUTE3_LIBS"
- ], [PKG_CHECK_MODULES([LIBNL], [libnl-1 >= $LIBNL_REQUIRED], [
+ # When linking with netcf, we must ensure that we pick the same version
+ # of libnl that netcf picked. Prefer libnl-3 unless we can prove
+ # netcf linked against libnl-1.
+ ncftool=`which ncftool`
+ case `(ldd "$ncftool") 2>&1` in
+ *libnl.so.1*) ;;
+ *)
+ PKG_CHECK_MODULES([LIBNL], [libnl-3.0], [
+ have_libnl=yes
+ 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])
+ LIBNL_CFLAGS="$LIBNL_CFLAGS $LIBNL_ROUTE3_CFLAGS"
+ LIBNL_LIBS="$LIBNL_LIBS $LIBNL_ROUTE3_LIBS"
+ ], []) ;;
+ esac
+ if test "$have_libnl" = no; then
+ PKG_CHECK_MODULES([LIBNL], [libnl-1 >= $LIBNL_REQUIRED], [
have_libnl=yes
AC_DEFINE_UNQUOTED([HAVE_LIBNL], [1],
[whether the netlink library is available])
@@ -2920,7 +2930,7 @@ if test "$with_linux" = "yes"; then
AC_MSG_ERROR([libnl-devel >= $LIBNL_REQUIRED is required for macvtap support])
fi
])
- ])
+ fi
fi
AM_CONDITIONAL([HAVE_LIBNL], [test "$have_libnl" = "yes"])
--
1.7.11.4
12 years, 7 months
[libvirt] [PATCH] network: fix incorrect VIR_NETWORK_UPDATE_COMMAND_* values
by Laine Stump
These enums originally were put into the flags for virNetworkUpdate,
and when they were moved into their own enum, the numbers weren't
appropriately changed, causing the commands to start with value 2
instead of 1. This causes problems for things like ENUM_IMPL, which
wants a string for every value in the requested range, including those
not used in the enum.
---
include/libvirt/libvirt.h.in | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/include/libvirt/libvirt.h.in b/include/libvirt/libvirt.h.in
index 84ac2d0..0f67cbb 100644
--- a/include/libvirt/libvirt.h.in
+++ b/include/libvirt/libvirt.h.in
@@ -2356,10 +2356,10 @@ int virNetworkUndefine (virNetworkPtr network);
*/
typedef enum {
VIR_NETWORK_UPDATE_COMMAND_NONE = 0, /* (invalid) */
- VIR_NETWORK_UPDATE_COMMAND_MODIFY = 2, /* modify an existing element */
- VIR_NETWORK_UPDATE_COMMAND_DELETE = 3, /* delete an existing element */
- VIR_NETWORK_UPDATE_COMMAND_ADD_LAST = 4, /* add an element at end of list */
- VIR_NETWORK_UPDATE_COMMAND_ADD_FIRST = 5, /* add an element at start of list */
+ VIR_NETWORK_UPDATE_COMMAND_MODIFY = 1, /* modify an existing element */
+ VIR_NETWORK_UPDATE_COMMAND_DELETE = 2, /* delete an existing element */
+ VIR_NETWORK_UPDATE_COMMAND_ADD_LAST = 3, /* add an element at end of list */
+ VIR_NETWORK_UPDATE_COMMAND_ADD_FIRST = 4, /* add an element at start of list */
#ifdef VIR_ENUM_SENTINELS
VIR_NETWORK_UPDATE_COMMAND_LAST
#endif
--
1.7.11.4
12 years, 7 months
[libvirt] [PATCHv2 0/9] new virNetworkUpdate API
by Laine Stump
=====
Changes from V1:
1) implemented Eric's suggested change to make "command"
a separate arg rather than squeezing it into the flags
2) already pushed the first two ACKed patches (not directly related to
new API
3) added new patch at the end implementing updates of dhcp host
entries.
This patchset implements a new API function called virNetworkUpdate
which enables updating certain parts of a libvirt network's definition
without the need to destroy/re-start the network. This is especially
useful, for example, to add/remove hosts from the dhcp static hosts
table, or change portgroup settings.
This was previously discussed in this thread:
https://www.redhat.com/archives/libvir-list/2012-August/msg01535.html
continuing here in September:
https://www.redhat.com/archives/libvir-list/2012-September/msg00328.html
with the final form here:
https://www.redhat.com/archives/libvir-list/2012-September/msg00465.html
In short, the single function has a "section" specifier which tells
the part of the network definition to be updated, a "parentIndex" that
gives the index of the *parent* element containing this section (when
there are multiples - in particular in the case of the <ip> element),
and a fully formed XML element which will be added as-is in the case
of VIR_NETWORK_UPDATE_ADD_* (after checking for a duplicate), used to
search for the specific element to delete in case of
VIR_NETWORK_UPDATE_DELETE, and used both to find the existing element
and replace its current contents in the case of VIR_UPDATE_EXISTING
(this implies that you can't change the change the attribute used for
indexing, e.g. the name of a portgroup, or mac address of a dhcp host
entry).
An example of use: to add a dhcp host entry to network "net", you would do this:
virNetworkUpdate(net, VIR_NETWORK_UPDATE_COMMAND_ADD_LAST,
VIR_NETWORK_SECTION_IP_DHCP_HOST, -1,
"<host mac='00:11:22:33:44:55' ip='192.168.122.5'/>",
VIR_NETWORK_UPDATE_AFFECT_LIVE
| VIR_NETWORK_UPDATE_AFFECT_CONFIG);
To delete that same entry:
virNetworkUpdate(net, VIR_NETWORK_UPDATE_COMMAND_DELETE,
VIR_NETWORK_SECTION_IP_DHCP_HOST, -1,
"<host mac='00:11:22:33:44:55'/>",
VIR_NETWORK_UPDATE_AFFECT_LIVE
| VIR_NETWORK_UPDATE_AFFECT_CONFIG);
If you wanted to force any of these to affect the dhcp host list in
the 3rd <ip> element of the network, you would replace "-1" with "2".
Another example: to modify the portgroup named "engineering" (e.g. to
increase the inbound average bandwidth from 1000 to 2000):
virNetworkUpdate(net, VIR_NETWORK_UPDATE_COMMAND_MODIFY,
VIR_NETWORK_SECTION_PORTGROUP, -1,
"<portgroup name='engineering' default='yes'>"
" <virtualport type='802.1Qbh'>"
" <parameters profileid='test'/>"
" </virtualport>"
" <bandwidth>"
" <inbound average='2000' peak='5000' burst='5120'/>"
" <outbound average='1000' peak='5000' burst='5120'/>"
" </bandwidth>"
"</portgroup>",
VIR_NETWORK_UPDATE_LIVE | VIR_NETWORK_UPDATE_CONFIG)
(note that parentIndex is irrelevant for PORTGROUP, since they are in
the toplevel of <network>, so there aren't multiple instances of
parents. In such cases, the caller *must* set parentIndex to -1 or 0 -
any other value indicates that they don't understand the purpose/usage
of parentIndex, so it must result in an error. Also note that the
above function would fail if it couldn't find an existing portgroup
with name='engineering' (i.e. it wouldn't automatically add a new one).)
Adding support for each of the different sections has been reduced to
a single function that handles the update of a virNetworkDef; all the
logic to determine which virNetworkDef (def or newDef) and to
restart/SIGHUP the appropriate daemons is in higher levels and is 100%
complete. The low level functions aren't yet finished, although the
function for IP_DHCP_HOST is nearly done.
As usual, several of the patches are re-factoring existing code, and a
couple are bugfixes that are only peripherally related:
1/9+2/9 - actual API
3/9 - utility functions to simplify API implementation
4/9 - framework for backend that updates the virNetworkDef
5/9 - refactoring in bridge_driver
6/9 - virNetworkUpdate for bridge_driver
7/9 - virNetworkUpdate for test_driver
8/9 - simple troubleshooting aid - restart dnsmasq/radvd
when libvirtd is restarted (if its process is missing).
9/9 - implement backend for VIR_NETWORK_SECTION_IP_DHCP_HOST
12 years, 7 months
[libvirt] [PATCH] virsh: Fix resource leaks when editing files.
by Peter Krempa
The cleanup path in virsh-edit helper was never reached when the edit
was successful leaking the document in memory as well as the temporary
file.
---
tools/virsh-edit.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/tools/virsh-edit.c b/tools/virsh-edit.c
index 512ac0d..0ed0e8f 100644
--- a/tools/virsh-edit.c
+++ b/tools/virsh-edit.c
@@ -68,6 +68,7 @@ do {
char *doc_edited = NULL;
char *doc_reread = NULL;
const char *msg = NULL;
+ bool edit_success = false;
/* Get the XML configuration of the object. */
doc = (EDIT_GET_XML);
@@ -139,7 +140,7 @@ redefine:
}
}
- break;
+ edit_success = true;
edit_cleanup:
VIR_FREE(doc);
@@ -149,7 +150,9 @@ edit_cleanup:
unlink (tmp);
VIR_FREE(tmp);
}
- goto cleanup;
+
+ if (!edit_success)
+ goto cleanup;
} while (0);
--
1.7.12
12 years, 7 months
[libvirt] [PATCH] util: don't free dmidecode path string before printing it
by Ján Tomko
The path was freed before printing the error message, resulting in:
error : virSysinfoRead:773 : internal error Failed to execute command
(null)
---
src/util/sysinfo.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/src/util/sysinfo.c b/src/util/sysinfo.c
index 92c3539..8ecd1e3 100644
--- a/src/util/sysinfo.c
+++ b/src/util/sysinfo.c
@@ -765,7 +765,6 @@ virSysinfoRead(void) {
}
cmd = virCommandNewArgList(path, "-q", "-t", "0,1,4,17", NULL);
- VIR_FREE(path);
virCommandSetOutputBuffer(cmd, &outbuf);
if (virCommandRun(cmd, NULL) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR,
@@ -796,6 +795,7 @@ virSysinfoRead(void) {
goto no_memory;
cleanup:
+ VIR_FREE(path);
VIR_FREE(outbuf);
virCommandFree(cmd);
--
1.7.8.6
12 years, 7 months