Re: [libvirt] [PATCH v2 0/4] New mdev type handling for aggregated resources

2018-10-07 Thread Zhenyu Wang
On 2018.10.08 03:19:25 +, Tian, Kevin wrote:
> Hi, Zhenyu,
> 
> curious about the progress of this series. Is there still some open remaining
> or a new version coming soon?
> 

I had new version almost ready before my vacation, planned to send after be 
back.
So will refresh this later. Sorry for any delay as was trying to close several
gvt issues.

Thanks.

-- 
Open Source Technology Center, Intel ltd.

$gpg --keyserver wwwkeys.pgp.net --recv-keys 4D781827


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

Re: [libvirt] [PATCH v2 0/4] New mdev type handling for aggregated resources

2018-10-07 Thread Tian, Kevin
Hi, Zhenyu,

curious about the progress of this series. Is there still some open remaining
or a new version coming soon?

Thanks
Kevin

> From: Zhenyu Wang [mailto:zhen...@linux.intel.com]
> Sent: Friday, July 20, 2018 10:19 AM
> 
> Current mdev device create interface depends on fixed mdev type, which
> get uuid
> from user to create instance of mdev device. If user wants to use
> customized
> number of resource for mdev device, then only can create new mdev type
> for that
> which may not be flexible. This requirement comes not only from to be
> able to
> allocate flexible resources for KVMGT, but also from Intel scalable IO
> virtualization which would use vfio/mdev to be able to allocate arbitrary
> resources on mdev instance. More info on [1] [2] [3].
> 
> To allow to create user defined resources for mdev, it trys to extend mdev
> create interface by adding new "instances=xxx" parameter following uuid,
> for
> target mdev type if aggregation is supported, it can create new mdev device
> which contains resources combined by number of instances, e.g
> 
> echo ",instances=10" > create
> 
> VM manager e.g libvirt can check mdev type with "aggregation" attribute
> which
> can support this setting. If no "aggregation" attribute found for mdev type,
> previous behavior is still kept for one instance allocation. And new sysfs
> attribute "instances" is created for each mdev device to show allocated
> number.
> 
> This trys to create new KVMGT type with minimal vGPU resources which
> can be
> combined with "instances=x" setting to allocate for user wanted resources.
> 
> References:
> [1] https://software.intel.com/en-us/download/intel-virtualization-
> technology-for-directed-io-architecture-specification
> [2] https://software.intel.com/en-us/download/intel-scalable-io-
> virtualization-technical-specification
> [3] https://schd.ws/hosted_files/lc32018/00/LC3-SIOV-final.pdf
> 
> v2:
>   - Add new create_with_instances driver hook
>   - Update doc for new attributes
> 
> Zhenyu Wang (4):
>   vfio/mdev: Add new instances parameter for mdev create
>   vfio/mdev: Add mdev device instances attribute
>   drm/i915/gvt: Add new aggregation type support
>   Documentation/vfio-mediated-device.txt: update for aggregation
> attribute
> 
>  Documentation/vfio-mediated-device.txt | 39 +++---
>  drivers/gpu/drm/i915/gvt/gvt.c | 26 +---
>  drivers/gpu/drm/i915/gvt/gvt.h | 14 ---
>  drivers/gpu/drm/i915/gvt/kvmgt.c   | 30 +++---
>  drivers/gpu/drm/i915/gvt/vgpu.c| 56 ++
>  drivers/vfio/mdev/mdev_core.c  | 19 +++--
>  drivers/vfio/mdev/mdev_private.h   |  6 ++-
>  drivers/vfio/mdev/mdev_sysfs.c | 42 ---
>  include/linux/mdev.h   | 10 +
>  9 files changed, 203 insertions(+), 39 deletions(-)
> 
> --
> 2.18.0


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


[libvirt] [PATCH v4 0/5] libxl: PVHv2 support

2018-10-07 Thread Marek Marczykowski-Górecki
This is a respin of my old PVHv1 patch[1], converted to PVHv2. The actual code
use "PVH" name.

The guest ostype reuse VIR_DOMAIN_OSTYPE_XEN, but to request PVH machine,
machine="xenpvh" attribute is used.

Since PVHv2 relies on features in newer Xen versions, I needed to convert also
some older code. For example b_info->u.hvm.nested_hvm was deprecated in favor
of b_info->nested_hvm. While the code do handle both old and new versions
(obviously refusing PVHv2 if Xen is too old), this isn't the case for tests.
How it should be handled, if at all?

To test this with all supported Xen versions (4.6, 4.7, 4.8, 4.9, 4.10, 4.11,
unstable), I've extended travis configuration for that[2]. It isn't exactly
trivial to build Xen 4.6-4.8 on recent system, mostly thanks to -Werror and new
warnings, but also other toolchain changes. Because of this, the configuration
is rather hacky. But it may be a good idea to include multiple pre-built Xen
versions in the base docker image and choose one using ./configure options 
(maybe
together with some symlink or environment variable like PKG_CONFIG_PATH).

[1] https://www.redhat.com/archives/libvir-list/2016-August/msg00376.html
[2] https://github.com/marmarek/libvirt/tree/travis-xen-pvh

Changes in v2:
 - drop "docs: don't refer to deprecated 'linux' ostype in example" patch -
   migrating further away from "linux" os type is offtopic to this series and
   apparently is a controversial thing
 - drop "docs: update domain schema for machine attribute" patch -
   already applied
 - apply review comments from Jim
 - rebase on master

Changes in v3:
 - rebase on master, drop already applied patches
 - use #ifdef LIBXL_DOMAIN_TYPE_PVH to detect PVH support, fix compilation
   failure on older Xen
 - exclude PVH from VIR_DOMAIN_OSTYPE_XEN <-> VIR_DOMAIN_OSTYPE_LINUX conversion
 - fix reported capabilities for PVH

Changes in v4:
 - change PVH support detection method

Marek Marczykowski-Górecki (5):
  libxl: reorder libxlMakeDomBuildInfo for upcoming PVH support
  libxl: add support for PVH
  tests: add basic Xen PVH test
  xenconfig: add support for parsing type= xl config entry
  xenconfig: add support for type="pvh"

 docs/formatcaps.html.in |  4 +-
 docs/schemas/domaincommon.rng   |  1 +-
 m4/virt-driver-libxl.m4 |  3 +-
 src/conf/domain_conf.c  |  6 +-
 src/libxl/libxl_capabilities.c  | 38 +--
 src/libxl/libxl_conf.c  | 76 --
 src/libxl/libxl_driver.c|  6 +-
 src/xenconfig/xen_common.c  | 27 ++--
 src/xenconfig/xen_xl.c  |  5 +-
 tests/libxlxml2domconfigdata/basic-pvh.json | 49 ++-
 tests/libxlxml2domconfigdata/basic-pvh.xml  | 28 -
 tests/libxlxml2domconfigtest.c  |  3 +-
 tests/testutilsxen.c|  3 +-
 tests/xlconfigdata/test-fullvirt-type.cfg   | 21 ++-
 tests/xlconfigdata/test-fullvirt-type.xml   | 27 -
 tests/xlconfigdata/test-paravirt-type.cfg   | 13 -
 tests/xlconfigdata/test-paravirt-type.xml   | 25 +++-
 tests/xlconfigdata/test-pvh-type.cfg| 13 -
 tests/xlconfigdata/test-pvh-type.xml| 25 +++-
 tests/xlconfigtest.c|  3 +-
 20 files changed, 341 insertions(+), 35 deletions(-)
 create mode 100644 tests/libxlxml2domconfigdata/basic-pvh.json
 create mode 100644 tests/libxlxml2domconfigdata/basic-pvh.xml
 create mode 100644 tests/xlconfigdata/test-fullvirt-type.cfg
 create mode 100644 tests/xlconfigdata/test-fullvirt-type.xml
 create mode 100644 tests/xlconfigdata/test-paravirt-type.cfg
 create mode 100644 tests/xlconfigdata/test-paravirt-type.xml
 create mode 100644 tests/xlconfigdata/test-pvh-type.cfg
 create mode 100644 tests/xlconfigdata/test-pvh-type.xml

base-commit: 199eee6aae7af3d813fbe98660c7e0fa1a8ae7b7
-- 
git-series 0.9.1

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

[libvirt] [PATCH v4 1/5] libxl: reorder libxlMakeDomBuildInfo for upcoming PVH support

2018-10-07 Thread Marek Marczykowski-Górecki
Make it easier to share HVM and PVH code where relevant. No functional
change.

Signed-off-by: Marek Marczykowski-Górecki 
---
 src/libxl/libxl_conf.c | 26 ++
 1 file changed, 14 insertions(+), 12 deletions(-)

