[libvirt] [PATCH 4/4] test: Drop useless prefix for genericxml2xml test data

2017-12-05 Thread Michal Privoznik
There's no reason for the files to have generic- prefix
since they all live under genericxml2xmlindata and
genericxml2xmloutdata directories.

Signed-off-by: Michal Privoznik 
---
 tests/genericxml2xmltest.c| 4 ++--
 ...-reconnect-invalid-mode.xml => chardev-reconnect-invalid-mode.xml} | 0
 ...nect-missing-timeout.xml => chardev-reconnect-missing-timeout.xml} | 0
 .../{generic-chardev-reconnect.xml => chardev-reconnect.xml}  | 0
 ...eric-chardev-tcp-missing-host.xml => chardev-tcp-missing-host.xml} | 0
 ...hardev-tcp-missing-service.xml => chardev-tcp-missing-service.xml} | 0
 ...hardev-tcp-multiple-source.xml => chardev-tcp-multiple-source.xml} | 0
 .../genericxml2xmlindata/{generic-chardev-tcp.xml => chardev-tcp.xml} | 0
 ...ng-connect-service.xml => chardev-udp-missing-connect-service.xml} | 0
 ...hardev-udp-multiple-source.xml => chardev-udp-multiple-source.xml} | 0
 .../genericxml2xmlindata/{generic-chardev-udp.xml => chardev-udp.xml} | 0
 ...dirdev-missing-path.xml => chardev-unix-redirdev-missing-path.xml} | 0
 ...ev-unix-rng-missing-path.xml => chardev-unix-rng-missing-path.xml} | 0
 ...tcard-missing-path.xml => chardev-unix-smartcard-missing-path.xml} | 0
 .../{generic-chardev-unix.xml => chardev-unix.xml}| 0
 .../{generic-cpu-cache-disable.xml => cpu-cache-disable.xml}  | 0
 .../{generic-cpu-cache-emulate.xml => cpu-cache-emulate.xml}  | 0
 .../{generic-cpu-cache-passthrough.xml => cpu-cache-passthrough.xml}  | 0
 .../{generic-disk-network-http.xml => disk-network-http.xml}  | 0
 .../genericxml2xmlindata/{generic-disk-virtio.xml => disk-virtio.xml} | 0
 ...k-compat-mismatch.xml => graphics-listen-back-compat-mismatch.xml} | 0
 ...raphics-listen-back-compat.xml => graphics-listen-back-compat.xml} | 0
 ...eric-graphics-vnc-autoport-no.xml => graphics-vnc-autoport-no.xml} | 0
 ...ics-vnc-listen-attr-only.xml => graphics-vnc-listen-attr-only.xml} | 0
 ...en-element-minimal.xml => graphics-vnc-listen-element-minimal.xml} | 0
 ...-with-address.xml => graphics-vnc-listen-element-with-address.xml} | 0
 ...eric-graphics-vnc-manual-port.xml => graphics-vnc-manual-port.xml} | 0
 .../{generic-graphics-vnc-minimal.xml => graphics-vnc-minimal.xml}| 0
 ...listen-address.xml => graphics-vnc-socket-attr-listen-address.xml} | 0
 ...smatch.xml => graphics-vnc-socket-attr-listen-socket-mismatch.xml} | 0
 ...r-listen-socket.xml => graphics-vnc-socket-attr-listen-socket.xml} | 0
 ...-graphics-vnc-socket-listen.xml => graphics-vnc-socket-listen.xml} | 0
 .../{generic-graphics-vnc-socket.xml => graphics-vnc-socket.xml}  | 0
 .../{generic-name-slash-fail.xml => name-slash-fail.xml}  | 0
 tests/genericxml2xmlindata/{generic-perf.xml => perf.xml} | 0
 .../{generic-vcpus-individual.xml => vcpus-individual.xml}| 0
 .../{generic-chardev-reconnect.xml => chardev-reconnect.xml}  | 0
 .../{generic-chardev-tcp.xml => chardev-tcp.xml}  | 0
 .../{generic-chardev-udp.xml => chardev-udp.xml}  | 0
 .../{generic-chardev-unix.xml => chardev-unix.xml}| 0
 .../{generic-disk-virtio.xml => disk-virtio.xml}  | 0
 ...raphics-listen-back-compat.xml => graphics-listen-back-compat.xml} | 0
 ...ics-vnc-listen-attr-only.xml => graphics-vnc-listen-attr-only.xml} | 0
 ...en-element-minimal.xml => graphics-vnc-listen-element-minimal.xml} | 0
 ...-with-address.xml => graphics-vnc-listen-element-with-address.xml} | 0
 ...eric-graphics-vnc-manual-port.xml => graphics-vnc-manual-port.xml} | 0
 .../{generic-graphics-vnc-minimal.xml => graphics-vnc-minimal.xml}| 0
 ...listen-address.xml => graphics-vnc-socket-attr-listen-address.xml} | 0
 ...r-listen-socket.xml => graphics-vnc-socket-attr-listen-socket.xml} | 0
 ...-graphics-vnc-socket-listen.xml => graphics-vnc-socket-listen.xml} | 0
 .../{generic-graphics-vnc-socket.xml => graphics-vnc-socket.xml}  | 0
 51 files changed, 2 insertions(+), 2 deletions(-)
 rename tests/genericxml2xmlindata/{generic-chardev-reconnect-invalid-mode.xml 
=> chardev-reconnect-invalid-mode.xml} (100%)
 rename 
tests/genericxml2xmlindata/{generic-chardev-reconnect-missing-timeout.xml => 
chardev-reconnect-missing-timeout.xml} (100%)
 rename tests/genericxml2xmlindata/{generic-chardev-reconnect.xml => 
chardev-reconnect.xml} (100%)
 rename tests/genericxml2xmlindata/{generic-chardev-tcp-missing-host.xml => 
chardev-tcp-missing-host.xml} (100%)
 rename tests/genericxml2xmlindata/{generic-chardev-tcp-missing-service.xml => 
chardev-tcp-missing-service.xml} (100%)
 rename tests/genericxml2xmlindata/{generic-chardev-tcp-multiple-source.xml => 
chardev-tcp-multiple-source.xml} (100%)
 rename tests/genericxml2xmlindata/{generic-chardev-tcp.xml => chardev-tcp.xml} 
(100%)
 rename 
tests/genericxml2xmlindata/{generic-chardev-udp-missing-connect-service.xml => 
chardev-udp-missing-connect-service.xml} (100%)

[libvirt] [PATCH 2/4] test: Drop useless prefix for qemuargv2xml test data

2017-12-05 Thread Michal Privoznik
There's no reason for the files to have qemuargv2xml- prefix
since they all live under qemuargv2xmldata directory.

Signed-off-by: Michal Privoznik 
---
 tests/qemuargv2xmltest.c  | 4 ++--
 .../{qemuargv2xml-boot-cdrom.args => boot-cdrom.args} | 0
 .../qemuargv2xmldata/{qemuargv2xml-boot-cdrom.xml => boot-cdrom.xml}  | 0
 .../{qemuargv2xml-boot-floppy.args => boot-floppy.args}   | 0
 .../{qemuargv2xml-boot-floppy.xml => boot-floppy.xml} | 0
 .../{qemuargv2xml-boot-network.args => boot-network.args} | 0
 .../{qemuargv2xml-boot-network.xml => boot-network.xml}   | 0
 .../{qemuargv2xml-clock-localtime.args => clock-localtime.args}   | 0
 .../{qemuargv2xml-clock-localtime.xml => clock-localtime.xml} | 0
 .../qemuargv2xmldata/{qemuargv2xml-clock-utc.args => clock-utc.args}  | 0
 tests/qemuargv2xmldata/{qemuargv2xml-clock-utc.xml => clock-utc.xml}  | 0
 .../{qemuargv2xml-console-compat.args => console-compat.args} | 0
 .../{qemuargv2xml-console-compat.xml => console-compat.xml}   | 0
 .../{qemuargv2xml-disk-cdrom-empty.args => disk-cdrom-empty.args} | 0
 .../{qemuargv2xml-disk-cdrom-empty.xml => disk-cdrom-empty.xml}   | 0
 .../{qemuargv2xml-disk-cdrom.args => disk-cdrom.args} | 0
 .../qemuargv2xmldata/{qemuargv2xml-disk-cdrom.xml => disk-cdrom.xml}  | 0
 ...argv2xml-disk-drive-boot-cdrom.args => disk-drive-boot-cdrom.args} | 0
 ...muargv2xml-disk-drive-boot-cdrom.xml => disk-drive-boot-cdrom.xml} | 0
 ...muargv2xml-disk-drive-boot-disk.args => disk-drive-boot-disk.args} | 0
 ...qemuargv2xml-disk-drive-boot-disk.xml => disk-drive-boot-disk.xml} | 0
 ...k-drive-cache-directsync.args => disk-drive-cache-directsync.args} | 0
 ...isk-drive-cache-directsync.xml => disk-drive-cache-directsync.xml} | 0
 ...2xml-disk-drive-cache-unsafe.args => disk-drive-cache-unsafe.args} | 0
 ...gv2xml-disk-drive-cache-unsafe.xml => disk-drive-cache-unsafe.xml} | 0
 ...ml-disk-drive-cache-v2-none.args => disk-drive-cache-v2-none.args} | 0
 ...2xml-disk-drive-cache-v2-none.xml => disk-drive-cache-v2-none.xml} | 0
 ...gv2xml-disk-drive-cache-v2-wb.args => disk-drive-cache-v2-wb.args} | 0
 ...argv2xml-disk-drive-cache-v2-wb.xml => disk-drive-cache-v2-wb.xml} | 0
 ...gv2xml-disk-drive-cache-v2-wt.args => disk-drive-cache-v2-wt.args} | 0
 ...argv2xml-disk-drive-cache-v2-wt.xml => disk-drive-cache-v2-wt.xml} | 0
 ...ror-policy-enospace.args => disk-drive-error-policy-enospace.args} | 0
 ...error-policy-enospace.xml => disk-drive-error-policy-enospace.xml} | 0
 ...drive-error-policy-stop.args => disk-drive-error-policy-stop.args} | 0
 ...k-drive-error-policy-stop.xml => disk-drive-error-policy-stop.xml} | 0
 ...port-rignore.args => disk-drive-error-policy-wreport-rignore.args} | 0
 ...report-rignore.xml => disk-drive-error-policy-wreport-rignore.xml} | 0
 ...qemuargv2xml-disk-drive-fmt-qcow.args => disk-drive-fmt-qcow.args} | 0
 .../{qemuargv2xml-disk-drive-fmt-qcow.xml => disk-drive-fmt-qcow.xml} | 0
 ...isk-drive-network-gluster.args => disk-drive-network-gluster.args} | 0
 ...-disk-drive-network-gluster.xml => disk-drive-network-gluster.xml} | 0
 ...ive-network-iscsi-auth.args => disk-drive-network-iscsi-auth.args} | 0
 ...drive-network-iscsi-auth.xml => disk-drive-network-iscsi-auth.xml} | 0
 ...ml-disk-drive-network-iscsi.args => disk-drive-network-iscsi.args} | 0
 ...2xml-disk-drive-network-iscsi.xml => disk-drive-network-iscsi.xml} | 0
 ...ive-network-nbd-export.args => disk-drive-network-nbd-export.args} | 0
 ...drive-network-nbd-export.xml => disk-drive-network-nbd-export.xml} | 0
 ...k-nbd-ipv6-export.args => disk-drive-network-nbd-ipv6-export.args} | 0
 ...ork-nbd-ipv6-export.xml => disk-drive-network-nbd-ipv6-export.xml} | 0
 ...k-drive-network-nbd-ipv6.args => disk-drive-network-nbd-ipv6.args} | 0
 ...isk-drive-network-nbd-ipv6.xml => disk-drive-network-nbd-ipv6.xml} | 0
 ...k-drive-network-nbd-unix.args => disk-drive-network-nbd-unix.args} | 0
 ...isk-drive-network-nbd-unix.xml => disk-drive-network-nbd-unix.xml} | 0
 ...gv2xml-disk-drive-network-nbd.args => disk-drive-network-nbd.args} | 0
 ...argv2xml-disk-drive-network-nbd.xml => disk-drive-network-nbd.xml} | 0
 ...k-drive-network-rbd-auth.args => disk-drive-network-rbd-auth.args} | 0
 ...isk-drive-network-rbd-auth.xml => disk-drive-network-rbd-auth.xml} | 0
 ...network-rbd-ceph-env.args => disk-drive-network-rbd-ceph-env.args} | 0
 ...e-network-rbd-ceph-env.xml => disk-drive-network-rbd-ceph-env.xml} | 0
 ...k-drive-network-rbd-ipv6.args => disk-drive-network-rbd-ipv6.args} | 0
 ...isk-drive-network-rbd-ipv6.xml => disk-drive-network-rbd-ipv6.xml} | 0
 ...gv2xml-disk-drive-network-rbd.args => disk-drive-network-rbd.args} | 0
 ...argv2xml-disk-drive-network-rbd.xml => disk-drive-network-rbd.xml} | 0
 ...k-drive-network-sheepdog.args => disk-drive-network-sheepdog.args} | 0
 ...isk-drive-network-sheepdog.xml => dis

[libvirt] [PATCH 3/4] test: Drop useless prefix for qemuxml2xmldata test data

2017-12-05 Thread Michal Privoznik
There's no reason for the files to have qemuxml2xmlout- prefix
since they all live under qemuxml2xmloutdata directory.

