[libvirt] [PATCH 0/6] Add support for TPM emulator and CRB interface

2018-04-05 Thread Stefan Berger
This series of patches add support for the new TPM CRB interface in
QEMU that will become available with QEMU 2.12.

The rest of the patches add support for the TPM emulator backend that
is available in QEMU and based on swtpm + libtpms. Here I hope for
feedback for how to organize the layout of directories, files, and
UnixIO socket files that QEMU needs to talk to 'swtpm'.

Stefan

Stefan Berger (6):
  tpm: Enable TPM CRB interface
  tpm: Add support for external swtpm TPM emulator
  tpm: Label the external swtpm with SELinux labels
  tpm: Handle TPM emulator device reconfigurations
  tpm: Add support for choosing emulation of a TPM 2
  tpm: Add swtpm to emulator cgroup

 docs/formatdomain.html.in  |  47 ++
 docs/schemas/domaincommon.rng  |  23 +-
 src/conf/domain_audit.c|   2 +
 src/conf/domain_conf.c | 131 -
 src/conf/domain_conf.h |  19 +
 src/libvirt_private.syms   |   8 +
 src/qemu/Makefile.inc.am   |   2 +
 src/qemu/libvirtd_qemu.aug |   3 +
 src/qemu/qemu.conf |   7 +
 src/qemu/qemu_capabilities.c   |  10 +
 src/qemu/qemu_capabilities.h   |   2 +
 src/qemu/qemu_cgroup.c |  54 ++
 src/qemu/qemu_cgroup.h |   1 +
 src/qemu/qemu_command.c|  52 +-
 src/qemu/qemu_conf.c   |  11 +-
 src/qemu/qemu_conf.h   |   2 +
 src/qemu/qemu_domain.c |   2 +
 src/qemu/qemu_driver.c |  16 +-
 src/qemu/qemu_extdevice.c  | 245 +
 src/qemu/qemu_extdevice.h  |  36 ++
 src/qemu/qemu_process.c|  12 +
 src/qemu/test_libvirtd_qemu.aug.in |   1 +
 src/security/security_dac.c|   6 +
 src/security/security_driver.h |   5 +-
 src/security/security_manager.c|  15 +
 src/security/security_manager.h|   3 +
 src/security/security_selinux.c| 101 
 src/security/security_stack.c  |  19 +
 src/util/vircgroup.c   |  42 ++
 src/util/vircgroup.h   |   1 +
 src/util/virfile.c |  12 +
 src/util/virfile.h |   2 +-
 src/util/virtpm.c  | 550 +
 src/util/virtpm.h  |  14 +
 tests/qemucapabilitiesdata/caps_2.11.0.s390x.xml   |   1 +
 tests/qemucapabilitiesdata/caps_2.12.0.aarch64.xml |   1 +
 tests/qemucapabilitiesdata/caps_2.12.0.ppc64.xml   |   1 +
 tests/qemucapabilitiesdata/caps_2.12.0.s390x.xml   |   1 +
 tests/qemucapabilitiesdata/caps_2.12.0.x86_64.xml  |   2 +
 tests/qemuxml2argvdata/tpm-emulator-tpm2.args  |  24 +
 tests/qemuxml2argvdata/tpm-emulator-tpm2.xml   |  30 ++
 tests/qemuxml2argvdata/tpm-emulator.args   |  24 +
 tests/qemuxml2argvdata/tpm-emulator.xml|  30 ++
 tests/qemuxml2argvdata/tpm-passthrough-crb.args|  24 +
 tests/qemuxml2argvdata/tpm-passthrough-crb.xml |  32 ++
 tests/qemuxml2argvmock.c   |   2 +
 tests/qemuxml2argvtest.c   |  23 +
 tests/qemuxml2xmloutdata/tpm-emulator-tpm2.xml |  34 ++
 tests/qemuxml2xmloutdata/tpm-emulator.xml  |  34 ++
 tests/qemuxml2xmloutdata/tpm-passthrough-crb.xml   |  36 ++
 tests/qemuxml2xmltest.c|   1 +
 51 files changed, 1736 insertions(+), 20 deletions(-)
 create mode 100644 src/qemu/qemu_extdevice.c
 create mode 100644 src/qemu/qemu_extdevice.h
 create mode 100644 tests/qemuxml2argvdata/tpm-emulator-tpm2.args
 create mode 100644 tests/qemuxml2argvdata/tpm-emulator-tpm2.xml
 create mode 100644 tests/qemuxml2argvdata/tpm-emulator.args
 create mode 100644 tests/qemuxml2argvdata/tpm-emulator.xml
 create mode 100644 tests/qemuxml2argvdata/tpm-passthrough-crb.args
 create mode 100644 tests/qemuxml2argvdata/tpm-passthrough-crb.xml
 create mode 100644 tests/qemuxml2xmloutdata/tpm-emulator-tpm2.xml
 create mode 100644 tests/qemuxml2xmloutdata/tpm-emulator.xml
 create mode 100644 tests/qemuxml2xmloutdata/tpm-passthrough-crb.xml

-- 
2.5.5

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [PATCH 2/6] tpm: Add support for external swtpm TPM emulator

2018-04-05 Thread Stefan Berger
This patch adds support for an external swtpm TPM emulator. The XML for
this type of TPM looks as follows:

 
   
 

The XML will currently only start a TPM 1.2.

Upon the first start, libvirt will run `swtpm_setup`, which will simulate the
manufacturing of a TPM and create certificates for it and write them into the
NVRAM location of the emulated TPM.

Then, libvirt will automatically start the swtpm TPM emulator using the `swtpm`
executable.

Once the VM terminates, libvirt uses the swtpm_ioctl executable to gracefully
shut down the `swtpm` in case it is still running (QEMU did not send shutdown)
or clean up the socket file.

The above mentioned executables must be found in the PATH.

The executables can either be run as root or started as root and switch to
the tss user. The requirement for the tss user comes through 'tcsd', which
is used for the simulation of the manufacturing. Which user is used can be
configured through qemu.conf.

The swtpm writes out state into files. The state is kept in 
/var/lib/libvirt/tpm:

[root@localhost libvirt]# ls -lZ | grep tpm

drwx--x--x. 7 root root unconfined_u:object_r:virt_var_lib_t:s0 4096 Apr  5 
16:22 tpm

The directory /var/lib/libvirt/tpm maintains per-TPM state directories but
also hosts the UnixIO socket of running swtpms, which QEMU uses for 
communicating
with them. At this point only the socket file is labeled properly and made 
accessible
for QEMU, which runs under the qemu user:

[root@localhost tpm]# ls -lZ
total 4
drwx--. 2 tss  tss  system_u:object_r:virt_var_lib_t:s0  4096 Apr  
5 16:46 485d0004-a48f-436a-8457-8a3b73e28567
srw---. 1 qemu qemu system_u:object_r:svirt_image_t:s0:c413,c4300 Apr  
5 16:46 485d0004-a48f-436a-8457-8a3b73e28567.sock

[root@localhost 485d0004-a48f-436a-8457-8a3b73e28567]# ls -lZ
total 8
-rw-r--r--. 1 tss tss system_u:object_r:virt_var_lib_t:s0 3648 Apr  5 16:46 
tpm-00.permall
-rw-r--r--. 1 tss tss system_u:object_r:virt_var_lib_t:s0 2237 Apr  5 16:46 
vtpm.log

root@sbct-3 485d0004-a48f-436a-8457-8a3b73e28567]# ps auxZ | grep swtpm | grep 
-v grep
system_u:system_r:virtd_t:s0-s0:c0.c1023 tss 18697 0.0  0.0 28172 3892 ?   
Ss   16:46   0:00 /usr/bin/swtpm socket --daemon --ctrl 
type=unixio,path=/var/lib/libvirt/tpm/485d0004-a48f-436a-8457-8a3b73e28567.sock,mode=0600
 --tpmstate dir=/var/lib/libvirt/tpm/485d0004-a48f-436a-8457-8a3b73e28567 --log 
file=/var/lib/libvirt/tpm/485d0004-a48f-436a-8457-8a3b73e28567/vtpm.log --runas 
59

[root@sbct-3 485d0004-a48f-436a-8457-8a3b73e28567]# ps auxZ | grep qemu | grep 
tpm | grep -v grep
system_u:system_r:svirt_t:s0:c413,c430 qemu 18702 2.5  0.0 3036052 48676 ? 
Sl   16:46   0:08 /bin/qemu-system-x86_64 -name 
guest=centos7.0,debug-threads=on -S -object 
secret,id=masterKey0,format=raw,file=/var/lib/libvirt/qemu/domain-6-centos7.0/master-key.aes
 -machine pc-i440fx-2.8,accel=kvm,usb=off,dump-guest-core=off -cpu kvm64 -m 
2048 -realtime mlock=off -smp 2,sockets=2,cores=1,threads=1 -uuid 
485d0004-a48f-436a-8457-8a3b73e28567 [...] -tpmdev 
emulator,id=tpm-tpm0,chardev=chrtpm -chardev 
socket,id=chrtpm,path=/var/lib/libvirt/tpm/485d0004-a48f-436a-8457-8a3b73e28567.sock
 -device tpm-tis,tpmdev=tpm-tpm0,id=tpm0 -device 
usb-mouse,id=input0,bus=usb.0,port=1 -vnc 127.0.0.1:0 -device 
cirrus-vga,id=video0,bus=pci.0,addr=0x2 -device 
virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x6 -msg timestamp=on

Signed-off-by: Stefan Berger 
---
 docs/formatdomain.html.in  |  30 ++
 docs/schemas/domaincommon.rng  |   5 +
 src/conf/domain_audit.c|   2 +
 src/conf/domain_conf.c |  51 ++-
 src/conf/domain_conf.h |   5 +
 src/libvirt_private.syms   |   5 +
 src/qemu/Makefile.inc.am   |   2 +
 src/qemu/libvirtd_qemu.aug |   3 +
 src/qemu/qemu.conf |   7 +
 src/qemu/qemu_capabilities.c   |   5 +
 src/qemu/qemu_capabilities.h   |   1 +
 src/qemu/qemu_cgroup.c |   1 +
 src/qemu/qemu_command.c|  52 ++-
 src/qemu/qemu_conf.c   |  11 +-
 src/qemu/qemu_conf.h   |   2 +
 src/qemu/qemu_domain.c |   2 +
 src/qemu/qemu_driver.c |  13 +
 src/qemu/qemu_extdevice.c  | 195 ++
 src/qemu/qemu_extdevice.h  |  36 ++
 src/qemu/qemu_process.c|   8 +
 src/qemu/test_libvirtd_qemu.aug.in |   1 +
 src/security/security_dac.c|   6 +
 src/security/security_selinux.c|  11 +
 src/util/virfile.c |  12 +
 src/util/virfile.h |   2 +-
 

[libvirt] [PATCH 1/6] tpm: Enable TPM CRB interface

2018-04-05 Thread Stefan Berger
Enable the TPM CRB interface added in QEMU 2.12. The TPM CRB
interface is a simpler interface than the TPM TIS and should only
be used with a TPM 2.

Signed-off-by: Stefan Berger 
---
 docs/formatdomain.html.in |  2 ++
 docs/schemas/domaincommon.rng |  5 +++-
 src/conf/domain_conf.c|  5 ++--
 src/conf/domain_conf.h|  1 +
 src/qemu/qemu_capabilities.c  |  5 
 src/qemu/qemu_capabilities.h  |  1 +
 tests/qemucapabilitiesdata/caps_2.12.0.x86_64.xml |  1 +
 tests/qemuxml2argvdata/tpm-passthrough-crb.args   | 24 +++
 tests/qemuxml2argvdata/tpm-passthrough-crb.xml| 32 
 tests/qemuxml2argvtest.c  |  3 ++
 tests/qemuxml2xmloutdata/tpm-passthrough-crb.xml  | 36 +++
 11 files changed, 111 insertions(+), 4 deletions(-)
 create mode 100644 tests/qemuxml2argvdata/tpm-passthrough-crb.args
 create mode 100644 tests/qemuxml2argvdata/tpm-passthrough-crb.xml
 create mode 100644 tests/qemuxml2xmloutdata/tpm-passthrough-crb.xml

diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index 08dc74b..16fc7db 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -7628,6 +7628,8 @@ qemu-kvm -net nic,model=? /dev/null
   The model attribute specifies what device
   model QEMU provides to the guest. If no model name is provided,
   tpm-tis will automatically be chosen.
+  Another available choice is the tpm-crb, which
+  should only be used when the backend is a TPM 2.
 
   
   backend
diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
index 8165e69..be5c628 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -4112,7 +4112,10 @@
 
   
 
-  tpm-tis
+  
+tpm-tis
+tpm-crb
+  
 
   
   
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index ae7c0d9..232174a 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -858,7 +858,8 @@ VIR_ENUM_IMPL(virDomainRNGBackend,
   "egd");
 
 VIR_ENUM_IMPL(virDomainTPMModel, VIR_DOMAIN_TPM_MODEL_LAST,
-  "tpm-tis")
+  "tpm-tis",
+  "tpm-crb")
 
 VIR_ENUM_IMPL(virDomainTPMBackend, VIR_DOMAIN_TPM_TYPE_LAST,
   "passthrough")
@@ -12549,8 +12550,6 @@ virDomainTPMDefParseXML(virDomainXMLOptionPtr xmlopt,
 virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("Unknown TPM frontend model '%s'"), model);
 goto error;
-} else {
-def->model = VIR_DOMAIN_TPM_MODEL_TIS;
 }
 
 ctxt->node = node;
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 61379e5..1724340 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -1277,6 +1277,7 @@ struct _virDomainHubDef {
 
 typedef enum {
 VIR_DOMAIN_TPM_MODEL_TIS,
+VIR_DOMAIN_TPM_MODEL_CRB,
 
 VIR_DOMAIN_TPM_MODEL_LAST
 } virDomainTPMModel;
diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index e54dde6..0952663 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -466,6 +466,7 @@ VIR_ENUM_IMPL(virQEMUCaps, QEMU_CAPS_LAST,
   /* 285 */
   "virtio-mouse-ccw",
   "virtio-tablet-ccw",
+  "tpm-crb",
 );
 
 
@@ -3104,6 +3105,10 @@ const struct tpmTypeToCaps virQEMUCapsTPMModelsToCaps[] 
= {
 .type = VIR_DOMAIN_TPM_MODEL_TIS,
 .caps = QEMU_CAPS_DEVICE_TPM_TIS,
 },
+{
+.type = VIR_DOMAIN_TPM_MODEL_CRB,
+.caps = QEMU_CAPS_DEVICE_TPM_CRB,
+},
 };
 
 static int
diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h
index 3f3c29f..604525a 100644
--- a/src/qemu/qemu_capabilities.h
+++ b/src/qemu/qemu_capabilities.h
@@ -450,6 +450,7 @@ typedef enum {
 /* 285 */
 QEMU_CAPS_DEVICE_VIRTIO_MOUSE_CCW, /* -device virtio-mouse-ccw */
 QEMU_CAPS_DEVICE_VIRTIO_TABLET_CCW, /* -device virtio-tablet-ccw */
+QEMU_CAPS_DEVICE_TPM_CRB, /* -device tpm-crb */
 
 QEMU_CAPS_LAST /* this must always be the last item */
 } virQEMUCapsFlags;
diff --git a/tests/qemucapabilitiesdata/caps_2.12.0.x86_64.xml 
b/tests/qemucapabilitiesdata/caps_2.12.0.x86_64.xml
index 334296e..39ee4f4 100644
--- a/tests/qemucapabilitiesdata/caps_2.12.0.x86_64.xml
+++ b/tests/qemucapabilitiesdata/caps_2.12.0.x86_64.xml
@@ -225,6 +225,7 @@
   
   
   
+  
   2011090
   0
   390060
diff --git a/tests/qemuxml2argvdata/tpm-passthrough-crb.args 
b/tests/qemuxml2argvdata/tpm-passthrough-crb.args
new file mode 100644
index 000..ae052b4
--- /dev/null
+++ b/tests/qemuxml2argvdata/tpm-passthrough-crb.args
@@ -0,0 +1,24 @@
+LC_ALL=C \
+PATH=/bin \
+HOME=/home/test \
+USER=test \
+LOGNAME=test \
+QEMU_AUDIO_DRV=none \

[libvirt] [PATCH 6/6] tpm: Add swtpm to emulator cgroup

2018-04-05 Thread Stefan Berger
Add the external swtpm to the emulator cgroup so that upper limits of CPU
usage can be enforced on the emulated TPM.

To enable this we need to have the swtpm write its pid into a file. We then
take the pid from this file to configure the emulator cgroup.

Signed-off-by: Stefan Berger 
---
 src/conf/domain_conf.c|  1 +
 src/conf/domain_conf.h|  1 +
 src/libvirt_private.syms  |  1 +
 src/qemu/qemu_cgroup.c| 53 
 src/qemu/qemu_cgroup.h|  1 +
 src/qemu/qemu_extdevice.c | 40 +--
 src/qemu/qemu_extdevice.h |  2 +-
 src/qemu/qemu_process.c   |  8 +--
 src/util/vircgroup.c  | 42 
 src/util/vircgroup.h  |  1 +
 src/util/virtpm.c | 61 +--
 src/util/virtpm.h |  6 +++--
 12 files changed, 203 insertions(+), 14 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 5498e2e..1b41584 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -2625,6 +2625,7 @@ void virDomainTPMDefFree(virDomainTPMDefPtr def)
 VIR_FREE(def->data.emulator.source.data.nix.path);
 VIR_FREE(def->data.emulator.storagepath);
 VIR_FREE(def->data.emulator.logfile);
+VIR_FREE(def->data.emulator.pidfile);
 break;
 case VIR_DOMAIN_TPM_TYPE_LAST:
 break;
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 4aab54b..29ef7ff 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -1310,6 +1310,7 @@ struct _virDomainTPMDef {
 /* swtpm storage path and logfile */
 char *storagepath;
 char *logfile;
+char *pidfile;
 } emulator;
 } data;
 };
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 42d..db69b56 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -1468,6 +1468,7 @@ virBufferVasprintf;
 
 # util/vircgroup.h
 virCgroupAddMachineTask;
+virCgroupAddProc;
 virCgroupAddTask;
 virCgroupAddTaskController;
 virCgroupAllowAllDevices;
diff --git a/src/qemu/qemu_cgroup.c b/src/qemu/qemu_cgroup.c
index bd4859c..859ed55 100644
--- a/src/qemu/qemu_cgroup.c
+++ b/src/qemu/qemu_cgroup.c
@@ -37,6 +37,7 @@
 #include "virtypedparam.h"
 #include "virnuma.h"
 #include "virsystemd.h"
+#include "virpidfile.h"
 
 #define VIR_FROM_THIS VIR_FROM_QEMU
 