diff --git a/src/libxl/libxl_conf.c b/src/libxl/libxl_conf.c
index e2bfa2f..f3da0ed 100644
--- a/src/libxl/libxl_conf.c
+++ b/src/libxl/libxl_conf.c
@@ -376,18 +376,6 @@ libxlMakeDomBuildInfo(virDomainDefPtr def,
 b_info->max_memkb = virDomainDefGetMemoryInitial(def);
 b_info->target_memkb = def->mem.cur_balloon;
 if (hvm) {
-char bootorder[VIR_DOMAIN_BOOT_LAST + 1];
-
-libxl_defbool_set(_info->u.hvm.pae,
-  def->features[VIR_DOMAIN_FEATURE_PAE] ==
-  VIR_TRISTATE_SWITCH_ON);
-libxl_defbool_set(_info->u.hvm.apic,
-  def->features[VIR_DOMAIN_FEATURE_APIC] ==
-  VIR_TRISTATE_SWITCH_ON);
-libxl_defbool_set(_info->u.hvm.acpi,
-  def->features[VIR_DOMAIN_FEATURE_ACPI] ==
-  VIR_TRISTATE_SWITCH_ON);
-
 if (caps &&
 def->cpu && def->cpu->mode == (VIR_CPU_MODE_HOST_PASSTHROUGH)) {
 bool hasHwVirt = false;
@@ -474,6 +462,20 @@ libxlMakeDomBuildInfo(virDomainDefPtr def,
  "mode=host-passthrough to avoid risk of changed guest "
  "semantics when mode=custom is supported in the future");
 }
+}
+
+if (hvm) {
+char bootorder[VIR_DOMAIN_BOOT_LAST + 1];
+
+libxl_defbool_set(_info->u.hvm.pae,
+  def->features[VIR_DOMAIN_FEATURE_PAE] ==
+  VIR_TRISTATE_SWITCH_ON);
+libxl_defbool_set(_info->u.hvm.apic,
+  def->features[VIR_DOMAIN_FEATURE_APIC] ==
+  VIR_TRISTATE_SWITCH_ON);
+libxl_defbool_set(_info->u.hvm.acpi,
+  def->features[VIR_DOMAIN_FEATURE_ACPI] ==
+  VIR_TRISTATE_SWITCH_ON);
 
 if (def->nsounds > 0) {
 /*
-- 
git-series 0.9.1

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

[libvirt] [PATCH v4 3/5] tests: add basic Xen PVH test

2018-10-07 Thread Marek Marczykowski-Górecki
Signed-off-by: Marek Marczykowski-Górecki 
---
Changes in v3:
 - update for modified "libxl: add support for PVH"
 - skip PVH test on too old Xen
---
 tests/libxlxml2domconfigdata/basic-pvh.json | 49 ++-
 tests/libxlxml2domconfigdata/basic-pvh.xml  | 28 +-
 tests/libxlxml2domconfigtest.c  |  3 +-
 3 files changed, 80 insertions(+)
 create mode 100644 tests/libxlxml2domconfigdata/basic-pvh.json
 create mode 100644 tests/libxlxml2domconfigdata/basic-pvh.xml

diff --git a/tests/libxlxml2domconfigdata/basic-pvh.json 
b/tests/libxlxml2domconfigdata/basic-pvh.json
new file mode 100644
index 000..48365c9
--- /dev/null
+++ b/tests/libxlxml2domconfigdata/basic-pvh.json
@@ -0,0 +1,49 @@
+{
+"c_info": {
+"type": "pvh",
+"name": "test-pvh",
+"uuid": "039e9ee6-4a84-3055-4c81-8ba426ae2656"
+},
+"b_info": {
+"max_vcpus": 4,
+"avail_vcpus": [
+0,
+1,
+2,
+3
+],
+"max_memkb": 524288,
+"target_memkb": 524288,
+"shadow_memkb": 8192,
+"sched_params": {
+
+},
+"kernel": "/boot/vmlinuz",
+"ramdisk": "/boot/initrd.img",
+"type.pvh": {
+},
+"arch_arm": {
+
+}
+},
+"disks": [
+{
+"pdev_path": "/var/lib/xen/images/test-pv.img",
+"vdev": "xvda",
+"backend": "qdisk",
+"format": "raw",
+"removable": 1,
+"readwrite": 1
+}
+],
+"nics": [
+{
+"devid": 0,
+"mac": "00:16:3e:3e:86:60",
+"bridge": "br0",
+"script": "/etc/xen/scripts/vif-bridge",
+"nictype": "vif"
+}
+],
+"on_reboot": "restart"
+}
diff --git a/tests/libxlxml2domconfigdata/basic-pvh.xml 
b/tests/libxlxml2domconfigdata/basic-pvh.xml
new file mode 100644
index 000..7bcf67f
--- /dev/null
+++ b/tests/libxlxml2domconfigdata/basic-pvh.xml
@@ -0,0 +1,28 @@
+
+  test-pvh
+  039e9ee6-4a84-3055-4c81-8ba426ae2656
+  524288
+  524288
+  4
+  
+xen
+/boot/vmlinuz
+/boot/initrd.img
+  
+  
+  destroy
+  restart
+  destroy
+  
+
+  
+  
+  
+
+
+  
+  
+  
+
+  
+
diff --git a/tests/libxlxml2domconfigtest.c b/tests/libxlxml2domconfigtest.c
index 22f9c2c..a2b2f81 100644
--- a/tests/libxlxml2domconfigtest.c
+++ b/tests/libxlxml2domconfigtest.c
@@ -204,6 +204,9 @@ mymain(void)
 
 DO_TEST("basic-pv");
 DO_TEST("basic-hvm");
+# ifdef HAVE_XEN_PVH
+DO_TEST("basic-pvh");
+# endif
 DO_TEST("cpu-shares-hvm");
 DO_TEST("variable-clock-hvm");
 DO_TEST("moredevs-hvm");
-- 
git-series 0.9.1

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

[libvirt] [PATCH v4 5/5] xenconfig: add support for type="pvh"

2018-10-07 Thread Marek Marczykowski-Górecki
Handle PVH domain type in both directions (xen-xl->xml, xml->xen-xl).
And add a test for it.

Signed-off-by: Marek Marczykowski-Górecki 
---
Changes in v3:
 - update for modified "libxl: add support for PVH"
---
 src/xenconfig/xen_common.c   | 11 +--
 src/xenconfig/xen_xl.c   |  5 +
 tests/testutilsxen.c |  3 ++-
 tests/xlconfigdata/test-pvh-type.cfg | 13 +
 tests/xlconfigdata/test-pvh-type.xml | 25 +
 tests/xlconfigtest.c |  1 +
 6 files changed, 55 insertions(+), 3 deletions(-)
 create mode 100644 tests/xlconfigdata/test-pvh-type.cfg
 create mode 100644 tests/xlconfigdata/test-pvh-type.xml

diff --git a/src/xenconfig/xen_common.c b/src/xenconfig/xen_common.c
index 6c27936..30b1c9f 100644
--- a/src/xenconfig/xen_common.c
+++ b/src/xenconfig/xen_common.c
@@ -1091,6 +1091,7 @@ xenParseGeneralMeta(virConfPtr conf, virDomainDefPtr def, 
virCapsPtr caps)
 virCapsDomainDataPtr capsdata = NULL;
 VIR_AUTOFREE(char *) str = NULL;
 int hvm = 0, ret = -1;
+const char *machine = "xenpv";
 
 if (xenConfigCopyString(conf, "name", >name) < 0)
 goto out;
@@ -1101,8 +1102,12 @@ xenParseGeneralMeta(virConfPtr conf, virDomainDefPtr 
def, virCapsPtr caps)
 if (xenConfigGetString(conf, "type", , NULL) == 0 && str) {
 if (STREQ(str, "pv")) {
 hvm = 0;
+} else if (STREQ(str, "pvh")) {
+hvm = 0;
+machine = "xenpvh";
 } else if (STREQ(str, "hvm")) {
 hvm = 1;
+machine = "xenfv";
 } else {
 virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("type %s is not supported"), str);
@@ -1110,14 +1115,16 @@ xenParseGeneralMeta(virConfPtr conf, virDomainDefPtr 
def, virCapsPtr caps)
 }
 } else {
 if ((xenConfigGetString(conf, "builder", , "linux") == 0) &&
-STREQ(str, "hvm"))
+STREQ(str, "hvm")) {
 hvm = 1;
+machine = "xenfv";
+}
 }
 
 def->os.type = (hvm ? VIR_DOMAIN_OSTYPE_HVM : VIR_DOMAIN_OSTYPE_XEN);
 
 if (!(capsdata = virCapabilitiesDomainDataLookup(caps, def->os.type,
-VIR_ARCH_NONE, def->virtType, NULL, NULL)))
+VIR_ARCH_NONE, def->virtType, NULL, machine)))
 goto out;
 
 def->os.arch = capsdata->arch;
diff --git a/src/xenconfig/xen_xl.c b/src/xenconfig/xen_xl.c
index 7250e57..0df8f35 100644
--- a/src/xenconfig/xen_xl.c
+++ b/src/xenconfig/xen_xl.c
@@ -1287,6 +1287,11 @@ xenFormatXLOS(virConfPtr conf, virDomainDefPtr def)
 
 /* XXX floppy disks */
 } else {
+if (STREQ(def->os.machine, "xenpvh")) {
+if (xenConfigSetString(conf, "type", "pvh") < 0)
+return -1;
+}
+
 if (def->os.bootloader &&
  xenConfigSetString(conf, "bootloader", def->os.bootloader) < 0)
 return -1;
diff --git a/tests/testutilsxen.c b/tests/testutilsxen.c
index d34be72..c112912 100644
--- a/tests/testutilsxen.c
+++ b/tests/testutilsxen.c
@@ -17,7 +17,8 @@ testXLInitCaps(void)
 "xenfv"
 };
 static const char *const xen_machines[] = {
-"xenpv"
+"xenpv",
+"xenpvh"
 };
 
 if ((caps = virCapabilitiesNew(virArchFromHost(),
diff --git a/tests/xlconfigdata/test-pvh-type.cfg 
b/tests/xlconfigdata/test-pvh-type.cfg
new file mode 100644
index 000..2493535
--- /dev/null
+++ b/tests/xlconfigdata/test-pvh-type.cfg
@@ -0,0 +1,13 @@
+name = "XenGuest2"
+uuid = "c7a5fdb2-cdaf-9455-926a-d65c16db1809"
+maxmem = 579
+memory = 394
+vcpus = 1
+localtime = 0
+on_poweroff = "destroy"
+on_reboot = "restart"
+on_crash = "restart"
+type = "pvh"
+kernel = "/tmp/vmlinuz"
+ramdisk = "/tmp/initrd"
+cmdline = "root=/dev/xvda1 console=hvc0"
diff --git a/tests/xlconfigdata/test-pvh-type.xml 
b/tests/xlconfigdata/test-pvh-type.xml
new file mode 100644
index 000..7e3f182
--- /dev/null
+++ b/tests/xlconfigdata/test-pvh-type.xml
@@ -0,0 +1,25 @@
+
+  XenGuest2
+  c7a5fdb2-cdaf-9455-926a-d65c16db1809
+  592896
+  403456
+  1
+  
+xen
+/tmp/vmlinuz
+/tmp/initrd
+root=/dev/xvda1 console=hvc0
+  
+  
+  destroy
+  restart
+  restart
+  
+
+  
+
+
+
+
+  
+
diff --git a/tests/xlconfigtest.c b/tests/xlconfigtest.c
index 6e3267e..5159182 100644
--- a/tests/xlconfigtest.c
+++ b/tests/xlconfigtest.c
@@ -281,6 +281,7 @@ mymain(void)
 DO_TEST("rbd-multihost-noauth");
 DO_TEST_FORMAT("paravirt-type", false);
 DO_TEST_FORMAT("fullvirt-type", false);
+DO_TEST("pvh-type");
 
 #ifdef LIBXL_HAVE_DEVICE_CHANNEL
 DO_TEST("channel-pty");
-- 
git-series 0.9.1

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

[libvirt] [PATCH v4 4/5] xenconfig: add support for parsing type= xl config entry

2018-10-07 Thread Marek Marczykowski-Górecki
builder="hvm" is deprecated since Xen 4.10, new syntax is type="hvm" (or
type="pv", which is default). Since the old one is still supported,
still use it when writing native config, so the config will work on
older Xen too (and will also not complicate tests).

Signed-off-by: Marek Marczykowski-Górecki 
---
"type" option is the only syntax for specifying PVH guest, coming in
next patch.

Changes in v2:
 - fix code style
---
 src/xenconfig/xen_common.c| 18 +---
 tests/xlconfigdata/test-fullvirt-type.cfg | 21 +++-
 tests/xlconfigdata/test-fullvirt-type.xml | 27 -
 tests/xlconfigdata/test-paravirt-type.cfg | 13 -
 tests/xlconfigdata/test-paravirt-type.xml | 25 ++-
 tests/xlconfigtest.c  |  2 ++-
 6 files changed, 103 insertions(+), 3 deletions(-)
 create mode 100644 tests/xlconfigdata/test-fullvirt-type.cfg
 create mode 100644 tests/xlconfigdata/test-fullvirt-type.xml
 create mode 100644 tests/xlconfigdata/test-paravirt-type.cfg
 create mode 100644 tests/xlconfigdata/test-paravirt-type.xml

diff --git a/src/xenconfig/xen_common.c b/src/xenconfig/xen_common.c
index 0a99587..6c27936 100644
--- a/src/xenconfig/xen_common.c
+++ b/src/xenconfig/xen_common.c
@@ -1098,9 +1098,21 @@ xenParseGeneralMeta(virConfPtr conf, virDomainDefPtr 
def, virCapsPtr caps)
 if (xenConfigGetUUID(conf, "uuid", def->uuid) < 0)
 goto out;
 
-if ((xenConfigGetString(conf, "builder", , "linux") == 0) &&
-STREQ(str, "hvm"))
-hvm = 1;
+if (xenConfigGetString(conf, "type", , NULL) == 0 && str) {
+if (STREQ(str, "pv")) {
+hvm = 0;
+} else if (STREQ(str, "hvm")) {
+hvm = 1;
+} else {
+virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+   _("type %s is not supported"), str);
+return -1;
+}
+} else {
+if ((xenConfigGetString(conf, "builder", , "linux") == 0) &&
+STREQ(str, "hvm"))
+hvm = 1;
+}
 
 def->os.type = (hvm ? VIR_DOMAIN_OSTYPE_HVM : VIR_DOMAIN_OSTYPE_XEN);
 
diff --git a/tests/xlconfigdata/test-fullvirt-type.cfg 
b/tests/xlconfigdata/test-fullvirt-type.cfg
new file mode 100644
index 000..f8ecc2e
--- /dev/null
+++ b/tests/xlconfigdata/test-fullvirt-type.cfg
@@ -0,0 +1,21 @@
+name = "XenGuest2"
+uuid = "c7a5fdb2-cdaf-9455-926a-d65c16db1809"
+maxmem = 579
+memory = 394
+vcpus = 1
+pae = 1
+acpi = 1
+apic = 1
+viridian = 0
+rtc_timeoffset = 0
+localtime = 0
+on_poweroff = "destroy"
+on_reboot = "restart"
+on_crash = "restart"
+device_model = "/usr/lib/xen/bin/qemu-system-i386"
+sdl = 0
+vnc = 0
+parallel = "none"
+serial = "none"
+type = "hvm"
+boot = "d"
diff --git a/tests/xlconfigdata/test-fullvirt-type.xml 
b/tests/xlconfigdata/test-fullvirt-type.xml
new file mode 100644
index 000..da8e360
--- /dev/null
+++ b/tests/xlconfigdata/test-fullvirt-type.xml
@@ -0,0 +1,27 @@
+
+  XenGuest2
+  c7a5fdb2-cdaf-9455-926a-d65c16db1809
+  592896
+  403456
+  1
+  
+hvm
+/usr/lib/xen/boot/hvmloader
+
+  
+  
+
+
+
+  
+  
+  destroy
+  restart
+  restart
+  
+/usr/lib/xen/bin/qemu-system-i386
+
+
+
+  
+
diff --git a/tests/xlconfigdata/test-paravirt-type.cfg 
b/tests/xlconfigdata/test-paravirt-type.cfg
new file mode 100644
index 000..078db99
--- /dev/null
+++ b/tests/xlconfigdata/test-paravirt-type.cfg
@@ -0,0 +1,13 @@
+name = "XenGuest2"
+uuid = "c7a5fdb2-cdaf-9455-926a-d65c16db1809"
+type = "pv"
+maxmem = 579
+memory = 394
+vcpus = 1
+localtime = 0
+on_poweroff = "destroy"
+on_reboot = "restart"
+on_crash = "restart"
+kernel = "/tmp/vmlinuz"
+ramdisk = "/tmp/initrd"
+cmdline = "root=/dev/xvda1 console=hvc0"
diff --git a/tests/xlconfigdata/test-paravirt-type.xml 
b/tests/xlconfigdata/test-paravirt-type.xml
new file mode 100644
index 000..4357640
--- /dev/null
+++ b/tests/xlconfigdata/test-paravirt-type.xml
@@ -0,0 +1,25 @@
+
+  XenGuest2
+  c7a5fdb2-cdaf-9455-926a-d65c16db1809
+  592896
+  403456
+  1
+  
+linux
+/tmp/vmlinuz
+/tmp/initrd
+root=/dev/xvda1 console=hvc0
+  
+  
+  destroy
+  restart
+  restart
+  
+
+  
+
+
+
+
+  
+
diff --git a/tests/xlconfigtest.c b/tests/xlconfigtest.c
index b2e4591..6e3267e 100644
--- a/tests/xlconfigtest.c
+++ b/tests/xlconfigtest.c
@@ -279,6 +279,8 @@ mymain(void)
 DO_TEST_FORMAT("paravirt-cmdline-extra-root", false);
 DO_TEST_FORMAT("paravirt-cmdline-bogus-extra-root", false);
 DO_TEST("rbd-multihost-noauth");
+DO_TEST_FORMAT("paravirt-type", false);
+DO_TEST_FORMAT("fullvirt-type", false);
 
 #ifdef LIBXL_HAVE_DEVICE_CHANNEL
 DO_TEST("channel-pty");
-- 
git-series 0.9.1

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

[libvirt] [PATCH v4 2/5] libxl: add support for PVH

2018-10-07 Thread Marek Marczykowski-Górecki
Since this is something between PV and HVM, it makes sense to put the
setting in place where domain type is specified.
To enable it, use  It is
also included in capabilities.xml, for every supported HVM guest type - it
doesn't seems to be any other requirement (besides new enough Xen).

Signed-off-by: Marek Marczykowski-Górecki 
---
Changes in v2 proposed by Jim:
 - use new_arch_added var instead of i == nr_guest_archs for clarity
 - improve comment
 - adjust for now required Xen >= 4.6 (remove part for Xen < 4.5)

Changes in v3:
 - limit VIR_DOMAIN_OSTYPE_XEN -> VIR_DOMAIN_OSTYPE_LINUX conversion to
 Xen PV only
 - do not accept VIR_DOMAIN_OSTYPE_LINUX for PVH
 - fix reported capabilities for PVH - remove hostdev passthrough and
 video/graphics
 - use #ifdef LIBXL_DOMAIN_TYPE_PVH instead of hypervisor version to
 check for PVH support
 - compile fix for Xen < 4.9

Changes in v4:
 - revert to "i == nr_guest_archs-1" check
 - let configure check for LIBXL_DOMAIN_TYPE_PVH and use #ifdef
 HAVE_XEN_PVH then
 - fix comment about Xen version
---
 docs/formatcaps.html.in|  4 +--
 docs/schemas/domaincommon.rng  |  1 +-
 m4/virt-driver-libxl.m4|  3 ++-
 src/conf/domain_conf.c |  6 ++--
 src/libxl/libxl_capabilities.c | 38 ++-
 src/libxl/libxl_conf.c | 50 ++-
 src/libxl/libxl_driver.c   |  6 ++--
 7 files changed, 90 insertions(+), 18 deletions(-)

diff --git a/docs/formatcaps.html.in b/docs/formatcaps.html.in
index 0d9c53d..fe113bc 100644
--- a/docs/formatcaps.html.in
+++ b/docs/formatcaps.html.in
@@ -104,8 +104,8 @@
 machineMachine type, for use in
   machine
   attribute of os/type element in domain XML. For example Xen
-  supports xenfv for HVM or xenpv for
-  PV.
+  supports xenfv for HVM, xenpv for
+  PV, or xenpvh for PVH.
 domainThe type attribute of
   this element specifies the type of hypervisor required to run the
   domain. Use in type
diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
index 099a949..820a7c6 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -341,6 +341,7 @@
   
 xenpv
 xenfv
+xenpvh
   
 
   
diff --git a/m4/virt-driver-libxl.m4 b/m4/virt-driver-libxl.m4
index 479d911..2cd97cc 100644
--- a/m4/virt-driver-libxl.m4
+++ b/m4/virt-driver-libxl.m4
@@ -75,6 +75,9 @@ AC_DEFUN([LIBVIRT_DRIVER_CHECK_LIBXL], [
 ])
   fi
 
+  dnl Check if Xen has support for PVH
+  AC_CHECK_DECL(LIBXL_DOMAIN_TYPE_PVH, [AC_DEFINE([HAVE_XEN_PVH], [1], [Define 
to 1 if Xen has PVH support.])], [], [#include ])
+
   AC_SUBST([LIBXL_CFLAGS])
   AC_SUBST([LIBXL_LIBS])
 ])
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 9911d56..a945ad4 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -19094,7 +19094,8 @@ virDomainDefParseCaps(virDomainDefPtr def,
  * be 'xen'. So we accept the former and convert
  */
 if (def->os.type == VIR_DOMAIN_OSTYPE_LINUX &&
-def->virtType == VIR_DOMAIN_VIRT_XEN) {
+def->virtType == VIR_DOMAIN_VIRT_XEN &&
+(!def->os.machine || STREQ(def->os.machine, "xenpv"))) {
 def->os.type = VIR_DOMAIN_OSTYPE_XEN;
 }
 
@@ -27705,7 +27706,8 @@ virDomainDefFormatInternal(virDomainDefPtr def,
  * be 'xen'. So we convert to the former for backcompat
  */
 if (def->virtType == VIR_DOMAIN_VIRT_XEN &&
-def->os.type == VIR_DOMAIN_OSTYPE_XEN)
+def->os.type == VIR_DOMAIN_OSTYPE_XEN &&
+(!def->os.machine || STREQ(def->os.machine, "xenpv")))
 virBufferAsprintf(buf, ">%s\n",
   virDomainOSTypeToString(VIR_DOMAIN_OSTYPE_LINUX));
 else
diff --git a/src/libxl/libxl_capabilities.c b/src/libxl/libxl_capabilities.c
index 18596c7..eecd5e9 100644
--- a/src/libxl/libxl_capabilities.c
+++ b/src/libxl/libxl_capabilities.c
@@ -57,6 +57,7 @@ struct guest_arch {
 virArch arch;
 int bits;
 int hvm;
+int pvh;
 int pae;
 int nonpae;
 int ia64_be;
@@ -491,13 +492,33 @@ libxlCapsInitGuests(libxl_ctx *ctx, virCapsPtr caps)
 guest_archs[i].nonpae = nonpae;
 if (ia64_be)
 guest_archs[i].ia64_be = ia64_be;
+
+/*
+ * Xen 4.10 introduced support for the PVH guest type, which
+ * requires hardware virtualization support similar to the
+ * HVM guest type. Add a PVH guest type for each new HVM
+ * guest type.
+ */
+#ifdef HAVE_XEN_PVH
+if (hvm && i == nr_guest_archs-1) {
+i = nr_guest_archs;
+/* Ensure we have not exhausted the guest_archs array */
+if (nr_guest_archs >= ARRAY_CARDINALITY(guest_archs))
+continue;
+

[libvirt] [PATCH 09/11] qemu: Detect whether iothread polling is supported

2018-10-07 Thread John Ferlan
Add a capability check for IOThread polling (all were added at the
same time, so only one check is necessary).

Based on code originally posted by Pavel Hrdina 
with the only changes to include the more recent QEMU releases.

Signed-off-by: John Ferlan 
---
 src/qemu/qemu_capabilities.c   | 2 ++
 src/qemu/qemu_capabilities.h   | 1 +
 tests/qemucapabilitiesdata/caps_2.10.0.aarch64.xml | 1 +
 tests/qemucapabilitiesdata/caps_2.10.0.ppc64.xml   | 1 +
 tests/qemucapabilitiesdata/caps_2.10.0.s390x.xml   | 1 +
 tests/qemucapabilitiesdata/caps_2.10.0.x86_64.xml  | 1 +
 tests/qemucapabilitiesdata/caps_2.11.0.s390x.xml   | 1 +
 tests/qemucapabilitiesdata/caps_2.11.0.x86_64.xml  | 1 +
 tests/qemucapabilitiesdata/caps_2.12.0.aarch64.xml | 1 +
 tests/qemucapabilitiesdata/caps_2.12.0.ppc64.xml   | 1 +
 tests/qemucapabilitiesdata/caps_2.12.0.s390x.xml   | 1 +
 tests/qemucapabilitiesdata/caps_2.12.0.x86_64.xml  | 1 +
 tests/qemucapabilitiesdata/caps_2.9.0.ppc64.xml| 1 +
 tests/qemucapabilitiesdata/caps_2.9.0.s390x.xml| 1 +
 tests/qemucapabilitiesdata/caps_2.9.0.x86_64.xml   | 1 +
 tests/qemucapabilitiesdata/caps_3.0.0.ppc64.xml| 1 +
 tests/qemucapabilitiesdata/caps_3.0.0.riscv32.xml  | 1 +
 tests/qemucapabilitiesdata/caps_3.0.0.riscv64.xml  | 1 +
 tests/qemucapabilitiesdata/caps_3.0.0.s390x.xml| 1 +
 tests/qemucapabilitiesdata/caps_3.0.0.x86_64.xml   | 1 +
 20 files changed, 21 insertions(+)

diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index e228f52ec0..54589a740d 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -508,6 +508,7 @@ VIR_ENUM_IMPL(virQEMUCaps, QEMU_CAPS_LAST,
   /* 315 */
   "vfio-pci.display",
   "blockdev",
+  "iothread.poll-max-ns",
 );
 
 
@@ -1237,6 +1238,7 @@ static struct virQEMUCapsStringFlags 
virQEMUCapsQMPSchemaQueries[] = {
 { "nbd-server-start/arg-type/tls-creds", QEMU_CAPS_NBD_TLS },
 { "screendump/arg-type/device", QEMU_CAPS_SCREENDUMP_DEVICE },
 { "block-commit/arg-type/*top",  QEMU_CAPS_ACTIVE_COMMIT },
+{ "query-iothreads/ret-type/poll-max-ns", QEMU_CAPS_IOTHREAD_POLLING },
 };
 
 typedef struct _virQEMUCapsObjectTypeProps virQEMUCapsObjectTypeProps;
diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h
index 934620ed31..8dbe23de20 100644
--- a/src/qemu/qemu_capabilities.h
+++ b/src/qemu/qemu_capabilities.h
@@ -492,6 +492,7 @@ typedef enum { /* virQEMUCapsFlags grouping marker for 
syntax-check */
 /* 315 */
 QEMU_CAPS_VFIO_PCI_DISPLAY, /* -device vfio-pci.display */
 QEMU_CAPS_BLOCKDEV, /* -blockdev and blockdev-add are supported */
+QEMU_CAPS_IOTHREAD_POLLING, /* -object iothread.poll-max-ns */
 
 QEMU_CAPS_LAST /* this must always be the last item */
 } virQEMUCapsFlags;
diff --git a/tests/qemucapabilitiesdata/caps_2.10.0.aarch64.xml 
b/tests/qemucapabilitiesdata/caps_2.10.0.aarch64.xml
index b9c4182a66..7061ba8f7e 100644
--- a/tests/qemucapabilitiesdata/caps_2.10.0.aarch64.xml
+++ b/tests/qemucapabilitiesdata/caps_2.10.0.aarch64.xml
@@ -151,6 +151,7 @@
   
   
   
+  
   201
   0
   305067
diff --git a/tests/qemucapabilitiesdata/caps_2.10.0.ppc64.xml 
b/tests/qemucapabilitiesdata/caps_2.10.0.ppc64.xml
index 66b25601e7..2a48b63efe 100644
--- a/tests/qemucapabilitiesdata/caps_2.10.0.ppc64.xml
+++ b/tests/qemucapabilitiesdata/caps_2.10.0.ppc64.xml
@@ -150,6 +150,7 @@
   
   
   
+  
   201
   0
   384412
diff --git a/tests/qemucapabilitiesdata/caps_2.10.0.s390x.xml 
b/tests/qemucapabilitiesdata/caps_2.10.0.s390x.xml
index e000aac384..c35e014b32 100644
--- a/tests/qemucapabilitiesdata/caps_2.10.0.s390x.xml
+++ b/tests/qemucapabilitiesdata/caps_2.10.0.s390x.xml
@@ -113,6 +113,7 @@
   
   
   
+  
   201
   0
   306247
diff --git a/tests/qemucapabilitiesdata/caps_2.10.0.x86_64.xml 
b/tests/qemucapabilitiesdata/caps_2.10.0.x86_64.xml
index ebc5e771d9..a8d787f99a 100644
--- a/tests/qemucapabilitiesdata/caps_2.10.0.x86_64.xml
+++ b/tests/qemucapabilitiesdata/caps_2.10.0.x86_64.xml
@@ -192,6 +192,7 @@
   
   
   
+  
   201
   0
   364386
diff --git a/tests/qemucapabilitiesdata/caps_2.11.0.s390x.xml 
b/tests/qemucapabilitiesdata/caps_2.11.0.s390x.xml
index 4eb8a39d94..6ee53a1f21 100644
--- a/tests/qemucapabilitiesdata/caps_2.11.0.s390x.xml
+++ b/tests/qemucapabilitiesdata/caps_2.11.0.s390x.xml
@@ -120,6 +120,7 @@
   
   
   
+  
   2011000
   0
   345099
diff --git a/tests/qemucapabilitiesdata/caps_2.11.0.x86_64.xml 
b/tests/qemucapabilitiesdata/caps_2.11.0.x86_64.xml
index 857a9a9f9a..4ba2a82b60 100644
--- a/tests/qemucapabilitiesdata/caps_2.11.0.x86_64.xml
+++ b/tests/qemucapabilitiesdata/caps_2.11.0.x86_64.xml
@@ -198,6 +198,7 @@
   
   
   
+  
   2011000
   0
   368875
diff --git a/tests/qemucapabilitiesdata/caps_2.12.0.aarch64.xml 
b/tests/qemucapabilitiesdata/caps_2.12.0.aarch64.xml
index 7bf1fab8cb..c7e62d3723 100644
--- 

[libvirt] [PATCH 11/11] tools: Add virsh iothreadset command

2018-10-07 Thread John Ferlan
Add a command to allow for setting various dynamic IOThread polling
interval scope (poll-max-ns, poll-grow, and poll-shrink). Describe
the values in the virsh.pod in as generic terms as possible. The
more specific QEMU algorithm has been divulged in the previous patch.

Based heavily on code originally posted by Pavel Hrdina
, but altered to only provide one command
and to not managed a poll disabled state.

Signed-off-by: John Ferlan 
---
 tools/virsh-domain.c | 110 +++
 tools/virsh.pod  |  21 +
 2 files changed, 131 insertions(+)

diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
index 372bdb95d3..4ee6ddf956 100644
--- a/tools/virsh-domain.c
+++ b/tools/virsh-domain.c
@@ -7734,6 +7734,110 @@ cmdIOThreadAdd(vshControl *ctl, const vshCmd *cmd)
 return ret;
 }
 
+
+ /*
+ * "iothreadset" command
+ */
+static const vshCmdInfo info_iothreadset[] = {
+{.name = "help",
+ .data = N_("modifies an existing IOThread of the guest domain")
+},
+{.name = "desc",
+ .data = N_("Modifies an existing IOThread of the guest domain.")
+},
+{.name = NULL}
+};
+
+static const vshCmdOptDef opts_iothreadset[] = {
+VIRSH_COMMON_OPT_DOMAIN_FULL(0),
+{.name = "id",
+ .type = VSH_OT_INT,
+ .flags = VSH_OFLAG_REQ,
+ .help = N_("iothread id of existing IOThread")
+},
+{.name = "poll-max-ns",
+ .type = VSH_OT_INT,
+ .help = N_("set the maximum IOThread polling time in ns")
+},
+{.name = "poll-grow",
+ .type = VSH_OT_INT,
+ .help = N_("set the value to increase the IOThread polling time")
+},
+{.name = "poll-shrink",
+ .type = VSH_OT_INT,
+ .help = N_("set the value for reduction of the IOThread polling time ")
+},
+VIRSH_COMMON_OPT_DOMAIN_LIVE,
+VIRSH_COMMON_OPT_DOMAIN_CURRENT,
+{.name = NULL}
+};
+
+static bool
+cmdIOThreadSet(vshControl *ctl, const vshCmd *cmd)
+{
+virDomainPtr dom;
+int id = 0;
+bool ret = false;
+bool live = vshCommandOptBool(cmd, "live");
+unsigned int flags = VIR_DOMAIN_AFFECT_CURRENT;
+virTypedParameterPtr params = NULL;
+int nparams = 0;
+int maxparams = 0;
+unsigned long long poll_max;
+unsigned int poll_val;
+int rc;
+
+if (live)
+flags |= VIR_DOMAIN_AFFECT_LIVE;
+
+if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
+return false;
+
+if (vshCommandOptInt(ctl, cmd, "id", ) < 0)
+goto cleanup;
+if (id <= 0) {
+vshError(ctl, _("Invalid IOThread id value: '%d'"), id);
+goto cleanup;
+}
+
+poll_val = 0;
+if ((rc = vshCommandOptULongLong(ctl, cmd, "poll-max-ns", _max)) < 0)
+goto cleanup;
+if (rc > 0 && virTypedParamsAddULLong(, , ,
+  VIR_DOMAIN_IOTHREAD_POLL_MAX_NS,
+  poll_max) < 0)
+goto save_error;
+
+#define VSH_IOTHREAD_SET_UINT_PARAMS(opt, param) \
+poll_val = 0; \
+if ((rc = vshCommandOptUInt(ctl, cmd, opt, _val)) < 0) \
+goto cleanup; \
+if (rc > 0 && \
+virTypedParamsAddUInt(, , , \
+  param, poll_val) < 0) \
+goto save_error;
+
+VSH_IOTHREAD_SET_UINT_PARAMS("poll-grow", VIR_DOMAIN_IOTHREAD_POLL_GROW)
+VSH_IOTHREAD_SET_UINT_PARAMS("poll-shrink", 
VIR_DOMAIN_IOTHREAD_POLL_SHRINK)
+
+#undef VSH_IOTHREAD_SET_UINT_PARAMS
+
+if (virDomainSetIOThreadParams(dom, id, params, nparams, flags) < 0)
+goto cleanup;
+
+ret = true;
+
+ cleanup:
+virTypedParamsFree(params, nparams);
+virshDomainFree(dom);
+return ret;
+
+ save_error:
+vshSaveLibvirtError();
+goto cleanup;
+}
+
+
 /*
  * "iothreaddel" command
  */
@@ -14149,6 +14253,12 @@ const vshCmdDef domManagementCmds[] = {
  .info = info_iothreadadd,
  .flags = 0
 },
+{.name = "iothreadset",
+ .handler = cmdIOThreadSet,
+ .opts = opts_iothreadset,
+ .info = info_iothreadset,
+ .flags = 0
+},
 {.name = "iothreaddel",
  .handler = cmdIOThreadDel,
  .opts = opts_iothreaddel,
diff --git a/tools/virsh.pod b/tools/virsh.pod
index 90f3c1ef5c..48766567f8 100644
--- a/tools/virsh.pod
+++ b/tools/virsh.pod
@@ -1732,6 +1732,27 @@ If I<--config> is specified, affect the next boot of a 
persistent guest.
 If I<--current> is specified or I<--live> and I<--config> are not specified,
 affect the current guest state.
 
+=item B I I
+[[I<--poll-max-ns> B] [I<--poll-grow> B]
+[I<--poll-shrink> B]]
+[[I<--config>] [I<--live>] | [I<--current>]]
+
+Modifies an existing iothread of the domain using the specified
+I. The I<--poll-max-ns> provides the maximum polling
+interval to be allowed for an IOThread in ns. If a 0 (zero) is provided,
+then polling for the IOThread is disabled.  The I<--poll-grow> is the
+factor by which the current polling time will be adjusted in order to
+reach the maximum polling time. If a 0 (zero) is provided, then the
+default 

[libvirt] [PATCH 08/11] qemu: Alter qemuDomainChgIOThread to take qemuMonitorIOThreadInfo

2018-10-07 Thread John Ferlan
Rather than passing an iothread_id, let's pass a qemuMonitorIOThreadInfo
structure so that a subsequent change to modify the iothread info can
just generate and pass one.

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

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index ff466df4b7..c87a0db86d 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -6023,7 +6023,7 @@ typedef enum {
 static int
 qemuDomainChgIOThread(virQEMUDriverPtr driver,
   virDomainObjPtr vm,
-  unsigned int iothread_id,
+  qemuMonitorIOThreadInfo iothread,
   virDomainIOThreadAction action,
   unsigned int flags)
 {
@@ -6052,19 +6052,19 @@ qemuDomainChgIOThread(virQEMUDriverPtr driver,
 
 switch (action) {
 case VIR_DOMAIN_IOTHREAD_ACTION_ADD:
-if (qemuDomainAddIOThreadCheck(def, iothread_id) < 0)
+if (qemuDomainAddIOThreadCheck(def, iothread.iothread_id) < 0)
 goto endjob;
 
-if (qemuDomainHotplugAddIOThread(driver, vm, iothread_id) < 0)
+if (qemuDomainHotplugAddIOThread(driver, vm, iothread.iothread_id) 
< 0)
 goto endjob;
 
 break;
 
 case VIR_DOMAIN_IOTHREAD_ACTION_DEL:
-if (qemuDomainDelIOThreadCheck(def, iothread_id) < 0)
+if (qemuDomainDelIOThreadCheck(def, iothread.iothread_id) < 0)
 goto endjob;
 
-if (qemuDomainHotplugDelIOThread(driver, vm, iothread_id) < 0)
+if (qemuDomainHotplugDelIOThread(driver, vm, iothread.iothread_id) 
< 0)
 goto endjob;
 
 break;
@@ -6077,19 +6077,19 @@ qemuDomainChgIOThread(virQEMUDriverPtr driver,
 if (persistentDef) {
 switch (action) {
 case VIR_DOMAIN_IOTHREAD_ACTION_ADD:
-if (qemuDomainAddIOThreadCheck(persistentDef, iothread_id) < 0)
+if (qemuDomainAddIOThreadCheck(persistentDef, 
iothread.iothread_id) < 0)
 goto endjob;
 
-if (!virDomainIOThreadIDAdd(persistentDef, iothread_id))
+if (!virDomainIOThreadIDAdd(persistentDef, iothread.iothread_id))
 goto endjob;
 
 break;
 
 case VIR_DOMAIN_IOTHREAD_ACTION_DEL:
-if (qemuDomainDelIOThreadCheck(persistentDef, iothread_id) < 0)
+if (qemuDomainDelIOThreadCheck(persistentDef, 
iothread.iothread_id) < 0)
 goto endjob;
 
-virDomainIOThreadIDDel(persistentDef, iothread_id);
+virDomainIOThreadIDDel(persistentDef, iothread.iothread_id);
 
 break;
 }
@@ -6116,6 +6116,7 @@ qemuDomainAddIOThread(virDomainPtr dom,
 {
 virQEMUDriverPtr driver = dom->conn->privateData;
 virDomainObjPtr vm = NULL;
+qemuMonitorIOThreadInfo iothread = {0};
 int ret = -1;
 
 virCheckFlags(VIR_DOMAIN_AFFECT_LIVE |
@@ -6133,7 +6134,8 @@ qemuDomainAddIOThread(virDomainPtr dom,
 if (virDomainAddIOThreadEnsureACL(dom->conn, vm->def, flags) < 0)
 goto cleanup;
 
-ret = qemuDomainChgIOThread(driver, vm, iothread_id,
+iothread.iothread_id = iothread_id;
+ret = qemuDomainChgIOThread(driver, vm, iothread,
 VIR_DOMAIN_IOTHREAD_ACTION_ADD, flags);
 
  cleanup:
@@ -6149,6 +6151,7 @@ qemuDomainDelIOThread(virDomainPtr dom,
 {
 virQEMUDriverPtr driver = dom->conn->privateData;
 virDomainObjPtr vm = NULL;
+qemuMonitorIOThreadInfo iothread = {0};
 int ret = -1;
 
 virCheckFlags(VIR_DOMAIN_AFFECT_LIVE |
@@ -6166,7 +6169,8 @@ qemuDomainDelIOThread(virDomainPtr dom,
 if (virDomainDelIOThreadEnsureACL(dom->conn, vm->def, flags) < 0)
goto cleanup;
 
-ret = qemuDomainChgIOThread(driver, vm, iothread_id,
+iothread.iothread_id = iothread_id;
+ret = qemuDomainChgIOThread(driver, vm, iothread,
 VIR_DOMAIN_IOTHREAD_ACTION_DEL, flags);
 
  cleanup:
-- 
2.17.1

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


[libvirt] [PATCH 10/11] qemu: Introduce qemuDomainSetIOThreadParams

2018-10-07 Thread John Ferlan
https://bugzilla.redhat.com/show_bug.cgi?id=1545732

Implement the QEMU driver mechanism in order to set the polling
parameters for an IOThread within the bounds specified by the
QEMU qapi parameter passing.

Based heavily on patches originally posted by Pavel Hrdina
, but modified to only handle alterations
for a running guest. For the most part the API names changed,
the typed parameters removed the poll enabled value, and the
capabilities check was moved to just before the live attempt
to set. Since changes are only supported for a running guest,
no guest XML alterations were kept.

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

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index c87a0db86d..be668b3217 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -5899,6 +5899,35 @@ qemuDomainHotplugAddIOThread(virQEMUDriverPtr driver,
 goto cleanup;
 }
 
+
+static int
+qemuDomainHotplugModIOThread(virQEMUDriverPtr driver,
+ virDomainObjPtr vm,
+ qemuMonitorIOThreadInfo iothread)
+{
+qemuDomainObjPrivatePtr priv = vm->privateData;
+int rc;
+
+if (!virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_IOTHREAD_POLLING)) {
+virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+   _("IOThreads polling is not supported for this QEMU"));
+return -1;
+}
+
+qemuDomainObjEnterMonitor(driver, vm);
+
+rc = qemuMonitorSetIOThread(priv->mon, );
+
+if (qemuDomainObjExitMonitor(driver, vm) < 0)
+return -1;
+
+if (rc < 0)
+return -1;
+
+return 0;
+}
+
+
 static int
 qemuDomainHotplugDelIOThread(virQEMUDriverPtr driver,
  virDomainObjPtr vm,
@@ -6015,9 +6044,107 @@ qemuDomainDelIOThreadCheck(virDomainDefPtr def,
 return 0;
 }
 
+
+/**
+ * @params: Pointer to params list
+ * @nparams: Number of params to be parsed
+ * @iothread: Buffer to store the values
+ *
+ * The following is a description of each value parsed:
+ *
+ *  - "poll-max-ns" for each IOThread is the maximum time in nanoseconds
+ *to allow each polling interval to occur. A polling interval is a
+ *period of time allowed for a thread to process data before it returns
+ *the CPU quantum back to the host. A value set too small will not allow
+ *the IOThread to run long enough on a CPU to process data. A value set
+ *too high will consume too much CPU time per IOThread failing to allow
+ *other threads running on the CPU to get time. A value of 0 (zero) will
+ *disable the polling.
+ *
+ * - "poll-grow" - factor to grow the current polling time when deemed
+ *   necessary. If a 0 (zero) value is provided, QEMU currently doubles
+ *   its polling interval unless the current value is greater than the
+ *   poll-max-ns.
+ *
+ * - "poll-shrink" - divisor to reduced the current polling time when deemed
+ *   necessary. If a 0 (zero) value is provided, QEMU resets the polling
+ *   interval to 0 (zero) allowing the poll-grow to manipulate the time.
+ *
+ * QEMU keeps track of the polling time elapsed and may grow or shrink the
+ * its polling interval based upon its heuristic algorithm. It is possible
+ * that calculations determine that it has found a "sweet spot" and no
+ * ajustments are made. The polling time value is not available.
+ *
+ * Returns 0 on success, -1 on failure with error set.
+ */
+static int
+qemuDomainIOThreadParseParams(virTypedParameterPtr params,
+  int nparams,
+  qemuMonitorIOThreadInfoPtr iothread)
+{
+if (virTypedParamsValidate(params, nparams,
+   VIR_DOMAIN_IOTHREAD_POLL_MAX_NS,
+   VIR_TYPED_PARAM_ULLONG,
+   VIR_DOMAIN_IOTHREAD_POLL_GROW,
+   VIR_TYPED_PARAM_UINT,
+   VIR_DOMAIN_IOTHREAD_POLL_SHRINK,
+   VIR_TYPED_PARAM_UINT,
+   NULL) < 0)
+return -1;
+
+if (virTypedParamsGetULLong(params, nparams,
+VIR_DOMAIN_IOTHREAD_POLL_MAX_NS,
+>poll_max_ns) < 0)
+return -1;
+
+if (virTypedParamsGetUInt(params, nparams,
+  VIR_DOMAIN_IOTHREAD_POLL_GROW,
+  >poll_grow) < 0)
+return -1;
+
+if (virTypedParamsGetUInt(params, nparams,
+  VIR_DOMAIN_IOTHREAD_POLL_SHRINK,
+  >poll_shrink) < 0)
+return -1;
+
+if (iothread->poll_max_ns > INT_MAX) {
+virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+   _("poll-max-ns (%llu) must be less than or equal to 
%d"),
+   iothread->poll_max_ns, INT_MAX);
+return -1;
+}
+
+if 

[libvirt] [PATCH 04/11] virsh: Add ability to display IOThread stats

2018-10-07 Thread John Ferlan
Add an --iothread qualifier to domstats and an explanation in
the man page. Describe the values in as generic terms as possible
allowing each hypervisor to provide a specific algorithm to utilize
the values as it sees fit.

Signed-off-by: John Ferlan 
---
 tools/virsh-domain-monitor.c |  7 +++
 tools/virsh.pod  | 26 --
 2 files changed, 31 insertions(+), 2 deletions(-)

diff --git a/tools/virsh-domain-monitor.c b/tools/virsh-domain-monitor.c
index 3a2636377d..5187c1e248 100644
--- a/tools/virsh-domain-monitor.c
+++ b/tools/virsh-domain-monitor.c
@@ -2066,6 +2066,10 @@ static const vshCmdOptDef opts_domstats[] = {
  .type = VSH_OT_BOOL,
  .help = N_("report domain perf event statistics"),
 },
+{.name = "iothread",
+ .type = VSH_OT_BOOL,
+ .help = N_("report domain IOThread information"),
+},
 {.name = "list-active",
  .type = VSH_OT_BOOL,
  .help = N_("list only active domains"),
@@ -2179,6 +2183,9 @@ cmdDomstats(vshControl *ctl, const vshCmd *cmd)
 if (vshCommandOptBool(cmd, "perf"))
 stats |= VIR_DOMAIN_STATS_PERF;
 
+if (vshCommandOptBool(cmd, "iothread"))
+stats |= VIR_DOMAIN_STATS_IOTHREAD;
+
 if (vshCommandOptBool(cmd, "list-active"))
 flags |= VIR_CONNECT_GET_ALL_DOMAINS_STATS_ACTIVE;
 
diff --git a/tools/virsh.pod b/tools/virsh.pod
index 86c041d575..90f3c1ef5c 100644
--- a/tools/virsh.pod
+++ b/tools/virsh.pod
@@ -975,7 +975,8 @@ or unique source names printed by this command.
 
 =item B [I<--raw>] [I<--enforce>] [I<--backing>] [I<--nowait>]
 [I<--state>] [I<--cpu-total>] [I<--balloon>] [I<--vcpu>] [I<--interface>]
-[I<--block>] [I<--perf>] [[I<--list-active>] [I<--list-inactive>]
+[I<--block>] [I<--perf>] [I<--iothread>]
+[[I<--list-active>] [I<--list-inactive>]
 [I<--list-persistent>] [I<--list-transient>] [I<--list-running>]
 [I<--list-paused>] [I<--list-shutoff>] [I<--list-other>]] | [I ...]
 
@@ -993,7 +994,7 @@ behavior use the I<--raw> flag.
 The individual statistics groups are selectable via specific flags. By
 default all supported statistics groups are returned. Supported
 statistics groups flags are: I<--state>, I<--cpu-total>, I<--balloon>,
-I<--vcpu>, I<--interface>, I<--block>, I<--perf>.
+I<--vcpu>, I<--interface>, I<--block>, I<--perf>, I<--iothread>.
 
 Note that - depending on the hypervisor type and version or the domain state
 - not all of the following statistics may be returned.
@@ -1126,6 +1127,27 @@ Information listed includes:
VIR_DOMAIN_EVENT_ID_BLOCK_THRESHOLD event
See domblkthreshold.
 
+I<--iothread> returns information about IOThreads on the running guest
+if supported by the hypervisor.
+
+The "poll-max-ns" for each thread is the maximum nanoseconds to allow
+each polling interval to occur. A polling interval is a period of time
+allowed for a thread to process data before being the guest gives up
+its CPU quantum back to the host. A value set too small will not allow
+the IOThread to run long enough on a CPU to process data. A value set
+too high will consume too much CPU time per IOThread failing to allow
+other threads running on the CPU to get time. The polling interval is
+not available for statistical purposes.
+
+ "iothread..poll-max-ns" - maximum polling time in nanoseconds used
+   by the  IOThread. A value of 0 (zero)
+   indicates polling is disabled.
+ "iothread..poll-grow" - polling time grow value. A value of 0 (zero)
+ indicates growth is managed by the hypervisor.
+ "iothread..poll-shrink" - polling time shrink value. A value of
+   0 (zero) indicates shrink is managed by
+   the hypervisor.
+
 Selecting a specific statistics groups doesn't guarantee that the
 daemon supports the selected group of stats. Flag I<--enforce>
 forces the command to fail if the daemon doesn't support the
-- 
2.17.1

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


[libvirt] [PATCH 05/11] lib: Introduce virDomainSetIOThreadParams

2018-10-07 Thread John Ferlan
Create a new API that will allow an adjustment of IOThread
polling parameters for the specified IOThread. These parameters
will not be saved in the guest XML. Currently the only parameters
supported will allow the hypervisor to adjust the parameters used
to limit and alter the scope of the polling interval. The polling
interval allows the IOThread to spend more or less time processing
in the guest.

Based on code originally posted by Pavel Hrdina 
to add virDomainAddIOThreadParams and virDomainModIOThreadParams.
Modification of those changes to use virDomainSetIOThreadParams
instead and remove concepts related to saving the data in guest
XML as well as the way to specifically enable the polling parameters.

Signed-off-by: John Ferlan 
---
 include/libvirt/libvirt-domain.h | 44 
 src/driver-hypervisor.h  |  8 
 src/libvirt-domain.c | 71 
 src/libvirt_public.syms  |  5 +++
 src/remote/remote_driver.c   |  1 +
 src/remote/remote_protocol.x | 21 +-
 src/remote_protocol-structs  | 10 +
 7 files changed, 159 insertions(+), 1 deletion(-)

diff --git a/include/libvirt/libvirt-domain.h b/include/libvirt/libvirt-domain.h
index 58fd4bc10c..bf89d0149f 100644
--- a/include/libvirt/libvirt-domain.h
+++ b/include/libvirt/libvirt-domain.h
@@ -1911,6 +1911,50 @@ int  virDomainDelIOThread(virDomainPtr 
domain,
   unsigned int iothread_id,
   unsigned int flags);
 
+/* IOThread set parameters */
+
+/**
+ * VIR_DOMAIN_IOTHREAD_POLL_MAX_NS:
+ *
+ * The maximum polling time that can be used by polling algorithm in ns.
+ * The polling time starts at 0 (zero) and is the time spent by the guest
+ * to process IOThread data before returning the CPU to the host. The
+ * polling time will be dynamically modified over time based on the
+ * poll_grow and poll_shrink parameters provided. A value set too large
+ * will cause more CPU time to be allocated the guest. A value set too
+ * small will not provide enough cycles for the guest to process data.
+ * The polling interval is not available for statistical purposes.
+ */
+# define VIR_DOMAIN_IOTHREAD_POLL_MAX_NS "poll_max_ns"
+
+/**
+ * VIR_DOMAIN_IOTHREAD_POLL_GROW:
+ *
+ * This provides a value for the dynamic polling adjustment algorithm to
+ * use to grow its polling interval up to the poll_max_ns value. A value
+ * of 0 (zero) allows the hypervisor to choose its own value. The algorithm
+ * to use for adjustment is hypervisor specific.
+ */
+# define VIR_DOMAIN_IOTHREAD_POLL_GROW "poll_grow"
+
+/**
+ * VIR_DOMAIN_IOTHREAD_POLL_SHRINK:
+ *
+ * This provides a value for the dynamic polling adjustment algorithm to
+ * use to shrink its polling interval when the polling interval exceeds
+ * the poll_max_ns value. A value of 0 (zero) allows the hypervisor to
+ * choose its own value. The algorithm to use for adjustment is hypervisor
+ * specific.
+ */
+# define VIR_DOMAIN_IOTHREAD_POLL_SHRINK "poll_shrink"
+
+int  virDomainSetIOThreadParams(virDomainPtr domain,
+unsigned int iothread_id,
+virTypedParameterPtr params,
+int nparams,
+unsigned int flags);
+
+
 /**
  * VIR_USE_CPU:
  * @cpumap: pointer to a bit map of real CPUs (in 8-bit bytes) (IN/OUT)
diff --git a/src/driver-hypervisor.h b/src/driver-hypervisor.h
index eef31eb1f0..6be3e175ce 100644
--- a/src/driver-hypervisor.h
+++ b/src/driver-hypervisor.h
@@ -406,6 +406,13 @@ typedef int
unsigned int iothread_id,
unsigned int flags);
 
+typedef int
+(*virDrvDomainSetIOThreadParams)(virDomainPtr domain,
+ unsigned int iothread_id,
+ virTypedParameterPtr params,
+ int nparams,
+ unsigned int flags);
+
 typedef int
 (*virDrvDomainGetSecurityLabel)(virDomainPtr domain,
 virSecurityLabelPtr seclabel);
@@ -1407,6 +1414,7 @@ struct _virHypervisorDriver {
 virDrvDomainPinIOThread domainPinIOThread;
 virDrvDomainAddIOThread domainAddIOThread;
 virDrvDomainDelIOThread domainDelIOThread;
+virDrvDomainSetIOThreadParams domainSetIOThreadParams;
 virDrvDomainGetSecurityLabel domainGetSecurityLabel;
 virDrvDomainGetSecurityLabelList domainGetSecurityLabelList;
 virDrvNodeGetSecurityModel nodeGetSecurityModel;
diff --git a/src/libvirt-domain.c b/src/libvirt-domain.c
index 9fda56d660..ce5de4b208 100644
--- a/src/libvirt-domain.c
+++ b/src/libvirt-domain.c
@@ -7812,6 +7812,77 @@ virDomainDelIOThread(virDomainPtr domain,
 }
 
 
+/**
+ * virDomainSetIOThreadParams:
+ * @domain: a domain object
+ * @iothread_id: 

[libvirt] [PATCH 02/11] qemu: Split qemuDomainGetIOThreadsLive

2018-10-07 Thread John Ferlan
Separate out the fetch of the IOThread monitor call into a separate
helper so that a subsequent domain statistics change can fetch the raw
IOThread data and parse it as it sees fit.

Signed-off-by: John Ferlan 
---
 src/qemu/qemu_driver.c | 59 --
 1 file changed, 34 insertions(+), 25 deletions(-)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index ef87a6ef05..e0edb43557 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -5486,20 +5486,18 @@ qemuDomainGetMaxVcpus(virDomainPtr dom)
  VIR_DOMAIN_VCPU_MAXIMUM));
 }
 
+
 static int
-qemuDomainGetIOThreadsLive(virQEMUDriverPtr driver,
-   virDomainObjPtr vm,
-   virDomainIOThreadInfoPtr **info)
+qemuDomainGetIOThreadsMon(virQEMUDriverPtr driver,
+  virDomainObjPtr vm,
+  qemuMonitorIOThreadInfoPtr **iothreads)
 {
 qemuDomainObjPrivatePtr priv;
-qemuMonitorIOThreadInfoPtr *iothreads = NULL;
-virDomainIOThreadInfoPtr *info_ret = NULL;
 int niothreads = 0;
-size_t i;
 int ret = -1;
 
 if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_QUERY) < 0)
-goto cleanup;
+return -1;
 
 if (!virDomainObjIsActive(vm)) {
 virReportError(VIR_ERR_OPERATION_INVALID, "%s",
@@ -5515,46 +5513,57 @@ qemuDomainGetIOThreadsLive(virQEMUDriverPtr driver,
 }
 
 qemuDomainObjEnterMonitor(driver, vm);
-niothreads = qemuMonitorGetIOThreads(priv->mon, );
-if (qemuDomainObjExitMonitor(driver, vm) < 0)
-goto endjob;
-if (niothreads < 0)
+niothreads = qemuMonitorGetIOThreads(priv->mon, iothreads);
+if (qemuDomainObjExitMonitor(driver, vm) < 0 || niothreads < 0)
 goto endjob;
 
-/* Nothing to do */
-if (niothreads == 0) {
-ret = 0;
-goto endjob;
-}
+ret = niothreads;
+
+ endjob:
+qemuDomainObjEndJob(driver, vm);
+
+return ret;
+}
+
+
+static int
+qemuDomainGetIOThreadsLive(virQEMUDriverPtr driver,
+   virDomainObjPtr vm,
+   virDomainIOThreadInfoPtr **info)
+{
+qemuMonitorIOThreadInfoPtr *iothreads = NULL;
+virDomainIOThreadInfoPtr *info_ret = NULL;
+int niothreads;
+size_t i;
+int ret = -1;
+
+if ((niothreads = qemuDomainGetIOThreadsMon(driver, vm, )) <= 0)
+return niothreads;
 
 if (VIR_ALLOC_N(info_ret, niothreads) < 0)
-goto endjob;
+goto cleanup;
 
 for (i = 0; i < niothreads; i++) {
 virBitmapPtr map = NULL;
 
 if (VIR_ALLOC(info_ret[i]) < 0)
-goto endjob;
+goto cleanup;
 info_ret[i]->iothread_id = iothreads[i]->iothread_id;
 
 if (!(map = virProcessGetAffinity(iothreads[i]->thread_id)))
-goto endjob;
+goto cleanup;
 
 if (virBitmapToData(map, _ret[i]->cpumap,
 _ret[i]->cpumaplen) < 0) {
 virBitmapFree(map);
-goto endjob;
+goto cleanup;
 }
 virBitmapFree(map);
 }
 
-*info = info_ret;
-info_ret = NULL;
+VIR_STEAL_PTR(*info, info_ret);
 ret = niothreads;
 
- endjob:
-qemuDomainObjEndJob(driver, vm);
-
  cleanup:
 if (info_ret) {
 for (i = 0; i < niothreads; i++)
-- 
2.17.1

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


[libvirt] [PATCH 01/11] qemu: Check for and return IOThread polling values if available

2018-10-07 Thread John Ferlan
If there are IOThread polling values in the query-iothreads return
buffer, then fill them in and set a bool indicating their presence.
This will allow for displaying in a domain stats output eventually.

Note that the QEMU values are managed a bit differently (as int's
stored in int64_t's) than we will manage them (as unsigned long and
int values). This is intentional to allow for value validation
checking when it comes time to provide the values to QEMU.

Signed-off-by: John Ferlan 
---
 src/qemu/qemu_monitor.h  |  4 
 src/qemu/qemu_monitor_json.c | 15 +++
 2 files changed, 19 insertions(+)

diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h
index 48b142a4f4..c2991e2b16 100644
--- a/src/qemu/qemu_monitor.h
+++ b/src/qemu/qemu_monitor.h
@@ -1116,6 +1116,10 @@ typedef qemuMonitorIOThreadInfo 
*qemuMonitorIOThreadInfoPtr;
 struct _qemuMonitorIOThreadInfo {
 unsigned int iothread_id;
 int thread_id;
+bool poll_valid;
+unsigned long long poll_max_ns;
+unsigned int poll_grow;
+unsigned int poll_shrink;
 };
 int qemuMonitorGetIOThreads(qemuMonitorPtr mon,
 qemuMonitorIOThreadInfoPtr **iothreads);
diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
index 3de298c9e2..2e92984b44 100644
--- a/src/qemu/qemu_monitor_json.c
+++ b/src/qemu/qemu_monitor_json.c
@@ -7441,6 +7441,21 @@ qemuMonitorJSONGetIOThreads(qemuMonitorPtr mon,
  "'thread-id' data"));
 goto cleanup;
 }
+
+/* Fetch poll values (since QEMU 2.9 ) if available. QEMU
+ * stores these values as int64_t's; however, the qapi type
+ * is an int. The qapi/misc.json also mis-describes the grow
+ * and shrink values as pure add/remove values. The source
+ * util/aio-posix.c function aio_poll uses them as a factor
+ * or divisor in it's calculation. We will fetch and store
+ * them as defined in our structures. */
+if (virJSONValueObjectGetNumberUlong(child, "poll-max-ns",
+ >poll_max_ns) == 0 &&
+virJSONValueObjectGetNumberUint(child, "poll-grow",
+>poll_grow) == 0 &&
+virJSONValueObjectGetNumberUint(child, "poll-shrink",
+>poll_shrink) == 0)
+info->poll_valid = true;
 }
 
 ret = n;
-- 
2.17.1

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


[libvirt] [PATCH 07/11] qemu: Alter qemuDomainChgIOThread to take enum instead of bool

2018-10-07 Thread John Ferlan
We're about to add a new state "modify" and thus the function
goes from just Add/Del. Use an enum to manage.

Extracted from code originally posted by Pavel Hrdina
, but placed into a separate patch.

Signed-off-by: John Ferlan 
---
 src/qemu/qemu_driver.c | 32 +---
 1 file changed, 25 insertions(+), 7 deletions(-)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index ff87865fe6..ff466df4b7 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -6015,11 +6015,16 @@ qemuDomainDelIOThreadCheck(virDomainDefPtr def,
 return 0;
 }
 
+typedef enum {
+VIR_DOMAIN_IOTHREAD_ACTION_ADD,
+VIR_DOMAIN_IOTHREAD_ACTION_DEL,
+} virDomainIOThreadAction;
+
 static int
 qemuDomainChgIOThread(virQEMUDriverPtr driver,
   virDomainObjPtr vm,
   unsigned int iothread_id,
-  bool add,
+  virDomainIOThreadAction action,
   unsigned int flags)
 {
 virQEMUDriverConfigPtr cfg = NULL;
@@ -6045,18 +6050,24 @@ qemuDomainChgIOThread(virQEMUDriverPtr driver,
 goto endjob;
 }
 
-if (add) {
+switch (action) {
+case VIR_DOMAIN_IOTHREAD_ACTION_ADD:
 if (qemuDomainAddIOThreadCheck(def, iothread_id) < 0)
 goto endjob;
 
 if (qemuDomainHotplugAddIOThread(driver, vm, iothread_id) < 0)
 goto endjob;
-} else {
+
+break;
+
+case VIR_DOMAIN_IOTHREAD_ACTION_DEL:
 if (qemuDomainDelIOThreadCheck(def, iothread_id) < 0)
 goto endjob;
 
 if (qemuDomainHotplugDelIOThread(driver, vm, iothread_id) < 0)
 goto endjob;
+
+break;
 }
 
 if (virDomainSaveStatus(driver->xmlopt, cfg->stateDir, vm, 
driver->caps) < 0)
@@ -6064,18 +6075,23 @@ qemuDomainChgIOThread(virQEMUDriverPtr driver,
 }
 
 if (persistentDef) {
-if (add) {
+switch (action) {
+case VIR_DOMAIN_IOTHREAD_ACTION_ADD:
 if (qemuDomainAddIOThreadCheck(persistentDef, iothread_id) < 0)
 goto endjob;
 
 if (!virDomainIOThreadIDAdd(persistentDef, iothread_id))
 goto endjob;
 
-} else {
+break;
+
+case VIR_DOMAIN_IOTHREAD_ACTION_DEL:
 if (qemuDomainDelIOThreadCheck(persistentDef, iothread_id) < 0)
 goto endjob;
 
 virDomainIOThreadIDDel(persistentDef, iothread_id);
+
+break;
 }
 
 if (virDomainSaveConfig(cfg->configDir, driver->caps,
@@ -6117,7 +6133,8 @@ qemuDomainAddIOThread(virDomainPtr dom,
 if (virDomainAddIOThreadEnsureACL(dom->conn, vm->def, flags) < 0)
 goto cleanup;
 
-ret = qemuDomainChgIOThread(driver, vm, iothread_id, true, flags);
+ret = qemuDomainChgIOThread(driver, vm, iothread_id,
+VIR_DOMAIN_IOTHREAD_ACTION_ADD, flags);
 
  cleanup:
 virDomainObjEndAPI();
@@ -6149,7 +6166,8 @@ qemuDomainDelIOThread(virDomainPtr dom,
 if (virDomainDelIOThreadEnsureACL(dom->conn, vm->def, flags) < 0)
goto cleanup;
 
-ret = qemuDomainChgIOThread(driver, vm, iothread_id, false, flags);
+ret = qemuDomainChgIOThread(driver, vm, iothread_id,
+VIR_DOMAIN_IOTHREAD_ACTION_DEL, flags);
 
  cleanup:
 virDomainObjEndAPI();
-- 
2.17.1

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


[libvirt] [PATCH 06/11] qemu: Add monitor functions to set IOThread params

2018-10-07 Thread John Ferlan
Add functions to set the IOThreadInfo param data for the live guest.

Based on code originally posted by Pavel Hrdina ,
but extracted into a separate patch. Note that qapi expects to receive
integer parameters rather than unsigned long long or unsigned int's.
QEMU does save the value in larger signed 64 bit values eventually.

Signed-off-by: John Ferlan 
---
 src/qemu/qemu_monitor.c  | 19 +++
 src/qemu/qemu_monitor.h  |  2 ++
 src/qemu/qemu_monitor_json.c | 33 +
 src/qemu/qemu_monitor_json.h |  4 
 4 files changed, 58 insertions(+)

diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c
index 7f7013e115..a65d638ab8 100644
--- a/src/qemu/qemu_monitor.c
+++ b/src/qemu/qemu_monitor.c
@@ -4135,6 +4135,25 @@ qemuMonitorGetIOThreads(qemuMonitorPtr mon,
 }
 
 
+/**
+ * qemuMonitorSetIOThread:
+ * @mon: Pointer to the monitor
+ * @iothreadInfo: filled IOThread info with data
+ *
+ * Alter the specified IOThread's IOThreadInfo values.
+ */
+int
+qemuMonitorSetIOThread(qemuMonitorPtr mon,
+   qemuMonitorIOThreadInfoPtr iothreadInfo)
+{
+VIR_DEBUG("iothread=%p", iothreadInfo);
+
+QEMU_CHECK_MONITOR(mon);
+
+return qemuMonitorJSONSetIOThread(mon, iothreadInfo);
+}
+
+
 /**
  * qemuMonitorGetMemoryDeviceInfo:
  * @mon: pointer to the monitor
diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h
index c2991e2b16..ef71fc6448 100644
--- a/src/qemu/qemu_monitor.h
+++ b/src/qemu/qemu_monitor.h
@@ -1123,6 +1123,8 @@ struct _qemuMonitorIOThreadInfo {
 };
 int qemuMonitorGetIOThreads(qemuMonitorPtr mon,
 qemuMonitorIOThreadInfoPtr **iothreads);
+int qemuMonitorSetIOThread(qemuMonitorPtr mon,
+   qemuMonitorIOThreadInfoPtr iothreadInfo);
 
 typedef struct _qemuMonitorMemoryDeviceInfo qemuMonitorMemoryDeviceInfo;
 typedef qemuMonitorMemoryDeviceInfo *qemuMonitorMemoryDeviceInfoPtr;
diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
index 2e92984b44..bb1d62b844 100644
--- a/src/qemu/qemu_monitor_json.c
+++ b/src/qemu/qemu_monitor_json.c
@@ -7474,6 +7474,39 @@ qemuMonitorJSONGetIOThreads(qemuMonitorPtr mon,
 }
 
 
+int
+qemuMonitorJSONSetIOThread(qemuMonitorPtr mon,
+   qemuMonitorIOThreadInfoPtr iothreadInfo)
+{
+int ret = -1;
+char *path = NULL;
+qemuMonitorJSONObjectProperty prop;
+
+if (virAsprintf(, "/objects/iothread%u",
+iothreadInfo->iothread_id) < 0)
+goto cleanup;
+
+#define VIR_IOTHREAD_SET_PROP(propName, propVal) \
+memset(, 0, sizeof(qemuMonitorJSONObjectProperty)); \
+prop.type = QEMU_MONITOR_OBJECT_PROPERTY_INT; \
+prop.val.iv = propVal; \
+if (qemuMonitorJSONSetObjectProperty(mon, path, propName, ) < 0) \
+goto cleanup;
+
+VIR_IOTHREAD_SET_PROP("poll-max-ns", iothreadInfo->poll_max_ns)
+VIR_IOTHREAD_SET_PROP("poll-grow", iothreadInfo->poll_grow)
+VIR_IOTHREAD_SET_PROP("poll-shrink", iothreadInfo->poll_shrink)
+
+#undef VIR_IOTHREAD_SET_PROP
+
+ret = 0;
+
+ cleanup:
+VIR_FREE(path);
+return ret;
+}
+
+
 int
 qemuMonitorJSONGetMemoryDeviceInfo(qemuMonitorPtr mon,
virHashTablePtr info)
diff --git a/src/qemu/qemu_monitor_json.h b/src/qemu/qemu_monitor_json.h
index da267b15b0..c3abd0ddf0 100644
--- a/src/qemu/qemu_monitor_json.h
+++ b/src/qemu/qemu_monitor_json.h
@@ -502,6 +502,10 @@ int qemuMonitorJSONGetIOThreads(qemuMonitorPtr mon,
 qemuMonitorIOThreadInfoPtr **iothreads)
 ATTRIBUTE_NONNULL(2);
 
+int qemuMonitorJSONSetIOThread(qemuMonitorPtr mon,
+   qemuMonitorIOThreadInfoPtr iothreadInfo)
+ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
+
 int qemuMonitorJSONGetMemoryDeviceInfo(qemuMonitorPtr mon,
virHashTablePtr info)
 ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
-- 
2.17.1

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


[libvirt] [PATCH 03/11] qemu: Implement the ability to return IOThread stats

2018-10-07 Thread John Ferlan
Process the IOThreads polling stats if available. Generate the
output params record to be returned to the caller with the three
values - poll-max-ns, poll-grow, and poll-shrink.

Signed-off-by: John Ferlan 
---
 include/libvirt/libvirt-domain.h |  1 +
 src/libvirt-domain.c | 38 
 src/qemu/qemu_driver.c   | 78 
 3 files changed, 117 insertions(+)

diff --git a/include/libvirt/libvirt-domain.h b/include/libvirt/libvirt-domain.h
index fdd2d6b8ea..58fd4bc10c 100644
--- a/include/libvirt/libvirt-domain.h
+++ b/include/libvirt/libvirt-domain.h
@@ -2048,6 +2048,7 @@ typedef enum {
 VIR_DOMAIN_STATS_INTERFACE = (1 << 4), /* return domain interfaces info */
 VIR_DOMAIN_STATS_BLOCK = (1 << 5), /* return domain block info */
 VIR_DOMAIN_STATS_PERF = (1 << 6), /* return domain perf event info */
+VIR_DOMAIN_STATS_IOTHREAD = (1 << 7), /* return iothread poll info */
 } virDomainStatsTypes;
 
 typedef enum {
diff --git a/src/libvirt-domain.c b/src/libvirt-domain.c
index 7690339521..9fda56d660 100644
--- a/src/libvirt-domain.c
+++ b/src/libvirt-domain.c
@@ -11499,6 +11499,44 @@ virConnectGetDomainCapabilities(virConnectPtr conn,
  *   long long. It is produced by the
  *   emulation_faults perf event
  *
+ * VIR_DOMAIN_STATS_IOTHREAD:
+ * Return IOThread statistics if available. IOThread polling is a
+ * timing mechanism that allows the hypervisor to generate a longer
+ * period of time in which the guest will perform operations on the
+ * CPU being used by the IOThread. The higher the value for poll-max-ns
+ * the longer the guest will keep the CPU. This may affect other host
+ * threads using the CPU. The poll-grow and poll-shrink values allow
+ * the hypervisor to generate a mechanism to add or remove polling time
+ * within the confines of 0 and poll-max-ns. For QEMU, the poll-grow is
+ * multiplied by the polling interval, while poll-shrink is used as a
+ * divisor. When not provided, QEMU may double the polling time until
+ * poll-max-ns is reached. When poll-shrink is 0 (zero) QEMU may reset
+ * the polling interval to 0 until it finds its "sweet spot". Setting
+ * poll-grow too large may cause frequent fluctution of the time; however,
+ * this can be tempered by a high poll-shrink to reduce the polling
+ * interval. For example, a poll-grow of 3 will triple the polling time
+ * which could quickly exceed poll-max-ns; however, a poll-shrink of
+ * 10 would cut that polling time more gradually.
+ *
+ * The typed parameter keys are in this format:
+ *
+ * "iothread.cnt" - maximum number of IOThreads in the subsequent list
+ *  as unsigned int. Each IOThread in the list will
+ *  will use it's iothread_id value as the . There
+ *  may be fewer  entries than the iothread.cnt
+ *  value if the polling values are not supported.
+ * "iothread..poll-max-ns" - maximum polling time in ns as an unsigned
+ *   long long. A 0 (zero) means polling is
+ *   disabled.
+ * "iothread..poll-grow" - polling time factor as an unsigned int.
+ * A 0 (zero) indicates to allow the underlying
+ * hypervisor to choose how to grow the
+ * polling time.
+ * "iothread..poll-shrink" - polling time divisor as an unsigned int.
+ * A 0 (zero) indicates to allow the underlying
+ * hypervisor to choose how to shrink the
+ * polling time.
+ *
  * Note that entire stats groups or individual stat fields may be missing from
  * the output in case they are not supported by the given hypervisor, are not
  * applicable for the current state of the guest domain, or their retrieval
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index e0edb43557..ff87865fe6 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -20431,6 +20431,83 @@ qemuDomainGetStatsBlock(virQEMUDriverPtr driver,
 
 #undef QEMU_ADD_NAME_PARAM
 
+#define QEMU_ADD_IOTHREAD_PARAM_UI(record, maxparams, id, name, value) \
+do { \
+char param_name[VIR_TYPED_PARAM_FIELD_LENGTH]; \
+snprintf(param_name, VIR_TYPED_PARAM_FIELD_LENGTH, \
+ "block.%u.%s", id, name); \
+if (virTypedParamsAddUInt(&(record)->params, \
+  &(record)->nparams, \
+  maxparams, \
+  param_name, \
+  value) < 0) \
+goto cleanup; \
+} while (0)
+
+#define QEMU_ADD_IOTHREAD_PARAM_ULL(record, maxparams, id, name, value) \
+do { \
+char 

[libvirt] [PATCH 00/11] Allow modification of IOThread polling values (redux)

2018-10-07 Thread John Ferlan
This series attempts to resurrect the concept of being able to modify
the IOThread polling parameters; however, in a slightly different
manner than the previous series posted by posted by Pavel Hrdina
:

  https://www.redhat.com/archives/libvir-list/2017-February/msg01047.html

The work is prompted by continued pleas found in the bz:

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

to provide some way to modify the paremters without needing to supply
QEMU command line pass through values.

It's accepted that the values being changed are fairly or extremely
low level type knobs; however, it's also shown that by being able to
turn the knob it is possible for certain, specific appliances to be
able to gain a performance benefit for the thread at the expense of
other competing threads.

Unlike the previous series, this series does not attempt to save the
polling values in the guest XML. Rather, it only modifies the live
guest's IOThread with new values. It also doesn't provide the polling
values in a virsh iothread* command, rather it uses the domstats
in order to fetch and display the values. The theory being this
leaves the onus on the higher level appliance/application to provide
the "proper guidance" and "concerns" related to changing the values
to the consumer. Not saving the values means whatever values that
are chosen do not "live" in perpetuity. Once the guest is shut down
or the IOThread removed from guest, the hypervisor default values
take over again. Perhaps not a perfect situation in terms of what
the bz requests; however, storage of default values that could
cause performance issues is not an optimal situation. So this I
figured is a "comprimise" of sorts.

If it's still felt that no we don't want to do this, then fine,
but please in doing so own the bz, state your case, and close it.
I'm 50/50 on it, but figured at least I'd present this option and
see what the concensus was.

John Ferlan (11):
  qemu: Check for and return IOThread polling values if available
  qemu: Split qemuDomainGetIOThreadsLive
  qemu: Implement the ability to return IOThread stats
  virsh: Add ability to display IOThread stats
  lib: Introduce virDomainSetIOThreadParams
  qemu: Add monitor functions to set IOThread params
  qemu: Alter qemuDomainChgIOThread to take enum instead of bool
  qemu: Alter qemuDomainChgIOThread to take qemuMonitorIOThreadInfo
  qemu: Detect whether iothread polling is supported
  qemu: Introduce qemuDomainSetIOThreadParams
  tools: Add virsh iothreadset command

 include/libvirt/libvirt-domain.h  |  45 ++
 src/driver-hypervisor.h   |   8 +
 src/libvirt-domain.c  | 109 +
 src/libvirt_public.syms   |   5 +
 src/qemu/qemu_capabilities.c  |   2 +
 src/qemu/qemu_capabilities.h  |   1 +
 src/qemu/qemu_driver.c| 393 --
 src/qemu/qemu_monitor.c   |  19 +
 src/qemu/qemu_monitor.h   |   6 +
 src/qemu/qemu_monitor_json.c  |  48 +++
 src/qemu/qemu_monitor_json.h  |   4 +
 src/remote/remote_driver.c|   1 +
 src/remote/remote_protocol.x  |  21 +-
 src/remote_protocol-structs   |  10 +
 .../caps_2.10.0.aarch64.xml   |   1 +
 .../caps_2.10.0.ppc64.xml |   1 +
 .../caps_2.10.0.s390x.xml |   1 +
 .../caps_2.10.0.x86_64.xml|   1 +
 .../caps_2.11.0.s390x.xml |   1 +
 .../caps_2.11.0.x86_64.xml|   1 +
 .../caps_2.12.0.aarch64.xml   |   1 +
 .../caps_2.12.0.ppc64.xml |   1 +
 .../caps_2.12.0.s390x.xml |   1 +
 .../caps_2.12.0.x86_64.xml|   1 +
 .../qemucapabilitiesdata/caps_2.9.0.ppc64.xml |   1 +
 .../qemucapabilitiesdata/caps_2.9.0.s390x.xml |   1 +
 .../caps_2.9.0.x86_64.xml |   1 +
 .../qemucapabilitiesdata/caps_3.0.0.ppc64.xml |   1 +
 .../caps_3.0.0.riscv32.xml|   1 +
 .../caps_3.0.0.riscv64.xml|   1 +
 .../qemucapabilitiesdata/caps_3.0.0.s390x.xml |   1 +
 .../caps_3.0.0.x86_64.xml |   1 +
 tools/virsh-domain-monitor.c  |   7 +
 tools/virsh-domain.c  | 110 +
 tools/virsh.pod   |  47 ++-
 35 files changed, 810 insertions(+), 44 deletions(-)

-- 
2.17.1

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