[libvirt] Question about LSN-2016-0001

2016-07-29 Thread Jim Fehlig
I've noticed the behavior described by this LSN with libvirt+Xen. Config
containing  allows any client to
connect with no authentication check. I asked about this on the Xen security
list and was told that "libxl interprets an empty password in the caller's
configuration to mean that passwordless access should be permitted". The libvirt
domXML docs are not clear on semantics of empty vnc password, only stating "The
passwd attribute provides a VNC password in clear text".

Should the libvirt domXML vnc passwd documentation be amended to define the
semantics of an empty string in the passwd attribute? Is the behavior
hypervisor-dependent as the documentation in qemu.conf suggests?

Regards,
Jim

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


[libvirt] [PATCH 2/9] tests: qemuxml2argv: Fix usb-too-long-port-path-invalid

2016-07-29 Thread Andrea Bolognani
The test case uses DO_TEST_PARSE_FLAGS_ERROR(), but doesn't
pass any parse flag. Use DO_TEST_PARSE_ERROR() instead.
---
 tests/qemuxml2argvtest.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index f3df06b..751d692 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -2064,9 +2064,9 @@ mymain(void)
 DO_TEST("master-key", QEMU_CAPS_OBJECT_SECRET);
 DO_TEST("usb-long-port-path", QEMU_CAPS_CHARDEV, QEMU_CAPS_NODEFCONFIG,
 QEMU_CAPS_USB_HUB);
-DO_TEST_PARSE_FLAGS_ERROR("usb-too-long-port-path-invalid",
-  QEMU_CAPS_CHARDEV,
-  QEMU_CAPS_NODEFCONFIG, QEMU_CAPS_USB_HUB);
+DO_TEST_PARSE_ERROR("usb-too-long-port-path-invalid",
+QEMU_CAPS_CHARDEV,
+QEMU_CAPS_NODEFCONFIG, QEMU_CAPS_USB_HUB);
 
 DO_TEST("acpi-table", NONE);
 DO_TEST("intel-iommu", QEMU_CAPS_DEVICE_PCI_BRIDGE,
-- 
2.7.4

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


[libvirt] [PATCH 8/9] qemu: domain: Reflect USB controller model in guest XML

2016-07-29 Thread Andrea Bolognani
When the user doesn't specify any model for a USB controller,
we use an architecture-dependent default, but we don't reflect
it in the guest XML.

Pick the default USB controller model when parsing the guest
XML instead of when creating the QEMU command line, so that
our choice is saved back to disk.
---
 src/qemu/qemu_domain.c   | 20 
 .../qemuxml2xmlout-ppc64-usb-controller.xml  |  2 +-
 .../qemuxml2xmlout-usb-controller-default-q35.xml|  2 +-
 3 files changed, 22 insertions(+), 2 deletions(-)

diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index 9b439df..ffa7fa7 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -2573,6 +2573,26 @@ qemuDomainDeviceDefPostParse(virDomainDeviceDefPtr dev,
virDomainNumaGetNodeCount(def->numa));
 goto cleanup;
 }
+} else if (cont->type == VIR_DOMAIN_CONTROLLER_TYPE_USB &&
+   cont->model == -1) {
+/* Pick a suitable default model for the USB controller if none
+ * has been selected by the user.
+ *
+ * We rely on device availability instead of setting the model
+ * unconditionally because, for some machine types, there's a
+ * chance we will get away with using the legacy USB controller
+ * when the relevant device is not available.
+ *
+ * See qemuBuildControllerDevCommandLine() */
+if (ARCH_IS_PPC64(def->os.arch)) {
+/* Default USB controller for ppc64 is pci-ohci */
+if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_PCI_OHCI))
+cont->model = VIR_DOMAIN_CONTROLLER_MODEL_USB_PCI_OHCI;
+} else {
+/* Default USB controller for anything else is piix3-uhci */
+if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_PIIX3_USB_UHCI))
+cont->model = VIR_DOMAIN_CONTROLLER_MODEL_USB_PIIX3_UHCI;
+}
 }
 }
 
diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-ppc64-usb-controller.xml 
b/tests/qemuxml2xmloutdata/qemuxml2xmlout-ppc64-usb-controller.xml
index 33e7810..30932e5 100644
--- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-ppc64-usb-controller.xml
+++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-ppc64-usb-controller.xml
@@ -19,7 +19,7 @@
   restart
   
 /usr/libexec/qemu-system-ppc64
-
+
   
 
 
diff --git 
a/tests/qemuxml2xmloutdata/qemuxml2xmlout-usb-controller-default-q35.xml 
b/tests/qemuxml2xmloutdata/qemuxml2xmlout-usb-controller-default-q35.xml
index 8c4f1f5..082a92e 100644
--- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-usb-controller-default-q35.xml
+++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-usb-controller-default-q35.xml
@@ -20,7 +20,7 @@
   
   
 
-
+
   
 
 
-- 
2.7.4

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


[libvirt] [PATCH 0/9] qemu: Reflect USB controller model in guest XML

2016-07-29 Thread Andrea Bolognani
Patches 1-3 take care of some tiny nits; patches 4-7 clean
up the test suite and add some new test cases that cover
the code changed by subsequent patches.

Patch 8 implements the feature advertised in the subject :)

Patch 9 gets rid of some code that's no longer necessary
after the changes.


Andrea Bolognani (9):
  tests: qemuxml2argv: Remove useless GIC flags
  tests: qemuxml2argv: Fix usb-too-long-port-path-invalid
  tests: qemuxml2xml: Fix disk-mirror
  tests: qemuxml2xml: Use WHEN_BOTH for most tests
  tests: qemuxml2xml: Pass capabilities to DO_TEST()
  tests: qemuxml2xml: Use DO_TEST() for most tests
  tests: qemuxml2xml: Add some USB test cases
  qemu: domain: Reflect USB controller model in guest XML
  qemu: command: Simplify USB controller model selection

 src/qemu/qemu_command.c|  60 +-
 src/qemu/qemu_domain.c |  20 +
 tests/qemuxml2argvtest.c   |  16 +-
 .../qemuxml2xmlout-ppc64-usb-controller-legacy.xml |  31 +
 .../qemuxml2xmlout-ppc64-usb-controller.xml|  31 +
 .../qemuxml2xmlout-usb-controller-default-q35.xml  |  37 +
 .../qemuxml2xmlout-usb-controller-explicit-q35.xml |  37 +
 .../qemuxml2xmlout-usb-controller.xml  |  27 +
 .../qemuxml2xmloutdata/qemuxml2xmlout-usb-none.xml |  25 +
 .../qemuxml2xmlout-usb-piix3-controller.xml|  27 +
 tests/qemuxml2xmltest.c| 932 ++---
 11 files changed, 728 insertions(+), 515 deletions(-)
 create mode 100644 
tests/qemuxml2xmloutdata/qemuxml2xmlout-ppc64-usb-controller-legacy.xml
 create mode 100644 
tests/qemuxml2xmloutdata/qemuxml2xmlout-ppc64-usb-controller.xml
 create mode 100644 
tests/qemuxml2xmloutdata/qemuxml2xmlout-usb-controller-default-q35.xml
 create mode 100644 
tests/qemuxml2xmloutdata/qemuxml2xmlout-usb-controller-explicit-q35.xml
 create mode 100644 tests/qemuxml2xmloutdata/qemuxml2xmlout-usb-controller.xml
 create mode 100644 tests/qemuxml2xmloutdata/qemuxml2xmlout-usb-none.xml
 create mode 100644 
tests/qemuxml2xmloutdata/qemuxml2xmlout-usb-piix3-controller.xml

-- 
2.7.4

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


[libvirt] [PATCH 5/9] tests: qemuxml2xml: Pass capabilities to DO_TEST()

2016-07-29 Thread Andrea Bolognani
This will allow us to remove most DO_TEST_FULL() usages. For the
time being, just add the extra argument to all DO_TEST() calls.
---
 tests/qemuxml2xmltest.c | 528 
 1 file changed, 264 insertions(+), 264 deletions(-)

diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c
index aaceb6f..86ce870 100644
--- a/tests/qemuxml2xmltest.c
+++ b/tests/qemuxml2xmltest.c
@@ -353,8 +353,8 @@ mymain(void)
 
 # define NONE QEMU_CAPS_LAST
 
-# define DO_TEST(name) \
-DO_TEST_FULL(name, WHEN_BOTH, GIC_NONE, NONE)
+# define DO_TEST(name, ...) \
+DO_TEST_FULL(name, WHEN_BOTH, GIC_NONE, __VA_ARGS__)
 
 
 
@@ -363,97 +363,97 @@ mymain(void)
  * values for these envvars */
 setenv("PATH", "/bin", 1);
 
-DO_TEST("minimal");
-DO_TEST("machine-core-on");
-DO_TEST("machine-core-off");
-DO_TEST("default-kvm-host-arch");
-DO_TEST("default-qemu-host-arch");
-DO_TEST("boot-cdrom");
-DO_TEST("boot-network");
-DO_TEST("boot-floppy");
-DO_TEST("boot-multi");
-DO_TEST("boot-menu-enable-with-timeout");
-DO_TEST("boot-menu-disable");
-DO_TEST("boot-menu-disable-with-timeout");
-DO_TEST("boot-order");
-
-DO_TEST("reboot-timeout-enabled");
-DO_TEST("reboot-timeout-disabled");
-
-DO_TEST("clock-utc");
-DO_TEST("clock-localtime");
-DO_TEST("cpu-empty");
-DO_TEST("cpu-kvmclock");
-DO_TEST("cpu-host-kvmclock");
-DO_TEST("cpu-host-passthrough-features");
-DO_TEST("cpu-host-model-features");
-DO_TEST("clock-catchup");
-DO_TEST("kvmclock");
-DO_TEST("clock-timer-hyperv-rtc");
-
-DO_TEST("cpu-eoi-disabled");
-DO_TEST("cpu-eoi-enabled");
-DO_TEST("eoi-disabled");
-DO_TEST("eoi-enabled");
-DO_TEST("pv-spinlock-disabled");
-DO_TEST("pv-spinlock-enabled");
-
-DO_TEST("hyperv");
-DO_TEST("hyperv-off");
-DO_TEST("hyperv-panic");
-
-DO_TEST("kvm-features");
-DO_TEST("kvm-features-off");
-
-DO_TEST("pmu-feature");
-DO_TEST("pmu-feature-off");
-
-DO_TEST("hugepages");
-DO_TEST("hugepages-pages");
-DO_TEST("hugepages-pages2");
-DO_TEST("hugepages-pages3");
-DO_TEST("hugepages-shared");
-DO_TEST("nosharepages");
-DO_TEST("restore-v2");
-DO_TEST("migrate");
-DO_TEST("qemu-ns-no-env");
-DO_TEST("disk-aio");
-DO_TEST("disk-cdrom");
-DO_TEST("disk-cdrom-empty");
-DO_TEST("disk-floppy");
-DO_TEST("disk-many");
-DO_TEST("disk-usb-device");
-DO_TEST("disk-virtio");
-DO_TEST("floppy-drive-fat");
-DO_TEST("disk-drive-boot-disk");
-DO_TEST("disk-drive-boot-cdrom");
-DO_TEST("disk-drive-error-policy-stop");
-DO_TEST("disk-drive-error-policy-enospace");
-DO_TEST("disk-drive-error-policy-wreport-rignore");
-DO_TEST("disk-drive-fmt-qcow");
-DO_TEST("disk-drive-copy-on-read");
-DO_TEST("disk-drive-cache-v2-wt");
-DO_TEST("disk-drive-cache-v2-wb");
-DO_TEST("disk-drive-cache-v2-none");
-DO_TEST("disk-drive-cache-directsync");
-DO_TEST("disk-drive-cache-unsafe");
-DO_TEST("disk-drive-network-nbd");
-DO_TEST("disk-drive-network-nbd-export");
-DO_TEST("disk-drive-network-nbd-ipv6");
-DO_TEST("disk-drive-network-nbd-ipv6-export");
-DO_TEST("disk-drive-network-nbd-unix");
-DO_TEST("disk-drive-network-iscsi");
-DO_TEST("disk-drive-network-iscsi-auth");
-DO_TEST("disk-drive-network-gluster");
-DO_TEST("disk-drive-network-rbd");
-DO_TEST("disk-drive-network-rbd-auth");
-DO_TEST("disk-drive-network-rbd-ipv6");
-DO_TEST("disk-drive-network-rbd-ceph-env");
-DO_TEST("disk-drive-network-sheepdog");
+DO_TEST("minimal", NONE);
+DO_TEST("machine-core-on", NONE);
+DO_TEST("machine-core-off", NONE);
+DO_TEST("default-kvm-host-arch", NONE);
+DO_TEST("default-qemu-host-arch", NONE);
+DO_TEST("boot-cdrom", NONE);
+DO_TEST("boot-network", NONE);
+DO_TEST("boot-floppy", NONE);
+DO_TEST("boot-multi", NONE);
+DO_TEST("boot-menu-enable-with-timeout", NONE);
+DO_TEST("boot-menu-disable", NONE);
+DO_TEST("boot-menu-disable-with-timeout", NONE);
+DO_TEST("boot-order", NONE);
+
+DO_TEST("reboot-timeout-enabled", NONE);
+DO_TEST("reboot-timeout-disabled", NONE);
+
+DO_TEST("clock-utc", NONE);
+DO_TEST("clock-localtime", NONE);
+DO_TEST("cpu-empty", NONE);
+DO_TEST("cpu-kvmclock", NONE);
+DO_TEST("cpu-host-kvmclock", NONE);
+DO_TEST("cpu-host-passthrough-features", NONE);
+DO_TEST("cpu-host-model-features", NONE);
+DO_TEST("clock-catchup", NONE);
+DO_TEST("kvmclock", NONE);
+DO_TEST("clock-timer-hyperv-rtc", NONE);
+
+DO_TEST("cpu-eoi-disabled", NONE);
+DO_TEST("cpu-eoi-enabled", NONE);
+DO_TEST("eoi-disabled", NONE);
+DO_TEST("eoi-enabled", NONE);
+DO_TEST("pv-spinlock-disabled", NONE);
+DO_TEST("pv-spinlock-enabled", NONE);
+
+DO_TEST("hyperv", NONE);
+DO_TEST("hyperv-off", NONE);
+

[libvirt] [PATCH 1/9] tests: qemuxml2argv: Remove useless GIC flags

2016-07-29 Thread Andrea Bolognani
DO_TEST_FAILURE() doesn't take a GIC version, but the GIC flag
was passed anyway. Get rid of all such occurrences.
---
 tests/qemuxml2argvtest.c | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index a5d51a8..f3df06b 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -1871,7 +1871,7 @@ mymain(void)
 DO_TEST_GIC("aarch64-gic-v2", GIC_BOTH,
 QEMU_CAPS_KVM, QEMU_CAPS_MACHINE_OPT,
 QEMU_CAPS_MACH_VIRT_GIC_VERSION);