Signed-off-by: Michal Privoznik 
---
 tests/qemuxml2xmltest.c   | 8 
 ...arch64-aavmf-virtio-mmio.xml => aarch64-aavmf-virtio-mmio.xml} | 0
 ...xml2xmlout-aarch64-gic-default.xml => aarch64-gic-default.xml} | 0
 .../{qemuxml2xmlout-aarch64-gic-host.xml => aarch64-gic-host.xml} | 0
 ...xmlout-aarch64-gic-none-both.xml => aarch64-gic-none-both.xml} | 0
 ...l2xmlout-aarch64-gic-none-tcg.xml => aarch64-gic-none-tcg.xml} | 0
 ...xml2xmlout-aarch64-gic-none-v2.xml => aarch64-gic-none-v2.xml} | 0
 ...xml2xmlout-aarch64-gic-none-v3.xml => aarch64-gic-none-v3.xml} | 0
 .../{qemuxml2xmlout-aarch64-gic-none.xml => aarch64-gic-none.xml} | 0
 .../{qemuxml2xmlout-aarch64-gic-v2.xml => aarch64-gic-v2.xml} | 0
 .../{qemuxml2xmlout-aarch64-gic-v3.xml => aarch64-gic-v3.xml} | 0
 ...muxml2xmlout-aarch64-pci-serial.xml => aarch64-pci-serial.xml} | 0
 ...xmlout-aarch64-video-default.xml => aarch64-video-default.xml} | 0
 ...-video-virtio-gpu-pci.xml => aarch64-video-virtio-gpu-pci.xml} | 0
 ...ch64-virtio-pci-default.xml => aarch64-virtio-pci-default.xml} | 0
 ...nual-addresses.xml => aarch64-virtio-pci-manual-addresses.xml} | 0
 .../{qemuxml2xmlout-acpi-table.xml => acpi-table.xml} | 0
 .../{qemuxml2xmlout-autoindex.xml => autoindex.xml}   | 0
 ...xml2xmlout-balloon-device-auto.xml => balloon-device-auto.xml} | 0
 ...xmlout-balloon-device-period.xml => balloon-device-period.xml} | 0
 ...-bios-nvram-os-interleave.xml => bios-nvram-os-interleave.xml} | 0
 .../{qemuxml2xmlout-bios-nvram.xml => bios-nvram.xml} | 0
 ...lout-blkdeviotune-group-num.xml => blkdeviotune-group-num.xml} | 0
 ...ut-blkdeviotune-max-length.xml => blkdeviotune-max-length.xml} | 0
 .../{qemuxml2xmlout-blkdeviotune-max.xml => blkdeviotune-max.xml} | 0
 .../{qemuxml2xmlout-blkdeviotune.xml => blkdeviotune.xml} | 0
 .../{qemuxml2xmlout-blkiotune-device.xml => blkiotune-device.xml} | 0
 .../{qemuxml2xmlout-blkiotune.xml => blkiotune.xml}   | 0
 .../{qemuxml2xmlout-boot-cdrom.xml => boot-cdrom.xml} | 0
 .../{qemuxml2xmlout-boot-floppy-q35.xml => boot-floppy-q35.xml}   | 0
 .../{qemuxml2xmlout-boot-floppy.xml => boot-floppy.xml}   | 0
 ...isable-with-timeout.xml => boot-menu-disable-with-timeout.xml} | 0
 ...qemuxml2xmlout-boot-menu-disable.xml => boot-menu-disable.xml} | 0
 ...-enable-with-timeout.xml => boot-menu-enable-with-timeout.xml} | 0
 .../{qemuxml2xmlout-boot-multi.xml => boot-multi.xml} | 0
 .../{qemuxml2xmlout-boot-network.xml => boot-network.xml} | 0
 .../{qemuxml2xmlout-boot-order.xml => boot-order.xml} | 0
 ...l2xmlout-bootindex-floppy-q35.xml => bootindex-floppy-q35.xml} | 0
 .../{qemuxml2xmlout-channel-guestfwd.xml => channel-guestfwd.xml} | 0
 ...-channel-unix-source-path.xml => channel-unix-source-path.xml} | 0
 ...xml2xmlout-channel-virtio-auto.xml => channel-virtio-auto.xml} | 0
 ...el-virtio-state-active.xml => channel-virtio-state-active.xml} | 0
 ...irtio-state-inactive.xml => channel-virtio-state-inactive.xml} | 0
 .../{qemuxml2xmlout-channel-virtio.xml => channel-virtio.xml} | 0
 .../{qemuxml2xmlout-chardev-label.xml => chardev-label.xml}   | 0
 .../{qemuxml2xmlout-clock-catchup.xml => clock-catchup.xml}   | 0
 .../{qemuxml2xmlout-clock-localtime.xml => clock-localtime.xml}   | 0
 ...lout-clock-timer-hyperv-rtc.xml => clock-timer-hyperv-rtc.xml} | 0
 .../{qemuxml2xmlout-clock-utc.xml => clock-utc.xml}   | 0
 ...xml2xmlout-console-compat-auto.xml => console-compat-auto.xml} | 0
 .../{qemuxml2xmlout-console-compat.xml => console-compat.xml} | 0
 .../{qemuxml2xmlout-console-compat2.xml => console-compat2.xml}   | 0
 ...xml2xmlout-console-virtio-many.xml => console-virtio-many.xml} | 0
 .../{qemuxml2xmlout-console-virtio.xml => console-virtio.xml} | 0
 ...l2xmlout-controller-usb-order.xml => controller-usb-order.xml} | 0
 ...lout-cpu-check-default-none.xml => cpu-check-default-none.xml} | 0
 ...ut-cpu-check-default-none2.xml => cpu-check-default-none2.xml} | 0
 ...pu-check-default-partial.xml => cpu-check-default-partial.xml} | 0
 ...-check-default-partial2.xml => cpu-check-default-partial2.xml} | 0
 .../{qemuxml2xmlout-cpu-check-full.xml => cpu-check-full.xml} | 0
 .../{qemuxml2xmlout-cpu-check-none.xml => cpu-check-none.xml} | 0
 ...qemuxml2xmlout-cpu-check-partial.xml => cpu-check-partial.xml} | 0
 .../{qemuxml2xmlout-cpu-empty.xml => cpu-empty.xml}   | 0
 .../{qemuxml2xmlout-cpu-eoi-disabled.xml => cpu-eoi-disabled.xml} | 0
 .../{qemuxml2xmlout-cpu-eoi-enabled.xml => cpu-eoi-enabled.xml}   | 0
 ...qemuxml2xmlout-cpu-host-kvmclock.xml => cpu-host-kvmclock.xml} | 0
 ...ut-cpu-host-model-features.xml => cpu-host-model-features.xml} | 0
 ...passthrough-features.xml => cpu-host-passthrough-features.xml} | 0
 .../

[libvirt] [PATCH 0/4] tests: Drop more useless prefixes

2017-12-05 Thread Michal Privoznik
Yet again, trimmed patches, whole patches can be found here:

  https://github.com/zippy2/libvirt/commits/qemuxml2xmldata

Michal Privoznik (4):
  test: Drop useless prefix for qemuagent test data
  test: Drop useless prefix for qemuargv2xml test data
  test: Drop useless prefix for qemuxml2xmldata test data
  test: Drop useless prefix for genericxml2xml test data

 tests/genericxml2xmltest.c| 4 ++--
 tests/qemuagenttest.c | 2 +-
 tests/qemuargv2xmltest.c  | 4 ++--
 tests/qemuxml2xmltest.c   | 8 
 
 684 files changed, 15 insertions(+), 15 deletions(-)

-- 
2.13.6

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


[libvirt] [PATCH 1/4] test: Drop useless prefix for qemuagent test data

2017-12-05 Thread Michal Privoznik
There's no reason for the files to have qemuagent- prefix
since they all live under qemuagentdata directory.

Signed-off-by: Michal Privoznik 
---
 tests/qemuagenttest.c| 2 +-
 tests/qemuagentdata/{qemuagent-fsinfo.xml => fsinfo.xml} | 0
 2 files changed, 1 insertion(+), 1 deletion(-)
 rename tests/qemuagentdata/{qemuagent-fsinfo.xml => fsinfo.xml} (100%)

diff --git a/tests/qemuagenttest.c b/tests/qemuagenttest.c
index 8d7aaf8a6..f214eb461 100644
--- a/tests/qemuagenttest.c
+++ b/tests/qemuagenttest.c
@@ -180,7 +180,7 @@ testQemuAgentGetFSInfo(const void *data)
 if (!test)
 return -1;
 
