Re: [libvirt] [PATCH 2/2] HACK: qemu: aarch64: Use virtio-pci if user specifies PCI controller
On 02/26/2016 10:13 AM, Andrea Bolognani wrote: On Wed, 2016-02-17 at 15:03 -0500, Laine Stump wrote: On 01/28/2016 04:14 PM, Cole Robinson wrote: If a user manually specifies this XML snippet for aarch64 machvirt: As you've noted below, this isn't correct. aarch64 machvirt has no implicit pci-root controller (aka "pci.0"). It instead has a pcie-root controller ("pcie.0"). Since a pci[e]-root controller cannot be explicitly added, by definition this couldn't work. Libvirt will interpret this to mean that the OS supports virtio-pci, and will allocate PCI addresses (instead of virtio-mmio) for virtio devices. This is a giant hack. Trying to improve it led me into the maze of PCI address code and I gave up for now. Here are the issues: * I'd prefer that to be model='pcie-root' which matches what qemu-system-aarch64 -M virt actually provides by default... however libvirt isn't happy with a single pcie-root specified by the user, it will error with: error: unsupported configuration: failed to create PCI bridge on bus 1: too many devices with fixed addresses That's not the right error, but it's caused by the fact that libvirt wants the pci-bridge device to be plugged into a standard PCI slot, but all the slots of pcie-root are PCIe slots. Since we now know that qemu doesn't mind if any standard PCI device is plugged into a PCIe slot, Should we rely on this behavior? Isn't this something that might change in the future? Or at least be quite puzzling for users? Just thinking out loud :) It was my identical thinking that led to libvirt being initially very strict about plugging PCI into PCI and PCIe into PCIe. I've since received reasonable assurances that qemu will continue to be permissive about plugging PCI things into PCIe, so I allow it, but still default to "purity". the decision of how we want to solve this problem depends on whether or not we want the devices in question to be hot-pluggable - the ports of pcie-root do not support hot-plugging devices (at least on Q35), while the ports on pci-bridge do. So if we require that all devices be hot-pluggable, then we have a few choices: 1) create the same PCI controller Frankenstein we currently have for Q35 - a dmi-to-pci-bridge plugged into pcie-root, and a pci-bridge plugged into dmi-to-pci-bridge. This is easiest because it already works, but it does create an extra unnecessary controller. This is the current situation, right? qemu-kvm in current aarch64 RHEL doesn't have the i82801b11-bridge device compiled in, by the way. However, since qemu-system-aarch64 in Fedora 23 *does* have it, I assume enabling it would simply be a matter of flipping a build configuration bit. 2) auto-add a pci-bridge in cases when there is a pcie-root but not standard PCI slots. This would take only a slight amount more work. 3) auto-add a pcie-root-port to each port of the pcie-root controller. This would still leave us with PCIe ports, so we would need to teach libvirt that it's okay to plug PCI devices into PCIe ports. As mentioned above, I'm not sure this is a good idea. Maybe I'm just afraid of my own shadow though :) If we don't require hot-pluggability, then we can just teach the address-assignment code that PCI devices can plug into non-hotpluggable PCIe ports and we're done. Or we can do a hybrid that's kind of a continuation of the "use PCI if it's available, otherwise mmio" - we could do this: A) If there are any standard PCI slots, then auto-assign to PCI slots (creating new pci-bridge controllers s necessary) B) else if there are any PCIe slots, then auto-assign to hot-pluggable PCIe if available, or straight PCIe if not. C) else use virtio-mmio. --- Mixed in with all of this discussion is my thinking that we should have some way to specify, in XML, constraints for the address of each device *without specifying the address itself*. Things we need to be able to specify: 1) Is a PCI-only vs. PCIe-only vs. either one (maybe this could be used in the future to constrain to virtio-mmio as well)? 2) Must the device be hot-pluggable? (default would be yes) 3) guest-side NUMA node? (I'm not sure if this needs to be user specifiable - in the case of a vfio-assigned device, I think all we need to to inform the guest which NUMA node the device is on in the host (via putting it on a PXB controller that is configured with that same NUMA node number). For emulated devices - is there any use to putting an *emulated* device on the same controller as a particular vfio-assigned device that is on a specific node? If not, then maybe it will never matter). It would be better if these "address constraints" were in a different part of the XML than the element itself - this would maintain the simplicity of being able to just remove all elements in order to force libvirt to re-assign all device addresses. This isn't something that needs doing
Re: [libvirt] [PATCH v3 00/14] Implement post-copy migration
On Wed, Mar 02, 2016 at 12:42:21 +0100, Jiri Denemark wrote: > (See "Add public APIs for post-copy migration" patch for more details > about post-copy migration.) > > Post-copy support was originally written by Cristian Klein in 2014, but > no one touched the series since then. Some patches in this series are > modified versions of the old patches from Cristian, some patches had to > be rewritten from scratch since libvirt code changed a lot (we started > using migration events), and some patches are completely new. > > While post-copy migration is included in QEMU 2.5.0, it didn't support > everything libvirt needs. Thus you need QEMU from git to use post-copy. > Luckily, the QEMU migration capability we need to enable to use > post-copy is still prefixed with "x-", which means it's still considered > experimental. We are pretty sure the interface QEMU provides is OK, but > we'd like to wait until seamless SPICE migration is fixed for post-copy > before removing the experimental prefix. This should hopefully happen in > time for QEMU 2.6.0. The SPICE issue has already been fixed in QEMU. Dave Gilbert will send a patch for removing the "x-" prefix and once it is pushed we can update this code and push it to libvirt (as long as this series gets positive review, of course). Jirka -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] Usability Enhancement: Import/Export VMs GUI
The single most important usability feature missed by our less technical users who migrate from VirtualBox is a one click import/export of VMs and their config settings. I was optimistic about the Gnome Boxes effort on Govf lib but unfortunately it was never realized and I would hesitate to recommend it because libvirt/virt-manager has the security advantages of sVirt. An ideal solution would work across all KVM frontends. -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 0/3] vz: disk format support
Please ignore these patches. I'll send a new version soon. On 01.03.2016 13:46, Mikhail Feoktistov wrote: Mikhail Feoktistov (3): vz: add vzInitVersion function vz: add virStorageFileFormat to connection structure vz: check supported disk format src/vz/vz_driver.c | 52 +++--- src/vz/vz_sdk.c| 28 --- src/vz/vz_sdk.h| 2 +- src/vz/vz_utils.c | 66 ++ src/vz/vz_utils.h | 10 + 5 files changed, 105 insertions(+), 53 deletions(-) -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH] locking: Use bit shift for flag values not constant values.
So far it hasn't bitten us, but if the next value wasn't 4, then the logic used to check flag bits would have issues. Signed-off-by: John Ferlan--- Noted this while reviewing danpb's virtlogd as chardev series. src/locking/lock_driver_lockd.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/locking/lock_driver_lockd.h b/src/locking/lock_driver_lockd.h index baf346a..6931fe7 100644 --- a/src/locking/lock_driver_lockd.h +++ b/src/locking/lock_driver_lockd.h @@ -23,8 +23,8 @@ # define __VIR_LOCK_DRIVER_LOCKD_H__ enum virLockSpaceProtocolAcquireResourceFlags { -VIR_LOCK_SPACE_PROTOCOL_ACQUIRE_RESOURCE_SHARED = 1, -VIR_LOCK_SPACE_PROTOCOL_ACQUIRE_RESOURCE_AUTOCREATE = 2, +VIR_LOCK_SPACE_PROTOCOL_ACQUIRE_RESOURCE_SHARED = (1 << 0), +VIR_LOCK_SPACE_PROTOCOL_ACQUIRE_RESOURCE_AUTOCREATE = (1 << 1), }; #endif /* __VIR_LOCK_DRIVER_LOCKD_H__ */ -- 2.5.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH v2 6/8] logging: support truncation of logfiles when opening
On 02/29/2016 08:33 AM, Daniel P. Berrange wrote: > The virtlogd daemon currently opens all files for append, but > in some cases the user may wish to discard existing data. Define > a new flag to indicate that logfiles should be truncated when > opening. > --- > src/logging/log_daemon_dispatch.c | 3 ++- > src/logging/log_handler.c | 6 ++ > src/logging/log_handler.h | 2 +- > src/logging/log_manager.h | 2 ++ > src/logging/log_protocol.x| 4 > 5 files changed, 11 insertions(+), 6 deletions(-) > [...] > diff --git a/src/logging/log_protocol.x b/src/logging/log_protocol.x > index b0ac31b..0363c75 100644 > --- a/src/logging/log_protocol.x > +++ b/src/logging/log_protocol.x > @@ -30,6 +30,10 @@ struct virLogManagerProtocolLogFilePosition { > }; > typedef struct virLogManagerProtocolLogFilePosition > virLogManagerProtocolLogFilePosition; > > +enum virLogManagerProtocolDomainOpenLogFileFlags { > +VIR_LOG_MANAGER_PROTOCOL_DOMAIN_OPEN_LOG_FILE_TRUNCATE = 1 > +}; > + Use "= (1 << 0)" (just to be painfully obvious for the next adjustment) Since the trunc setting is "flags & VIR_LOG_*_TRUNCATE" On an unrelated note (while looking at other possible uses of similar constructs - virLockSpaceProtocolAcquireResourceFlags so far is OK, but if the "next" value isn't 4 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH v2 4/8] qemu: don't append -chardev arg until after value is formatted
On 02/29/2016 08:33 AM, Daniel P. Berrange wrote: > The act of formatting a chardev backend value may need to > append command line arguments for passing FDs. If we append > the -chardev arg before formatting the value, then the > resulting arguments will end up intersposed I assume you meant interspersed (at least that's what my brain read)! > > Signed-off-by: Daniel P. Berrange> --- > src/qemu/qemu_command.c | 18 +- > 1 file changed, 9 insertions(+), 9 deletions(-) > -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH v2 8/8] qemu: support use of virtlogd with file based chardevs
On 02/29/2016 08:33 AM, Daniel P. Berrange wrote: > Currently the file based character devices let QEMU write > directly to a file on disk. This allows a malicious QEMU > to inflict a denial of service by consuming all free space. > > Switch QEMU to use a pipe to virtlogd, which will enforce > file rollover. > > Signed-off-by: Daniel P. Berrange> --- > src/qemu/qemu_command.c | 21 +++-- > 1 file changed, 11 insertions(+), 10 deletions(-) > > diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c > index e04e55e..462a019 100644 > --- a/src/qemu/qemu_command.c > +++ b/src/qemu/qemu_command.c > @@ -3983,18 +3983,19 @@ qemuBuildChrChardevStr(virLogManagerPtr logManager, > break; > > case VIR_DOMAIN_CHR_TYPE_FILE: > -virBufferAsprintf(, "file,id=char%s,path=%s", alias, (see below) > - dev->data.file.path); > -if (dev->data.file.append != VIR_TRISTATE_SWITCH_ABSENT) { > -if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_CHARDEV_FILE_APPEND)) { > -virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", > - _("append not supported in this QEMU > binary")); > -goto error; > -} > +virBufferAsprintf(, "file,id=char%s", alias); > > -virBufferAsprintf(, ",append=%s", > - > virTristateSwitchTypeToString(dev->data.file.append)); > +if (dev->data.file.append != VIR_TRISTATE_SWITCH_ABSENT && > +!virQEMUCapsGet(qemuCaps, QEMU_CAPS_CHARDEV_FILE_APPEND)) { > +virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", > + _("append not supported in this QEMU binary")); > +goto error; > } > +if (qemuBuildChrChardevFileStr(virQEMUCapsGet(qemuCaps, > QEMU_CAPS_CHARDEV_FILE_APPEND) ? > + logManager : NULL, cmd, def, , > + "file", dev->data.file.path, s/"file"/"path" ? > + "append", dev->data.file.append) < 0) > +goto error; > break; > > case VIR_DOMAIN_CHR_TYPE_PIPE: > -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH v2 0/8] Use virtlogd for chardevs & support logging
On 02/29/2016 08:33 AM, Daniel P. Berrange wrote: > This series of patches does two things > > * Converts the type=file chardev over to use virtlogd >(assuming use of virtlogd is enabled in qemu.conf) > > * Adds a element to all chardev >sources, allowing data to be captured to a logfile > > Both of these are important features wanted by openstack. > The first thing fixes a long standing security issue that > a guest OS can trivially exhuast host disk space by outputing > lots of data to its serial port. > > The second thing allows OpenStack to record boot up > messages for a guest's serial console, while still > allowing interactive serial console ussage. ie the > serial port will be configured with type=tcp, and > the new element used to record the data. > > Both these thing required changes in QEMU, which have > been merged for the forthcoming QEMU 2.6 release. > > Changed in v2: > > * Split patch 4 up into 4 separate patches > * Fix memory leaks > * Use common function for building log manager cli args > * Add missing XML docs > > Daniel P. Berrange (8): > logging: allow inode/offset params to be NULL > conf: allow use of a logfile with chardev backends > qemu: add support for logging chardev output to a file > qemu: don't append -chardev arg until after value is formatted > qemu: move functions for handling FD passing > logging: support truncation of logfiles when opening > qemu: use virtlogd for character device log files > qemu: support use of virtlogd with file based chardevs > > docs/formatdomain.html.in | 14 + > docs/schemas/domaincommon.rng | 12 + > src/conf/domain_conf.c | 30 +++ > src/conf/domain_conf.h | 2 + > src/logging/log_daemon_dispatch.c | 3 +- > src/logging/log_handler.c | 6 +- > src/logging/log_handler.h | 2 +- > src/logging/log_manager.c | 6 +- > src/logging/log_manager.h | 2 + > src/logging/log_protocol.x | 4 + > src/qemu/qemu_capabilities.c | 2 + > src/qemu/qemu_capabilities.h | 1 + > src/qemu/qemu_command.c| 282 > ++--- > src/qemu/qemu_command.h| 9 +- > src/qemu/qemu_domain.c | 6 + > src/qemu/qemu_domain.h | 3 + > src/qemu/qemu_driver.c | 2 +- > src/qemu/qemu_process.c| 4 +- > .../qemuxml2argv-serial-file-log.args | 25 ++ > .../qemuxml2argv-serial-file-log.xml | 39 +++ > tests/qemuxml2argvtest.c | 4 +- > 21 files changed, 353 insertions(+), 105 deletions(-) > create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-serial-file-log.args > create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-serial-file-log.xml > As you know patch 3 (qemu_capabilities.{c|h} & 7 (qemu_command.c) will require handling merge conflicts... ACK series modulo a couple of nits pointed out. John -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH] virLXCProcessMonitorInitNotify: Initialize @inode
This is an error message I've just seen. Fix it by initializing @inode. CC lxc/libvirt_driver_lxc_impl_la-lxc_process.lo lxc/lxc_process.c: In function 'virLXCProcessMonitorInitNotify': lxc/lxc_process.c:767:23: error: 'inode' may be used uninitialized in this function [-Werror=maybe-uninitialized] virDomainAuditInit(vm, initpid, inode); ^ Signed-off-by: Michal Privoznik--- Pushed under trivial rule. src/lxc/lxc_process.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/lxc/lxc_process.c b/src/lxc/lxc_process.c index 50bee48..5e0bbe2 100644 --- a/src/lxc/lxc_process.c +++ b/src/lxc/lxc_process.c @@ -749,7 +749,7 @@ static void virLXCProcessMonitorInitNotify(virLXCMonitorPtr mon ATTRIBUTE_UNUSED virLXCDriverPtr driver = lxc_driver; virLXCDomainObjPrivatePtr priv; virLXCDriverConfigPtr cfg = virLXCDriverGetConfig(driver); -ino_t inode; +ino_t inode = 0; virObjectLock(vm); @@ -762,7 +762,6 @@ static void virLXCProcessMonitorInitNotify(virLXCMonitorPtr mon ATTRIBUTE_UNUSED (unsigned long long)initpid, err && err->message ? err->message : ""); virResetLastError(); -inode = 0; } virDomainAuditInit(vm, initpid, inode); -- 2.4.10 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [libvirt-glib] gconfig: Fix next API version number
Commit 01e01f2 introduced a wrong next API version number in libvirt-gconfig.sym Signed-off-by: Fabiano FidĂȘncio--- libvirt-gconfig/libvirt-gconfig.sym | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libvirt-gconfig/libvirt-gconfig.sym b/libvirt-gconfig/libvirt-gconfig.sym index f11f97a..5bc2e24 100644 --- a/libvirt-gconfig/libvirt-gconfig.sym +++ b/libvirt-gconfig/libvirt-gconfig.sym @@ -733,7 +733,7 @@ global: gvir_config_domain_video_set_vgamem; } LIBVIRT_GCONFIG_0.2.1; -LIBVIRT_GCONFIG_0.2.4 { +LIBVIRT_GCONFIG_0.2.3 { gvir_config_domain_graphics_spice_set_gl; gvir_config_domain_video_set_accel3d; } LIBVIRT_GCONFIG_0.2.2; -- 2.5.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH v3 0/2] cleanup resolving persistent/running/current flags
On 03/02/2016 09:30 AM, Nikolay Shirokovskiy wrote: > Changes from version2 > = > > 1. Already ACKed or PUSHed patches are dropped. > 2. Patch of reusing virDomainObjUpdateModificationImpact is splitted > into lxc and libxl and compilation is fixed. > > Nikolay Shirokovskiy (2): > lxc: reuse virDomainObjUpdateModificationImpact > libxl: reuse virDomainObjUpdateModificationImpact > > src/libxl/libxl_driver.c | 63 > src/lxc/lxc_driver.c | 75 > > 2 files changed, 12 insertions(+), 126 deletions(-) > ACK series and pushed. I also adjusted the commit message on patch 2 from the v2 and pushed it along with this. Thanks for your (um) persistence - John -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 7/9] qemu: add support for offline vcpupin
On 02/24/2016 09:22 AM, Peter Krempa wrote: > Allow pinning for inactive cpus. The pinning mask will be automatically ^ NIT: vcpus > applied as we would apply the default mask in case of a cpu hotplug. > > Setting the scheduler settings for a vcpu has the same semantics. > > Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1306556 > --- > src/qemu/qemu_domain.c | 3 ++- > src/qemu/qemu_driver.c | 62 > ++ > 2 files changed, 24 insertions(+), 41 deletions(-) > -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 2/9] conf: Extract code filling data for virDomainGetVcpuPinInfo
On 02/24/2016 09:22 AM, Peter Krempa wrote: > The implementation of the inner guts of the function is similar for all > drivers, so we can add a helper and not have to reimplement it three > times. > --- > src/conf/domain_conf.c | 64 > > src/conf/domain_conf.h | 8 ++ > src/libvirt_private.syms | 1 + > src/libxl/libxl_driver.c | 38 +++- > src/qemu/qemu_driver.c | 43 +++- > src/test/test_driver.c | 38 > 6 files changed, 84 insertions(+), 108 deletions(-) > ACK with one nit... One difference I noted, the 'libxl' code would: memset(cpumaps, 0x00, maplen * ncpumaps); just before filling. Should that be replicated in the common code? If not then for the libxl code should the lines be kept? John [...] > diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c > index 404016e..a99c99c 100644 > --- a/src/libxl/libxl_driver.c > +++ b/src/libxl/libxl_driver.c > @@ -2423,8 +2423,7 @@ libxlDomainGetVcpuPinInfo(virDomainPtr dom, int > ncpumaps, > libxlDriverConfigPtr cfg = libxlDriverConfigGet(driver); > virDomainObjPtr vm = NULL; > virDomainDefPtr targetDef = NULL; > -int hostcpus, vcpu, ret = -1; > -virBitmapPtr allcpumap = NULL; > +int ret = -1; > > virCheckFlags(VIR_DOMAIN_AFFECT_LIVE | >VIR_DOMAIN_AFFECT_CONFIG, -1); > @@ -2445,41 +2444,10 @@ libxlDomainGetVcpuPinInfo(virDomainPtr dom, int > ncpumaps, > /* Make sure coverity knows targetDef is valid at this point. */ > sa_assert(targetDef); > > -/* Clamp to actual number of vcpus */ > -if (ncpumaps > virDomainDefGetVcpus(targetDef)) > -ncpumaps = virDomainDefGetVcpus(targetDef); > - > -if ((hostcpus = libxl_get_max_cpus(cfg->ctx)) < 0) > -goto cleanup; > - > -if (!(allcpumap = virBitmapNew(hostcpus))) > -goto cleanup; > - > -virBitmapSetAll(allcpumap); > - > -memset(cpumaps, 0x00, maplen * ncpumaps); ^ > - > -for (vcpu = 0; vcpu < ncpumaps; vcpu++) { > -virDomainVcpuInfoPtr vcpuinfo = virDomainDefGetVcpu(targetDef, vcpu); > -virBitmapPtr bitmap = NULL; > - > -if (!vcpuinfo->online) > -continue; > - > -if (vcpuinfo->cpumask) > -bitmap = vcpuinfo->cpumask; > -else if (targetDef->cpumask) > -bitmap = targetDef->cpumask; > -else > -bitmap = allcpumap; > - > -virBitmapToDataBuf(bitmap, VIR_GET_CPUMAP(cpumaps, maplen, vcpu), > maplen); > -} > - > -ret = ncpumaps; > +ret = virDomainDefGetVcpuPinInfoHelper(targetDef, maplen, ncpumaps, > cpumaps, > + libxl_get_max_cpus(cfg->ctx), > NULL); > > cleanup: > -virBitmapFree(allcpumap); > if (vm) > virObjectUnlock(vm); > virObjectUnref(cfg); [...] -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 8/9] qemu: vcpupin: Extract live vcpupin setting into a separate function
On 02/24/2016 09:22 AM, Peter Krempa wrote: > The function was now beyond maintainability. > --- > src/qemu/qemu_driver.c | 134 > - > 1 file changed, 77 insertions(+), 57 deletions(-) > hmmm... some comments below written before I viewed the patch 9 pcpumaplive changes... Perhaps there should be a merging of the two or even reverse the order with obvious logic adjustments... Without doing so leaves a 1-patch window with an issue. > diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c > index bfabc53..cab69a5 100644 > --- a/src/qemu/qemu_driver.c > +++ b/src/qemu/qemu_driver.c > @@ -4967,6 +4967,82 @@ qemuDomainSetVcpus(virDomainPtr dom, unsigned int > nvcpus) > > > static int > +qemuDomainPinVcpuLive(virDomainObjPtr vm, > + virDomainDefPtr def, > + int vcpu, > + virQEMUDriverPtr driver, > + virQEMUDriverConfigPtr cfg, > + virBitmapPtr cpumap) > +{ > +virDomainVcpuInfoPtr vcpuinfo; > +qemuDomainObjPrivatePtr priv = vm->privateData; > +virCgroupPtr cgroup_vcpu = NULL; > +char *str = NULL; > +virObjectEventPtr event = NULL; > +char paramField[VIR_TYPED_PARAM_FIELD_LENGTH] = ""; > +virTypedParameterPtr eventParams = NULL; > +int eventNparams = 0; > +int eventMaxparams = 0; > +int ret = -1; > + > +if (!qemuDomainHasVcpuPids(vm)) { > +virReportError(VIR_ERR_OPERATION_INVALID, > + "%s", _("cpu affinity is not supported")); > +goto cleanup; > +} > + > +if (!(vcpuinfo = virDomainDefGetVcpu(def, vcpu))) { > +virReportError(VIR_ERR_INVALID_ARG, > + _("vcpu %d is out of range of live cpu count %d"), > + vcpu, virDomainDefGetVcpusMax(def)); > +goto cleanup; > +} > + > +if (vcpuinfo->online) { > +/* Configure the corresponding cpuset cgroup before set affinity. */ > +if (virCgroupHasController(priv->cgroup, > VIR_CGROUP_CONTROLLER_CPUSET)) { > +if (virCgroupNewThread(priv->cgroup, VIR_CGROUP_THREAD_VCPU, > vcpu, > + false, _vcpu) < 0) > +goto cleanup; > +if (qemuSetupCgroupCpusetCpus(cgroup_vcpu, cpumap) < 0) > +goto cleanup; > +} > + > +if (virProcessSetAffinity(qemuDomainGetVcpuPid(vm, vcpu), cpumap) < > 0) > +goto cleanup; > +} > + > +virBitmapFree(vcpuinfo->cpumask); > +vcpuinfo->cpumask = cpumap; > +cpumap = NULL; Because there's some goto cleanup's after this, I think cpumap should be passed by reference and not value. > + > +if (virDomainSaveStatus(driver->xmlopt, cfg->stateDir, vm, driver->caps) > < 0) > +goto cleanup; > + > +if (snprintf(paramField, VIR_TYPED_PARAM_FIELD_LENGTH, > + VIR_DOMAIN_TUNABLE_CPU_VCPUPIN, vcpu) < 0) { > +goto cleanup; > +} > + > +str = virBitmapFormat(vcpuinfo->cpumask); > +if (virTypedParamsAddString(, , > +, paramField, str) < 0) > +goto cleanup; > + > +event = virDomainEventTunableNewFromObj(vm, eventParams, eventNparams); Are there any timing or locking consequences of this being called before qemuDomainObjEndJob and/or virDomainObjEndAPI (I don't think so, but typing what my eyes see as 'change'...) > + > +ret = 0; > + > + cleanup: > +virBitmapFree(cpumap); This is duplicated in the caller (pcpumaplive) and this function doesn't own this, so the caller should be left to handle. > +virCgroupFree(_vcpu); > +VIR_FREE(str); > +qemuDomainEventQueue(driver, event); > +return ret; > +} > + > + > +static int > qemuDomainPinVcpuFlags(virDomainPtr dom, > unsigned int vcpu, > unsigned char *cpumap, > @@ -4978,21 +5054,12 @@ qemuDomainPinVcpuFlags(virDomainPtr dom, > virDomainObjPtr vm; > virDomainDefPtr def; > virDomainDefPtr persistentDef; > -virCgroupPtr cgroup_vcpu = NULL; > int ret = -1; > -qemuDomainObjPrivatePtr priv; > virBitmapPtr pcpumap = NULL; > virBitmapPtr pcpumaplive = NULL; > virBitmapPtr pcpumappersist = NULL; > -virDomainVcpuInfoPtr vcpuinfolive = NULL; > virDomainVcpuInfoPtr vcpuinfopersist = NULL; > virQEMUDriverConfigPtr cfg = NULL; > -virObjectEventPtr event = NULL; > -char paramField[VIR_TYPED_PARAM_FIELD_LENGTH] = ""; > -char *str = NULL; > -virTypedParameterPtr eventParams = NULL; > -int eventNparams = 0; > -int eventMaxparams = 0; > > virCheckFlags(VIR_DOMAIN_AFFECT_LIVE | >VIR_DOMAIN_AFFECT_CONFIG, -1); > @@ -5011,15 +5078,6 @@ qemuDomainPinVcpuFlags(virDomainPtr dom, > if (virDomainObjGetDefs(vm, flags, , ) < 0) > goto endjob; > > -priv = vm->privateData; > - > -if (def && !(vcpuinfolive
Re: [libvirt] [PATCH 0/9] vcpu info refactors - part 3b
On 02/24/2016 09:22 AM, Peter Krempa wrote: > Yet another continuation of the saga. In this episode we add pinning for > inactive cpus. > > Peter Krempa (9): > virsh: vcpupin: Ask for pinning info for all vCPUs > conf: Extract code filling data for virDomainGetVcpuPinInfo > qemu: Report pinning for all vCPUs in qemuDomainGetVcpuPinInfo > conf: introduce parser feature flags > conf: refactor checking for unsupported memory devices > conf: extract ignoring of inactive vcpu pinning information > qemu: add support for offline vcpupin > qemu: vcpupin: Extract live vcpupin setting into a separate function > qemu: Refactor bitmap handling in qemuDomainPinVcpuFlags > > src/bhyve/bhyve_domain.c | 9 +- > src/conf/domain_conf.c | 157 +++--- > src/conf/domain_conf.h | 20 +++- > src/libvirt_private.syms | 3 +- > src/libxl/libxl_domain.c | 7 -- > src/libxl/libxl_driver.c | 38 +--- > src/lxc/lxc_domain.c | 8 -- > src/openvz/openvz_driver.c | 7 -- > src/phyp/phyp_driver.c | 6 +- > src/qemu/qemu_domain.c | 2 + > src/qemu/qemu_driver.c | 234 > +++-- > src/test/test_driver.c | 38 +--- > src/uml/uml_driver.c | 9 +- > src/vbox/vbox_common.c | 6 +- > src/vmware/vmware_driver.c | 6 +- > src/vmx/vmx.c | 8 +- > src/vz/vz_driver.c | 6 +- > src/xen/xen_driver.c | 7 -- > src/xenapi/xenapi_driver.c | 7 -- > tools/virsh-domain.c | 3 +- > 20 files changed, 279 insertions(+), 302 deletions(-) > ACK series modulo a couple of nits pointed out - most importantly is to combine patch 8 and 9. John -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 6/9] conf: extract ignoring of inactive vcpu pinning information
On 02/24/2016 09:22 AM, Peter Krempa wrote: > Introduce VIR_DOMAIN_DEF_FEATURE_OFFLINE_CPUPIN domain feature flag Should it be VCPUPIN ? > whcih will allow to skip ignoring of the pinning information for > hypervisor drivers which will want to implement forward-pinning of > vcpus. > --- > src/conf/domain_conf.c | 28 +++- > src/conf/domain_conf.h | 1 + > 2 files changed, 24 insertions(+), 5 deletions(-) > > diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c > index 101fae2..4220448 100644 > --- a/src/conf/domain_conf.c > +++ b/src/conf/domain_conf.c > @@ -4215,6 +4215,25 @@ > virDomainDeviceDefPostParseInternal(virDomainDeviceDefPtr dev, > } > > A little intro would be nice... > +static void > +virDomainDefRemoveOfflineVcpuPin(virDomainDefPtr def) > +{ > +size_t i; > +virDomainVcpuInfoPtr vcpu; > + > +for (i = 0; i < virDomainDefGetVcpusMax(def); i++) { > +vcpu = virDomainDefGetVcpu(def, i); > + > +if (!vcpu->online && vcpu->cpumask) { > +virBitmapFree(vcpu->cpumask); > +vcpu->cpumask = NULL; > + > +VIR_WARN("Ignoring unsupported vcpupin for offline vcpu '%zu'", > i); Is/was this for debugging? Do we really want to WARN or just go with INFO? > +} > +} > +} > + > + [...] -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH v4 1/5] migration: add compress method option
Signed-off-by: Nikolay Shirokovskiy--- include/libvirt/libvirt-domain.h | 11 +++ src/qemu/qemu_driver.c | 29 +-- src/qemu/qemu_migration.c| 163 --- src/qemu/qemu_migration.h| 23 ++ src/qemu/qemu_monitor.c | 2 +- src/qemu/qemu_monitor.h | 1 + 6 files changed, 195 insertions(+), 34 deletions(-) diff --git a/include/libvirt/libvirt-domain.h b/include/libvirt/libvirt-domain.h index 79c25df..b3a176f 100644 --- a/include/libvirt/libvirt-domain.h +++ b/include/libvirt/libvirt-domain.h @@ -671,6 +671,8 @@ typedef enum { * when supported */ VIR_MIGRATE_UNSAFE= (1 << 9), /* force migration even if it is considered unsafe */ VIR_MIGRATE_OFFLINE = (1 << 10), /* offline migrate */ +/* Migration options could be specified further via VIR_MIGRATE_PARAM_COMPRESSION + * otherwise default options will be used */ VIR_MIGRATE_COMPRESSED= (1 << 11), /* compress data during migration */ VIR_MIGRATE_ABORT_ON_ERROR= (1 << 12), /* abort migration on I/O errors happened during migration */ VIR_MIGRATE_AUTO_CONVERGE = (1 << 13), /* force convergence */ @@ -773,6 +775,15 @@ typedef enum { */ # define VIR_MIGRATE_PARAM_MIGRATE_DISKS"migrate_disks" +/** + * VIR_MIGRATE_PARAM_COMPRESSION: + * + * virDomainMigrate* params multiple field: string list of compression methods + * that are used to compress migration traffic. + */ + +# define VIR_MIGRATE_PARAM_COMPRESSION"compression" + /* Domain migration. */ virDomainPtr virDomainMigrate (virDomainPtr domain, virConnectPtr dconn, unsigned long flags, const char *dname, diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 4bd4071..b27b8f0 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -12061,7 +12061,7 @@ qemuDomainMigratePrepare2(virConnectPtr dconn, ret = qemuMigrationPrepareDirect(driver, dconn, NULL, 0, NULL, NULL, /* No cookies */ uri_in, uri_out, - , origname, NULL, 0, NULL, flags); + , origname, NULL, 0, NULL, NULL, flags); cleanup: VIR_FREE(origname); @@ -12114,7 +12114,7 @@ qemuDomainMigratePerform(virDomainPtr dom, * Consume any cookie we were able to decode though */ ret = qemuMigrationPerform(driver, dom->conn, vm, - NULL, dconnuri, uri, NULL, NULL, 0, NULL, + NULL, dconnuri, uri, NULL, NULL, 0, NULL, NULL, cookie, cookielen, NULL, NULL, /* No output cookies in v2 */ flags, dname, resource, false); @@ -12287,7 +12287,7 @@ qemuDomainMigratePrepare3(virConnectPtr dconn, cookiein, cookieinlen, cookieout, cookieoutlen, uri_in, uri_out, - , origname, NULL, 0, NULL, flags); + , origname, NULL, 0, NULL, NULL, flags); cleanup: VIR_FREE(origname); @@ -12316,6 +12316,7 @@ qemuDomainMigratePrepare3Params(virConnectPtr dconn, int nmigrate_disks; const char **migrate_disks = NULL; char *origname = NULL; +qemuMigrationCompressionPtr compression = NULL; int ret = -1; virCheckFlagsGoto(QEMU_MIGRATION_FLAGS, cleanup); @@ -12343,6 +12344,12 @@ qemuDomainMigratePrepare3Params(virConnectPtr dconn, if (nmigrate_disks < 0) goto cleanup; +if (VIR_ALLOC(compression) < 0) +goto cleanup; + +if (qemuMigrationCompressionParseParams(compression, params, nparams) < 0) +goto cleanup; + if (flags & VIR_MIGRATE_TUNNELLED) { /* this is a logical error; we never should have gotten here with * VIR_MIGRATE_TUNNELLED set @@ -12364,9 +12371,11 @@ qemuDomainMigratePrepare3Params(virConnectPtr dconn, cookieout, cookieoutlen, uri_in, uri_out, , origname, listenAddress, - nmigrate_disks, migrate_disks, flags); + nmigrate_disks, migrate_disks, + compression, flags); cleanup: +VIR_FREE(compression); VIR_FREE(migrate_disks); VIR_FREE(origname); virDomainDefFree(def); @@ -12498,7 +12507,7 @@ qemuDomainMigratePerform3(virDomainPtr dom, } return qemuMigrationPerform(driver, dom->conn, vm, xmlin, -dconnuri, uri, NULL, NULL, 0, NULL, +dconnuri, uri, NULL, NULL, 0,
[libvirt] [PATCH v4 4/5] qemu: migration: add compression options
Signed-off-by: Nikolay Shirokovskiy--- include/libvirt/libvirt-domain.h | 33 src/qemu/qemu_migration.c| 85 +++- src/qemu/qemu_migration.h| 7 3 files changed, 124 insertions(+), 1 deletion(-) diff --git a/include/libvirt/libvirt-domain.h b/include/libvirt/libvirt-domain.h index b3a176f..59df373 100644 --- a/include/libvirt/libvirt-domain.h +++ b/include/libvirt/libvirt-domain.h @@ -784,6 +784,39 @@ typedef enum { # define VIR_MIGRATE_PARAM_COMPRESSION"compression" +/** + * VIR_MIGRATE_PARAM_COMPRESSION_MT_LEVEL: + * + * virDomainMigrate* params field: the level of compression for multithread + * compression as VIR_TYPED_PARAM_INT. Accepted values * are in range 0-9. + * 0 is no compression, 1 is maximum speed and 9 is maximum compression. + */ +# define VIR_MIGRATE_PARAM_COMPRESSION_MT_LEVEL"compression.mt.level" + +/** + * VIR_MIGRATE_PARAM_COMPRESSION_MT_THREADS: + * + * virDomainMigrate* params field: the number of compression threads for + * multithread compression as VIR_TYPED_PARAM_INT. + */ +# define VIR_MIGRATE_PARAM_COMPRESSION_MT_THREADS "compression.mt.threads" + +/** + * VIR_MIGRATE_PARAM_COMPRESSION_MT_DTHREADS: + * + * virDomainMigrate* params field: the number of decompression threads for + * multithread compression as VIR_TYPED_PARAM_INT. + */ +# define VIR_MIGRATE_PARAM_COMPRESSION_MT_DTHREADS "compression.mt.dthreads" + +/** + * VIR_MIGRATE_PARAM_COMPRESSION_XBZRLE_CACHE: + * + * virDomainMigrate* params field: the size of page cache for xbzrle + * compression as VIR_TYPED_PARAM_ULLONG. + */ +# define VIR_MIGRATE_PARAM_COMPRESSION_XBZRLE_CACHE "compression.xbzrle.cache" + /* Domain migration. */ virDomainPtr virDomainMigrate (virDomainPtr domain, virConnectPtr dconn, unsigned long flags, const char *dname, diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index 5fcf132..88d62a9 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -3305,6 +3305,9 @@ qemuMigrationSetCompression(virQEMUDriverPtr driver, qemuMigrationCompressionPtr compression, unsigned int flags) { +int ret = -1; +qemuDomainObjPrivatePtr priv = vm->privateData; + /* * if compression methods are not set explicitly use flags to * set default compression methods @@ -3328,7 +3331,24 @@ qemuMigrationSetCompression(virQEMUDriverPtr driver, job) < 0) return -1; -return 0; +if (qemuDomainObjEnterMonitorAsync(driver, vm, job) < 0) +return -1; + +if (qemuMonitorSetMigrationParameters(priv->mon, >params) < 0) +goto cleanup; + +if (compression->xbzrle_cache_set && +qemuMonitorSetMigrationCacheSize(priv->mon, + compression->xbzrle_cache) < 0) +goto cleanup; + +ret = 0; + + cleanup: +if (qemuDomainObjExitMonitor(driver, vm) < 0) +ret = -1; + +return ret; } static int @@ -6359,6 +6379,8 @@ qemuMigrationCompressionParseParams(qemuMigrationCompressionPtr compression, virTypedParameterPtr params, int nparams) { size_t i; +qemuMonitorMigrationParametersPtr cparams = >params; +int rc; for (i = 0; i < nparams; i++) { if (STRNEQ(params[i].field, VIR_MIGRATE_PARAM_COMPRESSION)) @@ -6379,6 +6401,41 @@ qemuMigrationCompressionParseParams(qemuMigrationCompressionPtr compression, } } +#define VIR_GET_PARAMETER_OPT(PARAM, TYPE, PARENT, VALUE) \ +if ((rc = virTypedParamsGet ## TYPE(params, nparams,\ + PARAM, >VALUE)) < 0) \ +return -1; \ +\ +if (rc == 1)\ +PARENT->VALUE ## _set = 1; + +VIR_GET_PARAMETER_OPT(VIR_MIGRATE_PARAM_COMPRESSION_MT_LEVEL, + Int, cparams, level) +VIR_GET_PARAMETER_OPT(VIR_MIGRATE_PARAM_COMPRESSION_MT_THREADS, + Int, cparams, threads) +VIR_GET_PARAMETER_OPT(VIR_MIGRATE_PARAM_COMPRESSION_MT_DTHREADS, + Int, cparams, dthreads) +VIR_GET_PARAMETER_OPT(VIR_MIGRATE_PARAM_COMPRESSION_XBZRLE_CACHE, + ULLong, compression, xbzrle_cache) + +#undef VIR_GET_PARAMETER_OPT + +if ((cparams->level_set || cparams->threads_set || cparams->dthreads_set) && +!(compression->methods & QEMU_MIGRATION_COMPESS_MULTITHREAD)) { +virReportError(VIR_ERR_INVALID_ARG, "%s", + _("You cannot specify multithread compression " + "parameters without turning it on.")); +return -1; +} + +if
[libvirt] [PATCH v4 0/5] migration: add multithread compression
Add means to turn multithread compression on during migration. Add means to pass compression parameters in migration command. Changes from v3 === 1. HMP support is dropped. 2. Switch to a different implementation of setting migration parameters. Version 3 sets all parameters when configuring migration compression. If parameter is not specified explicitly it is set to hardcoded default value. New version set only explicitly specified parameters instead. This has some reproducibility drawbacks which are nevertheless could be overcomed and this issue will be addressed in another series. 3. Unspecified values are presented by bitset fields rather then specific values of parameters itself. This is a bit more tedious implementation to use but if we take it we can pass all parameter values checking to QEMU. 4. Misc minor changes on Jiri comments. Eli Qiao (1): qemumonitorjsontest: add test for getting multithread compress params Nikolay Shirokovskiy (2): migration: add compress method option qemu: migration: add compression options ShaoHe Feng (2): qemu monitor: add multithread compress parameters accessors virsh: add compression options for migration include/libvirt/libvirt-domain.h | 44 +++ src/qemu/qemu_driver.c | 29 - src/qemu/qemu_migration.c| 246 ++- src/qemu/qemu_migration.h| 30 + src/qemu/qemu_monitor.c | 24 +++- src/qemu/qemu_monitor.h | 18 +++ src/qemu/qemu_monitor_json.c | 110 + src/qemu/qemu_monitor_json.h | 5 + tests/qemumonitorjsontest.c | 53 + tools/virsh-domain.c | 83 + tools/virsh.pod | 25 +++- 11 files changed, 628 insertions(+), 39 deletions(-) -- 1.8.3.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH v4 2/5] qemu monitor: add multithread compress parameters accessors
From: ShaoHe FengSigned-off-by: ShaoHe Feng Signed-off-by: Nikolay Shirokovskiy --- src/qemu/qemu_monitor.c | 22 + src/qemu/qemu_monitor.h | 17 +++ src/qemu/qemu_monitor_json.c | 110 +++ src/qemu/qemu_monitor_json.h | 5 ++ 4 files changed, 154 insertions(+) diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c index 5e4461a..21c1df6 100644 --- a/src/qemu/qemu_monitor.c +++ b/src/qemu/qemu_monitor.c @@ -2157,6 +2157,28 @@ qemuMonitorSetMigrationCacheSize(qemuMonitorPtr mon, int +qemuMonitorGetMigrationParameters(qemuMonitorPtr mon, + qemuMonitorMigrationParametersPtr params) +{ +QEMU_CHECK_MONITOR_JSON(mon); + +return qemuMonitorJSONGetMigrationParameters(mon, params); +} + +int +qemuMonitorSetMigrationParameters(qemuMonitorPtr mon, + qemuMonitorMigrationParametersPtr params) +{ +VIR_DEBUG("level=%d threads=%d dthreads=%d", + params->level, params->threads, params->dthreads); + +QEMU_CHECK_MONITOR_JSON(mon); + +return qemuMonitorJSONSetMigrationParameters(mon, params); +} + + +int qemuMonitorGetMigrationStats(qemuMonitorPtr mon, qemuMonitorMigrationStatsPtr stats) { diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h index 28620b5..b28b431 100644 --- a/src/qemu/qemu_monitor.h +++ b/src/qemu/qemu_monitor.h @@ -469,6 +469,23 @@ int qemuMonitorGetMigrationCacheSize(qemuMonitorPtr mon, int qemuMonitorSetMigrationCacheSize(qemuMonitorPtr mon, unsigned long long cacheSize); +typedef struct _qemuMonitorMigrationParameters qemuMonitorMigrationParameters; +typedef qemuMonitorMigrationParameters *qemuMonitorMigrationParametersPtr; +struct _qemuMonitorMigrationParameters { +unsigned int level_set : 1; +unsigned int threads_set : 1; +unsigned int dthreads_set : 1; + +int level; +int threads; +int dthreads; +}; + +int qemuMonitorGetMigrationParameters(qemuMonitorPtr mon, + qemuMonitorMigrationParametersPtr params); +int qemuMonitorSetMigrationParameters(qemuMonitorPtr mon, + qemuMonitorMigrationParametersPtr params); + typedef enum { QEMU_MONITOR_MIGRATION_STATUS_INACTIVE, QEMU_MONITOR_MIGRATION_STATUS_SETUP, diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index 8352e53..999c644 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -2492,6 +2492,116 @@ qemuMonitorJSONSetMigrationCacheSize(qemuMonitorPtr mon, } +int +qemuMonitorJSONGetMigrationParameters(qemuMonitorPtr mon, + qemuMonitorMigrationParametersPtr params) +{ +int ret = -1; +virJSONValuePtr result; +virJSONValuePtr cmd = NULL; +virJSONValuePtr reply = NULL; + +if (!(cmd = qemuMonitorJSONMakeCommand("query-migrate-parameters", NULL))) +return -1; + +if ((ret = qemuMonitorJSONCommand(mon, cmd, )) < 0) +goto cleanup; + +if ((ret = qemuMonitorJSONCheckError(cmd, reply)) < 0) +goto cleanup; + +if (!(result = virJSONValueObjectGet(reply, "return"))) { +virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("query-migrate-parameters reply was missing " + "'return' data")); +goto cleanup; +} + +if (virJSONValueObjectGetNumberInt(result, "compress-level", + >level) < 0) { +virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("malformed/missing compress-level " + "in migrate parameters")); +goto cleanup; +} +params->level_set = 1; + +if (virJSONValueObjectGetNumberInt(result, "compress-threads", + >threads) < 0) { +virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("malformed/missing compress-threads " + "in migrate parameters")); +goto cleanup; +} +params->threads_set = 1; + +if (virJSONValueObjectGetNumberInt(result, "decompress-threads", + >dthreads) < 0) { +virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("malformed/missing decompress-threads " + "in migrate parameters")); +goto cleanup; +} +params->dthreads_set = 1; + +ret = 0; + cleanup: +virJSONValueFree(cmd); +virJSONValueFree(reply); +return ret; +} + +int +qemuMonitorJSONSetMigrationParameters(qemuMonitorPtr mon, + qemuMonitorMigrationParametersPtr params) +{ +int ret = -1; +virJSONValuePtr cmd = NULL; +virJSONValuePtr args = NULL; +virJSONValuePtr reply = NULL;
[libvirt] [PATCH v4 5/5] virsh: add compression options for migration
From: ShaoHe FengSigned-off-by: Nikolay Shirokovskiy --- tools/virsh-domain.c | 83 tools/virsh.pod | 25 2 files changed, 103 insertions(+), 5 deletions(-) diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index 979f115..6dd8eca 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -9666,6 +9666,31 @@ static const vshCmdOptDef opts_migrate[] = { .type = VSH_OT_STRING, .help = N_("comma separated list of disks to be migrated") }, +{.name = "compression-method", + .type = VSH_OT_STRING, + .help = N_("comma separated list of compression method to be used") +}, +{.name = "compression-mt-level", + .type = VSH_OT_INT, + .help = N_("compress level for multithread compression. " +"Values are in range 0-9, 9 means maximum compression. " +"'multithread' compression method must be selected with this option.") +}, +{.name = "compression-mt-threads", + .type = VSH_OT_INT, + .help = N_("number of compession threads from multithread compression. " +"'multithread' compression method must be selected with this option.") +}, +{.name = "compression-mt-dthreads", + .type = VSH_OT_INT, + .help = N_("number of decompession threads from multithread compression. " +"'multithread' compression method must be selected with this option.") +}, +{.name = "compression-xbzrle-cache", + .type = VSH_OT_INT, + .help = N_("page cache size for xbzrle compression. " +"'xbzrle' compression method must be selected with this option.") +}, {.name = NULL} }; @@ -9684,6 +9709,9 @@ doMigrate(void *opaque) virTypedParameterPtr params = NULL; int nparams = 0; int maxparams = 0; +int intOpt = 0; +unsigned long long ullOpt = 0; +int rv; virConnectPtr dconn = data->dconn; sigemptyset(); @@ -9744,6 +9772,61 @@ doMigrate(void *opaque) VIR_FREE(val); } +if (vshCommandOptStringReq(ctl, cmd, "compression-method", ) < 0) +goto out; +if (opt) { +char **val = NULL; + +val = virStringSplit(opt, ",", 0); + +if (virTypedParamsAddStringList(, +, +, +VIR_MIGRATE_PARAM_COMPRESSION, +(const char **)val) < 0) { +VIR_FREE(val); +goto save_error; +} + +VIR_FREE(val); +} + +if ((rv = vshCommandOptInt(ctl, cmd, "compression-mt-level", )) < 0) { +goto save_error; +} else if (rv > 0) { +if (virTypedParamsAddInt(, , , + VIR_MIGRATE_PARAM_COMPRESSION_MT_LEVEL, + intOpt) < 0) +goto save_error; +} + +if ((rv = vshCommandOptInt(ctl, cmd, "compression-mt-threads", )) < 0) { +goto save_error; +} else if (rv > 0) { +if (virTypedParamsAddInt(, , , + VIR_MIGRATE_PARAM_COMPRESSION_MT_THREADS, + intOpt) < 0) +goto save_error; +} + +if ((rv = vshCommandOptInt(ctl, cmd, "compression-mt-dthreads", )) < 0) { +goto save_error; +} else if (rv > 0) { +if (virTypedParamsAddInt(, , , + VIR_MIGRATE_PARAM_COMPRESSION_MT_DTHREADS, + intOpt) < 0) +goto save_error; +} + +if ((rv = vshCommandOptULongLong(ctl, cmd, "compression-xbzrle-cache", )) < 0) { +goto save_error; +} else if (rv > 0) { +if (virTypedParamsAddULLong(, , , +VIR_MIGRATE_PARAM_COMPRESSION_XBZRLE_CACHE, +ullOpt) < 0) +goto save_error; +} + if (vshCommandOptStringReq(ctl, cmd, "xml", ) < 0) goto out; if (opt) { diff --git a/tools/virsh.pod b/tools/virsh.pod index 4662658..854c7ae 100644 --- a/tools/virsh.pod +++ b/tools/virsh.pod @@ -1532,7 +1532,9 @@ to the I namespace is displayed instead of being modified. [I<--compressed>] [I<--abort-on-error>] [I<--auto-converge>] I I [I] [I] [I] [I] [I<--timeout> B] [I<--xml> B] -[I<--migrate-disks> B] +[I<--migrate-disks> B] [I<--compression-method> B] +[I<--compression-mt-level>] [I<--compression-mt-threads>] [I<--compression-mt-dthreads>] +[I<--compression-xbzrle-cache>] Migrate domain to another host. Add I<--live> for live migration; <--p2p> for peer-2-peer migration; I<--direct> for direct migration; or I<--tunnelled> @@ -1555,10 +1557,14 @@ enforces that no incompatible configuration changes will be made to the domain while the migration is underway; this flag is implicitly enabled when supported by the
[libvirt] [PATCH v4 3/5] qemumonitorjsontest: add test for getting multithread compress params
From: Eli QiaoSigned-off-by: Eli Qiao Signed-off-by: ShaoHe Feng Signed-off-by: Nikolay Shirokovskiy --- tests/qemumonitorjsontest.c | 53 + 1 file changed, 53 insertions(+) diff --git a/tests/qemumonitorjsontest.c b/tests/qemumonitorjsontest.c index 1be0bee..b31df36 100644 --- a/tests/qemumonitorjsontest.c +++ b/tests/qemumonitorjsontest.c @@ -1593,6 +1593,58 @@ testQemuMonitorJSONqemuMonitorJSONGetBlockStatsInfo(const void *data) } static int +testQemuMonitorJSONqemuMonitorJSONGetMigrationParameters(const void *data) +{ +virDomainXMLOptionPtr xmlopt = (virDomainXMLOptionPtr)data; +qemuMonitorTestPtr test = qemuMonitorTestNewSimple(true, xmlopt); +qemuMonitorMigrationParameters compression; +int ret = -1; + +if (!test) +return -1; + +if (qemuMonitorTestAddItem(test, "query-migrate-parameters", + "{" + "\"return\": {" + "\"decompress-threads\": 2," + "\"compress-threads\": 8," + "\"compress-level\": 1" + "}" + "}") < 0) { +goto cleanup; +} + +if (qemuMonitorJSONGetMigrationParameters(qemuMonitorTestGetMonitor(test), + ) < 0) +goto cleanup; + +if (compression.level != 1) { +virReportError(VIR_ERR_INTERNAL_ERROR, + "Invalid decompress-threads: %d, expected 1", + compression.level); +goto cleanup; +} +if (compression.threads != 8) { +virReportError(VIR_ERR_INTERNAL_ERROR, + "Invalid decompress-threads: %d, expected 8", + compression.threads); +goto cleanup; +} +if (compression.dthreads != 2) { +virReportError(VIR_ERR_INTERNAL_ERROR, + "Invalid decompress-threads: %d, expected 2", + compression.dthreads); +goto cleanup; +} +ret = 0; + + cleanup: +qemuMonitorTestFree(test); +return ret; +} + + +static int testQemuMonitorJSONqemuMonitorJSONGetMigrationCacheSize(const void *data) { virDomainXMLOptionPtr xmlopt = (virDomainXMLOptionPtr)data; @@ -2333,6 +2385,7 @@ mymain(void) DO_TEST(qemuMonitorJSONGetBlockInfo); DO_TEST(qemuMonitorJSONGetBlockStatsInfo); DO_TEST(qemuMonitorJSONGetMigrationCacheSize); +DO_TEST(qemuMonitorJSONGetMigrationParameters); DO_TEST(qemuMonitorJSONGetMigrationStats); DO_TEST(qemuMonitorJSONGetChardevInfo); DO_TEST(qemuMonitorJSONSetBlockIoThrottle); -- 1.8.3.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list