-DO_TEST_FAILURE("aarch64-gic-v3", GIC_NONE,
+DO_TEST_FAILURE("aarch64-gic-v3",
 QEMU_CAPS_KVM, QEMU_CAPS_MACHINE_OPT);
 DO_TEST_GIC("aarch64-gic-v3", GIC_NONE,
 QEMU_CAPS_KVM, QEMU_CAPS_MACHINE_OPT,
@@ -1885,7 +1885,7 @@ mymain(void)
 DO_TEST_GIC("aarch64-gic-v3", GIC_BOTH,
 QEMU_CAPS_KVM, QEMU_CAPS_MACHINE_OPT,
 QEMU_CAPS_MACH_VIRT_GIC_VERSION);
-DO_TEST_FAILURE("aarch64-gic-host", GIC_NONE,
+DO_TEST_FAILURE("aarch64-gic-host",
 QEMU_CAPS_KVM, QEMU_CAPS_MACHINE_OPT);
 DO_TEST_GIC("aarch64-gic-host", GIC_NONE,
 QEMU_CAPS_KVM, QEMU_CAPS_MACHINE_OPT,
@@ -1899,13 +1899,13 @@ mymain(void)
 DO_TEST_GIC("aarch64-gic-host", GIC_BOTH,
 QEMU_CAPS_KVM, QEMU_CAPS_MACHINE_OPT,
 QEMU_CAPS_MACH_VIRT_GIC_VERSION);
-DO_TEST_PARSE_ERROR("aarch64-gic-invalid", GIC_NONE,
+DO_TEST_PARSE_ERROR("aarch64-gic-invalid",
 QEMU_CAPS_KVM, QEMU_CAPS_MACHINE_OPT,
 QEMU_CAPS_MACH_VIRT_GIC_VERSION);
-DO_TEST_FAILURE("aarch64-gic-not-virt", GIC_NONE,
+DO_TEST_FAILURE("aarch64-gic-not-virt",
 QEMU_CAPS_KVM, QEMU_CAPS_MACHINE_OPT,
 QEMU_CAPS_MACH_VIRT_GIC_VERSION);
-DO_TEST_FAILURE("aarch64-gic-not-arm", GIC_NONE,
+DO_TEST_FAILURE("aarch64-gic-not-arm",
 QEMU_CAPS_KVM, QEMU_CAPS_MACHINE_OPT,
 QEMU_CAPS_MACH_VIRT_GIC_VERSION);
 
-- 
2.7.4

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


[libvirt] [PATCH 6/9] tests: qemuxml2xml: Use DO_TEST() for most tests

2016-07-29 Thread Andrea Bolognani
Now that DO_TEST() can be passed capabilities, there is little
need to use DO_TEST_FULL() instead of DO_TEST().
---
 tests/qemuxml2xmltest.c | 353 ++--
 1 file changed, 158 insertions(+), 195 deletions(-)

diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c
index 86ce870..9a9bf5a 100644
--- a/tests/qemuxml2xmltest.c
+++ b/tests/qemuxml2xmltest.c
@@ -450,34 +450,26 @@ mymain(void)
 DO_TEST("disk-drive-network-rbd-ipv6", NONE);
 DO_TEST("disk-drive-network-rbd-ceph-env", NONE);
 DO_TEST("disk-drive-network-sheepdog", NONE);
-DO_TEST_FULL("disk-scsi-device", WHEN_BOTH, GIC_NONE,
- QEMU_CAPS_NODEFCONFIG,
- QEMU_CAPS_SCSI_LSI);
+DO_TEST("disk-scsi-device",
+QEMU_CAPS_NODEFCONFIG, QEMU_CAPS_SCSI_LSI);
 DO_TEST("disk-scsi-vscsi", NONE);
-DO_TEST_FULL("disk-scsi-virtio-scsi", WHEN_BOTH, GIC_NONE,
- QEMU_CAPS_NODEFCONFIG,
- QEMU_CAPS_VIRTIO_SCSI);
-DO_TEST_FULL("disk-virtio-scsi-num_queues", WHEN_BOTH, GIC_NONE,
- QEMU_CAPS_NODEFCONFIG,
- QEMU_CAPS_VIRTIO_SCSI);
-DO_TEST_FULL("disk-virtio-scsi-cmd_per_lun", WHEN_BOTH, GIC_NONE,
- QEMU_CAPS_NODEFCONFIG,
- QEMU_CAPS_VIRTIO_SCSI);
-DO_TEST_FULL("disk-virtio-scsi-max_sectors", WHEN_BOTH, GIC_NONE,
- QEMU_CAPS_NODEFCONFIG,
- QEMU_CAPS_VIRTIO_SCSI);
-DO_TEST_FULL("disk-virtio-scsi-ioeventfd", WHEN_BOTH, GIC_NONE,
- QEMU_CAPS_NODEFCONFIG,
- QEMU_CAPS_VIRTIO_SCSI);
-DO_TEST_FULL("disk-scsi-megasas", WHEN_BOTH, GIC_NONE,
- QEMU_CAPS_NODEFCONFIG,
- QEMU_CAPS_SCSI_MEGASAS);
-DO_TEST_FULL("disk-scsi-mptsas1068", WHEN_BOTH, GIC_NONE,
- QEMU_CAPS_NODEFCONFIG,
- QEMU_CAPS_SCSI_MPTSAS1068,
- QEMU_CAPS_SCSI_DISK_WWN);
+DO_TEST("disk-scsi-virtio-scsi",
+QEMU_CAPS_NODEFCONFIG, QEMU_CAPS_VIRTIO_SCSI);
+DO_TEST("disk-virtio-scsi-num_queues",
+QEMU_CAPS_NODEFCONFIG, QEMU_CAPS_VIRTIO_SCSI);
+DO_TEST("disk-virtio-scsi-cmd_per_lun",
+QEMU_CAPS_NODEFCONFIG, QEMU_CAPS_VIRTIO_SCSI);
+DO_TEST("disk-virtio-scsi-max_sectors",
+QEMU_CAPS_NODEFCONFIG, QEMU_CAPS_VIRTIO_SCSI);
+DO_TEST("disk-virtio-scsi-ioeventfd",
+QEMU_CAPS_NODEFCONFIG, QEMU_CAPS_VIRTIO_SCSI);
+DO_TEST("disk-scsi-megasas",
+QEMU_CAPS_NODEFCONFIG, QEMU_CAPS_SCSI_MEGASAS);
+DO_TEST("disk-scsi-mptsas1068",
+QEMU_CAPS_NODEFCONFIG, QEMU_CAPS_SCSI_MPTSAS1068,
+QEMU_CAPS_SCSI_DISK_WWN);
 DO_TEST("disk-mirror-old", NONE);
-DO_TEST_FULL("disk-mirror", WHEN_BOTH, GIC_NONE, NONE);
+DO_TEST("disk-mirror", NONE);
 DO_TEST_FULL("disk-active-commit", WHEN_ACTIVE, GIC_NONE, NONE);
 DO_TEST("graphics-listen-network", NONE);
 DO_TEST("graphics-vnc", NONE);
@@ -503,7 +495,7 @@ mymain(void)
 DO_TEST("graphics-spice-auto-socket-cfg", NONE);
 cfg->spiceAutoUnixSocket = false;
 
-DO_TEST_FULL("nographics-vga", WHEN_BOTH, GIC_NONE, QEMU_CAPS_DISPLAY);
+DO_TEST("nographics-vga", QEMU_CAPS_DISPLAY);
 DO_TEST("input-usbmouse", NONE);
 DO_TEST("input-usbtablet", NONE);
 DO_TEST("misc-acpi", NONE);
@@ -568,8 +560,8 @@ mymain(void)
 DO_TEST("cputune-iothreadsched", NONE);
 DO_TEST("cputune-iothreadsched-zeropriority", NONE);
 DO_TEST("cputune-numatune", NONE);
-DO_TEST_FULL("vcpu-placement-static", WHEN_BOTH, GIC_NONE,
- QEMU_CAPS_DEVICE_PCI_BRIDGE);
+DO_TEST("vcpu-placement-static",
+QEMU_CAPS_DEVICE_PCI_BRIDGE);
 
 DO_TEST("smp", NONE);
 DO_TEST("iothreads", NONE);
@@ -577,15 +569,13 @@ mymain(void)
 DO_TEST("iothreads-ids-partial", NONE);
 DO_TEST("cputune-iothreads", NONE);
 DO_TEST("iothreads-disk", NONE);
-DO_TEST_FULL("iothreads-disk-virtio-ccw", WHEN_BOTH, GIC_NONE,
- QEMU_CAPS_VIRTIO_CCW, QEMU_CAPS_VIRTIO_S390);
-DO_TEST_FULL("iothreads-virtio-scsi-pci", WHEN_BOTH, GIC_NONE,
- QEMU_CAPS_NODEFCONFIG,
- QEMU_CAPS_VIRTIO_SCSI);
-DO_TEST_FULL("iothreads-virtio-scsi-ccw", WHEN_BOTH, GIC_NONE,
- QEMU_CAPS_VIRTIO_SCSI,
- QEMU_CAPS_VIRTIO_CCW,
- QEMU_CAPS_VIRTIO_S390);
+DO_TEST("iothreads-disk-virtio-ccw",
+QEMU_CAPS_VIRTIO_CCW, QEMU_CAPS_VIRTIO_S390);
+DO_TEST("iothreads-virtio-scsi-pci",
+QEMU_CAPS_NODEFCONFIG, QEMU_CAPS_VIRTIO_SCSI);
+DO_TEST("iothreads-virtio-scsi-ccw",
+QEMU_CAPS_VIRTIO_SCSI, QEMU_CAPS_VIRTIO_CCW,
+QEMU_CAPS_VIRTIO_S390);
 DO_TEST("lease", NONE);
 DO_TEST("event_idx", NONE);
 DO_TEST("vhost_queues", NONE);
@@ -613,14 +603,12 @@ mymain(void)
 DO_TEST_FULL("seclabel-dynamic-none-relabel", WHEN_INACTIVE, GIC_NONE, 
NONE);
 

Re: [libvirt] [PATCH python 1/2] Python binding for node poll lifecycle events API

2016-07-29 Thread Cole Robinson
On 07/28/2016 08:14 AM, Jovanka Gulicoska wrote:
> ---
>  generator.py   |   2 +
>  libvirt-override-virConnect.py |  45 
>  libvirt-override.c | 153 
> +
>  sanitytest.py  |   3 +
>  4 files changed, 203 insertions(+)
> 
> diff --git a/generator.py b/generator.py
> index 82f13e9..730e456 100755
> --- a/generator.py
> +++ b/generator.py
> @@ -525,6 +525,8 @@ skip_function = (
>  'virConnectNetworkEventDeregisterAny', # overridden in virConnect.py
>  'virConnectStoragePoolEventRegisterAny',   # overridden in virConnect.py
>  'virConnectStoragePoolEventDeregisterAny', # overridden in virConnect.py
> +'virConnectNodeDeviceEventRegisterAny',   # overridden in virConnect.py
> +'virConnectNodeDeviceEventDeregisterAny', # overridden in virConnect.py
>  'virSaveLastError', # We have our own python error wrapper
>  'virFreeError', # Only needed if we use virSaveLastError
>  'virConnectListAllDomains', # overridden in virConnect.py
> diff --git a/libvirt-override-virConnect.py b/libvirt-override-virConnect.py
> index b085b07..fb3d476 100644
> --- a/libvirt-override-virConnect.py
> +++ b/libvirt-override-virConnect.py
> @@ -347,6 +347,51 @@
>  self.storagePoolEventCallbackID[ret] = opaque
>  return ret
>  
> +def _dispatchNodeDeviceEventLifecycleCallback(self, dev, event, detail, 
> cbData):
> +"""Dispatches events to python user node device
> +   lifecycle event callbacks
> +"""
> +cb = cbData["cb"]
> +opaque = cbData["opaque"]
> +
> +cb(self, virNodeDevice(self, _obj=dev), event, detail, opaque)
> +return 0
> +
> +def _dispatchNodeDeviceEventGenericCallback(self, dev, cbData):
> +"""Dispatches events to python user node device
> +   generic event callbacks
> +"""
> +cb = cbData["cb"]
> +opaque = cbData["opaque"]
> +
> +cb(self, virNodeDevice(self, _obj=dev), opaque)
> +return 0
> +

The GenericCallback isn't used anywhere, so this can be dropped. I've made
that change and applied these locally, I'll push after the release.

Thanks,
Cole

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


[libvirt] [PATCH 4/9] tests: qemuxml2xml: Use WHEN_BOTH for most tests

2016-07-29 Thread Andrea Bolognani
A bunch of cases were only being tested for WHEN_ACTIVE or
WHEN_INACTIVE. Use WHEN_BOTH for all except the very few that
actually require the existing setup.
---
 tests/qemuxml2xmltest.c | 96 -
 1 file changed, 48 insertions(+), 48 deletions(-)

diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c
index 2af8245..aaceb6f 100644
--- a/tests/qemuxml2xmltest.c
+++ b/tests/qemuxml2xmltest.c
@@ -450,29 +450,29 @@ mymain(void)
 DO_TEST("disk-drive-network-rbd-ipv6");
 DO_TEST("disk-drive-network-rbd-ceph-env");
 DO_TEST("disk-drive-network-sheepdog");
-DO_TEST_FULL("disk-scsi-device", WHEN_ACTIVE, GIC_NONE,
+DO_TEST_FULL("disk-scsi-device", WHEN_BOTH, GIC_NONE,
  QEMU_CAPS_NODEFCONFIG,
  QEMU_CAPS_SCSI_LSI);
 DO_TEST("disk-scsi-vscsi");
-DO_TEST_FULL("disk-scsi-virtio-scsi", WHEN_ACTIVE, GIC_NONE,
+DO_TEST_FULL("disk-scsi-virtio-scsi", WHEN_BOTH, GIC_NONE,
  QEMU_CAPS_NODEFCONFIG,
  QEMU_CAPS_VIRTIO_SCSI);
-DO_TEST_FULL("disk-virtio-scsi-num_queues", WHEN_ACTIVE, GIC_NONE,
+DO_TEST_FULL("disk-virtio-scsi-num_queues", WHEN_BOTH, GIC_NONE,
  QEMU_CAPS_NODEFCONFIG,
  QEMU_CAPS_VIRTIO_SCSI);
-DO_TEST_FULL("disk-virtio-scsi-cmd_per_lun", WHEN_ACTIVE, GIC_NONE,
+DO_TEST_FULL("disk-virtio-scsi-cmd_per_lun", WHEN_BOTH, GIC_NONE,
  QEMU_CAPS_NODEFCONFIG,
  QEMU_CAPS_VIRTIO_SCSI);
-DO_TEST_FULL("disk-virtio-scsi-max_sectors", WHEN_ACTIVE, GIC_NONE,
+DO_TEST_FULL("disk-virtio-scsi-max_sectors", WHEN_BOTH, GIC_NONE,
  QEMU_CAPS_NODEFCONFIG,
  QEMU_CAPS_VIRTIO_SCSI);
-DO_TEST_FULL("disk-virtio-scsi-ioeventfd", WHEN_ACTIVE, GIC_NONE,
+DO_TEST_FULL("disk-virtio-scsi-ioeventfd", WHEN_BOTH, GIC_NONE,
  QEMU_CAPS_NODEFCONFIG,
  QEMU_CAPS_VIRTIO_SCSI);
-DO_TEST_FULL("disk-scsi-megasas", WHEN_ACTIVE, GIC_NONE,
+DO_TEST_FULL("disk-scsi-megasas", WHEN_BOTH, GIC_NONE,
  QEMU_CAPS_NODEFCONFIG,
  QEMU_CAPS_SCSI_MEGASAS);
-DO_TEST_FULL("disk-scsi-mptsas1068", WHEN_ACTIVE, GIC_NONE,
+DO_TEST_FULL("disk-scsi-mptsas1068", WHEN_BOTH, GIC_NONE,
  QEMU_CAPS_NODEFCONFIG,
  QEMU_CAPS_SCSI_MPTSAS1068,
  QEMU_CAPS_SCSI_DISK_WWN);
@@ -568,7 +568,7 @@ mymain(void)
 DO_TEST("cputune-iothreadsched");
 DO_TEST("cputune-iothreadsched-zeropriority");
 DO_TEST("cputune-numatune");
-DO_TEST_FULL("vcpu-placement-static", WHEN_ACTIVE, GIC_NONE,
+DO_TEST_FULL("vcpu-placement-static", WHEN_BOTH, GIC_NONE,
  QEMU_CAPS_DEVICE_PCI_BRIDGE);
 
 DO_TEST("smp");
@@ -577,12 +577,12 @@ mymain(void)
 DO_TEST("iothreads-ids-partial");
 DO_TEST("cputune-iothreads");
 DO_TEST("iothreads-disk");
-DO_TEST_FULL("iothreads-disk-virtio-ccw", WHEN_ACTIVE, GIC_NONE,
+DO_TEST_FULL("iothreads-disk-virtio-ccw", WHEN_BOTH, GIC_NONE,
  QEMU_CAPS_VIRTIO_CCW, QEMU_CAPS_VIRTIO_S390);
-DO_TEST_FULL("iothreads-virtio-scsi-pci", WHEN_ACTIVE, GIC_NONE,
+DO_TEST_FULL("iothreads-virtio-scsi-pci", WHEN_BOTH, GIC_NONE,
  QEMU_CAPS_NODEFCONFIG,
  QEMU_CAPS_VIRTIO_SCSI);
-DO_TEST_FULL("iothreads-virtio-scsi-ccw", WHEN_ACTIVE, GIC_NONE,
+DO_TEST_FULL("iothreads-virtio-scsi-ccw", WHEN_BOTH, GIC_NONE,
  QEMU_CAPS_VIRTIO_SCSI,
  QEMU_CAPS_VIRTIO_CCW,
  QEMU_CAPS_VIRTIO_S390);
@@ -613,11 +613,11 @@ mymain(void)
 DO_TEST_FULL("seclabel-dynamic-none-relabel", WHEN_INACTIVE, GIC_NONE, 
NONE);
 DO_TEST("numad-static-vcpu-no-numatune");
 
-DO_TEST_FULL("disk-scsi-lun-passthrough-sgio", WHEN_ACTIVE, GIC_NONE,
+DO_TEST_FULL("disk-scsi-lun-passthrough-sgio", WHEN_BOTH, GIC_NONE,
  QEMU_CAPS_NODEFCONFIG,
  QEMU_CAPS_SCSI_CD, QEMU_CAPS_SCSI_LSI, QEMU_CAPS_VIRTIO_SCSI,
  QEMU_CAPS_SCSI_DISK_WWN);
-DO_TEST_FULL("disk-scsi-disk-vpd", WHEN_ACTIVE, GIC_NONE,
+DO_TEST_FULL("disk-scsi-disk-vpd", WHEN_BOTH, GIC_NONE,
  QEMU_CAPS_NODEFCONFIG,
  QEMU_CAPS_SCSI_CD, QEMU_CAPS_SCSI_LSI, QEMU_CAPS_VIRTIO_SCSI,
  QEMU_CAPS_SCSI_DISK_WWN);
@@ -638,7 +638,7 @@ mymain(void)
 DO_TEST("balloon-device-period");
 DO_TEST("channel-virtio-auto");
 DO_TEST("console-compat-auto");
-DO_TEST_FULL("disk-scsi-device-auto", WHEN_ACTIVE, GIC_NONE,
+DO_TEST_FULL("disk-scsi-device-auto", WHEN_BOTH, GIC_NONE,
  QEMU_CAPS_NODEFCONFIG,
  QEMU_CAPS_SCSI_LSI);
 DO_TEST("console-virtio");
@@ -655,38 +655,38 @@ mymain(void)
 DO_TEST("metadata");
 DO_TEST("metadata-duplicate");
 
-DO_TEST_FULL("pci-bridge", WHEN_ACTIVE, GIC_NONE,
+DO_TEST_FULL("pci-bridge", WHEN_BOTH, GIC_NONE,
 

[libvirt] [PATCH 3/9] tests: qemuxml2xml: Fix disk-mirror

2016-07-29 Thread Andrea Bolognani
Instead of testing it twice using WHEN_ACTIVE and WHEN_INACTIVE
separately, just use WHEN_BOTH.
---
 tests/qemuxml2xmltest.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c
index 5f04b8b..2af8245 100644
--- a/tests/qemuxml2xmltest.c
+++ b/tests/qemuxml2xmltest.c
@@ -477,8 +477,7 @@ mymain(void)
  QEMU_CAPS_SCSI_MPTSAS1068,
  QEMU_CAPS_SCSI_DISK_WWN);
 DO_TEST("disk-mirror-old");
-DO_TEST_FULL("disk-mirror", WHEN_ACTIVE, GIC_NONE, NONE);
-DO_TEST_FULL("disk-mirror", WHEN_INACTIVE, GIC_NONE, NONE);
+DO_TEST_FULL("disk-mirror", WHEN_BOTH, GIC_NONE, NONE);
 DO_TEST_FULL("disk-active-commit", WHEN_ACTIVE, GIC_NONE, NONE);
 DO_TEST("graphics-listen-network");
 DO_TEST("graphics-vnc");
-- 
2.7.4

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


[libvirt] [PATCH 7/9] tests: qemuxml2xml: Add some USB test cases

2016-07-29 Thread Andrea Bolognani
All these configurations are already covered for qemuxml2argv,
but there were no equivalent tests for qemuxml2xml.
---
 .../qemuxml2xmlout-ppc64-usb-controller-legacy.xml | 31 ++
 .../qemuxml2xmlout-ppc64-usb-controller.xml| 31 ++
 .../qemuxml2xmlout-usb-controller-default-q35.xml  | 37 ++
 .../qemuxml2xmlout-usb-controller-explicit-q35.xml | 37 ++
 .../qemuxml2xmlout-usb-controller.xml  | 27 
 .../qemuxml2xmloutdata/qemuxml2xmlout-usb-none.xml | 25 +++
 .../qemuxml2xmlout-usb-piix3-controller.xml| 27 
 tests/qemuxml2xmltest.c| 16 ++
 8 files changed, 231 insertions(+)
 create mode 100644 
tests/qemuxml2xmloutdata/qemuxml2xmlout-ppc64-usb-controller-legacy.xml
 create mode 100644 
tests/qemuxml2xmloutdata/qemuxml2xmlout-ppc64-usb-controller.xml
 create mode 100644 
tests/qemuxml2xmloutdata/qemuxml2xmlout-usb-controller-default-q35.xml
 create mode 100644 
tests/qemuxml2xmloutdata/qemuxml2xmlout-usb-controller-explicit-q35.xml
 create mode 100644 tests/qemuxml2xmloutdata/qemuxml2xmlout-usb-controller.xml
 create mode 100644 tests/qemuxml2xmloutdata/qemuxml2xmlout-usb-none.xml
 create mode 100644 
tests/qemuxml2xmloutdata/qemuxml2xmlout-usb-piix3-controller.xml

diff --git 
a/tests/qemuxml2xmloutdata/qemuxml2xmlout-ppc64-usb-controller-legacy.xml 
b/tests/qemuxml2xmloutdata/qemuxml2xmlout-ppc64-usb-controller-legacy.xml
new file mode 100644
index 000..33e7810
--- /dev/null
+++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-ppc64-usb-controller-legacy.xml
@@ -0,0 +1,31 @@
+
+  QEMUGuest1
+  c7a5fdbd-edaf-9455-926a-d65c16db1809
+  219100
+  219100
+  1
+  
+hvm
+
+  
+  
+
+
+
+  
+  
+  destroy
+  restart
+  restart
+  
+/usr/libexec/qemu-system-ppc64
+
+  
+
+
+
+  
+
+
+  
+
diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-ppc64-usb-controller.xml 
b/tests/qemuxml2xmloutdata/qemuxml2xmlout-ppc64-usb-controller.xml
new file mode 100644
index 000..33e7810
--- /dev/null
+++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-ppc64-usb-controller.xml
@@ -0,0 +1,31 @@
+
+  QEMUGuest1
+  c7a5fdbd-edaf-9455-926a-d65c16db1809
+  219100
+  219100
+  1
+  
+hvm
+
+  
+  
+
+
+
+  
+  
+  destroy
+  restart
+  restart
+  
+/usr/libexec/qemu-system-ppc64
+
+  
+
+
+
+  
+
+
+  
+
diff --git 
a/tests/qemuxml2xmloutdata/qemuxml2xmlout-usb-controller-default-q35.xml 
b/tests/qemuxml2xmloutdata/qemuxml2xmlout-usb-controller-default-q35.xml
new file mode 100644
index 000..8c4f1f5
--- /dev/null
+++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-usb-controller-default-q35.xml
@@ -0,0 +1,37 @@
+
+  q35-test
+  11dbdcdd-4c3b-482b-8903-9bdb8c0a2774
+  2097152
+  2097152
+  1
+  
+hvm
+
+  
+  
+  destroy
+  restart
+  destroy
+  
+/usr/libexec/qemu-kvm
+
+
+  
+  
+  
+
+
+  
+
+
+  
+
+
+  
+  
+
+
+
+
+  
+
diff --git 
a/tests/qemuxml2xmloutdata/qemuxml2xmlout-usb-controller-explicit-q35.xml 
b/tests/qemuxml2xmloutdata/qemuxml2xmlout-usb-controller-explicit-q35.xml
new file mode 100644
index 000..540e817
--- /dev/null
+++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-usb-controller-explicit-q35.xml
@@ -0,0 +1,37 @@
+
+  q35-test
+  11dbdcdd-4c3b-482b-8903-9bdb8c0a2774
+  2097152
+  2097152
+  1
+  
+hvm
+
+  
+  
+  destroy
+  restart
+  destroy
+  
+/usr/libexec/qemu-kvm
+
+
+  
+  
+  
+
+
+  
+
+
+  
+
+
+  
+  
+
+
+
+
+  
+
diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-usb-controller.xml 
b/tests/qemuxml2xmloutdata/qemuxml2xmlout-usb-controller.xml
new file mode 100644
index 000..d37b985
--- /dev/null
+++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-usb-controller.xml
@@ -0,0 +1,27 @@
+
+  QEMUGuest1
+  c7a5fdbd-edaf-9455-926a-d65c16db1809
+  219136
+  219136
+  1
+  
+hvm
+
+  
+  
+  destroy
+  restart
+  destroy
+  
+/usr/bin/qemu
+
+  
+
+
+
+
+
+  
+
+  
+
diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-usb-none.xml 
b/tests/qemuxml2xmloutdata/qemuxml2xmlout-usb-none.xml
new file mode 100644
index 000..37e5e50
--- /dev/null
+++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-usb-none.xml
@@ -0,0 +1,25 @@
+
+  QEMUGuest1
+  c7a5fdbd-edaf-9455-926a-d65c16db1809
+  219136
+  219136
+  1
+  
+hvm
+
+  
+  
+  destroy
+  restart
+  destroy
+  
+/usr/bin/qemu
+
+
+
+
+
+  
+
+  
+
diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-usb-piix3-controller.xml 
b/tests/qemuxml2xmloutdata/qemuxml2xmlout-usb-piix3-controller.xml
new file mode 100644
index 000..a565953
--- /dev/null
+++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-usb-piix3-controller.xml
@@ -0,0 +1,27 @@
+

[libvirt] [PATCH 9/9] qemu: command: Simplify USB controller model selection

2016-07-29 Thread Andrea Bolognani
Since we now pick the default USB controller model when parsing
the guest XML, we can get rid of some duplicated code so that
the default model selection happens in one place only.

Add some comments as well.
---
 src/qemu/qemu_command.c | 60 -
 1 file changed, 30 insertions(+), 30 deletions(-)

diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 5325f48..d53620c 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -2387,8 +2387,7 @@ qemuControllerModelUSBToCaps(int model)
 
 
 static int
-qemuBuildUSBControllerDevStr(const virDomainDef *domainDef,
- virDomainControllerDefPtr def,
+qemuBuildUSBControllerDevStr(virDomainControllerDefPtr def,
  virQEMUCapsPtr qemuCaps,
  virBuffer *buf)
 {
@@ -2398,10 +2397,9 @@ qemuBuildUSBControllerDevStr(const virDomainDef 
*domainDef,
 model = def->model;
 
 if (model == -1) {
-if ARCH_IS_PPC64(domainDef->os.arch)
-model = VIR_DOMAIN_CONTROLLER_MODEL_USB_PCI_OHCI;
-else
-model = VIR_DOMAIN_CONTROLLER_MODEL_USB_PIIX3_UHCI;
+virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+   "%s", _("no model provided for USB controller"));
+return -1;
 }
 
 smodel = qemuControllerModelUSBTypeToString(model);
@@ -2630,7 +2628,7 @@ qemuBuildControllerDevStr(const virDomainDef *domainDef,
 break;
 
 case VIR_DOMAIN_CONTROLLER_TYPE_USB:
-if (qemuBuildUSBControllerDevStr(domainDef, def, qemuCaps, ) == -1)
+if (qemuBuildUSBControllerDevStr(def, qemuCaps, ) == -1)
 goto error;
 
 if (nusbcontroller)
@@ -3010,30 +3008,29 @@ qemuBuildControllerDevCommandLine(virCommandPtr cmd,
 
 if (cont->type == VIR_DOMAIN_CONTROLLER_TYPE_USB &&
 cont->model == -1 &&
-!qemuDomainMachineIsQ35(def)) {
-bool need_legacy = false;
-
-/* We're not using legacy usb controller for q35 */
-if (ARCH_IS_PPC64(def->os.arch)) {
-/* For ppc64 the legacy was OHCI */
-if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_PCI_OHCI))
-need_legacy = true;
-} else {
-/* For anything else, we used PIIX3_USB_UHCI */
-if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_PIIX3_USB_UHCI))
-need_legacy = true;
-}
-
-if (need_legacy) {
-if (usblegacy) {
-virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
-   _("Multiple legacy USB controllers are "
- "not supported"));
-return -1;
-}
-usblegacy = true;
-continue;
+!qemuDomainMachineIsQ35(def) &&
+!qemuDomainMachineIsVirt(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 (usblegacy) {
+virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+   _("Multiple legacy USB controllers are "
+ "not supported"));
+return -1;
 }
+usblegacy = true;
+continue;
 }
 
 virCommandAddArg(cmd, "-device");
@@ -3045,6 +3042,9 @@ qemuBuildControllerDevCommandLine(virCommandPtr cmd,
 }
 }
 
+/* We haven't added any USB controller yet, but we haven't been asked
+ * not to add one either. Add a legacy USB controller, unless we're
+ * creating a kind of guest we want to keep legacy-free */
 if (usbcontroller == 0 &&
 !qemuDomainMachineIsQ35(def) &&
 !qemuDomainMachineIsVirt(def) &&
-- 
2.7.4

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


Re: [libvirt] [PATCH 2/2] virpci: support driver_override sysfs interface

2016-07-29 Thread Laine Stump

On 07/11/2016 02:23 PM, Jim Fehlig wrote:

Currently, libvirt uses the new_id PCI sysfs interface to bind a PCI
stub driver to a PCI device. The new_id interface is known to be
buggy and racey, hence a more deterministic interface was introduced
in the 3.12 kernel - driver_override. For more details see

https://www.redhat.com/archives/libvir-list/2016-June/msg02124.html

This patch changes the stub binding/unbinding code to use the
driver_override interface if present. If not present, the new_id
interface will be used to provide compatibility with older kernels
lacking driver_override.

Signed-off-by: Jim Fehlig 
---
  src/util/virpci.c | 199 +-
  1 file changed, 152 insertions(+), 47 deletions(-)

diff --git a/src/util/virpci.c b/src/util/virpci.c
index 127b3b6..3c2fc9f 100644
--- a/src/util/virpci.c
+++ b/src/util/virpci.c
@@ -1158,6 +1158,19 @@ virPCIDeviceUnbindFromStub(virPCIDevicePtr dev)
  
  VIR_DEBUG("Reprobing for PCI device %s", dev->name);
  
+/* Remove driver_override if it exists */

+VIR_FREE(path);
+if (!(path = virPCIFile(dev->name, "driver_override")))
+goto cleanup;
+
+if (virFileExists(path) && virFileWriteStr(path, "\n", 0) < 0) {
+virReportSystemError(errno,
+ _("Failed to remove stub driver from "
+   "driver_override interface of PCI device '%s'"),
+ dev->name);
+goto cleanup;
+}
+


For unbinding the stub, you're just adding in the "clearing" of 
driver_override, without eliminating any of the other stuff that's done 
for the older deprecated method. If the driver_override file exists, you 
shouldn't do *any* of the old operations, just do what is described in 
the commit log message of the patch that added driver_override to the 
kernel:


  https://www.redhat.com/archives/libvir-list/2014-May/msg00670.html

I'll review the rest of it based on what ends up in the code rather than 
the diffs, since the diffs will be messed up when you get rid of patch 
1/2...




  /* Trigger a re-probe of the device is not in the stub's dynamic
   * ID table. If the stub is available, but 'remove_id' isn't
   * available, then re-probing would just cause the device to be
@@ -1193,49 +1206,13 @@ virPCIDeviceUnbindFromStub(virPCIDevicePtr dev)
  
  
  static int

-virPCIDeviceBindToStub(virPCIDevicePtr dev)
+virPCIDeviceBindToStubWithNewid(virPCIDevicePtr dev,
+const char *stubDriverName)
  {
-int result = -1;
-char *stubDriverPath = NULL;
-char *driverLink = NULL;
-char *path = NULL; /* reused for different purposes */
-const char *stubDriverName = NULL;
+int ret = -1;
+char *path = NULL;
  virErrorPtr err = NULL;
  
-/* Check the device is configured to use one of the known stub drivers */

-if (dev->stubDriver == VIR_PCI_STUB_DRIVER_NONE) {
-virReportError(VIR_ERR_INTERNAL_ERROR,
-   _("No stub driver configured for PCI device %s"),
-   dev->name);
-return -1;
-} else if (!(stubDriverName = 
virPCIStubDriverTypeToString(dev->stubDriver))) {
-virReportError(VIR_ERR_INTERNAL_ERROR,
-   _("Unknown stub driver configured for PCI device %s"),
-   dev->name);
-return -1;
-}
-
-if (!(stubDriverPath = virPCIDriverDir(stubDriverName))  ||
-!(driverLink = virPCIFile(dev->name, "driver")))
-goto cleanup;
-
-if (virFileExists(driverLink)) {
-if (virFileLinkPointsTo(driverLink, stubDriverPath)) {
-/* The device is already bound to the correct driver */
-VIR_DEBUG("Device %s is already bound to %s",
-  dev->name, stubDriverName);
-dev->unbind_from_stub = true;
-dev->remove_slot = true;
-result = 0;
-goto cleanup;
-}
-/*
- * If the device is bound to a driver that is not the stub,  we'll
- * need to reprobe later
- */
-dev->reprobe = true;
-}
-
  /* Add the PCI device ID to the stub's dynamic ID table;
   * this is needed to allow us to bind the device to the stub.
   * Note: if the device is not currently bound to any driver,
@@ -1283,7 +1260,7 @@ virPCIDeviceBindToStub(virPCIDevicePtr dev)
  }
  dev->unbind_from_stub = true;
  
-result = 0;

+ret = 0;
  
   remove_id:

  err = virSaveLastError();
@@ -1299,7 +1276,7 @@ virPCIDeviceBindToStub(virPCIDevicePtr dev)
   "cannot be probed again.", dev->id, stubDriverName);
  }
  dev->reprobe = false;
-result = -1;
+ret = -1;
  goto cleanup;
  }
  
@@ -1314,11 +1291,143 @@ virPCIDeviceBindToStub(virPCIDevicePtr dev)

   "cannot be probed again.", dev->id, stubDriverName);

Re: [libvirt] [PATCH] wireshark dissector compile fix

2016-07-29 Thread Benedikt Spranger
Am Fri, 29 Jul 2016 12:27:16 +0100
schrieb "Daniel P. Berrange" :

> On Fri, Jul 29, 2016 at 12:43:41PM +0200, Benedikt Spranger wrote:
> > Compiling libvirt wireshark dissector on a debian based system
> > failed: CC
> > wireshark/src/wireshark_src_libvirt_la-packet-libvirt.lo In file
> > included
> > from ../../libvirt/tools/wireshark/src/packet-libvirt.c:27:0: 
> > /usr/include/wireshark/epan/proto.h:40:18:
> > fatal error: glib.h: No such file or directory compilation
> > terminated. Makefile:2595: recipe for target
> > 'wireshark/src/wireshark_src_libvirt_la-packet-libvirt.lo' failed
> > 
> > Add an explicit dependency to glib.  
> 
> This is a bug in wireshark packages in debian that they should fix
> there.
see debian bug #832926

But IMHO this is half of the truth.

> Libvirt shouldn't be hardcoding knowledge about what other libs
> wireshark may happen to depend on.
I disagree here. libvirt explicit includes "glib.h" here. Therfore it
has a direct dependency to glib and this dependency should be checked.
Implicit dependencies tend to be a can of worms.

Regards
Benedikt Spranger

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


Re: [libvirt] [PATCH v2 8/8] virsh: Introduce nodedev-event command

2016-07-29 Thread Cole Robinson
On 07/28/2016 08:02 AM, Jovanka Gulicoska wrote:
> Add nodedev-event support for node device lifecycle events
> ---
>  tools/virsh-nodedev.c | 182 
> ++
>  tools/virsh.pod   |  18 +
>  2 files changed, 200 insertions(+)
> 
> diff --git a/tools/virsh-nodedev.c b/tools/virsh-nodedev.c
> index a715b61..5edcf34 100644
> --- a/tools/virsh-nodedev.c
> +++ b/tools/virsh-nodedev.c
> @@ -31,6 +31,7 @@
>  #include "viralloc.h"
>  #include "virfile.h"
>  #include "virstring.h"
> +#include "virtime.h"
>  #include "conf/node_device_conf.h"
>  
>  /*
> @@ -739,6 +740,181 @@ cmdNodeDeviceReset(vshControl *ctl, const vshCmd *cmd)
>  return ret;
>  }
>  
> +/*
> + * "nodedev-event" command
> + */
> +VIR_ENUM_DECL(virshNodeDeviceEvent)
> +VIR_ENUM_IMPL(virshNodeDeviceEvent,
> +  VIR_NODE_DEVICE_EVENT_LAST,
> +  N_("Created"),
> +  N_("Deleted"))
> +
> +static const char *
> +virshNodeDeviceEventToString(int event)
> +{
> +const char *str = virshNodeDeviceEventTypeToString(event);
> +return str ? _(str) : _("unknown");
> +}
> +
> +struct virshNodeDeviceEventData {
> +vshControl *ctl;
> +bool loop;
> +bool timestamp;
> +int count;
> +};
> +typedef struct virshNodeDeviceEventData virshNodeDeviceEventData;
> +
> +VIR_ENUM_DECL(virshNodeDeviceEventId)
> +VIR_ENUM_IMPL(virshNodeDeviceEventId,
> +  VIR_NODE_DEVICE_EVENT_ID_LAST,
> +  "lifecycle")
> +
> +static void
> +vshEventLifecyclePrint(virConnectPtr conn ATTRIBUTE_UNUSED,
> +   virNodeDevicePtr dev,
> +   int event,
> +   int detail ATTRIBUTE_UNUSED,
> +   void *opaque)
> +{
> +virshNodeDeviceEventData *data = opaque;
> +
> +if (!data->loop && data->count)
> +return;
> +
> +if (data->timestamp) {
> +char timestamp[VIR_TIME_STRING_BUFLEN];
> +
> +if (virTimeStringNowRaw(timestamp) < 0)
> +timestamp[0] = '\0';
> +
> +vshPrint(data->ctl, _("%s: event 'lifecycle' for node device %s: 
> %s\n"),
> + timestamp,
> + virNodeDeviceGetName(dev), 
> virshNodeDeviceEventToString(event));
> +} else {
> +vshPrint(data->ctl, _("event 'lifecycle' for node device %s: %s\n"),
> + virNodeDeviceGetName(dev), 
> virshNodeDeviceEventToString(event));
> +}
> +
> +data->count++;
> +if (!data->loop)
> +vshEventDone(data->ctl);
> +}
> +
> +static const vshCmdInfo info_node_device_event[] = {
> +{.name = "help",
> + .data = N_("Node Device Events")
> +},
> +{.name = "desc",
> + .data = N_("List event types, or wait for node device events to occur")
> +},
> +{.name = NULL}
> +};
> +
> +static const vshCmdOptDef opts_node_device_event[] = {
> +{.name = "node device",
> + .type = VSH_OT_STRING,
> + .help = N_("filter by node device name")
> +},
> +{.name = "event",
> + .type = VSH_OT_STRING,
> + .help = N_("which event type to wait for")
> +},
> +{.name = "loop",
> + .type = VSH_OT_BOOL,
> + .help = N_("loop until timeout or interrupt, rather than one-shot")
> +},
> +{.name = "timeout",
> + .type = VSH_OT_INT,
> + .help = N_("timeout seconds")
> +},
> +{.name = "list",
> + .type = VSH_OT_BOOL,
> + .help = N_("list valid event types")
> +},
> +{.name = "timestamp",
> + .type = VSH_OT_BOOL,
> + .help = N_("show timestamp for each printed event")
> +},
> +{.name = NULL}
> +};
> +
> +static bool
> +cmdNodeDeviceEvent(vshControl *ctl, const vshCmd *cmd)
> +{
> +virNodeDevicePtr dev = NULL;
> +bool ret = false;
> +int eventId = -1;
> +int timeout = 0;
> +virshNodeDeviceEventData data;
> +const char *eventName = NULL;
> +const char *device_value = NULL;
> +int event;
> +virshControlPtr priv = ctl->privData;
> +
> +if (vshCommandOptBool(cmd, "list")) {
> +size_t i;
> +
> +for (i = 0; i < VIR_NODE_DEVICE_EVENT_ID_LAST; i++)
> +vshPrint(ctl, "%s\n", virshNodeDeviceEventIdTypeToString(i));
> +return true;
> +}
> +
> +if (vshCommandOptStringReq(ctl, cmd, "event", ) < 0)
> +return false;
> +if (!eventName) {
> +vshError(ctl, "%s", _("either --list or event type is required"));
> +return false;
> +}
> +if ((event = virshNodeDeviceEventIdTypeFromString(eventName)) < 0) {
> +vshError(ctl, _("unknown event type %s"), eventName);
> +return false;
> +}
> +
> +data.ctl = ctl;
> +data.loop = vshCommandOptBool(cmd, "loop");
> +data.timestamp = vshCommandOptBool(cmd, "timestamp");
> +data.count = 0;
> +if (vshCommandOptTimeoutToMs(ctl, cmd, ) < 0)
> +return false;
> +
> +if (vshCommandOptStringReq(ctl, cmd, "device", _value) < 0)
> + return false;

Actually it looks like 

Re: [libvirt] [PATCH v2 6/8] node_device: Implement event queue in udev

2016-07-29 Thread Cole Robinson
On 07/28/2016 08:02 AM, Jovanka Gulicoska wrote:
> ---
>  src/node_device/node_device_udev.c | 46 
> ++
>  1 file changed, 37 insertions(+), 9 deletions(-)
> 
> diff --git a/src/node_device/node_device_udev.c 
> b/src/node_device/node_device_udev.c
> index 76c60ea..e7a407f 100644
> --- a/src/node_device/node_device_udev.c
> +++ b/src/node_device/node_device_udev.c
> @@ -28,6 +28,7 @@
>  
>  #include "dirname.h"
>  #include "node_device_conf.h"
> +#include "node_device_event.h"
>  #include "node_device_driver.h"
>  #include "node_device_linux_sysfs.h"
>  #include "node_device_udev.h"
> @@ -1024,22 +1025,31 @@ static int udevGetDeviceDetails(struct udev_device 
> *device,
>  static int udevRemoveOneDevice(struct udev_device *device)
>  {
>  virNodeDeviceObjPtr dev = NULL;
> +virObjectEventPtr event = NULL;
>  const char *name = NULL;
> -int ret = 0;
> +int ret = -1;
>  
>  name = udev_device_get_syspath(device);
>  dev = virNodeDeviceFindBySysfsPath(>devs, name);
>  
> -if (dev != NULL) {
> -VIR_DEBUG("Removing device '%s' with sysfs path '%s'",
> -  dev->def->name, name);
> -virNodeDeviceObjRemove(>devs, dev);
> -} else {
> +if (!dev) {
>  VIR_DEBUG("Failed to find device to remove that has udev name '%s'",
>name);
> -ret = -1;
> +goto cleanup;
>  }
>  
> +event = virNodeDeviceEventLifecycleNew(dev->def->name,
> +   VIR_NODE_DEVICE_EVENT_DELETED,
> +   0);
> +
> +VIR_DEBUG("Removing device '%s' with sysfs path '%s'",
> +  dev->def->name, name);
> +virNodeDeviceObjRemove(>devs, dev);
> +
> +ret = 0;
> + cleanup:
> +if (event)
> +virObjectEventStateQueue(driver->nodeDeviceEventState, event);
>  return ret;
>  }
>  
> @@ -1096,6 +1106,8 @@ static int udevAddOneDevice(struct udev_device *device)
>  {
>  virNodeDeviceDefPtr def = NULL;
>  virNodeDeviceObjPtr dev = NULL;
> +virObjectEventPtr event = NULL;
> +bool new_device;
>  int ret = -1;
>  
>  if (VIR_ALLOC(def) != 0)
> @@ -1119,17 +1131,28 @@ static int udevAddOneDevice(struct udev_device 
> *device)
>  if (udevSetParent(device, def) != 0)
>  goto cleanup;
>  
> +dev = virNodeDeviceFindByName(>devs, def->name);
> +new_device = !!dev;

I know I recommended this little tidbit offline, but the logic is actually
wrong :) new_device should be !dev

> +if (new_device)
> +nodeDeviceUnlock();
> +

Wrong unlock call, we need to unlock 'dev', not the whole driver.

>  /* If this is a device change, the old definition will be freed
>   * and the current definition will take its place. */
>  dev = virNodeDeviceAssignDef(>devs, def);
> -if (dev == NULL)
> -goto cleanup;
> +

We shouldn't drop this NULL check either.

These were the only issues in the patch series, so applied locally with this
stuff fixed:

diff --git a/src/node_device/node_device_udev.c
b/src/node_device/node_device_udev.c
index e7a407f..4182d5b 100644
--- a/src/node_device/node_device_udev.c
+++ b/src/node_device/node_device_udev.c
@@ -1107,7 +1107,7 @@ static int udevAddOneDevice(struct udev_device *device)
 virNodeDeviceDefPtr def = NULL;
 virNodeDeviceObjPtr dev = NULL;
 virObjectEventPtr event = NULL;
-bool new_device;
+bool new_device = true;
 int ret = -1;

 if (VIR_ALLOC(def) != 0)
@@ -1132,13 +1132,16 @@ static int udevAddOneDevice(struct udev_device *device)
 goto cleanup;

 dev = virNodeDeviceFindByName(>devs, def->name);
-new_device = !!dev;
-if (new_device)
-nodeDeviceUnlock();
+if (dev) {
+virNodeDeviceObjUnlock(dev);
+new_device = false;
+}

 /* If this is a device change, the old definition will be freed
  * and the current definition will take its place. */
 dev = virNodeDeviceAssignDef(>devs, def);
+if (dev == NULL)
+goto cleanup;

 if (new_device)
 event = virNodeDeviceEventLifecycleNew(dev->def->name,


I'll push after the 2.1.0 release is out!

Thanks,
Cole

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


Re: [libvirt] [PATCH 2/8] Add virtio revision attribute to memballoon

2016-07-29 Thread Daniel P. Berrange
On Fri, Jul 29, 2016 at 03:37:38PM +0200, Ján Tomko wrote:
> 
>   
> 
> 
> https://bugzilla.redhat.com/show_bug.cgi?id=1227354
> ---
>  docs/formatdomain.html.in  |  9 
>  docs/schemas/domaincommon.rng  | 14 ++
>  src/conf/domain_conf.c | 46 +++
>  src/conf/domain_conf.h |  9 
>  .../qemuxml2argv-virtio-revision.xml   | 53 
> ++
>  .../qemuxml2xmlout-virtio-revision.xml | 53 
> ++
>  tests/qemuxml2xmltest.c|  2 +
>  7 files changed, 186 insertions(+)
>  create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-virtio-revision.xml
>  create mode 100644 
> tests/qemuxml2xmloutdata/qemuxml2xmlout-virtio-revision.xml
> 
> diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
> index 8efd6af..3c3ec32 100644
> --- a/docs/formatdomain.html.in
> +++ b/docs/formatdomain.html.in
> @@ -6379,6 +6379,15 @@ qemu-kvm -net nic,model=? /dev/null
>Since 1.1.1, requires QEMU 1.5
>  
>
> +  virtio
> +  
> +
> +  An optional virtio can be used to enforce a particular
> +  virtio revision in QEMU. The valid values for the 
> revision
> +  are 0 and 1.

Per your cover letter the actual versions are 0.9 and 1.0, so I think
we should use those and not shorten it to just 0 & 1.


Regards,
Daniel
-- 
|: http://berrange.com  -o-http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org  -o- http://virt-manager.org :|
|: http://autobuild.org   -o- http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org   -o-   http://live.gnome.org/gtk-vnc :|

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

Re: [libvirt] [PATCH 8/8] qemu: format options for enforcing virtio revisions

2016-07-29 Thread Daniel P. Berrange
On Fri, Jul 29, 2016 at 03:37:44PM +0200, Ján Tomko wrote:
> https://bugzilla.redhat.com/show_bug.cgi?id=1227354
> 
> Translate the optional  attribute to
> disable-legacy=on/off and disable-modern=on/off options
> for the following devices:
> 
> virtio-balloon-pci
>   virtio-blk-pci
> virtio-scsi-pci
> virtio-serial-pci
> virtio-9p-pci
>  virtio-net-pci
>virtio-rng-pci

What about  and . The latter in fact only supports v1.0,
but we should still have the config there I think

Regards,
Daniel
-- 
|: http://berrange.com  -o-http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org  -o- http://virt-manager.org :|
|: http://autobuild.org   -o- http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org   -o-   http://live.gnome.org/gtk-vnc :|

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

[libvirt] [PATCH v2] virsh: use virConnectGetDomainCapabilities with maxvcpus

2016-07-29 Thread Shivaprasad G Bhat
virsh maxvcpus --type kvm output is useless on PPC. Also, in
commit e6806d79 we documented not rely on virConnectGetMaxVcpus
output. Fix the  maxvcpus to use virConnectGetDomainCapabilities
now to make it useful. The call is made to use the default emulator
binary and to check for the host machine and arch which is what the
command intends to show anyway.

Signed-off-by: Shivaprasad G Bhat 
---
 tools/virsh-host.c |   26 --
 1 file changed, 24 insertions(+), 2 deletions(-)

diff --git a/tools/virsh-host.c b/tools/virsh-host.c
index 57f0c0e..dd6ff4e 100644
--- a/tools/virsh-host.c
+++ b/tools/virsh-host.c
@@ -606,15 +606,37 @@ static bool
 cmdMaxvcpus(vshControl *ctl, const vshCmd *cmd)
 {
 const char *type = NULL;
-int vcpus;
+int vcpus = -1;
+char *caps = NULL;
+const unsigned int flags = 0; /* No flags so far */
+xmlDocPtr xml = NULL;
+xmlXPathContextPtr ctxt = NULL;
 virshControlPtr priv = ctl->privData;
 
 if (vshCommandOptStringReq(ctl, cmd, "type", ) < 0)
 return false;
 
+caps = virConnectGetDomainCapabilities(priv->conn, NULL, NULL, NULL, type, 
flags);
+if (!caps)
+goto fallback;
+
+xml = virXMLParseStringCtxt(caps, _("(domainCapabilities)"), );
+if (!xml) {
+VIR_FREE(caps);
+goto fallback;
+}
+
+virXPathInt("string(./vcpu[1]/@max)", ctxt, );
+
+xmlXPathFreeContext(ctxt);
+xmlFreeDoc(xml);
+if (vcpus > 0)
+goto exit;
+
+ fallback:
 if ((vcpus = virConnectGetMaxVcpus(priv->conn, type)) < 0)
 return false;
-
+ exit:
 vshPrint(ctl, "%d\n", vcpus);
 
 return true;

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


Re: [libvirt] [PATCH] admin: Fix the default uri for session daemon to libvirtd:///session

2016-07-29 Thread Michal Privoznik
On 29.07.2016 14:08, Daniel P. Berrange wrote:
> On Fri, Jul 29, 2016 at 02:06:00PM +0200, Erik Skultety wrote:
>> Just like we decide on which URI we go with based on EUID for qemu in remote
>> driver, do a similar thing for admin except we do not spawn a daemon in this
>> case.
> 
> IMHO we should auto-spawn the daemon too, so we have consistent
> behaviour virsh virsh.
> 

I don't think this is a good idea. The session daemon dies after 30
seconds after last connection was closed. There's no point in setting
something via admin API just to find it back on defaults after 1 minute
because new daemon has been spawned. It's not like our domain APIs where
libvirt refreshes the internal state of drivers upon their init.

Michal

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


[libvirt] [PATCH 7/8] Add virtio revision to rng devices

2016-07-29 Thread Ján Tomko

  /dev/random
  


https://bugzilla.redhat.com/show_bug.cgi?id=1227354
---
 docs/formatdomain.html.in   | 9 +
 docs/schemas/domaincommon.rng   | 3 +++
 src/conf/domain_conf.c  | 5 +
 src/conf/domain_conf.h  | 1 +
 tests/qemuxml2argvdata/qemuxml2argv-virtio-revision.xml | 5 +
 tests/qemuxml2xmloutdata/qemuxml2xmlout-virtio-revision.xml | 5 +
 6 files changed, 28 insertions(+)

diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index 6c8ea15..bc9a3db 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -6502,6 +6502,15 @@ qemu-kvm -net nic,model=? /dev/null
   
 
   
+  virtio
+  
+
+  An optional virtio element can be used to enforce a 
particular
+  virtio revision in QEMU. The valid values for the 
revision
+  are 0 and 1.
+  Since 2.2.0
+
+  
 
 
 
diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
index 05351a0..dbaa1d7 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -4750,6 +4750,9 @@
 
   
 
+
+  
+
   
 
   
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index bb91b0c..9f1f20f 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -12046,6 +12046,9 @@ virDomainRNGDefParseXML(xmlNodePtr node,
 if (virDomainDeviceInfoParseXML(node, NULL, >info, flags) < 0)
 goto error;
 
+if (virDomainVirtioRevisionParseXML(ctxt, >virtio_rev) < 0)
+goto error;
+
  cleanup:
 VIR_FREE(model);
 VIR_FREE(backend);
@@ -21690,6 +21693,8 @@ virDomainRNGDefFormat(virBufferPtr buf,
 return -1;
 }
 
+virDomainVirtioRevisionFormatXML(buf, def->virtio_rev);
+
 virBufferAdjustIndent(buf, -2);
 virBufferAddLit(buf, "\n");
 return 0;
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 880930f..9c806a4 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -1942,6 +1942,7 @@ struct _virDomainRNGDef {
 } source;
 
 virDomainDeviceInfo info;
+virDomainVirtioRevision virtio_rev;
 };
 
 typedef enum {
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-virtio-revision.xml 
b/tests/qemuxml2argvdata/qemuxml2argv-virtio-revision.xml
index 2e13808..94c844e 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-virtio-revision.xml
+++ b/tests/qemuxml2argvdata/qemuxml2argv-virtio-revision.xml
@@ -98,5 +98,10 @@
   
   
 
+
+  /dev/random
+  
+  
+
   
 
diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-virtio-revision.xml 
b/tests/qemuxml2xmloutdata/qemuxml2xmlout-virtio-revision.xml
index 2e13808..94c844e 100644
--- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-virtio-revision.xml
+++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-virtio-revision.xml
@@ -98,5 +98,10 @@
   
   
 
+
+  /dev/random
+  
+  
+
   
 
-- 
2.7.3

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


[libvirt] [PATCH 5/8] Add virtio revision attribute to filesystems

2016-07-29 Thread Ján Tomko

   ...
   


https://bugzilla.redhat.com/show_bug.cgi?id=1227354
---
 docs/formatdomain.html.in   | 10 ++
 docs/schemas/domaincommon.rng   |  3 +++
 src/conf/domain_conf.c  |  6 ++
 src/conf/domain_conf.h  |  1 +
 tests/qemuxml2argvdata/qemuxml2argv-virtio-revision.xml | 13 +
 tests/qemuxml2xmloutdata/qemuxml2xmlout-virtio-revision.xml | 13 +
 6 files changed, 46 insertions(+)

diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index 703dd26..fa8124d 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -2963,6 +2963,16 @@
 hard limit is enforced.
 Since 0.9.13
   
+
+  virtio
+  
+
+  An optional virtio element can be used to enforce a 
particular
+  virtio revision in QEMU. The valid values for the 
revision
+  are 0 and 1.
+  Since 2.2.0
+
+  
 
 
 Device Addresses
diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
index c24a060..24616a9 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -2079,6 +2079,9 @@
 
   
 
+
+  
+
   
 
   
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 844cd4b..7fa50d3 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -8688,6 +8688,9 @@ virDomainFSDefParseXML(xmlNodePtr node,
 goto error;
 }
 
+if (virDomainVirtioRevisionParseXML(ctxt, >virtio_rev) < 0)
+goto error;
+
 def->src->path = source;
 source = NULL;
 def->dst = target;
@@ -20334,6 +20337,9 @@ virDomainFSDefFormat(virBufferPtr buf,
 virBufferAsprintf(buf, ""
   "%llu\n", def->space_soft_limit);
 }
+
+virDomainVirtioRevisionFormatXML(buf, def->virtio_rev);
+
 virBufferAdjustIndent(buf, -2);
 virBufferAddLit(buf, "\n");
 return 0;
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 18b5bbd..af46c64 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -824,6 +824,7 @@ struct _virDomainFSDef {
 unsigned long long space_hard_limit; /* in bytes */
 unsigned long long space_soft_limit; /* in bytes */
 bool symlinksResolved;
+virDomainVirtioRevision virtio_rev;
 };
 
 
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-virtio-revision.xml 
b/tests/qemuxml2argvdata/qemuxml2argv-virtio-revision.xml
index b8fa986..2ee3533 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-virtio-revision.xml
+++ b/tests/qemuxml2argvdata/qemuxml2argv-virtio-revision.xml
@@ -48,6 +48,19 @@
 
   
 
+
+  
+  
+  
+  
+
+
+  
+  
+  
+  
+  
+
 
   
 
diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-virtio-revision.xml 
b/tests/qemuxml2xmloutdata/qemuxml2xmlout-virtio-revision.xml
index b8fa986..2ee3533 100644
--- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-virtio-revision.xml
+++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-virtio-revision.xml
@@ -48,6 +48,19 @@
 
   
 
+
+  
+  
+  
+  
+
+
+  
+  
+  
+  
+  
+
 
   
 
-- 
2.7.3

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


[libvirt] [PATCH 8/8] qemu: format options for enforcing virtio revisions

2016-07-29 Thread Ján Tomko
https://bugzilla.redhat.com/show_bug.cgi?id=1227354

Translate the optional  attribute to
disable-legacy=on/off and disable-modern=on/off options
for the following devices:

virtio-balloon-pci
  virtio-blk-pci
virtio-scsi-pci
virtio-serial-pci
virtio-9p-pci
 virtio-net-pci
   virtio-rng-pci
---
 src/qemu/qemu_command.c| 31 
 .../qemuxml2argv-virtio-revision.args  | 58 ++
 tests/qemuxml2argvtest.c   | 10 
 3 files changed, 99 insertions(+)
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-virtio-revision.args

diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 5325f48..db38279 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -386,6 +386,23 @@ qemuBuildDeviceAddressStr(virBufferPtr buf,
 return ret;
 }
 
+static void
+qemuBuildVirtioRevisionStr(virBufferPtr buf,
+   virDomainVirtioRevision rev)
+{
+switch (rev) {
+case VIR_DOMAIN_VIRTIO_REVISION_HERITAGE:
+virBufferAddLit(buf, ",disable-legacy=off,disable-modern=on");
+break;
+case VIR_DOMAIN_VIRTIO_REVISION_CONTEMPORARY:
+virBufferAddLit(buf, ",disable-legacy=on,disable-modern=off");
+break;
+case VIR_DOMAIN_VIRTIO_REVISION_DEFAULT:
+case VIR_DOMAIN_VIRTIO_REVISION_LAST:
+break;
+}
+}
+
 static int
 qemuBuildRomStr(virBufferPtr buf,
 virDomainDeviceInfoPtr info)
@@ -1992,6 +2009,9 @@ qemuBuildDriveDevStr(const virDomainDef *def,
   (disk->device == VIR_DOMAIN_DISK_DEVICE_LUN)
   ? "on" : "off");
 }
+
+qemuBuildVirtioRevisionStr(, disk->virtio_rev);
+
 if (qemuBuildDeviceAddressStr(, def, >info, qemuCaps) < 0)
 goto error;
 break;
@@ -2311,6 +2331,8 @@ qemuBuildFSDevStr(const virDomainDef *def,
   QEMU_FSDEV_HOST_PREFIX, fs->info.alias);
 virBufferAsprintf(, ",mount_tag=%s", fs->dst);
 
+qemuBuildVirtioRevisionStr(, fs->virtio_rev);
+
 if (qemuBuildDeviceAddressStr(, def, >info, qemuCaps) < 0)
 goto error;
 
@@ -2568,6 +2590,7 @@ qemuBuildControllerDevStr(const virDomainDef *domainDef,
   def->iothread);
 }
 }
+qemuBuildVirtioRevisionStr(, def->virtio_rev);
 break;
 case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_LSILOGIC:
 virBufferAddLit(, "lsi");
@@ -2613,6 +2636,7 @@ qemuBuildControllerDevStr(const virDomainDef *domainDef,
 virBufferAsprintf(, ",vectors=%d",
   def->opts.vioserial.vectors);
 }
+qemuBuildVirtioRevisionStr(, def->virtio_rev);
 break;
 
 case VIR_DOMAIN_CONTROLLER_TYPE_CCID:
@@ -3557,6 +3581,9 @@ qemuBuildNicDevStr(virDomainDefPtr def,
 virBufferAsprintf(, ",id=%s", net->info.alias);
 virBufferAsprintf(, ",mac=%s",
   virMacAddrFormat(>mac, macaddr));
+
+qemuBuildVirtioRevisionStr(, net->virtio_rev);
+
 if (qemuBuildDeviceAddressStr(, def, >info, qemuCaps) < 0)
 goto error;
 if (qemuBuildRomStr(, >info) < 0)
@@ -3827,6 +3854,8 @@ qemuBuildMemballoonCommandLine(virCommandPtr cmd,
   
virTristateSwitchTypeToString(def->memballoon->autodeflate));
 }
 
+qemuBuildVirtioRevisionStr(, def->memballoon->virtio_rev);
+
 virCommandAddArg(cmd, "-device");
 virCommandAddArgBuffer(cmd, );
 return 0;
@@ -5564,6 +5593,8 @@ qemuBuildRNGDevStr(const virDomainDef *def,
 virBufferAddLit(, ",period=1000");
 }
 
+qemuBuildVirtioRevisionStr(, dev->virtio_rev);
+
 if (qemuBuildDeviceAddressStr(, def, >info, qemuCaps) < 0)
 goto error;
 if (virBufferCheckError() < 0)
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-virtio-revision.args 
b/tests/qemuxml2argvdata/qemuxml2argv-virtio-revision.args
new file mode 100644
index 000..9ba70af
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-virtio-revision.args
@@ -0,0 +1,58 @@
+LC_ALL=C \
+PATH=/bin \
+HOME=/home/test \
+USER=test \
+LOGNAME=test \
+QEMU_AUDIO_DRV=none \
+/usr/bin/qemu \
+-name QEMUGuest1 \
+-S \
+-M pc \
+-m 214 \
+-smp 1,sockets=1,cores=1,threads=1 \
+-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \
+-nographic \
+-nodefaults \
+-monitor unix:/tmp/lib/domain--1-QEMUGuest1/monitor.sock,server,nowait \
+-no-acpi \
+-boot c \
+-device virtio-scsi-pci,disable-legacy=off,disable-modern=on,id=scsi0,\
+bus=pci.0,addr=0x8 \
+-device virtio-serial-pci,id=virtio-serial0,bus=pci.0,addr=0x9 \
+-usb \
+-drive file=/var/lib/libvirt/images/img1,format=raw,if=none,\
+id=drive-virtio-disk0 \
+-device 
virtio-blk-pci,disable-legacy=off,disable-modern=on,bus=pci.0,addr=0xa,\
+drive=drive-virtio-disk0,id=virtio-disk0 \
+-drive file=/var/lib/libvirt/images/img2,format=raw,if=none,\

[libvirt] [PATCH 4/8] Add virtio revision attribute to controllers

2016-07-29 Thread Ján Tomko




https://bugzilla.redhat.com/show_bug.cgi?id=1227354
---
 docs/formatdomain.html.in   |  8 
 docs/schemas/domaincommon.rng   |  3 +++
 src/conf/domain_conf.c  |  4 
 src/conf/domain_conf.h  |  1 +
 tests/qemuxml2argvdata/qemuxml2argv-virtio-revision.xml | 10 ++
 tests/qemuxml2xmloutdata/qemuxml2xmlout-virtio-revision.xml | 10 ++
 6 files changed, 36 insertions(+)

diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index 6ddd7ef..703dd26 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -3116,6 +3116,14 @@
   additional attributes that control specific features, such as:
 
 
+
+  For virtio controllers, an optional virtio element
+  can be used to enforce a particular virtio revision in QEMU.
+  The valid values for the revision
+  are 0 and 1.
+  Since 2.2.0
+
+
   
 virtio-serial
 The virtio-serial controller has two additional
diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
index 41a00a2..c24a060 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -1926,6 +1926,9 @@
 
   
 
+
+  
+
   
 
   
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 3a64c35..844cd4b 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -8285,6 +8285,9 @@ virDomainControllerDefParseXML(xmlNodePtr node,
 cur = cur->next;
 }
 
+if (virDomainVirtioRevisionParseXML(ctxt, >virtio_rev) < 0)
+goto error;
+
 /* node is parsed differently from target attributes because
  * someone thought it should be a subelement instead...
  */
@@ -20210,6 +20213,7 @@ virDomainControllerDefFormat(virBufferPtr buf,
 virBufferAsprintf(buf, "%lu\n", def->opts.pciopts.pcihole64size);
 }
+virDomainVirtioRevisionFormatXML(buf, def->virtio_rev);
 
 virBufferAdjustIndent(buf, -2);
 virBufferAddLit(buf, "\n");
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 0dbd3fd..18b5bbd 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -761,6 +761,7 @@ struct _virDomainControllerDef {
 virDomainUSBControllerOpts usbopts;
 } opts;
 virDomainDeviceInfo info;
+virDomainVirtioRevision virtio_rev;
 };
 
 
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-virtio-revision.xml 
b/tests/qemuxml2argvdata/qemuxml2argv-virtio-revision.xml
index 691fd5b..b8fa986 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-virtio-revision.xml
+++ b/tests/qemuxml2argvdata/qemuxml2argv-virtio-revision.xml
@@ -28,12 +28,22 @@
   
   
 
+
+  
+  
+  
+  
+
 
   
 
 
   
 
+
+  
+  
+
 
 
   
diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-virtio-revision.xml 
b/tests/qemuxml2xmloutdata/qemuxml2xmlout-virtio-revision.xml
index 691fd5b..b8fa986 100644
--- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-virtio-revision.xml
+++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-virtio-revision.xml
@@ -28,12 +28,22 @@
   
   
 
+
+  
+  
+  
+  
+
 
   
 
 
   
 
+
+  
+  
+
 
 
   
-- 
2.7.3

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


[libvirt] [PATCH 3/8] Add virtio revision attribute to disks

2016-07-29 Thread Ján Tomko

  


https://bugzilla.redhat.com/show_bug.cgi?id=1227354
---
 docs/formatdomain.html.in  |  9 +
 docs/schemas/domaincommon.rng  |  3 +++
 src/conf/domain_conf.c |  4 
 src/conf/domain_conf.h |  1 +
 tests/qemuxml2argvdata/qemuxml2argv-virtio-revision.xml| 14 ++
 .../qemuxml2xmloutdata/qemuxml2xmlout-virtio-revision.xml  | 14 ++
 6 files changed, 45 insertions(+)

diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index 3c3ec32..6ddd7ef 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -2776,6 +2776,15 @@
   
 
   
+  virtio
+  
+
+  An optional virtio element can be used to enforce a 
particular
+  virtio revision in QEMU. The valid values for the 
revision
+  are 0 and 1.
+  Since 2.2.0
+
+  
 
 
 Filesystems
diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
index 7043cee..41a00a2 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -1183,6 +1183,9 @@
   
 
   
+  
+
+  
 
   
   
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 7ae07e8..3a64c35 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -7673,6 +7673,9 @@ virDomainDiskDefParseXML(virDomainXMLOptionPtr xmlopt,
 }
 }
 
+if (virDomainVirtioRevisionParseXML(ctxt, >virtio_rev) < 0)
+goto error;
+
 /* Disk volume types will have authentication information handled in
  * virStorageTranslateDiskSourcePool
  */
@@ -20055,6 +20058,7 @@ virDomainDiskDefFormat(virBufferPtr buf,
 if (virDomainDeviceInfoFormat(buf, >info,
   flags | VIR_DOMAIN_DEF_FORMAT_ALLOW_BOOT) < 
0)
 return -1;
+virDomainVirtioRevisionFormatXML(buf, def->virtio_rev);
 
 virBufferAdjustIndent(buf, -2);
 virBufferAddLit(buf, "\n");
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index ba5ad70..0dbd3fd 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -620,6 +620,7 @@ struct _virDomainDiskDef {
 unsigned int iothread; /* unused = 0, > 0 specific thread # */
 int detect_zeroes; /* enum virDomainDiskDetectZeroes */
 char *domain_name; /* backend domain name */
+virDomainVirtioRevision virtio_rev;
 };
 
 
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-virtio-revision.xml 
b/tests/qemuxml2argvdata/qemuxml2argv-virtio-revision.xml
index efa94fe..691fd5b 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-virtio-revision.xml
+++ b/tests/qemuxml2argvdata/qemuxml2argv-virtio-revision.xml
@@ -14,6 +14,20 @@
   destroy
   
 /usr/bin/qemu
+
+  
+  
+  
+  
+  
+
+
+  
+  
+  
+  
+  
+
 
   
 
diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-virtio-revision.xml 
b/tests/qemuxml2xmloutdata/qemuxml2xmlout-virtio-revision.xml
index efa94fe..691fd5b 100644
--- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-virtio-revision.xml
+++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-virtio-revision.xml
@@ -14,6 +14,20 @@
   destroy
   
 /usr/bin/qemu
+
+  
+  
+  
+  
+  
+
+
+  
+  
+  
+  
+  
+
 
   
 
-- 
2.7.3

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


[libvirt] [PATCH 6/8] Add virtio revision attribute to intefaces

2016-07-29 Thread Ján Tomko

  
  
  


https://bugzilla.redhat.com/show_bug.cgi?id=1227354
---
 docs/formatdomain.html.in   |  8 +++-
 docs/schemas/domaincommon.rng   |  3 +++
 src/conf/domain_conf.c  |  5 +
 src/conf/domain_conf.h  |  1 +
 tests/qemuxml2argvdata/qemuxml2argv-virtio-revision.xml | 12 
 tests/qemuxml2xmloutdata/qemuxml2xmlout-virtio-revision.xml | 12 
 6 files changed, 40 insertions(+), 1 deletion(-)

diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index fa8124d..6c8ea15 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -4012,6 +4012,12 @@
   attribute type='pci'
   as documented above.
 
+
+  An optional virtio element can be used to enforce a 
particular
+  virtio revision in QEMU. The valid values for the revision
+  are 0 and 1.
+  Since 2.2.0
+
 
 Virtual network
 
@@ -6409,7 +6415,7 @@ qemu-kvm -net nic,model=? /dev/null
   virtio
   
 
-  An optional virtio can be used to enforce a particular
+  An optional virtio element can be used to enforce a 
particular
   virtio revision in QEMU. The valid values for the 
revision
   are 0 and 1.
   Since 2.2.0
diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
index 24616a9..05351a0 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -2372,6 +2372,9 @@
   
 
   
+  
+
+  
 
   
   

[libvirt] [PATCH 1/8] Fix indentation

2016-07-29 Thread Ján Tomko
---
 src/conf/domain_conf.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index a56e0f5..4999dea 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -8824,7 +8824,7 @@ virDomainActualNetDefParseXML(xmlNodePtr node,
 
 vlanNode = virXPathNode("./vlan", ctxt);
 if (vlanNode && virNetDevVlanParse(vlanNode, ctxt, >vlan) < 0)
-   goto error;
+goto error;
 
 *def = actual;
 actual = NULL;
-- 
2.7.3

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


[libvirt] [PATCH RFC 0/8] qemu: allow disabling certain virtio revisions

2016-07-29 Thread Ján Tomko
For https://bugzilla.redhat.com/show_bug.cgi?id=1227354

some users might want to adjust the QEMU defaults and disable
either virtio 0.9 or virtio 1.0 (spelled out as disable-legacy
and disable-modern on qemu command line).

This series uses a separate  element
right under the relevant device element for consistency,
even though it might fit better in different subelemets for
some of them.

Ján Tomko (8):
  Fix indentation
  Add virtio revision attribute to memballoon
  Add virtio revision attribute to disks
  Add virtio revision attribute to controllers
  Add virtio revision attribute to filesystems
  Add virtio revision attribute to intefaces
  Add virtio revision to rng devices
  qemu: format options for enforcing virtio revisions

 docs/formatdomain.html.in  |  51 ++
 docs/schemas/domaincommon.rng  |  29 ++
 src/conf/domain_conf.c |  72 +-
 src/conf/domain_conf.h |  14 +++
 src/qemu/qemu_command.c|  31 ++
 .../qemuxml2argv-virtio-revision.args  |  58 +++
 .../qemuxml2argv-virtio-revision.xml   | 107 +
 tests/qemuxml2argvtest.c   |  10 ++
 .../qemuxml2xmlout-virtio-revision.xml | 107 +
 tests/qemuxml2xmltest.c|   2 +
 10 files changed, 480 insertions(+), 1 deletion(-)
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-virtio-revision.args
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-virtio-revision.xml
 create mode 100644 tests/qemuxml2xmloutdata/qemuxml2xmlout-virtio-revision.xml

-- 
2.7.3

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

[libvirt] [PATCH 2/8] Add virtio revision attribute to memballoon

2016-07-29 Thread Ján Tomko

  


https://bugzilla.redhat.com/show_bug.cgi?id=1227354
---
 docs/formatdomain.html.in  |  9 
 docs/schemas/domaincommon.rng  | 14 ++
 src/conf/domain_conf.c | 46 +++
 src/conf/domain_conf.h |  9 
 .../qemuxml2argv-virtio-revision.xml   | 53 ++
 .../qemuxml2xmlout-virtio-revision.xml | 53 ++
 tests/qemuxml2xmltest.c|  2 +
 7 files changed, 186 insertions(+)
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-virtio-revision.xml
 create mode 100644 tests/qemuxml2xmloutdata/qemuxml2xmlout-virtio-revision.xml

diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index 8efd6af..3c3ec32 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -6379,6 +6379,15 @@ qemu-kvm -net nic,model=? /dev/null
   Since 1.1.1, requires QEMU 1.5
 
   
+  virtio
+  
+
+  An optional virtio can be used to enforce a particular
+  virtio revision in QEMU. The valid values for the 
revision
+  are 0 and 1.
+  Since 2.2.0
+
+  
 
 Random number generator device
 
diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
index 741f268..7043cee 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -3570,6 +3570,9 @@
 
   
 
+
+  
+
   
 
   
@@ -4776,6 +4779,17 @@
 
   
 
+  
+
+  
+
+  0
+  1
+
+  
+
+  
+
   
 
   
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 4999dea..7ae07e8 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -831,6 +831,12 @@ VIR_ENUM_IMPL(virDomainLoader,
   "rom",
   "pflash")
 
+VIR_ENUM_IMPL(virDomainVirtioRevision,
+  VIR_DOMAIN_VIRTIO_REVISION_LAST,
+  "default",
+  "0",
+  "1")
+
 /* Internal mapping: subset of block job types that can be present in
  *  XML (remaining types are not two-phase). */
 VIR_ENUM_DECL(virDomainBlockJob)
@@ -1056,6 +1062,41 @@ virDomainXMLOptionGetNamespace(virDomainXMLOptionPtr 
xmlopt)
 return >ns;
 }
 
+static int
+virDomainVirtioRevisionParseXML(xmlXPathContextPtr ctxt,
+virDomainVirtioRevision *res)
+{
+char *str = virXPathString("string(./virtio/@revision)", ctxt);
+int ret = -1;
+int val;
+
+if (!str)
+return 0;
+
+if ((val = virDomainVirtioRevisionTypeFromString(str)) < 0) {
+virReportError(VIR_ERR_XML_ERROR,
+   _("Unable to parse virtio revision: '%s'"),
+   str);
+goto cleanup;
+}
+
+ret = 0;
+*res = val;
+ cleanup:
+VIR_FREE(str);
+return ret;
+}
+
+
+static void
+virDomainVirtioRevisionFormatXML(virBufferPtr buf,
+ virDomainVirtioRevision val)
+{
+if (val != VIR_DOMAIN_VIRTIO_REVISION_DEFAULT)
+virBufferAsprintf(buf, "\n",
+  virDomainVirtioRevisionTypeToString(val));
+}
+
 
 void
 virBlkioDeviceArrayClear(virBlkioDevicePtr devices,
@@ -12058,6 +12099,9 @@ virDomainMemballoonDefParseXML(xmlNodePtr node,
 else if (virDomainDeviceInfoParseXML(node, NULL, >info, flags) < 0)
 goto error;
 
+if (virDomainVirtioRevisionParseXML(ctxt, >virtio_rev) < 0)
+goto error;
+
  cleanup:
 VIR_FREE(model);
 VIR_FREE(deflate);
@@ -21446,6 +21490,8 @@ virDomainMemballoonDefFormat(virBufferPtr buf,
 return -1;
 }
 
+virDomainVirtioRevisionFormatXML(, def->virtio_rev);
+
 if (!virBufferUse()) {
 virBufferAddLit(buf, "/>\n");
 } else {
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 3c2f182..ba5ad70 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -154,6 +154,13 @@ typedef virDomainTPMDef *virDomainTPMDefPtr;
 typedef struct _virDomainIOMMUDef virDomainIOMMUDef;
 typedef virDomainIOMMUDef *virDomainIOMMUDefPtr;
 
+typedef enum {
+VIR_DOMAIN_VIRTIO_REVISION_DEFAULT,
+VIR_DOMAIN_VIRTIO_REVISION_HERITAGE,
+VIR_DOMAIN_VIRTIO_REVISION_CONTEMPORARY,
+VIR_DOMAIN_VIRTIO_REVISION_LAST,
+} virDomainVirtioRevision;
+
 /* Flags for the 'type' field in virDomainDeviceDef */
 typedef enum {
 VIR_DOMAIN_DEVICE_NONE = 0,
@@ -1544,6 +1551,7 @@ struct _virDomainMemballoonDef {
 virDomainDeviceInfo info;
 int period; /* seconds between collections */
 int autodeflate; /* enum virTristateSwitch */
+virDomainVirtioRevision virtio_rev;
 };
 
 struct _virDomainNVRAMDef {
@@ -3016,6 +3024,7 @@ VIR_ENUM_DECL(virDomainTPMBackend)
 VIR_ENUM_DECL(virDomainMemoryModel)
 VIR_ENUM_DECL(virDomainMemoryBackingModel)
 VIR_ENUM_DECL(virDomainIOMMUModel)

Re: [libvirt] [PATCH] admin: Fix the default uri for session daemon to libvirtd:///session

2016-07-29 Thread Daniel P. Berrange
On Fri, Jul 29, 2016 at 02:06:00PM +0200, Erik Skultety wrote:
> Just like we decide on which URI we go with based on EUID for qemu in remote
> driver, do a similar thing for admin except we do not spawn a daemon in this
> case.

IMHO we should auto-spawn the daemon too, so we have consistent
behaviour virsh virsh.


Regards,
Daniel
-- 
|: http://berrange.com  -o-http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org  -o- http://virt-manager.org :|
|: http://autobuild.org   -o- http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org   -o-   http://live.gnome.org/gtk-vnc :|

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


[libvirt] [PATCH] admin: Fix the default uri for session daemon to libvirtd:///session

2016-07-29 Thread Erik Skultety
Just like we decide on which URI we go with based on EUID for qemu in remote
driver, do a similar thing for admin except we do not spawn a daemon in this
case.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1356858

Signed-off-by: Erik Skultety 
---
 src/libvirt-admin.c | 10 +++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/src/libvirt-admin.c b/src/libvirt-admin.c
index 4bf29b1..4552e84 100644
--- a/src/libvirt-admin.c
+++ b/src/libvirt-admin.c
@@ -176,10 +176,14 @@ virAdmGetDefaultURI(virConfPtr conf, char **uristr)
 /* Since we can't probe connecting via any hypervisor driver as 
libvirt
  * does, if no explicit URI was given and neither the environment
  * variable, nor the configuration parameter had previously been 
set,
- * we set the default admin server URI to 'libvirtd://system'.
+ * we set the default admin server URI to 'libvirtd:///system' or
+ * 'libvirtd:///session' depending on the process's EUID.
  */
-if (VIR_STRDUP(*uristr, "libvirtd:///system") < 0)
-return -1;
+if (geteuid() == 0 &&
+VIR_STRDUP(*uristr, "libvirtd:///system") < 0)
+return -1;
+else if (VIR_STRDUP(*uristr, "libvirtd:///session") < 0)
+return -1;
 }
 }
 
-- 
2.5.5

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


Re: [libvirt] [PATCH] wireshark dissector compile fix

2016-07-29 Thread Daniel P. Berrange
On Fri, Jul 29, 2016 at 12:43:41PM +0200, Benedikt Spranger wrote:
> Compiling libvirt wireshark dissector on a debian based system failed:
>   CC   wireshark/src/wireshark_src_libvirt_la-packet-libvirt.lo
>   In file included from 
> ../../libvirt/tools/wireshark/src/packet-libvirt.c:27:0:
>   /usr/include/wireshark/epan/proto.h:40:18: fatal error: glib.h: No such 
> file or directory
>   compilation terminated.
>   Makefile:2595: recipe for target 
> 'wireshark/src/wireshark_src_libvirt_la-packet-libvirt.lo' failed
> 
> Add an explicit dependency to glib.

This is a bug in wireshark packages in debian that they should fix there.
Libvirt shouldn't be hardcoding knowledge about what other libs wireshark
may happen to depend on.

Specifically the wireshark.pc file needs fixing to have the glib dep.

For reference, there's the corresponding fedora bug dealing with this
same problem:

  https://bugzilla.redhat.com/show_bug.cgi?id=132

Regards,
Daniel
-- 
|: http://berrange.com  -o-http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org  -o- http://virt-manager.org :|
|: http://autobuild.org   -o- http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org   -o-   http://live.gnome.org/gtk-vnc :|

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


[libvirt] [PATCH] wireshark: glib compile fix

2016-07-29 Thread Benedikt Spranger
libvirt wireshark dissector uses wireshark and glib. Since wireshark
development files did not depend on glib add an expicit dependency.

Signed-off-by: Benedikt Spranger 
---
 m4/virt-wireshark.m4 | 2 ++
 tools/Makefile.am| 4 ++--
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/m4/virt-wireshark.m4 b/m4/virt-wireshark.m4
index f383e2b..629e190 100644
--- a/m4/virt-wireshark.m4
+++ b/m4/virt-wireshark.m4
@@ -19,6 +19,7 @@ dnl
 
 AC_DEFUN([LIBVIRT_CHECK_WIRESHARK],[
   LIBVIRT_CHECK_PKG([WIRESHARK_DISSECTOR], [wireshark], [1.11.3])
+  LIBVIRT_CHECK_PKG([GLIB], [glib-2.0], [2.46.2])
 
   AC_ARG_WITH([ws-plugindir],
 [AS_HELP_STRING([--with-ws-plugindir],
@@ -52,4 +53,5 @@ AC_DEFUN([LIBVIRT_CHECK_WIRESHARK],[
 
 AC_DEFUN([LIBVIRT_RESULT_WIRESHARK],[
   LIBVIRT_RESULT_LIB([WIRESHARK_DISSECTOR])
+  LIBVIRT_RESULT_LIB([GLIB])
 ])
diff --git a/tools/Makefile.am b/tools/Makefile.am
index a01c58d..44c5e9b 100644
--- a/tools/Makefile.am
+++ b/tools/Makefile.am
@@ -408,8 +408,8 @@ if WITH_WIRESHARK_DISSECTOR
 ws_plugindir = $(plugindir)
 ws_plugin_LTLIBRARIES = wireshark/src/libvirt.la
 wireshark_src_libvirt_la_CPPFLAGS = \
-   -I wireshark/src $(WIRESHARK_DISSECTOR_CFLAGS)
-wireshark_src_libvirt_la_LDFLAGS = -avoid-version -module
+   -I wireshark/src $(WIRESHARK_DISSECTOR_CFLAGS) $(GLIB_CFLAGS)
+wireshark_src_libvirt_la_LDFLAGS = -avoid-version -module $(GLIB_LIBS)
 nodist_wireshark_src_libvirt_la_SOURCES = wireshark/src/plugin.c
 wireshark_src_libvirt_la_SOURCES = \
wireshark/src/packet-libvirt.h \
-- 
2.8.1

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


[libvirt] [PATCH] wireshark dissector compile fix

2016-07-29 Thread Benedikt Spranger
Compiling libvirt wireshark dissector on a debian based system failed:
  CC   wireshark/src/wireshark_src_libvirt_la-packet-libvirt.lo
  In file included from ../../libvirt/tools/wireshark/src/packet-libvirt.c:27:0:
  /usr/include/wireshark/epan/proto.h:40:18: fatal error: glib.h: No such file 
or directory
  compilation terminated.
  Makefile:2595: recipe for target 
'wireshark/src/wireshark_src_libvirt_la-packet-libvirt.lo' failed

Add an explicit dependency to glib.

Benedikt Spranger (1):
  wireshark: glib compile fix

 m4/virt-wireshark.m4 | 2 ++
 tools/Makefile.am| 4 ++--
 2 files changed, 4 insertions(+), 2 deletions(-)

-- 
2.8.1

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


Re: [libvirt] [PATCH 0/5] qemu: report actual vcpu state in virVcpuInfo

2016-07-29 Thread Viktor Mihajlovski
On 29.07.2016 08:30, Peter Krempa wrote:
> 
> So I was testing the data reported from the monitor while doing some
> work on othe vCPU hotplug series and found that for x86 the halted state
> is reported if the CPU is idle and thus halted.  This state it therefore
> almost always reported when the VM is idle.
> 
> Quoting conversation on previous version [1]:
> 
>>> Could you please elaborat how you expect to use this info?
>> Dpending on the architecture, the halted state is an indication that the
>> virtual CPU is not in use. On s390x for example the halted state is only
>> reported if the CPU is stopped or in disabled wait, both indicating that
>> the virtual CPUs are not enabled for the operating system.
> 
> While for the s390 platform the state may reasonably express that the
> vcpu is unused, other platforms have apparently different meaning.
I agree, however I haven't claimed that s390x and x86 use the same
mechanism or have the same semantics, even if in both cases the CPUs are
doing "nothing" (in the x86 case in a much more transient way).
> 
> Addditionally on x86_64 if the cpu is hotplugged but not grabbed by the
> guest it is reporting non-halted state.
> 
I don't have a current x86 QEMU setup to check with, but I am wondering
what the CPU thread is actually doing (actively looping?) if it's not
executing the HLT instruction. Anyway, it may be a correct
representation of the CPU doing "something".
>> This information can be used by a libvirt client application for
>> hotplugging decisions, and this is in fact the intention.
> 
> Wouldn't it be possible for you to use the virDomainGetGuestVcpus [2]
> API to determine this information more reliably using the guest agent?
As I said, on s390x the hypervisor-reported state IS reliable. Requiring
the guest agent may not be acceptable for all use cases.
> 
> I'm also a bit worried that the new state might cause problems with
> older apps actually using the value for any reason.
That could of course be, but otoh apps should really not assume that
enumerations like the cpu state will never be extended. virsh is a nice
example showing how to deal with it.
> 
> Said that. I still keep the series in a branch and I'll post a updated
> version including rebase on top of the oncomming vCPU hotplug series
> once I finish it since it completely rewrites the exact part of the
> monitor code requesting the information due to changes necessary to
> detect hotpluggable cpus in recent qemu.
Great, looking forward to it.
> 
> Peter
> 
> [1] https://www.redhat.com/archives/libvir-list/2016-July/msg00234.html
> [2] http://libvirt.org/html/libvirt-libvirt-domain.html#virDomainGetGuestVcpus
> 


-- 

Mit freundlichen Grüßen/Kind Regards
   Viktor Mihajlovski

IBM Deutschland Research & Development GmbH
Vorsitzender des Aufsichtsrats: Martina Köderitz
Geschäftsführung: Dirk Wittkopp
Sitz der Gesellschaft: Böblingen
Registergericht: Amtsgericht Stuttgart, HRB 243294

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


Re: [libvirt] [PATCH 00/13] Move functions from qemu_domain_address.c to domain_addr.c

2016-07-29 Thread Daniel P. Berrange
On Thu, Jul 28, 2016 at 07:00:40PM -0400, Laine Stump wrote:
> On 07/19/2016 08:07 PM, Tomasz Flendrich wrote:
> > This series depends on another one:
> > https://www.redhat.com/archives/libvir-list/2016-July/msg00696.html
> > 
> > Because the address sets are no longer cached, it's possible to move
> > functions that don't depend on qemu anymore from qemu_domain_address.c
> > to domain_addr.c. I did that with virtioSerial and PCI.
> > 
> > To make some functions not dependent on qemuCaps, their parameters
> > were changed to booleans. These changes are in [PATCH 02/13].
> > 
> > If you are satisfied with this approach, I can do the same with
> > the rest of the functions or just some of them.
> 
> The problem is that many/most these functions are by definition
> qemu-specific - only the qemu driver has any concept of a Q35 machinetype or
> a PIIX3 controller (actually that function should probably have used
> "i440fx" instead of PIIX3) or an aarch64 "virt" machinetype, or any use for
> a "busNr" etc etc. So moving them from qemu into conf is busy-work that is
> counter-productive.

Agreed, I would consider it to be mandatary to separate the general address
handling logic (which could be in conf) from the logic that assigns addresses
for specific QEMU machine types (which should always remain in the QEMU drive
dir).


Regards,
Daniel
-- 
|: http://berrange.com  -o-http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org  -o- http://virt-manager.org :|
|: http://autobuild.org   -o- http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org   -o-   http://live.gnome.org/gtk-vnc :|

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


[libvirt] [PATCH 3/2] qemu: cap: Refactor access to array in virQEMUCapsProbeQMPMachineTypes

2016-07-29 Thread Peter Krempa
Use a temporary pointer rather than always recalculating the index in a
very verbose way.
---
 src/qemu/qemu_capabilities.c | 16 +---
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index 23d4a65..c612960 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -2473,6 +2473,7 @@ static int
 virQEMUCapsProbeQMPMachineTypes(virQEMUCapsPtr qemuCaps,
 qemuMonitorPtr mon)
 {
+struct virQEMUCapsMachineType *mach;
 qemuMonitorMachineInfoPtr *machines = NULL;
 int nmachines = 0;
 int ret = -1;
@@ -2488,16 +2489,17 @@ virQEMUCapsProbeQMPMachineTypes(virQEMUCapsPtr qemuCaps,
 for (i = 0; i < nmachines; i++) {
 if (STREQ(machines[i]->name, "none"))
 continue;
-qemuCaps->nmachineTypes++;
-if (VIR_STRDUP(qemuCaps->machineTypes[qemuCaps->nmachineTypes 
-1].alias,
-   machines[i]->alias) < 0 ||
-VIR_STRDUP(qemuCaps->machineTypes[qemuCaps->nmachineTypes - 
1].name,
-   machines[i]->name) < 0)
+
+mach = &(qemuCaps->machineTypes[qemuCaps->nmachineTypes++]);
+
+if (VIR_STRDUP(mach->alias, machines[i]->alias) < 0 ||
+VIR_STRDUP(mach->name, machines[i]->name) < 0)
 goto cleanup;
+
+mach->maxCpus = machines[i]->maxCpus;
+
 if (machines[i]->isDefault)
 defIdx = qemuCaps->nmachineTypes - 1;
-qemuCaps->machineTypes[qemuCaps->nmachineTypes - 1].maxCpus =
-machines[i]->maxCpus;
 }

 if (defIdx)
-- 
2.9.2

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


[libvirt] [PATCH 1/2] qemu: capabilities: Drop unused function virQEMUCapsGetMachineTypes

2016-07-29 Thread Peter Krempa
---
 src/qemu/qemu_capabilities.c | 8 
 src/qemu/qemu_capabilities.h | 2 --
 2 files changed, 10 deletions(-)

diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index d5b73e6..f8e2c55 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -2240,14 +2240,6 @@ size_t virQEMUCapsGetCPUDefinitions(virQEMUCapsPtr 
qemuCaps,
 }


-size_t virQEMUCapsGetMachineTypes(virQEMUCapsPtr qemuCaps,
-  char ***names)
-{
-if (names)
-*names = qemuCaps->machineTypes;
-return qemuCaps->nmachineTypes;
-}
-
 int virQEMUCapsGetMachineTypesCaps(virQEMUCapsPtr qemuCaps,
size_t *nmachines,
virCapsGuestMachinePtr **machines)
diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h
index bd5c6d9..72e763a 100644
--- a/src/qemu/qemu_capabilities.h
+++ b/src/qemu/qemu_capabilities.h
@@ -419,8 +419,6 @@ int virQEMUCapsAddCPUDefinition(virQEMUCapsPtr qemuCaps,
 const char *name);
 size_t virQEMUCapsGetCPUDefinitions(virQEMUCapsPtr qemuCaps,
 char ***names);
-size_t virQEMUCapsGetMachineTypes(virQEMUCapsPtr qemuCaps,
-  char ***names);
 const char *virQEMUCapsGetCanonicalMachine(virQEMUCapsPtr qemuCaps,
const char *name);
 int virQEMUCapsGetMachineMaxCpus(virQEMUCapsPtr qemuCaps,
-- 
2.9.2

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


[libvirt] [PATCH 2/2] qemu: caps: Sanitize storage of machine type related data

2016-07-29 Thread Peter Krempa
Add a structure to store the data and use a single array of the
structures rather than having 3 separate arrays with shared indexes.
---
 src/qemu/qemu_capabilities.c | 117 +--
 1 file changed, 46 insertions(+), 71 deletions(-)

diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index f8e2c55..23d4a65 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -342,6 +342,11 @@ VIR_ENUM_IMPL(virQEMUCaps, QEMU_CAPS_LAST,
 );


+struct virQEMUCapsMachineType {
+char *name;
+char *alias;
+unsigned int maxCpus;
+};
 /*
  * Update the XML parser/formatter when adding more
  * information to this struct so that it gets cached
@@ -369,9 +374,7 @@ struct _virQEMUCaps {
 char **cpuDefinitions;

 size_t nmachineTypes;
-char **machineTypes;
-char **machineAliases;
-unsigned int *machineMaxCpus;
+struct virQEMUCapsMachineType *machineTypes;

 size_t ngicCapabilities;
 virGICCapability *gicCapabilities;
@@ -473,22 +476,13 @@ static void
 virQEMUCapsSetDefaultMachine(virQEMUCapsPtr qemuCaps,
  size_t defIdx)
 {
-char *name = qemuCaps->machineTypes[defIdx];
-char *alias = qemuCaps->machineAliases[defIdx];
-unsigned int maxCpus = qemuCaps->machineMaxCpus[defIdx];
+struct virQEMUCapsMachineType tmp = qemuCaps->machineTypes[defIdx];

 memmove(qemuCaps->machineTypes + 1,
 qemuCaps->machineTypes,
 sizeof(qemuCaps->machineTypes[0]) * defIdx);
-memmove(qemuCaps->machineAliases + 1,
-qemuCaps->machineAliases,
-sizeof(qemuCaps->machineAliases[0]) * defIdx);
-memmove(qemuCaps->machineMaxCpus + 1,
-qemuCaps->machineMaxCpus,
-sizeof(qemuCaps->machineMaxCpus[0]) * defIdx);
-qemuCaps->machineTypes[0] = name;
-qemuCaps->machineAliases[0] = alias;
-qemuCaps->machineMaxCpus[0] = maxCpus;
+
+qemuCaps->machineTypes[0] = tmp;
 }

 /* Format is:
@@ -536,23 +530,21 @@ virQEMUCapsParseMachineTypesStr(const char *output,
 }
 }

-if (VIR_REALLOC_N(qemuCaps->machineTypes, qemuCaps->nmachineTypes + 1) 
< 0 ||
-VIR_REALLOC_N(qemuCaps->machineAliases, qemuCaps->nmachineTypes + 
1) < 0 ||
-VIR_REALLOC_N(qemuCaps->machineMaxCpus, qemuCaps->nmachineTypes + 
1) < 0) {
+if (VIR_REALLOC_N(qemuCaps->machineTypes, qemuCaps->nmachineTypes + 1) 
< 0) {
 VIR_FREE(name);
 VIR_FREE(canonical);
 return -1;
 }
 qemuCaps->nmachineTypes++;
 if (canonical) {
-qemuCaps->machineTypes[qemuCaps->nmachineTypes-1] = canonical;
-qemuCaps->machineAliases[qemuCaps->nmachineTypes-1] = name;
+qemuCaps->machineTypes[qemuCaps->nmachineTypes-1].name = canonical;
+qemuCaps->machineTypes[qemuCaps->nmachineTypes-1].alias = name;
 } else {
-qemuCaps->machineTypes[qemuCaps->nmachineTypes-1] = name;
-qemuCaps->machineAliases[qemuCaps->nmachineTypes-1] = NULL;
+qemuCaps->machineTypes[qemuCaps->nmachineTypes-1].name = name;
+qemuCaps->machineTypes[qemuCaps->nmachineTypes-1].alias = NULL;
 }
 /* When parsing from command line we don't have information about 
maxCpus */
-qemuCaps->machineMaxCpus[qemuCaps->nmachineTypes-1] = 0;
+qemuCaps->machineTypes[qemuCaps->nmachineTypes-1].maxCpus = 0;
 } while ((p = next));


@@ -2042,16 +2034,12 @@ virQEMUCapsPtr virQEMUCapsNewCopy(virQEMUCapsPtr 
qemuCaps)

 if (VIR_ALLOC_N(ret->machineTypes, qemuCaps->nmachineTypes) < 0)
 goto error;
-if (VIR_ALLOC_N(ret->machineAliases, qemuCaps->nmachineTypes) < 0)
-goto error;
-if (VIR_ALLOC_N(ret->machineMaxCpus, qemuCaps->nmachineTypes) < 0)
-goto error;
 ret->nmachineTypes = qemuCaps->nmachineTypes;
 for (i = 0; i < qemuCaps->nmachineTypes; i++) {
-if (VIR_STRDUP(ret->machineTypes[i], qemuCaps->machineTypes[i]) < 0 ||
-VIR_STRDUP(ret->machineAliases[i], qemuCaps->machineAliases[i]) < 
0)
+if (VIR_STRDUP(ret->machineTypes[i].name, 
qemuCaps->machineTypes[i].name) < 0 ||
+VIR_STRDUP(ret->machineTypes[i].alias, 
qemuCaps->machineTypes[i].alias) < 0)
 goto error;
-ret->machineMaxCpus[i] = qemuCaps->machineMaxCpus[i];
+ret->machineTypes[i].maxCpus = qemuCaps->machineTypes[i].maxCpus;
 }

 return ret;
@@ -2068,12 +2056,10 @@ void virQEMUCapsDispose(void *obj)
 size_t i;

 for (i = 0; i < qemuCaps->nmachineTypes; i++) {
-VIR_FREE(qemuCaps->machineTypes[i]);
-VIR_FREE(qemuCaps->machineAliases[i]);
+VIR_FREE(qemuCaps->machineTypes[i].name);
+VIR_FREE(qemuCaps->machineTypes[i].alias);
 }
 VIR_FREE(qemuCaps->machineTypes);
-VIR_FREE(qemuCaps->machineAliases);
-VIR_FREE(qemuCaps->machineMaxCpus);

 for (i = 0; i < 

[libvirt] [PATCH 0/2] qemu: caps: Sanitize storage of machine type related data

2016-07-29 Thread Peter Krempa
Peter Krempa (2):
  qemu: capabilities: Drop unused function virQEMUCapsGetMachineTypes
  qemu: caps: Sanitize storage of machine type related data

 src/qemu/qemu_capabilities.c | 125 ---
 src/qemu/qemu_capabilities.h |   2 -
 2 files changed, 46 insertions(+), 81 deletions(-)

-- 
2.9.2

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


Re: [libvirt] [gconfig v2 1/2] config: Add vnc host setter

2016-07-29 Thread Christophe Fergeau
Hey,

On Thu, Jul 28, 2016 at 06:16:38PM +0300, Visarion Alexandru wrote:
> From: Visarion Alexandru 
> 
> Learn to set the address that vnc is listening on.
> ---
>  libvirt-gconfig/libvirt-gconfig-domain-graphics-vnc.c | 9 +
>  libvirt-gconfig/libvirt-gconfig-domain-graphics-vnc.h | 3 +++
>  libvirt-gconfig/libvirt-gconfig.sym   | 1 +
>  3 files changed, 13 insertions(+)
> 
> diff --git a/libvirt-gconfig/libvirt-gconfig-domain-graphics-vnc.c 
> b/libvirt-gconfig/libvirt-gconfig-domain-graphics-vnc.c
> index fc26bb9..dfec2d8 100644
> --- a/libvirt-gconfig/libvirt-gconfig-domain-graphics-vnc.c
> +++ b/libvirt-gconfig/libvirt-gconfig-domain-graphics-vnc.c
> @@ -120,6 +120,15 @@ void 
> gvir_config_domain_graphics_vnc_set_port(GVirConfigDomainGraphicsVnc *graph
> NULL);
>  }
>  
> +void gvir_config_domain_graphics_vnc_set_host(GVirConfigDomainGraphicsVnc 
> *graphics,
> +  const char *address)

Why not gvir_config_domain_graphics_set_listen_address?

Overall, the patch looks good (adding some short API documentation would
be nice). However, the "listen" attribute really is deprecated at this
point in favour of "listen" nodes. Adding an API setting the "listen"
attribute and removing the "listen" node really looks like we are adding
already obsolete API to libvirt-glib.

Ideally we'd add
void
gvir_config_domain_graphics_vnc_set_listen(GVirConfigDomainGraphicsVnc
*graphics, GList *listens);
and a GVirConfigDomainGraphicsListen base class +
GVirConfigDomainGraphicsListenAddress derived class

This would allow us to support only the preferred XML format.

Christophe


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

[libvirt] [PATCH 2/2] daemon: sasl: Don't forget to save SASL username to client's identity

2016-07-29 Thread Erik Skultety
Once the SASL authentication process has successfully passed, we should also
save the SASL username used to client's identity, so that when a client like
virt-admin tries to obtain it, the server will actually format the username to
the response data.

Signed-off-by: Erik Skultety 
---
 daemon/remote.c | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/daemon/remote.c b/daemon/remote.c
index 4aa43c2..6991a7e 100644
--- a/daemon/remote.c
+++ b/daemon/remote.c
@@ -3116,6 +3116,7 @@ static int
 remoteSASLFinish(virNetServerPtr server,
  virNetServerClientPtr client)
 {
+virIdentityPtr clnt_identity = NULL;
 const char *identity;
 struct daemonClientPrivate *priv = 
virNetServerClientGetPrivateData(client);
 int ssf;
@@ -3138,9 +3139,13 @@ remoteSASLFinish(virNetServerPtr server,
 if (!virNetSASLContextCheckIdentity(saslCtxt, identity))
 return -2;
 
+if (!(clnt_identity = virNetServerClientGetIdentity(client)))
+goto error;
+
 virNetServerClientSetAuth(client, 0);
 virNetServerTrackCompletedAuth(server);
 virNetServerClientSetSASLSession(client, priv->sasl);
+virIdentitySetSASLUserName(clnt_identity, identity);
 
 VIR_DEBUG("Authentication successful %d", virNetServerClientGetFD(client));
 
@@ -3148,6 +3153,7 @@ remoteSASLFinish(virNetServerPtr server,
   "client=%p auth=%d identity=%s",
   client, REMOTE_AUTH_SASL, identity);
 
+virObjectUnref(clnt_identity);
 virObjectUnref(priv->sasl);
 priv->sasl = NULL;
 
-- 
2.5.5

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


[libvirt] [PATCH 0/2] admin: sasl: Save the SASL username to client's identity

2016-07-29 Thread Erik Skultety
Erik Skultety (2):
  admin: Retrieve the SASL context for both local and remote connection
  daemon: sasl: Don't forget to save SASL username to client's identity

 daemon/admin_server.c | 14 +++---
 daemon/remote.c   |  6 ++
 2 files changed, 13 insertions(+), 7 deletions(-)

-- 
2.5.5

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


[libvirt] [PATCH 1/2] admin: Retrieve the SASL context for both local and remote connection

2016-07-29 Thread Erik Skultety
When commit 4a0e9108 added a support for client information retrieval, it made
the API return SASL identity info only for clients connected remotely, yet SASL
can be happily used with UNIX sockets as well.

Signed-off-by: Erik Skultety 
---
 daemon/admin_server.c | 14 +++---
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/daemon/admin_server.c b/daemon/admin_server.c
index 9f24f68..5bbf229 100644
--- a/daemon/admin_server.c
+++ b/daemon/admin_server.c
@@ -237,19 +237,19 @@ adminClientGetInfo(virNetServerClientPtr client,
  readonly) < 0)
 goto cleanup;
 
+if (virIdentityGetSASLUserName(identity, ) < 0 ||
+(attr &&
+ virTypedParamsAddString(, nparams, ,
+ VIR_CLIENT_INFO_SASL_USER_NAME,
+ attr) < 0))
+goto cleanup;
+
 if (!virNetServerClientIsLocal(client)) {
 if (virTypedParamsAddString(, nparams, ,
 VIR_CLIENT_INFO_SOCKET_ADDR,
 sock_addr) < 0)
 goto cleanup;
 
-if (virIdentityGetSASLUserName(identity, ) < 0 ||
-(attr &&
- virTypedParamsAddString(, nparams, ,
- VIR_CLIENT_INFO_SASL_USER_NAME,
- attr) < 0))
-goto cleanup;
-
 if (virIdentityGetX509DName(identity, ) < 0 ||
 (attr &&
  virTypedParamsAddString(, nparams, ,
-- 
2.5.5

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


Re: [libvirt] [gconfig v2 0/2] Add host setters

2016-07-29 Thread Christophe Fergeau
Hey,

On Thu, Jul 28, 2016 at 06:16:37PM +0300, Visarion Alexandru wrote:
> From: Visarion Alexandru 
> 
> These new patches are a bit different than the last ones.
> I first delete the  child node and
> then I modify the  attribute.

You could mention this in the commit log of each patch as well, and
indicate that otherwise we could get inconsistencies between the listen
node and attribute, which causes errors when trying to start (or define
?) the domain.

Christophe

> 
> Visarion Alexandru (2):
>   config: Add vnc host setter
>   config: Add spice host setter
> 
>  libvirt-gconfig/libvirt-gconfig-domain-graphics-spice.c | 10 ++
>  libvirt-gconfig/libvirt-gconfig-domain-graphics-spice.h |  3 +++
>  libvirt-gconfig/libvirt-gconfig-domain-graphics-vnc.c   |  9 +
>  libvirt-gconfig/libvirt-gconfig-domain-graphics-vnc.h   |  3 +++
>  libvirt-gconfig/libvirt-gconfig.sym |  2 ++
>  5 files changed, 27 insertions(+)
> 
> -- 
> 2.7.4
> 
> --
> libvir-list mailing list
> libvir-list@redhat.com
> https://www.redhat.com/mailman/listinfo/libvir-list


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

Re: [libvirt] [PATCH] conf: Catch invalid memory model earlier

2016-07-29 Thread Martin Kletzander

On Thu, Jul 28, 2016 at 06:28:40PM +0200, Michal Privoznik wrote:

Consider the following XML snippet:

   
 
   523264
   0
 
   

Whats wrong you ask? The @model attribute. This should result in
an error thrown into users faces during virDomainDefine phase.
Except it doesn't. The XML validation catches this error, but if
users chose to ignore that, they will end up with invalid XML.
Well, they won't be able to start the machine - that's when error
is produced currently. But it would be nice if we could catch the
error like this earlier.



I wonder why there's "" for MODEL_NONE and why it's even there.
Hoping we will use more models, ACK.


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

Re: [libvirt] [PATCH 0/5] qemu: report actual vcpu state in virVcpuInfo

2016-07-29 Thread Peter Krempa
On Mon, Jul 18, 2016 at 07:56:36 +0200, Peter Krempa wrote:
> On Thu, Jul 14, 2016 at 16:35:37 +0200, Viktor Mihajlovski wrote:
> > Currently, the virVcpuInfo returned by virDomainGetVcpus() will always
> > report a state of VIR_VCPU_RUNNING for each defined domain vcpu even if
> > the vcpu is currently in the halted state.
> > 
> > As the monitor interface is in fact reporting the accurate state, it is
> > rather easy to transport this information with the existing API.
> > 
> > This is done by
> > - adding a new state of VIR_VCPU_HALTED
> > - adding a monitor function to pass back the halted state for the vcpus
> > - adding a new field to the private domain vcpu object reflecting the
> >   halted state for the vcpu
> > - modifying the driver code to report the vcpu state based on the halted
> >   indicator
> > - extending virsh vcpuinfo to also display the halted state
> > 
> > The vcpu state is however not recorded in the internal XML format, since
> > the state can change asynchronously (without notification).
> 
> I'm going to pick this up in my work-in-progress series of adding vCPU
> hot(un)plug using the new APIs in qemu and I'll let you know about the
> issues once I see how well it integrates since it is touching the same
> places.

So I was testing the data reported from the monitor while doing some
work on othe vCPU hotplug series and found that for x86 the halted state
is reported if the CPU is idle and thus halted.  This state it therefore
almost always reported when the VM is idle.

Quoting conversation on previous version [1]:

> > Could you please elaborat how you expect to use this info?
> Dpending on the architecture, the halted state is an indication that the
> virtual CPU is not in use. On s390x for example the halted state is only
> reported if the CPU is stopped or in disabled wait, both indicating that
> the virtual CPUs are not enabled for the operating system.

While for the s390 platform the state may reasonably express that the
vcpu is unused, other platforms have apparently different meaning.

Addditionally on x86_64 if the cpu is hotplugged but not grabbed by the
guest it is reporting non-halted state.

> This information can be used by a libvirt client application for
> hotplugging decisions, and this is in fact the intention.

Wouldn't it be possible for you to use the virDomainGetGuestVcpus [2]
API to determine this information more reliably using the guest agent?

I'm also a bit worried that the new state might cause problems with
older apps actually using the value for any reason.

Said that. I still keep the series in a branch and I'll post a updated
version including rebase on top of the oncomming vCPU hotplug series
once I finish it since it completely rewrites the exact part of the
monitor code requesting the information due to changes necessary to
detect hotpluggable cpus in recent qemu.

Peter

[1] https://www.redhat.com/archives/libvir-list/2016-July/msg00234.html
[2] http://libvirt.org/html/libvirt-libvirt-domain.html#virDomainGetGuestVcpus

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


[libvirt] [PATCH] virsh: Report error when explicit connection fails

2016-07-29 Thread Martin Kletzander
Commit 0c56d9431839 forgot to return false in the cmdConnect command
after the clean up made there.

Before (assuming you don't have uri alias for 'asdf'):
  $ virsh connect asdf
  error: failed to connect to the hypervisor

  $ echo $?
  0

After (with the same assumption):
  $ virsh connect asdf
  error: failed to connect to the hypervisor
  error: no connection driver available for asdf

  $ echo $?
  1

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1356461

Signed-off-by: Martin Kletzander 
---
 tools/virsh.c | 16 ++--
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/tools/virsh.c b/tools/virsh.c
index f74698fa5f9a..d3fe06f19032 100644
--- a/tools/virsh.c
+++ b/tools/virsh.c
@@ -210,7 +210,7 @@ virshConnect(vshControl *ctl, const char *uri, bool 
readonly)
  * Reconnect after a disconnect from libvirtd
  *
  */
-static void
+static int
 virshReconnect(vshControl *ctl, const char *name, bool readonly, bool force)
 {
 bool connected = false;
@@ -237,6 +237,7 @@ virshReconnect(vshControl *ctl, const char *name, bool 
readonly, bool force)
 vshError(ctl, "%s", _("Failed to reconnect to the hypervisor"));
 else
 vshError(ctl, "%s", _("failed to connect to the hypervisor"));
+return -1;
 } else {
 if (name) {
 VIR_FREE(ctl->connname);
@@ -253,6 +254,7 @@ virshReconnect(vshControl *ctl, const char *name, bool 
readonly, bool force)
 priv->useGetInfo = false;
 priv->useSnapshotOld = false;
 priv->blockJobNoBytes = false;
+return 0;
 }

 int virshStreamSink(virStreamPtr st ATTRIBUTE_UNUSED,
@@ -301,7 +303,8 @@ cmdConnect(vshControl *ctl, const vshCmd *cmd)
 if (vshCommandOptStringReq(ctl, cmd, "name", ) < 0)
 return false;

-virshReconnect(ctl, name, ro, true);
+if (virshReconnect(ctl, name, ro, true) < 0)
+return false;

 return true;
 }
@@ -333,11 +336,13 @@ virshConnectionHandler(vshControl *ctl)
 {
 virshControlPtr priv = ctl->privData;

-if (!priv->conn || disconnected)
-virshReconnect(ctl, NULL, false, false);
+if ((!priv->conn || disconnected) &&
+virshReconnect(ctl, NULL, false, false) < 0)
+return NULL;

 if (virshConnectionUsability(ctl, priv->conn))
 return priv->conn;
+
 return NULL;
 }

@@ -444,14 +449,13 @@ virshInit(vshControl *ctl)
 return false;

 if (ctl->connname) {
-virshReconnect(ctl, NULL, false, false);
 /* Connecting to a named connection must succeed, but we delay
  * connecting to the default connection until we need it
  * (since the first command might be 'connect' which allows a
  * non-default connection, or might be 'help' which needs no
  * connection).
  */
-if (!priv->conn) {
+if (virshReconnect(ctl, NULL, false, false) < 0) {
 vshReportError(ctl);
 return false;
 }
-- 
2.9.2

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