-if (virAsprintf(&domain_filename, "%s/qemuagentdata/qemuagent-fsinfo.xml",
+if (virAsprintf(&domain_filename, "%s/qemuagentdata/fsinfo.xml",
 abs_srcdir) < 0)
 goto cleanup;
 
diff --git a/tests/qemuagentdata/qemuagent-fsinfo.xml 
b/tests/qemuagentdata/fsinfo.xml
similarity index 100%
rename from tests/qemuagentdata/qemuagent-fsinfo.xml
rename to tests/qemuagentdata/fsinfo.xml
-- 
2.13.6

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


Re: [libvirt] [PATCH 0/4] tests: Drop more useless prefixes

2017-12-05 Thread Ján Tomko

On Tue, Dec 05, 2017 at 09:01:15AM +0100, Michal Privoznik wrote:

Yet again, trimmed patches, whole patches can be found here:

 https://github.com/zippy2/libvirt/commits/qemuxml2xmldata

Michal Privoznik (4):
 test: Drop useless prefix for qemuagent test data
 test: Drop useless prefix for qemuargv2xml test data
 test: Drop useless prefix for qemuxml2xmldata test data
 test: Drop useless prefix for genericxml2xml test data

tests/genericxml2xmltest.c| 4 ++--
tests/qemuagenttest.c | 2 +-
tests/qemuargv2xmltest.c  | 4 ++--
tests/qemuxml2xmltest.c   | 8 

684 files changed, 15 insertions(+), 15 deletions(-)



ACK series

Jan


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

[libvirt] [sandbox 4/6] service: fix bad ConfigMountHostImage constructor call

2017-12-05 Thread Cédric Bosdonnat
Since commit 68406aff8 ConfigMountHostImage needs a format parameter,
virt-sandbox-service needs to fit the new API.
---
 bin/virt-sandbox-service | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/bin/virt-sandbox-service b/bin/virt-sandbox-service
index 45f4517..c34c6f3 100755
--- a/bin/virt-sandbox-service
+++ b/bin/virt-sandbox-service
@@ -20,6 +20,8 @@
 #
 
 import gi
+gi.require_version('LibvirtGConfig', '1.0')
+from gi.repository import LibvirtGConfig
 gi.require_version('LibvirtGObject', '1.0')
 from gi.repository import LibvirtGObject
 gi.require_version('LibvirtSandbox', '1.0')
@@ -223,7 +225,8 @@ class Container:
 def gen_filesystems(self):
 if self.use_image:
 self.image = self.DEFAULT_IMAGE % self.get_name()
-mount = LibvirtSandbox.ConfigMountHostImage.new(self.image, 
self.dest)
+mount = LibvirtSandbox.ConfigMountHostImage.new(self.image, 
self.dest,
+
LibvirtGConfig.DomainDiskFormat.RAW)
 self.config.add_mount(mount)
 
 def fix_stat(self, f):
-- 
2.15.1

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


[libvirt] [sandbox 2/6] machine: use squash security mode for non-root virt-sandbox mounts

2017-12-05 Thread Cédric Bosdonnat
When running virt-sandbox as a user with host-bind mount, the user
can't write in the mounted folder. If run as root, use passthrough
security mode, otherwise use squashed one to fix this.
---
 libvirt-sandbox/libvirt-sandbox-builder-machine.c | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/libvirt-sandbox/libvirt-sandbox-builder-machine.c 
b/libvirt-sandbox/libvirt-sandbox-builder-machine.c
index 7204f71..b6f2218 100644
--- a/libvirt-sandbox/libvirt-sandbox-builder-machine.c
+++ b/libvirt-sandbox/libvirt-sandbox-builder-machine.c
@@ -589,7 +589,10 @@ static gboolean 
gvir_sandbox_builder_machine_construct_devices(GVirSandboxBuilde
 
 fs = gvir_config_domain_filesys_new();
 gvir_config_domain_filesys_set_type(fs, 
GVIR_CONFIG_DOMAIN_FILESYS_MOUNT);
-gvir_config_domain_filesys_set_access_type(fs, 
GVIR_CONFIG_DOMAIN_FILESYS_ACCESS_PASSTHROUGH);
+if (getuid() == 0)
+gvir_config_domain_filesys_set_access_type(fs, 
GVIR_CONFIG_DOMAIN_FILESYS_ACCESS_PASSTHROUGH);
+else
+gvir_config_domain_filesys_set_access_type(fs, 
GVIR_CONFIG_DOMAIN_FILESYS_ACCESS_SQUASH);
 gvir_config_domain_filesys_set_source(fs,
   
gvir_sandbox_config_mount_file_get_source(mfile));
 gvir_config_domain_filesys_set_target(fs, target);
-- 
2.15.1

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


[libvirt] [sandbox 0/6] Misc patches

2017-12-05 Thread Cédric Bosdonnat
Hi all,

Here are a few patches I found sitting on my local copy. I also added a
few patches to convert to python3.

Cédric Bosdonnat (6):
  Pass debug and verbose values to init
  machine: use squash security mode  for non-root virt-sandbox mounts
  Add tests .log and .trs files to gitignore
  service: fix bad ConfigMountHostImage constructor call
  Convert to python3
  Don't hardcode interpreter path

 .gitignore|  2 +
 bin/virt-sandbox-image|  2 +-
 bin/virt-sandbox-service  | 75 +--
 bin/virt-sandbox.c|  3 +
 examples/demo.py  |  2 +-
 examples/shell.py |  2 +-
 examples/virt-sandbox-mkinitrd.py |  2 +-
 examples/virt-sandbox.py  |  2 +-
 libvirt-sandbox/image/cli.py  | 20 +++---
 libvirt-sandbox/image/sources/base.py |  1 -
 libvirt-sandbox/image/sources/docker.py   | 42 ++---
 libvirt-sandbox/image/sources/virtbuilder.py  |  1 -
 libvirt-sandbox/image/template.py |  8 +--
 libvirt-sandbox/libvirt-sandbox-builder-machine.c |  5 +-
 libvirt-sandbox/libvirt-sandbox-config.c  | 75 +++
 libvirt-sandbox/libvirt-sandbox-config.h  |  6 ++
 libvirt-sandbox/libvirt-sandbox-init-common.c |  3 +
 libvirt-sandbox/libvirt-sandbox.sym   |  4 ++
 18 files changed, 179 insertions(+), 76 deletions(-)

-- 
2.15.1

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

[libvirt] [sandbox 1/6] Pass debug and verbose values to init

2017-12-05 Thread Cédric Bosdonnat
libvirt-sandbox-init-common is expecting -d and -v parameters to
set it in debug or verbose mode... but those will never be passed
by the launcher program.

Writing the core.debug and core.verbose parameters in the sandbox
configuration makes those values actually usable from the init.
---
 bin/virt-sandbox.c|  3 ++
 libvirt-sandbox/libvirt-sandbox-config.c  | 75 +++
 libvirt-sandbox/libvirt-sandbox-config.h  |  6 +++
 libvirt-sandbox/libvirt-sandbox-init-common.c |  3 ++
 libvirt-sandbox/libvirt-sandbox.sym   |  4 ++
 5 files changed, 91 insertions(+)

diff --git a/bin/virt-sandbox.c b/bin/virt-sandbox.c
index 3058013..6032562 100644
--- a/bin/virt-sandbox.c
+++ b/bin/virt-sandbox.c
@@ -273,6 +273,9 @@ int main(int argc, char **argv) {
 if (shell)
 gvir_sandbox_config_set_shell(cfg, TRUE);
 
+gvir_sandbox_config_set_debug(cfg, debug);
+gvir_sandbox_config_set_verbose(cfg, verbose);
+
 if (isatty(STDIN_FILENO))
 gvir_sandbox_config_interactive_set_tty(icfg, TRUE);
 
diff --git a/libvirt-sandbox/libvirt-sandbox-config.c 
b/libvirt-sandbox/libvirt-sandbox-config.c
index 8709736..73a0fa4 100644
--- a/libvirt-sandbox/libvirt-sandbox-config.c
+++ b/libvirt-sandbox/libvirt-sandbox-config.c
@@ -68,6 +68,9 @@ struct _GVirSandboxConfigPrivate
 
 gchar *secLabel;
 gboolean secDynamic;
+
+gboolean debug;
+gboolean verbose;
 };
 
 G_DEFINE_ABSTRACT_TYPE(GVirSandboxConfig, gvir_sandbox_config, G_TYPE_OBJECT);
@@ -1926,6 +1929,59 @@ gboolean 
gvir_sandbox_config_set_security_opts(GVirSandboxConfig *config,
 return ret;
 }
 
+/**
+ * gvir_sandbox_config_set_debug:
+ * @config: (transfer none): the sandbox config
+ * @debug: true if the container init should print debugging messages
+ *
+ * Set whether the container init should print debugging messages.
+ */
+void gvir_sandbox_config_set_debug(GVirSandboxConfig *config, gboolean debug)
+{
+GVirSandboxConfigPrivate *priv = config->priv;
+priv->debug = debug;
+}
+
+/**
+ * gvir_sandbox_config_get_debug:
+ * @config: (transfer none): the sandbox config
+ *
+ * Retrieves the sandbox debug flag
+ *
+ * Returns: the debug flag
+ */
+gboolean gvir_sandbox_config_get_debug(GVirSandboxConfig *config)
+{
+GVirSandboxConfigPrivate *priv = config->priv;
+return priv->debug;
+}
+
+/**
+ * gvir_sandbox_config_set_verbose:
+ * @config: (transfer none): the sandbox config
+ * @verbose: true if the container init should be verbose
+ *
+ * Set whether the container init should be verbose.
+ */
+void gvir_sandbox_config_set_verbose(GVirSandboxConfig *config, gboolean 
verbose)
+{
+GVirSandboxConfigPrivate *priv = config->priv;
+priv->verbose = verbose;
+}
+
+/**
+ * gvir_sandbox_config_get_verbose:
+ * @config: (transfer none): the sandbox config
+ *
+ * Retrieves the sandbox verbose flag
+ *
+ * Returns: the verbose flag
+ */
+gboolean gvir_sandbox_config_get_verbose(GVirSandboxConfig *config)
+{
+GVirSandboxConfigPrivate *priv = config->priv;
+return priv->verbose;
+}
 
 static GVirSandboxConfigMount *gvir_sandbox_config_load_config_mount(GKeyFile 
*file,
  guint i,
@@ -2415,6 +2471,22 @@ static gboolean 
gvir_sandbox_config_load_config(GVirSandboxConfig *config,
 priv->secDynamic = b;
 }
 
+b = g_key_file_get_boolean(file, "core", "debug", &e);
+if (e) {
+g_error_free(e);
+e = NULL;
+} else {
+priv->debug = b;
+}
+
+b = g_key_file_get_boolean(file, "core", "verbose", &e);
+if (e) {
+g_error_free(e);
+e = NULL;
+} else {
+priv->verbose = b;
+}
+
 ret = TRUE;
  cleanup:
 return ret;
@@ -2677,6 +2749,9 @@ static void 
gvir_sandbox_config_save_config(GVirSandboxConfig *config,
 if (priv->secLabel)
 g_key_file_set_string(file, "security", "label", priv->secLabel);
 g_key_file_set_boolean(file, "security", "dynamic", priv->secDynamic);
+
+g_key_file_set_boolean(file, "core", "debug", priv->debug);
+g_key_file_set_boolean(file, "core", "verbose", priv->verbose);
 }
 
 
diff --git a/libvirt-sandbox/libvirt-sandbox-config.h 
b/libvirt-sandbox/libvirt-sandbox-config.h
index e5e53f7..8950e25 100644
--- a/libvirt-sandbox/libvirt-sandbox-config.h
+++ b/libvirt-sandbox/libvirt-sandbox-config.h
@@ -180,6 +180,12 @@ gboolean 
gvir_sandbox_config_set_security_opts(GVirSandboxConfig *config,
const gchar *optstr,
GError**error);
 
+void gvir_sandbox_config_set_debug(GVirSandboxConfig *config, gboolean debug);
+gboolean gvir_sandbox_config_get_debug(GVirSandboxConfig *config);
+
+void gvir_sandbox_config_set_verbose(GVirSandboxConfig *config, gboolean 
verbose);
+gboolean gvir_sandbox_config_get_verbose(GVirSandboxConfig *config);
+
 gchar **gvir_sandbox_config_get_command(GV

[libvirt] [sandbox 5/6] Convert to python3

2017-12-05 Thread Cédric Bosdonnat
Python2 is going to die soon, convert to python3.
---
 bin/virt-sandbox-service| 68 ++---
 libvirt-sandbox/image/cli.py| 18 -
 libvirt-sandbox/image/sources/docker.py | 41 ++--
 libvirt-sandbox/image/template.py   |  8 ++--
 4 files changed, 71 insertions(+), 64 deletions(-)

diff --git a/bin/virt-sandbox-service b/bin/virt-sandbox-service
index c34c6f3..e78defb 100755
--- a/bin/virt-sandbox-service
+++ b/bin/virt-sandbox-service
@@ -30,7 +30,6 @@ from gi.repository import GLib
 import gi
 import re
 import os, sys, shutil, errno, stat
-import exceptions
 import rpm
 from subprocess import Popen, PIPE, STDOUT
 import gettext
@@ -49,7 +48,6 @@ gettext.textdomain("libvirt-sandbox")
 try:
 gettext.install("libvirt-sandbox",
 localedir="/usr/share/locale",
-unicode=False,
 codeset = 'utf-8')
 except IOError:
 import __builtin__
@@ -235,7 +233,7 @@ class Container:
 path = "%s%s" % (self.dest, f)
 os.chown(path, s.st_uid, s.st_gid)
 os.chmod(path, s.st_mode)
-except OSError, e:
+except OSError as e:
 if not e.errno == errno.ENOENT:
 raise
 
@@ -253,7 +251,7 @@ class Container:
 try:
 path = "%s%s" % (self.dest, d)
 os.makedirs(path)
-except OSError, e:
+except OSError as e:
 if not e.errno == errno.EEXIST:
 raise
 
@@ -263,7 +261,7 @@ class Container:
 path = "%s%s" % (self.dest, f)
 fd=open(path, "w")
 fd.close()
-except OSError, e:
+except OSError as e:
 if not e.errno == errno.EEXIST:
 raise
 
@@ -404,10 +402,10 @@ class GenericContainer(Container):
 def create(self):
 try:
 self.create_generic()
-except Exception, e:
+except Exception as e:
 try:
 self.delete()
-except Exception, e2:
+except Exception as e2:
 pass
 raise e
 
@@ -418,6 +416,18 @@ class GenericContainer(Container):
 def is_template_unit(unit):
 return '@' in unit
 
+# Python 2 / 3 compability helpers
+def get_next(obj):
+if hasattr(obj, 'next'):
+return obj.next()
+else:
+return next(obj)
+
+def string(obj):
+if isinstance(obj, bytes):
+return str(obj, encoding='utf-8')
+return obj
+
 class SystemdContainer(Container):
 IGNORE_DIRS= [ "/var/run/", "/etc/logrotate.d/", "/etc/pam.d" ]
 DEFAULT_DIRS   = [ "/etc", "/var" ]
@@ -581,8 +591,8 @@ WantedBy=multi-user.target
 def get_rpm_for_unit(self, unitfile):
 mi = self.ts.dbMatch(rpm.RPMTAG_BASENAMES, unitfile)
 try:
-h = mi.next();
-except exceptions.StopIteration:
+h = get_next(mi);
+except StopIteration:
 return None
 return h['name']
 
@@ -590,8 +600,8 @@ WantedBy=multi-user.target
 def extract_rpm(self, rpm_name):
 mi = self.ts.dbMatch('name', rpm_name)
 try:
-h = mi.next();
-except exceptions.StopIteration:
+h = get_next(mi);
+except StopIteration:
 raise ValueError([_("Cannot find package named %s") % rpm_name])
 
 for fentry in h.fiFromHeader():
@@ -602,16 +612,16 @@ WantedBy=multi-user.target
 if os.path.isfile(fname):
 self.add_file(fname)
 
-srcrpm = h[rpm.RPMTAG_SOURCERPM]
+srcrpm = string(h[rpm.RPMTAG_SOURCERPM])
 srcrpmbits = self.split_filename(srcrpm)
 
-if srcrpmbits[0] == h[rpm.RPMTAG_NAME]:
+if srcrpmbits[0] == string(h[rpm.RPMTAG_NAME]):
 return
 
 mi = self.ts.dbMatch(rpm.RPMTAG_NAME, srcrpmbits[0])
 try:
-h = mi.next();
-except exceptions.StopIteration:
+h = get_next(mi);
+except StopIteration:
 raise ValueError([_("Cannot find base package %s") % 
srcrpmbits[0]])
 
 for fentry in h.fiFromHeader():
@@ -771,7 +781,7 @@ PrivateNetwork=false
 fd.write("[Unit]\n")
 fd.write("Description=Sandbox multi-user target\n")
 fd.close()
-except OSError, e:
+except OSError as e:
 if not e.errno == errno.EEXIST:
 raise
 
@@ -789,7 +799,7 @@ PrivateNetwork=false
 jpath = "/var/log/journal/" + uuid
 if os.path.lexists(jpath):
 os.remove(jpath)
-except Exception, e:
+except Exception as e:
 sys.stderr.write("%s: %s\n" % (sys.argv[0], e))
 sys.stderr.flush()
 
@@ -825,10 +835,10 @@ PrivateNetwork=false
 
 try:
 self.create_systemd()
-except Exception, e:
+except Exception as e:
 try:
 self.de

[libvirt] [sandbox 3/6] Add tests .log and .trs files to gitignore

2017-12-05 Thread Cédric Bosdonnat
---
 .gitignore | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/.gitignore b/.gitignore
index 83831bb..c4e2217 100644
--- a/.gitignore
+++ b/.gitignore
@@ -58,3 +58,5 @@ bin/virt-sandbox
 bin/virt-sandbox-service-util
 build/
 bin/*.1
+*.log
+*.trs
-- 
2.15.1

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


[libvirt] [sandbox 6/6] Don't hardcode interpreter path

2017-12-05 Thread Cédric Bosdonnat
This is particularly useful on operating systems that don't ship
Python as part of the base system (eg. FreeBSD) while still working
just as well as it did before on Linux.
---
 bin/virt-sandbox-image   | 2 +-
 bin/virt-sandbox-service | 2 +-
 examples/demo.py | 2 +-
 examples/shell.py| 2 +-
 examples/virt-sandbox-mkinitrd.py| 2 +-
 examples/virt-sandbox.py | 2 +-
 libvirt-sandbox/image/cli.py | 2 +-
 libvirt-sandbox/image/sources/base.py| 1 -
 libvirt-sandbox/image/sources/docker.py  | 1 -
 libvirt-sandbox/image/sources/virtbuilder.py | 1 -
 10 files changed, 7 insertions(+), 10 deletions(-)

diff --git a/bin/virt-sandbox-image b/bin/virt-sandbox-image
index 7e0d76b..61346ef 100755
--- a/bin/virt-sandbox-image
+++ b/bin/virt-sandbox-image
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/env python3
 # -*- coding: utf-8 -*-
 
 from libvirt_sandbox.image import cli
diff --git a/bin/virt-sandbox-service b/bin/virt-sandbox-service
index e78defb..b06f304 100755
--- a/bin/virt-sandbox-service
+++ b/bin/virt-sandbox-service
@@ -1,4 +1,4 @@
-#!/usr/bin/python -Es
+#!/usr/bin/env python3
 #
 # Authors: Dan Walsh 
 #
diff --git a/examples/demo.py b/examples/demo.py
index 6252194..c61b091 100755
--- a/examples/demo.py
+++ b/examples/demo.py
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/env python3
 
 from gi.repository import LibvirtGObject
 from gi.repository import LibvirtSandbox
diff --git a/examples/shell.py b/examples/shell.py
index 317d13e..86b2159 100755
--- a/examples/shell.py
+++ b/examples/shell.py
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/env python3
 
 from gi.repository import LibvirtGObject
 from gi.repository import LibvirtSandbox
diff --git a/examples/virt-sandbox-mkinitrd.py 
b/examples/virt-sandbox-mkinitrd.py
index 76df925..74d1b00 100755
--- a/examples/virt-sandbox-mkinitrd.py
+++ b/examples/virt-sandbox-mkinitrd.py
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/env python3
 
 from gi.repository import LibvirtGObject
 from gi.repository import LibvirtSandbox
diff --git a/examples/virt-sandbox.py b/examples/virt-sandbox.py
index 922ad00..e4ed6e7 100755
--- a/examples/virt-sandbox.py
+++ b/examples/virt-sandbox.py
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/env python3
 
 from gi.repository import LibvirtGObject
 from gi.repository import LibvirtSandbox
diff --git a/libvirt-sandbox/image/cli.py b/libvirt-sandbox/image/cli.py
index fa3cace..490c5e0 100644
--- a/libvirt-sandbox/image/cli.py
+++ b/libvirt-sandbox/image/cli.py
@@ -1,4 +1,4 @@
-#!/usr/bin/python -Es
+#!/usr/bin/env python3
 # -*- coding: utf-8 -*-
 # Authors: Daniel P. Berrange 
 #  Eren Yagdiran 
diff --git a/libvirt-sandbox/image/sources/base.py 
b/libvirt-sandbox/image/sources/base.py
index e4e4e41..0fc9243 100644
--- a/libvirt-sandbox/image/sources/base.py
+++ b/libvirt-sandbox/image/sources/base.py
@@ -1,4 +1,3 @@
-#!/usr/bin/python
 # -*- coding: utf-8 -*-
 #
 # Copyright (C) 2015 Universitat Politècnica de Catalunya.
diff --git a/libvirt-sandbox/image/sources/docker.py 
b/libvirt-sandbox/image/sources/docker.py
index e979054..eaf41fc 100755
--- a/libvirt-sandbox/image/sources/docker.py
+++ b/libvirt-sandbox/image/sources/docker.py
@@ -1,4 +1,3 @@
-#!/usr/bin/python
 # -*- coding: utf-8 -*-
 #
 # Copyright (C) 2015 Universitat Politècnica de Catalunya.
diff --git a/libvirt-sandbox/image/sources/virtbuilder.py 
b/libvirt-sandbox/image/sources/virtbuilder.py
index 6bd9695..1b32083 100755
--- a/libvirt-sandbox/image/sources/virtbuilder.py
+++ b/libvirt-sandbox/image/sources/virtbuilder.py
@@ -1,4 +1,3 @@
-#!/usr/bin/python
 #
 # Copyright (C) 2015 SUSE LLC
 #
-- 
2.15.1

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

Re: [libvirt] [PATCH 1/3] util: gettid() is Linux-specific

2017-12-05 Thread Daniel P. Berrange
On Mon, Dec 04, 2017 at 05:23:45PM +0100, Andrea Bolognani wrote:
> The manual page clearly states that
> 
>   gettid() is Linux-specific and should not be used in programs
>   that are intended to be portable.
> 
> Unfortunately, it looks like macOS implemented the functionality
> and defined SYS_gettid accordingly, only to deprecate syscall()
> altogether with 10.12 (Sierra), released last late year.
> 
> To avoid compilation errors, call gettid() on Linux only.
> 
> Signed-off-by: Andrea Bolognani 
> ---
>  src/util/virthread.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/src/util/virthread.c b/src/util/virthread.c
> index 6c495158f..05b5572f5 100644
> --- a/src/util/virthread.c
> +++ b/src/util/virthread.c
> @@ -268,7 +268,7 @@ bool virThreadIsSelf(virThreadPtr thread)
>   * the pthread_self() id on Linux.  */
>  unsigned long long virThreadSelfID(void)
>  {
> -#if defined(HAVE_SYS_SYSCALL_H) && defined(SYS_gettid)
> +#if defined(HAVE_SYS_SYSCALL_H) && defined(SYS_gettid) && defined(__linux__)
>  pid_t tid = syscall(SYS_gettid);
>  return tid;
>  #else

Reviewed-by: Daniel P. Berrange 


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 2/3] travis: Upgrade brew packages

2017-12-05 Thread Daniel P. Berrange
On Mon, Dec 04, 2017 at 05:23:46PM +0100, Andrea Bolognani wrote:
> Installed packages might be outdated by the time the build
> runs, so we should update them.
> 
> Signed-off-by: Andrea Bolognani 
> ---
>  .travis.yml | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/.travis.yml b/.travis.yml
> index 480419dfd..70fee3b6a 100644
> --- a/.travis.yml
> +++ b/.travis.yml
> @@ -88,7 +88,7 @@ env:
>  - VIR_TEST_DEBUG=1
>  
>  before_install:
> -  - if [ "$TRAVIS_OS_NAME" == "osx" ]; then brew update && brew install 
> gnutls libgcrypt yajl gettext rpcgen; fi
> +  - if [ "$TRAVIS_OS_NAME" == "osx" ]; then brew update && brew upgrade && 
> brew install gnutls libgcrypt yajl gettext rpcgen; fi
>  
>  before_script:
>- ./autogen.sh

Reviewed-by: Daniel P. Berrange 

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 3/3] travis: Don't try to install brew packages twice

2017-12-05 Thread Daniel P. Berrange
On Mon, Dec 04, 2017 at 05:23:47PM +0100, Andrea Bolognani wrote:
> gettext, gnutls and libgcrypt are already installed on the
> system, so we don't need to request their installation.
> 
> Signed-off-by: Andrea Bolognani 
> ---
>  .travis.yml | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/.travis.yml b/.travis.yml
> index 70fee3b6a..bef991cb9 100644
> --- a/.travis.yml
> +++ b/.travis.yml
> @@ -88,7 +88,7 @@ env:
>  - VIR_TEST_DEBUG=1
>  
>  before_install:
> -  - if [ "$TRAVIS_OS_NAME" == "osx" ]; then brew update && brew upgrade && 
> brew install gnutls libgcrypt yajl gettext rpcgen; fi
> +  - if [ "$TRAVIS_OS_NAME" == "osx" ]; then brew update && brew upgrade && 
> brew install rpcgen yajl; fi
>  
>  before_script:
>- ./autogen.sh

Reviewed-by: Daniel P. Berrange 

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


[libvirt] [PATCH] maint: Bump version number to 4.0.0

2017-12-05 Thread Andrea Bolognani
As documented in

  https://libvirt.org/downloads.html#schedule
  https://libvirt.org/downloads.html#numbering

the next release will happen in the middle of January 2018 and,
being the first release of a new year, will bring a brand new
major version number with it.

Signed-off-by: Andrea Bolognani 
---
Pushed under the "I can't believe you got it wrong, Michal!" rule.

 configure.ac  | 2 +-
 docs/news.xml | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/configure.ac b/configure.ac
index ec98e83d7..fba4e4bf5 100644
--- a/configure.ac
+++ b/configure.ac
@@ -16,7 +16,7 @@ dnl You should have received a copy of the GNU Lesser General 
Public
 dnl License along with this library.  If not, see
 dnl .
 
-AC_INIT([libvirt], [3.11.0], [libvir-list@redhat.com], [], 
[https://libvirt.org])
+AC_INIT([libvirt], [4.0.0], [libvir-list@redhat.com], [], 
[https://libvirt.org])
 AC_CONFIG_SRCDIR([src/libvirt.c])
 AC_CONFIG_AUX_DIR([build-aux])
 AC_CONFIG_HEADERS([config.h])
diff --git a/docs/news.xml b/docs/news.xml
index 72bdea220..0ec9857e2 100644
--- a/docs/news.xml
+++ b/docs/news.xml
@@ -33,7 +33,7 @@
  -->
 
 
-  
+  
 
 
 
-- 
2.14.3

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


Re: [libvirt] [[RFC] 0/8] Implement async QEMU event handling in libvirtd.

2017-12-05 Thread Prerna
I spent a while trying to work through this proposal, here are a few points
which need more thought:

On Wed, Nov 8, 2017 at 7:22 PM, Daniel P. Berrange 
wrote:

> On Mon, Nov 06, 2017 at 06:43:12AM +0100, Prerna wrote:
> > Thanks for your reply Daniel. I am still on vacation all of this week so
> > have not been able to respond.
> > Few questions inline:
> >
> > On Thu, Oct 26, 2017 at 2:43 PM, Daniel P. Berrange  >
> > wrote:
> >
> > > On Tue, Oct 24, 2017 at 10:34:53AM -0700, Prerna Saxena wrote:
> > > >
> > > > As noted in
> > > > https://www.redhat.com/archives/libvir-list/2017-May/msg00016.html
> > > > libvirt-QEMU driver handles all async events from the main loop.
> > > > Each event handling needs the per-VM lock to make forward progress.
> In
> > > > the case where an async event is received for the same VM which has
> an
> > > > RPC running, the main loop is held up contending for the same lock.
> > > >
> > > > This impacts scalability, and should be addressed on priority.
> > > >
> > > > Note that libvirt does have a 2-step deferred handling for a few
> event
> > > > categories, but (1) That is insufficient since blockign happens
> before
> > > > the handler could disambiguate which one needs to be posted to this
> > > > other queue.
> > > > (2) There needs to be homogeniety.
> > > >
> > > > The current series builds a framework for recording and handling VM
> > > > events.
> > > > It initializes per-VM event queue, and a global event queue pointing
> to
> > > > events from all the VMs. Event handling is staggered in 2 stages:
> > > > - When an event is received, it is enqueued in the per-VM queue as
> well
> > > >   as the global queues.
> > > > - The global queue is built into the QEMU Driver as a threadpool
> > > >   (currently with a single thread).
> > > > - Enqueuing of a new event triggers the global event worker thread,
> which
> > > >   then attempts to take a lock for this event's VM.
> > > > - If the lock is available, the event worker runs the function
> > > handling
> > > >   this event type. Once done, it dequeues this event from the
> global
> > > >   as well as per-VM queues.
> > > > - If the lock is unavailable(ie taken by RPC thread), the event
> > > worker
> > > >   thread leaves this as-is and picks up the next event.
> > > > - Once the RPC thread completes, it looks for events pertaining to
> the
> > > >   VM in the per-VM event queue. It then processes the events serially
> > > >   (holding the VM lock) until there are no more events remaining for
> > > >   this VM. At this point, the per-VM lock is relinquished.
> > >
> > > One of the nice aspects of processing the QEMU events in the main event
> > > loop is that handling of them is self-throttling. ie if one QEMU
> process
> > > goes mental and issues lots of events, we'll spend alot of time
> processing
> > > them all, but our memory usage is still bounded.
> > >
> > > If we take events from the VM and put them on a queue that is processed
> > > asynchronously, and the event processing thread gets stuck for some
> > > reason, then libvirt will end up queuing an unbounded number of events.
> > > This could cause considerable memory usage in libvirt. This could be
> > > exploited by a malicious VM to harm libvirt. eg a malicious QEMU could
> > > stop responding to monitor RPC calls, which would tie up the RPC
> threads
> > > and handling of RPC calls. This would in turn prevent events being
> > > processed due to being unable to acquire the state lock.  Now the VM
> > > can flood libvirtd with events which will all be read off the wire
> > > and queued in memory, potentially forever. So libvirt memory usage
> > > will balloon to an arbitrary level.
> > >
> > > Now, the current code isn't great when faced with malicious QEMU
> > > because with the same approach, QEMU can cause libvirtd main event
> > > loop to stall as you found. This feels less bad than unbounded
> > > memory usage though - if libvirt uses lots of memory, this will
> > > push other apps on the host into swap, and/or trigger the OOM
> > > killer.
> > >
> > > So I agree that we need to make event processing asynchronous from
> > > the main loop. When doing that through, I think we need to put an
> > > upper limit on the number of events we're willing to queue from a
> > > VM. When we get that limit, we should update the monitor event loop
> > > watch so that we stop reading further events, until existing events
> > > have been processed.
> >
> > We can update the watch at the monitor socket level. Ie, if we have hit
> > threshold limits reading events off the monitor socket, we ignore this
> > socket FD going forward. Now, this also means that we will miss any
> replies
> > coming off the same socket. It will mean that legitimate RPC replies
> coming
> > off the same socket will get ignored too. And in this case, we deadlock,
> > since event notifications will not be processed until the ongoing RPC
> > completes.
>
> An RPC waiting for a 

[libvirt] [REBASE PATCH v2 00/10] Implement query-dump command

2017-12-05 Thread John Ferlan
Original v2:
https://www.redhat.com/archives/libvir-list/2017-November/msg00779.html

Rebase due to additional capabilitiies

v2 Cover:
v1: https://www.redhat.com/archives/libvir-list/2017-November/msg00731.html

Differences from v1 (besides more patches)

Rather than use a timing loop in order to fetch the dump stats and
the presence of the 'query-dump' command, let's use the DUMP_COMPLETED
event and wire that up in order to determine when the dump has been
completed. In the mean time, the previous timing loop is converted into
a qemuDomainGetJobInfoDumpStats to be called if the "right conditions"
exist.  Also found/fixed a couple of minor issues from v1 regarding
usage "dumpformat" instead of just "format" from my patch 2 adjustment
and a type for qemuMonitorDumpStatus (was qemuMontiorDumpStatus in v1).


NB: (from v1 cover):

Details in the patches. Essentially though QEMU 2.6 added the ability
to perform the 'dump-guest-memory' via a thread by adding a 'detach'
boolean to the command. In order to watch the progress of the thread
the 'query-dump' command was added. The query-dump will return just
the current status, the total size to be dumped, and the current
progress. So using the migrate stats data in the DomainJobInfo we
can then save our current progress allowing tools such as virsh to
watch that progress.  As an added benefit, the dump-guest-memory is
now truly asynchronous.


John Ferlan (10):
  qemu: Clean up style for the qemuDumpToFd definition
  qemu: Alter dump-guest-memory command generation
  qemu: Add support for DUMP_COMPLETED event
  qemu: Introduce qemuProcessHandleDumpCompleted
  qemu: Introduce qemuMonitor[JSON]QueryDump
  qemu: Add new parameter to qemuMonitorDumpToFd
  qemu: Introduce qemuDomainGetJobInfoMigrationStats
  qemu: Introduce qemuDomainGetJobInfoDumpStats
  qemu: Add dump completed event to the capabilities
  qemu: Allow showing the dump progress for memory only dump

 src/qemu/qemu_capabilities.c   |   2 +
 src/qemu/qemu_capabilities.h   |   1 +
 src/qemu/qemu_domain.c |   2 +
 src/qemu/qemu_domain.h |   2 +
 src/qemu/qemu_driver.c | 157 ++---
 src/qemu/qemu_monitor.c|  39 -
 src/qemu/qemu_monitor.h|  33 -
 src/qemu/qemu_monitor_json.c   | 122 ++--
 src/qemu/qemu_monitor_json.h   |   7 +-
 src/qemu/qemu_process.c|  23 +++
 .../caps_2.10.0-gicv2.aarch64.xml  |   1 +
 .../caps_2.10.0-gicv3.aarch64.xml  |   1 +
 tests/qemucapabilitiesdata/caps_2.10.0.ppc64.xml   |   1 +
 tests/qemucapabilitiesdata/caps_2.10.0.s390x.xml   |   1 +
 tests/qemucapabilitiesdata/caps_2.10.0.x86_64.xml  |   1 +
 .../caps_2.6.0-gicv2.aarch64.xml   |   1 +
 .../caps_2.6.0-gicv3.aarch64.xml   |   1 +
 tests/qemucapabilitiesdata/caps_2.6.0.ppc64.xml|   1 +
 tests/qemucapabilitiesdata/caps_2.6.0.x86_64.xml   |   1 +
 tests/qemucapabilitiesdata/caps_2.7.0.s390x.xml|   1 +
 tests/qemucapabilitiesdata/caps_2.7.0.x86_64.xml   |   1 +
 tests/qemucapabilitiesdata/caps_2.8.0.s390x.xml|   1 +
 tests/qemucapabilitiesdata/caps_2.8.0.x86_64.xml   |   1 +
 tests/qemucapabilitiesdata/caps_2.9.0.ppc64.xml|   1 +
 tests/qemucapabilitiesdata/caps_2.9.0.s390x.xml|   1 +
 tests/qemucapabilitiesdata/caps_2.9.0.x86_64.xml   |   1 +
 tests/qemumonitorjsontest.c|   3 +-
 27 files changed, 365 insertions(+), 42 deletions(-)

-- 
2.13.6

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


[libvirt] [REBASE PATCH v2 05/10] qemu: Introduce qemuMonitor[JSON]QueryDump

2017-12-05 Thread John Ferlan
Add the query-dump API's in order to allow the dump-guest-memory
to be used to monitor progress.

Signed-off-by: John Ferlan 
---
 src/qemu/qemu_monitor.c  | 14 +
 src/qemu/qemu_monitor.h  | 11 +++
 src/qemu/qemu_monitor_json.c | 69 
 src/qemu/qemu_monitor_json.h |  4 +++
 4 files changed, 98 insertions(+)

diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c
index ae64edd95..41a04dd00 100644
--- a/src/qemu/qemu_monitor.c
+++ b/src/qemu/qemu_monitor.c
@@ -2760,6 +2760,20 @@ qemuMonitorMigrateCancel(qemuMonitorPtr mon)
 }
 
 
+int
+qemuMonitorQueryDump(qemuMonitorPtr mon,
+ qemuMonitorDumpStatsPtr stats)
+{
+QEMU_CHECK_MONITOR(mon);
+
+/* No capability is supported without JSON monitor */
+if (!mon->json)
+return 0;
+
+return qemuMonitorJSONQueryDump(mon, stats);
+}
+
+
 /**
  * Returns 1 if @capability is supported, 0 if it's not, or -1 on error.
  */
diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h
index ab4c67ef3..b4322e360 100644
--- a/src/qemu/qemu_monitor.h
+++ b/src/qemu/qemu_monitor.h
@@ -775,6 +775,17 @@ int qemuMonitorMigrateCancel(qemuMonitorPtr mon);
 int qemuMonitorGetDumpGuestMemoryCapability(qemuMonitorPtr mon,
 const char *capability);
 
+typedef struct _qemuMonitorDumpStats qemuMonitorDumpStats;
+typedef qemuMonitorDumpStats *qemuMonitorDumpStatsPtr;
+struct _qemuMonitorDumpStats {
+int status; /* qemuMonitorDumpStatus */
+unsigned long long completed; /* bytes written */
+unsigned long long total; /* total bytes to be written */
+};
+
+int qemuMonitorQueryDump(qemuMonitorPtr mon,
+ qemuMonitorDumpStatsPtr stats);
+
 int qemuMonitorDumpToFd(qemuMonitorPtr mon,
 int fd,
 const char *dumpformat);
diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
index 7e3cdce9c..f29588c4d 100644
--- a/src/qemu/qemu_monitor_json.c
+++ b/src/qemu/qemu_monitor_json.c
@@ -3131,6 +3131,75 @@ int qemuMonitorJSONMigrateCancel(qemuMonitorPtr mon)
 return ret;
 }
 
+
+/* qemuMonitorJSONQueryDump:
+ * @mon: Monitor pointer
+ * @stats: Dump "stats"
+ *
+ * Attempt to make a "query-dump" call, check for errors, and get/return
+ * the current from the reply
+ *
+ * Returns: 0 on success, -1 on failure
+ */
+int
+qemuMonitorJSONQueryDump(qemuMonitorPtr mon,
+ qemuMonitorDumpStatsPtr stats)
+{
+int ret = -1;
+virJSONValuePtr cmd = qemuMonitorJSONMakeCommand("query-dump", NULL);
+virJSONValuePtr reply = NULL;
+virJSONValuePtr result = NULL;
+const char *statusstr;
+
+if (!cmd)
+return -1;
+
+if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
+goto cleanup;
+
+if (qemuMonitorJSONCheckError(cmd, reply) < 0)
+goto cleanup;
+
+if (!(result = virJSONValueObjectGetObject(reply, "return")))
+goto cleanup;
+
+if (!(statusstr = virJSONValueObjectGetString(result, "status"))) {
+virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+   _("incomplete result, failed to get status"));
+goto cleanup;
+}
+
+stats->status = qemuMonitorDumpStatusTypeFromString(statusstr);
+if (stats->status < 0) {
+virReportError(VIR_ERR_INTERNAL_ERROR,
+   _("incomplete result, unknown status string '%s'"),
+   statusstr);
+goto cleanup;
+}
+
+if (virJSONValueObjectGetNumberUlong(result, "completed",
+ &stats->completed) < 0) {
+virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+   _("incomplete result, failed to get completed"));
+goto cleanup;
+}
+
+if (virJSONValueObjectGetNumberUlong(result, "total", &stats->total) < 0) {
+virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+   _("incomplete result, failed to get total"));
+goto cleanup;
+}
+
+ret = 0;
+
+ cleanup:
+virJSONValueFree(cmd);
+virJSONValueFree(reply);
+virJSONValueFree(result);
+return ret;
+}
+
+
 int
 qemuMonitorJSONGetDumpGuestMemoryCapability(qemuMonitorPtr mon,
 const char *capability)
diff --git a/src/qemu/qemu_monitor_json.h b/src/qemu/qemu_monitor_json.h
index 739a99293..090e3a144 100644
--- a/src/qemu/qemu_monitor_json.h
+++ b/src/qemu/qemu_monitor_json.h
@@ -162,6 +162,10 @@ int qemuMonitorJSONGetSpiceMigrationStatus(qemuMonitorPtr 
mon,
 
 int qemuMonitorJSONMigrateCancel(qemuMonitorPtr mon);
 
+int
+qemuMonitorJSONQueryDump(qemuMonitorPtr mon,
+ qemuMonitorDumpStatsPtr stats);
+
 int qemuMonitorJSONGetDumpGuestMemoryCapability(qemuMonitorPtr mon,
 const char *capability);
 
-- 
2.13.6

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

[libvirt] [REBASE PATCH v2 03/10] qemu: Add support for DUMP_COMPLETED event

2017-12-05 Thread John Ferlan
The event is fired when the domain memory only dump completes.

Wire up the code to extract and send along the status.

Signed-off-by: John Ferlan 
---
 src/qemu/qemu_monitor.c  | 18 ++
 src/qemu/qemu_monitor.h  | 19 +++
 src/qemu/qemu_monitor_json.c | 31 +++
 3 files changed, 68 insertions(+)

diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c
index 473a52735..ae64edd95 100644
--- a/src/qemu/qemu_monitor.c
+++ b/src/qemu/qemu_monitor.c
@@ -202,6 +202,10 @@ VIR_ENUM_IMPL(qemuMonitorBlockIOStatus,
   QEMU_MONITOR_BLOCK_IO_STATUS_LAST,
   "ok", "failed", "nospace")
 
+VIR_ENUM_IMPL(qemuMonitorDumpStatus,
+  QEMU_MONITOR_DUMP_STATUS_LAST,
+  "none", "active", "completed", "failed")
+
 char *
 qemuMonitorEscapeArg(const char *in)
 {
@@ -1655,6 +1659,20 @@ qemuMonitorEmitBlockThreshold(qemuMonitorPtr mon,
 
 
 int
+qemuMonitorEmitDumpCompleted(qemuMonitorPtr mon,
+ qemuMonitorDumpStatus status)
+{
+int ret = -1;
+
+VIR_DEBUG("mon=%p", mon);
+
+QEMU_MONITOR_CALLBACK(mon, ret, domainDumpCompleted, mon->vm, status);
+
+return ret;
+}
+
+
+int
 qemuMonitorSetCapabilities(qemuMonitorPtr mon)
 {
 QEMU_CHECK_MONITOR(mon);
diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h
index f81fb7f2a..ab4c67ef3 100644
--- a/src/qemu/qemu_monitor.h
+++ b/src/qemu/qemu_monitor.h
@@ -245,6 +245,21 @@ typedef int 
(*qemuMonitorDomainBlockThresholdCallback)(qemuMonitorPtr mon,
unsigned long long 
excess,
void *opaque);
 
+typedef enum {
+QEMU_MONITOR_DUMP_STATUS_NONE,
+QEMU_MONITOR_DUMP_STATUS_ACTIVE,
+QEMU_MONITOR_DUMP_STATUS_COMPLETED,
+QEMU_MONITOR_DUMP_STATUS_FAILED,
+
+QEMU_MONITOR_DUMP_STATUS_LAST,
+} qemuMonitorDumpStatus;
+
+VIR_ENUM_DECL(qemuMonitorDumpStatus)
+
+typedef int (*qemuMonitorDomainDumpCompletedCallback)(qemuMonitorPtr mon,
+  virDomainObjPtr vm,
+  qemuMonitorDumpStatus 
status,
+  void *opaque);
 
 typedef struct _qemuMonitorCallbacks qemuMonitorCallbacks;
 typedef qemuMonitorCallbacks *qemuMonitorCallbacksPtr;
@@ -278,6 +293,7 @@ struct _qemuMonitorCallbacks {
 qemuMonitorDomainMigrationPassCallback domainMigrationPass;
 qemuMonitorDomainAcpiOstInfoCallback domainAcpiOstInfo;
 qemuMonitorDomainBlockThresholdCallback domainBlockThreshold;
+qemuMonitorDomainDumpCompletedCallback domainDumpCompleted;
 };
 
 char *qemuMonitorEscapeArg(const char *in);
@@ -406,6 +422,9 @@ int qemuMonitorEmitBlockThreshold(qemuMonitorPtr mon,
   unsigned long long threshold,
   unsigned long long excess);
 
+int qemuMonitorEmitDumpCompleted(qemuMonitorPtr mon,
+ qemuMonitorDumpStatus status);
+
 int qemuMonitorStartCPUs(qemuMonitorPtr mon,
  virConnectPtr conn);
 int qemuMonitorStopCPUs(qemuMonitorPtr mon);
diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
index 2c01c99bf..7e3cdce9c 100644
--- a/src/qemu/qemu_monitor_json.c
+++ b/src/qemu/qemu_monitor_json.c
@@ -90,6 +90,7 @@ static void 
qemuMonitorJSONHandleMigrationStatus(qemuMonitorPtr mon, virJSONValu
 static void qemuMonitorJSONHandleMigrationPass(qemuMonitorPtr mon, 
virJSONValuePtr data);
 static void qemuMonitorJSONHandleAcpiOstInfo(qemuMonitorPtr mon, 
virJSONValuePtr data);
 static void qemuMonitorJSONHandleBlockThreshold(qemuMonitorPtr mon, 
virJSONValuePtr data);
+static void qemuMonitorJSONHandleDumpCompleted(qemuMonitorPtr mon, 
virJSONValuePtr data);
 
 typedef struct {
 const char *type;
@@ -106,6 +107,7 @@ static qemuEventHandler eventHandlers[] = {
 { "BLOCK_WRITE_THRESHOLD", qemuMonitorJSONHandleBlockThreshold, },
 { "DEVICE_DELETED", qemuMonitorJSONHandleDeviceDeleted, },
 { "DEVICE_TRAY_MOVED", qemuMonitorJSONHandleTrayChange, },
+{ "DUMP_COMPLETED", qemuMonitorJSONHandleDumpCompleted, },
 { "GUEST_PANICKED", qemuMonitorJSONHandleGuestPanic, },
 { "MIGRATION", qemuMonitorJSONHandleMigrationStatus, },
 { "MIGRATION_PASS", qemuMonitorJSONHandleMigrationPass, },
@@ -1138,6 +1140,35 @@ qemuMonitorJSONHandleBlockThreshold(qemuMonitorPtr mon, 
virJSONValuePtr data)
 }
 
 
+static void
+qemuMonitorJSONHandleDumpCompleted(qemuMonitorPtr mon,
+   virJSONValuePtr data)
+{
+const char *statusstr;
+qemuMonitorDumpStatus status;
+virJSONValuePtr result;
+
+if (!(result = virJSONValueObjectGetObject(data, "result"))) {
+VIR_WARN("missing result in dump completed event");
+return;
+}
+
+if (!(statusstr = virJSONValueObjectGetString(result, "status"))) {

[libvirt] [REBASE PATCH v2 07/10] qemu: Introduce qemuDomainGetJobInfoMigrationStats

2017-12-05 Thread John Ferlan
Extract out the parts of qemuDomainGetJobStatsInternal that get
the migration stats. We're about to add the ability to get just
dump information.

Signed-off-by: John Ferlan 
---
 src/qemu/qemu_driver.c | 52 --
 1 file changed, 33 insertions(+), 19 deletions(-)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 7c8233069..cb67b0e2e 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -13146,13 +13146,43 @@ qemuConnectBaselineCPU(virConnectPtr conn 
ATTRIBUTE_UNUSED,
 
 
 static int
+qemuDomainGetJobInfoMigrationStats(virQEMUDriverPtr driver,
+   virDomainObjPtr vm,
+   qemuDomainJobInfoPtr jobInfo)
+{
+qemuDomainObjPrivatePtr priv = vm->privateData;
+bool events = virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_MIGRATION_EVENT);
+
+if (jobInfo->status == QEMU_DOMAIN_JOB_STATUS_ACTIVE ||
+jobInfo->status == QEMU_DOMAIN_JOB_STATUS_MIGRATING ||
+jobInfo->status == QEMU_DOMAIN_JOB_STATUS_QEMU_COMPLETED ||
+jobInfo->status == QEMU_DOMAIN_JOB_STATUS_POSTCOPY) {
+if (events &&
+jobInfo->status != QEMU_DOMAIN_JOB_STATUS_ACTIVE &&
+qemuMigrationFetchStats(driver, vm, QEMU_ASYNC_JOB_NONE,
+jobInfo, NULL) < 0)
+return -1;
+
+if (jobInfo->status == QEMU_DOMAIN_JOB_STATUS_ACTIVE &&
+qemuMigrationFetchMirrorStats(driver, vm, QEMU_ASYNC_JOB_NONE,
+  jobInfo) < 0)
+return -1;
+
+if (qemuDomainJobInfoUpdateTime(jobInfo) < 0)
+return -1;
+}
+
+return 0;
+}
+
+
+static int
 qemuDomainGetJobStatsInternal(virQEMUDriverPtr driver,
   virDomainObjPtr vm,
   bool completed,
   qemuDomainJobInfoPtr jobInfo)
 {
 qemuDomainObjPrivatePtr priv = vm->privateData;
-bool events = virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_MIGRATION_EVENT);
 int ret = -1;
 
 if (completed) {
@@ -13187,24 +13217,8 @@ qemuDomainGetJobStatsInternal(virQEMUDriverPtr driver,
 }
 *jobInfo = *priv->job.current;
 
-if (jobInfo->status == QEMU_DOMAIN_JOB_STATUS_ACTIVE ||
-jobInfo->status == QEMU_DOMAIN_JOB_STATUS_MIGRATING ||
-jobInfo->status == QEMU_DOMAIN_JOB_STATUS_QEMU_COMPLETED ||
-jobInfo->status == QEMU_DOMAIN_JOB_STATUS_POSTCOPY) {
-if (events &&
-jobInfo->status != QEMU_DOMAIN_JOB_STATUS_ACTIVE &&
-qemuMigrationFetchStats(driver, vm, QEMU_ASYNC_JOB_NONE,
-jobInfo, NULL) < 0)
-goto cleanup;
-
-if (jobInfo->status == QEMU_DOMAIN_JOB_STATUS_ACTIVE &&
-qemuMigrationFetchMirrorStats(driver, vm, QEMU_ASYNC_JOB_NONE,
-  jobInfo) < 0)
-goto cleanup;
-
-if (qemuDomainJobInfoUpdateTime(jobInfo) < 0)
-goto cleanup;
-}
+if (qemuDomainGetJobInfoMigrationStats(driver, vm, jobInfo) < 0)
+goto cleanup;
 
 ret = 0;
 
-- 
2.13.6

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


[libvirt] [REBASE PATCH v2 06/10] qemu: Add new parameter to qemuMonitorDumpToFd

2017-12-05 Thread John Ferlan
Add a @detach parameter to the API in order allow running the QEMU
code as a thread.

Signed-off-by: John Ferlan 
---
 src/qemu/qemu_driver.c   | 2 +-
 src/qemu/qemu_monitor.c  | 7 +--
 src/qemu/qemu_monitor.h  | 3 ++-
 src/qemu/qemu_monitor_json.c | 4 +++-
 src/qemu/qemu_monitor_json.h | 3 ++-
 tests/qemumonitorjsontest.c  | 3 ++-
 6 files changed, 15 insertions(+), 7 deletions(-)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index f8ccc8879..7c8233069 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -3789,7 +3789,7 @@ qemuDumpToFd(virQEMUDriverPtr driver,
 }
 }
 
-ret = qemuMonitorDumpToFd(priv->mon, fd, dumpformat);
+ret = qemuMonitorDumpToFd(priv->mon, fd, dumpformat, false);
 
  cleanup:
 ignore_value(qemuDomainObjExitMonitor(driver, vm));
diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c
index 41a04dd00..259030f94 100644
--- a/src/qemu/qemu_monitor.c
+++ b/src/qemu/qemu_monitor.c
@@ -2794,7 +2794,10 @@ qemuMonitorGetDumpGuestMemoryCapability(qemuMonitorPtr 
mon,
 
 
 int
-qemuMonitorDumpToFd(qemuMonitorPtr mon, int fd, const char *dumpformat)
+qemuMonitorDumpToFd(qemuMonitorPtr mon,
+int fd,
+const char *dumpformat,
+bool detach)
 {
 int ret;
 VIR_DEBUG("fd=%d dumpformat=%s", fd, dumpformat);
@@ -2804,7 +2807,7 @@ qemuMonitorDumpToFd(qemuMonitorPtr mon, int fd, const 
char *dumpformat)
 if (qemuMonitorSendFileHandle(mon, "dump", fd) < 0)
 return -1;
 
-ret = qemuMonitorJSONDump(mon, "fd:dump", dumpformat);
+ret = qemuMonitorJSONDump(mon, "fd:dump", dumpformat, detach);
 
 if (ret < 0) {
 if (qemuMonitorCloseFileHandle(mon, "dump") < 0)
diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h
index b4322e360..c578a1f45 100644
--- a/src/qemu/qemu_monitor.h
+++ b/src/qemu/qemu_monitor.h
@@ -788,7 +788,8 @@ int qemuMonitorQueryDump(qemuMonitorPtr mon,
 
 int qemuMonitorDumpToFd(qemuMonitorPtr mon,
 int fd,
-const char *dumpformat);
+const char *dumpformat,
+bool detach);
 
 int qemuMonitorGraphicsRelocate(qemuMonitorPtr mon,
 int type,
diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
index f29588c4d..90cc785f9 100644
--- a/src/qemu/qemu_monitor_json.c
+++ b/src/qemu/qemu_monitor_json.c
@@ -3259,7 +3259,8 @@ 
qemuMonitorJSONGetDumpGuestMemoryCapability(qemuMonitorPtr mon,
 int
 qemuMonitorJSONDump(qemuMonitorPtr mon,
 const char *protocol,
-const char *dumpformat)
+const char *dumpformat,
+bool detach)
 {
 int ret = -1;
 virJSONValuePtr cmd = NULL;
@@ -3269,6 +3270,7 @@ qemuMonitorJSONDump(qemuMonitorPtr mon,
  "b:paging", false,
  "s:protocol", protocol,
  "S:format", dumpformat,
+ "B:detach", detach,
  NULL);
 if (!cmd)
 return -1;
diff --git a/src/qemu/qemu_monitor_json.h b/src/qemu/qemu_monitor_json.h
index 090e3a144..5baddbc8a 100644
--- a/src/qemu/qemu_monitor_json.h
+++ b/src/qemu/qemu_monitor_json.h
@@ -171,7 +171,8 @@ int 
qemuMonitorJSONGetDumpGuestMemoryCapability(qemuMonitorPtr mon,
 
 int qemuMonitorJSONDump(qemuMonitorPtr mon,
 const char *protocol,
-const char *dumpformat);
+const char *dumpformat,
+bool detach);
 
 int qemuMonitorJSONGraphicsRelocate(qemuMonitorPtr mon,
 int type,
diff --git a/tests/qemumonitorjsontest.c b/tests/qemumonitorjsontest.c
index fe46a33eb..1eeefbce9 100644
--- a/tests/qemumonitorjsontest.c
+++ b/tests/qemumonitorjsontest.c
@@ -1330,7 +1330,8 @@ GEN_TEST_FUNC(qemuMonitorJSONSetMigrationDowntime, 1)
 GEN_TEST_FUNC(qemuMonitorJSONMigrate, QEMU_MONITOR_MIGRATE_BACKGROUND |
   QEMU_MONITOR_MIGRATE_NON_SHARED_DISK |
   QEMU_MONITOR_MIGRATE_NON_SHARED_INC, "tcp:localhost:12345")
-GEN_TEST_FUNC(qemuMonitorJSONDump, "dummy_protocol", 
"dummy_memory_dump_format")
+GEN_TEST_FUNC(qemuMonitorJSONDump, "dummy_protocol", 
"dummy_memory_dump_format",
+  true)
 GEN_TEST_FUNC(qemuMonitorJSONGraphicsRelocate, VIR_DOMAIN_GRAPHICS_TYPE_SPICE,
   "localhost", 12345, 12346, NULL)
 GEN_TEST_FUNC(qemuMonitorJSONAddNetdev, "some_dummy_netdevstr")
-- 
2.13.6

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


[libvirt] [REBASE PATCH v2 01/10] qemu: Clean up style for the qemuDumpToFd definition

2017-12-05 Thread John Ferlan
Alter the function definition to follow more recent style

Signed-off-by: John Ferlan 
---
 src/qemu/qemu_driver.c | 11 ---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 5eae7d24a..f8ccc8879 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -3750,9 +3750,13 @@ qemuDomainManagedSaveRemove(virDomainPtr dom, unsigned 
int flags)
 return ret;
 }
 
-static int qemuDumpToFd(virQEMUDriverPtr driver, virDomainObjPtr vm,
-int fd, qemuDomainAsyncJob asyncJob,
-const char *dumpformat)
+
+static int
+qemuDumpToFd(virQEMUDriverPtr driver,
+ virDomainObjPtr vm,
+ int fd,
+ qemuDomainAsyncJob asyncJob,
+ const char *dumpformat)
 {
 qemuDomainObjPrivatePtr priv = vm->privateData;
 int ret = -1;
@@ -3793,6 +3797,7 @@ static int qemuDumpToFd(virQEMUDriverPtr driver, 
virDomainObjPtr vm,
 return ret;
 }
 
+
 static int
 doCoreDump(virQEMUDriverPtr driver,
virDomainObjPtr vm,
-- 
2.13.6

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


[libvirt] [REBASE PATCH v2 02/10] qemu: Alter dump-guest-memory command generation

2017-12-05 Thread John Ferlan
The qemuMonitorJSONMakeCommand can properly handle a NULL string
by using the "S:" parameter instead of "s:", so let's use that
of having in if/else condition that only adds the "s:".

Signed-off-by: John Ferlan 
---
 src/qemu/qemu_monitor_json.c | 18 +-
 1 file changed, 5 insertions(+), 13 deletions(-)

diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
index 64394f76f..2c01c99bf 100644
--- a/src/qemu/qemu_monitor_json.c
+++ b/src/qemu/qemu_monitor_json.c
@@ -3165,19 +3165,11 @@ qemuMonitorJSONDump(qemuMonitorPtr mon,
 virJSONValuePtr cmd = NULL;
 virJSONValuePtr reply = NULL;
 
-if (dumpformat) {
-cmd = qemuMonitorJSONMakeCommand("dump-guest-memory",
- "b:paging", false,
- "s:protocol", protocol,
- "s:format", dumpformat,
- NULL);
-} else {
-cmd = qemuMonitorJSONMakeCommand("dump-guest-memory",
- "b:paging", false,
- "s:protocol", protocol,
- NULL);
-}
-
+cmd = qemuMonitorJSONMakeCommand("dump-guest-memory",
+ "b:paging", false,
+ "s:protocol", protocol,
+ "S:format", dumpformat,
+ NULL);
 if (!cmd)
 return -1;
 
-- 
2.13.6

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


[libvirt] [REBASE PATCH v2 04/10] qemu: Introduce qemuProcessHandleDumpCompleted

2017-12-05 Thread John Ferlan
Add a couple of booleans to mark when there's a dump completion event
waiting and when a dump completed event has been received.

To ensure the dump completed event from a non memory-only dump doesn't
cause the a dump completed event to be fired, only broadcast if there's
a completion event waiting.

Signed-off-by: John Ferlan 
---
 src/qemu/qemu_domain.c  |  2 ++
 src/qemu/qemu_domain.h  |  2 ++
 src/qemu/qemu_process.c | 23 +++
 3 files changed, 27 insertions(+)

diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index e8e03134f..41da30eb8 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -334,6 +334,8 @@ qemuDomainObjResetAsyncJob(qemuDomainObjPrivatePtr priv)
 job->spiceMigration = false;
 job->spiceMigrated = false;
 job->postcopyEnabled = false;
+job->dumpCompletion = false;
+job->dumpCompleted = false;
 VIR_FREE(job->current);
 }
 
diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h
index c33af3671..441edb6dd 100644
--- a/src/qemu/qemu_domain.h
+++ b/src/qemu/qemu_domain.h
@@ -164,6 +164,8 @@ struct qemuDomainJobObj {
  * should wait for it to finish */
 bool spiceMigrated; /* spice migration completed */
 bool postcopyEnabled;   /* post-copy migration was enabled */
+bool dumpCompletion;/* waiting for dump completion */
+bool dumpCompleted; /* dump completed */
 };
 
 typedef void (*qemuDomainCleanupCallback)(virQEMUDriverPtr driver,
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index ea70885dd..d1c4c2175 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -1687,6 +1687,28 @@ qemuProcessHandleMigrationPass(qemuMonitorPtr mon 
ATTRIBUTE_UNUSED,
 }
 
 
+static int
+qemuProcessHandleDumpCompleted(qemuMonitorPtr mon ATTRIBUTE_UNUSED,
+   virDomainObjPtr vm,
+   qemuMonitorDumpStatus status,
+   void *opaque ATTRIBUTE_UNUSED)
+{
+qemuDomainObjPrivatePtr priv;
+
+virObjectLock(vm);
+
+VIR_DEBUG("Dump completed for domain %p %s with status=%s",
+  vm, vm->def->name, qemuMonitorDumpStatusTypeToString(status));
+
+priv = vm->privateData;
+priv->job.dumpCompleted = true;
+if (priv->job.dumpCompletion)
+virDomainObjBroadcast(vm);
+virObjectUnlock(vm);
+return 0;
+}
+
+
 static qemuMonitorCallbacks monitorCallbacks = {
 .eofNotify = qemuProcessHandleMonitorEOF,
 .errorNotify = qemuProcessHandleMonitorError,
@@ -1715,6 +1737,7 @@ static qemuMonitorCallbacks monitorCallbacks = {
 .domainMigrationPass = qemuProcessHandleMigrationPass,
 .domainAcpiOstInfo = qemuProcessHandleAcpiOstInfo,
 .domainBlockThreshold = qemuProcessHandleBlockThreshold,
+.domainDumpCompleted = qemuProcessHandleDumpCompleted,
 };
 
 static void
-- 
2.13.6

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


[libvirt] [REBASE PATCH v2 09/10] qemu: Add dump completed event to the capabilities

2017-12-05 Thread John Ferlan
Add the DUMP_COMPLETED check to the capabilities. This is the
mechanism used to determine whether the dump-guest-memory command
can support the "-detach" option and thus be able to wait on the
event and allow for a query of the progress of the dump.

Signed-off-by: John Ferlan 
---
 src/qemu/qemu_capabilities.c | 2 ++
 src/qemu/qemu_capabilities.h | 1 +
 tests/qemucapabilitiesdata/caps_2.10.0-gicv2.aarch64.xml | 1 +
 tests/qemucapabilitiesdata/caps_2.10.0-gicv3.aarch64.xml | 1 +
 tests/qemucapabilitiesdata/caps_2.10.0.ppc64.xml | 1 +
 tests/qemucapabilitiesdata/caps_2.10.0.s390x.xml | 1 +
 tests/qemucapabilitiesdata/caps_2.10.0.x86_64.xml| 1 +
 tests/qemucapabilitiesdata/caps_2.6.0-gicv2.aarch64.xml  | 1 +
 tests/qemucapabilitiesdata/caps_2.6.0-gicv3.aarch64.xml  | 1 +
 tests/qemucapabilitiesdata/caps_2.6.0.ppc64.xml  | 1 +
 tests/qemucapabilitiesdata/caps_2.6.0.x86_64.xml | 1 +
 tests/qemucapabilitiesdata/caps_2.7.0.s390x.xml  | 1 +
 tests/qemucapabilitiesdata/caps_2.7.0.x86_64.xml | 1 +
 tests/qemucapabilitiesdata/caps_2.8.0.s390x.xml  | 1 +
 tests/qemucapabilitiesdata/caps_2.8.0.x86_64.xml | 1 +
 tests/qemucapabilitiesdata/caps_2.9.0.ppc64.xml  | 1 +
 tests/qemucapabilitiesdata/caps_2.9.0.s390x.xml  | 1 +
 tests/qemucapabilitiesdata/caps_2.9.0.x86_64.xml | 1 +
 18 files changed, 19 insertions(+)

diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index 29714855b..8b5dc6a0a 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -456,6 +456,7 @@ VIR_ENUM_IMPL(virQEMUCaps, QEMU_CAPS_LAST,
 
   /* 280 */
   "pl011",
+  "dump-completed",
 );
 
 
@@ -1589,6 +1590,7 @@ struct virQEMUCapsStringFlags virQEMUCapsEvents[] = {
 { "VSERPORT_CHANGE", QEMU_CAPS_VSERPORT_CHANGE },
 { "DEVICE_TRAY_MOVED", QEMU_CAPS_DEVICE_TRAY_MOVED },
 { "BLOCK_WRITE_THRESHOLD", QEMU_CAPS_BLOCK_WRITE_THRESHOLD },
+{ "DUMP_COMPLETED", QEMU_CAPS_DUMP_COMPLETED },
 };
 
 struct virQEMUCapsStringFlags virQEMUCapsObjectTypes[] = {
diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h
index 9f239a0ec..5b767b773 100644
--- a/src/qemu/qemu_capabilities.h
+++ b/src/qemu/qemu_capabilities.h
@@ -442,6 +442,7 @@ typedef enum {
 
 /* 280 */
 QEMU_CAPS_DEVICE_PL011, /* -device pl011 (not user-instantiable) */
+QEMU_CAPS_DUMP_COMPLETED, /* DUMP_COMPLETED event */
 
 QEMU_CAPS_LAST /* this must always be the last item */
 } virQEMUCapsFlags;
diff --git a/tests/qemucapabilitiesdata/caps_2.10.0-gicv2.aarch64.xml 
b/tests/qemucapabilitiesdata/caps_2.10.0-gicv2.aarch64.xml
index eeb1840d3..80283d25a 100644
--- a/tests/qemucapabilitiesdata/caps_2.10.0-gicv2.aarch64.xml
+++ b/tests/qemucapabilitiesdata/caps_2.10.0-gicv2.aarch64.xml
@@ -185,6 +185,7 @@
   
   
   
+  
   201
   0
(v2.10.0)
diff --git a/tests/qemucapabilitiesdata/caps_2.10.0-gicv3.aarch64.xml 
b/tests/qemucapabilitiesdata/caps_2.10.0-gicv3.aarch64.xml
index 1e7b95ec0..dfccd319b 100644
--- a/tests/qemucapabilitiesdata/caps_2.10.0-gicv3.aarch64.xml
+++ b/tests/qemucapabilitiesdata/caps_2.10.0-gicv3.aarch64.xml
@@ -185,6 +185,7 @@
   
   
   
+  
   201
   0
(v2.10.0)
diff --git a/tests/qemucapabilitiesdata/caps_2.10.0.ppc64.xml 
b/tests/qemucapabilitiesdata/caps_2.10.0.ppc64.xml
index ca55e11eb..51b5b7231 100644
--- a/tests/qemucapabilitiesdata/caps_2.10.0.ppc64.xml
+++ b/tests/qemucapabilitiesdata/caps_2.10.0.ppc64.xml
@@ -183,6 +183,7 @@
   
   
   
+  
   201
   0
(v2.10.0)
diff --git a/tests/qemucapabilitiesdata/caps_2.10.0.s390x.xml 
b/tests/qemucapabilitiesdata/caps_2.10.0.s390x.xml
index 64e70f54b..3bb6f8c61 100644
--- a/tests/qemucapabilitiesdata/caps_2.10.0.s390x.xml
+++ b/tests/qemucapabilitiesdata/caps_2.10.0.s390x.xml
@@ -145,6 +145,7 @@
   
   
   
+  
   201
   0
   
diff --git a/tests/qemucapabilitiesdata/caps_2.10.0.x86_64.xml 
b/tests/qemucapabilitiesdata/caps_2.10.0.x86_64.xml
index 8fea70a52..a88bc3c2c 100644
--- a/tests/qemucapabilitiesdata/caps_2.10.0.x86_64.xml
+++ b/tests/qemucapabilitiesdata/caps_2.10.0.x86_64.xml
@@ -228,6 +228,7 @@
   
   
   
+  
   201
   0
(v2.10.0)
diff --git a/tests/qemucapabilitiesdata/caps_2.6.0-gicv2.aarch64.xml 
b/tests/qemucapabilitiesdata/caps_2.6.0-gicv2.aarch64.xml
index d3e2e18fa..816b80b41 100644
--- a/tests/qemucapabilitiesdata/caps_2.6.0-gicv2.aarch64.xml
+++ b/tests/qemucapabilitiesdata/caps_2.6.0-gicv2.aarch64.xml
@@ -174,6 +174,7 @@
   
   
   
+  
   2006000
   0
   
diff --git a/tests/qemucapabilitiesdata/caps_2.6.0-gicv3.aarch64.xml 
b/tests/qemucapabilitiesdata/caps_2.6.0-gicv3.aarch64.xml
index bc86d0353..33064ebfd 100644
--- a/tests/qemucapabilitiesdata/caps_2.6.0-gicv3.aarch64.xml
+++ b/tests/qemucapabilitiesdata/caps_2.6.0-gicv3.aarch64.xml
@@ -174,6 +174,7 @@
   
   
   
+  
   2006000
   0
   
diff --gi

[libvirt] [REBASE PATCH v2 08/10] qemu: Introduce qemuDomainGetJobInfoDumpStats

2017-12-05 Thread John Ferlan
Add an API to allow fetching the Dump statistics for the job
via the qemuDomainGetJobInfo API.

Signed-off-by: John Ferlan 
---
 src/qemu/qemu_driver.c | 56 --
 1 file changed, 54 insertions(+), 2 deletions(-)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index cb67b0e2e..d921a5e78 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -13177,6 +13177,53 @@ qemuDomainGetJobInfoMigrationStats(virQEMUDriverPtr 
driver,
 
 
 static int
+qemuDomainGetJobInfoDumpStats(virQEMUDriverPtr driver,
+  virDomainObjPtr vm,
+  qemuDomainJobInfoPtr jobInfo)
+{
+qemuDomainObjPrivatePtr priv = vm->privateData;
+qemuMonitorDumpStats stats;
+int rv;
+
+if (qemuDomainObjEnterMonitorAsync(driver, vm, QEMU_ASYNC_JOB_NONE) < 0)
+return -1;
+
+rv = qemuMonitorQueryDump(priv->mon, &stats);
+
+if (qemuDomainObjExitMonitor(driver, vm) < 0 || rv < 0)
+return -1;
+
+/* Save the stats in the migration stats so that qemuDomainJobInfoToInfo
+ * will be copy properly */
+jobInfo->stats.ram_total = stats.total;
+jobInfo->stats.ram_remaining = stats.total - stats.completed;
+jobInfo->stats.ram_transferred = stats.completed;
+switch (stats.status) {
+case QEMU_MONITOR_DUMP_STATUS_NONE:
+case QEMU_MONITOR_DUMP_STATUS_FAILED:
+case QEMU_MONITOR_DUMP_STATUS_LAST:
+virReportError(VIR_ERR_OPERATION_FAILED,
+   _("dump query failed, status=%d"), stats.status);
+return -1;
+break;
+
+case QEMU_MONITOR_DUMP_STATUS_ACTIVE:
+jobInfo->status = QEMU_DOMAIN_JOB_STATUS_ACTIVE;
+VIR_DEBUG("dump active, bytes written='%llu' remaining='%llu'",
+  stats.completed, stats.total - stats.completed);
+break;
+
+case QEMU_MONITOR_DUMP_STATUS_COMPLETED:
+jobInfo->status = QEMU_DOMAIN_JOB_STATUS_COMPLETED;
+VIR_DEBUG("dump completed, bytes written='%llu'", stats.completed);
+break;
+}
+
+return 0;
+}
+
+
+static int
 qemuDomainGetJobStatsInternal(virQEMUDriverPtr driver,
   virDomainObjPtr vm,
   bool completed,
@@ -13217,8 +13264,13 @@ qemuDomainGetJobStatsInternal(virQEMUDriverPtr driver,
 }
 *jobInfo = *priv->job.current;
 
-if (qemuDomainGetJobInfoMigrationStats(driver, vm, jobInfo) < 0)
-goto cleanup;
+if (priv->job.asyncJob == QEMU_ASYNC_JOB_DUMP && priv->job.dumpCompletion) 
{
+if (qemuDomainGetJobInfoDumpStats(driver, vm, jobInfo) < 0)
+goto cleanup;
+} else {
+if (qemuDomainGetJobInfoMigrationStats(driver, vm, jobInfo) < 0)
+goto cleanup;
+}
 
 ret = 0;
 
-- 
2.13.6

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


[libvirt] [REBASE PATCH v2 10/10] qemu: Allow showing the dump progress for memory only dump

2017-12-05 Thread John Ferlan
https://bugzilla.redhat.com/show_bug.cgi?id=916061

If the QEMU version running is new enough (based on the DUMP_COMPLETED
event), then we can add a 'detach' boolean to the dump-guest-memory
command in order to tell QEMU to run in a thread. This ensures that we
don't lock out other commands while the potentially long running dump
memory is completed.

This allows the usage of a qemuDumpWaitForCompletion which will wait
for the event while the qemuDomainGetJobInfoDumpStats can be used via
qemuDomainGetJobInfo in order to query QEMU in order to determine
how far along the job is.

Signed-off-by: John Ferlan 
---
 src/qemu/qemu_driver.c | 48 
 1 file changed, 44 insertions(+), 4 deletions(-)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index d921a5e78..c35963ae9 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -3751,6 +3751,34 @@ qemuDomainManagedSaveRemove(virDomainPtr dom, unsigned 
int flags)
 }
 
 
+/**
+ * qemuDumpWaitForCompletion:
+ * @vm: domain object
+ *
+ * If the query dump capability exists, then it's possible to start a
+ * guest memory dump operation using a thread via a 'detach' qualifier
+ * to the dump guest memory command. This allows the async check if the
+ * dump is done.
+ *
+ * Returns 0 on success, -1 on failure
+ */
+static int
+qemuDumpWaitForCompletion(virDomainObjPtr vm)
+{
+qemuDomainObjPrivatePtr priv = vm->privateData;
+
+if (!priv->job.dumpCompletion)
+return 0;
+
+VIR_DEBUG("Waiting for dump completion");
+while (!priv->job.dumpCompleted && !priv->job.abortJob) {
+if (virDomainObjWait(vm) < 0)
+return -1;
+}
+return 0;
+}
+
+
 static int
 qemuDumpToFd(virQEMUDriverPtr driver,
  virDomainObjPtr vm,
@@ -3759,6 +3787,7 @@ qemuDumpToFd(virQEMUDriverPtr driver,
  const char *dumpformat)
 {
 qemuDomainObjPrivatePtr priv = vm->privateData;
+bool detach = false;
 int ret = -1;
 
 if (!virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_DUMP_GUEST_MEMORY)) {
@@ -3767,10 +3796,13 @@ qemuDumpToFd(virQEMUDriverPtr driver,
 return -1;
 }
 
+detach = virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_DUMP_COMPLETED);
+
 if (qemuSecuritySetImageFDLabel(driver->securityManager, vm->def, fd) < 0)
 return -1;
 
-VIR_FREE(priv->job.current);
+if (!detach)
+VIR_FREE(priv->job.current);
 priv->job.dump_memory_only = true;
 
 if (qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) < 0)
@@ -3785,15 +3817,23 @@ qemuDumpToFd(virQEMUDriverPtr driver,
  "for this QEMU binary"),
dumpformat);
 ret = -1;
+ignore_value(qemuDomainObjExitMonitor(driver, vm));
 goto cleanup;
 }
 }
 
-ret = qemuMonitorDumpToFd(priv->mon, fd, dumpformat, false);
+ret = qemuMonitorDumpToFd(priv->mon, fd, dumpformat, detach);
 
- cleanup:
-ignore_value(qemuDomainObjExitMonitor(driver, vm));
+if (detach && ret == 0)
+priv->job.dumpCompletion = true;
+
+if ((qemuDomainObjExitMonitor(driver, vm) < 0) || ret < 0)
+goto cleanup;
+
+if (detach)
+ret = qemuDumpWaitForCompletion(vm);
 
+ cleanup:
 return ret;
 }
 
-- 
2.13.6

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


Re: [libvirt] [PATCH 03/17] qemu: Use virDomainControllerType in qemuBuildControllerDevStr switch

2017-12-05 Thread Ján Tomko

On Mon, Dec 04, 2017 at 08:38:53PM -0500, John Ferlan wrote:

Make sure all types of virDomainControllerType are handled in the
switch statement.

Signed-off-by: John Ferlan 
---
src/qemu/qemu_command.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)



ACK

Jan


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

Re: [libvirt] [PATCH 06/17] tests: Drop IDE controller in CCW

2017-12-05 Thread Ján Tomko

On Mon, Dec 04, 2017 at 08:38:56PM -0500, John Ferlan wrote:

From: Lin Ma 

Adding an IDE controller for a machinetype that has no built-in IDE
controller, libvirt will log an error. Currently the machinetype list
which returns by qemuDomainMachineHasBuiltinIDE only includes 440fx,
malta, sun4u and g3beige.

Signed-off-by: Lin Ma 
Signed-off-by: John Ferlan 
---
tests/qemuhotplugtestdomains/qemuhotplug-base-ccw-live+ccw-virtio.xml | 4 
...uhotplug-base-ccw-live-with-2-ccw-virtio+ccw-virtio-1-explicit.xml | 4 
...muhotplug-base-ccw-live-with-2-ccw-virtio+ccw-virtio-1-reverse.xml | 4 
.../qemuhotplug-base-ccw-live-with-2-ccw-virtio.xml   | 4 
...emuhotplug-base-ccw-live-with-ccw-virtio+ccw-virtio-2-explicit.xml | 4 
.../qemuhotplug-base-ccw-live-with-ccw-virtio+ccw-virtio-2.xml| 4 
.../qemuhotplug-base-ccw-live-with-ccw-virtio.xml | 4 
tests/qemuhotplugtestdomains/qemuhotplug-base-ccw-live.xml| 4 
8 files changed, 32 deletions(-)



ACK

Jan


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

Re: [libvirt] [PATCH 05/17] tests: Remove use of IDE disk for pseries floppy test

2017-12-05 Thread Ján Tomko

On Mon, Dec 04, 2017 at 08:38:55PM -0500, John Ferlan wrote:

From: Lin Ma 

Adding an IDE controller for a machinetype that has no built-in IDE
controller, libvirt will log an error. Currently the machinetype list
which returns by qemuDomainMachineHasBuiltinIDE only includes 440fx,
malta, sun4u and g3beige.

Remove the disk and the .args file since the expectation is the test
will fail in qemuxml2argvtest because floppy is not supported on pseries
and thus no disk is necessary and no .args file would be created to
compare against.

Signed-off-by: Lin Ma 
Signed-off-by: John Ferlan 
---
.../qemuxml2argv-disk-floppy-pseries.args  | 24 --
.../qemuxml2argv-disk-floppy-pseries.xml   |  7 ---
2 files changed, 31 deletions(-)
delete mode 100644 tests/qemuxml2argvdata/qemuxml2argv-disk-floppy-pseries.args



ACK

Jan


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

Re: [libvirt] [PATCH 04/17] qemu: Move CCW S390 Address check to controller def validate

2017-12-05 Thread Ján Tomko

On Mon, Dec 04, 2017 at 08:38:54PM -0500, John Ferlan wrote:

Move the call to qemuDomainCheckCCWS390AddressSupport from
qemuBuildControllerDevStr to qemuDomainDeviceDefValidateController.

This means we will get the qemuCaps from the driver opaque
variable passed to qemuDomainDeviceDefValidate.

Signed-off-by: John Ferlan 
---
src/qemu/qemu_command.c |  4 
src/qemu/qemu_domain.c  | 18 +++---
2 files changed, 15 insertions(+), 7 deletions(-)




@@ -3990,9 +3995,15 @@ qemuDomainDeviceDefValidateController(const 
virDomainControllerDef *controller,
static int
qemuDomainDeviceDefValidate(const virDomainDeviceDef *dev,
const virDomainDef *def,
-void *opaque ATTRIBUTE_UNUSED)
+void *opaque)
{
int ret = 0;
+virQEMUDriverPtr driver = opaque;
+virQEMUCapsPtr qemuCaps = NULL;
+
+if (!(qemuCaps = virQEMUCapsCacheLookup(driver->qemuCapsCache,
+def->emulator)))
+return -1;


The corresponding Unref should be a part of this patch

Jan



switch ((virDomainDeviceType) dev->type) {
case VIR_DOMAIN_DEVICE_NET:
@@ -4032,7 +4043,8 @@ qemuDomainDeviceDefValidate(const virDomainDeviceDef *dev,
break;

case VIR_DOMAIN_DEVICE_CONTROLLER:
-ret = qemuDomainDeviceDefValidateController(dev->data.controller, def);
+ret = qemuDomainDeviceDefValidateController(dev->data.controller, def,
+qemuCaps);
break;

case VIR_DOMAIN_DEVICE_LEASE:
--
2.13.6

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


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

Re: [libvirt] [PATCH 02/17] qemu: Introduce qemuDomainDeviceDefSkipController

2017-12-05 Thread Ján Tomko

On Mon, Dec 04, 2017 at 08:38:52PM -0500, John Ferlan wrote:

In order to be able to reuse some code for both controller def
validation and command line building, create a convenience helper
that will perform the "skip" avoidance checks. It will also set
some flags to allow the caller to specifically skip (or fail)
depending on the result of the flag (as opposed to building up
some ever growing list of variables).

Signed-off-by: John Ferlan 
---
src/qemu/qemu_command.c | 61 +--
src/qemu/qemu_domain.c  | 84 -
src/qemu/qemu_domain.h  | 12 +++
3 files changed, 102 insertions(+), 55 deletions(-)



[...]


diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index 569bbd29e..d4c7674c0 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -3884,10 +3884,92 @@ qemuDomainDeviceDefValidateDisk(const virDomainDiskDef 
*disk)
}


+/**
+ * qemuDomainDeviceDefSkipController:
+ * @controller: Controller to check
+ * @def: Domain definition
+ * @flags: qemuDomainDeviceSkipFlags to set if specific condition found
+ *
+ * Returns true if this controller can be skipped for command line generation
+ * or device validation


We should not skip validation for implicit devices. Some of the checks
added later are for implicit devices (PCI root, SATA controller).

It would be enough to split out the logic of figuring out whether the
controller is implicit out of command line generation.


+ */
+bool
+qemuDomainDeviceDefSkipController(const virDomainControllerDef *controller,
+  const virDomainDef *def,
+  unsigned int *flags)
+{
+/* skip USB controllers with type none.*/
+if (controller->type == VIR_DOMAIN_CONTROLLER_TYPE_USB &&
+controller->model == VIR_DOMAIN_CONTROLLER_MODEL_USB_NONE) {
+*flags |= QEMU_DOMAIN_DEVICE_SKIP_USB_CONTROLLER_FLAG;
+return true;
+}


Simply returning true here (no USB controller is implicit) should
suffice. The caller can figure out whether USB_NONE is present
by going through the controllers array again (via virDomainDefHasUSB).


+
+/* skip pcie-root */
+if (controller->type == VIR_DOMAIN_CONTROLLER_TYPE_PCI &&
+controller->model == VIR_DOMAIN_CONTROLLER_MODEL_PCIE_ROOT)
+return true;
+
+/* Skip pci-root, except for pSeries guests (which actually
+ * support more than one PCI Host Bridge per guest) */
+if (!qemuDomainIsPSeries(def) &&
+controller->type == VIR_DOMAIN_CONTROLLER_TYPE_PCI &&
+controller->model == VIR_DOMAIN_CONTROLLER_MODEL_PCI_ROOT)
+return true;
+
+/* first SATA controller on Q35 machines is implicit */
+if (controller->type == VIR_DOMAIN_CONTROLLER_TYPE_SATA &&
+controller->idx == 0 && qemuDomainIsQ35(def))
+return true;
+
+/* first IDE controller is implicit on various machines */
+if (controller->type == VIR_DOMAIN_CONTROLLER_TYPE_IDE &&
+controller->idx == 0 && qemuDomainHasBuiltinIDE(def))
+return true;
+
+if (controller->type == VIR_DOMAIN_CONTROLLER_TYPE_USB &&
+controller->model == -1 &&
+!qemuDomainIsQ35(def) &&
+!qemuDomainIsVirt(def)) {
+
+/* An appropriate default USB controller model should already
+ * have been selected in qemuDomainDeviceDefPostParse(); if
+ * we still have no model by now, we have to fall back to the
+ * legacy USB controller.
+ *
+ * Note that we *don't* want to end up with the legacy USB
+ * controller for q35 and virt machines, so we go ahead and
+ * fail in qemuBuildControllerDevStr(); on the other hand,
+ * for s390 machines we want to ignore any USB controller
+ * (see 548ba43028 for the full story), so we skip
+ * qemuBuildControllerDevStr() but we don't ultimately end
+ * up adding the legacy USB controller */
+if (*flags & QEMU_DOMAIN_DEVICE_SKIP_USB_LEGACY_FLAG) {
+virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+   _("Multiple legacy USB controllers are "
+ "not supported"));


A function returning bool where both options are valid should not be
setting errors.

For this error, validate can go through all the controllers. Command
line generator should not care and we can get rid of the remaining two
flags as their only purpose is to save us multiple passes through
the controllers field.


+*flags |= QEMU_DOMAIN_DEVICE_SKIP_USB_LEGACY_FAIL_FLAG;
+}
+*flags |= QEMU_DOMAIN_DEVICE_SKIP_USB_LEGACY_FLAG;
+return true;
+}
+
+return false;
+}
+
+
static int
qemuDomainDeviceDefValidateController(const virDomainControllerDef *controller,
-  const virDomainDef *def ATTRIBUTE_UNUSED)
+  const virDomainDef *def)
{
+unsigned int fl

Re: [libvirt] [PATCH 16/17] qemu: Introduce qemuDomainDeviceDefValidateControllerUSB

2017-12-05 Thread Ján Tomko

On Mon, Dec 04, 2017 at 08:39:06PM -0500, John Ferlan wrote:

Move the USB controller validation checs out of qemu_command and


*checks


into the proper qemu_domain validation helper.

We will start slowly and also modity the xml2argv test to change


*modify


from a RUN to PARSE failure check when the QEMU_CAPS_PIIX3_USB_UHCI
is removed.

Signed-off-by: John Ferlan 
---
src/qemu/qemu_command.c  |  6 --
src/qemu/qemu_domain.c   | 18 +-
tests/qemuxml2argvtest.c |  8 
3 files changed, 21 insertions(+), 11 deletions(-)



Jan


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

[libvirt] [rust PATCH] README: update libvirt.org links

2017-12-05 Thread Ján Tomko
The documentation page used the link from before libvirt.h was split
into multiple files.

The master repo linked to the go bindings.

Fix both and switch them to https, which is now default for the website.
---
Although trivial, I did not push these since I'm not a maintainer.

 README.md | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/README.md b/README.md
index 29d38a2..5643f74 100644
--- a/README.md
+++ b/README.md
@@ -16,7 +16,7 @@ The bindings use standard errors handling from Rust. Each 
method
 
 ## Documentation
 
-* http://libvirt.org/html/libvirt-libvirt.html
+* https://libvirt.org/html/index.html
 * https://docs.rs/crate/virt/
 
 ## Tests/Exercises
@@ -87,7 +87,7 @@ Or to send all patches on the current branch, against master
 
 Note the master GIT repository is at
 
-* http://libvirt.org/git/?p=libvirt-go.git;a=summary
+* https://libvirt.org/git/?p=libvirt-rust.git;a=summary
 
 The following automatic read-only mirrors are available as a
 convenience to allow contributors to "fork" the repository:
-- 
2.13.6

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


Re: [libvirt] [rust PATCH] README: update libvirt.org links

2017-12-05 Thread Daniel P. Berrange
On Tue, Dec 05, 2017 at 04:55:14PM +0100, Ján Tomko wrote:
> The documentation page used the link from before libvirt.h was split
> into multiple files.
> 
> The master repo linked to the go bindings.
> 
> Fix both and switch them to https, which is now default for the website.
> ---
> Although trivial, I did not push these since I'm not a maintainer.
> 
>  README.md | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)

Reviewed-by: Daniel P. Berrange 


> 
> diff --git a/README.md b/README.md
> index 29d38a2..5643f74 100644
> --- a/README.md
> +++ b/README.md
> @@ -16,7 +16,7 @@ The bindings use standard errors handling from Rust. Each 
> method
>  
>  ## Documentation
>  
> -* http://libvirt.org/html/libvirt-libvirt.html
> +* https://libvirt.org/html/index.html
>  * https://docs.rs/crate/virt/
>  
>  ## Tests/Exercises
> @@ -87,7 +87,7 @@ Or to send all patches on the current branch, against master
>  
>  Note the master GIT repository is at
>  
> -* http://libvirt.org/git/?p=libvirt-go.git;a=summary
> +* https://libvirt.org/git/?p=libvirt-rust.git;a=summary
>  
>  The following automatic read-only mirrors are available as a
>  convenience to allow contributors to "fork" the repository:
> -- 
> 2.13.6
> 
> --
> libvir-list mailing list
> libvir-list@redhat.com
> https://www.redhat.com/mailman/listinfo/libvir-list

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

[libvirt] [PATCH] nwfilter: don't crash listing filters in unprivileged daemon

2017-12-05 Thread Daniel P. Berrange
The unprivileged libvirtd does not support nwfilter config, by leaves the
driver active. It is supposed to result in all APIs being an effective
no-op, but several APIs rely on driver->nwfilters being non-NULL, or they
will reference a NULL pointer. Rather than adding checks for NULL in many
places, just make sure  driver->nwfilters is always initialized.

Signed-off-by: Daniel P. Berrange 
---
 src/nwfilter/nwfilter_driver.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/nwfilter/nwfilter_driver.c b/src/nwfilter/nwfilter_driver.c
index 2f9a51c405..89b767fe11 100644
--- a/src/nwfilter/nwfilter_driver.c
+++ b/src/nwfilter/nwfilter_driver.c
@@ -189,6 +189,8 @@ nwfilterStateInitialize(bool privileged,
 /* remember that we are going to use firewalld */
 driver->watchingFirewallD = (sysbus != NULL);
 driver->privileged = privileged;
+if (!(driver->nwfilters = virNWFilterObjListNew()))
+goto error;
 
 if (!privileged)
 return 0;
@@ -244,9 +246,6 @@ nwfilterStateInitialize(bool privileged,
 goto error;
 }
 
-if (!(driver->nwfilters = virNWFilterObjListNew()))
-goto error;
-
 if (virNWFilterObjListLoadAllConfigs(driver->nwfilters, driver->configDir) 
< 0)
 goto error;
 
@@ -271,6 +270,7 @@ nwfilterStateInitialize(bool privileged,
 virNWFilterIPAddrMapShutdown();
 
  err_free_driverstate:
+virNWFilterObjListFree(driver->nwfilters);
 VIR_FREE(driver);
 
 return -1;
-- 
2.14.3

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


Re: [libvirt] [sandbox 1/6] Pass debug and verbose values to init

2017-12-05 Thread Daniel P. Berrange
On Tue, Dec 05, 2017 at 10:53:17AM +0100, Cédric Bosdonnat wrote:
> libvirt-sandbox-init-common is expecting -d and -v parameters to
> set it in debug or verbose mode... but those will never be passed
> by the launcher program.

Hmm, libvirt-sandbox-init-{qemu,lxc} both know how to pass -d
to init-common.  If either of the virt specific init programs
are in debug mode (as indicated by the word "debug" in kernel
command line or equiv), then they pass -d to init-common.

You're right that there's no way to pass -v though.

Also, it might be useful to run init-common in debug mode
without the virt specific init being in debug mode, to avoid
drowning in debug.

> 
> Writing the core.debug and core.verbose parameters in the sandbox
> configuration makes those values actually usable from the init.
> ---
>  bin/virt-sandbox.c|  3 ++
>  libvirt-sandbox/libvirt-sandbox-config.c  | 75 
> +++
>  libvirt-sandbox/libvirt-sandbox-config.h  |  6 +++
>  libvirt-sandbox/libvirt-sandbox-init-common.c |  3 ++
>  libvirt-sandbox/libvirt-sandbox.sym   |  4 ++
>  5 files changed, 91 insertions(+)

Reviewed-by: Daniel P. Berrange 

if the commit message is fixed


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] [sandbox 2/6] machine: use squash security mode for non-root virt-sandbox mounts

2017-12-05 Thread Daniel P. Berrange
On Tue, Dec 05, 2017 at 10:53:18AM +0100, Cédric Bosdonnat wrote:
> When running virt-sandbox as a user with host-bind mount, the user
> can't write in the mounted folder. If run as root, use passthrough
> security mode, otherwise use squashed one to fix this.
> ---
>  libvirt-sandbox/libvirt-sandbox-builder-machine.c | 5 -
>  1 file changed, 4 insertions(+), 1 deletion(-)

Reviewed-by: Daniel P. Berrange 


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] [sandbox 3/6] Add tests .log and .trs files to gitignore

2017-12-05 Thread Daniel P. Berrange
On Tue, Dec 05, 2017 at 10:53:19AM +0100, Cédric Bosdonnat wrote:
> ---
>  .gitignore | 2 ++
>  1 file changed, 2 insertions(+)

Reviewed-by: Daniel P. Berrange 


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] [sandbox 4/6] service: fix bad ConfigMountHostImage constructor call

2017-12-05 Thread Daniel P. Berrange
On Tue, Dec 05, 2017 at 10:53:20AM +0100, Cédric Bosdonnat wrote:
> Since commit 68406aff8 ConfigMountHostImage needs a format parameter,
> virt-sandbox-service needs to fit the new API.
> ---
>  bin/virt-sandbox-service | 5 -
>  1 file changed, 4 insertions(+), 1 deletion(-)

Reviewed-by: Daniel P. Berrange 


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] [sandbox 5/6] Convert to python3

2017-12-05 Thread Daniel P. Berrange
On Tue, Dec 05, 2017 at 10:53:21AM +0100, Cédric Bosdonnat wrote:
> Python2 is going to die soon, convert to python3.

I'm unclear whether this change drops py2 support, or whether it makes it
work with py2+3 in parallel.

The commit message suggests py3 only, but then this:

> @@ -418,6 +416,18 @@ class GenericContainer(Container):
>  def is_template_unit(unit):
>  return '@' in unit
>  
> +# Python 2 / 3 compability helpers
> +def get_next(obj):
> +if hasattr(obj, 'next'):
> +return obj.next()
> +else:
> +return next(obj)
> +
> +def string(obj):
> +if isinstance(obj, bytes):
> +return str(obj, encoding='utf-8')
> +return obj


suggests py2+3 in parallel

I don't mind being py3 only.

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] [sandbox 6/6] Don't hardcode interpreter path

2017-12-05 Thread Daniel P. Berrange
On Tue, Dec 05, 2017 at 10:53:22AM +0100, Cédric Bosdonnat wrote:
> This is particularly useful on operating systems that don't ship
> Python as part of the base system (eg. FreeBSD) while still working
> just as well as it did before on Linux.
> ---
>  bin/virt-sandbox-image   | 2 +-
>  bin/virt-sandbox-service | 2 +-
>  examples/demo.py | 2 +-
>  examples/shell.py| 2 +-
>  examples/virt-sandbox-mkinitrd.py| 2 +-
>  examples/virt-sandbox.py | 2 +-
>  libvirt-sandbox/image/cli.py | 2 +-
>  libvirt-sandbox/image/sources/base.py| 1 -
>  libvirt-sandbox/image/sources/docker.py  | 1 -
>  libvirt-sandbox/image/sources/virtbuilder.py | 1 -
>  10 files changed, 7 insertions(+), 10 deletions(-)

Reviewed-by: Daniel P. Berrange 


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] nwfilter: don't crash listing filters in unprivileged daemon

2017-12-05 Thread John Ferlan


On 12/05/2017 11:41 AM, Daniel P. Berrange wrote:
> The unprivileged libvirtd does not support nwfilter config, by leaves the
> driver active. It is supposed to result in all APIs being an effective
> no-op, but several APIs rely on driver->nwfilters being non-NULL, or they
> will reference a NULL pointer. Rather than adding checks for NULL in many
> places, just make sure  driver->nwfilters is always initialized.
> 
> Signed-off-by: Daniel P. Berrange 
> ---
>  src/nwfilter/nwfilter_driver.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 

I think nwfilterStateCleanup will also need a slight, but obvious
adjustment...

Reviewed-by: John Ferlan 

John

(and since it's in 3.9, I need a bz to handle a backport )

> diff --git a/src/nwfilter/nwfilter_driver.c b/src/nwfilter/nwfilter_driver.c
> index 2f9a51c405..89b767fe11 100644
> --- a/src/nwfilter/nwfilter_driver.c
> +++ b/src/nwfilter/nwfilter_driver.c
> @@ -189,6 +189,8 @@ nwfilterStateInitialize(bool privileged,
>  /* remember that we are going to use firewalld */
>  driver->watchingFirewallD = (sysbus != NULL);
>  driver->privileged = privileged;
> +if (!(driver->nwfilters = virNWFilterObjListNew()))
> +goto error;
>  
>  if (!privileged)
>  return 0;
> @@ -244,9 +246,6 @@ nwfilterStateInitialize(bool privileged,
>  goto error;
>  }
>  
> -if (!(driver->nwfilters = virNWFilterObjListNew()))
> -goto error;
> -
>  if (virNWFilterObjListLoadAllConfigs(driver->nwfilters, 
> driver->configDir) < 0)
>  goto error;
>  
> @@ -271,6 +270,7 @@ nwfilterStateInitialize(bool privileged,
>  virNWFilterIPAddrMapShutdown();
>  
>   err_free_driverstate:
> +virNWFilterObjListFree(driver->nwfilters);
>  VIR_FREE(driver);
>  
>  return -1;
> 

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


[libvirt] [libvirt-php PATCH] Fix crash in VIRT_HASH_CURRENT_KEY_INFO macro

2017-12-05 Thread Dawid Zamirski
The PHP7 variant of the macro wasn't safe if the hash key was not a
string type. This was found when running php script with just
libvirt_connect call under xdebug session which segfaulted. This patch
makes the following changes:

* make sure that tmp_name is initialized to NULL
* set the key name only when zend_hash_get_current_key_ex did set it to
  something which happens only when type is HASH_KEY_IS_STRING
* stash the key index in out php_libvirt_hash_key_info struct because it
  wasn't there before and separate variable had to be used.
---
 src/libvirt-connection.c |  8 +++-
 src/libvirt-php.c|  6 ++
 src/libvirt-php.h|  1 +
 src/util.h   | 16 +---
 4 files changed, 15 insertions(+), 16 deletions(-)

diff --git a/src/libvirt-connection.c b/src/libvirt-connection.c
index 181b266..2d59d82 100644
--- a/src/libvirt-connection.c
+++ b/src/libvirt-connection.c
@@ -131,8 +131,6 @@ PHP_FUNCTION(libvirt_connect)
 HashPosition pointer;
 int array_count;
 
-zend_ulong index;
-
 unsigned long libVer;
 
 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|sba", &url, 
&url_len, &readonly, &zcreds) == FAILURE) {
@@ -176,13 +174,13 @@ PHP_FUNCTION(libvirt_connect)
 VIRT_FOREACH(arr_hash, pointer, data) {
 if (Z_TYPE_P(data) == IS_STRING) {
 php_libvirt_hash_key_info info;
-VIRT_HASH_CURRENT_KEY_INFO(arr_hash, pointer, index, info);
+VIRT_HASH_CURRENT_KEY_INFO(arr_hash, pointer, info);
 
 if (info.type == HASH_KEY_IS_STRING) {
 PHPWRITE(info.name, info.length);
 } else {
-DPRINTF("%s: credentials index %d\n", PHPFUNC, (int)index);
-creds[j].type = index;
+DPRINTF("%s: credentials index %d\n", PHPFUNC, info.index);
+creds[j].type = info.index;
 creds[j].result = (char *)emalloc(Z_STRLEN_P(data) + 1);
 memset(creds[j].result, 0, Z_STRLEN_P(data) + 1);
 creds[j].resultlen = Z_STRLEN_P(data);
diff --git a/src/libvirt-php.c b/src/libvirt-php.c
index ef057fe..efbef58 100644
--- a/src/libvirt-php.c
+++ b/src/libvirt-php.c
@@ -1921,7 +1921,6 @@ long get_next_free_numeric_value(virDomainPtr domain, 
char *xpath)
 HashPosition pointer;
 // int array_count;
 zval *data;
-unsigned long index;
 long max_slot = -1;
 
 xml = virDomainGetXMLDesc(domain, VIR_DOMAIN_XML_INACTIVE);
@@ -1934,7 +1933,7 @@ long get_next_free_numeric_value(virDomainPtr domain, 
char *xpath)
 VIRT_FOREACH(arr_hash, pointer, data) {
 if (Z_TYPE_P(data) == IS_STRING) {
 php_libvirt_hash_key_info info;
-VIRT_HASH_CURRENT_KEY_INFO(arr_hash, pointer, index, info);
+VIRT_HASH_CURRENT_KEY_INFO(arr_hash, pointer, info);
 
 if (info.type != HASH_KEY_IS_STRING) {
 long num = -1;
@@ -2439,7 +2438,6 @@ void parse_array(zval *arr, tVMDisk *disk, tVMNetwork 
*network)
 zval *data;
 php_libvirt_hash_key_info key;
 HashPosition pointer;
-unsigned long index;
 
 arr_hash = Z_ARRVAL_P(arr);
 //array_count = zend_hash_num_elements(arr_hash);
@@ -2451,7 +2449,7 @@ void parse_array(zval *arr, tVMDisk *disk, tVMNetwork 
*network)
 
 VIRT_FOREACH(arr_hash, pointer, data) {
 if ((Z_TYPE_P(data) == IS_STRING) || (Z_TYPE_P(data) == IS_LONG)) {
-VIRT_HASH_CURRENT_KEY_INFO(arr_hash, pointer, index, key);
+VIRT_HASH_CURRENT_KEY_INFO(arr_hash, pointer, key);
 if (key.type == HASH_KEY_IS_STRING) {
 if (disk != NULL) {
 if ((Z_TYPE_P(data) == IS_STRING) && strcmp(key.name, 
"path") == 0)
diff --git a/src/libvirt-php.h b/src/libvirt-php.h
index 8d13a6b..f24a329 100644
--- a/src/libvirt-php.h
+++ b/src/libvirt-php.h
@@ -137,6 +137,7 @@ typedef struct tVMNetwork {
 typedef struct _php_libvirt_hash_key_info {
 char *name;
 unsigned int length;
+unsigned int index;
 unsigned int type;
 } php_libvirt_hash_key_info;
 
diff --git a/src/util.h b/src/util.h
index ecb3a1f..72cfa91 100644
--- a/src/util.h
+++ b/src/util.h
@@ -135,12 +135,14 @@
 
 #  define VIRT_FOREACH_END(_dummy)
 
-#  define VIRT_HASH_CURRENT_KEY_INFO(_ht, _pos, _idx, _info) \
+#  define VIRT_HASH_CURRENT_KEY_INFO(_ht, _pos, _info) \
 do { \
-zend_string *tmp_key_info; \
-_info.type = zend_hash_get_current_key_ex(_ht, &tmp_key_info, &_idx, 
&_pos); \
-_info.name = ZSTR_VAL(tmp_key_info); \
-_info.length = ZSTR_LEN(tmp_key_info); \
+zend_string *tmp_name = NULL; \
+_info.type = zend_hash_get_current_key_ex(_ht, &tmp_name, (zend_ulong *) 
&_info.index, &_pos); \
+if (tmp_name) { \
+_info.name = ZSTR_VAL(tmp_name); \
+_info.length = ZSTR_LEN(tmp_name); \
+} \
 } while(0)
 
 #  define VIRT_ARRAY_INIT(_name) do { \
@@ -213,9 +215,9 @@
 

Re: [libvirt] [PATCH 02/17] qemu: Introduce qemuDomainDeviceDefSkipController

2017-12-05 Thread John Ferlan


On 12/05/2017 09:18 AM, Ján Tomko wrote:
> On Mon, Dec 04, 2017 at 08:38:52PM -0500, John Ferlan wrote:
>> In order to be able to reuse some code for both controller def
>> validation and command line building, create a convenience helper
>> that will perform the "skip" avoidance checks. It will also set
>> some flags to allow the caller to specifically skip (or fail)
>> depending on the result of the flag (as opposed to building up
>> some ever growing list of variables).
>>
>> Signed-off-by: John Ferlan 
>> ---
>> src/qemu/qemu_command.c | 61 +--
>> src/qemu/qemu_domain.c  | 84
>> -
>> src/qemu/qemu_domain.h  | 12 +++
>> 3 files changed, 102 insertions(+), 55 deletions(-)
>>
> 
> [...]
> 
>> diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
>> index 569bbd29e..d4c7674c0 100644
>> --- a/src/qemu/qemu_domain.c
>> +++ b/src/qemu/qemu_domain.c
>> @@ -3884,10 +3884,92 @@ qemuDomainDeviceDefValidateDisk(const
>> virDomainDiskDef *disk)
>> }
>>
>>
>> +/**
>> + * qemuDomainDeviceDefSkipController:
>> + * @controller: Controller to check
>> + * @def: Domain definition
>> + * @flags: qemuDomainDeviceSkipFlags to set if specific condition found
>> + *
>> + * Returns true if this controller can be skipped for command line
>> generation
>> + * or device validation
> 
> We should not skip validation for implicit devices. Some of the checks
> added later are for implicit devices (PCI root, SATA controller).
> 
> It would be enough to split out the logic of figuring out whether the
> controller is implicit out of command line generation.
> 

Obviously the "goal" was to avoid the same checks in Validation that
we're avoiding in command line building; however, if there are things
that need to be checked in Validation before what gets checked here,
then I could see that being "extra".

What I was trying to avoid was duplication of specific checks prior to
Validation that were being avoided anyways for command line building. As
in - we don't build that on the command line, so why bother checking
during validation.

>> + */
>> +bool
>> +qemuDomainDeviceDefSkipController(const virDomainControllerDef
>> *controller,
>> +  const virDomainDef *def,
>> +  unsigned int *flags)
>> +{
>> +    /* skip USB controllers with type none.*/
>> +    if (controller->type == VIR_DOMAIN_CONTROLLER_TYPE_USB &&
>> +    controller->model == VIR_DOMAIN_CONTROLLER_MODEL_USB_NONE) {
>> +    *flags |= QEMU_DOMAIN_DEVICE_SKIP_USB_CONTROLLER_FLAG;
>> +    return true;
>> +    }
> 
> Simply returning true here (no USB controller is implicit) should
> suffice. The caller can figure out whether USB_NONE is present
> by going through the controllers array again (via virDomainDefHasUSB).
> 
>> +
>> +    /* skip pcie-root */
>> +    if (controller->type == VIR_DOMAIN_CONTROLLER_TYPE_PCI &&
>> +    controller->model == VIR_DOMAIN_CONTROLLER_MODEL_PCIE_ROOT)
>> +    return true;
>> +
>> +    /* Skip pci-root, except for pSeries guests (which actually
>> + * support more than one PCI Host Bridge per guest) */
>> +    if (!qemuDomainIsPSeries(def) &&
>> +    controller->type == VIR_DOMAIN_CONTROLLER_TYPE_PCI &&
>> +    controller->model == VIR_DOMAIN_CONTROLLER_MODEL_PCI_ROOT)
>> +    return true;
>> +
>> +    /* first SATA controller on Q35 machines is implicit */
>> +    if (controller->type == VIR_DOMAIN_CONTROLLER_TYPE_SATA &&
>> +    controller->idx == 0 && qemuDomainIsQ35(def))
>> +    return true;
>> +
>> +    /* first IDE controller is implicit on various machines */
>> +    if (controller->type == VIR_DOMAIN_CONTROLLER_TYPE_IDE &&
>> +    controller->idx == 0 && qemuDomainHasBuiltinIDE(def))
>> +    return true;

This one is the initial reason I figured it would be better to have a
Skip helper as opposed to "copying" the same check in the ValidateIDE
code that we'd have in the command line building code.

Then the subsequent ones made the ValidateUSB *so much* easier.

>> +
>> +    if (controller->type == VIR_DOMAIN_CONTROLLER_TYPE_USB &&
>> +    controller->model == -1 &&
>> +    !qemuDomainIsQ35(def) &&
>> +    !qemuDomainIsVirt(def)) {
>> +
>> +    /* An appropriate default USB controller model should already
>> + * have been selected in qemuDomainDeviceDefPostParse(); if
>> + * we still have no model by now, we have to fall back to the
>> + * legacy USB controller.
>> + *
>> + * Note that we *don't* want to end up with the legacy USB
>> + * controller for q35 and virt machines, so we go ahead and
>> + * fail in qemuBuildControllerDevStr(); on the other hand,
>> + * for s390 machines we want to ignore any USB controller
>> + * (see 548ba43028 for the full story), so we skip
>> + * qemuBuildControllerDevStr() but we don't ultimately end
>> +