[libvirt] [PATCH 1/2] daemon: Use $(NULL) for libvird_admin's flags
This makes it consistent with the other FLAGS in this file and reduced clutter in the diff when adding new entries. --- daemon/Makefile.am | 8 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/daemon/Makefile.am b/daemon/Makefile.am index 59bc4d4..be1b5a9 100644 --- a/daemon/Makefile.am +++ b/daemon/Makefile.am @@ -136,14 +136,14 @@ libvirtd_admin_la_CFLAGS = \ $(PIE_CFLAGS) \ $(WARN_CFLAGS) \ $(LIBXML_CFLAGS)\ - $(COVERAGE_CFLAGS) - + $(COVERAGE_CFLAGS) \ + $(NULL) libvirtd_admin_la_LDFLAGS = \ $(PIE_LDFLAGS) \ $(RELRO_LDFLAGS)\ $(COVERAGE_LDFLAGS) \ - $(NO_INDIRECT_LDFLAGS) - + $(NO_INDIRECT_LDFLAGS) \ + $(NULL) libvirtd_admin_la_LIBADD = \ ../src/libvirt-admin.la -- 2.1.4 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH 2/2] libvirt-admin: Generate symbols file
Since we're linking this into libvirtd we need some symbols to be public but not part of the public API so mark them as LIBVIRT_ADMIN_PRIVATE_VERSION as we do with libvirt. Making all other symbols local makes sure we don't accidentally leak unwanted ones. --- configure.ac | 2 +- src/Makefile.am| 20 ++-- src/libvirt_admin.syms | 18 -- src/libvirt_admin_private.syms | 14 ++ src/libvirt_admin_public.syms | 18 ++ 5 files changed, 51 insertions(+), 21 deletions(-) delete mode 100644 src/libvirt_admin.syms create mode 100644 src/libvirt_admin_private.syms create mode 100644 src/libvirt_admin_public.syms diff --git a/configure.ac b/configure.ac index 46c80ce..9066ed6 100644 --- a/configure.ac +++ b/configure.ac @@ -2346,7 +2346,7 @@ WIN32_EXTRA_CFLAGS= dnl libvirt.syms is generated in builddir, but libvirt_qemu.syms is in git; dnl hence the asymmetric naming of these two symbol files. LIBVIRT_SYMBOL_FILE=libvirt.syms -LIBVIRT_ADMIN_SYMBOL_FILE='$(srcdir)/libvirt_admin.syms' +LIBVIRT_ADMIN_SYMBOL_FILE=libvirt_admin.syms LIBVIRT_LXC_SYMBOL_FILE='$(srcdir)/libvirt_lxc.syms' LIBVIRT_QEMU_SYMBOL_FILE='$(srcdir)/libvirt_qemu.syms' MSCOM_LIBS= diff --git a/src/Makefile.am b/src/Makefile.am index c4d49a5..9667292 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -540,7 +540,7 @@ check-drivername: $(AM_V_GEN)$(PERL) $(srcdir)/check-drivername.pl \ $(srcdir)/driver.h \ $(srcdir)/libvirt_public.syms \ - $(srcdir)/libvirt_admin.syms \ + $(srcdir)/libvirt_admin_public.syms \ $(srcdir)/libvirt_qemu.syms \ $(srcdir)/libvirt_lxc.syms @@ -2010,8 +2010,9 @@ EXTRA_DIST += \ libvirt_public.syms \ libvirt_lxc.syms\ libvirt_qemu.syms \ - libvirt_admin.syms \ + libvirt_admin_public.syms \ $(SYM_FILES)\ + $(ADMIN_SYM_FILES) \ $(NULL) BUILT_SOURCES += $(GENERATED_SYM_FILES) @@ -2038,6 +2039,19 @@ libvirt.syms: libvirt_public.syms $(USED_SYM_FILES) \ chmod a-w $@-tmp \ mv $@-tmp $@ +libvirt_admin.syms: libvirt_admin_public.syms $(ADMIN_SYM_FILES) \ + $(top_builddir)/config.status + $(AM_V_GEN)rm -f $@-tmp $@ ; \ + printf '# WARNING: generated from the following:\n# $^\n\n' $@-tmp \ + cat $(srcdir)/libvirt_admin_public.syms $@-tmp \ + printf '\n\n# Private symbols\n\n' $@-tmp \ + printf 'LIBVIRT_ADMIN_PRIVATE_$(VERSION) {\n\n' $@-tmp \ + printf 'global:\n\n' $@-tmp \ + cat $(ADMIN_SYM_FILES) $@-tmp \ + printf '\n\nlocal:\n*;\n\n};' $@-tmp \ + chmod a-w $@-tmp \ + mv $@-tmp libvirt_admin.syms + lib_LTLIBRARIES += libvirt-admin.la libvirt_admin_la_SOURCES = \ libvirt-admin.c \ @@ -2077,6 +2091,8 @@ libvirt_admin_la_LIBADD += \ $(SASL_LIBS)\ $(GNUTLS_LIBS) +ADMIN_SYM_FILES = $(srcdir)/libvirt_admin_private.syms + if WITH_DTRACE_PROBES libvirt_admin_la_LIBADD += libvirt_probes.lo endif WITH_DTRACE_PROBES diff --git a/src/libvirt_admin.syms b/src/libvirt_admin.syms deleted file mode 100644 index d9e3c0b..000 --- a/src/libvirt_admin.syms +++ /dev/null @@ -1,18 +0,0 @@ -# -# Officially exported symbols, for which header -# file definitions are installed in /usr/include/libvirt -# from libvirt-admin.h -# -# Versions here are *fixed* to match the libvirt version -# at which the symbol was introduced. This ensures that -# a new client app requiring symbol foo() can't accidentally -# run with old libvirt-admin.so not providing foo() - the global -# soname version info can't enforce this since we never -# change the soname -# -LIBVIRT_ADMIN_1.3.0 { -global: -virAdmConnectOpen; -virAdmConnectClose; -virAdmConnectRef; -}; diff --git a/src/libvirt_admin_private.syms b/src/libvirt_admin_private.syms new file mode 100644 index 000..401cd4e --- /dev/null +++ b/src/libvirt_admin_private.syms @@ -0,0 +1,14 @@ +# +# General private symbols for libvirt_admin. Add symbols here, and see +# Makefile.am for more details. +# +# Keep this file sorted by header name, then by symbols with each header. +# + +# admin/admin_protocol.x +xdr_admin_connect_open_args; + +# Let emacs know we want case-insensitive sorting +# Local Variables: +# sort-fold-case: t +# End: diff --git a/src/libvirt_admin_public.syms b/src/libvirt_admin_public.syms new file mode 100644 index 000..d9e3c0b --- /dev/null +++ b/src/libvirt_admin_public.syms @@ -0,0 +1,18 @@ +# +# Officially exported symbols, for which header +# file definitions are installed in /usr/include/libvirt +# from libvirt-admin.h +# +# Versions here are *fixed* to match the libvirt version +# at which the symbol was
Re: [libvirt] [PATCH] util: Remove empty resource partition created by libvirt
Daniel P. Berrange berra...@redhat.com writes: On Wed, Aug 12, 2015 at 11:09:12AM +0530, Nikunj A Dadhania wrote: Hi Daniel, Daniel P. Berrange berra...@redhat.com writes: On Tue, Aug 11, 2015 at 04:57:15PM +0530, Nikunj A Dadhania wrote: The default resource partition is created in the domain start path if it is not existing. Even when libvirtd is stopped after shutting down all domains, the resource partition still exists. The patch adds code to removes the default resource partition in the cgroup removal path of the domain. If the default resource partition is found to have no child cgroup, the default resource partition will be removed. Moreover, the code does not remove the user provided resource partitions. Signed-off-by: Nikunj A Dadhania nik...@linux.vnet.ibm.com I don't think we want to be doing this. In non-systemd hosts this will be deleting the heirarchy that the sysadmin manually pre-created for their VMs. In a systemd host it will also end up deleting slices that were created by systemd. AFAIU, there are three cases here: 1) User created resource partition, for example /production/foo As this is created by user, we should not touch them. And my patch does not remove them 2) systemd created /machine.slice If not libvirt, should systemd clean this up when the libvirtd service is stopped ? Currently, my patch does remove this when its found empty It isn't libvirtd's job to delete /machine.slice - systemd will periodically prune empty slices itself. Before runnning machine.slice . ├── blkio │ ├── system.slice │ └── user.slice ├── cpu - cpu,cpuacct ├── cpuacct - cpu,cpuacct ├── cpu,cpuacct │ ├── system.slice │ └── user.slice ├── cpuset ├── devices │ ├── system.slice │ └── user.slice ├── freezer ├── hugetlb ├── memory │ ├── system.slice │ └── user.slice ├── net_cls - net_cls,net_prio ├── net_cls,net_prio ├── net_prio - net_cls,net_prio ├── perf_event └── systemd ├── system.slice └── user.slice After starting systemd-machined: . ├── blkio │ ├── machine.slice │ ├── system.slice │ └── user.slice ├── cpu - cpu,cpuacct ├── cpuacct - cpu,cpuacct ├── cpu,cpuacct │ ├── machine.slice │ ├── system.slice │ └── user.slice ├── cpuset ├── devices │ ├── machine.slice │ ├── system.slice │ └── user.slice ├── freezer ├── hugetlb ├── memory │ ├── machine.slice │ ├── system.slice │ └── user.slice ├── net_cls - net_cls,net_prio ├── net_cls,net_prio ├── net_prio - net_cls,net_prio ├── perf_event └── systemd ├── machine.slice ├── system.slice └── user.slice systemd leaves out cpuset/freezer. So these are basically created by libvirt and not by systemd. When I went through systemd code, it seems cpuset/freezer is disabled on purpose. systemd/src/core/main.c static int initialize_join_controllers(void) { /* By default, mount cpu + cpuacct together, and net_cls * + net_prio. We'd like to add cpuset to the mix, but * cpuset doesn't really work for groups with no initialized * attributes. */ Some more details here: http://www.freedesktop.org/wiki/Software/systemd/ControlGroupInterface/ Note that the number of cgroup attributes currently exposed as unit properties is limited. This will be extended later on, as their kernel interfaces are cleaned up. For example cpuset or freezer are currently not exposed at all due to the broken inheritance semantics of the kernel logic. 3) libvirt created /machine As this was created manually by libvirt, should we delete it here in libvirt daemon No, you can't assume /machine is created by libvirtd - it could have been created by the user, just like case 3. I was thinking of an idea to create a stub directory libvirt-owned in the machine/machine.slice if libvirt created this directory. So while on the exit path if we find the directory empty and is owned by libvirt, we can clean that up. Regards, Nikunj -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH] docs: Drop unused rule for internals/%.html.tmp target
We're using the %.html.tmp for all html files now so drop the unused one and rather make sure the needed directory exists. This fixes build failures as described in https://www.redhat.com/archives/libvir-list/2015-August/msg00603.html --- configure.ac | 1 + docs/Makefile.am | 9 - 2 files changed, 1 insertion(+), 9 deletions(-) diff --git a/configure.ac b/configure.ac index 9066ed6..749dbb7 100644 --- a/configure.ac +++ b/configure.ac @@ -2774,6 +2774,7 @@ AC_DEFINE_UNQUOTED([isbase64],[libvirt_gl_isbase64],[Hack to avoid symbol clash] AC_DEFINE_UNQUOTED([base64_encode],[libvirt_gl_base64_encode],[Hack to avoid symbol clash]) AC_DEFINE_UNQUOTED([base64_encode_alloc],[libvirt_gl_base64_encode_alloc],[Hack to avoid symbol clash]) +AC_CONFIG_COMMANDS([mkdir], [$MKDIR_P docs/internals]) AC_CONFIG_FILES([run], [chmod +x,-w run]) AC_CONFIG_FILES([\ diff --git a/docs/Makefile.am b/docs/Makefile.am index daf37b6..563baca 100644 --- a/docs/Makefile.am +++ b/docs/Makefile.am @@ -218,15 +218,6 @@ $(srcdir)/hvsupport.html.in: $(srcdir)/hvsupport.pl $(api_DATA) \ %.png: %.fig convert -rotate 90 $ $@ -internals/%.html.tmp: internals/%.html.in subsite.xsl page.xsl sitemap.html.in - @if [ -x $(XSLTPROC) ] ; then \ - echo Generating $@; \ - $(MKDIR_P) internals; \ - name=`echo $@ | sed -e 's/.tmp//'`; \ - $(XSLTPROC) --stringparam pagename $$name --nonet \ - $(top_srcdir)/docs/subsite.xsl $ $@ \ - || { rm $@ exit 1; }; fi - %.html.tmp: %.html.in site.xsl page.xsl sitemap.html.in $(acl_generated) @if [ -x $(XSLTPROC) ] ; then \ echo Generating $@; \ -- 2.1.4 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] virConfWalk: fix the inconsistent name
On 19.08.2015 04:36, Cao jin wrote: Fix inconsistency between function description and actual parameter name. Signed-off-by: Cao jin caoj.f...@cn.fujitsu.com --- src/util/virconf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/util/virconf.c b/src/util/virconf.c index ab98c5c..9f2d116 100644 --- a/src/util/virconf.c +++ b/src/util/virconf.c @@ -930,7 +930,7 @@ virConfSetValue(virConfPtr conf, * virConfWalk: * @conf: a configuration file handle * @callback: the function to call to process each entry - * @data: obscure data passed to callback + * @opaque: obscure data passed to callback * * Walk over all entries of the configuration file and run the callback * for each with entry name, value and the obscure data. ACKed and pushed. Michal -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [libvirt-php PATCH] added missing libvirt 1.2.8 constants
On 15.08.2015 13:50, Eric Schultz wrote: --- src/libvirt-php.c | 24 +++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/src/libvirt-php.c b/src/libvirt-php.c index f0a2167..8588128 100644 --- a/src/libvirt-php.c +++ b/src/libvirt-php.c @@ -1216,6 +1216,8 @@ PHP_MINIT_FUNCTION(libvirt) /* XML contants */ REGISTER_LONG_CONSTANT(VIR_DOMAIN_XML_SECURE, 1, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT(VIR_DOMAIN_XML_INACTIVE, 2, CONST_CS | CONST_PERSISTENT); +REGISTER_LONG_CONSTANT(VIR_DOMAIN_XML_UPDATE_CPU, 4, CONST_CS | CONST_PERSISTENT); +REGISTER_LONG_CONSTANT(VIR_DOMAIN_XML_MIGRATABLE, 8, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT(VIR_NODE_CPU_STATS_ALL_CPUS, VIR_NODE_CPU_STATS_ALL_CPUS, CONST_CS | CONST_PERSISTENT); @@ -1227,6 +1229,7 @@ PHP_MINIT_FUNCTION(libvirt) REGISTER_LONG_CONSTANT(VIR_DOMAIN_SHUTDOWN, 4, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT(VIR_DOMAIN_SHUTOFF,5, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT(VIR_DOMAIN_CRASHED,6, CONST_CS | CONST_PERSISTENT); +REGISTER_LONG_CONSTANT(VIR_DOMAIN_PMSUSPENDED,7, CONST_CS | CONST_PERSISTENT); /* Volume constants */ REGISTER_LONG_CONSTANT(VIR_STORAGE_VOL_RESIZE_ALLOCATE,1, CONST_CS | CONST_PERSISTENT); @@ -1270,6 +1273,7 @@ PHP_MINIT_FUNCTION(libvirt) /* Memory constants */ REGISTER_LONG_CONSTANT(VIR_MEMORY_VIRTUAL,1, CONST_CS | CONST_PERSISTENT); +REGISTER_LONG_CONSTANT(VIR_MEMORY_PHYSICAL, 2, CONST_CS | CONST_PERSISTENT); /* Version checking constants */ REGISTER_LONG_CONSTANT(VIR_VERSION_BINDING, VIR_VERSION_BINDING,CONST_CS | CONST_PERSISTENT); @@ -1317,7 +1321,13 @@ PHP_MINIT_FUNCTION(libvirt) /* The number of statistics supported by this version of the interface. To add new statistics, add them */ /* to the enum and increase this value. */ REGISTER_LONG_CONSTANT(VIR_DOMAIN_MEMORY_STAT_AVAILABLE, 5, CONST_CS | CONST_PERSISTENT); -REGISTER_LONG_CONSTANT(VIR_DOMAIN_MEMORY_STAT_NR, 6, CONST_CS | CONST_PERSISTENT); +/* Current balloon value (in KB). */ +REGISTER_LONG_CONSTANT(VIR_DOMAIN_MEMORY_STAT_ACTUAL_BALLOON, 6, CONST_CS | CONST_PERSISTENT); +/* Resident Set Size of the process running the domain. This value is in kB */ +REGISTER_LONG_CONSTANT(VIR_DOMAIN_MEMORY_STAT_RSS, 7, CONST_CS | CONST_PERSISTENT); +/* The number of statistics supported by this version of the interface. */ +/* To add new statistics, add them to the enum and increase this value. */ +REGISTER_LONG_CONSTANT(VIR_DOMAIN_MEMORY_STAT_NR, 8, CONST_CS | CONST_PERSISTENT); Ouch, nice catch! /* Job constants */ REGISTER_LONG_CONSTANT(VIR_DOMAIN_JOB_NONE, 0, CONST_CS | CONST_PERSISTENT); @@ -1354,6 +1364,18 @@ PHP_MINIT_FUNCTION(libvirt) REGISTER_LONG_CONSTANT(VIR_MIGRATE_NON_SHARED_DISK,64, CONST_CS | CONST_PERSISTENT); /* migration with non-shared storage with incremental copy (same base image shared between source and destination) */ REGISTER_LONG_CONSTANT(VIR_MIGRATE_NON_SHARED_INC,128, CONST_CS | CONST_PERSISTENT); +/* protect for changing domain configuration through the whole migration process; this will be used automatically when supported */ +REGISTER_LONG_CONSTANT(VIR_MIGRATE_CHANGE_PROTECTION,256, CONST_CS | CONST_PERSISTENT); +/* force migration even if it is considered unsafe */ +REGISTER_LONG_CONSTANT(VIR_MIGRATE_UNSAFE,512, CONST_CS | CONST_PERSISTENT); +/* offline migrate */ +REGISTER_LONG_CONSTANT(VIR_MIGRATE_OFFLINE,1024, CONST_CS | CONST_PERSISTENT); +/* compress data during migration */ +REGISTER_LONG_CONSTANT(VIR_MIGRATE_COMPRESSED,2048, CONST_CS | CONST_PERSISTENT); +/* abort migration on I/O errors happened during migration */ +REGISTER_LONG_CONSTANT(VIR_MIGRATE_ABORT_ON_ERROR,4096, CONST_CS | CONST_PERSISTENT); +/* force convergence */ +REGISTER_LONG_CONSTANT(VIR_MIGRATE_AUTO_CONVERGE,8192, CONST_CS | CONST_PERSISTENT); /* Modify device allocation based on current domain state */ REGISTER_LONG_CONSTANT(VIR_DOMAIN_DEVICE_MODIFY_CURRENT, 0, CONST_CS | CONST_PERSISTENT); ACKed and pushed. Congratulations on your first libvirt contribution! Michal -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] virconf: correct code format
On Mon, Aug 17, 2015 at 08:42:03PM +0800, Cao jin wrote: Signed-off-by: Cao jin caoj.f...@cn.fujitsu.com --- src/util/virconf.c | 4 ++-- src/util/virconf.h | 33 - 2 files changed, 18 insertions(+), 19 deletions(-) ACK and pushed. Jan signature.asc Description: Digital signature -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [virtio-pci] unbind port from virtio-pci causes kernel crash
I am running kvm based virtual guest. The guest has two virtio-based ports. Now I am trying to unbind ports from their current drivers (by echo :00:06.0 /sys/bus/pci/drivers/virtio-pci/unbind) and getting kernel crash. Don't know how to move forward. Any suggestions are highly appreciated. [ 110.034006] WARNING: at kernel/irq/manage.c:937 __free_irq+0x205/0x210() [ 110.034006] Hardware name: Standard PC (i440FX + PIIX, 1996) [ 110.034006] Modules linked in: rte_kni igb_uio knpusim(P) knpushm(P) virtio_scsi virtio_blk vmw_pvscsi ata_piix mptsas mptspi mptscsih mptbase ub be2net ixgbevf enic ixgbe mdio e1000e e1000 vmxnet3 virtio_net bnx2 3c59x uhci_hcd ehci_hcd [ 110.034006] Pid: 5578, comm: sh Tainted: PW 2.6.38-staros-v3-ssi-64 #2 [ 110.034006] Call Trace: [ 110.034006] [810a1905] ? __free_irq+0x205/0x210 [ 110.034006] [810a1905] ? __free_irq+0x205/0x210 [ 110.034006] [81056710] ? warn_slowpath_common+0x90/0xc0 [ 110.034006] [8105675a] ? warn_slowpath_null+0x1a/0x20 [ 110.034006] [810a1905] ? __free_irq+0x205/0x210 [ 110.034006] [810a1957] ? free_irq+0x47/0x90 [ 110.034006] [812f96a3] ? vp_del_vqs+0x73/0xb0 [ 110.034006] [a00192f6] ? virtnet_del_vqs+0x36/0x50 [virtio_net] [ 110.034006] [a001ab16] ? remove_vq_common+0x36/0x40 [virtio_net] [ 110.034006] [a001c47f] ? virtnet_remove+0x3f/0xbc0 [virtio_net] [ 110.034006] [812f8612] ? virtio_dev_remove+0x22/0x50 [ 110.034006] [8133a176] ? __device_release_driver+0x66/0xc0 [ 110.034006] [8133a8ed] ? device_release_driver+0x2d/0x40 [ 110.034006] [81339b8d] ? bus_remove_device+0x7d/0xe0 [ 110.034006] [81336a98] ? device_del+0x128/0x1a0 [ 110.034006] [81336b32] ? device_unregister+0x22/0x60 [ 110.034006] [812f8682] ? unregister_virtio_device+0x12/0x20 [ 110.034006] [8155fe2d] ? virtio_pci_remove+0x1d/0x20 [ 110.034006] [812b6ee7] ? pci_device_remove+0x37/0x70 [ 110.034006] [8133a176] ? __device_release_driver+0x66/0xc0 [ 110.034006] [8133a8ed] ? device_release_driver+0x2d/0x40 [ 110.034006] [81339c8b] ? driver_unbind+0x9b/0xc0 [ 110.034006] [81338bbc] ? drv_attr_store+0x2c/0x30 [ 110.034006] [8117f0a6] ? sysfs_write_file+0xe6/0x150 [ 110.034006] [8111fd7e] ? vfs_write+0xce/0x170 [ 110.034006] [81120485] ? sys_write+0x55/0x90 [ 110.034006] [8103fc40] ? sysenter_dispatch+0x7/0x37 [ 110.034006] [81563e49] ? trace_hardirqs_on_thunk+0x3a/0x3c [ 110.034006] ---[ end trace 4eaa2a86a8e2da24 ]--- [ 110.074389] general protection fault: [#1] PREEMPT SMP [ 110.075006] last sysfs file: /sys/bus/pci/drivers/virtio-pci/unbind -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH v3] lxc: Inherit namespace feature
On 14.08.2015 14:09, Daniel P. Berrange wrote: From: Imran Khan ik.n...@gmail.com This patch adds feature for lxc containers to inherit namespaces. This is very similar to what lxc-tools or docker provides. Look for man lxc-start and you will find that you can pass command args as [ --share-[net|ipc|uts] name|pid ]. Or check out docker networking option in which you can give --net=container:NAME_or_ID as an option for sharing +namespace. From this patch you can add extra libvirt option to share s/// namespace in following way. lxc:namespace lxc:sharenet type='netns' value='red'/ lxc:shareipc type='pid' value='12345'/ lxc:shareuts type='name' value='container1'/ /lxc:namespace The netns option is specific to sharenet. It can be used to inherit from existing network namespace. Signed-off-by: Daniel P. Berrange berra...@redhat.com --- docs/drvlxc.html.in | 21 ++ docs/schemas/domaincommon.rng | 42 po/POTFILES.in| 1 + src/Makefile.am | 6 +- src/lxc/lxc_conf.c| 2 +- src/lxc/lxc_container.c | 71 ++-- src/lxc/lxc_container.h | 2 + src/lxc/lxc_controller.c | 45 - src/lxc/lxc_domain.c | 149 ++ src/lxc/lxc_domain.h | 26 src/lxc/lxc_process.c | 149 ++ tests/lxcxml2xmltest.c| 1 + 12 files changed, 506 insertions(+), 9 deletions(-) diff --git a/src/lxc/lxc_process.c b/src/lxc/lxc_process.c index e99b039..9699377 100644 --- a/src/lxc/lxc_process.c +++ b/src/lxc/lxc_process.c @@ -359,6 +359,135 @@ char *virLXCProcessSetupInterfaceDirect(virConnectPtr conn, return ret; } +static const char *nsInfoLocal[VIR_LXC_DOMAIN_NAMESPACE_LAST] = { +[VIR_LXC_DOMAIN_NAMESPACE_SHARENET] = net, +[VIR_LXC_DOMAIN_NAMESPACE_SHAREIPC] = ipc, +[VIR_LXC_DOMAIN_NAMESPACE_SHAREUTS] = uts, +}; + +static int virLXCProcessSetupNamespaceName(virConnectPtr conn, int ns_type, const char *name) +{ +virLXCDriverPtr driver = conn-privateData; +int fd = -1; +virDomainObjPtr vm; +char *path; + +vm = virDomainObjListFindByName(driver-domains, name); +if (!vm) { +virReportError(VIR_ERR_NO_DOMAIN, + _(No domain with matching name '%s'), name); +return -1; +} + +if (virAsprintf(path, /proc/%lld/ns/%s, +(long long int)vm-pid, +nsInfoLocal[ns_type]) 0) +goto cleanup; + +if ((fd = open(path, O_RDONLY)) 0) { +virReportSystemError(errno, + _(failed to open ns %s), + virLXCDomainNamespaceTypeToString(ns_type)); +goto cleanup; +} + + cleanup: +VIR_FREE(path); +virObjectUnlock(vm); +virObjectUnref(vm); +return fd; +} + + +static int virLXCProcessSetupNamespacePID(int ns_type, const char *name) +{ +int fd; +char *path; + +if (virAsprintf(path, /proc/%s/ns/%s, +name, +nsInfoLocal[ns_type]) 0) +return -1; +fd = open(path, O_RDONLY); +VIR_FREE(path); +if (fd 0) { +virReportSystemError(errno, + _(failed to open ns %s), + virLXCDomainNamespaceTypeToString(ns_type)); +return -1; +} +return fd; +} + + +static int virLXCProcessSetupNamespaceNet(int ns_type, const char *name) +{ +char *path; +int fd; +if (ns_type != VIR_LXC_DOMAIN_NAMESPACE_SHARENET) { +virReportError(VIR_ERR_CONFIG_UNSUPPORTED, %s s/$/,/ + _('netns' namespace source can only be + used with sharenet)); +return -1; +} + +if (virAsprintf(path, /var/run/netns/%s, name) 0) +return -1; +fd = open(path, O_RDONLY); +VIR_FREE(path); +if (fd 0) { +virReportSystemError(errno, + _(failed to open netns %s), name); +return -1; +} +return fd; +} + + diff --git a/tests/lxcxml2xmltest.c b/tests/lxcxml2xmltest.c index 3e00347..8d824b9 100644 --- a/tests/lxcxml2xmltest.c +++ b/tests/lxcxml2xmltest.c @@ -133,6 +133,7 @@ mymain(void) DO_TEST(filesystem-root); DO_TEST(idmap); DO_TEST(capabilities); +DO_TEST(sharenet); Have you forgot to git add tests/lxcxml2xmldata/lxc-sharenet.xml? I like the idea though. I'm tempted to ACK this if you fix all the small issues I've raised. Michal -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH V2 1/3] libxl: fix ref counting of libxlMigrationDstArgs
On 07.08.2015 19:53, Jim Fehlig wrote: This patch fixes some flawed logic around ref counting the libxlMigrationDstArgs object. First, when adding sockets to the event loop with virNetSocketAddIOCallback(), the generic virObjectFreeCallback() was registered as a free function, with libxlMigrationDstArgs as its parameter. A reference was also taken on libxlMigrationDstArgs for each successful call to virNetSocketAddIOCallback(). The rational behind this logic was that the libxlMigrationDstArgs object had to out-live the socket objects. But virNetSocketAddIOCallback() already takes a reference on socket objects, ensuring their life until removed from the event loop and unref'ed in virNetSocketEventFree(). We only need to ensure libxlMigrationDstArgs lives until libxlDoMigrateReceive() finishes, which can be done by simply unref'ing libxlMigrationDstArgs at the end of libxlDoMigrateReceive(). The second flaw was unref'ing the sockets in the failure path of libxlMigrateReceive() and at the end of libxlDoMigrateReceive(). As mentioned above, the sockets are already unref'ed by virNetSocketEventFree() when removed from the event loop. Attempting to unref the socket a second time resulted in a libvirtd crash since the socket was previously unref'ed and disposed. Signed-off-by: Jim Fehlig jfeh...@suse.com --- V2: Initialize args in libxlDomainMigrationPrepare src/libxl/libxl_migration.c | 20 ++-- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/src/libxl/libxl_migration.c b/src/libxl/libxl_migration.c index aa9547b..f9673c8 100644 --- a/src/libxl/libxl_migration.c +++ b/src/libxl/libxl_migration.c @@ -112,11 +112,11 @@ libxlDoMigrateReceive(void *opaque) virNetSocketUpdateIOCallback(socks[i], 0); This is pre-existing, but since the socket callback is removed right after, it does not make much sense to update its events to listen for. virNetSocketRemoveIOCallback(socks[i]); virNetSocketClose(socks[i]); -virObjectUnref(socks[i]); This will leak the socks[i] object, wouldn't it? I mean, in libxlDomainMigrationPrepare() on line 392 virNetSocketNewListenTCP() is called. This initialize the array with object pointers. Then virNetSocketAddIOCallback() + virNetSocketRemoveIOCallback() pair keep the ref counter consistent. This makes me think you should not remove this line. socks[i] = NULL; } args-nsocks = 0; VIR_FORCE_CLOSE(recvfd); +virObjectUnref(args); } @@ -164,11 +164,11 @@ libxlMigrateReceive(virNetSocketPtr sock, virNetSocketUpdateIOCallback(socks[i], 0); virNetSocketRemoveIOCallback(socks[i]); virNetSocketClose(socks[i]); -virObjectUnref(socks[i]); socks[i] = NULL; } args-nsocks = 0; VIR_FORCE_CLOSE(recvfd); +virObjectUnref(args); } static int @@ -318,7 +318,7 @@ libxlDomainMigrationPrepare(virConnectPtr dconn, virNetSocketPtr *socks = NULL; size_t nsocks = 0; int nsocks_listen = 0; -libxlMigrationDstArgs *args; +libxlMigrationDstArgs *args = NULL; size_t i; int ret = -1; @@ -420,22 +420,12 @@ libxlDomainMigrationPrepare(virConnectPtr dconn, VIR_EVENT_HANDLE_READABLE, libxlMigrateReceive, args, - virObjectFreeCallback) 0) + NULL) 0) continue; -/* - * Successfully added sock to event loop. Take a ref on args to - * ensure it is not freed until sock is removed from the event loop. - * Ref is dropped in virObjectFreeCallback after being removed - * from the event loop. - */ -virObjectRef(args); nsocks_listen++; } -/* Done with args in this function, drop reference */ -virObjectUnref(args); - if (!nsocks_listen) goto error; @@ -448,6 +438,8 @@ libxlDomainMigrationPrepare(virConnectPtr dconn, virObjectUnref(socks[i]); } VIR_FREE(socks); +virObjectUnref(args); + /* Remove virDomainObj from domain list */ if (vm) { virDomainObjListRemove(driver-domains, vm); Otherwise looking good. Michal -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH V2 3/3] libxl: acquire a job when receiving a migrating domain
On 07.08.2015 19:53, Jim Fehlig wrote: Commit f86ae403 moved acquiring a job from libxlDomainStart() to its callers. One spot missed was in libxlDoMigrateReceive(). Acquire a job in libxlDoMigrateReceive() before calling libxlDomainStart(). Signed-off-by: Jim Fehlig jfeh...@suse.com --- src/libxl/libxl_migration.c | 20 +--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/src/libxl/libxl_migration.c b/src/libxl/libxl_migration.c index a407ad9..8db3aea 100644 --- a/src/libxl/libxl_migration.c +++ b/src/libxl/libxl_migration.c @@ -95,17 +95,20 @@ libxlDoMigrateReceive(void *opaque) int recvfd = args-recvfd; size_t i; int ret; +bool remove_dom = 0; + +virObjectLock(vm); +if (libxlDomainObjBeginJob(driver, vm, LIBXL_JOB_MODIFY) 0) +goto cleanup; /* * Always start the domain paused. If needed, unpause in the * finish phase, after transfer of the domain is complete. */ -virObjectLock(vm); ret = libxlDomainStart(driver, vm, true, recvfd); -virObjectUnlock(vm); if (ret 0 !vm-persistent) -virDomainObjListRemove(driver-domains, vm); +remove_dom = true; /* Remove all listen socks from event handler, and close them. */ for (i = 0; i nsocks; i++) { @@ -117,6 +120,17 @@ libxlDoMigrateReceive(void *opaque) args-nsocks = 0; VIR_FORCE_CLOSE(recvfd); virObjectUnref(args); + +if (!libxlDomainObjEndJob(driver, vm)) +vm = NULL; + + cleanup: +if (remove_dom vm) { +virDomainObjListRemove(driver-domains, vm); +vm = NULL; +} +if (vm) +virObjectUnlock(vm); } ACK Michal -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH V2 2/3] libxl: don't attempt to resume domain when suspend fails
On 07.08.2015 19:53, Jim Fehlig wrote: Failure of libxl_domain_suspend() does not leave the domain in a suspended state, so no need to call libxl_domain_resume(), which btw will fail with domain not suspended. Signed-off-by: Jim Fehlig jfeh...@suse.com --- src/libxl/libxl_migration.c | 14 -- 1 file changed, 14 deletions(-) diff --git a/src/libxl/libxl_migration.c b/src/libxl/libxl_migration.c index f9673c8..a407ad9 100644 --- a/src/libxl/libxl_migration.c +++ b/src/libxl/libxl_migration.c @@ -178,7 +178,6 @@ libxlDoMigrateSend(libxlDriverPrivatePtr driver, int sockfd) { libxlDriverConfigPtr cfg = libxlDriverConfigGet(driver); -virObjectEventPtr event = NULL; int xl_flags = 0; int ret; @@ -188,24 +187,11 @@ libxlDoMigrateSend(libxlDriverPrivatePtr driver, ret = libxl_domain_suspend(cfg-ctx, vm-def-id, sockfd, xl_flags, NULL); if (ret != 0) { -/* attempt to resume the domain on failure */ -if (libxl_domain_resume(cfg-ctx, vm-def-id, 1, 0) != 0) { -VIR_DEBUG(Failed to resume domain following failed migration); -virDomainObjSetState(vm, VIR_DOMAIN_PAUSED, - VIR_DOMAIN_PAUSED_MIGRATION); -event = virDomainEventLifecycleNewFromObj(vm, VIR_DOMAIN_EVENT_SUSPENDED, - VIR_DOMAIN_EVENT_SUSPENDED_MIGRATED); -ignore_value(virDomainSaveStatus(driver-xmlopt, cfg-stateDir, vm)); -} virReportError(VIR_ERR_INTERNAL_ERROR, %s, _(Failed to send migration data to destination host)); ret = -1; -goto cleanup; } - cleanup: -if (event) -libxlDomainEventQueue(driver, event); virObjectUnref(cfg); return ret; } ACK Michal -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 2/2] libvirt-admin: Generate symbols file
On 19.08.2015 14:39, Guido Günther wrote: Since we're linking this into libvirtd we need some symbols to be public but not part of the public API so mark them as LIBVIRT_ADMIN_PRIVATE_VERSION as we do with libvirt. Making all other symbols local makes sure we don't accidentally leak unwanted ones. --- configure.ac | 2 +- src/Makefile.am| 20 ++-- src/libvirt_admin.syms | 18 -- src/libvirt_admin_private.syms | 14 ++ src/libvirt_admin_public.syms | 18 ++ 5 files changed, 51 insertions(+), 21 deletions(-) delete mode 100644 src/libvirt_admin.syms create mode 100644 src/libvirt_admin_private.syms create mode 100644 src/libvirt_admin_public.syms Cool! ACK to both. Thanks for solving that. Michal -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] docs: Drop unused rule for internals/%.html.tmp target
On 19.08.2015 14:40, Guido Günther wrote: We're using the %.html.tmp for all html files now so drop the unused one and rather make sure the needed directory exists. This fixes build failures as described in https://www.redhat.com/archives/libvir-list/2015-August/msg00603.html --- configure.ac | 1 + docs/Makefile.am | 9 - 2 files changed, 1 insertion(+), 9 deletions(-) diff --git a/configure.ac b/configure.ac index 9066ed6..749dbb7 100644 --- a/configure.ac +++ b/configure.ac @@ -2774,6 +2774,7 @@ AC_DEFINE_UNQUOTED([isbase64],[libvirt_gl_isbase64],[Hack to avoid symbol clash] AC_DEFINE_UNQUOTED([base64_encode],[libvirt_gl_base64_encode],[Hack to avoid symbol clash]) AC_DEFINE_UNQUOTED([base64_encode_alloc],[libvirt_gl_base64_encode_alloc],[Hack to avoid symbol clash]) +AC_CONFIG_COMMANDS([mkdir], [$MKDIR_P docs/internals]) AC_CONFIG_FILES([run], [chmod +x,-w run]) AC_CONFIG_FILES([\ diff --git a/docs/Makefile.am b/docs/Makefile.am index daf37b6..563baca 100644 --- a/docs/Makefile.am +++ b/docs/Makefile.am @@ -218,15 +218,6 @@ $(srcdir)/hvsupport.html.in: $(srcdir)/hvsupport.pl $(api_DATA) \ %.png: %.fig convert -rotate 90 $ $@ -internals/%.html.tmp: internals/%.html.in subsite.xsl page.xsl sitemap.html.in - @if [ -x $(XSLTPROC) ] ; then \ - echo Generating $@; \ - $(MKDIR_P) internals; \ - name=`echo $@ | sed -e 's/.tmp//'`; \ - $(XSLTPROC) --stringparam pagename $$name --nonet \ - $(top_srcdir)/docs/subsite.xsl $ $@ \ - || { rm $@ exit 1; }; fi - %.html.tmp: %.html.in site.xsl page.xsl sitemap.html.in $(acl_generated) @if [ -x $(XSLTPROC) ] ; then \ echo Generating $@; \ ACK Michal -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] qemu: Report better error message when renaming to existing domain name
On 18/08/15 21:05, Martin Kletzander wrote: Signed-off-by: Martin Kletzander mklet...@redhat.com --- src/qemu/qemu_driver.c | 16 1 file changed, 16 insertions(+) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 99a3817ff5ab..16061a51d4a7 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -19892,6 +19892,7 @@ static int qemuDomainRename(virDomainPtr dom, virQEMUDriverPtr driver = dom-conn-privateData; virQEMUDriverConfigPtr cfg = NULL; virDomainObjPtr vm = NULL; +virDomainObjPtr tmp_dom = NULL; virObjectEventPtr event_new = NULL; virObjectEventPtr event_old = NULL; int ret = -1; @@ -19946,6 +19947,21 @@ static int qemuDomainRename(virDomainPtr dom, goto endjob; } +/* + * This is a rather racy check, but still better than reporting + * internal error. And since new_name != name here, there's no + * deadlock imminent. + */ +tmp_dom = virDomainObjListFindByName(driver-domains, new_name); +if (tmp_dom) { +virObjectUnlock(tmp_dom); +virObjectUnref(tmp_dom); +virReportError(VIR_ERR_OPERATION_INVALID, + _(domain with name '%s' already exists), + new_name); +goto endjob; +} + if (VIR_STRDUP(new_dom_name, new_name) 0) goto endjob; ACK, definitely tells more than Duplicate key error. Erik -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list