@@ -1106,6 +1107,58 @@ qemuSetupCgroupCpusetCpus(virCgroupPtr cgroup,
 
 
 int
+qemuSetupCgroupForExtDevices(virDomainObjPtr vm)
+{
+qemuDomainObjPrivatePtr priv = vm->privateData;
+virDomainTPMDefPtr tpm = vm->def->tpm;
+virCgroupPtr cgroup_temp = NULL;
+pid_t pid;
+int ret = -1;
+
+if (priv->cgroup == NULL)
+return 0; /* Not supported, so claim success */
+
+/*
+ * If CPU cgroup controller is not initialized here, then we need
+ * neither period nor quota settings.  And if CPUSET controller is
+ * not initialized either, then there's nothing to do anyway.
+ */
+if (!virCgroupHasController(priv->cgroup, VIR_CGROUP_CONTROLLER_CPU) &&
+!virCgroupHasController(priv->cgroup, VIR_CGROUP_CONTROLLER_CPUSET))
+return 0;
+
+if (virCgroupNewThread(priv->cgroup, VIR_CGROUP_THREAD_EMULATOR, 0,
+   false, _temp) < 0)
+goto cleanup;
+
+if (tpm) {
+switch (tpm->type) {
+case VIR_DOMAIN_TPM_TYPE_EMULATOR:
+if (virPidFileReadPath(tpm->data.emulator.pidfile, ) < 0) {
+virReportError(VIR_ERR_INTERNAL_ERROR,
+   _("Could not read swtpm's pidfile %s"),
+   tpm->data.emulator.pidfile);
+goto cleanup;
+}
+if (virCgroupAddProc(cgroup_temp, pid) < 0)
+goto cleanup;
+break;
+case VIR_DOMAIN_TPM_TYPE_PASSTHROUGH:
+case VIR_DOMAIN_TPM_TYPE_LAST:
+break;
+}
+}
+
+ret = 0;
+
+cleanup:
+virCgroupFree(_temp);
+
+return ret;
+}
+
+
+int
 qemuSetupGlobalCpuCgroup(virDomainObjPtr vm)
 {
 qemuDomainObjPrivatePtr priv = vm->privateData;
diff --git a/src/qemu/qemu_cgroup.h b/src/qemu/qemu_cgroup.h
index 3b8ff60..478bf7e 100644
--- a/src/qemu/qemu_cgroup.h
+++ b/src/qemu/qemu_cgroup.h
@@ -69,6 +69,7 @@ int qemuSetupCgroupVcpuBW(virCgroupPtr cgroup,
   long long quota);
 int qemuSetupCgroupCpusetCpus(virCgroupPtr cgroup, virBitmapPtr cpumask);
 int qemuSetupGlobalCpuCgroup(virDomainObjPtr vm);
+int qemuSetupCgroupForExtDevices(virDomainObjPtr vm);
 int qemuRemoveCgroup(virDomainObjPtr vm);
 
 typedef struct _qemuCgroupEmulatorAllNodesData qemuCgroupEmulatorAllNodesData;
diff --git a/src/qemu/qemu_extdevice.c b/src/qemu/qemu_extdevice.c
index e685faf..439cb31 100644
--- a/src/qemu/qemu_extdevice.c
+++ b/src/qemu/qemu_extdevice.c
@@ -35,6 +35,7 @@
 
 VIR_LOG_INIT("qemu.qemu_extdevice")
 

[libvirt] [PATCH 4/6] tpm: Handle TPM emulator device reconfigurations

2018-04-05 Thread Stefan Berger
This patch looks at device changes due to modified XML. With the TPM
emulator we have to handle cases where the TPM is removed from the VM
or when it is reconfigured in some way.

In the device removal case we remove the storage path.

The function we create here will be used later to handle other device
changes as well.

Signed-off-by: Stefan Berger 
---
 src/conf/domain_conf.c   | 38 ++
 src/conf/domain_conf.h   |  3 +++
 src/libvirt_private.syms |  1 +
 src/qemu/qemu_driver.c   |  3 ++-
 4 files changed, 44 insertions(+), 1 deletion(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 9f7f3ce..72e4412 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -29412,3 +29412,41 @@ virDomainDiskTranslateSourcePool(virDomainDiskDefPtr 
def)
 virStoragePoolDefFree(pooldef);
 return ret;
 }
+
+
+static int
+virDomainCheckTPMChanges(virDomainDefPtr def,
+ virDomainDefPtr newDef)
+{
+int ret = 0;
+
+if (!def->tpm)
+return 0;
+
+if (!newDef->tpm) {
+/* TPM removed */
+virDomainTPMDeleteAny(def);
+} else {
+if (newDef->tpm->type != def->tpm->type) {
+/* type changed */
+virDomainTPMDeleteAny(def);
+}
+}
+
+return ret;
+}
+
+
+int
+virDomainCheckDeviceChanges(virDomainDefPtr def,
+virDomainDefPtr newDef)
+{
+int ret;
+
+if (!def || !newDef)
+return 0;
+
+ret = virDomainCheckTPMChanges(def, newDef);
+
+return ret;
+}
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 9802533..1f479b0 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -3537,5 +3537,8 @@ virDomainNetResolveActualType(virDomainNetDefPtr iface)
 
 int virDomainDiskTranslateSourcePool(virDomainDiskDefPtr def);
 
+int virDomainCheckDeviceChanges(virDomainDefPtr def,
+virDomainDefPtr newDef)
+ATTRIBUTE_NONNULL(1);
 
 #endif /* __DOMAIN_CONF_H */
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 191142e..42d 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -198,6 +198,7 @@ virDomainBootTypeFromString;
 virDomainBootTypeToString;
 virDomainCapabilitiesPolicyTypeToString;
 virDomainCapsFeatureTypeToString;
+virDomainCheckDeviceChanges;
 virDomainChrConsoleTargetTypeFromString;
 virDomainChrConsoleTargetTypeToString;
 virDomainChrDefForeach;
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index ef0d0c9..e7a325c 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -7438,7 +7438,8 @@ qemuDomainDefineXMLFlags(virConnectPtr conn,
 }
 vm->persistent = 1;
 
-if (virDomainSaveConfig(cfg->configDir, driver->caps,
+if (virDomainCheckDeviceChanges(oldDef, vm->def) < 0 ||
+virDomainSaveConfig(cfg->configDir, driver->caps,
 vm->newDef ? vm->newDef : vm->def) < 0) {
 if (oldDef) {
 /* There is backup so this VM was defined before.
-- 
2.5.5

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [PATCH 5/6] tpm: Add support for choosing emulation of a TPM 2

2018-04-05 Thread Stefan Berger
This patch extends the TPM's device XML with TPM 2 support. This only works
for the emulator type backend and looks as follows:


  


Once the version of a TPM has been chosen it cannot be changed anymore unless
one removes the TPM device first and then reads it. However, one looses all
the secrets stored inside or tied to the emulated TPM by doing this.

Signed-off-by: Stefan Berger 
---
 docs/formatdomain.html.in  | 17 ++-
 docs/schemas/domaincommon.rng  | 13 ++
 src/conf/domain_conf.c | 36 ++-
 src/conf/domain_conf.h |  6 +++
 src/util/virtpm.c  | 64 +-
 tests/qemuxml2argvdata/tpm-emulator-tpm2.args  | 24 ++
 tests/qemuxml2argvdata/tpm-emulator-tpm2.xml   | 30 
 tests/qemuxml2argvtest.c   |  3 ++
 tests/qemuxml2xmloutdata/tpm-emulator-tpm2.xml | 34 ++
 9 files changed, 223 insertions(+), 4 deletions(-)
 create mode 100644 tests/qemuxml2argvdata/tpm-emulator-tpm2.args
 create mode 100644 tests/qemuxml2argvdata/tpm-emulator-tpm2.xml
 create mode 100644 tests/qemuxml2xmloutdata/tpm-emulator-tpm2.xml

diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index bd6fedc..e5463a0 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -7635,7 +7635,7 @@ qemu-kvm -net nic,model=? /dev/null
   ...
   devices
 tpm model='tpm-tis'
-  backend type='emulator'
+  backend type='emulator' tpmversion='2'
   /backend
 /tpm
   /devices
@@ -7684,6 +7684,21 @@ qemu-kvm -net nic,model=? /dev/null
   
 
   
+  tpmversion
+  
+
+  The tpmversion attribute indicates the version
+  of the TPM. By default a TPM 1.2 is created. This attribute
+  only works with the emulator backend. The following
+  versions are supported:
+
+
+  '1.2' : creates a TPM 1.2
+  '2.0' or '2' :  creates a TPM 2
+
+Note that once a certain version of a TPM has been created for
+a guest, the version must not be changed anymore.
+  
 
 
 NVRAM device
diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
index d628444..77328bd 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -4140,6 +4140,19 @@
   
 
   
+  
+
+  
+
+  
+1.2
+2
+2.0
+  
+   
+  
+
+  
 
   
 
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 72e4412..5498e2e 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -12557,7 +12557,7 @@ virDomainSmartcardDefParseXML(virDomainXMLOptionPtr 
xmlopt,
  * or like this:
  *
  * 
- *   
+ *   
  * 
  */
 static virDomainTPMDefPtr
@@ -12570,6 +12570,7 @@ virDomainTPMDefParseXML(virDomainXMLOptionPtr xmlopt,
 char *path = NULL;
 char *model = NULL;
 char *backend = NULL;
+char *tpmversion = NULL;
 virDomainTPMDefPtr def;
 xmlNodePtr save = ctxt->node;
 xmlNodePtr *backends = NULL;
@@ -12616,6 +12617,20 @@ virDomainTPMDefParseXML(virDomainXMLOptionPtr xmlopt,
 goto error;
 }
 
+tpmversion = virXMLPropString(backends[0], "tpmversion");
+if (!tpmversion || STREQ(tpmversion, "1.2")) {
+def->tpmversion = VIR_DOMAIN_TPM_VERSION_1_2;
+/* only TIS available for emulator */
+if (def->type == VIR_DOMAIN_TPM_TYPE_EMULATOR)
+def->model = VIR_DOMAIN_TPM_MODEL_TIS;
+} else if (STREQ(tpmversion, "2.0") || STREQ(tpmversion, "2")) {
+def->tpmversion = VIR_DOMAIN_TPM_VERSION_2;
+} else {
+virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+   _("Unsupported TPM version '%s'"),
+   tpmversion);
+}
+
 switch (def->type) {
 case VIR_DOMAIN_TPM_TYPE_PASSTHROUGH:
 path = virXPathString("string(./backend/device/@path)", ctxt);
@@ -12640,6 +12655,7 @@ virDomainTPMDefParseXML(virDomainXMLOptionPtr xmlopt,
 VIR_FREE(model);
 VIR_FREE(backend);
 VIR_FREE(backends);
+VIR_FREE(tpmversion);
 ctxt->node = save;
 return def;
 
@@ -24803,6 +24819,8 @@ virDomainTPMDefFormat(virBufferPtr buf,
 virBufferAdjustIndent(buf, 2);
 virBufferAsprintf(buf, "type));
+if (def->tpmversion == VIR_DOMAIN_TPM_VERSION_2)
+virBufferAddLit(buf, " tpmversion='2'");
 virBufferAdjustIndent(buf, 2);
 
 switch (def->type) {
@@ -29430,6 +29448,22 @@ virDomainCheckTPMChanges(virDomainDefPtr def,
 if (newDef->tpm->type != def->tpm->type) {
 /* type changed */
 virDomainTPMDeleteAny(def);
+} else {
+switch (def->tpm->type) {
+case VIR_DOMAIN_TPM_TYPE_EMULATOR:
+if 

[libvirt] [PATCH 3/6] tpm: Label the external swtpm with SELinux labels

2018-04-05 Thread Stefan Berger
In this patch we label the swtpm process with SELinux labels. We give it the
same label as the QEMU process has. We label its state directory and files
as well.

The file and process labels now look as follows:

[root@localhost tpm]# ls -lZ
total 4
rwx--. 2 tss  tss  system_u:object_r:svirt_image_t:s0:c254,c932 4096 Apr  5 
16:46 485d0004-a48f-436a-8457-8a3b73e28567
srw---. 1 qemu qemu system_u:object_r:svirt_image_t:s0:c254,c9320 Apr  
5 16:57 485d0004-a48f-436a-8457-8a3b73e28567.sock

[root@localhost 485d0004-a48f-436a-8457-8a3b73e28567]# ls -lZ
total 8
-rw-r--r--. 1 tss tss system_u:object_r:svirt_image_t:s0:c254,c932 3648 Apr  5 
16:46 tpm-00.permall
-rw-r--r--. 1 tss tss system_u:object_r:svirt_image_t:s0:c254,c932 2237 Apr  5 
16:46 vtpm.log

root@sbct-3 485d0004-a48f-436a-8457-8a3b73e28567]# ps auxZ | grep swtpm | grep 
-v grep
system_u:system_r:svirt_t:s0:c254,c932 tss 25664 0.0  0.0 28172  3892 ?
Ss   16:57   0:00 /usr/bin/swtpm socket --daemon --ctrl 
type=unixio,path=/var/lib/libvirt/tpm/485d0004-a48f-436a-8457-8a3b73e28567.sock,mode=0600
 --tpmstate dir=/var/lib/libvirt/tpm/485d0004-a48f-436a-8457-8a3b73e28567 --log 
file=/var/lib/libvirt/tpm/485d0004-a48f-436a-8457-8a3b73e28567/vtpm.log --runas 
59

[root@sbct-3 485d0004-a48f-436a-8457-8a3b73e28567]# ps auxZ | grep qemu | grep 
tpm | grep -v grep
system_u:system_r:svirt_t:s0:c254,c932 qemu 25669 99.0  0.0 3096704 48500 ?
Sl   16:57   3:28 /bin/qemu-system-x86_64 -name 
guest=centos7.0,debug-threads=on -S -object 
secret,id=masterKey0,format=raw,file=/var/lib/libvirt/qemu/domain-1-centos7.0/master-key.aes
 -machine pc-i440fx-2.8,accel=kvm,usb=off,dump-guest-core=off -cpu kvm64 -m 
2048 -realtime mlock=off -smp 2,sockets=2,cores=1,threads=1 -uuid 
485d0004-a48f-436a-8457-8a3b73e28567 [...] -tpmdev 
emulator,id=tpm-tpm0,chardev=chrtpm -chardev 
socket,id=chrtpm,path=/var/lib/libvirt/tpm/485d0004-a48f-436a-8457-8a3b73e28567.sock
 -device tpm-tis,tpmdev=tpm-tpm0,id=tpm0 -device 
usb-mouse,id=input0,bus=usb.0,port=1 -vnc 127.0.0.1:0 -device 
cirrus-vga,id=video0,bus=pci.0,addr=0x2 -device 
virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x6 -msg timestamp=on

Signed-off-by: Stefan Berger 
---
 src/conf/domain_conf.c  |  2 +
 src/conf/domain_conf.h  |  3 ++
 src/libvirt_private.syms|  1 +
 src/qemu/qemu_extdevice.c   | 26 +++-
 src/security/security_driver.h  |  5 ++-
 src/security/security_manager.c | 15 +++
 src/security/security_manager.h |  3 ++
 src/security/security_selinux.c | 90 +
 src/security/security_stack.c   | 19 +
 src/util/virtpm.c   |  5 ++-
 10 files changed, 165 insertions(+), 4 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index da14ef8..9f7f3ce 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -2623,6 +2623,8 @@ void virDomainTPMDefFree(virDomainTPMDefPtr def)
 break;
 case VIR_DOMAIN_TPM_TYPE_EMULATOR:
 VIR_FREE(def->data.emulator.source.data.nix.path);
+VIR_FREE(def->data.emulator.storagepath);
+VIR_FREE(def->data.emulator.logfile);
 break;
 case VIR_DOMAIN_TPM_TYPE_LAST:
 break;
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 4ecc70d..9802533 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -1301,6 +1301,9 @@ struct _virDomainTPMDef {
 } passthrough;
 struct {
 virDomainChrSourceDef source;
+/* swtpm storage path and logfile */
+char *storagepath;
+char *logfile;
 } emulator;
 } data;
 };
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index e64bbef..191142e 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -1334,6 +1334,7 @@ virSecurityManagerSetProcessLabel;
 virSecurityManagerSetSavedStateLabel;
 virSecurityManagerSetSocketLabel;
 virSecurityManagerSetTapFDLabel;
+virSecurityManagerSetTPMLabels;
 virSecurityManagerStackAddNested;
 virSecurityManagerTransactionAbort;
 virSecurityManagerTransactionCommit;
diff --git a/src/qemu/qemu_extdevice.c b/src/qemu/qemu_extdevice.c
index 4f42c9b..e685faf 100644
--- a/src/qemu/qemu_extdevice.c
+++ b/src/qemu/qemu_extdevice.c
@@ -105,12 +105,36 @@ qemuExtTPMStartEmulator(virQEMUDriverPtr driver,
 
 virCommandSetErrorBuffer(cmd, );
 
-if (virCommandRun(cmd, ) < 0 || exitstatus != 0) {
+if (virSecurityManagerSetTPMLabels(driver->securityManager,
+   def) < 0)
+goto error;
+
+if (virSecurityManagerSetChildProcessLabel(driver->securityManager,
+   def, cmd) < 0)
+goto error;
+
+if (virSecurityManagerPreFork(driver->securityManager) < 0)
+goto error;
+
+/*
+ * make sure we run this as root
+ * note: when installing libvirtd via make install we don't need this,
+ 

Re: [libvirt] [PATCH 2/2] util: introduce virSocketAddrParseAny

2018-04-05 Thread Jim Fehlig

On 04/05/2018 02:55 PM, Jim Fehlig wrote:

On 03/29/2018 11:27 AM, John Ferlan wrote:



On 03/26/2018 04:29 PM, Jim Fehlig wrote:

When preparing for migration, the libxl driver creates a new TCP listen
socket for the incoming migration by calling virNetSocketNewListenTCP,
passing the destination host name. virNetSocketNewListenTCP calls
virSocketAddrParse to check if the host name is a wildcard address, in
which case it avoids adding the AI_ADDRCONFIG flag to the hints passed to
getaddrinfo. If the host name is not an IP address, virSocketAddrParse
reports an error

error : virSocketAddrParseInternal:121 : Cannot parse socket address
'myhost.example.com': Name or service not known

But virNetSocketNewListenTCP succeeds regardless and the overall migration
operation succeeds.

Introduce virSocketAddrParseAny and use it when simply testing if a host
name/addr is parsable.

Signed-off-by: Jim Fehlig 
---

Essentially a V2 of

https://www.redhat.com/archives/libvir-list/2018-March/msg01120.html

It takes a slightly different approach by creating a function that can
parse host names or IP addresses.

  src/libvirt_private.syms |  1 +
  src/rpc/virnetsocket.c   |  2 +-
  src/util/virsocketaddr.c | 50 +---
  src/util/virsocketaddr.h |  5 +
  4 files changed, 54 insertions(+), 4 deletions(-)



Reviewed-by: John Ferlan 

Wait for 4.2.0 for this one...

John

BTW: Your call on whether to add to the new API comments something about
the API could be susceptible to a delay due to network name resolution
lookup pause.  That is, from the getaddrinfo man page:

"The AI_NUMERICHOST flag suppresses any potentially lengthy network host
address lookups."


Good point. I squashed in the below comment to this patch before pushing both.

Regards,
Jim

diff --git a/src/util/virsocketaddr.c b/src/util/virsocketaddr.c
index 84610560f..99dc54830 100644
--- a/src/util/virsocketaddr.c
+++ b/src/util/virsocketaddr.c
@@ -173,7 +173,10 @@ int virSocketAddrParse(virSocketAddrPtr addr, const char 
*val, int family)

   *
   * Mostly a wrapper for getaddrinfo() extracting the address storage
   * from a host name like acme.example.com or a numeric string like 1.2.3.4
- * or 2001:db8:85a3:0:0:8a2e:370:7334
+ * or 2001:db8:85a3:0:0:8a2e:370:7334.
+ *
+ * When @val is a network host name, this function may be susceptible to a
+ * delay due to potentially lengthy netork host address lookups.


Heh, only now did I notice the misspelling of 'network'. I'll push a trivial 
followup.


Regards,
Jim

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

[libvirt] [PATCH] util: fix spelling in virSocketAddrParseAny docs

2018-04-05 Thread Jim Fehlig
s/netork/network/

Signed-off-by: Jim Fehlig 
---

Pushing as trivial.

 src/util/virsocketaddr.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/util/virsocketaddr.c b/src/util/virsocketaddr.c
index 4f2457629..5c3bfad0a 100644
--- a/src/util/virsocketaddr.c
+++ b/src/util/virsocketaddr.c
@@ -176,7 +176,7 @@ int virSocketAddrParse(virSocketAddrPtr addr, const char 
*val, int family)
  * or 2001:db8:85a3:0:0:8a2e:370:7334.
  *
  * When @val is a network host name, this function may be susceptible to a
- * delay due to potentially lengthy netork host address lookups.
+ * delay due to potentially lengthy network host address lookups.
  *
  * Returns the length of the network address or -1 in case of error.
  */
-- 
2.16.2

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] [PATCH 2/2] util: introduce virSocketAddrParseAny

2018-04-05 Thread Jim Fehlig

On 03/29/2018 11:27 AM, John Ferlan wrote:



On 03/26/2018 04:29 PM, Jim Fehlig wrote:

When preparing for migration, the libxl driver creates a new TCP listen
socket for the incoming migration by calling virNetSocketNewListenTCP,
passing the destination host name. virNetSocketNewListenTCP calls
virSocketAddrParse to check if the host name is a wildcard address, in
which case it avoids adding the AI_ADDRCONFIG flag to the hints passed to
getaddrinfo. If the host name is not an IP address, virSocketAddrParse
reports an error

error : virSocketAddrParseInternal:121 : Cannot parse socket address
'myhost.example.com': Name or service not known

But virNetSocketNewListenTCP succeeds regardless and the overall migration
operation succeeds.

Introduce virSocketAddrParseAny and use it when simply testing if a host
name/addr is parsable.

Signed-off-by: Jim Fehlig 
---

Essentially a V2 of

https://www.redhat.com/archives/libvir-list/2018-March/msg01120.html

It takes a slightly different approach by creating a function that can
parse host names or IP addresses.

  src/libvirt_private.syms |  1 +
  src/rpc/virnetsocket.c   |  2 +-
  src/util/virsocketaddr.c | 50 +---
  src/util/virsocketaddr.h |  5 +
  4 files changed, 54 insertions(+), 4 deletions(-)



Reviewed-by: John Ferlan 

Wait for 4.2.0 for this one...

John

BTW: Your call on whether to add to the new API comments something about
the API could be susceptible to a delay due to network name resolution
lookup pause.  That is, from the getaddrinfo man page:

"The AI_NUMERICHOST flag suppresses any potentially lengthy network host
address lookups."


Good point. I squashed in the below comment to this patch before pushing both.

Regards,
Jim

diff --git a/src/util/virsocketaddr.c b/src/util/virsocketaddr.c
index 84610560f..99dc54830 100644
--- a/src/util/virsocketaddr.c
+++ b/src/util/virsocketaddr.c
@@ -173,7 +173,10 @@ int virSocketAddrParse(virSocketAddrPtr addr, const char 
*val, int family)

  *
  * Mostly a wrapper for getaddrinfo() extracting the address storage
  * from a host name like acme.example.com or a numeric string like 1.2.3.4
- * or 2001:db8:85a3:0:0:8a2e:370:7334
+ * or 2001:db8:85a3:0:0:8a2e:370:7334.
+ *
+ * When @val is a network host name, this function may be susceptible to a
+ * delay due to potentially lengthy netork host address lookups.
  *
  * Returns the length of the network address or -1 in case of error.
  */

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] anyone ever seen virDomainCreateWithFlags() essentially hang?

2018-04-05 Thread Chris Friesen

On 04/05/2018 12:17 PM, Jiri Denemark wrote:

On Thu, Apr 05, 2018 at 12:00:44 -0600, Chris Friesen wrote:

I'm investigating something weird with libvirt 1.2.17 and qemu 2.3.0.

I'm using the python bindings, and I seem to have a case where
libvirtmod.virDomainCreateWithFlags() hung rather than returned.  Then, about
15min later a subsequent call to libvirtmod.virDomainDestroy() from a different
eventlet within the same process seems to have "unblocked" the original creation
call, which raised an exception and an error code of
libvirt.VIR_ERR_INTERNAL_ERROR.  The virDomainDestroy() call came back with an
error of "Requested operation is not valid: domain is not running".

The corresponding qemu logs show the guest starting up and then a bit over 15min
later there is a "shutting down" log.  At shutdown time the libvirtd log shows
"qemuMonitorIORead:609 : Unable to read from monitor: Connection reset by peer".


Looks like qemu is hung and is not responding to commands libvirt sends
to the QEMU's monitor socket. And since this happens while libvirt is in
the process of starting up the domain (it sends several commands to QEMU
before it starts the virtual CPU and considers the domain running), you
see a hanging virDomainCreateWithFlags API.


Seems plausible.  The libvirt qemuDomainDestroyFlags() code seems to kill the 
qemu process first before emitting the "domain is not running" error, so that 
would fit with the logs.


Of course now I have an unexplained qemu hang, which isn't much better. :)

Chris

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] anyone ever seen virDomainCreateWithFlags() essentially hang?

2018-04-05 Thread Jiri Denemark
On Thu, Apr 05, 2018 at 12:00:44 -0600, Chris Friesen wrote:
> I'm investigating something weird with libvirt 1.2.17 and qemu 2.3.0.
> 
> I'm using the python bindings, and I seem to have a case where 
> libvirtmod.virDomainCreateWithFlags() hung rather than returned.  Then, about 
> 15min later a subsequent call to libvirtmod.virDomainDestroy() from a 
> different 
> eventlet within the same process seems to have "unblocked" the original 
> creation 
> call, which raised an exception and an error code of 
> libvirt.VIR_ERR_INTERNAL_ERROR.  The virDomainDestroy() call came back with 
> an 
> error of "Requested operation is not valid: domain is not running".
> 
> The corresponding qemu logs show the guest starting up and then a bit over 
> 15min 
> later there is a "shutting down" log.  At shutdown time the libvirtd log 
> shows 
> "qemuMonitorIORead:609 : Unable to read from monitor: Connection reset by 
> peer".

Looks like qemu is hung and is not responding to commands libvirt sends
to the QEMU's monitor socket. And since this happens while libvirt is in
the process of starting up the domain (it sends several commands to QEMU
before it starts the virtual CPU and considers the domain running), you
see a hanging virDomainCreateWithFlags API.

Jirka

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] anyone ever seen virDomainCreateWithFlags() essentially hang?

2018-04-05 Thread Chris Friesen

I'm investigating something weird with libvirt 1.2.17 and qemu 2.3.0.

I'm using the python bindings, and I seem to have a case where 
libvirtmod.virDomainCreateWithFlags() hung rather than returned.  Then, about 
15min later a subsequent call to libvirtmod.virDomainDestroy() from a different 
eventlet within the same process seems to have "unblocked" the original creation 
call, which raised an exception and an error code of 
libvirt.VIR_ERR_INTERNAL_ERROR.  The virDomainDestroy() call came back with an 
error of "Requested operation is not valid: domain is not running".


The corresponding qemu logs show the guest starting up and then a bit over 15min 
later there is a "shutting down" log.  At shutdown time the libvirtd log shows 
"qemuMonitorIORead:609 : Unable to read from monitor: Connection reset by peer".


The parent function did two additional retries, and both the retries failed in 
similar fashion.


In all three caess there seems to be a pattern of the qemu instance starting up 
but virDomainCreateWithFlags() not returning, then a subsequent 
virDomainDestroy() call for the same domain causing the 
virDomainCreateWithFlags() call to get "unblocked" and return -1 leading to an 
exception in the python code.


Any ideas what might cause this behaviour?

I haven't reproduced the "hanging" behaviour myself, I'm working entirely off of 
logs from the affected system.


Thanks,
Chris

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] [PATCH 0/7] Prepare for daemon split

2018-04-05 Thread Daniel P . Berrangé
On Thu, Apr 05, 2018 at 01:06:28PM -0400, Laine Stump wrote:
> On 03/28/2018 11:18 AM, Daniel P. Berrangé wrote:
> > When we split up the daemons, libvirtd will need to forward different
> > sets of APIs to different daemons. This means libvirtd is going to need
> > to have multiple virConnectPtr instances open.
> 
> Have you done any thinking about what will need to be added to the
> network driver API (or how)? I'd like to be involved with that.

I've not thought about it beyond hoping magic ponies will solve the
problems you describe below :)  So far I'm just working on the general
refactoring to let us (optionally) create the various daemons so there
is something concrete to explore the problems with.

> One part that troubles me is that there will no longer be a parent-child
> relationship between the process keeping track of network allocations
> and the qemu process - currently if a qemu process dies, libvirtd knows
> about it and can recover the resources that had been allocated, but with
> the network driver in a separate process, qemu could die and
> libvirtd-qemu might not be around to notify libvirtd-network (or
> whatever we end up calling the processes).

BTW, naming will be virt${DRIVER}d (eg virtqemud, virtnetworkd, etc) but
minor detail. Anyway, if QEMU dies, and virtqemud isn't running, then
when virtqemud starts up again it would notice that the QEMU went away
and do recovery, presumably telling other daemons to release resources
if needed.

> Likewise, there is the nwfilter driver's complicated callback setup to
> reload the iptables rules of all relevant domains when a filter's
> definition is changed. I haven't thought about the details, but I think
> that will need some "interesting" handling.

I was thinking the nwfilter automatic rebuild ought to be possible to
have entirely self-contained, because rebuilding shouldn't need help
from the QEMU driver - it just needs the TAP dev to exist.

> Also the network driver and nwfilter driver both use virfirewall.c,
> which has a mutex to prevent simultaneous updates; either we'll need to
> put that functionality into one of the drivers and have the other one
> call it via a public API, or we'll need to rely on iptables -w (but even
> that could lead to different results, since it's locking just during
> application of a single rule rather than a complete transaction (as
> defined by virfirewall.c).

Two possible options

 - Replace the mutex with a lock file + fcntl() locks, that both
   virnetworkd & virnwfilterd will use
 - Have virnetworkd actually call virnwfilterd to setup the rules
   it needs. I'm not sure if nwfilter can express the rules we
   need though.


Regards,
Daniel
-- 
|: https://berrange.com  -o-https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org -o-https://fstop138.berrange.com :|
|: https://entangle-photo.org-o-https://www.instagram.com/dberrange :|

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Re: [libvirt] [PATCH 0/7] Prepare for daemon split

2018-04-05 Thread Laine Stump
On 03/28/2018 11:18 AM, Daniel P. Berrangé wrote:
> When we split up the daemons, libvirtd will need to forward different
> sets of APIs to different daemons. This means libvirtd is going to need
> to have multiple virConnectPtr instances open.

Have you done any thinking about what will need to be added to the
network driver API (or how)? I'd like to be involved with that.

One part that troubles me is that there will no longer be a parent-child
relationship between the process keeping track of network allocations
and the qemu process - currently if a qemu process dies, libvirtd knows
about it and can recover the resources that had been allocated, but with
the network driver in a separate process, qemu could die and
libvirtd-qemu might not be around to notify libvirtd-network (or
whatever we end up calling the processes).

Likewise, there is the nwfilter driver's complicated callback setup to
reload the iptables rules of all relevant domains when a filter's
definition is changed. I haven't thought about the details, but I think
that will need some "interesting" handling.

Also the network driver and nwfilter driver both use virfirewall.c,
which has a mutex to prevent simultaneous updates; either we'll need to
put that functionality into one of the drivers and have the other one
call it via a public API, or we'll need to rely on iptables -w (but even
that could lead to different results, since it's locking just during
application of a single rule rather than a complete transaction (as
defined by virfirewall.c).

>
> This series prepares for that by introducing "separate" connections,
> which are actually just an extra reference on the current single
> connection. This will facilitate later changes.
>
> Daniel P. Berrangé (7):
>   rpc: refactor way connection object is generated for remote dispatch
>   remote: use a separate connection for interface APIs
>   remote: use a separate connection for network APIs
>   remote: use a separate connection for nodedev APIs
>   remote: use a separate connection for nwfilter APIs
>   remote: use a separate connection for secret APIs
>   remote: use a separate connection for storage APIs
>
>  src/remote/remote_daemon.h  |  6 +++
>  src/remote/remote_daemon_dispatch.c | 81 +++
>  src/rpc/gendispatch.pl  | 95 
> -
>  3 files changed, 128 insertions(+), 54 deletions(-)
>

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Re: [libvirt] Run libvirtd from git: virsh hangs

2018-04-05 Thread Mathieu Tarral
> strace isn't very helpful for debugging hangs - better to connect to
> libvirtd with GDB and get a stack trace of all threads, using
>
>   (gdb)  thread apply all bt

This is what i have with GDB

(gdb) thread apply all bt

Thread 1 (Thread 0x7f8b18e7c700 (LWP 4196)):
#0  pthread_cond_wait@@GLIBC_2.3.2 () at
../sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S:185
#1  0x7f8b207eb6e6 in virCondWait (c=c@entry=0x55d3353c7c68,
m=m@entry=0x55d3353c7ba0) at util/virthread.c:154
#2  0x7f8b207ec1f4 in virThreadPoolWorker
(opaque=opaque@entry=0x55d3353d3a40) at util/virthreadpool.c:124
#3  0x7f8b207eb488 in virThreadHelper (data=) at
util/virthread.c:206
#4  0x7f8b1f89c494 in start_thread (arg=0x7f8b18e7c700) at
pthread_create.c:333
#5  0x7f8b1f5deacf in clone () at
../sysdeps/unix/sysv/linux/x86_64/clone.S:97

Just one thread, waiting.

Thanks.

-- 
Mathieu Tarral

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [jenkins-ci PATCH 1/2] jobs: Don't set $PYTHONPATH for python-distutil jobs

2018-04-05 Thread Andrea Bolognani
Now that $PYTHONPATH is set in the environment through the
shell profile, we no longer need to set it at the Jenkins
level for the virt-manager build to succeed.

This reverts commit 6116509ac308562f69d533651d40599a7ce36b39.

Signed-off-by: Andrea Bolognani 
---
 jobs/python-distutils.yaml | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/jobs/python-distutils.yaml b/jobs/python-distutils.yaml
index 16eca1c..8ef0b27 100644
--- a/jobs/python-distutils.yaml
+++ b/jobs/python-distutils.yaml
@@ -42,7 +42,6 @@
   - shell: |
   {global_env}
   {local_env}
-  export 
PYTHONPATH=$VIRT_PREFIX/lib/python{pyver}.4/site-packages:$VIRT_PREFIX/lib64/python{pyver}.4/site-packages:$VIRT_PREFIX/lib/python{pyver}.5/site-packages:$VIRT_PREFIX/lib64/python{pyver}.5/site-packages:$VIRT_PREFIX/lib/python{pyver}.6/site-packages:$VIRT_PREFIX/lib64/python{pyver}.6/site-packages:$VIRT_PREFIX/lib/python{pyver}.7/site-packages:$VIRT_PREFIX/lib64/python{pyver}.7/site-packages
   {command_pre_build}
   python{pyver} ./setup.py build
   python{pyver} ./setup.py install --prefix=$VIRT_PREFIX
@@ -84,7 +83,6 @@
   - shell: |
   {global_env}
   {local_env}
-  export 
PYTHONPATH=$VIRT_PREFIX/lib/python{pyver}.4/site-packages:$VIRT_PREFIX/lib64/python{pyver}.4/site-packages:$VIRT_PREFIX/lib/python{pyver}.5/site-packages:$VIRT_PREFIX/lib64/python{pyver}.5/site-packages:$VIRT_PREFIX/lib/python{pyver}.6/site-packages:$VIRT_PREFIX/lib64/python{pyver}.6/site-packages:$VIRT_PREFIX/lib/python{pyver}.7/site-packages:$VIRT_PREFIX/lib64/python{pyver}.7/site-packages
   python{pyver} ./setup.py test
 publishers:
   - email:
@@ -123,7 +121,6 @@
   - shell: |
   {global_env}
   {local_env}
-  export 
PYTHONPATH=$VIRT_PREFIX/lib/python{pyver}.4/site-packages:$VIRT_PREFIX/lib64/python{pyver}.4/site-packages:$VIRT_PREFIX/lib/python{pyver}.5/site-packages:$VIRT_PREFIX/lib64/python{pyver}.5/site-packages:$VIRT_PREFIX/lib/python{pyver}.6/site-packages:$VIRT_PREFIX/lib64/python{pyver}.6/site-packages:$VIRT_PREFIX/lib/python{pyver}.7/site-packages:$VIRT_PREFIX/lib64/python{pyver}.7/site-packages
   sed -i -e 's/BuildRequires: libvirt.*devel.*//' *.spec.in
   python{pyver} ./setup.py rpm
 publishers:
-- 
2.14.3

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [jenkins-ci PATCH 0/2] jobs: Simplify Python jobs

2018-04-05 Thread Andrea Bolognani
By reverting a bunch of semi-recent changes.

Requires

  https://www.redhat.com/archives/libvir-list/2018-April/msg00356.html

Andrea Bolognani (2):
  jobs: Don't set $PYTHONPATH for python-distutil jobs
  jobs: Build using $PYTHON

 jobs/python-distutils.yaml   | 29 +
 projects/libvirt-python.yaml | 29 ++---
 projects/virt-manager.yaml   | 11 ---
 3 files changed, 19 insertions(+), 50 deletions(-)

-- 
2.14.3

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [jenkins-ci PATCH 2/2] jobs: Build using $PYTHON

2018-04-05 Thread Andrea Bolognani
The current setup is fairly complicated and doesn't buy us
much in terms of coverage: we can default to Python 3 wherever
it's available, and still test Python 2 builds pass thanks to
CentOS, which doesn't have Python 3 yet, and the RPM build jobs,
which build both variants if at all possible.

This reverts commit 57980d405d631f4ce2bfffcec343e506fde343f9
and then some.

Signed-off-by: Andrea Bolognani 
---
 jobs/python-distutils.yaml   | 26 +-
 projects/libvirt-python.yaml | 29 ++---
 projects/virt-manager.yaml   | 11 ---
 3 files changed, 19 insertions(+), 47 deletions(-)

diff --git a/jobs/python-distutils.yaml b/jobs/python-distutils.yaml
index 8ef0b27..bfa0715 100644
--- a/jobs/python-distutils.yaml
+++ b/jobs/python-distutils.yaml
@@ -1,11 +1,11 @@
 
 - job-template:
 id: python-distutils-build-job
-name: '{name}-{branch}-py{pyver}-build'
+name: '{name}-{branch}-build'
 project-type: matrix
-description: '{title} Build (Python {pyver})'
+description: '{title} Build'
 command_pre_build: ''
-workspace: '{name}-{branch}-py{pyver}'
+workspace: '{name}-{branch}'
 child-workspace: '.'
 block-downstream: true
 block-upstream: true
@@ -43,8 +43,8 @@
   {global_env}
   {local_env}
   {command_pre_build}
-  python{pyver} ./setup.py build
-  python{pyver} ./setup.py install --prefix=$VIRT_PREFIX
+  $PYTHON ./setup.py build
+  $PYTHON ./setup.py install --prefix=$VIRT_PREFIX
 publishers:
   - email:
   recipients: '{obj:spam}'
@@ -54,10 +54,10 @@
 
 - job-template:
 id: python-distutils-check-job
-name: '{name}-{branch}-py{pyver}-check'
+name: '{name}-{branch}-check'
 project-type: matrix
-description: '{title} Check (Python {pyver})'
-workspace: '{name}-{branch}-py{pyver}'
+description: '{title} Check'
+workspace: '{name}-{branch}'
 child-workspace: '.'
 block-downstream: true
 block-upstream: true
@@ -83,7 +83,7 @@
   - shell: |
   {global_env}
   {local_env}
-  python{pyver} ./setup.py test
+  $PYTHON ./setup.py test
 publishers:
   - email:
   recipients: '{obj:spam}'
@@ -92,10 +92,10 @@
 
 - job-template:
 id: python-distutils-rpm-job
-name: '{name}-{branch}-py{pyver}-rpm'
+name: '{name}-{branch}-rpm'
 project-type: matrix
-description: '{title} RPM (Python {pyver})'
-workspace: '{name}-{branch}-py{pyver}'
+description: '{title} RPM'
+workspace: '{name}-{branch}'
 child-workspace: '.'
 block-downstream: true
 block-upstream: true
@@ -122,7 +122,7 @@
   {global_env}
   {local_env}
   sed -i -e 's/BuildRequires: libvirt.*devel.*//' *.spec.in
-  python{pyver} ./setup.py rpm
+  $PYTHON ./setup.py rpm
 publishers:
   - email:
   recipients: '{obj:spam}'
diff --git a/projects/libvirt-python.yaml b/projects/libvirt-python.yaml
index 1c29321..dd8ac13 100644
--- a/projects/libvirt-python.yaml
+++ b/projects/libvirt-python.yaml
@@ -14,36 +14,11 @@
 title: Libvirt Python
 jobs:
   - python-distutils-build-job:
-  pyver: 2
   parent_jobs: 'libvirt-master-build'
-  - python-distutils-build-job:
-  pyver: 3
-  parent_jobs: 'libvirt-master-build'
-  machines:
-- libvirt-debian-8
-- libvirt-debian-9
-- libvirt-fedora-26
-- libvirt-fedora-27
-- libvirt-fedora-rawhide
-- libvirt-freebsd-10
-- libvirt-freebsd-11
   - python-distutils-check-job:
-  pyver: 2
-  parent_jobs: 'libvirt-python-master-py{pyver}-build'
-  - python-distutils-check-job:
-  pyver: 3
-  parent_jobs: 'libvirt-python-master-py{pyver}-build'
-  machines:
-- libvirt-debian-8
-- libvirt-debian-9
-- libvirt-fedora-26
-- libvirt-fedora-27
-- libvirt-fedora-rawhide
-- libvirt-freebsd-10
-- libvirt-freebsd-11
+  parent_jobs: 'libvirt-python-master-build'
   - python-distutils-rpm-job:
-  pyver: 2
-  parent_jobs: 'libvirt-python-master-py{pyver}-check'
+  parent_jobs: 'libvirt-python-master-check'
   machines:
 - libvirt-centos-6
 - libvirt-centos-7
diff --git a/projects/virt-manager.yaml b/projects/virt-manager.yaml
index e626cb0..8c18680 100644
--- a/projects/virt-manager.yaml
+++ b/projects/virt-manager.yaml
@@ -11,15 +11,13 @@
 title: Virtual Machine Manager
 jobs:
   - python-distutils-build-job:
-  pyver: 3
   parent_jobs:
-- 'libvirt-python-master-py{pyver}-build'
+- 'libvirt-python-master-build'
 - 'libosinfo-master-build'
   command_pre_build: |
-

Re: [libvirt] Run libvirtd from git: virsh hangs

2018-04-05 Thread Daniel P . Berrangé
On Thu, Apr 05, 2018 at 06:11:44PM +0300, Mathieu Tarral wrote:
> > You can enable debugging for virsh too:
> >
> > LIBVIRT_DEBUG=1 ./tools/virsh list --all
> >
> > Alternatively, you can run the libvirtd under strace to see if it
> > accepts() the connection request. Seems like virsh is trying to connect
> > to a different socket than libvirtd is listening to.
> 
> I can see the socket being created by libvirtd in 
> /var/run/libvirt/libvirt-sock.
> 
> And as i start virsh (the system one) as root, it tries to open a
> connection to 'qemu:///system'
> 
> Now, i tried to monitor what virsh was trying to do with strace, as
> you suggested, using
> sudo strace -v -y -yy -s 4096 virsh list --all
> 
> connect(5, {sa_family=AF_UNIX,

> You can see that it successfully connects to the libvirt.sock, and
> then it polls on the socket (5).

That'll be waiting for a response from libvirtd I presume

> 
> So i tried to strace libvirtd too:

[snip]

strace isn't very helpful for debugging hangs - better to connect to
libvirtd with GDB and get a stack trace of all threads, using

  (gdb)  thread apply all bt

Regards,
Daniel
-- 
|: https://berrange.com  -o-https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org -o-https://fstop138.berrange.com :|
|: https://entangle-photo.org-o-https://www.instagram.com/dberrange :|

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] Run libvirtd from git: virsh hangs

2018-04-05 Thread Mathieu Tarral
> You can enable debugging for virsh too:
>
> LIBVIRT_DEBUG=1 ./tools/virsh list --all
>
> Alternatively, you can run the libvirtd under strace to see if it
> accepts() the connection request. Seems like virsh is trying to connect
> to a different socket than libvirtd is listening to.

I can see the socket being created by libvirtd in /var/run/libvirt/libvirt-sock.

And as i start virsh (the system one) as root, it tries to open a
connection to 'qemu:///system'

Now, i tried to monitor what virsh was trying to do with strace, as
you suggested, using
sudo strace -v -y -yy -s 4096 virsh list --all

connect(5, {sa_family=AF_UNIX,
sun_path="/var/run/libvirt/libvirt-sock"}, 110) = 0
getsockname(5, {sa_family=AF_UNIX}, [128->2]) = 0
futex(0x7f73d0b16108, FUTEX_WAKE_PRIVATE, 2147483647) = 0
fcntl(5, F_GETFD)  = 0
fcntl(5, F_SETFD, FD_CLOEXEC) = 0
fcntl(5, F_GETFL)  = 0x2 (flags O_RDWR)
fcntl(5, F_SETFL, O_RDWR|O_NONBLOCK) = 0
futex(0x7f73d0b16008, FUTEX_WAKE_PRIVATE, 2147483647) = 0
pipe2([6, 7], O_CLOEXEC) = 0
write(4, "\0", 1)  = 1
futex(0x7f73d0b15360, FUTEX_WAKE_PRIVATE, 1) = 1
futex(0x7f73d0b160d0, FUTEX_WAKE_PRIVATE, 2147483647) = 0
futex(0x7f73d0b16020, FUTEX_WAKE_PRIVATE, 2147483647) = 0
brk(0x56228000) = 0x56228000
write(4, "\0", 1)  = 1
futex(0x7f73d0b15360, FUTEX_WAKE_PRIVATE, 1) = 1
rt_sigprocmask(SIG_BLOCK, [PIPE CHLD WINCH], [], 8) = 0
poll([{fd=5, events=POLLOUT}, {fd=6,
events=POLLIN}], 2, -1) = 1 ([{fd=5, revents=POLLOUT}])
rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
write(5, "\0\0\0\34
\0\200\206\0\0\0\1\0\0\0B\0\0\0\0\0\0\0\0\0\0\0\0", 28) = 28
brk(0x56218000) = 0x56218000
rt_sigprocmask(SIG_BLOCK, [PIPE CHLD WINCH], [], 8) = 0
poll([{fd=5, events=POLLIN}, {fd=6,
events=POLLIN}], 2, -1

You can see that it successfully connects to the libvirt.sock, and
then it polls on the socket (5).

So i tried to strace libvirtd too:

bind(8, {sa_family=AF_UNIX,
sun_path="/var/run/libvirt/libvirt-sock"}, 110) = 0
umask(022)  = 077
futex(0x7f537d1138e0, FUTEX_WAKE_PRIVATE, 2147483647) = 0
fcntl(8, F_GETFD) = 0
fcntl(8, F_SETFD,
FD_CLOEXEC) = 0
fcntl(8, F_GETFL) =
0x2 (flags O_RDWR)
fcntl(8, F_SETFL,
O_RDWR|O_NONBLOCK) = 0
listen(8, 1000) = 0
socket(AF_UNIX, SOCK_STREAM, 0) = 9
unlink("/var/run/libvirt/libvirt-sock-ro") = -1 ENOENT (No such file
or directory)
umask(0177000)  = 022
bind(9, {sa_family=AF_UNIX,
sun_path="/var/run/libvirt/libvirt-sock-ro"}, 110) = 0
umask(022)  = 000
fcntl(9, F_GETFD) = 0
fcntl(9, F_SETFD,
FD_CLOEXEC) = 0
fcntl(9, F_GETFL)
= 0x2 (flags O_RDWR)
fcntl(9, F_SETFL,
O_RDWR|O_NONBLOCK) = 0
listen(9, 1000) = 0
socket(AF_UNIX, SOCK_STREAM, 0) = 10
unlink("/var/run/libvirt/libvirt-admin-sock") = -1 ENOENT (No such
file or directory)
umask(0177077)  = 022
bind(10, {sa_family=AF_UNIX,
sun_path="/var/run/libvirt/libvirt-admin-sock"}, 110) = 0
umask(022)  = 077
fcntl(10, F_GETFD) = 0
fcntl(10,
F_SETFD, FD_CLOEXEC) = 0
fcntl(10,
F_GETFL) = 0x2 (flags O_RDWR)
fcntl(10,
F_SETFL, O_RDWR|O_NONBLOCK) = 0
listen(10, 20) = 0
mmap(NULL, 8392704, PROT_READ|PROT_WRITE,
MAP_PRIVATE|MAP_ANONYMOUS|MAP_STACK, -1, 0) = 0x7f536bbbf000
mprotect(0x7f536bbbf000, 4096, PROT_NONE) = 0
clone(child_stack=0x7f536c3beeb0,
flags=CLONE_VM|CLONE_FS|CLONE_FILES|CLONE_SIGHAND|CLONE_THREAD|CLONE_SYSVSEM|CLONE_SETTLS|CLONE_PARENT_SETTID|CLONE_CHILD_CLEARTID,
parent_tidptr=0x7f536c3bf9d0, tls=0x7f536c3bf700,
child_tidptr=0x7f536c3bf9d0) = 349
socket(AF_NETLINK, SOCK_RAW|SOCK_CLOEXEC, NETLINK_ROUTE) =
11
setsockopt(11, SOL_SOCKET, SO_SNDBUF, [32768], 4) = 0
setsockopt(11, SOL_SOCKET, SO_RCVBUF, [32768], 4) = 0
getpid()= 

Re: [libvirt] [PATCH v4 3/3] news: Document device mapper fix

2018-04-05 Thread Michal Privoznik
On 04/05/2018 12:51 PM, Peter Krempa wrote:
> On Thu, Apr 05, 2018 at 10:09:41 +0200, Michal Privoznik wrote:
>> Signed-off-by: Michal Privoznik 
>> ---
>>  docs/news.xml | 12 
>>  1 file changed, 12 insertions(+)
> 
> ACK
> 

I've pushed these.

Thanks,
Michal

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] [PATCH v5 05/10] qemu: add support to launch SEV guest

2018-04-05 Thread Brijesh Singh



On 04/04/2018 09:22 AM, John Ferlan wrote:


I understand - your other option is to make required. This is one of
those cases where there is a gray area with respect to libvirt picking
some default or policy that we generally prefer to avoid.



I think now I am more inclined towards making it required from libvirt 
-- this matches with SEV spec.




As noted before/elsewhere - what happens when the default changes...




Theoretically speaking, change in default policy should not cause any 
issue when creating the guest. But the policy change can limit us what a 
hypervisor can do after the boots, e.g disable or disable debug, 
migration or save/restore etc.



On side note, I will be going on 4 weeks of paternity leave starting 
next week and will submit the series after I am back from leave.




+}

Check out storageBackendCreateQemuImgSecretPath which just goes straight
to safewrite when writing to the file or qemuDomainWriteMasterKeyFile
which is a similar w/r/t a single key file for the domain.

The one thing to think about being the privileges for the file being
created and written and the expectations for QEMU's usage. I think this
is more like the storage secret code, but I could be wrong!


The data is public in this case, we do not need to protect it with
secret. Hence I am keeping all this certificate keys in unsecure place.


It wasn't so much the public keys as it was me (more or less) thinking
out loud about the protections on the file that you're "temporarily"
creating and using to pass the keys.

I noted two other areas which libvirt does something similarly - one is
the master public key file for decrypting the AES secrets for
libvirt/qemu secret manipulation.  The second is the "temporary" file we
create in the storage driver to handle the luks encryption password for
create/resize of a luks encrypted file when using qemu-img. Now that is
slightly different than using a temporary file for the emulator binary.

In any case, since you're creating in libDir it's probably OK as is, but
I know when reading files libvirt creates which qemu will use there have
been issues in the past - I always have to refresh my memory what those
issues are though.




IIRC, Daniel recommended to use libDir in previous reviews, if its not a 
big deal then we lets use libDir in initial patches and if need arises 
then we can revisit it later.


thanks for all your feedback.

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] [dbus PATCH] test: Don't hardcode python3 path

2018-04-05 Thread Pavel Hrdina
On Thu, Apr 05, 2018 at 03:51:17PM +0200, Andrea Bolognani wrote:
> Using /usr/bin/python3 is fine for Linux, but it's not portable
> to other operating systems such as FreeBSD, where the binary
> lives under /usr/local/bin instead.
> 
> Use /usr/bin/env to abstract the issue away. With this, 'make
> check' completes successfully on FreeBSD 10, 11 and -CURRENT.
> 
> Signed-off-by: Andrea Bolognani 
> ---
>  test/test_connect.py | 2 +-
>  test/test_domain.py  | 2 +-
>  test/test_network.py | 2 +-
>  3 files changed, 3 insertions(+), 3 deletions(-)

Reviewed-by: Pavel Hrdina 


signature.asc
Description: PGP signature
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Re: [libvirt] [dbus PATCH 10/10] Implement Create method for Network Interface

2018-04-05 Thread Pavel Hrdina
On Thu, Apr 05, 2018 at 03:29:34PM +0200, Katerina Koukiou wrote:
> Signed-off-by: Katerina Koukiou 
> ---
>  data/org.libvirt.Network.xml |  4 
>  src/network.c| 21 +
>  test/test_network.py | 14 ++
>  3 files changed, 39 insertions(+)

Reviewed-by: Pavel Hrdina 


signature.asc
Description: PGP signature
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Re: [libvirt] [dbus PATCH 09/10] Implement Undefine method for Network Interface

2018-04-05 Thread Pavel Hrdina
On Thu, Apr 05, 2018 at 03:29:33PM +0200, Katerina Koukiou wrote:
> Signed-off-by: Katerina Koukiou 
> ---
>  data/org.libvirt.Network.xml |  4 
>  src/network.c| 21 +
>  test/test_network.py | 13 +
>  3 files changed, 38 insertions(+)

Reviewed-by: Pavel Hrdina 


signature.asc
Description: PGP signature
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Re: [libvirt] [dbus PATCH 08/10] Implement Destroy method for Network Interface.

2018-04-05 Thread Pavel Hrdina
On Thu, Apr 05, 2018 at 03:29:32PM +0200, Katerina Koukiou wrote:
> Signed-off-by: Katerina Koukiou 
> ---
>  data/org.libvirt.Network.xml |  4 
>  src/network.c| 21 +
>  test/test_network.py | 13 +
>  3 files changed, 38 insertions(+)
> 
> diff --git a/data/org.libvirt.Network.xml b/data/org.libvirt.Network.xml
> index d144c5d..c143f08 100644
> --- a/data/org.libvirt.Network.xml
> +++ b/data/org.libvirt.Network.xml
> @@ -19,5 +19,9 @@
>  value="See 
> https://libvirt.org/html/libvirt-libvirt-network.html#virNetworkGetUUIDString"/>
>  
> +
> +   +value="See 
> https://libvirt.org/html/libvirt-libvirt-network.html#virDomainDestroy"/>

virNetworkDestroy

I guess that's a copy error :).

> +
>

Reviewed-by: Pavel Hrdina 


signature.asc
Description: PGP signature
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Re: [libvirt] [PATCH 01/68] qemu: Move qemuDomainCheckMigrationCapabilities

2018-04-05 Thread Ján Tomko

On Wed, Apr 04, 2018 at 04:40:50PM +0200, Jiri Denemark wrote:

Since the function is tightly connected to migration, it was renamed as
qemuMigrationCapsCheck and moved to qemu_migration.c.

Signed-off-by: Jiri Denemark 
---
src/qemu/qemu_domain.c| 72 ---
src/qemu/qemu_domain.h|  4 ---
src/qemu/qemu_migration.c | 72 +++
src/qemu/qemu_migration.h |  6 
src/qemu/qemu_process.c   |  2 +-
5 files changed, 79 insertions(+), 77 deletions(-)



ACK

Jano


signature.asc
Description: Digital signature
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Re: [libvirt] [dbus PATCH 07/10] Register Network Lifecycle Events

2018-04-05 Thread Pavel Hrdina
On Thu, Apr 05, 2018 at 03:29:31PM +0200, Katerina Koukiou wrote:
> Signed-off-by: Katerina Koukiou 
> ---
>  data/org.libvirt.Connect.xml |  6 +
>  src/connect.c| 13 ++
>  src/connect.h|  1 +
>  src/events.c | 60 
> 
>  4 files changed, 80 insertions(+)
> 
> diff --git a/data/org.libvirt.Connect.xml b/data/org.libvirt.Connect.xml
> index d15c2f6..b11dbfb 100644
> --- a/data/org.libvirt.Connect.xml
> +++ b/data/org.libvirt.Connect.xml
> @@ -68,5 +68,11 @@
>
>
>  
> +
> +   +value="See 
> https://libvirt.org/html/libvirt-libvirt-network.html#virConnectNetworkEventCallback"/>

This should point to virConnectNetworkEventLifecycleCallback.

> +  
> +  
> +
>
>  
> diff --git a/src/connect.c b/src/connect.c
> index 90172e3..a9006a2 100644
> --- a/src/connect.c
> +++ b/src/connect.c
> @@ -49,6 +49,16 @@ virtDBusConnectClose(virtDBusConnect *connect,
>  }
>  }
>  
> +for (gint i = 0; i < VIR_NETWORK_EVENT_ID_LAST; i += 1) {
> +if (connect->network_callback_ids[i] >= 0) {
> +if (deregisterEvents) {
> +virConnectNetworkEventDeregisterAny(connect->connection,
> +
> connect->network_callback_ids[i]);
> +}
> +connect->network_callback_ids[i] = -1;
> +}
> +}
> +
>  virConnectClose(connect->connection);
>  connect->connection = NULL;
>  }
> @@ -431,6 +441,9 @@ virtDBusConnectNew(virtDBusConnect **connectp,
>  for (gint i = 0; i < VIR_DOMAIN_EVENT_ID_LAST; i += 1)
>  connect->domain_callback_ids[i] = -1;
>  
> +for (gint i = 0; i < VIR_NETWORK_EVENT_ID_LAST; i += 1)
> +connect->network_callback_ids[i] = -1;
> +
>  connect->bus = bus;
>  connect->uri = uri;
>  connect->connectPath = connectPath;
> diff --git a/src/connect.h b/src/connect.h
> index e69898c..e8c757f 100644
> --- a/src/connect.h
> +++ b/src/connect.h
> @@ -18,6 +18,7 @@ struct virtDBusConnect {
>  GMutex lock;
>  
>  gint domain_callback_ids[VIR_DOMAIN_EVENT_ID_LAST];
> +gint network_callback_ids[VIR_NETWORK_EVENT_ID_LAST];

Same as for domain, networkCallbackIds.

>  };
>  typedef struct virtDBusConnect virtDBusConnect;
>  
> diff --git a/src/events.c b/src/events.c
> index 5fa61f5..b4d22a6 100644
> --- a/src/events.c
> +++ b/src/events.c
> @@ -170,6 +170,48 @@ virtDBusEventsDomainDiskChange(virConnectPtr connection 
> G_GNUC_UNUSED,
>  return 0;
>  }
>  
> +VIRT_DBUS_ENUM_DECL(virtDBusEventsNetworkEvent)
> +VIRT_DBUS_ENUM_IMPL(virtDBusEventsNetworkEvent,
> +VIR_NETWORK_EVENT_LAST,
> +"Defined",
> +"Undefined",
> +"Started",
> +"Stopped")
> +
> +static const gchar *
> +virtDBusEventsNetworkEventToString(gint event)
> +{
> +const gchar *str = virtDBusEventsNetworkEventTypeToString(event);
> +return str ? str : "unknown";
> +}

I missed this while reviewing the domain event changes, but this
function is no longer needed because we check the return value for NULL
in order to not emit any signal if we cannot translate it into string.

Whit this function it will never happen because it returns "unknown"
in that case.  So we can remove it.

> +
> +static gint
> +virtDBusEventsNetworkLifecycle(virConnectPtr connection G_GNUC_UNUSED,
> +   virNetworkPtr network,
> +   gint event,
> +   gint detail G_GNUC_UNUSED,
> +   gpointer opaque)
> +{
> +virtDBusConnect *connect = opaque;
> +g_autofree gchar *path = NULL;
> +const gchar *eventStr = virtDBusEventsNetworkEventToString(event);

Here we can use virtDBusEventsNetworkEventTypeToString directly.

Reviewed-by: Pavel Hrdina 


signature.asc
Description: PGP signature
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Re: [libvirt] Run libvirtd from git: virsh hangs

2018-04-05 Thread Michal Privoznik
On 04/05/2018 03:59 PM, Mathieu Tarral wrote:
> Hi,
> 
> I managed to compile libvirt from the git repo,
> now i have some trouble to run it.
> 
> This is what i did:
> 
> I configured the source to use /var because i wanted the socket
> to be at the same place as the system one
> (/var/run/libvirt/libvirt-sock)
> ./configure --prefix=$HOME/usr --localstatedir=/var
> make
> make install
> 
> at this point i stopped my system libvirtd and virtlogd
> sudo systemctl stop libvirtd
> sudo systemctl stop virtlogd
> 
> And then i launched my custom libvirtd and virtlogd
> cd $HOME/usr/sbin
> sudo ./libvirtd -v
> sudo ./virtlogd -v
> 
> After that i tried to list the available domains with virsh (using the
> system binary)
> sudo virsh
> virsh # list --all
> 
> And this call hangs forever.
> There is no more output in libvirtd stdout/stderr, even if i set log_level to 
> 1.
> 
> Did i miss anything in the configuration ?

You can enable debugging for virsh too:

LIBVIRT_DEBUG=1 ./tools/virsh list --all

Alternatively, you can run the libvirtd under strace to see if it
accepts() the connection request. Seems like virsh is trying to connect
to a different socket than libvirtd is listening to.

Michal

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] [PATCH v2] docs: add page describing goals for host platform version support

2018-04-05 Thread Andrea Bolognani
On Thu, 2018-04-05 at 11:05 +0100, Daniel P. Berrangé wrote:
> Described how we decide which host platforms to support for libvirt,
> which in turn makes it easier to decide when a platform / software
> version can be dropped.
> 
> Signed-off-by: Daniel P. Berrangé 
> ---
>  docs/index.html.in |   2 +-
>  docs/platforms.html.in | 105 
> +
>  2 files changed, 106 insertions(+), 1 deletion(-)
>  create mode 100644 docs/platforms.html.in

[...]
> +
> +  Note that when considering software versions shipped in distros as
> +  support targets, libvirt considers only the version number, and assumes
> +  the features in that distro match the upstream release with the same
> +  version. IOW, if a distro backports extra features to the software in

s/IOW/In other words/


Reviewed-by: Andrea Bolognani 

-- 
Andrea Bolognani / Red Hat / Virtualization

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

[libvirt] [jenkins-ci PATCH 0/2] Add libvirt-dbus project

2018-04-05 Thread Andrea Bolognani
Andrea Bolognani (2):
  guests: Add libvirt-dbus project
  projects: Add libvirt-dbus project

 guests/host_vars/libvirt-centos-7/main.yml|  1 +
 guests/host_vars/libvirt-debian-9/main.yml|  1 +
 guests/host_vars/libvirt-debian-sid/main.yml  |  1 +
 guests/host_vars/libvirt-fedora-26/main.yml   |  1 +
 guests/host_vars/libvirt-fedora-27/main.yml   |  1 +
 guests/host_vars/libvirt-fedora-rawhide/main.yml  |  1 +
 guests/host_vars/libvirt-freebsd-10/main.yml  |  1 +
 guests/host_vars/libvirt-freebsd-11/main.yml  |  1 +
 guests/host_vars/libvirt-freebsd-current/main.yml |  1 +
 guests/host_vars/libvirt-ubuntu-16/main.yml   |  1 +
 guests/vars/mappings.yml  | 10 
 guests/vars/projects/libvirt-dbus.yml |  6 +
 projects/libvirt-dbus.yaml| 31 +++
 13 files changed, 57 insertions(+)
 create mode 100644 guests/vars/projects/libvirt-dbus.yml
 create mode 100644 projects/libvirt-dbus.yaml

-- 
2.14.3

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [jenkins-ci PATCH 2/2] projects: Add libvirt-dbus project

2018-04-05 Thread Andrea Bolognani
Signed-off-by: Andrea Bolognani 
---
 projects/libvirt-dbus.yaml | 31 +++
 1 file changed, 31 insertions(+)
 create mode 100644 projects/libvirt-dbus.yaml

diff --git a/projects/libvirt-dbus.yaml b/projects/libvirt-dbus.yaml
new file mode 100644
index 000..7e761c7
--- /dev/null
+++ b/projects/libvirt-dbus.yaml
@@ -0,0 +1,31 @@
+
+- project:
+name: libvirt-dbus
+title: Libvirt D-Bus
+jobs:
+  - autotools-build-job:
+  parent_jobs: 'libvirt-glib-master-build'
+  machines:
+- libvirt-centos-7
+- libvirt-debian-9
+- libvirt-fedora-26
+- libvirt-fedora-27
+- libvirt-fedora-rawhide
+- libvirt-freebsd-10
+- libvirt-freebsd-11
+  - autotools-check-job:
+  parent_jobs: 'libvirt-dbus-master-build'
+  machines:
+- libvirt-debian-9
+- libvirt-fedora-26
+- libvirt-fedora-27
+- libvirt-fedora-rawhide
+- libvirt-freebsd-10
+- libvirt-freebsd-11
+  - autotools-rpm-job:
+  parent_jobs: 'libvirt-dbus-master-check'
+  machines:
+- libvirt-centos-7
+- libvirt-fedora-26
+- libvirt-fedora-27
+- libvirt-fedora-rawhide
-- 
2.14.3

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [jenkins-ci PATCH 1/2] guests: Add libvirt-dbus project

2018-04-05 Thread Andrea Bolognani
Signed-off-by: Andrea Bolognani 
---
 guests/host_vars/libvirt-centos-7/main.yml|  1 +
 guests/host_vars/libvirt-debian-9/main.yml|  1 +
 guests/host_vars/libvirt-debian-sid/main.yml  |  1 +
 guests/host_vars/libvirt-fedora-26/main.yml   |  1 +
 guests/host_vars/libvirt-fedora-27/main.yml   |  1 +
 guests/host_vars/libvirt-fedora-rawhide/main.yml  |  1 +
 guests/host_vars/libvirt-freebsd-10/main.yml  |  1 +
 guests/host_vars/libvirt-freebsd-11/main.yml  |  1 +
 guests/host_vars/libvirt-freebsd-current/main.yml |  1 +
 guests/host_vars/libvirt-ubuntu-16/main.yml   |  1 +
 guests/vars/mappings.yml  | 10 ++
 guests/vars/projects/libvirt-dbus.yml |  6 ++
 12 files changed, 26 insertions(+)
 create mode 100644 guests/vars/projects/libvirt-dbus.yml

diff --git a/guests/host_vars/libvirt-centos-7/main.yml 
b/guests/host_vars/libvirt-centos-7/main.yml
index 935ab15..62c929e 100644
--- a/guests/host_vars/libvirt-centos-7/main.yml
+++ b/guests/host_vars/libvirt-centos-7/main.yml
@@ -6,6 +6,7 @@ projects:
   - libosinfo
   - libvirt
   - libvirt-cim
+  - libvirt-dbus
   - libvirt-glib
   - libvirt-go
   - libvirt-go-xml
diff --git a/guests/host_vars/libvirt-debian-9/main.yml 
b/guests/host_vars/libvirt-debian-9/main.yml
index bdaa00d..f53ac50 100644
--- a/guests/host_vars/libvirt-debian-9/main.yml
+++ b/guests/host_vars/libvirt-debian-9/main.yml
@@ -5,6 +5,7 @@ PYTHONPATH: $VIRT_PREFIX/lib/python3.5/site-packages
 projects:
   - libosinfo
   - libvirt
+  - libvirt-dbus
   - libvirt-glib
   - libvirt-go
   - libvirt-go-xml
diff --git a/guests/host_vars/libvirt-debian-sid/main.yml 
b/guests/host_vars/libvirt-debian-sid/main.yml
index cb61b6e..f5eb52c 100644
--- a/guests/host_vars/libvirt-debian-sid/main.yml
+++ b/guests/host_vars/libvirt-debian-sid/main.yml
@@ -5,6 +5,7 @@ PYTHONPATH: $VIRT_PREFIX/lib/python3.6/site-packages
 projects:
   - libosinfo
   - libvirt
+  - libvirt-dbus
   - libvirt-glib
   - libvirt-go
   - libvirt-go-xml
diff --git a/guests/host_vars/libvirt-fedora-26/main.yml 
b/guests/host_vars/libvirt-fedora-26/main.yml
index 732df24..3f69f80 100644
--- a/guests/host_vars/libvirt-fedora-26/main.yml
+++ b/guests/host_vars/libvirt-fedora-26/main.yml
@@ -6,6 +6,7 @@ projects:
   - libosinfo
   - libvirt
   - libvirt-cim
+  - libvirt-dbus
   - libvirt-glib
   - libvirt-go
   - libvirt-go-xml
diff --git a/guests/host_vars/libvirt-fedora-27/main.yml 
b/guests/host_vars/libvirt-fedora-27/main.yml
index 732df24..3f69f80 100644
--- a/guests/host_vars/libvirt-fedora-27/main.yml
+++ b/guests/host_vars/libvirt-fedora-27/main.yml
@@ -6,6 +6,7 @@ projects:
   - libosinfo
   - libvirt
   - libvirt-cim
+  - libvirt-dbus
   - libvirt-glib
   - libvirt-go
   - libvirt-go-xml
diff --git a/guests/host_vars/libvirt-fedora-rawhide/main.yml 
b/guests/host_vars/libvirt-fedora-rawhide/main.yml
index 732df24..3f69f80 100644
--- a/guests/host_vars/libvirt-fedora-rawhide/main.yml
+++ b/guests/host_vars/libvirt-fedora-rawhide/main.yml
@@ -6,6 +6,7 @@ projects:
   - libosinfo
   - libvirt
   - libvirt-cim
+  - libvirt-dbus
   - libvirt-glib
   - libvirt-go
   - libvirt-go-xml
diff --git a/guests/host_vars/libvirt-freebsd-10/main.yml 
b/guests/host_vars/libvirt-freebsd-10/main.yml
index 05e1955..487b3e8 100644
--- a/guests/host_vars/libvirt-freebsd-10/main.yml
+++ b/guests/host_vars/libvirt-freebsd-10/main.yml
@@ -12,6 +12,7 @@ sudoers: /usr/local/etc/sudoers
 projects:
   - libosinfo
   - libvirt
+  - libvirt-dbus
   - libvirt-glib
   - libvirt-go
   - libvirt-go-xml
diff --git a/guests/host_vars/libvirt-freebsd-11/main.yml 
b/guests/host_vars/libvirt-freebsd-11/main.yml
index 05e1955..487b3e8 100644
--- a/guests/host_vars/libvirt-freebsd-11/main.yml
+++ b/guests/host_vars/libvirt-freebsd-11/main.yml
@@ -12,6 +12,7 @@ sudoers: /usr/local/etc/sudoers
 projects:
   - libosinfo
   - libvirt
+  - libvirt-dbus
   - libvirt-glib
   - libvirt-go
   - libvirt-go-xml
diff --git a/guests/host_vars/libvirt-freebsd-current/main.yml 
b/guests/host_vars/libvirt-freebsd-current/main.yml
index 05e1955..487b3e8 100644
--- a/guests/host_vars/libvirt-freebsd-current/main.yml
+++ b/guests/host_vars/libvirt-freebsd-current/main.yml
@@ -12,6 +12,7 @@ sudoers: /usr/local/etc/sudoers
 projects:
   - libosinfo
   - libvirt
+  - libvirt-dbus
   - libvirt-glib
   - libvirt-go
   - libvirt-go-xml
diff --git a/guests/host_vars/libvirt-ubuntu-16/main.yml 
b/guests/host_vars/libvirt-ubuntu-16/main.yml
index 7991608..9aa5114 100644
--- a/guests/host_vars/libvirt-ubuntu-16/main.yml
+++ b/guests/host_vars/libvirt-ubuntu-16/main.yml
@@ -5,6 +5,7 @@ PYTHONPATH: $VIRT_PREFIX/lib/python3.5/site-packages
 projects:
   - libosinfo
   - libvirt
+  - libvirt-dbus
   - libvirt-glib
   - libvirt-go
   - libvirt-go-xml
diff --git a/guests/vars/mappings.yml b/guests/vars/mappings.yml
index cb44b3d..e074648 100644
--- a/guests/vars/mappings.yml
+++ 

[libvirt] Run libvirtd from git: virsh hangs

2018-04-05 Thread Mathieu Tarral
Hi,

I managed to compile libvirt from the git repo,
now i have some trouble to run it.

This is what i did:

I configured the source to use /var because i wanted the socket
to be at the same place as the system one
(/var/run/libvirt/libvirt-sock)
./configure --prefix=$HOME/usr --localstatedir=/var
make
make install

at this point i stopped my system libvirtd and virtlogd
sudo systemctl stop libvirtd
sudo systemctl stop virtlogd

And then i launched my custom libvirtd and virtlogd
cd $HOME/usr/sbin
sudo ./libvirtd -v
sudo ./virtlogd -v

After that i tried to list the available domains with virsh (using the
system binary)
sudo virsh
virsh # list --all

And this call hangs forever.
There is no more output in libvirtd stdout/stderr, even if i set log_level to 1.

Did i miss anything in the configuration ?

Thanks guys !

-- 
Mathieu Tarral

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] [dbus PATCH 06/10] Rename callback_ids variable to domain_callback_ids

2018-04-05 Thread Pavel Hrdina
On Thu, Apr 05, 2018 at 03:29:30PM +0200, Katerina Koukiou wrote:
> The callback_ids var is domain specific.
> Renaming it now, so as to keep consistent naming when introducing
> events for other entities.
> 
> Signed-off-by: Katerina Koukiou 
> ---
>  src/connect.c |  8 
>  src/connect.h |  2 +-
>  src/events.c  | 16 
>  3 files changed, 13 insertions(+), 13 deletions(-)
> 
> diff --git a/src/connect.c b/src/connect.c
> index f22f682..90172e3 100644
> --- a/src/connect.c
> +++ b/src/connect.c
> @@ -40,12 +40,12 @@ virtDBusConnectClose(virtDBusConnect *connect,
>  {
>  
>  for (gint i = 0; i < VIR_DOMAIN_EVENT_ID_LAST; i += 1) {
> -if (connect->callback_ids[i] >= 0) {
> +if (connect->domain_callback_ids[i] >= 0) {

Since we are renaming it I would suggest to use camleCase,
domainCallbackIds, to make the name consistent with the rest of
libvirt-dbus code.

Reviewed-by: Pavel Hrdina 


signature.asc
Description: PGP signature
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Re: [libvirt] [dbus PATCH 05/10] Rename virtDBusEventsRegisterEvent to virtDBusDomainEventsRegisterEvent

2018-04-05 Thread Pavel Hrdina
On Thu, Apr 05, 2018 at 03:29:29PM +0200, Katerina Koukiou wrote:
> This function was specific to Domain Lifecycle Events.
> Rename it now, so that we can keep consistent naming when introducing
> Events for other entities.
> 
> Signed-off-by: Katerina Koukiou 
> ---
>  src/events.c | 36 ++--
>  1 file changed, 18 insertions(+), 18 deletions(-)
> 
> diff --git a/src/events.c b/src/events.c
> index eb85a3a..c6896d4 100644
> --- a/src/events.c
> +++ b/src/events.c
> @@ -171,9 +171,9 @@ virtDBusEventsDomainDiskChange(virConnectPtr connection 
> G_GNUC_UNUSED,
>  }
>  
>  static void
> -virtDBusEventsRegisterEvent(virtDBusConnect *connect,
> -gint id,
> -virConnectDomainEventGenericCallback callback)
> +virtDBusDomainEventsRegisterEvent(virtDBusConnect *connect,

The name should be virtDBusEventsRegisterDomainEvent.  virtDBusEvents
is prefix for this file.

> +  gint id,
> +  virConnectDomainEventGenericCallback 
> callback)
>  {
>  g_assert(connect->callback_ids[id] == -1);

Reviewed-by: Pavel Hrdina 


signature.asc
Description: PGP signature
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Re: [libvirt] [dbus PATCH 04/10] Implement NetworkLookupByUUID method for network interface.

2018-04-05 Thread Pavel Hrdina
On Thu, Apr 05, 2018 at 03:29:28PM +0200, Katerina Koukiou wrote:
> Signed-off-by: Katerina Koukiou 
> ---
>  data/org.libvirt.Connect.xml |  6 ++
>  src/connect.c| 29 +
>  test/test_connect.py |  1 +
>  3 files changed, 36 insertions(+)
> 
> diff --git a/data/org.libvirt.Connect.xml b/data/org.libvirt.Connect.xml
> index 043ee32..d15c2f6 100644
> --- a/data/org.libvirt.Connect.xml
> +++ b/data/org.libvirt.Connect.xml
> @@ -56,6 +56,12 @@
>
>
>  
> +
> +   +value="See 
> https://libvirt.org/html/libvirt-libvirt-network.html#virNetworkLookupByUUID"/>

This should mention virNetworkLookupByUUIDString.

> +  
> +  
> +
>  
>  value="See 
> https://libvirt.org/html/libvirt-libvirt-domain.html#virConnectDomainEventCallback"/>
> diff --git a/src/connect.c b/src/connect.c
> index d036753..f22f682 100644
> --- a/src/connect.c
> +++ b/src/connect.c
> @@ -348,6 +348,34 @@ virtDBusNetworkLookupByName(GVariant *inArgs,
>  *outArgs = g_variant_new("(o)", path);
>  }
>  
> +static void
> +virtDBusNetworkLookupByUUID(GVariant *inArgs,
> +GUnixFDList *inFDs G_GNUC_UNUSED,
> +const gchar *objectPath G_GNUC_UNUSED,
> +gpointer userData,
> +GVariant **outArgs,
> +GUnixFDList **outFDs G_GNUC_UNUSED,
> +GError **error)
> +{
> +virtDBusConnect *connect = userData;
> +g_autoptr(virNetwork) network = NULL;
> +g_autofree gchar *path = NULL;
> +const gchar *uuidstr;
> +
> +g_variant_get(inArgs, "(s)", );

In order to use const gchar you need to use "()" as the format string.
The "&" indicates that the string is not copied to the variable but you
get only a pointer.

> +
> +if (!virtDBusConnectOpen(connect, error))
> +return;
> +
> +network = virNetworkLookupByUUIDString(connect->connection, uuidstr);
> +if (!network)
> +return virtDBusUtilSetLastVirtError(error);
> +
> +path = virtDBusUtilBusPathForVirNetwork(network, connect->networkPath);
> +
> +*outArgs = g_variant_new("(o)", path);
> +}

Reviewed-by: Pavel Hrdina 


signature.asc
Description: PGP signature
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Re: [libvirt] [dbus PATCH 01/10] Implement BridgeName property for Network interface.

2018-04-05 Thread Katerina Koukiou
On Thu, 2018-04-05 at 15:44 +0200, Pavel Hrdina wrote:
> On Thu, Apr 05, 2018 at 03:29:25PM +0200, Katerina Koukiou wrote:
> > Signed-off-by: Katerina Koukiou 
> > ---
> >  data/org.libvirt.Network.xml |  4 
> >  src/network.c| 23 +++
> >  test/test_network.py |  1 +
> >  3 files changed, 28 insertions(+)
> > 
> > diff --git a/data/org.libvirt.Network.xml
> > b/data/org.libvirt.Network.xml
> > index 1215ac3..83a6b9e 100644
> > --- a/data/org.libvirt.Network.xml
> > +++ b/data/org.libvirt.Network.xml
> > @@ -3,6 +3,10 @@
> >  
> >  
> >
> > +
> > +   > +value="See https://libvirt.org/html/libvirt-libvirt-networ
> > k.html#virNetworkGetBridgeName"/>;
> > +
> >  
> > >  value="See https://libvirt.org/html/libvirt-libvirt-networ
> > k.html#virNetworkGetName"/>;
> > diff --git a/src/network.c b/src/network.c
> > index 56cbb41..fab017c 100644
> > --- a/src/network.c
> > +++ b/src/network.c
> > @@ -24,6 +24,28 @@ virtDBusNetworkGetVirNetwork(virtDBusConnect
> > *connect,
> >  return network;
> >  }
> >  
> > +static void
> > +virtDBusNetworkGetBridgeName(const gchar *objectPath,
> > + gpointer userData,
> > + GVariant **value,
> > + GError **error)
> > +{
> > +virtDBusConnect *connect = userData;
> > +g_autoptr(virNetwork) network = NULL;
> > +const gchar *bridge;
> 
> This needs to be g_autofree gchar *bridge = NULL;
> 
> virtDBusNetworkGetVirNetwork returns a string that needs to be freed.

You mean virNetworkGetBridgeName. Nice catch, thanks.

> 
> > +
> > +network = virtDBusNetworkGetVirNetwork(connect, objectPath,
> > error);
> > +if (!network)
> > +return;
> > +
> > +bridge = virNetworkGetBridgeName(network);
> > +
> > +if (!bridge)
> > +return virtDBusUtilSetLastVirtError(error);
> > +
> > +*value = g_variant_new("s", bridge);
> > +}
> 
> Reviewed-by: Pavel Hrdina 

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [dbus PATCH] test: Don't hardcode python3 path

2018-04-05 Thread Andrea Bolognani
Using /usr/bin/python3 is fine for Linux, but it's not portable
to other operating systems such as FreeBSD, where the binary
lives under /usr/local/bin instead.

Use /usr/bin/env to abstract the issue away. With this, 'make
check' completes successfully on FreeBSD 10, 11 and -CURRENT.

Signed-off-by: Andrea Bolognani 
---
 test/test_connect.py | 2 +-
 test/test_domain.py  | 2 +-
 test/test_network.py | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/test/test_connect.py b/test/test_connect.py
index 440a496..d972561 100755
--- a/test/test_connect.py
+++ b/test/test_connect.py
@@ -1,4 +1,4 @@
-#!/usr/bin/python3
+#!/usr/bin/env python3
 
 import dbus
 import libvirttest
diff --git a/test/test_domain.py b/test/test_domain.py
index d36adf7..7ec2318 100755
--- a/test/test_domain.py
+++ b/test/test_domain.py
@@ -1,4 +1,4 @@
-#!/usr/bin/python3
+#!/usr/bin/env python3
 
 import dbus
 import libvirttest
diff --git a/test/test_network.py b/test/test_network.py
index 97ab0aa..5178862 100755
--- a/test/test_network.py
+++ b/test/test_network.py
@@ -1,4 +1,4 @@
-#!/usr/bin/python3
+#!/usr/bin/env python3
 
 import dbus
 import libvirttest
-- 
2.14.3

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] [dbus PATCH 03/10] Implement UUID property for Network interface.

2018-04-05 Thread Pavel Hrdina
On Thu, Apr 05, 2018 at 03:29:27PM +0200, Katerina Koukiou wrote:
> Signed-off-by: Katerina Koukiou 
> ---
>  data/org.libvirt.Network.xml |  4 
>  src/network.c| 21 +
>  test/test_network.py |  1 +
>  3 files changed, 26 insertions(+)

Reviewed-by: Pavel Hrdina 


signature.asc
Description: PGP signature
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Re: [libvirt] [dbus PATCH 02/10] Implement Autostart property for Network Interface

2018-04-05 Thread Pavel Hrdina
On Thu, Apr 05, 2018 at 03:29:26PM +0200, Katerina Koukiou wrote:
> Signed-off-by: Katerina Koukiou 
> ---
>  data/org.libvirt.Network.xml |  4 
>  src/network.c| 21 +
>  test/test_network.py |  1 +
>  3 files changed, 26 insertions(+)

Reviewed-by: Pavel Hrdina 


signature.asc
Description: PGP signature
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Re: [libvirt] [dbus PATCH 01/10] Implement BridgeName property for Network interface.

2018-04-05 Thread Pavel Hrdina
On Thu, Apr 05, 2018 at 03:29:25PM +0200, Katerina Koukiou wrote:
> Signed-off-by: Katerina Koukiou 
> ---
>  data/org.libvirt.Network.xml |  4 
>  src/network.c| 23 +++
>  test/test_network.py |  1 +
>  3 files changed, 28 insertions(+)
> 
> diff --git a/data/org.libvirt.Network.xml b/data/org.libvirt.Network.xml
> index 1215ac3..83a6b9e 100644
> --- a/data/org.libvirt.Network.xml
> +++ b/data/org.libvirt.Network.xml
> @@ -3,6 +3,10 @@
>  
>  
>
> +
> +   +value="See 
> https://libvirt.org/html/libvirt-libvirt-network.html#virNetworkGetBridgeName"/>
> +
>  
>  value="See 
> https://libvirt.org/html/libvirt-libvirt-network.html#virNetworkGetName"/>
> diff --git a/src/network.c b/src/network.c
> index 56cbb41..fab017c 100644
> --- a/src/network.c
> +++ b/src/network.c
> @@ -24,6 +24,28 @@ virtDBusNetworkGetVirNetwork(virtDBusConnect *connect,
>  return network;
>  }
>  
> +static void
> +virtDBusNetworkGetBridgeName(const gchar *objectPath,
> + gpointer userData,
> + GVariant **value,
> + GError **error)
> +{
> +virtDBusConnect *connect = userData;
> +g_autoptr(virNetwork) network = NULL;
> +const gchar *bridge;

This needs to be g_autofree gchar *bridge = NULL;

virtDBusNetworkGetVirNetwork returns a string that needs to be freed.

> +
> +network = virtDBusNetworkGetVirNetwork(connect, objectPath, error);
> +if (!network)
> +return;
> +
> +bridge = virNetworkGetBridgeName(network);
> +
> +if (!bridge)
> +return virtDBusUtilSetLastVirtError(error);
> +
> +*value = g_variant_new("s", bridge);
> +}

Reviewed-by: Pavel Hrdina 


signature.asc
Description: PGP signature
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

[libvirt] [PATCH] qemu: use target.port for isa-serial

2018-04-05 Thread Thilo Cestonaro
A configured target.port is currently totaly ignored, while contsructing
qemu commandline, for all types of serial devices. This patch adds a -device
parameter "index" for the target model isa-serial.
This enables the user to specify which serial device will end in which ttySX
device.
---
 src/qemu/qemu_command.c | 16 
 1 file changed, 16 insertions(+)

diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index bbd3cd0a7..a685abec0 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -10290,6 +10290,22 @@ qemuBuildSerialChrDeviceStr(char **deviceStr,
   
virDomainChrSerialTargetModelTypeToString(serial->targetModel),
   serial->info.alias, serial->info.alias);
 
+switch ((virDomainChrSerialTargetModel) serial->targetModel) {
+case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_ISA_SERIAL:
+if (serial->target.port != -1)
+virBufferAsprintf(, ",index=%d", serial->target.port);
+break;
+case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_NONE:
+case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_USB_SERIAL:
+case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_PCI_SERIAL:
+case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_SPAPR_VTY:
+case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_PL011:
+case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_SCLPCONSOLE:
+case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_SCLPLMCONSOLE:
+case VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_LAST:
+break;
+}
+
 if (qemuBuildDeviceAddressStr(, def, >info, qemuCaps) < 0)
 goto error;
 
-- 
2.15.1

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [dbus PATCH 10/10] Implement Create method for Network Interface

2018-04-05 Thread Katerina Koukiou
Signed-off-by: Katerina Koukiou 
---
 data/org.libvirt.Network.xml |  4 
 src/network.c| 21 +
 test/test_network.py | 14 ++
 3 files changed, 39 insertions(+)

diff --git a/data/org.libvirt.Network.xml b/data/org.libvirt.Network.xml
index 8a8eef7..0505e7a 100644
--- a/data/org.libvirt.Network.xml
+++ b/data/org.libvirt.Network.xml
@@ -19,6 +19,10 @@
   https://libvirt.org/html/libvirt-libvirt-network.html#virNetworkGetUUIDString"/>
 
+
+  https://libvirt.org/html/libvirt-libvirt-network.html#virNetworkCreate"/>
+
 
   https://libvirt.org/html/libvirt-libvirt-network.html#virDomainDestroy"/>
diff --git a/src/network.c b/src/network.c
index c911880..1d749e4 100644
--- a/src/network.c
+++ b/src/network.c
@@ -107,6 +107,26 @@ virtDBusNetworkGetUUID(const gchar *objectPath,
 *value = g_variant_new("s", uuid);
 }
 
+static void
+virtDBusNetworkCreate(GVariant *inArgs G_GNUC_UNUSED,
+  GUnixFDList *inFDs G_GNUC_UNUSED,
+  const gchar *objectPath,
+  gpointer userData,
+  GVariant **outArgs G_GNUC_UNUSED,
+  GUnixFDList **outFDs G_GNUC_UNUSED,
+  GError **error)
+{
+virtDBusConnect *connect = userData;
+g_autoptr(virNetwork) network = NULL;
+
+network = virtDBusNetworkGetVirNetwork(connect, objectPath, error);
+if (!network)
+return;
+
+if (virNetworkCreate(network) < 0)
+virtDBusUtilSetLastVirtError(error);
+}
+
 static void
 virtDBusNetworkDestroy(GVariant *inArgs G_GNUC_UNUSED,
GUnixFDList *inFDs G_GNUC_UNUSED,
@@ -156,6 +176,7 @@ static virtDBusGDBusPropertyTable 
virtDBusNetworkPropertyTable[] = {
 };
 
 static virtDBusGDBusMethodTable virtDBusNetworkMethodTable[] = {
+{ "Create", virtDBusNetworkCreate },
 { "Destroy", virtDBusNetworkDestroy },
 { "Undefine", virtDBusNetworkUndefine },
 { 0 }
diff --git a/test/test_network.py b/test/test_network.py
index f61e73d..17d4555 100755
--- a/test/test_network.py
+++ b/test/test_network.py
@@ -17,6 +17,20 @@ class TestNetwork(libvirttest.BaseTestClass):
 assert isinstance(props['Name'], dbus.String)
 assert isinstance(props['UUID'], dbus.String)
 
+def test_network_create(self):
+def domain_started(path, _event):
+assert isinstance(path, dbus.ObjectPath)
+self.loop.quit()
+
+self.connect.connect_to_signal('NetworkEvent', domain_started, 
arg1='Started')
+
+_,test_network = self.test_network()
+interface_obj = dbus.Interface(test_network, 'org.libvirt.Network')
+interface_obj.Destroy()
+interface_obj.Create()
+
+self.main_loop()
+
 def test_network_destroy(self):
 def network_stopped(path, _event):
 assert isinstance(path, dbus.ObjectPath)
-- 
2.15.0

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [dbus PATCH 09/10] Implement Undefine method for Network Interface

2018-04-05 Thread Katerina Koukiou
Signed-off-by: Katerina Koukiou 
---
 data/org.libvirt.Network.xml |  4 
 src/network.c| 21 +
 test/test_network.py | 13 +
 3 files changed, 38 insertions(+)

diff --git a/data/org.libvirt.Network.xml b/data/org.libvirt.Network.xml
index c143f08..8a8eef7 100644
--- a/data/org.libvirt.Network.xml
+++ b/data/org.libvirt.Network.xml
@@ -23,5 +23,9 @@
   https://libvirt.org/html/libvirt-libvirt-network.html#virDomainDestroy"/>
 
+
+  https://libvirt.org/html/libvirt-libvirt-network.html#virNetworkUndefine"/>
+
   
 
diff --git a/src/network.c b/src/network.c
index d46e327..c911880 100644
--- a/src/network.c
+++ b/src/network.c
@@ -127,6 +127,26 @@ virtDBusNetworkDestroy(GVariant *inArgs G_GNUC_UNUSED,
 virtDBusUtilSetLastVirtError(error);
 }
 
+static void
+virtDBusNetworkUndefine(GVariant *inArgs G_GNUC_UNUSED,
+GUnixFDList *inFDs G_GNUC_UNUSED,
+const gchar *objectPath,
+gpointer userData,
+GVariant **outArgs G_GNUC_UNUSED,
+GUnixFDList **outFDs G_GNUC_UNUSED,
+GError **error)
+{
+virtDBusConnect *connect = userData;
+g_autoptr(virNetwork) network = NULL;
+
+network = virtDBusNetworkGetVirNetwork(connect, objectPath, error);
+if (!network)
+return;
+
+if (virNetworkUndefine(network) < 0)
+virtDBusUtilSetLastVirtError(error);
+}
+
 static virtDBusGDBusPropertyTable virtDBusNetworkPropertyTable[] = {
 { "Autostart", virtDBusNetworkGetAutostart, NULL },
 { "BridgeName", virtDBusNetworkGetBridgeName, NULL },
@@ -137,6 +157,7 @@ static virtDBusGDBusPropertyTable 
virtDBusNetworkPropertyTable[] = {
 
 static virtDBusGDBusMethodTable virtDBusNetworkMethodTable[] = {
 { "Destroy", virtDBusNetworkDestroy },
+{ "Undefine", virtDBusNetworkUndefine },
 { 0 }
 };
 
diff --git a/test/test_network.py b/test/test_network.py
index 825b52f..f61e73d 100755
--- a/test/test_network.py
+++ b/test/test_network.py
@@ -30,6 +30,19 @@ class TestNetwork(libvirttest.BaseTestClass):
 
 self.main_loop()
 
+def test_network_undefine(self):
+def domain_undefined(path, _event):
+assert isinstance(path, dbus.ObjectPath)
+self.loop.quit()
+
+self.connect.connect_to_signal('NetworkEvent', domain_undefined, 
arg1='Undefined')
+
+_,test_network = self.test_network()
+interface_obj = dbus.Interface(test_network, 'org.libvirt.Network')
+interface_obj.Destroy()
+interface_obj.Undefine()
+
+self.main_loop()
 
 if __name__ == '__main__':
 libvirttest.run()
-- 
2.15.0

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [dbus PATCH 08/10] Implement Destroy method for Network Interface.

2018-04-05 Thread Katerina Koukiou
Signed-off-by: Katerina Koukiou 
---
 data/org.libvirt.Network.xml |  4 
 src/network.c| 21 +
 test/test_network.py | 13 +
 3 files changed, 38 insertions(+)

diff --git a/data/org.libvirt.Network.xml b/data/org.libvirt.Network.xml
index d144c5d..c143f08 100644
--- a/data/org.libvirt.Network.xml
+++ b/data/org.libvirt.Network.xml
@@ -19,5 +19,9 @@
   https://libvirt.org/html/libvirt-libvirt-network.html#virNetworkGetUUIDString"/>
 
+
+  https://libvirt.org/html/libvirt-libvirt-network.html#virDomainDestroy"/>
+
   
 
diff --git a/src/network.c b/src/network.c
index 90c2d9c..d46e327 100644
--- a/src/network.c
+++ b/src/network.c
@@ -107,6 +107,26 @@ virtDBusNetworkGetUUID(const gchar *objectPath,
 *value = g_variant_new("s", uuid);
 }
 
+static void
+virtDBusNetworkDestroy(GVariant *inArgs G_GNUC_UNUSED,
+   GUnixFDList *inFDs G_GNUC_UNUSED,
+   const gchar *objectPath,
+   gpointer userData,
+   GVariant **outArgs G_GNUC_UNUSED,
+   GUnixFDList **outFDs G_GNUC_UNUSED,
+   GError **error)
+{
+virtDBusConnect *connect = userData;
+g_autoptr(virNetwork) network = NULL;
+
+network = virtDBusNetworkGetVirNetwork(connect, objectPath, error);
+if (!network)
+return;
+
+if (virNetworkDestroy(network) < 0)
+virtDBusUtilSetLastVirtError(error);
+}
+
 static virtDBusGDBusPropertyTable virtDBusNetworkPropertyTable[] = {
 { "Autostart", virtDBusNetworkGetAutostart, NULL },
 { "BridgeName", virtDBusNetworkGetBridgeName, NULL },
@@ -116,6 +136,7 @@ static virtDBusGDBusPropertyTable 
virtDBusNetworkPropertyTable[] = {
 };
 
 static virtDBusGDBusMethodTable virtDBusNetworkMethodTable[] = {
+{ "Destroy", virtDBusNetworkDestroy },
 { 0 }
 };
 
diff --git a/test/test_network.py b/test/test_network.py
index e753f7f..825b52f 100755
--- a/test/test_network.py
+++ b/test/test_network.py
@@ -17,6 +17,19 @@ class TestNetwork(libvirttest.BaseTestClass):
 assert isinstance(props['Name'], dbus.String)
 assert isinstance(props['UUID'], dbus.String)
 
+def test_network_destroy(self):
+def network_stopped(path, _event):
+assert isinstance(path, dbus.ObjectPath)
+self.loop.quit()
+
+self.connect.connect_to_signal('NetworkEvent', network_stopped, 
arg1='Stopped')
+
+_, test_network = self.test_network()
+interface_obj = dbus.Interface(test_network, 'org.libvirt.Network')
+interface_obj.Destroy()
+
+self.main_loop()
+
 
 if __name__ == '__main__':
 libvirttest.run()
-- 
2.15.0

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [dbus PATCH 01/10] Implement BridgeName property for Network interface.

2018-04-05 Thread Katerina Koukiou
Signed-off-by: Katerina Koukiou 
---
 data/org.libvirt.Network.xml |  4 
 src/network.c| 23 +++
 test/test_network.py |  1 +
 3 files changed, 28 insertions(+)

diff --git a/data/org.libvirt.Network.xml b/data/org.libvirt.Network.xml
index 1215ac3..83a6b9e 100644
--- a/data/org.libvirt.Network.xml
+++ b/data/org.libvirt.Network.xml
@@ -3,6 +3,10 @@
 
 
   
+
+  https://libvirt.org/html/libvirt-libvirt-network.html#virNetworkGetBridgeName"/>
+
 
   https://libvirt.org/html/libvirt-libvirt-network.html#virNetworkGetName"/>
diff --git a/src/network.c b/src/network.c
index 56cbb41..fab017c 100644
--- a/src/network.c
+++ b/src/network.c
@@ -24,6 +24,28 @@ virtDBusNetworkGetVirNetwork(virtDBusConnect *connect,
 return network;
 }
 
+static void
+virtDBusNetworkGetBridgeName(const gchar *objectPath,
+ gpointer userData,
+ GVariant **value,
+ GError **error)
+{
+virtDBusConnect *connect = userData;
+g_autoptr(virNetwork) network = NULL;
+const gchar *bridge;
+
+network = virtDBusNetworkGetVirNetwork(connect, objectPath, error);
+if (!network)
+return;
+
+bridge = virNetworkGetBridgeName(network);
+
+if (!bridge)
+return virtDBusUtilSetLastVirtError(error);
+
+*value = g_variant_new("s", bridge);
+}
+
 static void
 virtDBusNetworkGetName(const gchar *objectPath,
gpointer userData,
@@ -46,6 +68,7 @@ virtDBusNetworkGetName(const gchar *objectPath,
 }
 
 static virtDBusGDBusPropertyTable virtDBusNetworkPropertyTable[] = {
+{ "BridgeName", virtDBusNetworkGetBridgeName, NULL },
 { "Name", virtDBusNetworkGetName, NULL },
 { 0 }
 };
diff --git a/test/test_network.py b/test/test_network.py
index 97ab0aa..9f15c2e 100755
--- a/test/test_network.py
+++ b/test/test_network.py
@@ -12,6 +12,7 @@ class TestNetwork(libvirttest.BaseTestClass):
 """
 _, obj = self.test_network()
 props = obj.GetAll('org.libvirt.Network', 
dbus_interface=dbus.PROPERTIES_IFACE)
+assert isinstance(props['BridgeName'], dbus.String)
 assert isinstance(props['Name'], dbus.String)
 
 
-- 
2.15.0

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [dbus PATCH 03/10] Implement UUID property for Network interface.

2018-04-05 Thread Katerina Koukiou
Signed-off-by: Katerina Koukiou 
---
 data/org.libvirt.Network.xml |  4 
 src/network.c| 21 +
 test/test_network.py |  1 +
 3 files changed, 26 insertions(+)

diff --git a/data/org.libvirt.Network.xml b/data/org.libvirt.Network.xml
index 30b352a..d144c5d 100644
--- a/data/org.libvirt.Network.xml
+++ b/data/org.libvirt.Network.xml
@@ -15,5 +15,9 @@
   https://libvirt.org/html/libvirt-libvirt-network.html#virNetworkGetName"/>
 
+
+  https://libvirt.org/html/libvirt-libvirt-network.html#virNetworkGetUUIDString"/>
+
   
 
diff --git a/src/network.c b/src/network.c
index 5e48fa7..90c2d9c 100644
--- a/src/network.c
+++ b/src/network.c
@@ -87,10 +87,31 @@ virtDBusNetworkGetName(const gchar *objectPath,
 *value = g_variant_new("s", name);
 }
 
+static void
+virtDBusNetworkGetUUID(const gchar *objectPath,
+   gpointer userData,
+   GVariant **value,
+   GError **error)
+{
+virtDBusConnect *connect = userData;
+g_autoptr(virNetwork) network = NULL;
+gchar uuid[VIR_UUID_STRING_BUFLEN] = "";
+
+network = virtDBusNetworkGetVirNetwork(connect, objectPath, error);
+if (!network)
+return;
+
+if (virNetworkGetUUIDString(network, uuid) < 0)
+return virtDBusUtilSetLastVirtError(error);
+
+*value = g_variant_new("s", uuid);
+}
+
 static virtDBusGDBusPropertyTable virtDBusNetworkPropertyTable[] = {
 { "Autostart", virtDBusNetworkGetAutostart, NULL },
 { "BridgeName", virtDBusNetworkGetBridgeName, NULL },
 { "Name", virtDBusNetworkGetName, NULL },
+{ "UUID", virtDBusNetworkGetUUID, NULL },
 { 0 }
 };
 
diff --git a/test/test_network.py b/test/test_network.py
index 1842944..e753f7f 100755
--- a/test/test_network.py
+++ b/test/test_network.py
@@ -15,6 +15,7 @@ class TestNetwork(libvirttest.BaseTestClass):
 assert isinstance(props['Autostart'], dbus.Boolean)
 assert isinstance(props['BridgeName'], dbus.String)
 assert isinstance(props['Name'], dbus.String)
+assert isinstance(props['UUID'], dbus.String)
 
 
 if __name__ == '__main__':
-- 
2.15.0

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [dbus PATCH 04/10] Implement NetworkLookupByUUID method for network interface.

2018-04-05 Thread Katerina Koukiou
Signed-off-by: Katerina Koukiou 
---
 data/org.libvirt.Connect.xml |  6 ++
 src/connect.c| 29 +
 test/test_connect.py |  1 +
 3 files changed, 36 insertions(+)

diff --git a/data/org.libvirt.Connect.xml b/data/org.libvirt.Connect.xml
index 043ee32..d15c2f6 100644
--- a/data/org.libvirt.Connect.xml
+++ b/data/org.libvirt.Connect.xml
@@ -56,6 +56,12 @@
   
   
 
+
+  https://libvirt.org/html/libvirt-libvirt-network.html#virNetworkLookupByUUID"/>
+  
+  
+
 
   https://libvirt.org/html/libvirt-libvirt-domain.html#virConnectDomainEventCallback"/>
diff --git a/src/connect.c b/src/connect.c
index d036753..f22f682 100644
--- a/src/connect.c
+++ b/src/connect.c
@@ -348,6 +348,34 @@ virtDBusNetworkLookupByName(GVariant *inArgs,
 *outArgs = g_variant_new("(o)", path);
 }
 
+static void
+virtDBusNetworkLookupByUUID(GVariant *inArgs,
+GUnixFDList *inFDs G_GNUC_UNUSED,
+const gchar *objectPath G_GNUC_UNUSED,
+gpointer userData,
+GVariant **outArgs,
+GUnixFDList **outFDs G_GNUC_UNUSED,
+GError **error)
+{
+virtDBusConnect *connect = userData;
+g_autoptr(virNetwork) network = NULL;
+g_autofree gchar *path = NULL;
+const gchar *uuidstr;
+
+g_variant_get(inArgs, "(s)", );
+
+if (!virtDBusConnectOpen(connect, error))
+return;
+
+network = virNetworkLookupByUUIDString(connect->connection, uuidstr);
+if (!network)
+return virtDBusUtilSetLastVirtError(error);
+
+path = virtDBusUtilBusPathForVirNetwork(network, connect->networkPath);
+
+*outArgs = g_variant_new("(o)", path);
+}
+
 static virtDBusGDBusPropertyTable virtDBusConnectPropertyTable[] = {
 { "Version", virtDBusConnectGetVersion, NULL },
 { 0 }
@@ -362,6 +390,7 @@ static virtDBusGDBusMethodTable 
virtDBusConnectMethodTable[] = {
 { "DomainLookupByUUID", virtDBusDomainLookupByUUID },
 { "ListNetworks", virtDBusConnectListNetworks },
 { "NetworkLookupByName", virtDBusNetworkLookupByName },
+{ "NetworkLookupByUUID", virtDBusNetworkLookupByUUID },
 { 0 }
 };
 
diff --git a/test/test_connect.py b/test/test_connect.py
index 440a496..5bddd2f 100755
--- a/test/test_connect.py
+++ b/test/test_connect.py
@@ -88,6 +88,7 @@ class TestConnect(libvirttest.BaseTestClass):
 
 @pytest.mark.parametrize("lookup_method_name,lookup_item", [
 ("NetworkLookupByName", 'Name'),
+("NetworkLookupByUUID", 'UUID'),
 ])
 def test_connect_network_lookup_by_property(self, lookup_method_name, 
lookup_item):
 """Parameterized test for all NetworkLookupBy* API calls of Connect 
interface
-- 
2.15.0

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [dbus PATCH 02/10] Implement Autostart property for Network Interface

2018-04-05 Thread Katerina Koukiou
Signed-off-by: Katerina Koukiou 
---
 data/org.libvirt.Network.xml |  4 
 src/network.c| 21 +
 test/test_network.py |  1 +
 3 files changed, 26 insertions(+)

diff --git a/data/org.libvirt.Network.xml b/data/org.libvirt.Network.xml
index 83a6b9e..30b352a 100644
--- a/data/org.libvirt.Network.xml
+++ b/data/org.libvirt.Network.xml
@@ -3,6 +3,10 @@
 
 
   
+
+  https://libvirt.org/html/libvirt-libvirt-network.html#virNetworkGetAutostart"/>
+
 
   https://libvirt.org/html/libvirt-libvirt-network.html#virNetworkGetBridgeName"/>
diff --git a/src/network.c b/src/network.c
index fab017c..5e48fa7 100644
--- a/src/network.c
+++ b/src/network.c
@@ -24,6 +24,26 @@ virtDBusNetworkGetVirNetwork(virtDBusConnect *connect,
 return network;
 }
 
+static void
+virtDBusNetworkGetAutostart(const gchar *objectPath,
+gpointer userData,
+GVariant **value,
+GError **error)
+{
+virtDBusConnect *connect = userData;
+g_autoptr(virNetwork) network = NULL;
+gint autostart = 0;
+
+network = virtDBusNetworkGetVirNetwork(connect, objectPath, error);
+if (!network)
+return;
+
+if (virNetworkGetAutostart(network, ) < 0)
+return virtDBusUtilSetLastVirtError(error);
+
+*value = g_variant_new("b", !!autostart);
+}
+
 static void
 virtDBusNetworkGetBridgeName(const gchar *objectPath,
  gpointer userData,
@@ -68,6 +88,7 @@ virtDBusNetworkGetName(const gchar *objectPath,
 }
 
 static virtDBusGDBusPropertyTable virtDBusNetworkPropertyTable[] = {
+{ "Autostart", virtDBusNetworkGetAutostart, NULL },
 { "BridgeName", virtDBusNetworkGetBridgeName, NULL },
 { "Name", virtDBusNetworkGetName, NULL },
 { 0 }
diff --git a/test/test_network.py b/test/test_network.py
index 9f15c2e..1842944 100755
--- a/test/test_network.py
+++ b/test/test_network.py
@@ -12,6 +12,7 @@ class TestNetwork(libvirttest.BaseTestClass):
 """
 _, obj = self.test_network()
 props = obj.GetAll('org.libvirt.Network', 
dbus_interface=dbus.PROPERTIES_IFACE)
+assert isinstance(props['Autostart'], dbus.Boolean)
 assert isinstance(props['BridgeName'], dbus.String)
 assert isinstance(props['Name'], dbus.String)
 
-- 
2.15.0

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [dbus PATCH 00/10] Impement some APIs for network Interface

2018-04-05 Thread Katerina Koukiou
Katerina Koukiou (10):
  Implement BridgeName property for Network interface.
  Implement Autostart property for Network Interface
  Implement UUID property for Network interface.
  Implement NetworkLookupByUUID method for network interface.
  Rename virtDBusEventsRegisterEvent to
virtDBusDomainEventsRegisterEvent
  Rename callback_ids variable to domain_callback_ids
  Register Network Lifecycle Events
  Implement Destroy method for Network Interface.
  Implement Undefine method for Network Interface
  Implement Create method for Network Interface

 data/org.libvirt.Connect.xml |  12 
 data/org.libvirt.Network.xml |  24 
 src/connect.c|  50 +++--
 src/connect.h|   3 +-
 src/events.c | 112 -
 src/network.c| 128 +++
 test/test_connect.py |   1 +
 test/test_network.py |  43 +++
 8 files changed, 342 insertions(+), 31 deletions(-)

-- 
2.15.0

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [dbus PATCH 05/10] Rename virtDBusEventsRegisterEvent to virtDBusDomainEventsRegisterEvent

2018-04-05 Thread Katerina Koukiou
This function was specific to Domain Lifecycle Events.
Rename it now, so that we can keep consistent naming when introducing
Events for other entities.

Signed-off-by: Katerina Koukiou 
---
 src/events.c | 36 ++--
 1 file changed, 18 insertions(+), 18 deletions(-)

diff --git a/src/events.c b/src/events.c
index eb85a3a..c6896d4 100644
--- a/src/events.c
+++ b/src/events.c
@@ -171,9 +171,9 @@ virtDBusEventsDomainDiskChange(virConnectPtr connection 
G_GNUC_UNUSED,
 }
 
 static void
-virtDBusEventsRegisterEvent(virtDBusConnect *connect,
-gint id,
-virConnectDomainEventGenericCallback callback)
+virtDBusDomainEventsRegisterEvent(virtDBusConnect *connect,
+  gint id,
+  virConnectDomainEventGenericCallback 
callback)
 {
 g_assert(connect->callback_ids[id] == -1);
 
@@ -188,24 +188,24 @@ virtDBusEventsRegisterEvent(virtDBusConnect *connect,
 void
 virtDBusEventsRegister(virtDBusConnect *connect)
 {
-virtDBusEventsRegisterEvent(connect,
-VIR_DOMAIN_EVENT_ID_LIFECYCLE,
-
VIR_DOMAIN_EVENT_CALLBACK(virtDBusEventsDomainLifecycle));
+virtDBusDomainEventsRegisterEvent(connect,
+  VIR_DOMAIN_EVENT_ID_LIFECYCLE,
+  
VIR_DOMAIN_EVENT_CALLBACK(virtDBusEventsDomainLifecycle));
 
-virtDBusEventsRegisterEvent(connect,
-VIR_DOMAIN_EVENT_ID_DEVICE_ADDED,
-
VIR_DOMAIN_EVENT_CALLBACK(virtDBusEventsDomainDeviceAdded));
+virtDBusDomainEventsRegisterEvent(connect,
+  VIR_DOMAIN_EVENT_ID_DEVICE_ADDED,
+  
VIR_DOMAIN_EVENT_CALLBACK(virtDBusEventsDomainDeviceAdded));
 
-virtDBusEventsRegisterEvent(connect,
-VIR_DOMAIN_EVENT_ID_DEVICE_REMOVED,
-
VIR_DOMAIN_EVENT_CALLBACK(virtDBusEventsDomainDeviceRemoved));
+virtDBusDomainEventsRegisterEvent(connect,
+  VIR_DOMAIN_EVENT_ID_DEVICE_REMOVED,
+  
VIR_DOMAIN_EVENT_CALLBACK(virtDBusEventsDomainDeviceRemoved));
 
-virtDBusEventsRegisterEvent(connect,
-VIR_DOMAIN_EVENT_ID_DISK_CHANGE,
-
VIR_DOMAIN_EVENT_CALLBACK(virtDBusEventsDomainDiskChange));
+virtDBusDomainEventsRegisterEvent(connect,
+  VIR_DOMAIN_EVENT_ID_DISK_CHANGE,
+  
VIR_DOMAIN_EVENT_CALLBACK(virtDBusEventsDomainDiskChange));
 
-virtDBusEventsRegisterEvent(connect,
-VIR_DOMAIN_EVENT_ID_TRAY_CHANGE,
-
VIR_DOMAIN_EVENT_CALLBACK(virtDBusEventsDomainTrayChange));
+virtDBusDomainEventsRegisterEvent(connect,
+  VIR_DOMAIN_EVENT_ID_TRAY_CHANGE,
+  
VIR_DOMAIN_EVENT_CALLBACK(virtDBusEventsDomainTrayChange));
 
 }
-- 
2.15.0

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [dbus PATCH 07/10] Register Network Lifecycle Events

2018-04-05 Thread Katerina Koukiou
Signed-off-by: Katerina Koukiou 
---
 data/org.libvirt.Connect.xml |  6 +
 src/connect.c| 13 ++
 src/connect.h|  1 +
 src/events.c | 60 
 4 files changed, 80 insertions(+)

diff --git a/data/org.libvirt.Connect.xml b/data/org.libvirt.Connect.xml
index d15c2f6..b11dbfb 100644
--- a/data/org.libvirt.Connect.xml
+++ b/data/org.libvirt.Connect.xml
@@ -68,5 +68,11 @@
   
   
 
+
+  https://libvirt.org/html/libvirt-libvirt-network.html#virConnectNetworkEventCallback"/>
+  
+  
+
   
 
diff --git a/src/connect.c b/src/connect.c
index 90172e3..a9006a2 100644
--- a/src/connect.c
+++ b/src/connect.c
@@ -49,6 +49,16 @@ virtDBusConnectClose(virtDBusConnect *connect,
 }
 }
 
+for (gint i = 0; i < VIR_NETWORK_EVENT_ID_LAST; i += 1) {
+if (connect->network_callback_ids[i] >= 0) {
+if (deregisterEvents) {
+virConnectNetworkEventDeregisterAny(connect->connection,
+
connect->network_callback_ids[i]);
+}
+connect->network_callback_ids[i] = -1;
+}
+}
+
 virConnectClose(connect->connection);
 connect->connection = NULL;
 }
@@ -431,6 +441,9 @@ virtDBusConnectNew(virtDBusConnect **connectp,
 for (gint i = 0; i < VIR_DOMAIN_EVENT_ID_LAST; i += 1)
 connect->domain_callback_ids[i] = -1;
 
+for (gint i = 0; i < VIR_NETWORK_EVENT_ID_LAST; i += 1)
+connect->network_callback_ids[i] = -1;
+
 connect->bus = bus;
 connect->uri = uri;
 connect->connectPath = connectPath;
diff --git a/src/connect.h b/src/connect.h
index e69898c..e8c757f 100644
--- a/src/connect.h
+++ b/src/connect.h
@@ -18,6 +18,7 @@ struct virtDBusConnect {
 GMutex lock;
 
 gint domain_callback_ids[VIR_DOMAIN_EVENT_ID_LAST];
+gint network_callback_ids[VIR_NETWORK_EVENT_ID_LAST];
 };
 typedef struct virtDBusConnect virtDBusConnect;
 
diff --git a/src/events.c b/src/events.c
index 5fa61f5..b4d22a6 100644
--- a/src/events.c
+++ b/src/events.c
@@ -170,6 +170,48 @@ virtDBusEventsDomainDiskChange(virConnectPtr connection 
G_GNUC_UNUSED,
 return 0;
 }
 
+VIRT_DBUS_ENUM_DECL(virtDBusEventsNetworkEvent)
+VIRT_DBUS_ENUM_IMPL(virtDBusEventsNetworkEvent,
+VIR_NETWORK_EVENT_LAST,
+"Defined",
+"Undefined",
+"Started",
+"Stopped")
+
+static const gchar *
+virtDBusEventsNetworkEventToString(gint event)
+{
+const gchar *str = virtDBusEventsNetworkEventTypeToString(event);
+return str ? str : "unknown";
+}
+
+static gint
+virtDBusEventsNetworkLifecycle(virConnectPtr connection G_GNUC_UNUSED,
+   virNetworkPtr network,
+   gint event,
+   gint detail G_GNUC_UNUSED,
+   gpointer opaque)
+{
+virtDBusConnect *connect = opaque;
+g_autofree gchar *path = NULL;
+const gchar *eventStr = virtDBusEventsNetworkEventToString(event);
+
+if (!eventStr)
+return 0;
+
+path = virtDBusUtilBusPathForVirNetwork(network, connect->networkPath);
+
+g_dbus_connection_emit_signal(connect->bus,
+  NULL,
+  connect->connectPath,
+  VIRT_DBUS_CONNECT_INTERFACE,
+  "NetworkEvent",
+  g_variant_new("(os)", path, eventStr),
+  NULL);
+
+return 0;
+}
+
 static void
 virtDBusDomainEventsRegisterEvent(virtDBusConnect *connect,
   gint id,
@@ -185,6 +227,21 @@ virtDBusDomainEventsRegisterEvent(virtDBusConnect *connect,
 NULL);
 }
 
+static void
+virtDBusNetworkEventsRegisterEvent(virtDBusConnect *connect,
+   gint id,
+   virConnectNetworkEventGenericCallback 
callback)
+{
+g_assert(connect->network_callback_ids[id] == -1);
+
+connect->network_callback_ids[id] = 
virConnectNetworkEventRegisterAny(connect->connection,
+  NULL,
+  id,
+  
VIR_NETWORK_EVENT_CALLBACK(callback),
+  
connect,
+  
NULL);
+}
+
 void
 virtDBusEventsRegister(virtDBusConnect *connect)
 {
@@ -208,4 +265,7 @@ virtDBusEventsRegister(virtDBusConnect *connect)
   VIR_DOMAIN_EVENT_ID_TRAY_CHANGE,
   

[libvirt] [dbus PATCH 06/10] Rename callback_ids variable to domain_callback_ids

2018-04-05 Thread Katerina Koukiou
The callback_ids var is domain specific.
Renaming it now, so as to keep consistent naming when introducing
events for other entities.

Signed-off-by: Katerina Koukiou 
---
 src/connect.c |  8 
 src/connect.h |  2 +-
 src/events.c  | 16 
 3 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/src/connect.c b/src/connect.c
index f22f682..90172e3 100644
--- a/src/connect.c
+++ b/src/connect.c
@@ -40,12 +40,12 @@ virtDBusConnectClose(virtDBusConnect *connect,
 {
 
 for (gint i = 0; i < VIR_DOMAIN_EVENT_ID_LAST; i += 1) {
-if (connect->callback_ids[i] >= 0) {
+if (connect->domain_callback_ids[i] >= 0) {
 if (deregisterEvents) {
 virConnectDomainEventDeregisterAny(connect->connection,
-   connect->callback_ids[i]);
+   
connect->domain_callback_ids[i]);
 }
-connect->callback_ids[i] = -1;
+connect->domain_callback_ids[i] = -1;
 }
 }
 
@@ -429,7 +429,7 @@ virtDBusConnectNew(virtDBusConnect **connectp,
 g_mutex_init(>lock);
 
 for (gint i = 0; i < VIR_DOMAIN_EVENT_ID_LAST; i += 1)
-connect->callback_ids[i] = -1;
+connect->domain_callback_ids[i] = -1;
 
 connect->bus = bus;
 connect->uri = uri;
diff --git a/src/connect.h b/src/connect.h
index 7ed84b8..e69898c 100644
--- a/src/connect.h
+++ b/src/connect.h
@@ -17,7 +17,7 @@ struct virtDBusConnect {
 virConnectPtr connection;
 GMutex lock;
 
-gint callback_ids[VIR_DOMAIN_EVENT_ID_LAST];
+gint domain_callback_ids[VIR_DOMAIN_EVENT_ID_LAST];
 };
 typedef struct virtDBusConnect virtDBusConnect;
 
diff --git a/src/events.c b/src/events.c
index c6896d4..5fa61f5 100644
--- a/src/events.c
+++ b/src/events.c
@@ -175,14 +175,14 @@ virtDBusDomainEventsRegisterEvent(virtDBusConnect 
*connect,
   gint id,
   virConnectDomainEventGenericCallback 
callback)
 {
-g_assert(connect->callback_ids[id] == -1);
-
-connect->callback_ids[id] = 
virConnectDomainEventRegisterAny(connect->connection,
- NULL,
- id,
- 
VIR_DOMAIN_EVENT_CALLBACK(callback),
- connect,
- NULL);
+g_assert(connect->domain_callback_ids[id] == -1);
+
+connect->domain_callback_ids[id] = 
virConnectDomainEventRegisterAny(connect->connection,
+NULL,
+id,
+
VIR_DOMAIN_EVENT_CALLBACK(callback),
+
connect,
+NULL);
 }
 
 void
-- 
2.15.0

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] [PATCH] qemu: cpu: fix fullCPU to include all emulatable qemu features

2018-04-05 Thread Jiri Denemark
On Thu, Apr 05, 2018 at 10:26:48 +0300, Nikolay Shirokovskiy wrote:
> I've checked against latest upstream version of libvirt. Issue is still not 
> fixed.
> 
> I guess I should provide cpu data for tests like in next patch:

Yeah, CPU data would be helpful to see more details about the CPU. You
can generate them in tests/cputestdata using

./cpu-gather.sh | ./cpu-parse.sh

You may need to install the cpuid tool before using them and ideally
have a modern QEMU binary installed too.

Jirka

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] Libvirt master compilation failed

2018-04-05 Thread Mathieu Tarral
> Forgot to install 'gettext', maybe.
I was missing gettext indeed.

I ran the autogen.sh again, then make, and the build was successful.

I wonder why this wasn't spotted by the configure.sh script from autotools ?

There is an issue to be fixed here.


Thank you Pino !


-- 
Mathieu Tarral

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [libvirt PATCH v2 00/4] Require QEMU 1.5.0

2018-04-05 Thread Ján Tomko
v2:
* Change the version from 1.3.0 to 1.5.0
* Mention this breaks RHEL 6 QEMU and list the versions
in relevant long-term releases

Some of the patches are very big, available in my repo:
https://repo.or.cz/libvirt/jtomko.git/shortlog/refs/heads/caps_cleanup_v2
git fetch git://repo.or.cz/libvirt/jtomko.git caps_cleanup_v2:

Ján Tomko (44):
  qemuxml2argvtest: Fix q35-virt-manager capabilities
  Delete bogus cpu-host-passthrough test
  Force QMP capability probing
  Require QEMU 1.5.0

  The following patches are nearly identical to v1:
  * rebased on the 1.3.1 and 1.4.2 caps deletion
  * luks-disks-source-qcow2.args is fixed

  Deprecate QEMU_CAPS_PCI_MULTIFUNCTION
  Deprecate QEMU_CAPS_NETDEV
  Clean up qemuDomainAttachNetDevice
  Remove unused qemuDomainNetVLAN
  Remove qemuDomainSupportsNetdev
  Deprecate QEMU_CAPS_MONITOR_JSON
  Deprecate QEMU_CAPS_NO_USER_CONFIG
  Deprecate QEMU_CAPS_MEM_PATH
  Deprecate QEMU_CAPS_DRIVE_SERIAL
  Deprecate QEMU_CAPS_SDL
  Deprecate QEMU_CAPS_RTC
  Deprecate QEMU_CAPS_RTC_TD_HACK
  Deprecate QEMU_CAPS_VHOST_NET
  Deprecate QEMU_CAPS_NODEFCONFIG
  Deprecate QEMU_CAPS_BOOT_MENU
  Deprecate QEMU_CAPS_FSDEV
  Deprecate QEMU_CAPS_NAME_PROCESS
  Deprecate QEMU_CAPS_SMBIOS_TYPE
  Deprecate QEMU_CAPS_VGA_NONE
  Deprecate QEMU_CAPS_DRIVE_AIO
  Deprecate QEMU_CAPS_CHARDEV_SPICEVMC
  Deprecate QEMU_CAPS_DEVICE_SPICEVMC
  Deprecate QEMU_CAPS_DRIVE_CACHE_DIRECTSYNC
  Deprecate QEMU_CAPS_NO_SHUTDOWN
  Deprecate QEMU_CAPS_DRIVE_CACHE_UNSAFE
  Deprecate QEMU_CAPS_FSDEV_READONLY
  Deprecate QEMU_CAPS_DRIVE_COPY_ON_READ
  Deprecate QEMU_CAPS_FSDEV_WRITEOUT
  Deprecate QEMU_CAPS_DRIVE_IOTUNE
  Deprecate QEMU_CAPS_WAKEUP
  Deprecate QEMU_CAPS_NETDEV_BRIDGE
  Deprecate QEMU_CAPS_SECCOMP_SANDBOX
  Deprecate QEMU_CAPS_DTB
  Deprecate QEMU_CAPS_IPV6_MIGRATION
  Deprecate QEMU_CAPS_MACHINE_OPT
  Deprecate QEMU_CAPS_DUMP_GUEST_CORE
  Deprecate QEMU_CAPS_VNC_SHARE_POLICY
  Deprecate QEMU_CAPS_HOST_PCI_MULTIDOMAIN
  Deprecate QEMU_CAPS_DISPLAY
  Deprecate QEMU_CAPS_MACHINE_USB_OPT

 cfg.mk |2 +-
 src/qemu/qemu_capabilities.c   |  936 +
 src/qemu/qemu_capabilities.h   |   74 +-
 src/qemu/qemu_capspriv.h   |   17 +-
 src/qemu/qemu_command.c|  690 ++
 src/qemu/qemu_domain.c |   16 -
 src/qemu/qemu_domain.h |6 -
 src/qemu/qemu_driver.c |   48 +-
 src/qemu/qemu_hotplug.c|  147 +-
 src/qemu/qemu_interface.c  |4 +-
 src/qemu/qemu_interface.h  |1 -
 src/qemu/qemu_migration.c  |   10 +-
 src/qemu/qemu_process.c|   23 +-
 tests/Makefile.am  |8 +-
 .../qemucapabilitiesdata/caps_1.2.2.x86_64.replies | 1886 -
 tests/qemucapabilitiesdata/caps_1.2.2.x86_64.xml   |  172 --
 .../qemucapabilitiesdata/caps_1.3.1.x86_64.replies | 2141 ---
 tests/qemucapabilitiesdata/caps_1.3.1.x86_64.xml   |  196 --
 .../qemucapabilitiesdata/caps_1.4.2.x86_64.replies | 2191 
 tests/qemucapabilitiesdata/caps_1.4.2.x86_64.xml   |  198 --
 tests/qemucapabilitiesdata/caps_1.5.3.x86_64.xml   |   35 -
 tests/qemucapabilitiesdata/caps_1.6.0.x86_64.xml   |   35 -
 tests/qemucapabilitiesdata/caps_1.7.0.x86_64.xml   |   35 -
 tests/qemucapabilitiesdata/caps_2.1.1.x86_64.xml   |   35 -
 tests/qemucapabilitiesdata/caps_2.10.0.aarch64.xml |   35 -
 tests/qemucapabilitiesdata/caps_2.10.0.ppc64.xml   |   35 -
 tests/qemucapabilitiesdata/caps_2.10.0.s390x.xml   |   35 -
 tests/qemucapabilitiesdata/caps_2.10.0.x86_64.xml  |   35 -
 tests/qemucapabilitiesdata/caps_2.11.0.s390x.xml   |   35 -
 tests/qemucapabilitiesdata/caps_2.12.0.aarch64.xml |   35 -
 tests/qemucapabilitiesdata/caps_2.12.0.ppc64.xml   |   35 -
 tests/qemucapabilitiesdata/caps_2.12.0.s390x.xml   |   35 -
 tests/qemucapabilitiesdata/caps_2.12.0.x86_64.xml  |   35 -
 tests/qemucapabilitiesdata/caps_2.4.0.x86_64.xml   |   35 -
 tests/qemucapabilitiesdata/caps_2.5.0.x86_64.xml   |   35 -
 tests/qemucapabilitiesdata/caps_2.6.0.aarch64.xml  |   35 -
 tests/qemucapabilitiesdata/caps_2.6.0.ppc64.xml|   35 -
 tests/qemucapabilitiesdata/caps_2.6.0.x86_64.xml   |   35 -
 tests/qemucapabilitiesdata/caps_2.7.0.s390x.xml|   35 -
 tests/qemucapabilitiesdata/caps_2.7.0.x86_64.xml   |   35 -
 tests/qemucapabilitiesdata/caps_2.8.0.s390x.xml|   35 -
 tests/qemucapabilitiesdata/caps_2.8.0.x86_64.xml   |   35 -
 tests/qemucapabilitiesdata/caps_2.9.0.ppc64.xml|   35 -
 tests/qemucapabilitiesdata/caps_2.9.0.s390x.xml|   35 -
 tests/qemucapabilitiesdata/caps_2.9.0.x86_64.xml   |   35 -
 tests/qemucapabilitiestest.c   |3 -
 tests/qemucapsprobe.c  |2 +-
 

[libvirt] [libvirt PATCH v2 01/44] qemuxml2argvtest: Fix q35-virt-manager capabilities

2018-04-05 Thread Ján Tomko
Use QEMU_CAPS_MACHINE_OPT and QEMU_CAPS_MACHINE_VMPORT_OPT
since it specifies .

Signed-off-by: Ján Tomko 
---
 tests/qemuxml2argvdata/q35-virt-manager-basic.args | 2 +-
 tests/qemuxml2argvtest.c   | 2 ++
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/tests/qemuxml2argvdata/q35-virt-manager-basic.args 
b/tests/qemuxml2argvdata/q35-virt-manager-basic.args
index 96d2ae5924..c7dd514fec 100644
--- a/tests/qemuxml2argvdata/q35-virt-manager-basic.args
+++ b/tests/qemuxml2argvdata/q35-virt-manager-basic.args
@@ -7,7 +7,7 @@ QEMU_AUDIO_DRV=spice \
 /usr/bin/qemu-system-x86_64 \
 -name virt-manager-basic \
 -S \
--M pc-q35-2.7 \
+-machine pc-q35-2.7,accel=kvm,vmport=off \
 -m 4096 \
 -smp 2,sockets=2,cores=1,threads=1 \
 -uuid 1b826c23-8767-47ad-a6b5-c83a88277f71 \
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index d79913dd0a..5ccbb3cff9 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -2384,6 +2384,8 @@ mymain(void)
 DO_TEST("q35-virt-manager-basic",
 QEMU_CAPS_KVM,
 QEMU_CAPS_RTC,
+QEMU_CAPS_MACHINE_OPT,
+QEMU_CAPS_MACHINE_VMPORT_OPT,
 QEMU_CAPS_ICH9_DISABLE_S3,
 QEMU_CAPS_ICH9_DISABLE_S4,
 QEMU_CAPS_VIRTIO_PCI_DISABLE_LEGACY,
-- 
2.16.1

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

[libvirt] [jenkins-ci PATCH 10/10] guests: Remove per-host make variable

2018-04-05 Thread Andrea Bolognani
We are figuring out which make binary we should use dynamically
in the shell profile now, so this variable is redundant; plus,
we were not actually using it anywhere.

Signed-off-by: Andrea Bolognani 
---
 guests/group_vars/all/main.yml| 1 -
 guests/host_vars/libvirt-freebsd-10/main.yml  | 1 -
 guests/host_vars/libvirt-freebsd-11/main.yml  | 1 -
 guests/host_vars/libvirt-freebsd-current/main.yml | 1 -
 4 files changed, 4 deletions(-)

diff --git a/guests/group_vars/all/main.yml b/guests/group_vars/all/main.yml
index fb83a56..4229e73 100644
--- a/guests/group_vars/all/main.yml
+++ b/guests/group_vars/all/main.yml
@@ -22,6 +22,5 @@ PYTHONPATH:
 
 bash: /bin/bash
 java: /usr/bin/java
-make: /usr/bin/make
 su: /bin/su
 sudoers: /etc/sudoers
diff --git a/guests/host_vars/libvirt-freebsd-10/main.yml 
b/guests/host_vars/libvirt-freebsd-10/main.yml
index 4d57042..05e1955 100644
--- a/guests/host_vars/libvirt-freebsd-10/main.yml
+++ b/guests/host_vars/libvirt-freebsd-10/main.yml
@@ -6,7 +6,6 @@ PYTHONPATH: $VIRT_PREFIX/lib/python3.6/site-packages
 
 bash: /usr/local/bin/bash
 java: /usr/local/bin/java
-make: /usr/local/bin/gmake
 su: /usr/bin/su
 sudoers: /usr/local/etc/sudoers
 
diff --git a/guests/host_vars/libvirt-freebsd-11/main.yml 
b/guests/host_vars/libvirt-freebsd-11/main.yml
index 4d57042..05e1955 100644
--- a/guests/host_vars/libvirt-freebsd-11/main.yml
+++ b/guests/host_vars/libvirt-freebsd-11/main.yml
@@ -6,7 +6,6 @@ PYTHONPATH: $VIRT_PREFIX/lib/python3.6/site-packages
 
 bash: /usr/local/bin/bash
 java: /usr/local/bin/java
-make: /usr/local/bin/gmake
 su: /usr/bin/su
 sudoers: /usr/local/etc/sudoers
 
diff --git a/guests/host_vars/libvirt-freebsd-current/main.yml 
b/guests/host_vars/libvirt-freebsd-current/main.yml
index 4d57042..05e1955 100644
--- a/guests/host_vars/libvirt-freebsd-current/main.yml
+++ b/guests/host_vars/libvirt-freebsd-current/main.yml
@@ -6,7 +6,6 @@ PYTHONPATH: $VIRT_PREFIX/lib/python3.6/site-packages
 
 bash: /usr/local/bin/bash
 java: /usr/local/bin/java
-make: /usr/local/bin/gmake
 su: /usr/bin/su
 sudoers: /usr/local/etc/sudoers
 
-- 
2.14.3

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [jenkins-ci PATCH 07/10] guests: Add more enviroment variables to shell profile

2018-04-05 Thread Andrea Bolognani
All these are currently defined per-worker at the Jenkins level,
which has several disadvantages: first of all, they are completely
invisible to anyone except people with admin access to the Jenkins
instance; moreover, updating them requires a lot of clicking in
the web interface, and change history is not tracked. Moving their
configuration to the shell profile solves all those issues.

Signed-off-by: Andrea Bolognani 
---
 guests/group_vars/all/main.yml | 6 ++
 guests/templates/bashrc| 6 ++
 2 files changed, 12 insertions(+)

diff --git a/guests/group_vars/all/main.yml b/guests/group_vars/all/main.yml
index ee53eec..c5166bc 100644
--- a/guests/group_vars/all/main.yml
+++ b/guests/group_vars/all/main.yml
@@ -10,7 +10,13 @@ jenkins_url: https://ci.centos.org/computer/{{ 
inventory_hostname }}/slave-agent
 
 # Environment variables and paths to commands/files that might be
 # OS-dependent. Can be overridden on a per-host basis
+VIRT_PREFIX: $HOME/build/libvirt
 PATH: $VIRT_PREFIX/bin:$PATH
+C_INCLUDE_PATH: $VIRT_PREFIX/include
+LD_LIBRARY_PATH: $VIRT_PREFIX/lib
+PKG_CONFIG_PATH: $VIRT_PREFIX/lib/pkgconfig
+XDG_DATA_DIRS: $VIRT_PREFIX/share:/usr/share:/usr/local/share
+GI_TYPELIB_PATH: $VIRT_PREFIX/lib/girepository-1.0
 
 bash: /bin/bash
 java: /usr/bin/java
diff --git a/guests/templates/bashrc b/guests/templates/bashrc
index affdf4c..721272a 100644
--- a/guests/templates/bashrc
+++ b/guests/templates/bashrc
@@ -1,6 +1,12 @@
 export PS1="[\u@\h \w]\$ "
 
+export VIRT_PREFIX="{{ VIRT_PREFIX }}"
 export PATH="{{ PATH }}"
+export C_INCLUDE_PATH="{{ C_INCLUDE_PATH }}"
+export LD_LIBRARY_PATH="{{ LD_LIBRARY_PATH }}"
+export PKG_CONFIG_PATH="{{ PKG_CONFIG_PATH }}"
+export XDG_DATA_DIRS="{{ XDG_DATA_DIRS }}"
+export GI_TYPELIB_PATH="{{ GI_TYPELIB_PATH }}"
 
 which gmake >/dev/null 2>&1 && export MAKE="gmake" || export MAKE="make"
 which ccache >/dev/null 2>&1 && export CC="ccache cc"
-- 
2.14.3

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [libvirt PATCH v2 02/44] Delete bogus cpu-host-passthrough test

2018-04-05 Thread Ján Tomko
We test the same XML for a type='kvm' domain twice, once with
QEMU_CAPS_KVM (expecting success), once without (expecting failure).

The failure case relies on QEMU_CAPS_MACHINE_OPT not being set,
failing in qemuBuildObsoleteAccelArg.

Checking a domain-type error message in a cpu test is strange.
Delete the negative test to allow assuming QEMU_CAPS_MACHINE_OPT by
default.

Signed-off-by: Ján Tomko 
---
 tests/qemuxml2argvtest.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index 5ccbb3cff9..24eb8cbc5b 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -1715,7 +1715,6 @@ mymain(void)
 DO_TEST_FAILURE("cpu-host-model-nofallback", NONE);
 skipLegacyCPUs = false;
 DO_TEST("cpu-host-passthrough", QEMU_CAPS_KVM);
-DO_TEST_FAILURE("cpu-host-passthrough", NONE);
 DO_TEST_FAILURE("cpu-qemu-host-passthrough", QEMU_CAPS_KVM);
 
 qemuTestSetHostArch(driver.caps, VIR_ARCH_S390X);
-- 
2.16.1

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

[libvirt] [jenkins-ci PATCH 05/10] guests: Move make configuration to shell profile

2018-04-05 Thread Andrea Bolognani
Now that we have our custom shell profile, we can pick the
correct make variant dynamically there instead of doing it
in the Jenkins job definition, so that the $MAKE variable
will also be available when using the guests outside of the
CI environment.

Signed-off-by: Andrea Bolognani 
---
 guests/templates/bashrc | 1 +
 jobs/defaults.yaml  | 5 -
 2 files changed, 1 insertion(+), 5 deletions(-)

diff --git a/guests/templates/bashrc b/guests/templates/bashrc
index 51d0e64..6bc0a56 100644
--- a/guests/templates/bashrc
+++ b/guests/templates/bashrc
@@ -1,3 +1,4 @@
 export PS1="[\u@\h \w]\$ "
 
+which gmake >/dev/null 2>&1 && export MAKE="gmake" || export MAKE="make"
 which ccache >/dev/null 2>&1 && export CC="ccache cc"
diff --git a/jobs/defaults.yaml b/jobs/defaults.yaml
index cc58314..1eb77d9 100644
--- a/jobs/defaults.yaml
+++ b/jobs/defaults.yaml
@@ -4,11 +4,6 @@
 branch: master
 node: libvirt
 global_env: |
-  MAKE='make'
-  unamestr=`uname`
-  if [ "$unamestr" = 'FreeBSD' ]; then
-  MAKE='gmake'
-  fi
   export PATH=$VIRT_PREFIX/bin:$PATH
 local_env: |
 smp: 3
-- 
2.14.3

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [jenkins-ci PATCH 09/10] guests: Add Python configuration to shell profile

2018-04-05 Thread Andrea Bolognani
This is conceptually identical to how Perl is handled, except
that we still need to override $PYTHONPATH in Jenkins jobs in
order to be able to build projects using both Python 3 and
Python 2 on the same guest. We might want to reconsider that
decision, but for the time being this change is still helpful
to people running guests outside of the CI environment.

Signed-off-by: Andrea Bolognani 
---
 guests/group_vars/all/main.yml| 1 +
 guests/host_vars/libvirt-centos-6/main.yml| 1 +
 guests/host_vars/libvirt-centos-7/main.yml| 1 +
 guests/host_vars/libvirt-debian-8/main.yml| 1 +
 guests/host_vars/libvirt-debian-9/main.yml| 1 +
 guests/host_vars/libvirt-debian-sid/main.yml  | 1 +
 guests/host_vars/libvirt-fedora-26/main.yml   | 1 +
 guests/host_vars/libvirt-fedora-27/main.yml   | 1 +
 guests/host_vars/libvirt-fedora-rawhide/main.yml  | 1 +
 guests/host_vars/libvirt-freebsd-10/main.yml  | 1 +
 guests/host_vars/libvirt-freebsd-11/main.yml  | 1 +
 guests/host_vars/libvirt-freebsd-current/main.yml | 1 +
 guests/host_vars/libvirt-ubuntu-14/main.yml   | 1 +
 guests/host_vars/libvirt-ubuntu-16/main.yml   | 1 +
 guests/templates/bashrc   | 2 ++
 15 files changed, 16 insertions(+)

diff --git a/guests/group_vars/all/main.yml b/guests/group_vars/all/main.yml
index 6456bd5..fb83a56 100644
--- a/guests/group_vars/all/main.yml
+++ b/guests/group_vars/all/main.yml
@@ -18,6 +18,7 @@ PKG_CONFIG_PATH: $VIRT_PREFIX/lib/pkgconfig
 XDG_DATA_DIRS: $VIRT_PREFIX/share:/usr/share:/usr/local/share
 GI_TYPELIB_PATH: $VIRT_PREFIX/lib/girepository-1.0
 PERL5LIB:
+PYTHONPATH:
 
 bash: /bin/bash
 java: /usr/bin/java
diff --git a/guests/host_vars/libvirt-centos-6/main.yml 
b/guests/host_vars/libvirt-centos-6/main.yml
index 2265615..422d033 100644
--- a/guests/host_vars/libvirt-centos-6/main.yml
+++ b/guests/host_vars/libvirt-centos-6/main.yml
@@ -1,5 +1,6 @@
 ---
 PERL5LIB: $VIRT_PREFIX/lib64/perl5
+PYTHONPATH: $VIRT_PREFIX/lib64/python2.6/site-packages
 
 projects:
   - libvirt
diff --git a/guests/host_vars/libvirt-centos-7/main.yml 
b/guests/host_vars/libvirt-centos-7/main.yml
index 3068bb1..935ab15 100644
--- a/guests/host_vars/libvirt-centos-7/main.yml
+++ b/guests/host_vars/libvirt-centos-7/main.yml
@@ -1,5 +1,6 @@
 ---
 PERL5LIB: $VIRT_PREFIX/lib64/perl5
+PYTHONPATH: $VIRT_PREFIX/lib64/python2.7/site-packages
 
 projects:
   - libosinfo
diff --git a/guests/host_vars/libvirt-debian-8/main.yml 
b/guests/host_vars/libvirt-debian-8/main.yml
index 76c0076..bfd074d 100644
--- a/guests/host_vars/libvirt-debian-8/main.yml
+++ b/guests/host_vars/libvirt-debian-8/main.yml
@@ -1,5 +1,6 @@
 ---
 PERL5LIB: $VIRT_PREFIX/lib/x86_64-linux-gnu/perl/5.20.2
+PYTHONPATH: $VIRT_PREFIX/lib/python3.4/site-packages
 
 projects:
   - libosinfo
diff --git a/guests/host_vars/libvirt-debian-9/main.yml 
b/guests/host_vars/libvirt-debian-9/main.yml
index 45bc9de..bdaa00d 100644
--- a/guests/host_vars/libvirt-debian-9/main.yml
+++ b/guests/host_vars/libvirt-debian-9/main.yml
@@ -1,5 +1,6 @@
 ---
 PERL5LIB: $VIRT_PREFIX/lib/x86_64-linux-gnu/perl/5.24.1
+PYTHONPATH: $VIRT_PREFIX/lib/python3.5/site-packages
 
 projects:
   - libosinfo
diff --git a/guests/host_vars/libvirt-debian-sid/main.yml 
b/guests/host_vars/libvirt-debian-sid/main.yml
index 96b49d2..cb61b6e 100644
--- a/guests/host_vars/libvirt-debian-sid/main.yml
+++ b/guests/host_vars/libvirt-debian-sid/main.yml
@@ -1,5 +1,6 @@
 ---
 PERL5LIB: $VIRT_PREFIX/lib/x86_64-linux-gnu/perl/5.26.1
+PYTHONPATH: $VIRT_PREFIX/lib/python3.6/site-packages
 
 projects:
   - libosinfo
diff --git a/guests/host_vars/libvirt-fedora-26/main.yml 
b/guests/host_vars/libvirt-fedora-26/main.yml
index b21e829..732df24 100644
--- a/guests/host_vars/libvirt-fedora-26/main.yml
+++ b/guests/host_vars/libvirt-fedora-26/main.yml
@@ -1,5 +1,6 @@
 ---
 PERL5LIB: $VIRT_PREFIX/lib64/perl5
+PYTHONPATH: $VIRT_PREFIX/lib64/python3.6/site-packages
 
 projects:
   - libosinfo
diff --git a/guests/host_vars/libvirt-fedora-27/main.yml 
b/guests/host_vars/libvirt-fedora-27/main.yml
index b21e829..732df24 100644
--- a/guests/host_vars/libvirt-fedora-27/main.yml
+++ b/guests/host_vars/libvirt-fedora-27/main.yml
@@ -1,5 +1,6 @@
 ---
 PERL5LIB: $VIRT_PREFIX/lib64/perl5
+PYTHONPATH: $VIRT_PREFIX/lib64/python3.6/site-packages
 
 projects:
   - libosinfo
diff --git a/guests/host_vars/libvirt-fedora-rawhide/main.yml 
b/guests/host_vars/libvirt-fedora-rawhide/main.yml
index b21e829..732df24 100644
--- a/guests/host_vars/libvirt-fedora-rawhide/main.yml
+++ b/guests/host_vars/libvirt-fedora-rawhide/main.yml
@@ -1,5 +1,6 @@
 ---
 PERL5LIB: $VIRT_PREFIX/lib64/perl5
+PYTHONPATH: $VIRT_PREFIX/lib64/python3.6/site-packages
 
 projects:
   - libosinfo
diff --git a/guests/host_vars/libvirt-freebsd-10/main.yml 
b/guests/host_vars/libvirt-freebsd-10/main.yml
index dc1a018..4d57042 100644
--- a/guests/host_vars/libvirt-freebsd-10/main.yml
+++ 

[libvirt] [jenkins-ci PATCH 03/10] guests: Add custom shell profile

2018-04-05 Thread Andrea Bolognani
We want to take control of the user's environment. For now the
custom shell profile only sets the prompt, but it will later
be used to influence the build environment.

Signed-off-by: Andrea Bolognani 
---
 guests/tasks/users.yml| 17 +
 guests/templates/bash_profile |  1 +
 guests/templates/bashrc   |  1 +
 3 files changed, 19 insertions(+)
 create mode 100644 guests/templates/bash_profile
 create mode 100644 guests/templates/bashrc

diff --git a/guests/tasks/users.yml b/guests/tasks/users.yml
index 1ecacee..8e59fa9 100644
--- a/guests/tasks/users.yml
+++ b/guests/tasks/users.yml
@@ -82,3 +82,20 @@
 owner: '{{ flavor }}'
 group: '{{ flavor }}'
 create: yes
+
+- name: '{{ flavor }}: Create shell profile'
+  template:
+src: templates/{{ item }}
+dest: /home/{{ flavor }}/.{{ item }}
+owner: '{{ flavor }}'
+group: '{{ flavor }}'
+  with_items:
+- bash_profile
+- bashrc
+
+- name: '{{ flavor }}: Remove existing shell profile'
+  file:
+path: /home/{{ flavor }}/.{{ item }}
+state: absent
+  with_items:
+- profile
diff --git a/guests/templates/bash_profile b/guests/templates/bash_profile
new file mode 100644
index 000..a82a60e
--- /dev/null
+++ b/guests/templates/bash_profile
@@ -0,0 +1 @@
+test -f ~/.bashrc && . ~/.bashrc
diff --git a/guests/templates/bashrc b/guests/templates/bashrc
new file mode 100644
index 000..6640da6
--- /dev/null
+++ b/guests/templates/bashrc
@@ -0,0 +1 @@
+export PS1="[\u@\h \w]\$ "
-- 
2.14.3

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [jenkins-ci PATCH 06/10] guests: Move $PATH configuration to shell profile

2018-04-05 Thread Andrea Bolognani
Same as for $MAKE, moving the configuration here makes it
easier to reproduce issues outside of the CI environment.

Signed-off-by: Andrea Bolognani 
---
 guests/group_vars/all/main.yml | 6 --
 guests/templates/bashrc| 2 ++
 jobs/defaults.yaml | 1 -
 3 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/guests/group_vars/all/main.yml b/guests/group_vars/all/main.yml
index dbe9517..ee53eec 100644
--- a/guests/group_vars/all/main.yml
+++ b/guests/group_vars/all/main.yml
@@ -8,8 +8,10 @@ ansible_ssh_pass: root
 
 jenkins_url: https://ci.centos.org/computer/{{ inventory_hostname 
}}/slave-agent.jnlp
 
-# Paths to various commands and files that might be OS-dependent. Can
-# be overridden on a per-host basis
+# Environment variables and paths to commands/files that might be
+# OS-dependent. Can be overridden on a per-host basis
+PATH: $VIRT_PREFIX/bin:$PATH
+
 bash: /bin/bash
 java: /usr/bin/java
 make: /usr/bin/make
diff --git a/guests/templates/bashrc b/guests/templates/bashrc
index 6bc0a56..affdf4c 100644
--- a/guests/templates/bashrc
+++ b/guests/templates/bashrc
@@ -1,4 +1,6 @@
 export PS1="[\u@\h \w]\$ "
 
+export PATH="{{ PATH }}"
+
 which gmake >/dev/null 2>&1 && export MAKE="gmake" || export MAKE="make"
 which ccache >/dev/null 2>&1 && export CC="ccache cc"
diff --git a/jobs/defaults.yaml b/jobs/defaults.yaml
index 1eb77d9..23f8555 100644
--- a/jobs/defaults.yaml
+++ b/jobs/defaults.yaml
@@ -4,7 +4,6 @@
 branch: master
 node: libvirt
 global_env: |
-  export PATH=$VIRT_PREFIX/bin:$PATH
 local_env: |
 smp: 3
 spam: yman...@redhat.com libvirt...@redhat.com
-- 
2.14.3

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [jenkins-ci PATCH 04/10] guests: Move ccache configuration to shell profile

2018-04-05 Thread Andrea Bolognani
Now that we have our custom shell profile, making sure ccache
is used is way simpler.

Signed-off-by: Andrea Bolognani 
---
 guests/tasks/users.yml  | 18 --
 guests/templates/bashrc |  2 ++
 2 files changed, 2 insertions(+), 18 deletions(-)

diff --git a/guests/tasks/users.yml b/guests/tasks/users.yml
index 8e59fa9..e691b32 100644
--- a/guests/tasks/users.yml
+++ b/guests/tasks/users.yml
@@ -65,24 +65,6 @@
 owner: '{{ flavor }}'
 group: '{{ flavor }}'
 
-- name: '{{ flavor }}: Enable ccache'
-  lineinfile:
-path: /home/{{ flavor }}/.profile
-line: 'which ccache >/dev/null 2>&1 && export CC="ccache cc"'
-state: present
-owner: '{{ flavor }}'
-group: '{{ flavor }}'
-create: yes
-
-- name: '{{ flavor }}: Enable ccache'
-  lineinfile:
-path: /home/{{ flavor }}/.bashrc
-line: 'which ccache >/dev/null 2>&1 && export CC="ccache cc"'
-state: present
-owner: '{{ flavor }}'
-group: '{{ flavor }}'
-create: yes
-
 - name: '{{ flavor }}: Create shell profile'
   template:
 src: templates/{{ item }}
diff --git a/guests/templates/bashrc b/guests/templates/bashrc
index 6640da6..51d0e64 100644
--- a/guests/templates/bashrc
+++ b/guests/templates/bashrc
@@ -1 +1,3 @@
 export PS1="[\u@\h \w]\$ "
+
+which ccache >/dev/null 2>&1 && export CC="ccache cc"
-- 
2.14.3

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [jenkins-ci PATCH 08/10] guests: Move Perl configuration to shell profile

2018-04-05 Thread Andrea Bolognani
Same as for $VIRT_PREFIX and friends, we want these to be
tracked along with the rest of the CI setup instead of being a
completely opaque, side-loaded blob.

Signed-off-by: Andrea Bolognani 
---
 guests/group_vars/all/main.yml| 1 +
 guests/host_vars/libvirt-centos-6/main.yml| 2 ++
 guests/host_vars/libvirt-centos-7/main.yml| 2 ++
 guests/host_vars/libvirt-debian-8/main.yml| 2 ++
 guests/host_vars/libvirt-debian-9/main.yml| 2 ++
 guests/host_vars/libvirt-debian-sid/main.yml  | 2 ++
 guests/host_vars/libvirt-fedora-26/main.yml   | 2 ++
 guests/host_vars/libvirt-fedora-27/main.yml   | 2 ++
 guests/host_vars/libvirt-fedora-rawhide/main.yml  | 2 ++
 guests/host_vars/libvirt-freebsd-10/main.yml  | 2 ++
 guests/host_vars/libvirt-freebsd-11/main.yml  | 2 ++
 guests/host_vars/libvirt-freebsd-current/main.yml | 2 ++
 guests/host_vars/libvirt-ubuntu-14/main.yml   | 2 ++
 guests/host_vars/libvirt-ubuntu-16/main.yml   | 2 ++
 guests/templates/bashrc   | 1 +
 15 files changed, 28 insertions(+)

diff --git a/guests/group_vars/all/main.yml b/guests/group_vars/all/main.yml
index c5166bc..6456bd5 100644
--- a/guests/group_vars/all/main.yml
+++ b/guests/group_vars/all/main.yml
@@ -17,6 +17,7 @@ LD_LIBRARY_PATH: $VIRT_PREFIX/lib
 PKG_CONFIG_PATH: $VIRT_PREFIX/lib/pkgconfig
 XDG_DATA_DIRS: $VIRT_PREFIX/share:/usr/share:/usr/local/share
 GI_TYPELIB_PATH: $VIRT_PREFIX/lib/girepository-1.0
+PERL5LIB:
 
 bash: /bin/bash
 java: /usr/bin/java
diff --git a/guests/host_vars/libvirt-centos-6/main.yml 
b/guests/host_vars/libvirt-centos-6/main.yml
index f7e383d..2265615 100644
--- a/guests/host_vars/libvirt-centos-6/main.yml
+++ b/guests/host_vars/libvirt-centos-6/main.yml
@@ -1,4 +1,6 @@
 ---
+PERL5LIB: $VIRT_PREFIX/lib64/perl5
+
 projects:
   - libvirt
   - libvirt-cim
diff --git a/guests/host_vars/libvirt-centos-7/main.yml 
b/guests/host_vars/libvirt-centos-7/main.yml
index 155da25..3068bb1 100644
--- a/guests/host_vars/libvirt-centos-7/main.yml
+++ b/guests/host_vars/libvirt-centos-7/main.yml
@@ -1,4 +1,6 @@
 ---
+PERL5LIB: $VIRT_PREFIX/lib64/perl5
+
 projects:
   - libosinfo
   - libvirt
diff --git a/guests/host_vars/libvirt-debian-8/main.yml 
b/guests/host_vars/libvirt-debian-8/main.yml
index 43503ce..76c0076 100644
--- a/guests/host_vars/libvirt-debian-8/main.yml
+++ b/guests/host_vars/libvirt-debian-8/main.yml
@@ -1,4 +1,6 @@
 ---
+PERL5LIB: $VIRT_PREFIX/lib/x86_64-linux-gnu/perl/5.20.2
+
 projects:
   - libosinfo
   - libvirt
diff --git a/guests/host_vars/libvirt-debian-9/main.yml 
b/guests/host_vars/libvirt-debian-9/main.yml
index cde85bd..45bc9de 100644
--- a/guests/host_vars/libvirt-debian-9/main.yml
+++ b/guests/host_vars/libvirt-debian-9/main.yml
@@ -1,4 +1,6 @@
 ---
+PERL5LIB: $VIRT_PREFIX/lib/x86_64-linux-gnu/perl/5.24.1
+
 projects:
   - libosinfo
   - libvirt
diff --git a/guests/host_vars/libvirt-debian-sid/main.yml 
b/guests/host_vars/libvirt-debian-sid/main.yml
index cde85bd..96b49d2 100644
--- a/guests/host_vars/libvirt-debian-sid/main.yml
+++ b/guests/host_vars/libvirt-debian-sid/main.yml
@@ -1,4 +1,6 @@
 ---
+PERL5LIB: $VIRT_PREFIX/lib/x86_64-linux-gnu/perl/5.26.1
+
 projects:
   - libosinfo
   - libvirt
diff --git a/guests/host_vars/libvirt-fedora-26/main.yml 
b/guests/host_vars/libvirt-fedora-26/main.yml
index 1098d8a..b21e829 100644
--- a/guests/host_vars/libvirt-fedora-26/main.yml
+++ b/guests/host_vars/libvirt-fedora-26/main.yml
@@ -1,4 +1,6 @@
 ---
+PERL5LIB: $VIRT_PREFIX/lib64/perl5
+
 projects:
   - libosinfo
   - libvirt
diff --git a/guests/host_vars/libvirt-fedora-27/main.yml 
b/guests/host_vars/libvirt-fedora-27/main.yml
index 1098d8a..b21e829 100644
--- a/guests/host_vars/libvirt-fedora-27/main.yml
+++ b/guests/host_vars/libvirt-fedora-27/main.yml
@@ -1,4 +1,6 @@
 ---
+PERL5LIB: $VIRT_PREFIX/lib64/perl5
+
 projects:
   - libosinfo
   - libvirt
diff --git a/guests/host_vars/libvirt-fedora-rawhide/main.yml 
b/guests/host_vars/libvirt-fedora-rawhide/main.yml
index 1098d8a..b21e829 100644
--- a/guests/host_vars/libvirt-fedora-rawhide/main.yml
+++ b/guests/host_vars/libvirt-fedora-rawhide/main.yml
@@ -1,4 +1,6 @@
 ---
+PERL5LIB: $VIRT_PREFIX/lib64/perl5
+
 projects:
   - libosinfo
   - libvirt
diff --git a/guests/host_vars/libvirt-freebsd-10/main.yml 
b/guests/host_vars/libvirt-freebsd-10/main.yml
index 2f7bced..dc1a018 100644
--- a/guests/host_vars/libvirt-freebsd-10/main.yml
+++ b/guests/host_vars/libvirt-freebsd-10/main.yml
@@ -1,6 +1,8 @@
 ---
 ansible_python_interpreter: /usr/local/bin/python2
 
+PERL5LIB: $VIRT_PREFIX/lib/perl5/site_perl/mach/5.26
+
 bash: /usr/local/bin/bash
 java: /usr/local/bin/java
 make: /usr/local/bin/gmake
diff --git a/guests/host_vars/libvirt-freebsd-11/main.yml 
b/guests/host_vars/libvirt-freebsd-11/main.yml
index 2f7bced..dc1a018 100644
--- a/guests/host_vars/libvirt-freebsd-11/main.yml
+++ b/guests/host_vars/libvirt-freebsd-11/main.yml
@@ -1,6 +1,8 

[libvirt] [jenkins-ci PATCH 02/10] guests: Enable ~/.bashrc on FreeBSD

2018-04-05 Thread Andrea Bolognani
Due to the way bash is compiled on FreeBSD, we need to flip an
extra switch in order to convince it to process the shell profile
even when we're running commands non-interactively through ssh.

Signed-off-by: Andrea Bolognani 
---
 guests/tasks/kludges.yml | 18 ++
 1 file changed, 18 insertions(+)

diff --git a/guests/tasks/kludges.yml b/guests/tasks/kludges.yml
index 001b5c6..0196559 100644
--- a/guests/tasks/kludges.yml
+++ b/guests/tasks/kludges.yml
@@ -29,3 +29,21 @@
   when:
 - os_name == 'FreeBSD'
 - os_version == '11'
+
+# FreeBSD compiles bash without defining SSH_SOURCE_BASHRC, which means
+# it won't try to detect when it's spawned by ssh and source ~/.bashrc
+# when that's the case. Our workaround is setting $BASH_ENV globally
+- name: Enable ~/.bashrc
+  replace:
+path: /etc/login.conf
+regexp: '^(.*):setenv=(BASH_ENV=[^,]*,)?(.*):\\$'
+replace: '\1:setenv=BASH_ENV=~/.bashrc,\3:\\'
+validate: 'cap_mkdb %s'
+  register: loginconf
+  when:
+- os_name == 'FreeBSD'
+
+- name: Enable ~/.bashrc
+  command: cap_mkdb /etc/login.conf
+  when:
+- loginconf.changed
-- 
2.14.3

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [jenkins-ci PATCH 00/10] guests: Improve enviroment handling

2018-04-05 Thread Andrea Bolognani
The basic goal is to move all environment configuration that
affects builds to a single place which is tracked along with all
other changes to the CI environment.

Patch 8/10 also happens to fix build of packages that depend on
libvirt-perl on FreeBSD now that they've switched to Perl 5.26,
though we haven't run into this specific problem yet due to other
issues in the CI enviroment ;)

Andrea Bolognani (10):
  guests: Rename compat -> kludges
  guests: Enable ~/.bashrc on FreeBSD
  guests: Add custom shell profile
  guests: Move ccache configuration to shell profile
  guests: Move make configuration to shell profile
  guests: Move $PATH configuration to shell profile
  guests: Add more enviroment variables to shell profile
  guests: Move Perl configuration to shell profile
  guests: Add Python configuration to shell profile
  guests: Remove per-host make variable

 guests/group_vars/all/main.yml| 15 ++---
 guests/host_vars/libvirt-centos-6/main.yml|  3 +++
 guests/host_vars/libvirt-centos-7/main.yml|  3 +++
 guests/host_vars/libvirt-debian-8/main.yml|  3 +++
 guests/host_vars/libvirt-debian-9/main.yml|  3 +++
 guests/host_vars/libvirt-debian-sid/main.yml  |  3 +++
 guests/host_vars/libvirt-fedora-26/main.yml   |  3 +++
 guests/host_vars/libvirt-fedora-27/main.yml   |  3 +++
 guests/host_vars/libvirt-fedora-rawhide/main.yml  |  3 +++
 guests/host_vars/libvirt-freebsd-10/main.yml  |  4 +++-
 guests/host_vars/libvirt-freebsd-11/main.yml  |  4 +++-
 guests/host_vars/libvirt-freebsd-current/main.yml |  4 +++-
 guests/host_vars/libvirt-ubuntu-14/main.yml   |  3 +++
 guests/host_vars/libvirt-ubuntu-16/main.yml   |  3 +++
 guests/site.yml   |  2 +-
 guests/tasks/{compat.yml => kludges.yml}  | 18 +++
 guests/tasks/users.yml| 27 +++
 guests/templates/bash_profile |  1 +
 guests/templates/bashrc   | 15 +
 jobs/defaults.yaml|  6 -
 20 files changed, 99 insertions(+), 27 deletions(-)
 rename guests/tasks/{compat.yml => kludges.yml} (59%)
 create mode 100644 guests/templates/bash_profile
 create mode 100644 guests/templates/bashrc

-- 
2.14.3

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [jenkins-ci PATCH 01/10] guests: Rename compat -> kludges

2018-04-05 Thread Andrea Bolognani
This task only contains workarounds that we shouldn't have to
worry about to begin with, and that hopefully in due time we'll
be able to drop entirely. Rename it to make this more apparent.

Signed-off-by: Andrea Bolognani 
---
 guests/site.yml  | 2 +-
 guests/tasks/{compat.yml => kludges.yml} | 0
 2 files changed, 1 insertion(+), 1 deletion(-)
 rename guests/tasks/{compat.yml => kludges.yml} (100%)

diff --git a/guests/site.yml b/guests/site.yml
index 869291d..26127be 100644
--- a/guests/site.yml
+++ b/guests/site.yml
@@ -32,7 +32,7 @@
 # Configure environment. Needs to happen after installing base packages
 - include: tasks/bootloader.yml
 - include: tasks/services.yml
-- include: tasks/compat.yml
+- include: tasks/kludges.yml
 - include: tasks/users.yml
 
 # Install build dependencies for each project
diff --git a/guests/tasks/compat.yml b/guests/tasks/kludges.yml
similarity index 100%
rename from guests/tasks/compat.yml
rename to guests/tasks/kludges.yml
-- 
2.14.3

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] Libvirt master compilation failed

2018-04-05 Thread Pino Toscano
Hi,

On Thursday, 5 April 2018 13:54:17 CEST Mathieu Tarral wrote:
> [...]
> make[3]: Entering directory '/var/ansible/libvirt/po'
> rm -f af.gmo && : -c --statistics -o af.gmo af.po
> mv: cannot stat 't-af.gmo': No such file or directory
> Makefile:470: recipe for target 'af.gmo' failed
> make[3]: *** [af.gmo] Error 1
> make[3]: Leaving directory '/var/ansible/libvirt/po'
> Makefile:507: recipe for target 'stamp-po' failed
> make[2]: *** [stamp-po] Error 2
> make[2]: Leaving directory '/var/ansible/libvirt/po'
> Makefile:2121: recipe for target 'all-recursive' failed
> make[1]: *** [all-recursive] Error 1
> make[1]: Leaving directory '/var/ansible/libvirt'
> Makefile:2014: recipe for target 'all' failed
> make: *** [all] Error 2
> 
> 
> I'm on Debian stretch, i installed every dependency required by the
> configure script.
> Any ideas what's wrong here ?

Forgot to install 'gettext', maybe.

-- 
Pino Toscano

signature.asc
Description: This is a digitally signed message part.
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

[libvirt] Libvirt master compilation failed

2018-04-05 Thread Mathieu Tarral
Hello,

i have been trying to compile the latest libvirt from the Github mirror.

I checked out on this commit: 3487973ee0c730b6fbfc6183af798c46ae3b85ff
virjsontest: Use a more stable floating point number for testing

But the compilation failed with this error:

  CC   ssh.o
  CCLD ssh
  CC   qemucapsprobe.o
  CCLD qemucapsprobe
  CC   nsslinktest-nsslinktest.o
  CCLD nsslinktest
  CC   nssguestlinktest-nsslinktest.o
  CCLD nssguestlinktest
make[2]: Leaving directory '/var/ansible/libvirt/tests'
Making all in po
make[2]: Entering directory '/var/ansible/libvirt/po'
test ! -f ./libvirt.pot || \
  test -z "af.gmo am.gmo anp.gmo ar.gmo as.gmo ast.gmo bal.gmo be.gmo
bg.gmo bn.gmo bn_IN.gmo bo.gmo br.gmo brx.gmo bs.gmo ca.gmo cs.gmo
cy.gmo da.gmo de.gmo de_CH.gmo el.gmo en_GB.gmo eo.gmo es.gmo et.gmo
eu.gmo fa.gmo fi.gmo fr.gmo gl.gmo gu.gmo he.gmo hi.gmo hr.gmo hu.gmo
ia.gmo id.gmo ilo.gmo is.gmo it.gmo ja.gmo ka.gmo kk.gmo km.gmo kn.gmo
ko.gmo kw.gmo k...@kkcor.gmo k...@uccor.gmo kw_GB.gmo ky.gmo lt.gmo lv.gmo
mai.gmo mk.gmo ml.gmo mn.gmo mr.gmo ms.gmo nb.gmo nds.gmo ne.gmo
nl.gmo nn.gmo nso.gmo or.gmo pa.gmo pl.gmo pt.gmo pt_BR.gmo ro.gmo
ru.gmo si.gmo sk.gmo sl.gmo sq.gmo sr.gmo s...@latin.gmo sv.gmo ta.gmo
te.gmo tg.gmo th.gmo tr.gmo tw.gmo uk.gmo ur.gmo vi.gmo wba.gmo yo.gmo
zh_CN.gmo zh_HK.gmo zh_TW.gmo zu.gmo" || make af.gmo am.gmo anp.gmo
ar.gmo as.gmo ast.gmo bal.gmo be.gmo bg.gmo bn.gmo bn_IN.gmo bo.gmo
br.gmo brx.gmo bs.gmo ca.gmo cs.gmo cy.gmo da.gmo de.gmo de_CH.gmo
el.gmo en_GB.gmo eo.gmo es.gmo et.gmo eu.gmo fa.gmo fi.gmo fr.gmo
gl.gmo gu.gmo he.gmo hi.gmo hr.gmo hu.gmo ia.gmo id.gmo ilo.gmo is.gmo
it.gmo ja.gmo ka.gmo kk.gmo km.gmo kn.gmo ko.gmo kw.gmo k...@kkcor.gmo
k...@uccor.gmo kw_GB.gmo ky.gmo lt.gmo lv.gmo mai.gmo mk.gmo ml.gmo
mn.gmo mr.gmo ms.gmo nb.gmo nds.gmo ne.gmo nl.gmo nn.gmo nso.gmo
or.gmo pa.gmo pl.gmo pt.gmo pt_BR.gmo ro.gmo ru.gmo si.gmo sk.gmo
sl.gmo sq.gmo sr.gmo s...@latin.gmo sv.gmo ta.gmo te.gmo tg.gmo th.gmo
tr.gmo tw.gmo uk.gmo ur.gmo vi.gmo wba.gmo yo.gmo zh_CN.gmo zh_HK.gmo
zh_TW.gmo zu.gmo
make[3]: Entering directory '/var/ansible/libvirt/po'
rm -f af.gmo && : -c --statistics -o af.gmo af.po
mv: cannot stat 't-af.gmo': No such file or directory
Makefile:470: recipe for target 'af.gmo' failed
make[3]: *** [af.gmo] Error 1
make[3]: Leaving directory '/var/ansible/libvirt/po'
Makefile:507: recipe for target 'stamp-po' failed
make[2]: *** [stamp-po] Error 2
make[2]: Leaving directory '/var/ansible/libvirt/po'
Makefile:2121: recipe for target 'all-recursive' failed
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory '/var/ansible/libvirt'
Makefile:2014: recipe for target 'all' failed
make: *** [all] Error 2


I'm on Debian stretch, i installed every dependency required by the
configure script.
Any ideas what's wrong here ?


Thanks.


-- 
Mathieu Tarral

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] [PATCH v2] docs: add page describing goals for host platform version support

2018-04-05 Thread John Ferlan


On 04/05/2018 06:05 AM, Daniel P. Berrangé wrote:
> Described how we decide which host platforms to support for libvirt,
> which in turn makes it easier to decide when a platform / software
> version can be dropped.
> 
> Signed-off-by: Daniel P. Berrangé 
> ---
>  docs/index.html.in |   2 +-
>  docs/platforms.html.in | 105 
> +
>  2 files changed, 106 insertions(+), 1 deletion(-)
>  create mode 100644 docs/platforms.html.in
> 
> diff --git a/docs/index.html.in b/docs/index.html.in
> index 1b3a7a3db6..4783c39e3c 100644
> --- a/docs/index.html.in
> +++ b/docs/index.html.in
> @@ -28,7 +28,7 @@
>  The libvirt project:
>
>
> -is a toolkit to manage virtualization hosts
> +is a toolkit to manage  href="platforms.html.in">virtualization platforms
>  is accessible from C, Python, Perl, Java and more
>  is licensed under open source licenses
>  supports KVM,
> diff --git a/docs/platforms.html.in b/docs/platforms.html.in
> new file mode 100644
> index 00..776e930e78
> --- /dev/null
> +++ b/docs/platforms.html.in
> @@ -0,0 +1,105 @@
> +
> +
> +http://www.w3.org/1999/xhtml;>
> +  
> +Supported host platforms
> +
> +
> +
> +Build targets
> +
> +
> +  Libvirt drivers aim to support building and executing on multiple
> +  host OS platforms. This document outlines which platforms are the
> +  major build targets. These platforms are used as the basis for deciding
> +  upon the minimum required versions of 3rd party software libvirt 
> depends
> +  on. If a platform is not listed here, it does not imply that libvirt
> +  won't work. If an unlisted platform has comparable software versions
> +  to a listed platform, there is every expectation that it will work.
> +  Bug reports are welcome for problems encountered on unlisted platforms
> +  unless they are clearly older vintage that what is described here.

s/that/than/

> +
> +
> +
> +  Note that when considering software versions shipped in distros as
> +  support targets, libvirt considers only the version number, and assumes
> +  the features in that distro match the upstream release with the same
> +  version. IOW, if a distro backports extra features to the software in
> +  their distro, libvirt upstream code will not add explicit support for
> +  those backports, unless the feature is auto-detectable in a manner that
> +  works for the upstream releases too.
> +
> +
> +
> +  The Repology site is a useful resource to identify currently shipped
> +  versions of software in various operating systems, though it does not
> +  cover all distros listed below.
> +
> +
> +
> +   href="https://repology.org/metapackage/libvirt/versions;>libvirt
> +   href="https://repology.org/metapackage/qemu/versions;>qemu
> +
> +
> +
> +Linux OS
> +
> +
> +  For distributions with frequent, short-lifetime releases, the project
> +  will aim to support all versions that are not end of life by their
> +  respective vendors. For the purposes of identifying supported software
> +  versions, the project will look at Fedora, Ubuntu  OpenSUSE 
> distros.

s/Ubuntu /Ubuntu, /

e.g. a, b, & c

> +  Other short-lifetime distros will be assumed to ship similar software
> +  versions.
> +
> +
> +
> +  For distributions with long-lifetime releases, the project will aim to
> +  support the most recent major version at all times. Support for the
> +  previous major version will be dropped 2 years after the new major
> +  version is released. For the purposes of identifying supported software
> +  versions, the project will look at RHEL, Debian, Ubuntu LTS  SLES

Likewise, s/LTS/LTS,/

Reviewed-by: John Ferlan 

John

> +  distros. Other long-lifetime distros will be assumed to ship similar
> +  software versions.
> +
> +
> +Windows
> +
> +
> +  The project supports building with current versions of the MinGW
> +  toolchain, hosted on Linux.
> +
> +
> +macOS
> +
> +
> +  The project supports building with the current version of macOS,
> +  with the current homebrew package set available.
> +
> +
> +FreeBSD
> +
> +
> +  The project aims to support the most recent major version
> +  at all times. Support for the previous major version will
> +  be dropped 2 years after the new major version is released.
> +
> +
> +Virtualization platforms
> +
> +
> +  For hypervisor drivers which execute
> +  locally (QEMU, LXC, VZ, libxl, etc), the set of supported operating
> +  system platforms listed above will inform choices as to the minimum
> +  required versions of 3rd party libraries and hypervisor management
> +  APIs.
> +
> +
> +  If a hypervisor is 

Re: [libvirt] [PATCH v2 0/8] Prepare for daemon split

2018-04-05 Thread John Ferlan


On 04/05/2018 06:51 AM, Daniel P. Berrangé wrote:
> When we split up the daemons, libvirtd will need to forward different
> sets of APIs to different daemons. This means libvirtd is going to need
> to have multiple virConnectPtr instances open.
> 
> This series prepares for that by introducing "separate" connections,
> which are actually just an extra reference on the current single
> connection. This will facilitate later changes.
> 
> Daniel P. Berrangé (8):
>   rpc: refactor way connection object is generated for remote dispatch
>   remote: push check for conn down into remoteClientFreePrivateCallbacks
>   remote: use a separate connection for interface APIs
>   remote: use a separate connection for network APIs
>   remote: use a separate connection for nodedev APIs
>   remote: use a separate connection for nwfilter APIs
>   remote: use a separate connection for secret APIs
>   remote: use a separate connection for storage APIs
> 
>  src/remote/remote_daemon.h  |   6 +++
>  src/remote/remote_daemon_dispatch.c |  94 +++-
>  src/rpc/gendispatch.pl  | 104 
> +---
>  3 files changed, 138 insertions(+), 66 deletions(-)
> 

Reviewed-by: John Ferlan 

(series)

John

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Re: [libvirt] [PATCH v2] docs: add page describing goals for host platform version support

2018-04-05 Thread Daniel P . Berrangé
On Thu, Apr 05, 2018 at 12:56:57PM +0200, Pavel Hrdina wrote:
> On Thu, Apr 05, 2018 at 11:05:04AM +0100, Daniel P. Berrangé wrote:
> > Described how we decide which host platforms to support for libvirt,
> > which in turn makes it easier to decide when a platform / software
> > version can be dropped.
> > 
> > Signed-off-by: Daniel P. Berrangé 
> > ---
> >  docs/index.html.in |   2 +-
> >  docs/platforms.html.in | 105 
> > +
> >  2 files changed, 106 insertions(+), 1 deletion(-)
> >  create mode 100644 docs/platforms.html.in
> > 
> > diff --git a/docs/index.html.in b/docs/index.html.in
> > index 1b3a7a3db6..4783c39e3c 100644
> > --- a/docs/index.html.in
> > +++ b/docs/index.html.in
> > @@ -28,7 +28,7 @@
> >  The libvirt project:
> >
> >
> > -is a toolkit to manage virtualization hosts
> > +is a toolkit to manage  > href="platforms.html.in">virtualization platforms
> >  is accessible from C, Python, Perl, Java and more
> >  is licensed under open source licenses
> >  supports KVM,
> > diff --git a/docs/platforms.html.in b/docs/platforms.html.in
> > new file mode 100644
> > index 00..776e930e78
> > --- /dev/null
> > +++ b/docs/platforms.html.in
> > @@ -0,0 +1,105 @@
> > +
> > +
> > +http://www.w3.org/1999/xhtml;>
> > +  
> > +Supported host platforms
> > +
> > +
> > +
> > +Build targets
> > +
> > +
> > +  Libvirt drivers aim to support building and executing on multiple
> > +  host OS platforms. This document outlines which platforms are the
> > +  major build targets. These platforms are used as the basis for 
> > deciding
> > +  upon the minimum required versions of 3rd party software libvirt 
> > depends
> > +  on. If a platform is not listed here, it does not imply that libvirt
> > +  won't work. If an unlisted platform has comparable software versions
> > +  to a listed platform, there is every expectation that it will work.
> > +  Bug reports are welcome for problems encountered on unlisted 
> > platforms
> > +  unless they are clearly older vintage that what is described here.
> > +
> > +
> > +
> > +  Note that when considering software versions shipped in distros as
> > +  support targets, libvirt considers only the version number, and 
> > assumes
> > +  the features in that distro match the upstream release with the same
> > +  version. IOW, if a distro backports extra features to the software in
> > +  their distro, libvirt upstream code will not add explicit support for
> > +  those backports, unless the feature is auto-detectable in a manner 
> > that
> > +  works for the upstream releases too.
> > +
> > +
> > +
> > +  The Repology site is a useful resource to identify currently shipped
> > +  versions of software in various operating systems, though it does not
> > +  cover all distros listed below.
> > +
> > +
> > +
> > +   > href="https://repology.org/metapackage/libvirt/versions;>libvirt
> > +   > href="https://repology.org/metapackage/qemu/versions;>qemu
> 
> Maybe we should also list the "qemu-kvm" package since RHEL/CentOS uses
> that name.

Oh yes, it never occurred to me to check if that name existed. Will add
it.

> Reviewed-by: Pavel Hrdina 



Regards,
Daniel
-- 
|: https://berrange.com  -o-https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org -o-https://fstop138.berrange.com :|
|: https://entangle-photo.org-o-https://www.instagram.com/dberrange :|

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Re: [libvirt] [dbus PATCH v3 0/4] Introduce Network Interface

2018-04-05 Thread Katerina Koukiou
On Thu, 2018-04-05 at 12:51 +0200, Pavel Hrdina wrote:
> On Thu, Apr 05, 2018 at 12:40:16PM +0200, Katerina Koukiou wrote:
> > This patchset introduces also some basic methods and properties for
> > Network interface.
> > More functionality will be added in following patchsets.
> > New functions are covered by the test suite.
> > 
> > Changes from v2:
> > * Added test_list_networks test.
> > * xml files should group methods/signals/properties together.
> > * Some other minor fixes.
> > 
> > Katerina Koukiou (4):
> >   Introduce Network Interface
> >   Implement ListNetworks method for Connect interface
> >   Implement Name property for Network interface
> >   Implement NetworkLookupByName method for Connect interface
> 
> With the indentation fixed

Fixed and pushed.
Thanks for review.

> 
> Reviewed-by: Pavel Hrdina 

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] [PATCH v2] docs: add page describing goals for host platform version support

2018-04-05 Thread Pavel Hrdina
On Thu, Apr 05, 2018 at 11:05:04AM +0100, Daniel P. Berrangé wrote:
> Described how we decide which host platforms to support for libvirt,
> which in turn makes it easier to decide when a platform / software
> version can be dropped.
> 
> Signed-off-by: Daniel P. Berrangé 
> ---
>  docs/index.html.in |   2 +-
>  docs/platforms.html.in | 105 
> +
>  2 files changed, 106 insertions(+), 1 deletion(-)
>  create mode 100644 docs/platforms.html.in
> 
> diff --git a/docs/index.html.in b/docs/index.html.in
> index 1b3a7a3db6..4783c39e3c 100644
> --- a/docs/index.html.in
> +++ b/docs/index.html.in
> @@ -28,7 +28,7 @@
>  The libvirt project:
>
>
> -is a toolkit to manage virtualization hosts
> +is a toolkit to manage  href="platforms.html.in">virtualization platforms
>  is accessible from C, Python, Perl, Java and more
>  is licensed under open source licenses
>  supports KVM,
> diff --git a/docs/platforms.html.in b/docs/platforms.html.in
> new file mode 100644
> index 00..776e930e78
> --- /dev/null
> +++ b/docs/platforms.html.in
> @@ -0,0 +1,105 @@
> +
> +
> +http://www.w3.org/1999/xhtml;>
> +  
> +Supported host platforms
> +
> +
> +
> +Build targets
> +
> +
> +  Libvirt drivers aim to support building and executing on multiple
> +  host OS platforms. This document outlines which platforms are the
> +  major build targets. These platforms are used as the basis for deciding
> +  upon the minimum required versions of 3rd party software libvirt 
> depends
> +  on. If a platform is not listed here, it does not imply that libvirt
> +  won't work. If an unlisted platform has comparable software versions
> +  to a listed platform, there is every expectation that it will work.
> +  Bug reports are welcome for problems encountered on unlisted platforms
> +  unless they are clearly older vintage that what is described here.
> +
> +
> +
> +  Note that when considering software versions shipped in distros as
> +  support targets, libvirt considers only the version number, and assumes
> +  the features in that distro match the upstream release with the same
> +  version. IOW, if a distro backports extra features to the software in
> +  their distro, libvirt upstream code will not add explicit support for
> +  those backports, unless the feature is auto-detectable in a manner that
> +  works for the upstream releases too.
> +
> +
> +
> +  The Repology site is a useful resource to identify currently shipped
> +  versions of software in various operating systems, though it does not
> +  cover all distros listed below.
> +
> +
> +
> +   href="https://repology.org/metapackage/libvirt/versions;>libvirt
> +   href="https://repology.org/metapackage/qemu/versions;>qemu

Maybe we should also list the "qemu-kvm" package since RHEL/CentOS uses
that name.

Reviewed-by: Pavel Hrdina 


signature.asc
Description: PGP signature
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

[libvirt] [PATCH v2 4/8] remote: use a separate connection for network APIs

2018-04-05 Thread Daniel P . Berrangé
Reviewed-by: John Ferlan 
Signed-off-by: Daniel P. Berrangé 
---
 src/remote/remote_daemon.h  |  1 +
 src/remote/remote_daemon_dispatch.c | 19 +++
 src/rpc/gendispatch.pl  |  6 ++
 3 files changed, 18 insertions(+), 8 deletions(-)

diff --git a/src/remote/remote_daemon.h b/src/remote/remote_daemon.h
index 31f433c15d..60be78fe0b 100644
--- a/src/remote/remote_daemon.h
+++ b/src/remote/remote_daemon.h
@@ -75,6 +75,7 @@ struct daemonClientPrivate {
  */
 virConnectPtr conn;
 virConnectPtr interfaceConn;
+virConnectPtr networkConn;
 
 daemonClientStreamPtr streams;
 };
diff --git a/src/remote/remote_daemon_dispatch.c 
b/src/remote/remote_daemon_dispatch.c
index 34c140e613..bc26bccf65 100644
--- a/src/remote/remote_daemon_dispatch.c
+++ b/src/remote/remote_daemon_dispatch.c
@@ -1704,7 +1704,7 @@ remoteClientFreePrivateCallbacks(struct 
daemonClientPrivate *priv)
 DEREG_CB(priv->conn, priv->domainEventCallbacks,
  priv->ndomainEventCallbacks,
  virConnectDomainEventDeregisterAny, "domain");
-DEREG_CB(priv->conn, priv->networkEventCallbacks,
+DEREG_CB(priv->networkConn, priv->networkEventCallbacks,
  priv->nnetworkEventCallbacks,
  virConnectNetworkEventDeregisterAny, "network");
 DEREG_CB(priv->conn, priv->storageEventCallbacks,
@@ -1747,6 +1747,8 @@ void remoteClientFree(void *data)
 virConnectClose(priv->conn);
 if (priv->interfaceConn)
 virConnectClose(priv->interfaceConn);
+if (priv->networkConn)
+virConnectClose(priv->networkConn);
 
 VIR_FREE(priv);
 }
@@ -1820,6 +1822,7 @@ remoteDispatchConnectOpen(virNetServerPtr server 
ATTRIBUTE_UNUSED,
 goto cleanup;
 
 priv->interfaceConn = virObjectRef(priv->conn);
+priv->networkConn = virObjectRef(priv->conn);
 
 /* force update the @readonly attribute which was inherited from the
  * virNetServerService object - this is important for sockets that are RW
@@ -5716,7 +5719,7 @@ 
remoteDispatchConnectNetworkEventRegisterAny(virNetServerPtr server ATTRIBUTE_UN
 virNetServerClientGetPrivateData(client);
 virNetworkPtr net = NULL;
 
-if (!priv->conn) {
+if (!priv->networkConn) {
 virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
 goto cleanup;
 }
@@ -5724,7 +5727,7 @@ 
remoteDispatchConnectNetworkEventRegisterAny(virNetServerPtr server ATTRIBUTE_UN
 virMutexLock(>lock);
 
 if (args->net &&
-!(net = get_nonnull_network(priv->conn, *args->net)))
+!(net = get_nonnull_network(priv->networkConn, *args->net)))
 goto cleanup;
 
 if (args->eventID >= VIR_NETWORK_EVENT_ID_LAST || args->eventID < 0) {
@@ -5750,7 +5753,7 @@ 
remoteDispatchConnectNetworkEventRegisterAny(virNetServerPtr server ATTRIBUTE_UN
callback) < 0)
 goto cleanup;
 
-if ((callbackID = virConnectNetworkEventRegisterAny(priv->conn,
+if ((callbackID = virConnectNetworkEventRegisterAny(priv->networkConn,
 net,
 args->eventID,
 
networkEventCallbacks[args->eventID],
@@ -5789,7 +5792,7 @@ 
remoteDispatchConnectNetworkEventDeregisterAny(virNetServerPtr server ATTRIBUTE_
 struct daemonClientPrivate *priv =
 virNetServerClientGetPrivateData(client);
 
-if (!priv->conn) {
+if (!priv->networkConn) {
 virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
 goto cleanup;
 }
@@ -5807,7 +5810,7 @@ 
remoteDispatchConnectNetworkEventDeregisterAny(virNetServerPtr server ATTRIBUTE_
 goto cleanup;
 }
 
-if (virConnectNetworkEventDeregisterAny(priv->conn, args->callbackID) < 0)
+if (virConnectNetworkEventDeregisterAny(priv->networkConn, 
args->callbackID) < 0)
 goto cleanup;
 
 VIR_DELETE_ELEMENT(priv->networkEventCallbacks, i,
@@ -6470,12 +6473,12 @@ remoteDispatchNetworkGetDHCPLeases(virNetServerPtr 
server ATTRIBUTE_UNUSED,
 virNetworkPtr net = NULL;
 int nleases = 0;
 
-if (!priv->conn) {
+if (!priv->networkConn) {
 virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
 goto cleanup;
 }
 
-if (!(net = get_nonnull_network(priv->conn, args->net)))
+if (!(net = get_nonnull_network(priv->networkConn, args->net)))
 goto cleanup;
 
 if ((nleases = virNetworkGetDHCPLeases(net,
diff --git a/src/rpc/gendispatch.pl b/src/rpc/gendispatch.pl
index 88fcd46c45..51faa899c6 100755
--- a/src/rpc/gendispatch.pl
+++ b/src/rpc/gendispatch.pl
@@ -128,6 +128,9 @@ sub get_conn_arg {
 if ($type =~ /remote_nonnull_interface/) {
 return "priv->interfaceConn";
 }
+if ($type =~ /remote_nonnull_network/) {
+return 

Re: [libvirt] [PATCH v4 3/3] news: Document device mapper fix

2018-04-05 Thread Peter Krempa
On Thu, Apr 05, 2018 at 10:09:41 +0200, Michal Privoznik wrote:
> Signed-off-by: Michal Privoznik 
> ---
>  docs/news.xml | 12 
>  1 file changed, 12 insertions(+)

ACK


signature.asc
Description: PGP signature
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

[libvirt] [PATCH v2 1/8] rpc: refactor way connection object is generated for remote dispatch

2018-04-05 Thread Daniel P . Berrangé
Calling a push_privconn method to directly push the connection object
name into the arg list is inconvenient. Refactor so that we acquire
the connection variable name upfront, and push it to the arg list
separately. This allows various hardcoded usage of "priv->conn" to
be parameterized.

Reviewed-by: John Ferlan 
Signed-off-by: Daniel P. Berrangé 
---
 src/rpc/gendispatch.pl | 57 +-
 1 file changed, 24 insertions(+), 33 deletions(-)

diff --git a/src/rpc/gendispatch.pl b/src/rpc/gendispatch.pl
index fb15cc4849..d5e61f5bb8 100755
--- a/src/rpc/gendispatch.pl
+++ b/src/rpc/gendispatch.pl
@@ -110,19 +110,13 @@ sub name_to_TypeName {
 return $typename;
 }
 
-sub push_privconn {
-my $args = shift;
-
-if (!@$args) {
-if ($structprefix eq "admin") {
-push(@$args, "priv->dmn");
-} else {
-push(@$args, "priv->conn");
-}
+sub get_conn_arg {
+if ($structprefix eq "admin") {
+return "priv->dmn";
 }
+return "priv->conn";
 }
 
-
 # Read the input file (usually remote_protocol.x) and form an
 # opinion about the name, args and return type of each RPC.
 my ($name, $ProcName, $id, $flags, %calls, @calls, %opts);
@@ -487,6 +481,8 @@ elsif ($mode eq "server") {
 my @free_list = ();
 my @free_list_on_error = ("virNetMessageSaveError(rerr);");
 
+my $conn = get_conn_arg();
+
 # handle arguments to the function
 if ($argtype ne "void") {
 # node device is special, as it's identified by name
@@ -497,7 +493,7 @@ elsif ($mode eq "server") {
 $has_node_device = 1;
 push(@vars_list, "virNodeDevicePtr dev = NULL");
 push(@getters_list,
- "if (!(dev = virNodeDeviceLookupByName(priv->conn, 
args->name)))\n" .
+ "if (!(dev = virNodeDeviceLookupByName($conn, 
args->name)))\n" .
  "goto cleanup;\n");
 push(@args_list, "dev");
 push(@free_list,
@@ -513,7 +509,7 @@ elsif ($mode eq "server") {
 
 push(@vars_list, "vir${type_name}Ptr $2 = NULL");
 push(@getters_list,
- "if (!($2 = get_nonnull_$1(priv->conn, 
args->$2)))\n" .
+ "if (!($2 = get_nonnull_$1($conn, args->$2)))\n" .
  "goto cleanup;\n");
 push(@args_list, "$2");
 push(@free_list,
@@ -522,7 +518,7 @@ elsif ($mode eq "server") {
 push(@vars_list, "virDomainPtr dom = NULL");
 push(@vars_list, "virDomainSnapshotPtr snapshot = NULL");
 push(@getters_list,
- "if (!(dom = get_nonnull_domain(priv->conn, 
args->${1}.dom)))\n" .
+ "if (!(dom = get_nonnull_domain($conn, 
args->${1}.dom)))\n" .
  "goto cleanup;\n" .
  "\n" .
  "if (!(snapshot = 
get_nonnull_domain_snapshot(dom, args->${1})))\n" .
@@ -532,11 +528,11 @@ elsif ($mode eq "server") {
  "virObjectUnref(snapshot);\n" .
  "virObjectUnref(dom);");
 } elsif ($args_member =~ 
m/^(?:(?:admin|remote)_string|remote_uuid) (\S+)<\S+>;/) {
-push_privconn(\@args_list);
+push(@args_list, $conn) if !@args_list;
 push(@args_list, "args->$1.$1_val");
 push(@args_list, "args->$1.$1_len");
 } elsif ($args_member =~ 
m/^(?:opaque|(?:admin|remote)_nonnull_string) (\S+)<\S+>;(.*)$/) {
-push_privconn(\@args_list);
+push(@args_list, $conn) if !@args_list;
 
 my $cast = "";
 my $arg_name = $1;
@@ -553,7 +549,7 @@ elsif ($mode eq "server") {
 push(@args_list, "${cast}args->$arg_name.${arg_name}_val");
 push(@args_list, "args->$arg_name.${arg_name}_len");
 } elsif ($args_member =~ m/^(?:unsigned )?int (\S+)<\S+>;/) {
-push_privconn(\@args_list);
+push(@args_list, $conn) if !@args_list;
 
 push(@args_list, "args->$1.$1_val");
 push(@args_list, "args->$1.$1_len");
@@ -561,7 +557,7 @@ elsif ($mode eq "server") {
 push(@vars_list, "virTypedParameterPtr $1 = NULL");
 push(@vars_list, "int n$1 = 0");
 if ($call->{ProcName} eq "NodeSetMemoryParameters") {
-push(@args_list, "priv->conn");
+push(@args_list, "$conn");
 }
 push(@args_list, "$1");
 push(@args_list, "n$1");
@@ -576,25 +572,25 @@ 

[libvirt] [PATCH v2 3/8] remote: use a separate connection for interface APIs

2018-04-05 Thread Daniel P . Berrangé
Reviewed-by: John Ferlan 
Signed-off-by: Daniel P. Berrangé 
---
 src/remote/remote_daemon.h  |  1 +
 src/remote/remote_daemon_dispatch.c |  4 
 src/rpc/gendispatch.pl  | 25 -
 3 files changed, 29 insertions(+), 1 deletion(-)

diff --git a/src/remote/remote_daemon.h b/src/remote/remote_daemon.h
index 4467f71da9..31f433c15d 100644
--- a/src/remote/remote_daemon.h
+++ b/src/remote/remote_daemon.h
@@ -74,6 +74,7 @@ struct daemonClientPrivate {
  * called, it will be set back to NULL if that succeeds.
  */
 virConnectPtr conn;
+virConnectPtr interfaceConn;
 
 daemonClientStreamPtr streams;
 };
diff --git a/src/remote/remote_daemon_dispatch.c 
b/src/remote/remote_daemon_dispatch.c
index 853e63901b..34c140e613 100644
--- a/src/remote/remote_daemon_dispatch.c
+++ b/src/remote/remote_daemon_dispatch.c
@@ -1745,6 +1745,8 @@ void remoteClientFree(void *data)
 
 if (priv->conn)
 virConnectClose(priv->conn);
+if (priv->interfaceConn)
+virConnectClose(priv->interfaceConn);
 
 VIR_FREE(priv);
 }
@@ -1817,6 +1819,8 @@ remoteDispatchConnectOpen(virNetServerPtr server 
ATTRIBUTE_UNUSED,
 if (priv->conn == NULL)
 goto cleanup;
 
+priv->interfaceConn = virObjectRef(priv->conn);
+
 /* force update the @readonly attribute which was inherited from the
  * virNetServerService object - this is important for sockets that are RW
  * by default, but do accept RO flags, e.g. TCP
diff --git a/src/rpc/gendispatch.pl b/src/rpc/gendispatch.pl
index d5e61f5bb8..88fcd46c45 100755
--- a/src/rpc/gendispatch.pl
+++ b/src/rpc/gendispatch.pl
@@ -111,9 +111,32 @@ sub name_to_TypeName {
 }
 
 sub get_conn_arg {
+my $proc = shift;
+my $args = shift;
+my $rets = shift;
+
 if ($structprefix eq "admin") {
 return "priv->dmn";
 }
+
+my @types;
+push @types, @{$args} if $args;
+push @types, @{$rets} if $rets;
+
+# This correctly detects most APIs
+foreach my $type (@types) {
+if ($type =~ /remote_nonnull_interface/) {
+return "priv->interfaceConn";
+}
+}
+
+# This is for the few virConnect APIs that
+# return things which aren't objects. eg list
+# of pool names, or number of pools.
+if ($proc =~ /Connect.*Interface/ || $proc =~ /InterfaceChange/) {
+return "priv->interfaceConn";
+}
+
 return "priv->conn";
 }
 
@@ -481,7 +504,7 @@ elsif ($mode eq "server") {
 my @free_list = ();
 my @free_list_on_error = ("virNetMessageSaveError(rerr);");
 
-my $conn = get_conn_arg();
+my $conn = get_conn_arg($call->{ProcName}, $call->{args_members}, 
$call->{ret_members});
 
 # handle arguments to the function
 if ($argtype ne "void") {
-- 
2.14.3

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

[libvirt] [PATCH v2 2/8] remote: push check for conn down into remoteClientFreePrivateCallbacks

2018-04-05 Thread Daniel P . Berrangé
There will shortly be many connection objects, so we should not assume a
single check against priv->conn is sufficient.

Signed-off-by: Daniel P. Berrangé 
---
 src/remote/remote_daemon_dispatch.c | 11 +++
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/src/remote/remote_daemon_dispatch.c 
b/src/remote/remote_daemon_dispatch.c
index 121d114ae3..853e63901b 100644
--- a/src/remote/remote_daemon_dispatch.c
+++ b/src/remote/remote_daemon_dispatch.c
@@ -1673,6 +1673,11 @@ void remoteRelayConnectionClosedEvent(virConnectPtr conn 
ATTRIBUTE_UNUSED, int r
 #define DEREG_CB(conn, eventCallbacks, neventCallbacks, deregFcn, name) \
 do { \
 size_t i; \
+if (neventCallbacks && !conn) { \
+VIR_WARN("Have %zu %s event callbacks but no connection", \
+ neventCallbacks, name); \
+break; \
+} \
 for (i = 0; i < neventCallbacks; i++) { \
 int callbackID = eventCallbacks[i]->callbackID; \
 if (callbackID < 0) { \
@@ -1715,7 +1720,7 @@ remoteClientFreePrivateCallbacks(struct 
daemonClientPrivate *priv)
  priv->nqemuEventCallbacks,
  virConnectDomainQemuMonitorEventDeregister, "qemu monitor");
 
-if (priv->closeRegistered) {
+if (priv->closeRegistered && priv->conn) {
 if (virConnectUnregisterCloseCallback(priv->conn,
   
remoteRelayConnectionClosedEvent) < 0)
 VIR_WARN("unexpected close callback event deregister failure");
@@ -1751,9 +1756,7 @@ static void remoteClientCloseFunc(virNetServerClientPtr 
client)
 
 daemonRemoveAllClientStreams(priv->streams);
 
-/* Deregister event delivery callback */
-if (priv->conn)
-remoteClientFreePrivateCallbacks(priv);
+remoteClientFreePrivateCallbacks(priv);
 }
 
 
-- 
2.14.3

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

[libvirt] [PATCH v2 8/8] remote: use a separate connection for storage APIs

2018-04-05 Thread Daniel P . Berrangé
Reviewed-by: John Ferlan 
Signed-off-by: Daniel P. Berrangé 
---
 src/remote/remote_daemon.h  |  1 +
 src/remote/remote_daemon_dispatch.c | 19 +++
 src/rpc/gendispatch.pl  |  6 ++
 3 files changed, 18 insertions(+), 8 deletions(-)

diff --git a/src/remote/remote_daemon.h b/src/remote/remote_daemon.h
index 2b757d9cd6..2834da04a9 100644
--- a/src/remote/remote_daemon.h
+++ b/src/remote/remote_daemon.h
@@ -79,6 +79,7 @@ struct daemonClientPrivate {
 virConnectPtr nodedevConn;
 virConnectPtr nwfilterConn;
 virConnectPtr secretConn;
+virConnectPtr storageConn;
 
 daemonClientStreamPtr streams;
 };
diff --git a/src/remote/remote_daemon_dispatch.c 
b/src/remote/remote_daemon_dispatch.c
index 8f1b537db9..5b764bab48 100644
--- a/src/remote/remote_daemon_dispatch.c
+++ b/src/remote/remote_daemon_dispatch.c
@@ -1707,7 +1707,7 @@ remoteClientFreePrivateCallbacks(struct 
daemonClientPrivate *priv)
 DEREG_CB(priv->networkConn, priv->networkEventCallbacks,
  priv->nnetworkEventCallbacks,
  virConnectNetworkEventDeregisterAny, "network");
-DEREG_CB(priv->conn, priv->storageEventCallbacks,
+DEREG_CB(priv->storageConn, priv->storageEventCallbacks,
  priv->nstorageEventCallbacks,
  virConnectStoragePoolEventDeregisterAny, "storage");
 DEREG_CB(priv->nodedevConn, priv->nodeDeviceEventCallbacks,
@@ -1755,6 +1755,8 @@ void remoteClientFree(void *data)
 virConnectClose(priv->nwfilterConn);
 if (priv->secretConn)
 virConnectClose(priv->secretConn);
+if (priv->storageConn)
+virConnectClose(priv->storageConn);
 
 VIR_FREE(priv);
 }
@@ -1832,6 +1834,7 @@ remoteDispatchConnectOpen(virNetServerPtr server 
ATTRIBUTE_UNUSED,
 priv->nodedevConn = virObjectRef(priv->conn);
 priv->nwfilterConn = virObjectRef(priv->conn);
 priv->secretConn = virObjectRef(priv->conn);
+priv->storageConn = virObjectRef(priv->conn);
 
 /* force update the @readonly attribute which was inherited from the
  * virNetServerService object - this is important for sockets that are RW
@@ -5850,7 +5853,7 @@ 
remoteDispatchConnectStoragePoolEventRegisterAny(virNetServerPtr server ATTRIBUT
 virNetServerClientGetPrivateData(client);
 virStoragePoolPtr  pool = NULL;
 
-if (!priv->conn) {
+if (!priv->storageConn) {
 virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
 goto cleanup;
 }
@@ -5858,7 +5861,7 @@ 
remoteDispatchConnectStoragePoolEventRegisterAny(virNetServerPtr server ATTRIBUT
 virMutexLock(>lock);
 
 if (args->pool &&
-!(pool = get_nonnull_storage_pool(priv->conn, *args->pool)))
+!(pool = get_nonnull_storage_pool(priv->storageConn, *args->pool)))
 goto cleanup;
 
 if (args->eventID >= VIR_STORAGE_POOL_EVENT_ID_LAST || args->eventID < 0) {
@@ -5884,7 +5887,7 @@ 
remoteDispatchConnectStoragePoolEventRegisterAny(virNetServerPtr server ATTRIBUT
callback) < 0)
 goto cleanup;
 
-if ((callbackID = virConnectStoragePoolEventRegisterAny(priv->conn,
+if ((callbackID = virConnectStoragePoolEventRegisterAny(priv->storageConn,
 pool,
 args->eventID,
 
storageEventCallbacks[args->eventID],
@@ -5922,7 +5925,7 @@ 
remoteDispatchConnectStoragePoolEventDeregisterAny(virNetServerPtr server ATTRIB
 struct daemonClientPrivate *priv =
 virNetServerClientGetPrivateData(client);
 
-if (!priv->conn) {
+if (!priv->storageConn) {
 virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
 goto cleanup;
 }
@@ -5940,7 +5943,7 @@ 
remoteDispatchConnectStoragePoolEventDeregisterAny(virNetServerPtr server ATTRIB
 goto cleanup;
 }
 
-if (virConnectStoragePoolEventDeregisterAny(priv->conn, args->callbackID) 
< 0)
+if (virConnectStoragePoolEventDeregisterAny(priv->storageConn, 
args->callbackID) < 0)
 goto cleanup;
 
 VIR_DELETE_ELEMENT(priv->storageEventCallbacks, i,
@@ -6914,12 +6917,12 @@ remoteDispatchStorageVolGetInfoFlags(virNetServerPtr 
server ATTRIBUTE_UNUSED,
 struct daemonClientPrivate *priv =
 virNetServerClientGetPrivateData(client);
 
-if (!priv->conn) {
+if (!priv->storageConn) {
 virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
 goto cleanup;
 }
 
-if (!(vol = get_nonnull_storage_vol(priv->conn, args->vol)))
+if (!(vol = get_nonnull_storage_vol(priv->storageConn, args->vol)))
 goto cleanup;
 
 if (virStorageVolGetInfoFlags(vol, , args->flags) < 0)
diff --git a/src/rpc/gendispatch.pl b/src/rpc/gendispatch.pl
index 0c575cd055..b8b83b6b40 100755
--- a/src/rpc/gendispatch.pl
+++ 

[libvirt] [PATCH v2 7/8] remote: use a separate connection for secret APIs

2018-04-05 Thread Daniel P . Berrangé
Reviewed-by: John Ferlan 
Signed-off-by: Daniel P. Berrangé 
---
 src/remote/remote_daemon.h  |  1 +
 src/remote/remote_daemon_dispatch.c | 19 +++
 src/rpc/gendispatch.pl  |  6 ++
 3 files changed, 18 insertions(+), 8 deletions(-)

diff --git a/src/remote/remote_daemon.h b/src/remote/remote_daemon.h
index 1b906401d3..2b757d9cd6 100644
--- a/src/remote/remote_daemon.h
+++ b/src/remote/remote_daemon.h
@@ -78,6 +78,7 @@ struct daemonClientPrivate {
 virConnectPtr networkConn;
 virConnectPtr nodedevConn;
 virConnectPtr nwfilterConn;
+virConnectPtr secretConn;
 
 daemonClientStreamPtr streams;
 };
diff --git a/src/remote/remote_daemon_dispatch.c 
b/src/remote/remote_daemon_dispatch.c
index 36190de8f2..8f1b537db9 100644
--- a/src/remote/remote_daemon_dispatch.c
+++ b/src/remote/remote_daemon_dispatch.c
@@ -1713,7 +1713,7 @@ remoteClientFreePrivateCallbacks(struct 
daemonClientPrivate *priv)
 DEREG_CB(priv->nodedevConn, priv->nodeDeviceEventCallbacks,
  priv->nnodeDeviceEventCallbacks,
  virConnectNodeDeviceEventDeregisterAny, "node device");
-DEREG_CB(priv->conn, priv->secretEventCallbacks,
+DEREG_CB(priv->secretConn, priv->secretEventCallbacks,
  priv->nsecretEventCallbacks,
  virConnectSecretEventDeregisterAny, "secret");
 DEREG_CB(priv->conn, priv->qemuEventCallbacks,
@@ -1753,6 +1753,8 @@ void remoteClientFree(void *data)
 virConnectClose(priv->nodedevConn);
 if (priv->nwfilterConn)
 virConnectClose(priv->nwfilterConn);
+if (priv->secretConn)
+virConnectClose(priv->secretConn);
 
 VIR_FREE(priv);
 }
@@ -1829,6 +1831,7 @@ remoteDispatchConnectOpen(virNetServerPtr server 
ATTRIBUTE_UNUSED,
 priv->networkConn = virObjectRef(priv->conn);
 priv->nodedevConn = virObjectRef(priv->conn);
 priv->nwfilterConn = virObjectRef(priv->conn);
+priv->secretConn = virObjectRef(priv->conn);
 
 /* force update the @readonly attribute which was inherited from the
  * virNetServerService object - this is important for sockets that are RW
@@ -4050,12 +4053,12 @@ remoteDispatchSecretGetValue(virNetServerPtr server 
ATTRIBUTE_UNUSED,
 struct daemonClientPrivate *priv =
 virNetServerClientGetPrivateData(client);
 
-if (!priv->conn) {
+if (!priv->secretConn) {
 virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
 goto cleanup;
 }
 
-if (!(secret = get_nonnull_secret(priv->conn, args->secret)))
+if (!(secret = get_nonnull_secret(priv->secretConn, args->secret)))
 goto cleanup;
 
 if (!(value = virSecretGetValue(secret, _size, args->flags)))
@@ -6089,7 +6092,7 @@ 
remoteDispatchConnectSecretEventRegisterAny(virNetServerPtr server ATTRIBUTE_UNU
 virNetServerClientGetPrivateData(client);
 virSecretPtr secret = NULL;
 
-if (!priv->conn) {
+if (!priv->secretConn) {
 virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
 goto cleanup;
 }
@@ -6097,7 +6100,7 @@ 
remoteDispatchConnectSecretEventRegisterAny(virNetServerPtr server ATTRIBUTE_UNU
 virMutexLock(>lock);
 
 if (args->secret &&
-!(secret = get_nonnull_secret(priv->conn, *args->secret)))
+!(secret = get_nonnull_secret(priv->secretConn, *args->secret)))
 goto cleanup;
 
 if (args->eventID >= VIR_SECRET_EVENT_ID_LAST || args->eventID < 0) {
@@ -6123,7 +6126,7 @@ 
remoteDispatchConnectSecretEventRegisterAny(virNetServerPtr server ATTRIBUTE_UNU
callback) < 0)
 goto cleanup;
 
-if ((callbackID = virConnectSecretEventRegisterAny(priv->conn,
+if ((callbackID = virConnectSecretEventRegisterAny(priv->secretConn,
secret,
args->eventID,

secretEventCallbacks[args->eventID],
@@ -6161,7 +6164,7 @@ 
remoteDispatchConnectSecretEventDeregisterAny(virNetServerPtr server ATTRIBUTE_U
 struct daemonClientPrivate *priv =
 virNetServerClientGetPrivateData(client);
 
-if (!priv->conn) {
+if (!priv->secretConn) {
 virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
 goto cleanup;
 }
@@ -6179,7 +6182,7 @@ 
remoteDispatchConnectSecretEventDeregisterAny(virNetServerPtr server ATTRIBUTE_U
 goto cleanup;
 }
 
-if (virConnectSecretEventDeregisterAny(priv->conn, args->callbackID) < 0)
+if (virConnectSecretEventDeregisterAny(priv->secretConn, args->callbackID) 
< 0)
 goto cleanup;
 
 VIR_DELETE_ELEMENT(priv->secretEventCallbacks, i,
diff --git a/src/rpc/gendispatch.pl b/src/rpc/gendispatch.pl
index cccfcab743..0c575cd055 100755
--- a/src/rpc/gendispatch.pl
+++ b/src/rpc/gendispatch.pl
@@ -137,6 +137,9 @@ sub get_conn_arg {
 

[libvirt] [PATCH v2 5/8] remote: use a separate connection for nodedev APIs

2018-04-05 Thread Daniel P . Berrangé
Reviewed-by: John Ferlan 
Signed-off-by: Daniel P. Berrangé 
---
 src/remote/remote_daemon.h  |  1 +
 src/remote/remote_daemon_dispatch.c | 19 +++
 src/rpc/gendispatch.pl  |  6 ++
 3 files changed, 18 insertions(+), 8 deletions(-)

diff --git a/src/remote/remote_daemon.h b/src/remote/remote_daemon.h
index 60be78fe0b..517eec1fc2 100644
--- a/src/remote/remote_daemon.h
+++ b/src/remote/remote_daemon.h
@@ -76,6 +76,7 @@ struct daemonClientPrivate {
 virConnectPtr conn;
 virConnectPtr interfaceConn;
 virConnectPtr networkConn;
+virConnectPtr nodedevConn;
 
 daemonClientStreamPtr streams;
 };
diff --git a/src/remote/remote_daemon_dispatch.c 
b/src/remote/remote_daemon_dispatch.c
index bc26bccf65..668f67cca8 100644
--- a/src/remote/remote_daemon_dispatch.c
+++ b/src/remote/remote_daemon_dispatch.c
@@ -1710,7 +1710,7 @@ remoteClientFreePrivateCallbacks(struct 
daemonClientPrivate *priv)
 DEREG_CB(priv->conn, priv->storageEventCallbacks,
  priv->nstorageEventCallbacks,
  virConnectStoragePoolEventDeregisterAny, "storage");
-DEREG_CB(priv->conn, priv->nodeDeviceEventCallbacks,
+DEREG_CB(priv->nodedevConn, priv->nodeDeviceEventCallbacks,
  priv->nnodeDeviceEventCallbacks,
  virConnectNodeDeviceEventDeregisterAny, "node device");
 DEREG_CB(priv->conn, priv->secretEventCallbacks,
@@ -1749,6 +1749,8 @@ void remoteClientFree(void *data)
 virConnectClose(priv->interfaceConn);
 if (priv->networkConn)
 virConnectClose(priv->networkConn);
+if (priv->nodedevConn)
+virConnectClose(priv->nodedevConn);
 
 VIR_FREE(priv);
 }
@@ -1823,6 +1825,7 @@ remoteDispatchConnectOpen(virNetServerPtr server 
ATTRIBUTE_UNUSED,
 
 priv->interfaceConn = virObjectRef(priv->conn);
 priv->networkConn = virObjectRef(priv->conn);
+priv->nodedevConn = virObjectRef(priv->conn);
 
 /* force update the @readonly attribute which was inherited from the
  * virNetServerService object - this is important for sockets that are RW
@@ -3782,12 +3785,12 @@ remoteDispatchNodeDeviceGetParent(virNetServerPtr 
server ATTRIBUTE_UNUSED,
 struct daemonClientPrivate *priv =
 virNetServerClientGetPrivateData(client);
 
-if (!priv->conn) {
+if (!priv->nodedevConn) {
 virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
 goto cleanup;
 }
 
-if (!(dev = virNodeDeviceLookupByName(priv->conn, args->name)))
+if (!(dev = virNodeDeviceLookupByName(priv->nodedevConn, args->name)))
 goto cleanup;
 
 parent = virNodeDeviceGetParent(dev);
@@ -5962,7 +5965,7 @@ 
remoteDispatchConnectNodeDeviceEventRegisterAny(virNetServerPtr server ATTRIBUTE
 virNetServerClientGetPrivateData(client);
 virNodeDevicePtr  dev = NULL;
 
-if (!priv->conn) {
+if (!priv->nodedevConn) {
 virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
 goto cleanup;
 }
@@ -5970,7 +5973,7 @@ 
remoteDispatchConnectNodeDeviceEventRegisterAny(virNetServerPtr server ATTRIBUTE
 virMutexLock(>lock);
 
 if (args->dev &&
-!(dev = get_nonnull_node_device(priv->conn, *args->dev)))
+!(dev = get_nonnull_node_device(priv->nodedevConn, *args->dev)))
 goto cleanup;
 
 if (args->eventID >= VIR_NODE_DEVICE_EVENT_ID_LAST || args->eventID < 0) {
@@ -5996,7 +5999,7 @@ 
remoteDispatchConnectNodeDeviceEventRegisterAny(virNetServerPtr server ATTRIBUTE
callback) < 0)
 goto cleanup;
 
-if ((callbackID = virConnectNodeDeviceEventRegisterAny(priv->conn,
+if ((callbackID = virConnectNodeDeviceEventRegisterAny(priv->nodedevConn,
dev,
args->eventID,

nodeDeviceEventCallbacks[args->eventID],
@@ -6034,7 +6037,7 @@ 
remoteDispatchConnectNodeDeviceEventDeregisterAny(virNetServerPtr server ATTRIBU
 struct daemonClientPrivate *priv =
 virNetServerClientGetPrivateData(client);
 
-if (!priv->conn) {
+if (!priv->nodedevConn) {
 virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
 goto cleanup;
 }
@@ -6052,7 +6055,7 @@ 
remoteDispatchConnectNodeDeviceEventDeregisterAny(virNetServerPtr server ATTRIBU
 goto cleanup;
 }
 
-if (virConnectNodeDeviceEventDeregisterAny(priv->conn, args->callbackID) < 
0)
+if (virConnectNodeDeviceEventDeregisterAny(priv->nodedevConn, 
args->callbackID) < 0)
 goto cleanup;
 
 VIR_DELETE_ELEMENT(priv->nodeDeviceEventCallbacks, i,
diff --git a/src/rpc/gendispatch.pl b/src/rpc/gendispatch.pl
index 51faa899c6..af29d88b99 100755
--- a/src/rpc/gendispatch.pl
+++ b/src/rpc/gendispatch.pl
@@ -131,6 +131,9 @@ sub get_conn_arg {
 if ($type 

[libvirt] [PATCH v2 6/8] remote: use a separate connection for nwfilter APIs

2018-04-05 Thread Daniel P . Berrangé
Reviewed-by: John Ferlan 
Signed-off-by: Daniel P. Berrangé 
---
 src/remote/remote_daemon.h  | 1 +
 src/remote/remote_daemon_dispatch.c | 3 +++
 src/rpc/gendispatch.pl  | 6 ++
 3 files changed, 10 insertions(+)

diff --git a/src/remote/remote_daemon.h b/src/remote/remote_daemon.h
index 517eec1fc2..1b906401d3 100644
--- a/src/remote/remote_daemon.h
+++ b/src/remote/remote_daemon.h
@@ -77,6 +77,7 @@ struct daemonClientPrivate {
 virConnectPtr interfaceConn;
 virConnectPtr networkConn;
 virConnectPtr nodedevConn;
+virConnectPtr nwfilterConn;
 
 daemonClientStreamPtr streams;
 };
diff --git a/src/remote/remote_daemon_dispatch.c 
b/src/remote/remote_daemon_dispatch.c
index 668f67cca8..36190de8f2 100644
--- a/src/remote/remote_daemon_dispatch.c
+++ b/src/remote/remote_daemon_dispatch.c
@@ -1751,6 +1751,8 @@ void remoteClientFree(void *data)
 virConnectClose(priv->networkConn);
 if (priv->nodedevConn)
 virConnectClose(priv->nodedevConn);
+if (priv->nwfilterConn)
+virConnectClose(priv->nwfilterConn);
 
 VIR_FREE(priv);
 }
@@ -1826,6 +1828,7 @@ remoteDispatchConnectOpen(virNetServerPtr server 
ATTRIBUTE_UNUSED,
 priv->interfaceConn = virObjectRef(priv->conn);
 priv->networkConn = virObjectRef(priv->conn);
 priv->nodedevConn = virObjectRef(priv->conn);
+priv->nwfilterConn = virObjectRef(priv->conn);
 
 /* force update the @readonly attribute which was inherited from the
  * virNetServerService object - this is important for sockets that are RW
diff --git a/src/rpc/gendispatch.pl b/src/rpc/gendispatch.pl
index af29d88b99..cccfcab743 100755
--- a/src/rpc/gendispatch.pl
+++ b/src/rpc/gendispatch.pl
@@ -134,6 +134,9 @@ sub get_conn_arg {
 if ($type =~ /remote_nonnull_node_device/) {
 return "priv->nodedevConn";
 }
+if ($type =~ /remote_nonnull_nwfilter/) {
+return "priv->nwfilterConn";
+}
 }
 
 # This is for the few virConnect APIs that
@@ -148,6 +151,9 @@ sub get_conn_arg {
 if ($proc =~ /Node.*Device/) {
 return "priv->nodedevConn";
 }
+if ($proc =~ /Connect.*NWFilter/) {
+return "priv->nwfilterConn";
+}
 
 return "priv->conn";
 }
-- 
2.14.3

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

[libvirt] [PATCH v2 0/8] Prepare for daemon split

2018-04-05 Thread Daniel P . Berrangé
When we split up the daemons, libvirtd will need to forward different
sets of APIs to different daemons. This means libvirtd is going to need
to have multiple virConnectPtr instances open.

This series prepares for that by introducing "separate" connections,
which are actually just an extra reference on the current single
connection. This will facilitate later changes.

Daniel P. Berrangé (8):
  rpc: refactor way connection object is generated for remote dispatch
  remote: push check for conn down into remoteClientFreePrivateCallbacks
  remote: use a separate connection for interface APIs
  remote: use a separate connection for network APIs
  remote: use a separate connection for nodedev APIs
  remote: use a separate connection for nwfilter APIs
  remote: use a separate connection for secret APIs
  remote: use a separate connection for storage APIs

 src/remote/remote_daemon.h  |   6 +++
 src/remote/remote_daemon_dispatch.c |  94 +++-
 src/rpc/gendispatch.pl  | 104 +---
 3 files changed, 138 insertions(+), 66 deletions(-)

-- 
2.14.3

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Re: [libvirt] [dbus PATCH v3 0/4] Introduce Network Interface

2018-04-05 Thread Pavel Hrdina
On Thu, Apr 05, 2018 at 12:40:16PM +0200, Katerina Koukiou wrote:
> This patchset introduces also some basic methods and properties for
> Network interface.
> More functionality will be added in following patchsets.
> New functions are covered by the test suite.
> 
> Changes from v2:
> * Added test_list_networks test.
> * xml files should group methods/signals/properties together.
> * Some other minor fixes.
> 
> Katerina Koukiou (4):
>   Introduce Network Interface
>   Implement ListNetworks method for Connect interface
>   Implement Name property for Network interface
>   Implement NetworkLookupByName method for Connect interface

With the indentation fixed

Reviewed-by: Pavel Hrdina 


signature.asc
Description: PGP signature
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Re: [libvirt] [PATCH v4 2/3] qemu_cgroup: Handle device mapper targets properly

2018-04-05 Thread Peter Krempa
On Thu, Apr 05, 2018 at 10:09:40 +0200, Michal Privoznik wrote:
> https://bugzilla.redhat.com/show_bug.cgi?id=1557769
> 
> Problem with device mapper targets is that there can be several
> other devices 'hidden' behind them. For instance, /dev/dm-1 can
> consist of /dev/sda, /dev/sdb and /dev/sdc. Therefore, when
> setting up devices CGroup and namespaces we have to take this
> into account.
> 
> This bug was exposed after Linux kernel was fixed. Initially,
> kernel used different functions for getting block device in
> open() and ioctl(). While CGroup permissions were checked in the
> former case, due to a bug in kernel they were not checked in the
> latter case. This changed with the upstream commit of
> 519049afead4f7c3e6446028c41e99fde958cc04 (v4.16-rc5~11^2~4).
> 
> Signed-off-by: Michal Privoznik 
> ---
>  libvirt.spec.in|  2 ++
>  src/qemu/qemu_cgroup.c | 46 +++---
>  2 files changed, 45 insertions(+), 3 deletions(-)
> 
> diff --git a/libvirt.spec.in b/libvirt.spec.in
> index 97143c68ae..7dd63c0762 100644
> --- a/libvirt.spec.in
> +++ b/libvirt.spec.in
> @@ -801,6 +801,8 @@ Requires: gzip
>  Requires: bzip2
>  Requires: lzop
>  Requires: xz
> +# For mpath devices
> +Requires: device-mapper

AFAIK if you link with a library, RPM picks the dependency up
automatically, so this should not be required. It's required only for
packages which provide binaries we use.

Also the comment would not be entirely true, since it's required for all
device mapper devices.

>  %if 0%{?fedora} || 0%{?rhel} > 7
>  Requires: systemd-container
>  %endif

ACK to the rest of the patch.


signature.asc
Description: PGP signature
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Re: [libvirt] [dbus PATCH v3 1/4] Introduce Network Interface

2018-04-05 Thread Pavel Hrdina
On Thu, Apr 05, 2018 at 12:40:17PM +0200, Katerina Koukiou wrote:
> Signed-off-by: Katerina Koukiou 
> ---
>  data/Makefile.am |  3 ++-
>  data/org.libvirt.Network.xml |  7 +
>  src/Makefile.am  |  3 ++-
>  src/connect.c|  6 +
>  src/connect.h|  1 +
>  src/network.c| 64 
> 
>  src/network.h|  9 +++
>  src/util.c   | 33 +++
>  src/util.h   | 15 +++
>  9 files changed, 139 insertions(+), 2 deletions(-)
>  create mode 100644 data/org.libvirt.Network.xml
>  create mode 100644 src/network.c
>  create mode 100644 src/network.h

[...]

> diff --git a/src/network.c b/src/network.c
> new file mode 100644
> index 000..0d0e992
> --- /dev/null
> +++ b/src/network.c
> @@ -0,0 +1,64 @@
> +#include "network.h"
> +#include "util.h"
> +
> +#include 
> +
> +static virtDBusGDBusPropertyTable virtDBusNetworkPropertyTable[] = {
> +{ 0 }
> +};
> +
> +static virtDBusGDBusMethodTable virtDBusNetworkMethodTable[] = {
> +{ 0 }
> +};
> +
> +static gchar **
> +virtDBusNetworkEnumerate(gpointer userData)
> +{
> +virtDBusConnect *connect = userData;
> +g_autoptr(virNetworkPtr) networks = NULL;
> +gint num = 0;
> +gchar **ret = NULL;
> +
> +if (!virtDBusConnectOpen(connect, NULL))
> +return NULL;
> +
> +num = virConnectListAllNetworks(connect->connection, , 0);
> +if (num < 0)
> +return NULL;
> +
> +if (num == 0)
> +return NULL;
> +
> +ret = g_new0(gchar *, num + 1);
> +
> +for (gint i = 0; i < num; i++) {
> +ret[i] = virtDBusUtilBusPathForVirNetwork(networks[i],
> +  connect->networkPath);
> +}
> +
> +return ret;
> +}
> +
> +static GDBusInterfaceInfo *interfaceInfo = NULL;
> +
> +void
> +virtDBusNetworkRegister(virtDBusConnect *connect,
> +   GError **error)

The indentation is still off here.

> +{
> +connect->networkPath = g_strdup_printf("%s/network", 
> connect->connectPath);
> +
> +if (!interfaceInfo) {
> +interfaceInfo = 
> virtDBusGDBusLoadIntrospectData(VIRT_DBUS_NETWORK_INTERFACE,
> +error);
> +if (!interfaceInfo)
> +return;
> +}
> +
> +virtDBusGDBusRegisterSubtree(connect->bus,
> + connect->networkPath,
> + interfaceInfo,
> + virtDBusNetworkEnumerate,
> + virtDBusNetworkMethodTable,
> + virtDBusNetworkPropertyTable,
> + connect);
> +}
> diff --git a/src/network.h b/src/network.h
> new file mode 100644
> index 000..fc53b28
> --- /dev/null
> +++ b/src/network.h
> @@ -0,0 +1,9 @@
> +#pragma once
> +
> +#include "connect.h"
> +
> +#define VIRT_DBUS_NETWORK_INTERFACE "org.libvirt.Network"
> +
> +void
> +virtDBusNetworkRegister(virtDBusConnect *connect,
> +GError **error);
> diff --git a/src/util.c b/src/util.c
> index be65172..03a0f10 100644
> --- a/src/util.c
> +++ b/src/util.c
> @@ -151,3 +151,36 @@ virtDBusUtilEnumFromString(const gchar *const *types,
>  
>  return -1;
>  }
> +
> +virNetworkPtr
> +virtDBusUtilVirNetworkFromBusPath(virConnectPtr connection,
> + const gchar *path,
> + const gchar *networkPath)

And here the indentation is also off.

> +{
> +g_autofree gchar *name = NULL;
> +gsize prefixLen = strlen(networkPath) + 1;
> +
> +name = virtDBusUtilDecodeUUID(path+prefixLen);
> +
> +return virNetworkLookupByUUIDString(connection, name);
> +}
> +
> +gchar *
> +virtDBusUtilBusPathForVirNetwork(virNetworkPtr network,
> + const gchar *networkPath)
> +{
> +gchar uuid[VIR_UUID_STRING_BUFLEN] = "";
> +g_autofree gchar *newUuid = NULL;
> +virNetworkGetUUIDString(network, uuid);
> +newUuid = virtDBusUtilEncodeUUID(uuid);
> +return g_strdup_printf("%s/%s", networkPath, newUuid);
> +}
> +
> +void
> +virtDBusUtilVirNetworkListFree(virNetworkPtr *networks)
> +{
> +for (gint i = 0; networks[i] != NULL; i += 1)
> +virNetworkFree(networks[i]);
> +
> +g_free(networks);
> +}
> diff --git a/src/util.h b/src/util.h
> index c9d9cfd..7bb4ad6 100644
> --- a/src/util.h
> +++ b/src/util.h
> @@ -65,3 +65,18 @@ virtDBusUtilEnumToString(const gchar *const *types,
>  #define VIRT_DBUS_ENUM_DECL(name) \
>  const gchar *name ##TypeToString(gint type) G_GNUC_PURE; \
>  gint name ##TypeFromString(const gchar *type) G_GNUC_PURE;
> +
> +virNetworkPtr
> +virtDBusUtilVirNetworkFromBusPath(virConnectPtr connection,
> + const gchar *path,
> + 

Re: [libvirt] [PATCH v4 1/3] util: Introduce virDevMapperGetTargets

2018-04-05 Thread Peter Krempa
On Thu, Apr 05, 2018 at 10:09:39 +0200, Michal Privoznik wrote:
> This helper fetches dependencies for given device mapper target.
> 
> At the same time, we need to provide a dummy log function because
> by default libdevmapper prints out error messages to stderr which
> we need to suppress.
> 
> Signed-off-by: Michal Privoznik 
> ---
>  src/libvirt_private.syms |   4 +
>  src/util/Makefile.inc.am |   2 +
>  src/util/virdevmapper.c  | 199 
> +++
>  src/util/virdevmapper.h  |  31 
>  4 files changed, 236 insertions(+)
>  create mode 100644 src/util/virdevmapper.c
>  create mode 100644 src/util/virdevmapper.h

ACK


signature.asc
Description: PGP signature
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

[libvirt] [dbus PATCH v3 3/4] Implement Name property for Network interface

2018-04-05 Thread Katerina Koukiou
Signed-off-by: Katerina Koukiou 
---
 data/org.libvirt.Network.xml |  4 
 src/network.c| 43 +++
 test/Makefile.am |  3 ++-
 test/libvirttest.py  | 12 
 test/test_network.py | 19 +++
 5 files changed, 80 insertions(+), 1 deletion(-)
 create mode 100755 test/test_network.py

diff --git a/data/org.libvirt.Network.xml b/data/org.libvirt.Network.xml
index 2b7c4f7..1215ac3 100644
--- a/data/org.libvirt.Network.xml
+++ b/data/org.libvirt.Network.xml
@@ -3,5 +3,9 @@
 
 
   
+
+  https://libvirt.org/html/libvirt-libvirt-network.html#virNetworkGetName"/>
+
   
 
diff --git a/src/network.c b/src/network.c
index 0d0e992..fdfaaa7 100644
--- a/src/network.c
+++ b/src/network.c
@@ -3,7 +3,50 @@
 
 #include 
 
+static virNetworkPtr
+virtDBusNetworkGetVirNetwork(virtDBusConnect *connect,
+ const gchar *objectPath,
+ GError **error)
+{
+virNetworkPtr network;
+
+if (virtDBusConnectOpen(connect, error) < 0)
+return NULL;
+
+network = virtDBusUtilVirNetworkFromBusPath(connect->connection,
+objectPath,
+connect->networkPath);
+if (!network) {
+virtDBusUtilSetLastVirtError(error);
+return NULL;
+}
+
+return network;
+}
+
+static void
+virtDBusNetworkGetName(const gchar *objectPath,
+   gpointer userData,
+   GVariant **value,
+   GError **error)
+{
+virtDBusConnect *connect = userData;
+g_autoptr(virNetwork) network = NULL;
+const gchar *name;
+
+network = virtDBusNetworkGetVirNetwork(connect, objectPath, error);
+if (!network)
+return;
+
+name = virNetworkGetName(network);
+if (!name)
+return virtDBusUtilSetLastVirtError(error);
+
+*value = g_variant_new("s", name);
+}
+
 static virtDBusGDBusPropertyTable virtDBusNetworkPropertyTable[] = {
+{ "Name", virtDBusNetworkGetName, NULL },
 { 0 }
 };
 
diff --git a/test/Makefile.am b/test/Makefile.am
index acb2d33..089ade5 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -4,7 +4,8 @@ test_helpers = \
 
 test_programs = \
test_connect.py \
-   test_domain.py
+   test_domain.py \
+   test_network.py
 
 EXTRA_DIST = \
$(test_helpers) \
diff --git a/test/libvirttest.py b/test/libvirttest.py
index c4dc96f..ecd8aef 100644
--- a/test/libvirttest.py
+++ b/test/libvirttest.py
@@ -70,3 +70,15 @@ class BaseTestClass():
 path = self.connect.ListDomains(0)[0]
 obj = self.bus.get_object('org.libvirt', path)
 return obj, dbus.Interface(obj, 'org.libvirt.Domain')
+
+def test_network(self):
+"""Fetch information for the test network from test driver
+
+Returns:
+(dbus.proxies.ProxyObject, dbus.proxies.ProxyObject):
+Test Network Object, Local proxy for the test Network Object.
+
+"""
+path = self.connect.ListNetworks(0)[0]
+obj = self.bus.get_object('org.libvirt', path)
+return path, obj
diff --git a/test/test_network.py b/test/test_network.py
new file mode 100755
index 000..97ab0aa
--- /dev/null
+++ b/test/test_network.py
@@ -0,0 +1,19 @@
+#!/usr/bin/python3
+
+import dbus
+import libvirttest
+
+
+class TestNetwork(libvirttest.BaseTestClass):
+""" Tests for methods and properties of the Network interface
+"""
+def test_network_properties_type(self):
+""" Ensure correct return type for Network properties
+"""
+_, obj = self.test_network()
+props = obj.GetAll('org.libvirt.Network', 
dbus_interface=dbus.PROPERTIES_IFACE)
+assert isinstance(props['Name'], dbus.String)
+
+
+if __name__ == '__main__':
+libvirttest.run()
-- 
2.15.0

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [dbus PATCH v3 1/4] Introduce Network Interface

2018-04-05 Thread Katerina Koukiou
Signed-off-by: Katerina Koukiou 
---
 data/Makefile.am |  3 ++-
 data/org.libvirt.Network.xml |  7 +
 src/Makefile.am  |  3 ++-
 src/connect.c|  6 +
 src/connect.h|  1 +
 src/network.c| 64 
 src/network.h|  9 +++
 src/util.c   | 33 +++
 src/util.h   | 15 +++
 9 files changed, 139 insertions(+), 2 deletions(-)
 create mode 100644 data/org.libvirt.Network.xml
 create mode 100644 src/network.c
 create mode 100644 src/network.h

diff --git a/data/Makefile.am b/data/Makefile.am
index dd60713..61702df 100644
--- a/data/Makefile.am
+++ b/data/Makefile.am
@@ -20,7 +20,8 @@ polkit_DATA = $(polkit_files:.rules.in=.rules)
 
 interfaces_files = \
org.libvirt.Connect.xml \
-   org.libvirt.Domain.xml
+   org.libvirt.Domain.xml \
+   org.libvirt.Network.xml
 interfacesdir = $(DBUS_INTERFACES_DIR)
 interfaces_DATA = $(interfaces_files)
 
diff --git a/data/org.libvirt.Network.xml b/data/org.libvirt.Network.xml
new file mode 100644
index 000..2b7c4f7
--- /dev/null
+++ b/data/org.libvirt.Network.xml
@@ -0,0 +1,7 @@
+http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd;>
+
+
+  
+  
+
diff --git a/src/Makefile.am b/src/Makefile.am
index 7248561..158398a 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -8,7 +8,8 @@ DAEMON_SOURCES = \
util.c util.h \
domain.c domain.h \
events.c events.h \
-   gdbus.c gdbus.h
+   gdbus.c gdbus.h \
+   network.c network.h
 
 EXTRA_DIST = \
$(DAEMON_SOURCES)
diff --git a/src/connect.c b/src/connect.c
index 2350736..2fdd248 100644
--- a/src/connect.c
+++ b/src/connect.c
@@ -1,6 +1,7 @@
 #include "connect.h"
 #include "domain.h"
 #include "events.h"
+#include "network.h"
 #include "util.h"
 
 #include 
@@ -303,6 +304,7 @@ virtDBusConnectFree(virtDBusConnect *connect)
 virtDBusConnectClose(connect, TRUE);
 
 g_free(connect->domainPath);
+g_free(connect->networkPath);
 g_free(connect);
 }
 G_DEFINE_AUTOPTR_CLEANUP_FUNC(virtDBusConnect, virtDBusConnectFree);
@@ -345,6 +347,10 @@ virtDBusConnectNew(virtDBusConnect **connectp,
 if (error && *error)
 return;
 
+virtDBusNetworkRegister(connect, error);
+if (error && *error)
+return;
+
 *connectp = connect;
 connect = NULL;
 }
diff --git a/src/connect.h b/src/connect.h
index 9572857..7ed84b8 100644
--- a/src/connect.h
+++ b/src/connect.h
@@ -13,6 +13,7 @@ struct virtDBusConnect {
 const gchar *uri;
 const gchar *connectPath;
 gchar *domainPath;
+gchar *networkPath;
 virConnectPtr connection;
 GMutex lock;
 
diff --git a/src/network.c b/src/network.c
new file mode 100644
index 000..0d0e992
--- /dev/null
+++ b/src/network.c
@@ -0,0 +1,64 @@
+#include "network.h"
+#include "util.h"
+
+#include 
+
+static virtDBusGDBusPropertyTable virtDBusNetworkPropertyTable[] = {
+{ 0 }
+};
+
+static virtDBusGDBusMethodTable virtDBusNetworkMethodTable[] = {
+{ 0 }
+};
+
+static gchar **
+virtDBusNetworkEnumerate(gpointer userData)
+{
+virtDBusConnect *connect = userData;
+g_autoptr(virNetworkPtr) networks = NULL;
+gint num = 0;
+gchar **ret = NULL;
+
+if (!virtDBusConnectOpen(connect, NULL))
+return NULL;
+
+num = virConnectListAllNetworks(connect->connection, , 0);
+if (num < 0)
+return NULL;
+
+if (num == 0)
+return NULL;
+
+ret = g_new0(gchar *, num + 1);
+
+for (gint i = 0; i < num; i++) {
+ret[i] = virtDBusUtilBusPathForVirNetwork(networks[i],
+  connect->networkPath);
+}
+
+return ret;
+}
+
+static GDBusInterfaceInfo *interfaceInfo = NULL;
+
+void
+virtDBusNetworkRegister(virtDBusConnect *connect,
+   GError **error)
+{
+connect->networkPath = g_strdup_printf("%s/network", connect->connectPath);
+
+if (!interfaceInfo) {
+interfaceInfo = 
virtDBusGDBusLoadIntrospectData(VIRT_DBUS_NETWORK_INTERFACE,
+error);
+if (!interfaceInfo)
+return;
+}
+
+virtDBusGDBusRegisterSubtree(connect->bus,
+ connect->networkPath,
+ interfaceInfo,
+ virtDBusNetworkEnumerate,
+ virtDBusNetworkMethodTable,
+ virtDBusNetworkPropertyTable,
+ connect);
+}
diff --git a/src/network.h b/src/network.h
new file mode 100644
index 000..fc53b28
--- /dev/null
+++ b/src/network.h
@@ -0,0 +1,9 @@
+#pragma once
+
+#include "connect.h"
+
+#define VIRT_DBUS_NETWORK_INTERFACE "org.libvirt.Network"
+
+void
+virtDBusNetworkRegister(virtDBusConnect *connect,
+

[libvirt] [dbus PATCH v3 4/4] Implement NetworkLookupByName method for Connect interface

2018-04-05 Thread Katerina Koukiou
Signed-off-by: Katerina Koukiou 
---
 data/org.libvirt.Connect.xml |  6 ++
 src/connect.c| 29 +
 test/test_connect.py | 11 +++
 3 files changed, 46 insertions(+)

diff --git a/data/org.libvirt.Connect.xml b/data/org.libvirt.Connect.xml
index 94704ff..043ee32 100644
--- a/data/org.libvirt.Connect.xml
+++ b/data/org.libvirt.Connect.xml
@@ -50,6 +50,12 @@
   
   
 
+
+  https://libvirt.org/html/libvirt-libvirt-network.html#virNetworkLookupByName"/>
+  
+  
+
 
   https://libvirt.org/html/libvirt-libvirt-domain.html#virConnectDomainEventCallback"/>
diff --git a/src/connect.c b/src/connect.c
index f9cd96c..d036753 100644
--- a/src/connect.c
+++ b/src/connect.c
@@ -320,6 +320,34 @@ virtDBusConnectListNetworks(GVariant *inArgs,
 *outArgs = g_variant_new_tuple(, 1);
 }
 
+static void
+virtDBusNetworkLookupByName(GVariant *inArgs,
+GUnixFDList *inFDs G_GNUC_UNUSED,
+const gchar *objectPath G_GNUC_UNUSED,
+gpointer userData,
+GVariant **outArgs,
+GUnixFDList **outFDs G_GNUC_UNUSED,
+GError **error)
+{
+virtDBusConnect *connect = userData;
+g_autoptr(virNetwork) network = NULL;
+g_autofree gchar *path = NULL;
+const gchar *name;
+
+g_variant_get(inArgs, "(s)", );
+
+if (!virtDBusConnectOpen(connect, error))
+return;
+
+network = virNetworkLookupByName(connect->connection, name);
+if (!network)
+return virtDBusUtilSetLastVirtError(error);
+
+path = virtDBusUtilBusPathForVirNetwork(network, connect->networkPath);
+
+*outArgs = g_variant_new("(o)", path);
+}
+
 static virtDBusGDBusPropertyTable virtDBusConnectPropertyTable[] = {
 { "Version", virtDBusConnectGetVersion, NULL },
 { 0 }
@@ -333,6 +361,7 @@ static virtDBusGDBusMethodTable 
virtDBusConnectMethodTable[] = {
 { "DomainLookupByName", virtDBusDomainLookupByName },
 { "DomainLookupByUUID", virtDBusDomainLookupByUUID },
 { "ListNetworks", virtDBusConnectListNetworks },
+{ "NetworkLookupByName", virtDBusNetworkLookupByName },
 { 0 }
 };
 
diff --git a/test/test_connect.py b/test/test_connect.py
index 03f353f..440a496 100755
--- a/test/test_connect.py
+++ b/test/test_connect.py
@@ -86,6 +86,17 @@ class TestConnect(libvirttest.BaseTestClass):
 # ensure the path exists by calling Introspect on it
 network.Introspect(dbus_interface=dbus.INTROSPECTABLE_IFACE)
 
+@pytest.mark.parametrize("lookup_method_name,lookup_item", [
+("NetworkLookupByName", 'Name'),
+])
+def test_connect_network_lookup_by_property(self, lookup_method_name, 
lookup_item):
+"""Parameterized test for all NetworkLookupBy* API calls of Connect 
interface
+"""
+original_path, obj = self.test_network()
+prop = obj.Get('org.libvirt.Network', lookup_item, 
dbus_interface=dbus.PROPERTIES_IFACE)
+path = getattr(self.connect, lookup_method_name)(prop)
+assert original_path == path
+
 
 if __name__ == '__main__':
 libvirttest.run()
-- 
2.15.0

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [dbus PATCH v3 2/4] Implement ListNetworks method for Connect interface

2018-04-05 Thread Katerina Koukiou
Signed-off-by: Katerina Koukiou 
---
 data/org.libvirt.Connect.xml |  6 ++
 src/connect.c| 41 +
 test/test_connect.py | 12 
 3 files changed, 59 insertions(+)

diff --git a/data/org.libvirt.Connect.xml b/data/org.libvirt.Connect.xml
index 1695100..94704ff 100644
--- a/data/org.libvirt.Connect.xml
+++ b/data/org.libvirt.Connect.xml
@@ -44,6 +44,12 @@
   
   
 
+
+  https://libvirt.org/html/libvirt-libvirt-network.html#virConnectListAllNetworks"/>
+  
+  
+
 
   https://libvirt.org/html/libvirt-libvirt-domain.html#virConnectDomainEventCallback"/>
diff --git a/src/connect.c b/src/connect.c
index 2fdd248..f9cd96c 100644
--- a/src/connect.c
+++ b/src/connect.c
@@ -280,6 +280,46 @@ virtDBusDomainLookupByUUID(GVariant *inArgs,
 *outArgs = g_variant_new("(o)", path);
 }
 
+static void
+virtDBusConnectListNetworks(GVariant *inArgs,
+GUnixFDList *inFDs G_GNUC_UNUSED,
+const gchar *objectPath G_GNUC_UNUSED,
+gpointer userData,
+GVariant **outArgs,
+GUnixFDList **outFDs G_GNUC_UNUSED,
+GError **error)
+{
+virtDBusConnect *connect = userData;
+g_autoptr(virNetworkPtr) networks = NULL;
+guint flags;
+GVariantBuilder builder;
+GVariant *gnetworks;
+
+g_variant_get(inArgs, "(u)", );
+
+if (!virtDBusConnectOpen(connect, error))
+return;
+
+if (virConnectListAllNetworks(connect->connection, , flags) < 0)
+return virtDBusUtilSetLastVirtError(error);
+
+if (!*networks)
+return;
+
+g_variant_builder_init(, G_VARIANT_TYPE("ao"));
+
+for (gint i = 0; networks[i]; i++) {
+g_autofree gchar *path = NULL;
+path = virtDBusUtilBusPathForVirNetwork(networks[i],
+connect->networkPath);
+
+g_variant_builder_add(, "o", path);
+}
+
+gnetworks = g_variant_builder_end();
+*outArgs = g_variant_new_tuple(, 1);
+}
+
 static virtDBusGDBusPropertyTable virtDBusConnectPropertyTable[] = {
 { "Version", virtDBusConnectGetVersion, NULL },
 { 0 }
@@ -292,6 +332,7 @@ static virtDBusGDBusMethodTable 
virtDBusConnectMethodTable[] = {
 { "DomainLookupByID", virtDBusDomainLookupByID },
 { "DomainLookupByName", virtDBusDomainLookupByName },
 { "DomainLookupByUUID", virtDBusDomainLookupByUUID },
+{ "ListNetworks", virtDBusConnectListNetworks },
 { 0 }
 };
 
diff --git a/test/test_connect.py b/test/test_connect.py
index 5df7a5b..03f353f 100755
--- a/test/test_connect.py
+++ b/test/test_connect.py
@@ -74,6 +74,18 @@ class TestConnect(libvirttest.BaseTestClass):
 props = obj.GetAll('org.libvirt.Connect', 
dbus_interface=dbus.PROPERTIES_IFACE)
 assert isinstance(props[property_name], expected_type)
 
+def test_list_networks(self):
+networks = self.connect.ListNetworks(0)
+assert isinstance(networks, dbus.Array)
+assert len(networks) == 1
+
+for path in networks:
+assert isinstance(path, dbus.ObjectPath)
+network = self.bus.get_object('org.libvirt', path)
+
+# ensure the path exists by calling Introspect on it
+network.Introspect(dbus_interface=dbus.INTROSPECTABLE_IFACE)
+
 
 if __name__ == '__main__':
 libvirttest.run()
-- 
2.15.0

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [dbus PATCH v3 0/4] Introduce Network Interface

2018-04-05 Thread Katerina Koukiou
This patchset introduces also some basic methods and properties for
Network interface.
More functionality will be added in following patchsets.
New functions are covered by the test suite.

Changes from v2:
* Added test_list_networks test.
* xml files should group methods/signals/properties together.
* Some other minor fixes.

Katerina Koukiou (4):
  Introduce Network Interface
  Implement ListNetworks method for Connect interface
  Implement Name property for Network interface
  Implement NetworkLookupByName method for Connect interface

 data/Makefile.am |   3 +-
 data/org.libvirt.Connect.xml |  12 +
 data/org.libvirt.Network.xml |  11 +
 src/Makefile.am  |   3 +-
 src/connect.c|  76 ++
 src/connect.h|   1 +
 src/network.c| 107 +++
 src/network.h|   9 
 src/util.c   |  33 +
 src/util.h   |  15 ++
 test/Makefile.am |   3 +-
 test/libvirttest.py  |  12 +
 test/test_connect.py |  23 ++
 test/test_network.py |  19 
 14 files changed, 324 insertions(+), 3 deletions(-)
 create mode 100644 data/org.libvirt.Network.xml
 create mode 100644 src/network.c
 create mode 100644 src/network.h
 create mode 100755 test/test_network.py

-- 
2.15.0

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] [PATCH 3/7] remote: use a separate connection for network APIs

2018-04-05 Thread Daniel P . Berrangé
On Wed, Apr 04, 2018 at 01:45:45PM -0400, John Ferlan wrote:
> 
> 
> On 03/28/2018 11:18 AM, Daniel P. Berrangé wrote:
> > Signed-off-by: Daniel P. Berrangé 
> > ---
> >  src/remote/remote_daemon.h  |  1 +
> >  src/remote/remote_daemon_dispatch.c | 19 +++
> >  src/rpc/gendispatch.pl  |  6 ++
> >  3 files changed, 18 insertions(+), 8 deletions(-)
> > 
> > diff --git a/src/remote/remote_daemon.h b/src/remote/remote_daemon.h
> > index 31f433c15d..60be78fe0b 100644
> > --- a/src/remote/remote_daemon.h
> > +++ b/src/remote/remote_daemon.h
> > @@ -75,6 +75,7 @@ struct daemonClientPrivate {
> >   */
> >  virConnectPtr conn;
> >  virConnectPtr interfaceConn;
> > +virConnectPtr networkConn;
> >  
> >  daemonClientStreamPtr streams;
> >  };
> > diff --git a/src/remote/remote_daemon_dispatch.c 
> > b/src/remote/remote_daemon_dispatch.c
> > index 7971646c28..d0bc474850 100644
> > --- a/src/remote/remote_daemon_dispatch.c
> > +++ b/src/remote/remote_daemon_dispatch.c
> > @@ -1699,7 +1699,7 @@ remoteClientFreePrivateCallbacks(struct 
> > daemonClientPrivate *priv)
> 
> Trying to forward think - will there ever come a day when priv->conn ==
> NULL, but priv->*Conn != NULL?  The caller is gated on priv->conn...
> 
> IOW: Do we need to separate this one out a bit now

I'm not entirely sure at this time. It makes sense to push the if (conn)
check down into this method though, so I'll do that.


Regards,
Daniel
-- 
|: https://berrange.com  -o-https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org -o-https://fstop138.berrange.com :|
|: https://entangle-photo.org-o-https://www.instagram.com/dberrange :|

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Re: [libvirt] [PATCH 1/7] rpc: refactor way connection object is generated for remote dispatch

2018-04-05 Thread Daniel P . Berrangé
On Wed, Apr 04, 2018 at 01:41:54PM -0400, John Ferlan wrote:
> 
> 
> On 03/28/2018 11:18 AM, Daniel P. Berrangé wrote:
> > Calling a push_privconn method to directly push the connection object
> > name into the arg list is inconvenient. Refactor so that we acquire
> > the connection variable name upfront, and push it to the arg list
> > separately. This allows various hardcoded usage of "priv->conn" to
> > be parameterized.
> > 
> > Signed-off-by: Daniel P. Berrangé 
> > ---
> >  src/rpc/gendispatch.pl | 48 
> > ++--
> >  1 file changed, 22 insertions(+), 26 deletions(-)
> > 
> > diff --git a/src/rpc/gendispatch.pl b/src/rpc/gendispatch.pl
> > index fb15cc4849..e11921f3d9 100755
> > --- a/src/rpc/gendispatch.pl
> > +++ b/src/rpc/gendispatch.pl
> 
> [...]
> 
> > @@ -1002,7 +998,7 @@ elsif ($mode eq "server") {
> >  if ($structprefix eq "admin") {
> >  print "if (!priv->dmn) {\n";
> >  } else {
> > -print "if (!priv->conn) {\n";
> > +print "if (!$conn) {\n";
> >  }
> 
> Shouldn't this just be "if (!$conn) {\n" for both halves of the if else?

Oh yes, we can simplify that because $conn already accounts for the 'dmn'
vs 'conn' difference.

> 
> w/ slight adjustment,
> 
> Reviewed-by: John Ferlan 

Regards,
Daniel
-- 
|: https://berrange.com  -o-https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org -o-https://fstop138.berrange.com :|
|: https://entangle-photo.org-o-https://www.instagram.com/dberrange :|

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Re: [libvirt] [PATCH] docs: add page describing goals for host platform version support

2018-04-05 Thread Pavel Hrdina
On Thu, Apr 05, 2018 at 10:54:53AM +0100, Daniel P. Berrangé wrote:
> On Tue, Apr 03, 2018 at 05:23:21PM +0200, Pavel Hrdina wrote:
> > On Tue, Apr 03, 2018 at 03:56:11PM +0100, Daniel P. Berrangé wrote:
> > > Describe how we decide which host platforms to support for libvirt,
> > > which in turn makes it easier to decide when a platform / software
> > > version can be dropped.
> > > 
> > > Signed-off-by: Daniel P. Berrangé 
> > > ---
> > >  docs/index.html.in |  2 +-
> > >  docs/platforms.html.in | 74 
> > > ++
> > >  2 files changed, 75 insertions(+), 1 deletion(-)
> > >  create mode 100644 docs/platforms.html.in
> > > 
> 
> > > +FreeBSD
> > > +
> > > +
> > > +  The project will aim to support the most recent major version
> > > +  at all times. Support for the previous major version will
> > > +  be dropped 2 years after the new major version is released.
> > > +
> > > +
> > > +Virtualization platforms
> > > +
> > > +
> > > +  For hypervisor drivers which execute locally (QEMU, LXC, VZ,
> > 
> > s/ VZ,// or s/VZ/OpenVZ/ ?
> 
> Not sure I see why you want that ?   The modern VZ driver is run locally
> in libvirtd, the same as QEMU, LXC, etc.

Right, once I've read it again it actually make sense.  I thought that
it shouldn't be mentioned twice.

Pavel


signature.asc
Description: PGP signature
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

  1   2   >