Re: [Qemu-devel] [PATCH v6] s390x/cpu: expose the guest crash information
On Wed, 7 Feb 2018 19:15:22 +0100 Christian Borntraeger wrote: > On 02/07/2018 05:58 PM, Cornelia Huck wrote: > > > > >> +## > >> +# @S390CrashReason: > >> +# > >> +# Reason why the CPU is in a crashed state. > >> +# > >> +# @unknown: no crash reason was set > >> +# > >> +# @disabledwait: the CPU has entered a disabled wait state > >> +# > >> +# @extintloop: timer interrupt with new PSW enabled for timer > >> +# > >> +# @pgmintloop: program interrupt with BAD new PSW > >> +# > >> +# @opintloop: operation exception interrupt with invalid code at the > >> program > >> +# interrupt new PSW > >> +# > >> +# Since: 2.12 > >> +## > >> +{ 'enum': 'S390CrashReason', > >> + 'data': [ 'unknown', > >> +'disabledwait', > >> +'extintloop', > >> +'pgmintloop', > >> +'opintloop' ] } > > > > Would some hyphens or underscores make this a bit more readable? FWICS, > > QAPI would create something like S390_CRASH_REASON_DISABLED_WAIT for > > 'disabled-wait', which looks reasonable to me. > > > disabled-wait > extint-loop > pgmint-loop > opint-loop > > ? Looks good to me.
[Qemu-devel] [RESEND PATCH] PPC: e500: Fix duplicate kernel load and device tree overlap
This patch fixes an incorrect behavior when the -kernel argument has been specified without -bios. In this case the kernel was loaded twice. At address 32M as a raw image and afterwards by load_elf/load_uimage at the corresponding load address. In this case the region for the device tree and the raw kernel image may overlap. The patch fixes the behavior by loading the kernel image once with load_elf/load_uimage and skips loading the raw image. It also ensures that the device tree is generated behind bios/kernel/initrd. Signed-off-by: David Engraf --- hw/ppc/e500.c | 89 --- 1 file changed, 48 insertions(+), 41 deletions(-) diff --git a/hw/ppc/e500.c b/hw/ppc/e500.c index c4fe06ea2a..0321bd66a8 100644 --- a/hw/ppc/e500.c +++ b/hw/ppc/e500.c @@ -776,7 +776,6 @@ void ppce500_init(MachineState *machine, PPCE500Params *params) MemoryRegion *ram = g_new(MemoryRegion, 1); PCIBus *pci_bus; CPUPPCState *env = NULL; -uint64_t loadaddr; hwaddr kernel_base = -1LL; int kernel_size = 0; hwaddr dt_base = 0; @@ -913,11 +912,6 @@ void ppce500_init(MachineState *machine, PPCE500Params *params) /* Register spinning region */ sysbus_create_simple("e500-spin", params->spin_base, NULL); -if (cur_base < (32 * 1024 * 1024)) { -/* u-boot occupies memory up to 32MB, so load blobs above */ -cur_base = (32 * 1024 * 1024); -} - if (params->has_mpc8xxx_gpio) { qemu_irq poweroff_irq; @@ -952,36 +946,6 @@ void ppce500_init(MachineState *machine, PPCE500Params *params) sysbus_mmio_get_region(s, 0)); } -/* Load kernel. */ -if (machine->kernel_filename) { -kernel_base = cur_base; -kernel_size = load_image_targphys(machine->kernel_filename, - cur_base, - ram_size - cur_base); -if (kernel_size < 0) { -fprintf(stderr, "qemu: could not load kernel '%s'\n", -machine->kernel_filename); -exit(1); -} - -cur_base += kernel_size; -} - -/* Load initrd. */ -if (machine->initrd_filename) { -initrd_base = (cur_base + INITRD_LOAD_PAD) & ~INITRD_PAD_MASK; -initrd_size = load_image_targphys(machine->initrd_filename, initrd_base, - ram_size - initrd_base); - -if (initrd_size < 0) { -fprintf(stderr, "qemu: could not load initial ram disk '%s'\n", -machine->initrd_filename); -exit(1); -} - -cur_base = initrd_base + initrd_size; -} - /* * Smart firmware defaults ahead! * @@ -1006,24 +970,67 @@ void ppce500_init(MachineState *machine, PPCE500Params *params) } filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name); -bios_size = load_elf(filename, NULL, NULL, &bios_entry, &loadaddr, NULL, +bios_size = load_elf(filename, NULL, NULL, &bios_entry, &cur_base, NULL, 1, PPC_ELF_MACHINE, 0, 0); if (bios_size < 0) { /* * Hrm. No ELF image? Try a uImage, maybe someone is giving us an * ePAPR compliant kernel */ -kernel_size = load_uimage(filename, &bios_entry, &loadaddr, NULL, - NULL, NULL); -if (kernel_size < 0) { +bios_size = load_uimage(filename, &bios_entry, &cur_base, NULL, +NULL, NULL); +if (bios_size < 0) { fprintf(stderr, "qemu: could not load firmware '%s'\n", filename); exit(1); } } +cur_base += bios_size; g_free(filename); +/* Load bare kernel only if no bios/u-boot has been provided */ +if (machine->kernel_filename != bios_name) { +kernel_base = cur_base; +kernel_size = load_image_targphys(machine->kernel_filename, + cur_base, + ram_size - cur_base); +if (kernel_size < 0) { +fprintf(stderr, "qemu: could not load kernel '%s'\n", +machine->kernel_filename); +exit(1); +} + +cur_base += kernel_size; +} else { +kernel_base = cur_base; +kernel_size = bios_size; +} + +if (cur_base < (32 * 1024 * 1024)) { +/* u-boot occupies memory up to 32MB, so load blobs above */ +cur_base = (32 * 1024 * 1024); +} + +/* Load initrd. */ +if (machine->initrd_filename) { +initrd_base = (cur_base + INITRD_LOAD_PAD) & ~INITRD_PAD_MASK; +initrd_size = load_image_targphys(machine->initrd_filename, initrd_base, + ram_size - initrd_base); + +if (initrd_size < 0) { +fprintf(stderr, "qemu: could not load initial ram disk '%s'\n", +
Re: [Qemu-devel] [Qemu-ppc] [PATCH] spapr: check smp_threads < vsmt
On 07/02/2018 21:21, Greg Kurz wrote: > On Wed, 7 Feb 2018 17:17:30 +0100 > Laurent Vivier wrote: > >> We ignore silently the value of smp_threads when we set >> the VSMT value, and if smp_threads is greater than VSMT >> kernel is going into trouble later. >> >> Fixes: 8904e5a750 >> ("spapr: Adjust default VSMT value for better migration compatibility") >> >> Signed-off-by: Laurent Vivier >> --- >> hw/ppc/spapr.c | 17 - >> 1 file changed, 8 insertions(+), 9 deletions(-) >> >> diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c >> index 32a876be56..638b3cafd0 100644 >> --- a/hw/ppc/spapr.c >> +++ b/hw/ppc/spapr.c >> @@ -2294,15 +2294,7 @@ static void spapr_set_vsmt_mode(sPAPRMachineState >> *spapr, Error **errp) >> } >> >> /* Detemine the VSMT mode to use: */ >> -if (vsmt_user) { >> -if (spapr->vsmt < smp_threads) { >> -error_setg(&local_err, "Cannot support VSMT mode %d" >> - " because it must be >= threads/core (%d)", >> - spapr->vsmt, smp_threads); > > In this case, we'd error out because the user requested two settings that > are known to be incompatible. > >> -goto out; >> -} >> -/* In this case, spapr->vsmt has been set by the command line */ >> -} else { >> +if (!vsmt_user) { >> /* >> * Default VSMT value is tricky, because we need it to be as >> * consistent as possible (for migration), but this requires >> @@ -2313,6 +2305,13 @@ static void spapr_set_vsmt_mode(sPAPRMachineState >> *spapr, Error **errp) >> spapr->vsmt = 8; > > In this case, we'd error out because the user requested a setting that is > incompatible with our default. Maybe worth a separate error message ? > > "Cannot support %d threads/core because it must be <= to default VSMT mode > (8)" I'm going to update the error message. Thanks, Laurent
Re: [Qemu-devel] [PATCH 2/2] qmp: document query-cpus performance issue
On Wed, Feb 07, 2018 at 12:50:14PM -0500, Luiz Capitulino wrote: > Signed-off-by: Luiz Capitulino > --- > qapi-schema.json | 4 > 1 file changed, 4 insertions(+) > > diff --git a/qapi-schema.json b/qapi-schema.json > index 82d6f12b53..0665a14dba 100644 > --- a/qapi-schema.json > +++ b/qapi-schema.json > @@ -526,6 +526,10 @@ > # > # Returns a list of information about each virtual CPU. > # > +# WARNING: This command incurs a performance penalty for latency > +# sensitive workloads and hence it's not recommended to > +# to be used in production. Use query-cpus-fast instead I suggest being more explicit about exactly what the problem is, so people understand implications if they choose to still use it. ie This command causes vCPU threads to exit to userspace, which causes an small interruption guest CPU execution. This will have a negative impact on realtime guests and other latency sensitive guest workloads. It is recommended to use query-cpus-fast instead of this command to avoid the vCPU interruption. Regards, Daniel -- |: https://berrange.com -o-https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o-https://fstop138.berrange.com :| |: https://entangle-photo.org-o-https://www.instagram.com/dberrange :|
[Qemu-devel] [PATCH v2] spapr: check smp_threads <= vsmt
We ignore silently the value of smp_threads when we set the default VSMT value, and if smp_threads is greater than VSMT kernel is going into trouble later. Fixes: 8904e5a750 ("spapr: Adjust default VSMT value for better migration compatibility") Signed-off-by: Laurent Vivier --- Notes: v2: display a specific error message when the default VSMT is used fix subject hw/ppc/spapr.c | 6 ++ 1 file changed, 6 insertions(+) diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index 32a876be56..11de276cd5 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -2311,6 +2311,12 @@ static void spapr_set_vsmt_mode(sPAPRMachineState *spapr, Error **errp) * overwhelmingly common case in production systems. */ spapr->vsmt = 8; +if (spapr->vsmt < smp_threads) { +error_setg(&local_err, "Cannot support %d threads/core" + " because it must be <= to default VSMT mode (%d)", + smp_threads, spapr->vsmt); +goto out; +} } /* KVM: If necessary, set the SMT mode: */ -- 2.14.3
[Qemu-devel] [PATCH] target-i386: adds PV_DEDICATED hint CPUID feature bit
From: Wanpeng Li Add PV_DEDICATED hint cpuid feature bit. Cc: Paolo Bonzini Cc: Radim Krčmář Cc: Eduardo Habkost Signed-off-by: Wanpeng Li --- target/i386/cpu.c | 4 target/i386/cpu.h | 3 +++ 2 files changed, 7 insertions(+) diff --git a/target/i386/cpu.c b/target/i386/cpu.c index d70954b..cf48931 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -4076,6 +4076,9 @@ static int x86_cpu_filter_features(X86CPU *cpu) x86_cpu_get_supported_feature_word(w, false); uint32_t requested_features = env->features[w]; env->features[w] &= host_feat; +if (cpu->pv_dedicated && (w == FEAT_KVM)) { +env->features[w] |= CPUID_PV_DEDICATED; +} cpu->filtered_features[w] = requested_features & ~env->features[w]; if (cpu->filtered_features[w]) { rv = 1; @@ -4682,6 +4685,7 @@ static Property x86_cpu_properties[] = { false), DEFINE_PROP_BOOL("vmware-cpuid-freq", X86CPU, vmware_cpuid_freq, true), DEFINE_PROP_BOOL("tcg-cpuid", X86CPU, expose_tcg, true), +DEFINE_PROP_BOOL("pv-dedicated", X86CPU, pv_dedicated, false), /* * From "Requirements for Implementing the Microsoft diff --git a/target/i386/cpu.h b/target/i386/cpu.h index f91e37d..8000da5 100644 --- a/target/i386/cpu.h +++ b/target/i386/cpu.h @@ -672,6 +672,8 @@ typedef uint32_t FeatureWordArray[FEATURE_WORDS]; #define CPUID_8000_0008_EBX_IBPB(1U << 12) /* Indirect Branch Prediction Barrier */ +#define CPUID_PV_DEDICATED (1U << 8) + #define CPUID_XSAVE_XSAVEOPT (1U << 0) #define CPUID_XSAVE_XSAVEC (1U << 1) #define CPUID_XSAVE_XGETBV1(1U << 2) @@ -1276,6 +1278,7 @@ struct X86CPU { bool expose_kvm; bool expose_tcg; bool migratable; +bool pv_dedicated; bool max_features; /* Enable all supported features automatically */ uint32_t apic_id; -- 2.7.4
[Qemu-devel] [PATCH] S390: Expose s390-specific CPU info
Presently s390x is the only architecture not exposing specific CPU information via QMP query-cpus. Upstream discussion has shown that it could make sense to report the architecture specific CPU state, e.g. to detect that a CPU has been stopped. With this change the output of query-cpus will look like this on s390: [{"arch": "s390", "current": true, "props": {"core-id": 0}, "cpu_state": "operating", "CPU": 0, "qom_path": "/machine/unattached/device[0]", "halted": false, "thread_id": 63115}, {"arch": "s390", "current": false, "props": {"core-id": 1}, "cpu_state": "stopped", "CPU": 1, "qom_path": "/machine/unattached/device[1]", "halted": true, "thread_id": 63116}] Signed-off-by: Viktor Mihajlovski --- cpus.c | 6 ++ hmp.c | 4 hw/s390x/s390-virtio-ccw.c | 2 +- qapi-schema.json | 25 - target/s390x/cpu.c | 24 target/s390x/cpu.h | 7 ++- target/s390x/kvm.c | 8 target/s390x/sigp.c| 38 +++--- 8 files changed, 72 insertions(+), 42 deletions(-) diff --git a/cpus.c b/cpus.c index 2cb0af9..39e46dd 100644 --- a/cpus.c +++ b/cpus.c @@ -2033,6 +2033,9 @@ CpuInfoList *qmp_query_cpus(Error **errp) #elif defined(TARGET_TRICORE) TriCoreCPU *tricore_cpu = TRICORE_CPU(cpu); CPUTriCoreState *env = &tricore_cpu->env; +#elif defined(TARGET_S390X) +S390CPU *s390_cpu = S390_CPU(cpu); +CPUS390XState *env = &s390_cpu->env; #endif cpu_synchronize_state(cpu); @@ -2060,6 +2063,9 @@ CpuInfoList *qmp_query_cpus(Error **errp) #elif defined(TARGET_TRICORE) info->value->arch = CPU_INFO_ARCH_TRICORE; info->value->u.tricore.PC = env->PC; +#elif defined(TARGET_S390X) +info->value->arch = CPU_INFO_ARCH_S390; +info->value->u.s390.cpu_state = env->cpu_state; #else info->value->arch = CPU_INFO_ARCH_OTHER; #endif diff --git a/hmp.c b/hmp.c index b3de32d..37e04c3 100644 --- a/hmp.c +++ b/hmp.c @@ -390,6 +390,10 @@ void hmp_info_cpus(Monitor *mon, const QDict *qdict) case CPU_INFO_ARCH_TRICORE: monitor_printf(mon, " PC=0x%016" PRIx64, cpu->value->u.tricore.PC); break; +case CPU_INFO_ARCH_S390: +monitor_printf(mon, " state=%s", + CpuInfoS390State_str(cpu->value->u.s390.cpu_state)); +break; default: break; } diff --git a/hw/s390x/s390-virtio-ccw.c b/hw/s390x/s390-virtio-ccw.c index 3807dcb..3e6360e 100644 --- a/hw/s390x/s390-virtio-ccw.c +++ b/hw/s390x/s390-virtio-ccw.c @@ -373,7 +373,7 @@ static void s390_machine_reset(void) /* all cpus are stopped - configure and start the ipl cpu only */ s390_ipl_prepare_cpu(ipl_cpu); -s390_cpu_set_state(CPU_STATE_OPERATING, ipl_cpu); +s390_cpu_set_state(CPU_INFOS390_STATE_OPERATING, ipl_cpu); } static void s390_machine_device_plug(HotplugHandler *hotplug_dev, diff --git a/qapi-schema.json b/qapi-schema.json index 5c06745..c34880b 100644 --- a/qapi-schema.json +++ b/qapi-schema.json @@ -413,7 +413,7 @@ # Since: 2.6 ## { 'enum': 'CpuInfoArch', - 'data': ['x86', 'sparc', 'ppc', 'mips', 'tricore', 'other' ] } + 'data': ['x86', 'sparc', 'ppc', 'mips', 'tricore', 's390', 'other' ] } ## # @CpuInfo: @@ -452,6 +452,7 @@ 'ppc': 'CpuInfoPPC', 'mips': 'CpuInfoMIPS', 'tricore': 'CpuInfoTricore', +'s390': 'CpuInfoS390', 'other': 'CpuInfoOther' } } ## @@ -522,6 +523,28 @@ { 'struct': 'CpuInfoOther', 'data': { } } ## +# @CpuInfoS390State: +# +# An enumeration of cpu states that can be assumed by a virtual +# S390 CPU +# +# Since: 2.12 +## +{ 'enum': 'CpuInfoS390State', + 'data': [ 'uninitialized', 'stopped', 'check_stop', 'operating', 'load' ] } + +## +# @CpuInfoS390: +# +# Additional information about a virtual S390 CPU +# +# @cpu_state: the CPUs state +# +# Since: 2.12 +## +{ 'struct': 'CpuInfoS390', 'data': { 'cpu_state': 'CpuInfoS390State' } } + +## # @query-cpus: # # Returns a list of information about each virtual CPU. diff --git a/target/s390x/cpu.c b/target/s390x/cpu.c index d2e6b9f..996cbc8 100644 --- a/target/s390x/cpu.c +++ b/target/s390x/cpu.c @@ -58,8 +58,8 @@ static bool s390_cpu_has_work(CPUState *cs) S390CPU *cpu = S390_CPU(cs); /* STOPPED cpus can never wake up */ -if (s390_cpu_get_state(cpu) != CPU_STATE_LOAD && -s390_cpu_get_state(cpu) != CPU_STATE_OPERATING) { +if (s390_cpu_get_state(cpu) != CPU_INFOS390_STATE_LOAD && +s390_cpu_get_state(cpu) != CPU_INFOS390_STATE_OPERATING) { return false; } @@ -77,7 +77,7 @@ static void s390_cpu_load_normal(CPUState *s) S390CPU *cpu = S390_CPU(s); cpu->env.psw.addr = ldl_phys(s->as, 4) & PSW_MASK_ESA_ADDR; cpu->env.psw.mask = PSW_MASK_32 | PSW_MASK_
Re: [Qemu-devel] [RFC] exec: eliminate ram naming issue as migration
On Thu, 8 Feb 2018 09:20:45 +0800 "Tan, Jianfeng" wrote: > On 2/7/2018 8:06 PM, Igor Mammedov wrote: > > On Wed, 7 Feb 2018 07:49:58 + > > "Tan, Jianfeng" wrote: > > > >>> -Original Message- > >>> From: Paolo Bonzini [mailto:pbonz...@redhat.com] > >>> Sent: Tuesday, February 6, 2018 1:32 AM > >>> To: Igor Mammedov > >>> Cc: Tan, Jianfeng; qemu-devel@nongnu.org; Jason Wang; Maxime Coquelin; > >>> Michael S . Tsirkin > >>> Subject: Re: [Qemu-devel] [RFC] exec: eliminate ram naming issue as > >>> migration > >>> > >>> On 05/02/2018 18:15, Igor Mammedov wrote: > >> Then we would have both ram block named pc.ram: > >>Block NamePSize > >>pc.ram 4 KiB > >>/objects/pc.ram2 MiB > >> > >> But I assume it's a corner case which not really happen. > > Yeah, you're right. :/ I hadn't thought of hotplug. It can happen > > indeed. > perhaps we should fail object_add memory-backend-foo if it resulted > in creating ramblock with duplicate id > >>> Note that it would only be duplicated with Jianfeng's patch. So I'm > >>> worried that his patch is worse than what we have now, because it may > >>> create conflicts with system RAMBlock names are not necessarily > >>> predictable. Right now, -object creates RAMBlock names that are nicely > >>> constrained within /object/. > >> So we are trading off between the benefit it takes and the bad effect it > >> brings. > >> > >> I'm wondering if the above example is the only failed case this patch > >> leads to, i.e, only there is a ram named "pc.ram" and "/object/pc.ram" in > >> the src VM? > >> > >> Please also consider the second option, that adding an alias name for > >> RAMBlock; I'm not a big fan for that one, as it just pushes the problem to > >> OpenStack/Libvirt. > > looking at provided CLI examples it's configuration issue on src and dst, > > one shall not mix numa and non numa variants. > > Aha, that's another thing we also want to change. We now add numa at dst > node, only because without -numa, we cannot set up the file-baked memory > with share=on. then shouldn't you start src with the same -numa to begin with, changing such things on the fly is not supported. General rule is that machine on dst has to be the same as on src. (with backend not visible to guest it possible might be changed but it's hard to tell if something would break due to that or would continue working in future since doesn't go along with above rule) > For example, "-m xG -mem-path xxx" can set up a file-baked memory, but > the file is not share-able. It could be solved by adding memdev option to machine, which would allow to specify backend object. And then on top make -mem-path alias new option to clean thing up. But then again, You'd need to start both src and dst with the same option. > > > >> Or any other suggestions? > > Fix configuration, namely dst side of it (i.e. use the same -m only variant > > without -numa as it's on src). > > > > BTW, what are you trying to achieve adding -numa on dst? > > See above reply. > > Thanks, > Jianfeng
Re: [Qemu-devel] [patch] linux-user/syscall.c: Fix missing break for host_to_target_cmsg
On 2018-02-07 19:27, Laurent Vivier wrote: Le 07/02/2018 à 10:49, no-re...@patchew.org a écrit : Hi, This series failed build test on s390x host. Please find the details below. ... CC aarch64_be-linux-user/linux-user/syscall.o In file included from /var/tmp/patchew-tester-tmp-ewjgn083/src/linux-user/qemu.h:16:0, from /var/tmp/patchew-tester-tmp-ewjgn083/src/linux-user/syscall.c:118: /var/tmp/patchew-tester-tmp-ewjgn083/src/linux-user/syscall.c: In function ‘do_sendrecvmsg_locked’: /var/tmp/patchew-tester-tmp-ewjgn083/src/linux-user/syscall_defs.h:308:61: error: ‘tgt_len’ may be used uninitialized in this function [-Werror=maybe-uninitialized] #define TARGET_CMSG_LEN(len) (sizeof(struct target_cmsghdr) + (len)) ^ /var/tmp/patchew-tester-tmp-ewjgn083/src/linux-user/syscall.c:1797:13: note: ‘tgt_len’ was declared here int tgt_len, tgt_space; ^~~ it seems gcc disagrees with Coverity... I think this should fixed like: diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 74378947f0..d7fbe334eb 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -1824,8 +1824,10 @@ static inline abi_long host_to_target_cmsg(struct target_msghdr *target_msgh, tgt_len = sizeof(struct target_timeval); break; default: +tgt_len = len; break; In my view this will result in assigning a wrong value to ‘tgt_len’ at this ‘switch-case’ condition. Instead looking at the option of initializing ‘tgt_len' to ‘0’. @@ -1789,7 +1789,7 @@ void *target_data = TARGET_CMSG_DATA(target_cmsg); int len = cmsg->cmsg_len - sizeof(struct cmsghdr); -int tgt_len, tgt_space; +int tgt_len = 0, tgt_space; /* We never copy a half-header but may copy half-data; * this is Linux's behaviour in put_cmsg(). Note that @@ -1821,6 +1821,7 @@ default: break; } +break; default: tgt_len = len; break; Re-sending this mail because earlier one not reached the mailing list. Please accept my apologies if it is a duplicate. } +break; default: tgt_len = len; break; Peter? Thanks, Laurent -- Regards, R.Nageswara Sastry
Re: [Qemu-devel] [PATCH RFC 06/21] qapi-gen: New common driver for code and doc generators
Markus Armbruster writes: > Marc-Andre Lureau writes: > >> On Fri, Feb 2, 2018 at 2:03 PM, Markus Armbruster wrote: [...] >>> diff --git a/scripts/qapi2texi.py b/scripts/qapi/doc.py >>> old mode 100755 >>> new mode 100644 >>> similarity index 92% >>> rename from scripts/qapi2texi.py >>> rename to scripts/qapi/doc.py >>> index 924b374cd3..1f57f6e1c2 >>> --- a/scripts/qapi2texi.py >>> +++ b/scripts/qapi/doc.py >>> @@ -4,10 +4,9 @@ >>> # This work is licensed under the terms of the GNU LGPL, version 2+. >>> # See the COPYING file in the top-level directory. >>> """This script produces the documentation of a qapi schema in texinfo >>> format""" >>> + >>> import re >>> -import sys >>> - >>> -import qapi >>> +import qapi.common >>> >>> MSG_FMT = """ >>> @deftypefn {type} {{}} {name} >>> @@ -196,7 +195,7 @@ def texi_entity(doc, what, base=None, variants=None, >>> + texi_sections(doc)) >>> >>> >>> -class QAPISchemaGenDocVisitor(qapi.QAPISchemaVisitor): >>> +class QAPISchemaGenDocVisitor(qapi.common.QAPISchemaVisitor): >> >> Would be a bit easier to read and more consitent with a top-level >> "from qapi.common import QAPISchemaVisitor" > > Can do. The obvious patch (appended) doesn't work, because doc_required is always False in gen_doc(). WTF?!? [...] diff --git a/scripts/qapi/doc.py b/scripts/qapi/doc.py index 4027722032..919e77b79e 100644 --- a/scripts/qapi/doc.py +++ b/scripts/qapi/doc.py @@ -7,7 +7,7 @@ from __future__ import print_function import re -import qapi.common +from qapi.common import doc_required, QAPIGenDoc, QAPISchemaVisitor MSG_FMT = """ @deftypefn {type} {{}} {name} @@ -196,7 +196,7 @@ def texi_entity(doc, what, base=None, variants=None, + texi_sections(doc)) -class QAPISchemaGenDocVisitor(qapi.common.QAPISchemaVisitor): +class QAPISchemaGenDocVisitor(QAPISchemaVisitor): def __init__(self): self.out = None self.cur_doc = None @@ -272,7 +272,7 @@ def texi_schema(schema): def gen_doc(schema, output_dir, prefix): -if qapi.common.doc_required: -gen = qapi.common.QAPIGenDoc() +if doc_required: +gen = QAPIGenDoc() gen.add(texi_schema(schema)) gen.write(output_dir, prefix + 'qapi.texi')
[Qemu-devel] [PATCH v7] s390x/cpu: expose the guest crash information
This patch is the s390 implementation of guest crash information, similar to commit d187e08dc4 ("i386/cpu: add crash-information QOM property") and the related commits. We will detect several crash reasons, with the "disabled wait" being the most important one, since this is used by all s390 guests as a "panic like" notification. Demonstrate these ways with examples as follows. 1. crash-information QOM property; Run qemu with -qmp unix:qmp-sock,server, then use utility "qmp-shell" to execute "qom-get" command, and might get the result like, (QEMU) (QEMU) qom-get path=/machine/unattached/device[0] \ property=crash-information {"return": {"core": 0, "reason": "disabled-wait", "psw-mask": 562956395872256, \ "type": "s390", "psw-addr": 1102832}} 2. GUEST_PANICKED event reporting; Run qemu with a socket option, and telnet or nc to that, -chardev socket,id=qmp,port=,host=localhost,server \ -mon chardev=qmp,mode=control,pretty=on \ Negotiating the mode by { "execute": "qmp_capabilities" }, and the crash information will be reported on a guest crash event like, { "timestamp": { "seconds": 1518004739, "microseconds": 552563 }, "event": "GUEST_PANICKED", "data": { "action": "pause", "info": { "core": 0, "psw-addr": 1102832, "reason": "disabled-wait", "psw-mask": 562956395872256, "type": "s390" } } } 3. log; Run qemu with the parameters: -D -d guest_errors, to specify the logfile and log item. The results might be, Guest crashed on cpu 0: disabled-wait PSW: 0x000200018000 0x0010d3f0 Co-authored-by: Jing Liu Signed-off-by: Christian Borntraeger --- v6->v7: - word separation like disabled-wait instead of disabledwait - use S390CrashReason_str instead of qapi_enum_lookup - fix linux user - improve description for extint-loop qapi/run-state.json | 55 +-- target/s390x/cpu.c| 43 target/s390x/cpu.h| 2 ++ target/s390x/helper.c | 5 - target/s390x/kvm.c| 15 +++--- vl.c | 11 +-- 6 files changed, 118 insertions(+), 13 deletions(-) diff --git a/qapi/run-state.json b/qapi/run-state.json index bca46a8785..4bd15ae54f 100644 --- a/qapi/run-state.json +++ b/qapi/run-state.json @@ -320,22 +320,29 @@ # # An enumeration of the guest panic information types # +# @hyper-v: hyper-v guest panic information type +# +# @s390: s390 guest panic information type (Since: 2.12) +# # Since: 2.9 ## { 'enum': 'GuestPanicInformationType', - 'data': [ 'hyper-v'] } + 'data': [ 'hyper-v', 's390' ] } ## # @GuestPanicInformation: # # Information about a guest panic # +# @type: Crash type that defines the hypervisor specific information +# # Since: 2.9 ## {'union': 'GuestPanicInformation', 'base': {'type': 'GuestPanicInformationType'}, 'discriminator': 'type', - 'data': { 'hyper-v': 'GuestPanicInformationHyperV' } } + 'data': { 'hyper-v': 'GuestPanicInformationHyperV', + 's390': 'GuestPanicInformationS390' } } ## # @GuestPanicInformationHyperV: @@ -350,3 +357,47 @@ 'arg3': 'uint64', 'arg4': 'uint64', 'arg5': 'uint64' } } + +## +# @S390CrashReason: +# +# Reason why the CPU is in a crashed state. +# +# @unknown: no crash reason was set +# +# @disabled-wait: the CPU has entered a disabled wait state +# +# @extint-loop: clock comparator or cpu timer interrupt with new PSW enabled +# for external interrupts +# +# @pgmint-loop: program interrupt with BAD new PSW +# +# @opint-loop: operation exception interrupt with invalid code at the program +# interrupt new PSW +# +# Since: 2.12 +## +{ 'enum': 'S390CrashReason', + 'data': [ 'unknown', +'disabled-wait', +'extint-loop', +'pgmint-loop', +'opint-loop' ] } + +## +# @GuestPanicInformationS390: +# +# S390 specific guest panic information (PSW) +# +# @core: core id of the CPU that crashed +# @psw-mask: control fields of guest PSW +# @psw-addr: guest instruction address +# @reason: guest crash reason in human readable form +# +# Since: 2.12 +## +{'struct': 'GuestPanicInformationS390', + 'data': { 'core': 'uint32', + 'psw-mask': 'uint64', + 'psw-addr': 'uint64', + 'reason': 'S390CrashReason' } } diff --git a/target/s390x/cpu.c b/target/s390x/cpu.c index d2e6b9f5c7..603e68e284 100644 --- a/target/s390x/cpu.c +++ b/target/s390x/cpu.c @@ -35,6 +35,8 @@ #include "qemu/error-report.h" #include "trace.h" #include "qapi/visitor.h" +#include "qapi-visit.h" +#include "sysemu/hw_accel.h" #include "exec/exec-all.h" #include "hw/qdev-properties.h" #ifndef CONFIG_USER_ONLY @@ -237,6 +239,44 @@ out: error_propagate(errp, err); } +static GuestPanicInformation *s390_cpu_get_c
[Qemu-devel] Questions regarding how QEMU initializes virtual peripherals
Hello all, I am working with QEMU to simulate VersatilePB board. I am trying to understand how QEMU initialize the virtual peripherals (e.g. UART, vectored Interrupt controller .. etc). When I traced the code, I found a function called "object_init_with_type" in object.c, in which the function pointer "ti->instance_init(obj)" seems to call the peripherals initialization functions. *I have couple of questions here:* 1.) Some peripheral initialization functions are called multiple times such as pl011_init, why is that ? 2.) Where is the entry point for the whole initialization functionalities (that will eventually call "object_init_with_type") Thank you. -- Best Regards, Ramy Sameh Embedded Software Engineer
Re: [Qemu-devel] [Qemu-block] [PATCH] block: early check for blockers on drive-mirror
On Wed 07 Feb 2018 05:29:20 PM CET, Paolo Bonzini wrote: > Even if an op blocker is present for BLOCK_OP_TYPE_MIRROR_SOURCE, > it is checked a bit late and the result is that the target is > created even if drive-mirror subsequently fails. Add an early > check to avoid this. > > Signed-off-by: Paolo Bonzini > --- > blockdev.c | 5 + > 1 file changed, 5 insertions(+) > > diff --git a/blockdev.c b/blockdev.c > index 8e977eef11..c7e2e0a00e 100644 > --- a/blockdev.c > +++ b/blockdev.c > @@ -3565,6 +3565,11 @@ void qmp_drive_mirror(DriveMirror *arg, Error **errp) > return; > } > > +/* Early check to avoid creating target */ > +if (bdrv_op_is_blocked(bs, BLOCK_OP_TYPE_MIRROR_SOURCE, errp)) { > +return; > +} > + > aio_context = bdrv_get_aio_context(bs); > aio_context_acquire(aio_context); Do we need to hold the AioContext in order to check for op blockers? Berto
Re: [Qemu-devel] [PATCH 1/2] qmp: add query-cpus-fast
On 08.02.2018 08:41, Viktor Mihajlovski wrote: > On 07.02.2018 18:50, Luiz Capitulino wrote: >> The query-cpus command has an extremely serious side effect: >> it always interrupt all running vCPUs so that they can run >> ioctl calls. This can cause a huge performance degradation for >> some workloads. And most of the information retrieved by the >> ioctl calls are not even used by query-cpus. >> >> This commit introduces a replacement for query-cpus called >> query-cpus-fast, which has the following features: >> >> o Never interrupt vCPUs threads. query-cpus-fast only returns >>vCPU information maintained by QEMU itself, which should be >>sufficient for most management software needs >> >> o Make "halted" field optional: we only return it if the >>halted state is maintained by QEMU. But this also gives >>the option of dropping the field in the future (see below) >> >> o Drop irrelevant fields such as "current", "pc" and "arch" > I disagree that arch is irrelevant and would strongly suggest to keep > arch and arch-specific fields. At least in the case of s390 there's a > cpu_state field that can be obtained cheaply. I've posted a patch [1] to add s390-specific state info to the query-cpus output. This state *can* be obtained without kicking the CPU out of VM execution. With this info in the query-cpus-fast return data we can eventually get rid of halted and its ramifications. [...] [1] https://lists.gnu.org/archive/html/qemu-devel/2018-02/msg02032.html -- Regards, Viktor Mihajlovski
Re: [Qemu-devel] [PATCH] S390: Expose s390-specific CPU info
On Thu, 8 Feb 2018 10:48:08 +0100 Viktor Mihajlovski wrote: [added some cc:s] > Presently s390x is the only architecture not exposing specific > CPU information via QMP query-cpus. Upstream discussion has shown > that it could make sense to report the architecture specific CPU > state, e.g. to detect that a CPU has been stopped. > > With this change the output of query-cpus will look like this on > s390: > > [{"arch": "s390", "current": true, > "props": {"core-id": 0}, "cpu_state": "operating", "CPU": 0, > "qom_path": "/machine/unattached/device[0]", > "halted": false, "thread_id": 63115}, > {"arch": "s390", "current": false, > "props": {"core-id": 1}, "cpu_state": "stopped", "CPU": 1, > "qom_path": "/machine/unattached/device[1]", > "halted": true, "thread_id": 63116}] > > Signed-off-by: Viktor Mihajlovski > --- > cpus.c | 6 ++ > hmp.c | 4 > hw/s390x/s390-virtio-ccw.c | 2 +- > qapi-schema.json | 25 - > target/s390x/cpu.c | 24 > target/s390x/cpu.h | 7 ++- > target/s390x/kvm.c | 8 > target/s390x/sigp.c| 38 +++--- > 8 files changed, 72 insertions(+), 42 deletions(-) > > diff --git a/cpus.c b/cpus.c > index 2cb0af9..39e46dd 100644 > --- a/cpus.c > +++ b/cpus.c > @@ -2033,6 +2033,9 @@ CpuInfoList *qmp_query_cpus(Error **errp) > #elif defined(TARGET_TRICORE) > TriCoreCPU *tricore_cpu = TRICORE_CPU(cpu); > CPUTriCoreState *env = &tricore_cpu->env; > +#elif defined(TARGET_S390X) > +S390CPU *s390_cpu = S390_CPU(cpu); > +CPUS390XState *env = &s390_cpu->env; > #endif > > cpu_synchronize_state(cpu); > @@ -2060,6 +2063,9 @@ CpuInfoList *qmp_query_cpus(Error **errp) > #elif defined(TARGET_TRICORE) > info->value->arch = CPU_INFO_ARCH_TRICORE; > info->value->u.tricore.PC = env->PC; > +#elif defined(TARGET_S390X) > +info->value->arch = CPU_INFO_ARCH_S390; > +info->value->u.s390.cpu_state = env->cpu_state; > #else > info->value->arch = CPU_INFO_ARCH_OTHER; > #endif > diff --git a/hmp.c b/hmp.c > index b3de32d..37e04c3 100644 > --- a/hmp.c > +++ b/hmp.c > @@ -390,6 +390,10 @@ void hmp_info_cpus(Monitor *mon, const QDict *qdict) > case CPU_INFO_ARCH_TRICORE: > monitor_printf(mon, " PC=0x%016" PRIx64, > cpu->value->u.tricore.PC); > break; > +case CPU_INFO_ARCH_S390: > +monitor_printf(mon, " state=%s", > + > CpuInfoS390State_str(cpu->value->u.s390.cpu_state)); > +break; > default: > break; > } > diff --git a/hw/s390x/s390-virtio-ccw.c b/hw/s390x/s390-virtio-ccw.c > index 3807dcb..3e6360e 100644 > --- a/hw/s390x/s390-virtio-ccw.c > +++ b/hw/s390x/s390-virtio-ccw.c > @@ -373,7 +373,7 @@ static void s390_machine_reset(void) > > /* all cpus are stopped - configure and start the ipl cpu only */ > s390_ipl_prepare_cpu(ipl_cpu); > -s390_cpu_set_state(CPU_STATE_OPERATING, ipl_cpu); > +s390_cpu_set_state(CPU_INFOS390_STATE_OPERATING, ipl_cpu); Exposing the state as a QAPI enum has the unfortunate side effect of that new name. It feels slightly awkward to me, as it is a state for real decisions and not just for info statements... > } > > static void s390_machine_device_plug(HotplugHandler *hotplug_dev, > diff --git a/qapi-schema.json b/qapi-schema.json > index 5c06745..c34880b 100644 > --- a/qapi-schema.json > +++ b/qapi-schema.json > @@ -413,7 +413,7 @@ > # Since: 2.6 > ## > { 'enum': 'CpuInfoArch', > - 'data': ['x86', 'sparc', 'ppc', 'mips', 'tricore', 'other' ] } > + 'data': ['x86', 'sparc', 'ppc', 'mips', 'tricore', 's390', 'other' ] } > > ## > # @CpuInfo: > @@ -452,6 +452,7 @@ > 'ppc': 'CpuInfoPPC', > 'mips': 'CpuInfoMIPS', > 'tricore': 'CpuInfoTricore', > +'s390': 'CpuInfoS390', > 'other': 'CpuInfoOther' } } > > ## > @@ -522,6 +523,28 @@ > { 'struct': 'CpuInfoOther', 'data': { } } > > ## > +# @CpuInfoS390State: > +# > +# An enumeration of cpu states that can be assumed by a virtual > +# S390 CPU > +# > +# Since: 2.12 > +## > +{ 'enum': 'CpuInfoS390State', > + 'data': [ 'uninitialized', 'stopped', 'check_stop', 'operating', 'load' ] } > + > +## > +# @CpuInfoS390: > +# > +# Additional information about a virtual S390 CPU > +# > +# @cpu_state: the CPUs state > +# > +# Since: 2.12 > +## > +{ 'struct': 'CpuInfoS390', 'data': { 'cpu_state': 'CpuInfoS390State' } } > + > +## > # @query-cpus: > # > # Returns a list of information about each virtual CPU. > diff --git a/target/s390x/cpu.c b/target/s390x/cpu.c > index d2e6b9f..996cbc8 100644 > --- a/target/s390x/cpu.c > +++ b/target/s390x/cpu.c > @@ -58,8 +58,8 @@ static bool s390_cpu_has_work(CPUState *cs) > S390CP
Re: [Qemu-devel] [PULL 0/1] Ide patches
On 7 February 2018 at 16:33, John Snow wrote: > The following changes since commit 0833df03f4206a6cf416fbb3d380fa95c8e61fba: > > Merge remote-tracking branch > 'remotes/dgilbert/tags/pull-migration-20180206a' into staging (2018-02-07 > 12:07:23 +) > > are available in the Git repository at: > > https://github.com/jnsnow/qemu.git tags/ide-pull-request > > for you to fetch changes up to 29e1d473ccb0703044541959df443c175ea5f5da: > > ide-test: test trim requests (2018-02-07 11:25:22 -0500) > > > > > > Anton Nefedov (1): > ide-test: test trim requests > > tests/ide-test.c | 71 > > 1 file changed, 71 insertions(+) > Applied, thanks. -- PMM
Re: [Qemu-devel] [RFC] exec: eliminate ram naming issue as migration
On 2/8/2018 5:51 PM, Igor Mammedov wrote: On Thu, 8 Feb 2018 09:20:45 +0800 "Tan, Jianfeng" wrote: On 2/7/2018 8:06 PM, Igor Mammedov wrote: On Wed, 7 Feb 2018 07:49:58 + "Tan, Jianfeng" wrote: -Original Message- From: Paolo Bonzini [mailto:pbonz...@redhat.com] Sent: Tuesday, February 6, 2018 1:32 AM To: Igor Mammedov Cc: Tan, Jianfeng; qemu-devel@nongnu.org; Jason Wang; Maxime Coquelin; Michael S . Tsirkin Subject: Re: [Qemu-devel] [RFC] exec: eliminate ram naming issue as migration On 05/02/2018 18:15, Igor Mammedov wrote: Then we would have both ram block named pc.ram: Block NamePSize pc.ram 4 KiB /objects/pc.ram2 MiB But I assume it's a corner case which not really happen. Yeah, you're right. :/ I hadn't thought of hotplug. It can happen indeed. perhaps we should fail object_add memory-backend-foo if it resulted in creating ramblock with duplicate id Note that it would only be duplicated with Jianfeng's patch. So I'm worried that his patch is worse than what we have now, because it may create conflicts with system RAMBlock names are not necessarily predictable. Right now, -object creates RAMBlock names that are nicely constrained within /object/. So we are trading off between the benefit it takes and the bad effect it brings. I'm wondering if the above example is the only failed case this patch leads to, i.e, only there is a ram named "pc.ram" and "/object/pc.ram" in the src VM? Please also consider the second option, that adding an alias name for RAMBlock; I'm not a big fan for that one, as it just pushes the problem to OpenStack/Libvirt. looking at provided CLI examples it's configuration issue on src and dst, one shall not mix numa and non numa variants. Aha, that's another thing we also want to change. We now add numa at dst node, only because without -numa, we cannot set up the file-baked memory with share=on. then shouldn't you start src with the same -numa to begin with, changing such things on the fly is not supported. Yes, you are describing the best practice. But we are originally trying to migrate without any changes to QEMU. General rule is that machine on dst has to be the same as on src. OK. (with backend not visible to guest it possible might be changed but it's hard to tell if something would break due to that or would continue working in future since doesn't go along with above rule) For example, "-m xG -mem-path xxx" can set up a file-baked memory, but the file is not share-able. It could be solved by adding memdev option to machine, which would allow to specify backend object. And then on top make -mem-path alias new option to clean thing up. Do you mean? src vm: -m xG dst vm: -m xG,memdev=pc.ram -object memory-backend-file,id=pc.ram,size=xG,mem-path=xxx,share=on ... But then again, You'd need to start both src and dst with the same option. Yeah, got it :-)
Re: [Qemu-devel] [PATCH] S390: Expose s390-specific CPU info
On 02/08/2018 11:16 AM, Cornelia Huck wrote: > On Thu, 8 Feb 2018 10:48:08 +0100 > Viktor Mihajlovski wrote: > > [added some cc:s] > >> Presently s390x is the only architecture not exposing specific >> CPU information via QMP query-cpus. Upstream discussion has shown >> that it could make sense to report the architecture specific CPU >> state, e.g. to detect that a CPU has been stopped. >> >> With this change the output of query-cpus will look like this on >> s390: >> >> [{"arch": "s390", "current": true, >> "props": {"core-id": 0}, "cpu_state": "operating", "CPU": 0, >> "qom_path": "/machine/unattached/device[0]", >> "halted": false, "thread_id": 63115}, >> {"arch": "s390", "current": false, >> "props": {"core-id": 1}, "cpu_state": "stopped", "CPU": 1, >> "qom_path": "/machine/unattached/device[1]", >> "halted": true, "thread_id": 63116}] >> >> Signed-off-by: Viktor Mihajlovski >> --- >> cpus.c | 6 ++ >> hmp.c | 4 >> hw/s390x/s390-virtio-ccw.c | 2 +- >> qapi-schema.json | 25 - >> target/s390x/cpu.c | 24 >> target/s390x/cpu.h | 7 ++- >> target/s390x/kvm.c | 8 >> target/s390x/sigp.c| 38 +++--- >> 8 files changed, 72 insertions(+), 42 deletions(-) >> >> diff --git a/cpus.c b/cpus.c >> index 2cb0af9..39e46dd 100644 >> --- a/cpus.c >> +++ b/cpus.c >> @@ -2033,6 +2033,9 @@ CpuInfoList *qmp_query_cpus(Error **errp) >> #elif defined(TARGET_TRICORE) >> TriCoreCPU *tricore_cpu = TRICORE_CPU(cpu); >> CPUTriCoreState *env = &tricore_cpu->env; >> +#elif defined(TARGET_S390X) >> +S390CPU *s390_cpu = S390_CPU(cpu); >> +CPUS390XState *env = &s390_cpu->env; >> #endif >> >> cpu_synchronize_state(cpu); >> @@ -2060,6 +2063,9 @@ CpuInfoList *qmp_query_cpus(Error **errp) >> #elif defined(TARGET_TRICORE) >> info->value->arch = CPU_INFO_ARCH_TRICORE; >> info->value->u.tricore.PC = env->PC; >> +#elif defined(TARGET_S390X) >> +info->value->arch = CPU_INFO_ARCH_S390; >> +info->value->u.s390.cpu_state = env->cpu_state; >> #else >> info->value->arch = CPU_INFO_ARCH_OTHER; >> #endif >> diff --git a/hmp.c b/hmp.c >> index b3de32d..37e04c3 100644 >> --- a/hmp.c >> +++ b/hmp.c >> @@ -390,6 +390,10 @@ void hmp_info_cpus(Monitor *mon, const QDict *qdict) >> case CPU_INFO_ARCH_TRICORE: >> monitor_printf(mon, " PC=0x%016" PRIx64, >> cpu->value->u.tricore.PC); >> break; >> +case CPU_INFO_ARCH_S390: >> +monitor_printf(mon, " state=%s", >> + >> CpuInfoS390State_str(cpu->value->u.s390.cpu_state)); >> +break; >> default: >> break; >> } >> diff --git a/hw/s390x/s390-virtio-ccw.c b/hw/s390x/s390-virtio-ccw.c >> index 3807dcb..3e6360e 100644 >> --- a/hw/s390x/s390-virtio-ccw.c >> +++ b/hw/s390x/s390-virtio-ccw.c >> @@ -373,7 +373,7 @@ static void s390_machine_reset(void) >> >> /* all cpus are stopped - configure and start the ipl cpu only */ >> s390_ipl_prepare_cpu(ipl_cpu); >> -s390_cpu_set_state(CPU_STATE_OPERATING, ipl_cpu); >> +s390_cpu_set_state(CPU_INFOS390_STATE_OPERATING, ipl_cpu); > > Exposing the state as a QAPI enum has the unfortunate side effect of > that new name. It feels slightly awkward to me, as it is a state for > real decisions and not just for info statements... I asked Viktor to use the qapi enum instead of having two sets of defines that we need to keep in sync. (in fact 3, as the kernel kvm mpstate definition is also there). But yes, the INFO in that name is somewhat strange. No good idea though.
Re: [Qemu-devel] [PATCH v4 03/22] RISC-V CPU Core Definition
On Thu, 8 Feb 2018 15:19:13 +1300 Michael Clark wrote: > On Wed, Feb 7, 2018 at 4:03 AM, Igor Mammedov wrote: > > > On Tue, 6 Feb 2018 11:09:56 +1300 > > Michael Clark wrote: > > > > > On Tue, Feb 6, 2018 at 4:04 AM, Igor Mammedov > > wrote: > > > > > > > On Mon, 5 Feb 2018 19:22:28 +1300 > > > > Michael Clark wrote: > > > > > > > > > Add CPU state header, CPU definitions and initialization routines > > > > > > > > > > Signed-off-by: Michael Clark > > > > > --- > > > > > target/riscv/cpu.c | 385 ++ > > > > ++ > > > > > target/riscv/cpu.h | 256 + > > > > > target/riscv/cpu_bits.h | 417 ++ > > > > ++ > > > > > 3 files changed, 1058 insertions(+) > > > > > create mode 100644 target/riscv/cpu.c > > > > > create mode 100644 target/riscv/cpu.h > > > > > create mode 100644 target/riscv/cpu_bits.h > > > > > > > > > > diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c > > > > > new file mode 100644 > > > > > index 000..684b78b > > > > > --- /dev/null > > > > > +++ b/target/riscv/cpu.c > > > > [...] > > > > > + > > > > > +static const RISCVCPUInfo riscv_cpus[] = { > > > > > +#ifdef CONFIG_USER_ONLY > > > > > +{ TYPE_RISCV_CPU_ANY,riscv_any_cpu_init }, > > > > > +#else > > > > > +{ TYPE_RISCV_CPU_IMAFDCSU_PRIV_1_09, > > riscv_imafdcsu_priv1_9_cpu_init > > > > }, > > > > > +{ TYPE_RISCV_CPU_IMAFDCSU_PRIV_1_10, > > riscv_imafdcsu_priv1_10_cpu_init > > > > }, > > > > > +{ TYPE_RISCV_CPU_IMACU_PRIV_1_10, > > riscv_imacu_priv1_10_cpu_init > > > > }, > > > > > +{ TYPE_RISCV_CPU_IMAC_PRIV_1_10, > > riscv_imac_priv1_10_cpu_init }, > > > > > +#endif > > > > > +{ NULL, NULL } > > > > > +}; > > > > > + > > > > [...] > > > > > +static void cpu_register(const RISCVCPUInfo *info) > > > > > +{ > > > > > +TypeInfo type_info = { > > > > > +.name = info->name, > > > > > +.parent = TYPE_RISCV_CPU, > > > > > +.instance_size = sizeof(RISCVCPU), > > > > > +.instance_init = info->initfn, > > > > > +}; > > > > > + > > > > > +type_register(&type_info); > > > > > +} > > > > > + > > > > > +static const TypeInfo riscv_cpu_type_info = { > > > > > +.name = TYPE_RISCV_CPU, > > > > > +.parent = TYPE_CPU, > > > > > +.instance_size = sizeof(RISCVCPU), > > > > > +.instance_init = riscv_cpu_init, > > > > > +.abstract = false, > > > > > +.class_size = sizeof(RISCVCPUClass), > > > > > +.class_init = riscv_cpu_class_init, > > > > > +}; > > > > [...] > > > > > > > > > +static void riscv_cpu_register_types(void) > > > > > +{ > > > > > +const RISCVCPUInfo *info = riscv_cpus; > > > > > + > > > > > +type_register_static(&riscv_cpu_type_info); > > > > > + > > > > > +while (info->name) { > > > > > +cpu_register(info); > > > > > +info++; > > > > > +} > > > > > +} > > > > > + > > > > > +type_init(riscv_cpu_register_types) > > > > For simplistic type definitions like that, > > > > above parts should use DEFINE_TYPES(), see c6678108 for reference. > > > > > > > > > > > > > diff --git a/target/riscv/cpu.h b/target/riscv/cpu.h > > > > > new file mode 100644 > > > > > index 000..8b816ae > > > > > --- /dev/null > > > > > +++ b/target/riscv/cpu.h > > > > [...] > > > > > +#define TYPE_RISCV_CPU"riscv" > > > > > +#define TYPE_RISCV_CPU_ANY"riscv-any" > > > > > +#define TYPE_RISCV_CPU_IMAFDCSU_PRIV_1_09 "riscv-imafdcsu-priv1.9" > > > > > +#define TYPE_RISCV_CPU_IMAFDCSU_PRIV_1_10 "riscv-imafdcsu-priv1.10" > > > > > +#define TYPE_RISCV_CPU_IMACU_PRIV_1_10"riscv-imacu-priv1.10" > > > > > +#define TYPE_RISCV_CPU_IMAC_PRIV_1_10 "riscv-imac-priv1.10" Also you can use RISCV_CPU_TYPE_NAME() from blow to form above names, like: #define TYPE_RISCV_CPU"riscv-cpu" #define TYPE_RISCV_CPU_ANYRISCV_CPU_TYPE_NAME("any") ... then whatever naming format is required, you'd be able to change it just in RISCV_CPU_TYPE_NAME() without touching the rest. > > > > > + > > > > > +#define RISCV_CPU_TYPE_PREFIX TYPE_RISCV_CPU "-" > > > > > +#define RISCV_CPU_TYPE_NAME(name) (RISCV_CPU_TYPE_PREFIX name) > > > > it still uses prefix notation versus commonly used suffix in form of > > > > "targetFOO-cpu" > > > > this prefix approach would get in the way if we try to generalize > > > > naming <-> type conversion later[*]. > > > > So it would better to be consistent with approach qemu uses for cpu > > types > > > > (I believe power had prefix based pnv types but it has been fixed > > > > to common suffix based pattern later). > > > > > > > > * discussion on thread "[PATCH v5 0/6] Add a valid_cpu_types property" > > > > > > > > > > I can reverse them if needed, just it seems a little odd to have riscv on > > > the right-hand side of the extensions. I can do this in the
[Qemu-devel] [PATCH v6 01/28] migration: better error handling with QEMUFile
If the postcopy down due to some reason, we can always see this on dst: qemu-system-x86_64: RP: Received invalid message 0x length 0x However in most cases that's not the real issue. The problem is that qemu_get_be16() has no way to show whether the returned data is valid or not, and we are _always_ assuming it is valid. That's possibly not wise. The best approach to solve this would be: refactoring QEMUFile interface to allow the APIs to return error if there is. However it needs quite a bit of work and testing. For now, let's explicitly check the validity first before using the data in all places for qemu_get_*(). This patch tries to fix most of the cases I can see. Only if we are with this, can we make sure we are processing the valid data, and also can we make sure we can capture the channel down events correctly. Reviewed-by: Dr. David Alan Gilbert Signed-off-by: Peter Xu --- migration/migration.c | 5 + migration/ram.c | 21 + migration/savevm.c| 40 ++-- 3 files changed, 60 insertions(+), 6 deletions(-) diff --git a/migration/migration.c b/migration/migration.c index dec406d25d..9d2660dd6f 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -1707,6 +1707,11 @@ static void *source_return_path_thread(void *opaque) header_type = qemu_get_be16(rp); header_len = qemu_get_be16(rp); +if (qemu_file_get_error(rp)) { +mark_source_rp_bad(ms); +goto out; +} + if (header_type >= MIG_RP_MSG_MAX || header_type == MIG_RP_MSG_INVALID) { error_report("RP: Received invalid message 0x%04x length 0x%04x", diff --git a/migration/ram.c b/migration/ram.c index 5a109efeda..09e8013501 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -2696,6 +2696,16 @@ static int ram_load_postcopy(QEMUFile *f) uint8_t ch; addr = qemu_get_be64(f); + +/* + * If qemu file error, we should stop here, and then "addr" + * may be invalid + */ +ret = qemu_file_get_error(f); +if (ret) { +break; +} + flags = addr & ~TARGET_PAGE_MASK; addr &= TARGET_PAGE_MASK; @@ -2776,9 +2786,15 @@ static int ram_load_postcopy(QEMUFile *f) error_report("Unknown combination of migration flags: %#x" " (postcopy mode)", flags); ret = -EINVAL; +break; +} + +/* Detect for any possible file errors */ +if (!ret && qemu_file_get_error(f)) { +ret = qemu_file_get_error(f); } -if (place_needed) { +if (!ret && place_needed) { /* This gets called at the last target page in the host page */ void *place_dest = host + TARGET_PAGE_SIZE - block->page_size; @@ -2790,9 +2806,6 @@ static int ram_load_postcopy(QEMUFile *f) place_source, block); } } -if (!ret) { -ret = qemu_file_get_error(f); -} } return ret; diff --git a/migration/savevm.c b/migration/savevm.c index f202c3de3a..76fcc2b1c3 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -1780,6 +1780,11 @@ static int loadvm_process_command(QEMUFile *f) cmd = qemu_get_be16(f); len = qemu_get_be16(f); +/* Check validity before continue processing of cmds */ +if (qemu_file_get_error(f)) { +return qemu_file_get_error(f); +} + trace_loadvm_process_command(cmd, len); if (cmd >= MIG_CMD_MAX || cmd == MIG_CMD_INVALID) { error_report("MIG_CMD 0x%x unknown (len 0x%x)", cmd, len); @@ -1845,6 +1850,7 @@ static int loadvm_process_command(QEMUFile *f) */ static bool check_section_footer(QEMUFile *f, SaveStateEntry *se) { +int ret; uint8_t read_mark; uint32_t read_section_id; @@ -1855,6 +1861,13 @@ static bool check_section_footer(QEMUFile *f, SaveStateEntry *se) read_mark = qemu_get_byte(f); +ret = qemu_file_get_error(f); +if (ret) { +error_report("%s: Read section footer failed: %d", + __func__, ret); +return false; +} + if (read_mark != QEMU_VM_SECTION_FOOTER) { error_report("Missing section footer for %s", se->idstr); return false; @@ -1890,6 +1903,13 @@ qemu_loadvm_section_start_full(QEMUFile *f, MigrationIncomingState *mis) instance_id = qemu_get_be32(f); version_id = qemu_get_be32(f); +ret = qemu_file_get_error(f); +if (ret) { +error_report("%s: Failed to read instance/version ID: %d", + __func__, ret); +return ret; +} + trace_qemu_loadvm_state_section_startfull(section_id, idstr, instance_id, version_id); /* Find savevm section */ @@ -1937,6 +1957,13 @@ qemu_loadvm_section_part_end(QEMUFile *f, MigrationIncomingState *mis) section_id =
[Qemu-devel] [PATCH v6 03/28] migration: provide postcopy_fault_thread_notify()
A general helper to notify the fault thread. Reviewed-by: Dr. David Alan Gilbert Signed-off-by: Peter Xu --- migration/postcopy-ram.c | 35 --- migration/postcopy-ram.h | 2 ++ 2 files changed, 22 insertions(+), 15 deletions(-) diff --git a/migration/postcopy-ram.c b/migration/postcopy-ram.c index 9ad4f20f82..032abfbf1a 100644 --- a/migration/postcopy-ram.c +++ b/migration/postcopy-ram.c @@ -377,25 +377,15 @@ int postcopy_ram_incoming_cleanup(MigrationIncomingState *mis) trace_postcopy_ram_incoming_cleanup_entry(); if (mis->have_fault_thread) { -uint64_t tmp64; - if (qemu_ram_foreach_block(cleanup_range, mis)) { return -1; } -/* - * Tell the fault_thread to exit, it's an eventfd that should - * currently be at 0, we're going to increment it to 1 - */ -tmp64 = 1; +/* Let the fault thread quit */ atomic_set(&mis->fault_thread_quit, 1); -if (write(mis->userfault_event_fd, &tmp64, 8) == 8) { -trace_postcopy_ram_incoming_cleanup_join(); -qemu_thread_join(&mis->fault_thread); -} else { -/* Not much we can do here, but may as well report it */ -error_report("%s: incrementing userfault_event_fd: %s", __func__, - strerror(errno)); -} +postcopy_fault_thread_notify(mis); +trace_postcopy_ram_incoming_cleanup_join(); +qemu_thread_join(&mis->fault_thread); + trace_postcopy_ram_incoming_cleanup_closeuf(); close(mis->userfault_fd); close(mis->userfault_event_fd); @@ -824,6 +814,21 @@ void *postcopy_get_tmp_page(MigrationIncomingState *mis) /* - */ +void postcopy_fault_thread_notify(MigrationIncomingState *mis) +{ +uint64_t tmp64 = 1; + +/* + * Wakeup the fault_thread. It's an eventfd that should currently + * be at 0, we're going to increment it to 1 + */ +if (write(mis->userfault_event_fd, &tmp64, 8) != 8) { +/* Not much we can do here, but may as well report it */ +error_report("%s: incrementing failed: %s", __func__, + strerror(errno)); +} +} + /** * postcopy_discard_send_init: Called at the start of each RAMBlock before * asking to discard individual ranges. diff --git a/migration/postcopy-ram.h b/migration/postcopy-ram.h index 77ea0fd264..14f6cadcbd 100644 --- a/migration/postcopy-ram.h +++ b/migration/postcopy-ram.h @@ -114,4 +114,6 @@ PostcopyState postcopy_state_get(void); /* Set the state and return the old state */ PostcopyState postcopy_state_set(PostcopyState new_state); +void postcopy_fault_thread_notify(MigrationIncomingState *mis); + #endif -- 2.14.3
[Qemu-devel] [PATCH v6 07/28] migration: allow src return path to pause
Let the thread pause for network issues. Reviewed-by: Dr. David Alan Gilbert Signed-off-by: Peter Xu --- migration/migration.c | 35 +-- migration/migration.h | 1 + migration/trace-events | 2 ++ 3 files changed, 36 insertions(+), 2 deletions(-) diff --git a/migration/migration.c b/migration/migration.c index fc0d0e0e31..5c3b701102 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -1688,6 +1688,18 @@ static void migrate_handle_rp_req_pages(MigrationState *ms, const char* rbname, } } +/* Return true to retry, false to quit */ +static bool postcopy_pause_return_path_thread(MigrationState *s) +{ +trace_postcopy_pause_return_path(); + +qemu_sem_wait(&s->postcopy_pause_rp_sem); + +trace_postcopy_pause_return_path_continued(); + +return true; +} + /* * Handles messages sent on the return path towards the source VM * @@ -1704,6 +1716,8 @@ static void *source_return_path_thread(void *opaque) int res; trace_source_return_path_thread_entry(); + +retry: while (!ms->rp_state.error && !qemu_file_get_error(rp) && migration_is_setup_or_active(ms->state)) { trace_source_return_path_thread_loop_top(); @@ -1795,13 +1809,28 @@ static void *source_return_path_thread(void *opaque) break; } } -if (qemu_file_get_error(rp)) { + +out: +res = qemu_file_get_error(rp); +if (res) { +if (res == -EIO) { +/* + * Maybe there is something we can do: it looks like a + * network down issue, and we pause for a recovery. + */ +if (postcopy_pause_return_path_thread(ms)) { +/* Reload rp, reset the rest */ +rp = ms->rp_state.from_dst_file; +ms->rp_state.error = false; +goto retry; +} +} + trace_source_return_path_thread_bad_end(); mark_source_rp_bad(ms); } trace_source_return_path_thread_end(); -out: ms->rp_state.from_dst_file = NULL; qemu_fclose(rp); return NULL; @@ -2609,6 +2638,7 @@ static void migration_instance_finalize(Object *obj) g_free(params->tls_creds); qemu_sem_destroy(&ms->pause_sem); qemu_sem_destroy(&ms->postcopy_pause_sem); +qemu_sem_destroy(&ms->postcopy_pause_rp_sem); } static void migration_instance_init(Object *obj) @@ -2639,6 +2669,7 @@ static void migration_instance_init(Object *obj) params->has_xbzrle_cache_size = true; qemu_sem_init(&ms->postcopy_pause_sem, 0); +qemu_sem_init(&ms->postcopy_pause_rp_sem, 0); } /* diff --git a/migration/migration.h b/migration/migration.h index 27ba256c40..765bd9f5bd 100644 --- a/migration/migration.h +++ b/migration/migration.h @@ -184,6 +184,7 @@ struct MigrationState /* Needed by postcopy-pause state */ QemuSemaphore postcopy_pause_sem; +QemuSemaphore postcopy_pause_rp_sem; }; void migrate_set_state(int *state, int old_state, int new_state); diff --git a/migration/trace-events b/migration/trace-events index 8685a62c98..ca17a70222 100644 --- a/migration/trace-events +++ b/migration/trace-events @@ -99,6 +99,8 @@ migration_thread_setup_complete(void) "" open_return_path_on_source(void) "" open_return_path_on_source_continue(void) "" postcopy_start(void) "" +postcopy_pause_return_path(void) "" +postcopy_pause_return_path_continued(void) "" postcopy_pause_continued(void) "" postcopy_pause_incoming(void) "" postcopy_pause_incoming_continued(void) "" -- 2.14.3
[Qemu-devel] [PATCH v6 08/28] migration: allow send_rq to fail
We will not allow failures to happen when sending data from destination to source via the return path. However it is possible that there can be errors along the way. This patch allows the migrate_send_rp_message() to return error when it happens, and further extended it to migrate_send_rp_req_pages(). Reviewed-by: Dr. David Alan Gilbert Signed-off-by: Peter Xu --- migration/migration.c | 35 --- migration/migration.h | 2 +- 2 files changed, 29 insertions(+), 8 deletions(-) diff --git a/migration/migration.c b/migration/migration.c index 5c3b701102..b3899c2b6e 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -204,17 +204,35 @@ static void deferred_incoming_migration(Error **errp) * Send a message on the return channel back to the source * of the migration. */ -static void migrate_send_rp_message(MigrationIncomingState *mis, -enum mig_rp_message_type message_type, -uint16_t len, void *data) +static int migrate_send_rp_message(MigrationIncomingState *mis, + enum mig_rp_message_type message_type, + uint16_t len, void *data) { +int ret = 0; + trace_migrate_send_rp_message((int)message_type, len); qemu_mutex_lock(&mis->rp_mutex); + +/* + * It's possible that the file handle got lost due to network + * failures. + */ +if (!mis->to_src_file) { +ret = -EIO; +goto error; +} + qemu_put_be16(mis->to_src_file, (unsigned int)message_type); qemu_put_be16(mis->to_src_file, len); qemu_put_buffer(mis->to_src_file, data, len); qemu_fflush(mis->to_src_file); + +/* It's possible that qemu file got error during sending */ +ret = qemu_file_get_error(mis->to_src_file); + +error: qemu_mutex_unlock(&mis->rp_mutex); +return ret; } /* Request a range of pages from the source VM at the given @@ -224,11 +242,12 @@ static void migrate_send_rp_message(MigrationIncomingState *mis, * Start: Address offset within the RB * Len: Length in bytes required - must be a multiple of pagesize */ -void migrate_send_rp_req_pages(MigrationIncomingState *mis, const char *rbname, - ram_addr_t start, size_t len) +int migrate_send_rp_req_pages(MigrationIncomingState *mis, const char *rbname, + ram_addr_t start, size_t len) { uint8_t bufc[12 + 1 + 255]; /* start (8), len (4), rbname up to 256 */ size_t msglen = 12; /* start + len */ +enum mig_rp_message_type msg_type; *(uint64_t *)bufc = cpu_to_be64((uint64_t)start); *(uint32_t *)(bufc + 8) = cpu_to_be32((uint32_t)len); @@ -240,10 +259,12 @@ void migrate_send_rp_req_pages(MigrationIncomingState *mis, const char *rbname, bufc[msglen++] = rbname_len; memcpy(bufc + msglen, rbname, rbname_len); msglen += rbname_len; -migrate_send_rp_message(mis, MIG_RP_MSG_REQ_PAGES_ID, msglen, bufc); +msg_type = MIG_RP_MSG_REQ_PAGES_ID; } else { -migrate_send_rp_message(mis, MIG_RP_MSG_REQ_PAGES, msglen, bufc); +msg_type = MIG_RP_MSG_REQ_PAGES; } + +return migrate_send_rp_message(mis, msg_type, msglen, bufc); } void qemu_start_incoming_migration(const char *uri, Error **errp) diff --git a/migration/migration.h b/migration/migration.h index 765bd9f5bd..ecdb38ee53 100644 --- a/migration/migration.h +++ b/migration/migration.h @@ -238,7 +238,7 @@ void migrate_send_rp_shut(MigrationIncomingState *mis, uint32_t value); void migrate_send_rp_pong(MigrationIncomingState *mis, uint32_t value); -void migrate_send_rp_req_pages(MigrationIncomingState *mis, const char* rbname, +int migrate_send_rp_req_pages(MigrationIncomingState *mis, const char* rbname, ram_addr_t start, size_t len); #endif -- 2.14.3
[Qemu-devel] [PATCH v6 02/28] migration: reuse mis->userfault_quit_fd
It was only used for quitting the page fault thread before. Let it be something more useful - now we can use it to notify a "wake" for the page fault thread (for any reason), and it only means "quit" if the fault_thread_quit is set. Since we changed what it does, renaming it to userfault_event_fd. Reviewed-by: Dr. David Alan Gilbert Signed-off-by: Peter Xu --- migration/migration.h| 6 -- migration/postcopy-ram.c | 29 - 2 files changed, 24 insertions(+), 11 deletions(-) diff --git a/migration/migration.h b/migration/migration.h index d3b214e5ba..eb36ea9278 100644 --- a/migration/migration.h +++ b/migration/migration.h @@ -36,6 +36,8 @@ struct MigrationIncomingState { bool have_fault_thread; QemuThread fault_thread; QemuSemaphore fault_thread_sem; +/* Set this when we want the fault thread to quit */ +bool fault_thread_quit; bool have_listen_thread; QemuThread listen_thread; @@ -43,8 +45,8 @@ struct MigrationIncomingState { /* For the kernel to send us notifications */ int userfault_fd; -/* To tell the fault_thread to quit */ -int userfault_quit_fd; +/* To notify the fault_thread to wake, e.g., when need to quit */ +int userfault_event_fd; QEMUFile *to_src_file; QemuMutex rp_mutex;/* We send replies from multiple threads */ void *postcopy_tmp_page; diff --git a/migration/postcopy-ram.c b/migration/postcopy-ram.c index bec6c2c66b..9ad4f20f82 100644 --- a/migration/postcopy-ram.c +++ b/migration/postcopy-ram.c @@ -387,17 +387,18 @@ int postcopy_ram_incoming_cleanup(MigrationIncomingState *mis) * currently be at 0, we're going to increment it to 1 */ tmp64 = 1; -if (write(mis->userfault_quit_fd, &tmp64, 8) == 8) { +atomic_set(&mis->fault_thread_quit, 1); +if (write(mis->userfault_event_fd, &tmp64, 8) == 8) { trace_postcopy_ram_incoming_cleanup_join(); qemu_thread_join(&mis->fault_thread); } else { /* Not much we can do here, but may as well report it */ -error_report("%s: incrementing userfault_quit_fd: %s", __func__, +error_report("%s: incrementing userfault_event_fd: %s", __func__, strerror(errno)); } trace_postcopy_ram_incoming_cleanup_closeuf(); close(mis->userfault_fd); -close(mis->userfault_quit_fd); +close(mis->userfault_event_fd); mis->have_fault_thread = false; } @@ -520,7 +521,7 @@ static void *postcopy_ram_fault_thread(void *opaque) pfd[0].fd = mis->userfault_fd; pfd[0].events = POLLIN; pfd[0].revents = 0; -pfd[1].fd = mis->userfault_quit_fd; +pfd[1].fd = mis->userfault_event_fd; pfd[1].events = POLLIN; /* Waiting for eventfd to go positive */ pfd[1].revents = 0; @@ -530,8 +531,18 @@ static void *postcopy_ram_fault_thread(void *opaque) } if (pfd[1].revents) { -trace_postcopy_ram_fault_thread_quit(); -break; +uint64_t tmp64 = 0; + +/* Consume the signal */ +if (read(mis->userfault_event_fd, &tmp64, 8) != 8) { +/* Nothing obviously nicer than posting this error. */ +error_report("%s: read() failed", __func__); +} + +if (atomic_read(&mis->fault_thread_quit)) { +trace_postcopy_ram_fault_thread_quit(); +break; +} } ret = read(mis->userfault_fd, &msg, sizeof(msg)); @@ -610,9 +621,9 @@ int postcopy_ram_enable_notify(MigrationIncomingState *mis) } /* Now an eventfd we use to tell the fault-thread to quit */ -mis->userfault_quit_fd = eventfd(0, EFD_CLOEXEC); -if (mis->userfault_quit_fd == -1) { -error_report("%s: Opening userfault_quit_fd: %s", __func__, +mis->userfault_event_fd = eventfd(0, EFD_CLOEXEC); +if (mis->userfault_event_fd == -1) { +error_report("%s: Opening userfault_event_fd: %s", __func__, strerror(errno)); close(mis->userfault_fd); return -1; -- 2.14.3
[Qemu-devel] [PATCH v6 00/28] Migration: postcopy failure recovery
Tree is pushed here for better reference and testing (online tree includes monitor OOB series): https://github.com/xzpeter/qemu/tree/postcopy-recovery-support This version added back the migrate-pause command, and let it to be run on either side of migration. Meanwhile, fixed a tricky error on source that RAMState.f is not setup correctly after resume. >From this version, testing is carried out using the mig_mon tool with command during migration: $ mig_mon mm_dirty 512 It means dirtying 512MB memory using maximum dirty rate, which will also verify the memory during dirtying. The tool can be found at: https://github.com/xzpeter/clibs/blob/master/bsd/mig_mon/mig_mon.c To test this two series altogether, please checkout above tree and build. Note: to test on small and single host, one need to disable full bandwidth postcopy migration otherwise it'll complete very fast. Basically a simple patch like this would help: diff --git a/migration/migration.c b/migration/migration.c index 4de3b551fe..c0206023d7 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -1904,7 +1904,7 @@ static int postcopy_start(MigrationState *ms, bool *old_vm_running) * will notice we're in POSTCOPY_ACTIVE and not actually * wrap their state up here */ -qemu_file_set_rate_limit(ms->to_dst_file, INT64_MAX); +// qemu_file_set_rate_limit(ms->to_dst_file, INT64_MAX); if (migrate_postcopy_ram()) { /* Ping just for debugging, helps line traces up */ qemu_savevm_send_ping(ms->to_dst_file, 2); This patch is included already in above github tree. Please feel free to drop this patch when want to test on big machines and between real hosts. Detailed Test Procedures (QMP only) === 1. start source QEMU. $qemu -M q35,kernel-irqchip=split -enable-kvm -snapshot \ -smp 4 -m 1G -qmp stdio \ -name peter-vm,debug-threads=on \ -netdev user,id=net0 \ -device e1000,netdev=net0 \ -global migration.x-max-bandwidth=4096 \ -global migration.x-postcopy-ram=on \ /images/fedora-25.qcow2 2. start destination QEMU. $qemu -M q35,kernel-irqchip=split -enable-kvm -snapshot \ -smp 4 -m 1G -qmp stdio \ -name peter-vm,debug-threads=on \ -netdev user,id=net0 \ -device e1000,netdev=net0 \ -global migration.x-max-bandwidth=4096 \ -global migration.x-postcopy-ram=on \ -incoming tcp:0.0.0.0: \ /images/fedora-25.qcow2 3. On source, do QMP handshake as normal: {"execute": "qmp_capabilities"} {"return": {}} 4. On destination, do QMP handshake to enable OOB: {"execute": "qmp_capabilities", "arguments": { "enable": [ "oob" ] } } {"return": {}} 5. On source, trigger initial migrate command, switch to postcopy: {"execute": "migrate", "arguments": { "uri": "tcp:localhost:" } } {"return": {}} {"execute": "query-migrate"} {"return": {"expected-downtime": 300, "status": "active", ...}} {"execute": "migrate-start-postcopy"} {"return": {}} {"timestamp": {"seconds": 1512454728, "microseconds": 768096}, "event": "STOP"} {"execute": "query-migrate"} {"return": {"expected-downtime": 44472, "status": "postcopy-active", ...}} 6. On source, manually trigger a "fake network down" using "migrate-cancel" command: {"execute": "migrate_cancel"} {"return": {}} During postcopy, it'll not really cancel the migration, but pause it. On both sides, we should see this on stderr: qemu-system-x86_64: Detected IO failure for postcopy. Migration paused. It means now both sides are in postcopy-pause state. 7. (Optional) On destination side, let's try to hang the main thread using the new x-oob-test command, providing a "lock=true" param: {"execute": "x-oob-test", "id": "lock-dispatcher-cmd", "arguments": { "lock": true } } After sending this command, we should not see any "return", because main thread is blocked already. But we can still use the monitor since the monitor now has dedicated IOThread. 8. On destination side, provide a new incoming port using the new command "migrate-recover" (note that if step 7 is carried out, we _must_ use OOB form, otherwise the command will hang. With OOB, this command will return immediately): {"execute": "migrate-recover", "id": "recover-cmd", "arguments": { "uri": "tcp:localhost:5556" }, "control": { "run-oob": true } } {"timestamp": {"seconds": 1512454976, "microseconds": 186053}, "event": "MIGRATION", "data": {"status": "setup"}} {"return": {}, "id": "recover-cmd"} We can see that the command will success even if main thread is locked up. 9. (Optional) This step is only needed if step 7 is carried out. On destination, let's unlock the main thread before resuming the migration, this time with "lock=false" to unlock the main thread (since system running needs the main thread). Note that we _must_ use OOB command here too: {"execute": "x-oob-test", "id": "u
[Qemu-devel] [PATCH v6 13/28] migration: new state "postcopy-recover"
Introducing new migration state "postcopy-recover". If a migration procedure is paused and the connection is rebuilt afterward successfully, we'll switch the source VM state from "postcopy-paused" to the new state "postcopy-recover", then we'll do the resume logic in the migration thread (along with the return path thread). This patch only do the state switch on source side. Another following up patch will handle the state switching on destination side using the same status bit. Reviewed-by: Dr. David Alan Gilbert Signed-off-by: Peter Xu --- migration/migration.c | 76 ++- qapi/migration.json | 4 ++- 2 files changed, 60 insertions(+), 20 deletions(-) diff --git a/migration/migration.c b/migration/migration.c index 2088a1d1bf..6c5e422616 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -559,6 +559,7 @@ static bool migration_is_setup_or_active(int state) case MIGRATION_STATUS_ACTIVE: case MIGRATION_STATUS_POSTCOPY_ACTIVE: case MIGRATION_STATUS_POSTCOPY_PAUSED: +case MIGRATION_STATUS_POSTCOPY_RECOVER: case MIGRATION_STATUS_SETUP: case MIGRATION_STATUS_PRE_SWITCHOVER: case MIGRATION_STATUS_DEVICE: @@ -639,6 +640,7 @@ MigrationInfo *qmp_query_migrate(Error **errp) case MIGRATION_STATUS_PRE_SWITCHOVER: case MIGRATION_STATUS_DEVICE: case MIGRATION_STATUS_POSTCOPY_PAUSED: +case MIGRATION_STATUS_POSTCOPY_RECOVER: /* TODO add some postcopy stats */ info->has_status = true; info->has_total_time = true; @@ -2245,6 +2247,13 @@ typedef enum MigThrError { MIG_THR_ERR_FATAL = 2, } MigThrError; +/* Return zero if success, or <0 for error */ +static int postcopy_do_resume(MigrationState *s) +{ +/* TODO: do the resume logic */ +return 0; +} + /* * We don't return until we are in a safe state to continue current * postcopy migration. Returns MIG_THR_ERR_RECOVERED if recovered, or @@ -2253,29 +2262,55 @@ typedef enum MigThrError { static MigThrError postcopy_pause(MigrationState *s) { assert(s->state == MIGRATION_STATUS_POSTCOPY_ACTIVE); -migrate_set_state(&s->state, MIGRATION_STATUS_POSTCOPY_ACTIVE, - MIGRATION_STATUS_POSTCOPY_PAUSED); -/* Current channel is possibly broken. Release it. */ -assert(s->to_dst_file); -qemu_file_shutdown(s->to_dst_file); -qemu_fclose(s->to_dst_file); -s->to_dst_file = NULL; +while (true) { +migrate_set_state(&s->state, s->state, + MIGRATION_STATUS_POSTCOPY_PAUSED); -error_report("Detected IO failure for postcopy. " - "Migration paused."); +/* Current channel is possibly broken. Release it. */ +assert(s->to_dst_file); +qemu_file_shutdown(s->to_dst_file); +qemu_fclose(s->to_dst_file); +s->to_dst_file = NULL; -/* - * We wait until things fixed up. Then someone will setup the - * status back for us. - */ -while (s->state == MIGRATION_STATUS_POSTCOPY_PAUSED) { -qemu_sem_wait(&s->postcopy_pause_sem); -} +error_report("Detected IO failure for postcopy. " + "Migration paused."); -trace_postcopy_pause_continued(); +/* + * We wait until things fixed up. Then someone will setup the + * status back for us. + */ +while (s->state == MIGRATION_STATUS_POSTCOPY_PAUSED) { +qemu_sem_wait(&s->postcopy_pause_sem); +} + +if (s->state == MIGRATION_STATUS_POSTCOPY_RECOVER) { +/* Woken up by a recover procedure. Give it a shot */ -return MIG_THR_ERR_RECOVERED; +/* + * Firstly, let's wake up the return path now, with a new + * return path channel. + */ +qemu_sem_post(&s->postcopy_pause_rp_sem); + +/* Do the resume logic */ +if (postcopy_do_resume(s) == 0) { +/* Let's continue! */ +trace_postcopy_pause_continued(); +return MIG_THR_ERR_RECOVERED; +} else { +/* + * Something wrong happened during the recovery, let's + * pause again. Pause is always better than throwing + * data away. + */ +continue; +} +} else { +/* This is not right... Time to quit. */ +return MIG_THR_ERR_FATAL; +} +} } static MigThrError migration_detect_error(MigrationState *s) @@ -2595,7 +2630,10 @@ void migrate_fd_connect(MigrationState *s, Error *error_in) } if (resume) { -/* TODO: do the resume logic */ +/* Wakeup the main migration thread to do the recovery */ +migrate_set_state(&s->state, MIGRATION_STATUS_POSTCOPY_PAUSED, + MIGRATION_STATUS_POSTCOPY_RECOVER); +qemu_sem_post(&s->postcopy_pause_sem); ret
[Qemu-devel] [PATCH v6 10/28] qmp: hmp: add migrate "resume" option
It will be used when we want to resume one paused migration. Reviewed-by: Dr. David Alan Gilbert Signed-off-by: Peter Xu --- hmp-commands.hx | 7 --- hmp.c | 4 +++- migration/migration.c | 2 +- qapi/migration.json | 5 - 4 files changed, 12 insertions(+), 6 deletions(-) diff --git a/hmp-commands.hx b/hmp-commands.hx index 15620c94d3..28ed5a7a13 100644 --- a/hmp-commands.hx +++ b/hmp-commands.hx @@ -895,13 +895,14 @@ ETEXI { .name = "migrate", -.args_type = "detach:-d,blk:-b,inc:-i,uri:s", -.params = "[-d] [-b] [-i] uri", +.args_type = "detach:-d,blk:-b,inc:-i,resume:-r,uri:s", +.params = "[-d] [-b] [-i] [-r] uri", .help = "migrate to URI (using -d to not wait for completion)" "\n\t\t\t -b for migration without shared storage with" " full copy of disk\n\t\t\t -i for migration without " "shared storage with incremental copy of disk " - "(base image shared between src and destination)", + "(base image shared between src and destination)" + "\n\t\t\t -r to resume a paused migration", .cmd= hmp_migrate, }, diff --git a/hmp.c b/hmp.c index b3de32d219..6f8eec8365 100644 --- a/hmp.c +++ b/hmp.c @@ -1921,10 +1921,12 @@ void hmp_migrate(Monitor *mon, const QDict *qdict) bool detach = qdict_get_try_bool(qdict, "detach", false); bool blk = qdict_get_try_bool(qdict, "blk", false); bool inc = qdict_get_try_bool(qdict, "inc", false); +bool resume = qdict_get_try_bool(qdict, "resume", false); const char *uri = qdict_get_str(qdict, "uri"); Error *err = NULL; -qmp_migrate(uri, !!blk, blk, !!inc, inc, false, false, &err); +qmp_migrate(uri, !!blk, blk, !!inc, inc, +false, false, true, resume, &err); if (err) { hmp_handle_error(mon, &err); return; diff --git a/migration/migration.c b/migration/migration.c index 4a8c873b52..dbcc3f6296 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -1362,7 +1362,7 @@ bool migration_is_blocked(Error **errp) void qmp_migrate(const char *uri, bool has_blk, bool blk, bool has_inc, bool inc, bool has_detach, bool detach, - Error **errp) + bool has_resume, bool resume, Error **errp) { Error *local_err = NULL; MigrationState *s = migrate_get_current(); diff --git a/qapi/migration.json b/qapi/migration.json index 49d27f3b29..9d6ccfec6b 100644 --- a/qapi/migration.json +++ b/qapi/migration.json @@ -1012,6 +1012,8 @@ # @detach: this argument exists only for compatibility reasons and # is ignored by QEMU # +# @resume: resume one paused migration, default "off". (since 2.12) +# # Returns: nothing on success # # Since: 0.14.0 @@ -1033,7 +1035,8 @@ # ## { 'command': 'migrate', - 'data': {'uri': 'str', '*blk': 'bool', '*inc': 'bool', '*detach': 'bool' } } + 'data': {'uri': 'str', '*blk': 'bool', '*inc': 'bool', + '*detach': 'bool', '*resume': 'bool' } } ## # @migrate-incoming: -- 2.14.3
[Qemu-devel] [PATCH v6 05/28] migration: implement "postcopy-pause" src logic
Now when network down for postcopy, the source side will not fail the migration. Instead we convert the status into this new paused state, and we will try to wait for a rescue in the future. If a recovery is detected, migration_thread() will reset its local variables to prepare for that. Reviewed-by: Dr. David Alan Gilbert Signed-off-by: Peter Xu --- migration/migration.c | 99 +++--- migration/migration.h | 3 ++ migration/trace-events | 1 + 3 files changed, 97 insertions(+), 6 deletions(-) diff --git a/migration/migration.c b/migration/migration.c index e8a79bb181..de5ee9c1d4 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -2154,6 +2154,80 @@ bool migrate_colo_enabled(void) return s->enabled_capabilities[MIGRATION_CAPABILITY_X_COLO]; } +typedef enum MigThrError { +/* No error detected */ +MIG_THR_ERR_NONE = 0, +/* Detected error, but resumed successfully */ +MIG_THR_ERR_RECOVERED = 1, +/* Detected fatal error, need to exit */ +MIG_THR_ERR_FATAL = 2, +} MigThrError; + +/* + * We don't return until we are in a safe state to continue current + * postcopy migration. Returns MIG_THR_ERR_RECOVERED if recovered, or + * MIG_THR_ERR_FATAL if unrecovery failure happened. + */ +static MigThrError postcopy_pause(MigrationState *s) +{ +assert(s->state == MIGRATION_STATUS_POSTCOPY_ACTIVE); +migrate_set_state(&s->state, MIGRATION_STATUS_POSTCOPY_ACTIVE, + MIGRATION_STATUS_POSTCOPY_PAUSED); + +/* Current channel is possibly broken. Release it. */ +assert(s->to_dst_file); +qemu_file_shutdown(s->to_dst_file); +qemu_fclose(s->to_dst_file); +s->to_dst_file = NULL; + +error_report("Detected IO failure for postcopy. " + "Migration paused."); + +/* + * We wait until things fixed up. Then someone will setup the + * status back for us. + */ +while (s->state == MIGRATION_STATUS_POSTCOPY_PAUSED) { +qemu_sem_wait(&s->postcopy_pause_sem); +} + +trace_postcopy_pause_continued(); + +return MIG_THR_ERR_RECOVERED; +} + +static MigThrError migration_detect_error(MigrationState *s) +{ +int ret; + +/* Try to detect any file errors */ +ret = qemu_file_get_error(s->to_dst_file); + +if (!ret) { +/* Everything is fine */ +return MIG_THR_ERR_NONE; +} + +if (s->state == MIGRATION_STATUS_POSTCOPY_ACTIVE && ret == -EIO) { +/* + * For postcopy, we allow the network to be down for a + * while. After that, it can be continued by a + * recovery phase. + */ +return postcopy_pause(s); +} else { +/* + * For precopy (or postcopy with error outside IO), we fail + * with no time. + */ +migrate_set_state(&s->state, s->state, MIGRATION_STATUS_FAILED); +trace_migration_thread_file_err(); + +/* Time to stop the migration, now. */ +return MIG_THR_ERR_FATAL; +} +} + static void migration_calculate_complete(MigrationState *s) { uint64_t bytes = qemu_ftell(s->to_dst_file); @@ -2310,6 +2384,7 @@ static void *migration_thread(void *opaque) { MigrationState *s = opaque; int64_t setup_start = qemu_clock_get_ms(QEMU_CLOCK_HOST); +MigThrError thr_error; rcu_register_thread(); @@ -2359,13 +2434,22 @@ static void *migration_thread(void *opaque) } } -if (qemu_file_get_error(s->to_dst_file)) { -if (migration_is_setup_or_active(s->state)) { -migrate_set_state(&s->state, s->state, - MIGRATION_STATUS_FAILED); -} -trace_migration_thread_file_err(); +/* + * Try to detect any kind of failures, and see whether we + * should stop the migration now. + */ +thr_error = migration_detect_error(s); +if (thr_error == MIG_THR_ERR_FATAL) { +/* Stop migration */ break; +} else if (thr_error == MIG_THR_ERR_RECOVERED) { +/* + * Just recovered from a e.g. network failure, reset all + * the local variables. This is important to avoid + * breaking transferred_bytes and bandwidth calculation + */ +s->iteration_start_time = qemu_clock_get_ms(QEMU_CLOCK_REALTIME); +s->iteration_initial_bytes = 0; } current_time = qemu_clock_get_ms(QEMU_CLOCK_REALTIME); @@ -2523,6 +2607,7 @@ static void migration_instance_finalize(Object *obj) g_free(params->tls_hostname); g_free(params->tls_creds); qemu_sem_destroy(&ms->pause_sem); +qemu_sem_destroy(&ms->postcopy_pause_sem); } static void migration_instance_init(Object *obj) @@ -2551,6 +2636,8 @@ static void migration_instance_init(Object *obj) params->has_x_multifd_channels = true; params->has_x_multifd_page_count = true; params->has_
[Qemu-devel] [PATCH v6 15/28] migration: new cmd MIG_CMD_RECV_BITMAP
Add a new vm command MIG_CMD_RECV_BITMAP to request received bitmap for one ramblock. Reviewed-by: Dr. David Alan Gilbert Signed-off-by: Peter Xu --- migration/savevm.c | 61 ++ migration/savevm.h | 1 + migration/trace-events | 2 ++ 3 files changed, 64 insertions(+) diff --git a/migration/savevm.c b/migration/savevm.c index 4a75e66aab..7abd510b0a 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -78,6 +78,7 @@ enum qemu_vm_cmd { were previously sent during precopy but are dirty. */ MIG_CMD_PACKAGED, /* Send a wrapped stream within this stream */ +MIG_CMD_RECV_BITMAP, /* Request for recved bitmap on dst */ MIG_CMD_MAX }; @@ -95,6 +96,7 @@ static struct mig_cmd_args { [MIG_CMD_POSTCOPY_RAM_DISCARD] = { .len = -1, .name = "POSTCOPY_RAM_DISCARD" }, [MIG_CMD_PACKAGED] = { .len = 4, .name = "PACKAGED" }, +[MIG_CMD_RECV_BITMAP] = { .len = -1, .name = "RECV_BITMAP" }, [MIG_CMD_MAX] = { .len = -1, .name = "MAX" }, }; @@ -953,6 +955,19 @@ void qemu_savevm_send_postcopy_run(QEMUFile *f) qemu_savevm_command_send(f, MIG_CMD_POSTCOPY_RUN, 0, NULL); } +void qemu_savevm_send_recv_bitmap(QEMUFile *f, char *block_name) +{ +size_t len; +char buf[256]; + +trace_savevm_send_recv_bitmap(block_name); + +buf[0] = len = strlen(block_name); +memcpy(buf + 1, block_name, len); + +qemu_savevm_command_send(f, MIG_CMD_RECV_BITMAP, len + 1, (uint8_t *)buf); +} + bool qemu_savevm_state_blocked(Error **errp) { SaveStateEntry *se; @@ -1775,6 +1790,49 @@ static int loadvm_handle_cmd_packaged(MigrationIncomingState *mis) return ret; } +/* + * Handle request that source requests for recved_bitmap on + * destination. Payload format: + * + * len (1 byte) + ramblock_name (<255 bytes) + */ +static int loadvm_handle_recv_bitmap(MigrationIncomingState *mis, + uint16_t len) +{ +QEMUFile *file = mis->from_src_file; +RAMBlock *rb; +char block_name[256]; +size_t cnt; + +cnt = qemu_get_counted_string(file, block_name); +if (!cnt) { +error_report("%s: failed to read block name", __func__); +return -EINVAL; +} + +/* Validate before using the data */ +if (qemu_file_get_error(file)) { +return qemu_file_get_error(file); +} + +if (len != cnt + 1) { +error_report("%s: invalid payload length (%d)", __func__, len); +return -EINVAL; +} + +rb = qemu_ram_block_by_name(block_name); +if (!rb) { +error_report("%s: block '%s' not found", __func__, block_name); +return -EINVAL; +} + +/* TODO: send the bitmap back to source */ + +trace_loadvm_handle_recv_bitmap(block_name); + +return 0; +} + /* * Process an incoming 'QEMU_VM_COMMAND' * 0 just a normal return @@ -1848,6 +1906,9 @@ static int loadvm_process_command(QEMUFile *f) case MIG_CMD_POSTCOPY_RAM_DISCARD: return loadvm_postcopy_ram_handle_discard(mis, len); + +case MIG_CMD_RECV_BITMAP: +return loadvm_handle_recv_bitmap(mis, len); } return 0; diff --git a/migration/savevm.h b/migration/savevm.h index 295c4a1f2c..8126b1cc14 100644 --- a/migration/savevm.h +++ b/migration/savevm.h @@ -46,6 +46,7 @@ int qemu_savevm_send_packaged(QEMUFile *f, const uint8_t *buf, size_t len); void qemu_savevm_send_postcopy_advise(QEMUFile *f); void qemu_savevm_send_postcopy_listen(QEMUFile *f); void qemu_savevm_send_postcopy_run(QEMUFile *f); +void qemu_savevm_send_recv_bitmap(QEMUFile *f, char *block_name); void qemu_savevm_send_postcopy_ram_discard(QEMUFile *f, const char *name, uint16_t len, diff --git a/migration/trace-events b/migration/trace-events index 06a919a6e3..62b27fbf11 100644 --- a/migration/trace-events +++ b/migration/trace-events @@ -12,6 +12,7 @@ loadvm_state_cleanup(void) "" loadvm_handle_cmd_packaged(unsigned int length) "%u" loadvm_handle_cmd_packaged_main(int ret) "%d" loadvm_handle_cmd_packaged_received(int ret) "%d" +loadvm_handle_recv_bitmap(char *s) "%s" loadvm_postcopy_handle_advise(void) "" loadvm_postcopy_handle_listen(void) "" loadvm_postcopy_handle_run(void) "" @@ -34,6 +35,7 @@ savevm_send_open_return_path(void) "" savevm_send_ping(uint32_t val) "0x%x" savevm_send_postcopy_listen(void) "" savevm_send_postcopy_run(void) "" +savevm_send_recv_bitmap(char *name) "%s" savevm_state_setup(void) "" savevm_state_header(void) "" savevm_state_iterate(void) "" -- 2.14.3
[Qemu-devel] [PATCH v6 04/28] migration: new postcopy-pause state
Introducing a new state "postcopy-paused", which can be used when the postcopy migration is paused. It is targeted for postcopy network failure recovery. Reviewed-by: Dr. David Alan Gilbert Signed-off-by: Peter Xu --- migration/migration.c | 2 ++ qapi/migration.json | 5 - 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/migration/migration.c b/migration/migration.c index 9d2660dd6f..e8a79bb181 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -535,6 +535,7 @@ static bool migration_is_setup_or_active(int state) switch (state) { case MIGRATION_STATUS_ACTIVE: case MIGRATION_STATUS_POSTCOPY_ACTIVE: +case MIGRATION_STATUS_POSTCOPY_PAUSED: case MIGRATION_STATUS_SETUP: case MIGRATION_STATUS_PRE_SWITCHOVER: case MIGRATION_STATUS_DEVICE: @@ -614,6 +615,7 @@ MigrationInfo *qmp_query_migrate(Error **errp) case MIGRATION_STATUS_POSTCOPY_ACTIVE: case MIGRATION_STATUS_PRE_SWITCHOVER: case MIGRATION_STATUS_DEVICE: +case MIGRATION_STATUS_POSTCOPY_PAUSED: /* TODO add some postcopy stats */ info->has_status = true; info->has_total_time = true; diff --git a/qapi/migration.json b/qapi/migration.json index 4cd3d13158..49d27f3b29 100644 --- a/qapi/migration.json +++ b/qapi/migration.json @@ -89,6 +89,8 @@ # # @postcopy-active: like active, but now in postcopy mode. (since 2.5) # +# @postcopy-paused: during postcopy but paused. (since 2.12) +# # @completed: migration is finished. # # @failed: some error occurred during migration process. @@ -106,7 +108,8 @@ ## { 'enum': 'MigrationStatus', 'data': [ 'none', 'setup', 'cancelling', 'cancelled', -'active', 'postcopy-active', 'completed', 'failed', 'colo', +'active', 'postcopy-active', 'postcopy-paused', +'completed', 'failed', 'colo', 'pre-switchover', 'device' ] } ## -- 2.14.3
[Qemu-devel] [PATCH v6 19/28] migration: introduce SaveVMHandlers.resume_prepare
This is hook function to be called when a postcopy migration wants to resume from a failure. For each module, it should provide its own recovery logic before we switch to the postcopy-active state. Reviewed-by: Dr. David Alan Gilbert Signed-off-by: Peter Xu --- include/migration/register.h | 2 ++ migration/migration.c| 20 +++- migration/savevm.c | 25 + migration/savevm.h | 1 + migration/trace-events | 1 + 5 files changed, 48 insertions(+), 1 deletion(-) diff --git a/include/migration/register.h b/include/migration/register.h index f4f7bdc177..128124f008 100644 --- a/include/migration/register.h +++ b/include/migration/register.h @@ -42,6 +42,8 @@ typedef struct SaveVMHandlers { LoadStateHandler *load_state; int (*load_setup)(QEMUFile *f, void *opaque); int (*load_cleanup)(void *opaque); +/* Called when postcopy migration wants to resume from failure */ +int (*resume_prepare)(MigrationState *s, void *opaque); } SaveVMHandlers; int register_savevm_live(DeviceState *dev, diff --git a/migration/migration.c b/migration/migration.c index 00e933f317..f0a35f7dfd 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -2381,7 +2381,25 @@ typedef enum MigThrError { /* Return zero if success, or <0 for error */ static int postcopy_do_resume(MigrationState *s) { -/* TODO: do the resume logic */ +int ret; + +/* + * Call all the resume_prepare() hooks, so that modules can be + * ready for the migration resume. + */ +ret = qemu_savevm_state_resume_prepare(s); +if (ret) { +error_report("%s: resume_prepare() failure detected: %d", + __func__, ret); +return ret; +} + +/* + * TODO: handshake with dest using MIG_CMD_RESUME, + * MIG_RP_MSG_RESUME_ACK, then switch source state to + * "postcopy-active" + */ + return 0; } diff --git a/migration/savevm.c b/migration/savevm.c index 3ba3ae5327..d40092a2b6 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -1028,6 +1028,31 @@ void qemu_savevm_state_setup(QEMUFile *f) } } +int qemu_savevm_state_resume_prepare(MigrationState *s) +{ +SaveStateEntry *se; +int ret; + +trace_savevm_state_resume_prepare(); + +QTAILQ_FOREACH(se, &savevm_state.handlers, entry) { +if (!se->ops || !se->ops->resume_prepare) { +continue; +} +if (se->ops && se->ops->is_active) { +if (!se->ops->is_active(se->opaque)) { +continue; +} +} +ret = se->ops->resume_prepare(s, se->opaque); +if (ret < 0) { +return ret; +} +} + +return 0; +} + /* * this function has three return values: * negative: there was one error, and we have -errno. diff --git a/migration/savevm.h b/migration/savevm.h index a5f3879191..3193f04cca 100644 --- a/migration/savevm.h +++ b/migration/savevm.h @@ -31,6 +31,7 @@ bool qemu_savevm_state_blocked(Error **errp); void qemu_savevm_state_setup(QEMUFile *f); +int qemu_savevm_state_resume_prepare(MigrationState *s); void qemu_savevm_state_header(QEMUFile *f); int qemu_savevm_state_iterate(QEMUFile *f, bool postcopy); void qemu_savevm_state_cleanup(void); diff --git a/migration/trace-events b/migration/trace-events index 7422a395da..fe46b2c6c5 100644 --- a/migration/trace-events +++ b/migration/trace-events @@ -39,6 +39,7 @@ savevm_send_postcopy_run(void) "" savevm_send_postcopy_resume(void) "" savevm_send_recv_bitmap(char *name) "%s" savevm_state_setup(void) "" +savevm_state_resume_prepare(void) "" savevm_state_header(void) "" savevm_state_iterate(void) "" savevm_state_cleanup(void) "" -- 2.14.3
[Qemu-devel] [PATCH v6 06/28] migration: allow dst vm pause on postcopy
When there is IO error on the incoming channel (e.g., network down), instead of bailing out immediately, we allow the dst vm to switch to the new POSTCOPY_PAUSE state. Currently it is still simple - it waits the new semaphore, until someone poke it for another attempt. One note is that here on ram loading thread we cannot detect the POSTCOPY_ACTIVE state, but we need to detect the more specific POSTCOPY_INCOMING_RUNNING state, to make sure we have already loaded all the device states. Reviewed-by: Dr. David Alan Gilbert Signed-off-by: Peter Xu --- migration/migration.c | 1 + migration/migration.h | 3 +++ migration/savevm.c | 63 -- migration/trace-events | 2 ++ 4 files changed, 67 insertions(+), 2 deletions(-) diff --git a/migration/migration.c b/migration/migration.c index de5ee9c1d4..fc0d0e0e31 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -155,6 +155,7 @@ MigrationIncomingState *migration_incoming_get_current(void) memset(&mis_current, 0, sizeof(MigrationIncomingState)); qemu_mutex_init(&mis_current.rp_mutex); qemu_event_init(&mis_current.main_thread_load_event, false); +qemu_sem_init(&mis_current.postcopy_pause_sem_dst, 0); once = true; } return &mis_current; diff --git a/migration/migration.h b/migration/migration.h index 3e4af0a831..27ba256c40 100644 --- a/migration/migration.h +++ b/migration/migration.h @@ -61,6 +61,9 @@ struct MigrationIncomingState { /* The coroutine we should enter (back) after failover */ Coroutine *migration_incoming_co; QemuSemaphore colo_incoming_sem; + +/* notify PAUSED postcopy incoming migrations to try to continue */ +QemuSemaphore postcopy_pause_sem_dst; }; MigrationIncomingState *migration_incoming_get_current(void); diff --git a/migration/savevm.c b/migration/savevm.c index 76fcc2b1c3..d83c1e846a 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -1544,8 +1544,8 @@ static int loadvm_postcopy_ram_handle_discard(MigrationIncomingState *mis, */ static void *postcopy_ram_listen_thread(void *opaque) { -QEMUFile *f = opaque; MigrationIncomingState *mis = migration_incoming_get_current(); +QEMUFile *f = mis->from_src_file; int load_res; migrate_set_state(&mis->state, MIGRATION_STATUS_ACTIVE, @@ -1559,6 +1559,14 @@ static void *postcopy_ram_listen_thread(void *opaque) */ qemu_file_set_blocking(f, true); load_res = qemu_loadvm_state_main(f, mis); + +/* + * This is tricky, but, mis->from_src_file can change after it + * returns, when postcopy recovery happened. In the future, we may + * want a wrapper for the QEMUFile handle. + */ +f = mis->from_src_file; + /* And non-blocking again so we don't block in any cleanup */ qemu_file_set_blocking(f, false); @@ -1641,7 +1649,7 @@ static int loadvm_postcopy_handle_listen(MigrationIncomingState *mis) /* Start up the listening thread and wait for it to signal ready */ qemu_sem_init(&mis->listen_thread_sem, 0); qemu_thread_create(&mis->listen_thread, "postcopy/listen", - postcopy_ram_listen_thread, mis->from_src_file, + postcopy_ram_listen_thread, NULL, QEMU_THREAD_DETACHED); qemu_sem_wait(&mis->listen_thread_sem); qemu_sem_destroy(&mis->listen_thread_sem); @@ -2026,11 +2034,44 @@ void qemu_loadvm_state_cleanup(void) } } +/* Return true if we should continue the migration, or false. */ +static bool postcopy_pause_incoming(MigrationIncomingState *mis) +{ +trace_postcopy_pause_incoming(); + +migrate_set_state(&mis->state, MIGRATION_STATUS_POSTCOPY_ACTIVE, + MIGRATION_STATUS_POSTCOPY_PAUSED); + +assert(mis->from_src_file); +qemu_file_shutdown(mis->from_src_file); +qemu_fclose(mis->from_src_file); +mis->from_src_file = NULL; + +assert(mis->to_src_file); +qemu_file_shutdown(mis->to_src_file); +qemu_mutex_lock(&mis->rp_mutex); +qemu_fclose(mis->to_src_file); +mis->to_src_file = NULL; +qemu_mutex_unlock(&mis->rp_mutex); + +error_report("Detected IO failure for postcopy. " + "Migration paused."); + +while (mis->state == MIGRATION_STATUS_POSTCOPY_PAUSED) { +qemu_sem_wait(&mis->postcopy_pause_sem_dst); +} + +trace_postcopy_pause_incoming_continued(); + +return true; +} + static int qemu_loadvm_state_main(QEMUFile *f, MigrationIncomingState *mis) { uint8_t section_type; int ret = 0; +retry: while (true) { section_type = qemu_get_byte(f); @@ -2075,6 +2116,24 @@ static int qemu_loadvm_state_main(QEMUFile *f, MigrationIncomingState *mis) out: if (ret < 0) { qemu_file_set_error(f, ret); + +/* + * Detect whether it is: + * + * 1. postcopy running (after receiving all device data, which + *must be in PO
[Qemu-devel] [PATCH v6 11/28] migration: pass MigrationState to migrate_init()
Let the callers take the object, then pass it to migrate_init(). Reviewed-by: Dr. David Alan Gilbert Signed-off-by: Peter Xu --- migration/migration.c | 7 ++- migration/migration.h | 2 +- migration/savevm.c| 5 - 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/migration/migration.c b/migration/migration.c index dbcc3f6296..37b7170c20 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -1260,10 +1260,8 @@ bool migration_is_idle(void) return false; } -MigrationState *migrate_init(void) +void migrate_init(MigrationState *s) { -MigrationState *s = migrate_get_current(); - /* * Reinitialise all migration state, except * parameters/capabilities that the user set, and @@ -1293,7 +1291,6 @@ MigrationState *migrate_init(void) s->vm_was_running = false; s->iteration_initial_bytes = 0; s->threshold_size = 0; -return s; } static GSList *migration_blockers; @@ -1401,7 +1398,7 @@ void qmp_migrate(const char *uri, bool has_blk, bool blk, migrate_set_block_incremental(s, true); } -s = migrate_init(); +migrate_init(s); if (strstart(uri, "tcp:", &p)) { tcp_start_outgoing_migration(s, p, &local_err); diff --git a/migration/migration.h b/migration/migration.h index c39e325615..9e3ddb0b06 100644 --- a/migration/migration.h +++ b/migration/migration.h @@ -202,7 +202,7 @@ void migrate_fd_error(MigrationState *s, const Error *error); void migrate_fd_connect(MigrationState *s, Error *error_in); -MigrationState *migrate_init(void); +void migrate_init(MigrationState *s); bool migration_is_blocked(Error **errp); /* True if outgoing migration has entered postcopy phase */ bool migration_in_postcopy(void); diff --git a/migration/savevm.c b/migration/savevm.c index 5b1a0a7fe1..4a75e66aab 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -1256,8 +1256,11 @@ void qemu_savevm_state_cleanup(void) static int qemu_savevm_state(QEMUFile *f, Error **errp) { int ret; -MigrationState *ms = migrate_init(); +MigrationState *ms = migrate_get_current(); MigrationStatus status; + +migrate_init(ms); + ms->to_dst_file = f; if (migration_is_blocked(errp)) { -- 2.14.3
[Qemu-devel] [PATCH v6 16/28] migration: new message MIG_RP_MSG_RECV_BITMAP
Introducing new return path message MIG_RP_MSG_RECV_BITMAP to send received bitmap of ramblock back to source. This is the reply message of MIG_CMD_RECV_BITMAP, it contains not only the header (including the ramblock name), and it was appended with the whole ramblock received bitmap on the destination side. When the source receives such a reply message (MIG_RP_MSG_RECV_BITMAP), it parses it, convert it to the dirty bitmap by inverting the bits. One thing to mention is that, when we send the recv bitmap, we are doing these things in extra: - converting the bitmap to little endian, to support when hosts are using different endianess on src/dst. - do proper alignment for 8 bytes, to support when hosts are using different word size (32/64 bits) on src/dst. Reviewed-by: Dr. David Alan Gilbert Signed-off-by: Peter Xu --- migration/migration.c | 68 +++ migration/migration.h | 2 + migration/ram.c| 144 + migration/ram.h| 3 ++ migration/savevm.c | 2 +- migration/trace-events | 3 ++ 6 files changed, 221 insertions(+), 1 deletion(-) diff --git a/migration/migration.c b/migration/migration.c index 6503b26386..9374f90dff 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -93,6 +93,7 @@ enum mig_rp_message_type { MIG_RP_MSG_REQ_PAGES_ID, /* data (start: be64, len: be32, id: string) */ MIG_RP_MSG_REQ_PAGES,/* data (start: be64, len: be32) */ +MIG_RP_MSG_RECV_BITMAP, /* send recved_bitmap back to source */ MIG_RP_MSG_MAX }; @@ -506,6 +507,45 @@ void migrate_send_rp_pong(MigrationIncomingState *mis, migrate_send_rp_message(mis, MIG_RP_MSG_PONG, sizeof(buf), &buf); } +void migrate_send_rp_recv_bitmap(MigrationIncomingState *mis, + char *block_name) +{ +char buf[512]; +int len; +int64_t res; + +/* + * First, we send the header part. It contains only the len of + * idstr, and the idstr itself. + */ +len = strlen(block_name); +buf[0] = len; +memcpy(buf + 1, block_name, len); + +if (mis->state != MIGRATION_STATUS_POSTCOPY_RECOVER) { +error_report("%s: MSG_RP_RECV_BITMAP only used for recovery", + __func__); +return; +} + +migrate_send_rp_message(mis, MIG_RP_MSG_RECV_BITMAP, len + 1, buf); + +/* + * Next, we dump the received bitmap to the stream. + * + * TODO: currently we are safe since we are the only one that is + * using the to_src_file handle (fault thread is still paused), + * and it's ok even not taking the mutex. However the best way is + * to take the lock before sending the message header, and release + * the lock after sending the bitmap. + */ +qemu_mutex_lock(&mis->rp_mutex); +res = ramblock_recv_bitmap_send(mis->to_src_file, block_name); +qemu_mutex_unlock(&mis->rp_mutex); + +trace_migrate_send_rp_recv_bitmap(block_name, res); +} + MigrationCapabilityStatusList *qmp_query_migrate_capabilities(Error **errp) { MigrationCapabilityStatusList *head = NULL; @@ -1729,6 +1769,7 @@ static struct rp_cmd_args { [MIG_RP_MSG_PONG] = { .len = 4, .name = "PONG" }, [MIG_RP_MSG_REQ_PAGES] = { .len = 12, .name = "REQ_PAGES" }, [MIG_RP_MSG_REQ_PAGES_ID] = { .len = -1, .name = "REQ_PAGES_ID" }, +[MIG_RP_MSG_RECV_BITMAP]= { .len = -1, .name = "RECV_BITMAP" }, [MIG_RP_MSG_MAX]= { .len = -1, .name = "MAX" }, }; @@ -1773,6 +1814,19 @@ static bool postcopy_pause_return_path_thread(MigrationState *s) return true; } +static int migrate_handle_rp_recv_bitmap(MigrationState *s, char *block_name) +{ +RAMBlock *block = qemu_ram_block_by_name(block_name); + +if (!block) { +error_report("%s: invalid block name '%s'", __func__, block_name); +return -EINVAL; +} + +/* Fetch the received bitmap and refresh the dirty bitmap */ +return ram_dirty_bitmap_reload(s, block); +} + /* * Handles messages sent on the return path towards the source VM * @@ -1878,6 +1932,20 @@ retry: migrate_handle_rp_req_pages(ms, (char *)&buf[13], start, len); break; +case MIG_RP_MSG_RECV_BITMAP: +if (header_len < 1) { +error_report("%s: missing block name", __func__); +mark_source_rp_bad(ms); +goto out; +} +/* Format: len (1B) + idstr (<255B). This ends the idstr. */ +buf[buf[0] + 1] = '\0'; +if (migrate_handle_rp_recv_bitmap(ms, (char *)(buf + 1))) { +mark_source_rp_bad(ms); +goto out; +} +break; + default: break; } diff --git a/migration/migration.h b/migration/migration.h index 9e3ddb0b06..6c3f1c4e48 100644 --- a/migration/migration.h +++ b/migration/migration.h @@ -241,5 +241,7 @@ void migrate_se
[Qemu-devel] [PATCH v6 20/28] migration: synchronize dirty bitmap for resume
This patch implements the first part of core RAM resume logic for postcopy. ram_resume_prepare() is provided for the work. When the migration is interrupted by network failure, the dirty bitmap on the source side will be meaningless, because even the dirty bit is cleared, it is still possible that the sent page was lost along the way to destination. Here instead of continue the migration with the old dirty bitmap on source, we ask the destination side to send back its received bitmap, then invert it to be our initial dirty bitmap. The source side send thread will issue the MIG_CMD_RECV_BITMAP requests, once per ramblock, to ask for the received bitmap. On destination side, MIG_RP_MSG_RECV_BITMAP will be issued, along with the requested bitmap. Data will be received on the return-path thread of source, and the main migration thread will be notified when all the ramblock bitmaps are synchronized. Reviewed-by: Dr. David Alan Gilbert Signed-off-by: Peter Xu --- migration/migration.c | 2 ++ migration/migration.h | 1 + migration/ram.c| 47 +++ migration/trace-events | 4 4 files changed, 54 insertions(+) diff --git a/migration/migration.c b/migration/migration.c index f0a35f7dfd..c2ecebda02 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -2894,6 +2894,7 @@ static void migration_instance_finalize(Object *obj) qemu_sem_destroy(&ms->pause_sem); qemu_sem_destroy(&ms->postcopy_pause_sem); qemu_sem_destroy(&ms->postcopy_pause_rp_sem); +qemu_sem_destroy(&ms->rp_state.rp_sem); } static void migration_instance_init(Object *obj) @@ -2925,6 +2926,7 @@ static void migration_instance_init(Object *obj) qemu_sem_init(&ms->postcopy_pause_sem, 0); qemu_sem_init(&ms->postcopy_pause_rp_sem, 0); +qemu_sem_init(&ms->rp_state.rp_sem, 0); } /* diff --git a/migration/migration.h b/migration/migration.h index bb81b6c926..88f5614b90 100644 --- a/migration/migration.h +++ b/migration/migration.h @@ -119,6 +119,7 @@ struct MigrationState QEMUFile *from_dst_file; QemuThreadrp_thread; bool error; +QemuSemaphore rp_sem; } rp_state; double mbps; diff --git a/migration/ram.c b/migration/ram.c index 463d5b3fe4..a2a4b05d5c 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -49,6 +49,7 @@ #include "qemu/rcu_queue.h" #include "migration/colo.h" #include "migration/block.h" +#include "savevm.h" /***/ /* ram save/restore */ @@ -3056,6 +3057,38 @@ static bool ram_has_postcopy(void *opaque) return migrate_postcopy_ram(); } +/* Sync all the dirty bitmap with destination VM. */ +static int ram_dirty_bitmap_sync_all(MigrationState *s, RAMState *rs) +{ +RAMBlock *block; +QEMUFile *file = s->to_dst_file; +int ramblock_count = 0; + +trace_ram_dirty_bitmap_sync_start(); + +RAMBLOCK_FOREACH(block) { +qemu_savevm_send_recv_bitmap(file, block->idstr); +trace_ram_dirty_bitmap_request(block->idstr); +ramblock_count++; +} + +trace_ram_dirty_bitmap_sync_wait(); + +/* Wait until all the ramblocks' dirty bitmap synced */ +while (ramblock_count--) { +qemu_sem_wait(&s->rp_state.rp_sem); +} + +trace_ram_dirty_bitmap_sync_complete(); + +return 0; +} + +static void ram_dirty_bitmap_reload_notify(MigrationState *s) +{ +qemu_sem_post(&s->rp_state.rp_sem); +} + /* * Read the received bitmap, revert it as the initial dirty bitmap. * This is only used when the postcopy migration is paused but wants @@ -3130,12 +3163,25 @@ int ram_dirty_bitmap_reload(MigrationState *s, RAMBlock *block) trace_ram_dirty_bitmap_reload_complete(block->idstr); +/* + * We succeeded to sync bitmap for current ramblock. If this is + * the last one to sync, we need to notify the main send thread. + */ +ram_dirty_bitmap_reload_notify(s); + ret = 0; out: free(le_bitmap); return ret; } +static int ram_resume_prepare(MigrationState *s, void *opaque) +{ +RAMState *rs = *(RAMState **)opaque; + +return ram_dirty_bitmap_sync_all(s, rs); +} + static SaveVMHandlers savevm_ram_handlers = { .save_setup = ram_save_setup, .save_live_iterate = ram_save_iterate, @@ -3147,6 +3193,7 @@ static SaveVMHandlers savevm_ram_handlers = { .save_cleanup = ram_save_cleanup, .load_setup = ram_load_setup, .load_cleanup = ram_load_cleanup, +.resume_prepare = ram_resume_prepare, }; void ram_mig_init(void) diff --git a/migration/trace-events b/migration/trace-events index fe46b2c6c5..45b1d89217 100644 --- a/migration/trace-events +++ b/migration/trace-events @@ -82,8 +82,12 @@ ram_load_postcopy_loop(uint64_t addr, int flags) "@%" PRIx64 " %x" ram_postcopy_send_discard_bitmap(void) "" ram_save_page(const char *rbname, uint64_t offset, void *host) "%s: offset: 0x%" PRIx64 " host: %p" ram_sav
[Qemu-devel] [PATCH v6 09/28] migration: allow fault thread to pause
Allows the fault thread to stop handling page faults temporarily. When network failure happened (and if we expect a recovery afterwards), we should not allow the fault thread to continue sending things to source, instead, it should halt for a while until the connection is rebuilt. When the dest main thread noticed the failure, it kicks the fault thread to switch to pause state. Reviewed-by: Dr. David Alan Gilbert Signed-off-by: Peter Xu --- migration/migration.c| 1 + migration/migration.h| 1 + migration/postcopy-ram.c | 50 migration/savevm.c | 3 +++ migration/trace-events | 2 ++ 5 files changed, 53 insertions(+), 4 deletions(-) diff --git a/migration/migration.c b/migration/migration.c index b3899c2b6e..4a8c873b52 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -156,6 +156,7 @@ MigrationIncomingState *migration_incoming_get_current(void) qemu_mutex_init(&mis_current.rp_mutex); qemu_event_init(&mis_current.main_thread_load_event, false); qemu_sem_init(&mis_current.postcopy_pause_sem_dst, 0); +qemu_sem_init(&mis_current.postcopy_pause_sem_fault, 0); once = true; } return &mis_current; diff --git a/migration/migration.h b/migration/migration.h index ecdb38ee53..c39e325615 100644 --- a/migration/migration.h +++ b/migration/migration.h @@ -64,6 +64,7 @@ struct MigrationIncomingState { /* notify PAUSED postcopy incoming migrations to try to continue */ QemuSemaphore postcopy_pause_sem_dst; +QemuSemaphore postcopy_pause_sem_fault; }; MigrationIncomingState *migration_incoming_get_current(void); diff --git a/migration/postcopy-ram.c b/migration/postcopy-ram.c index 032abfbf1a..31c290c884 100644 --- a/migration/postcopy-ram.c +++ b/migration/postcopy-ram.c @@ -485,6 +485,17 @@ static int ram_block_enable_notify(const char *block_name, void *host_addr, return 0; } +static bool postcopy_pause_fault_thread(MigrationIncomingState *mis) +{ +trace_postcopy_pause_fault_thread(); + +qemu_sem_wait(&mis->postcopy_pause_sem_fault); + +trace_postcopy_pause_fault_thread_continued(); + +return true; +} + /* * Handle faults detected by the USERFAULT markings */ @@ -535,6 +546,22 @@ static void *postcopy_ram_fault_thread(void *opaque) } } +if (!mis->to_src_file) { +/* + * Possibly someone tells us that the return path is + * broken already using the event. We should hold until + * the channel is rebuilt. + */ +if (postcopy_pause_fault_thread(mis)) { +last_rb = NULL; +/* Continue to read the userfaultfd */ +} else { +error_report("%s: paused but don't allow to continue", + __func__); +break; +} +} + ret = read(mis->userfault_fd, &msg, sizeof(msg)); if (ret != sizeof(msg)) { if (errno == EAGAIN) { @@ -574,18 +601,33 @@ static void *postcopy_ram_fault_thread(void *opaque) qemu_ram_get_idstr(rb), rb_offset); +retry: /* * Send the request to the source - we want to request one * of our host page sizes (which is >= TPS) */ if (rb != last_rb) { last_rb = rb; -migrate_send_rp_req_pages(mis, qemu_ram_get_idstr(rb), - rb_offset, qemu_ram_pagesize(rb)); +ret = migrate_send_rp_req_pages(mis, qemu_ram_get_idstr(rb), +rb_offset, qemu_ram_pagesize(rb)); } else { /* Save some space */ -migrate_send_rp_req_pages(mis, NULL, - rb_offset, qemu_ram_pagesize(rb)); +ret = migrate_send_rp_req_pages(mis, NULL, +rb_offset, qemu_ram_pagesize(rb)); +} + +if (ret) { +/* May be network failure, try to wait for recovery */ +if (ret == -EIO && postcopy_pause_fault_thread(mis)) { +/* We got reconnected somehow, try to continue */ +last_rb = NULL; +goto retry; +} else { +/* This is a unavoidable fault */ +error_report("%s: migrate_send_rp_req_pages() get %d", + __func__, ret); +break; +} } } trace_postcopy_ram_fault_thread_exit(); diff --git a/migration/savevm.c b/migration/savevm.c index d83c1e846a..5b1a0a7fe1 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -2054,6 +2054,9 @@ static bool postcopy_pause_incoming(MigrationIncomingState *mis) mis->to_src_file = NULL; qemu_mutex_unlock(&mis->rp_mutex); +
[Qemu-devel] [PATCH v6 25/28] qmp/migration: new command migrate-recover
The first allow-oob=true command. It's used on destination side when the postcopy migration is paused and ready for a recovery. After execution, a new migration channel will be established for postcopy to continue. Signed-off-by: Peter Xu --- migration/migration.c | 26 ++ migration/migration.h | 1 + migration/savevm.c| 3 +++ qapi/migration.json | 20 4 files changed, 50 insertions(+) diff --git a/migration/migration.c b/migration/migration.c index cf3a3f416c..bb57ed9ade 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -1422,6 +1422,32 @@ void qmp_migrate_incoming(const char *uri, Error **errp) once = false; } +void qmp_migrate_recover(const char *uri, Error **errp) +{ +MigrationIncomingState *mis = migration_incoming_get_current(); + +if (mis->state != MIGRATION_STATUS_POSTCOPY_PAUSED) { +error_setg(errp, "Migrate recover can only be run " + "when postcopy is paused."); +return; +} + +if (mis->postcopy_recover_triggered) { +error_setg(errp, "Migrate recovery is triggered already"); +return; +} + +/* This will make sure we'll only allow one recover for one pause */ +mis->postcopy_recover_triggered = true; + +/* + * Note that this call will never start a real migration; it will + * only re-setup the migration stream and poke existing migration + * to continue using that newly established channel. + */ +qemu_start_incoming_migration(uri, errp); +} + bool migration_is_blocked(Error **errp) { if (qemu_savevm_state_blocked(errp)) { diff --git a/migration/migration.h b/migration/migration.h index 88f5614b90..581bf4668b 100644 --- a/migration/migration.h +++ b/migration/migration.h @@ -65,6 +65,7 @@ struct MigrationIncomingState { QemuSemaphore colo_incoming_sem; /* notify PAUSED postcopy incoming migrations to try to continue */ +bool postcopy_recover_triggered; QemuSemaphore postcopy_pause_sem_dst; QemuSemaphore postcopy_pause_sem_fault; }; diff --git a/migration/savevm.c b/migration/savevm.c index d40092a2b6..5f41b062ba 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -2182,6 +2182,9 @@ static bool postcopy_pause_incoming(MigrationIncomingState *mis) /* Notify the fault thread for the invalidated file handle */ postcopy_fault_thread_notify(mis); +/* Clear the triggered bit to allow one recovery */ +mis->postcopy_recover_triggered = false; + error_report("Detected IO failure for postcopy. " "Migration paused."); diff --git a/qapi/migration.json b/qapi/migration.json index 055130314d..dfbcb02d4c 100644 --- a/qapi/migration.json +++ b/qapi/migration.json @@ -1172,3 +1172,23 @@ # Since: 2.9 ## { 'command': 'xen-colo-do-checkpoint' } + +## +# @migrate-recover: +# +# Provide a recovery migration stream URI. +# +# @uri: the URI to be used for the recovery of migration stream. +# +# Returns: nothing. +# +# Example: +# +# -> { "execute": "migrate-recover", +# "arguments": { "uri": "tcp:192.168.1.200:12345" } } +# <- { "return": {} } +# +# Since: 2.12 +## +{ 'command': 'migrate-recover', 'data': { 'uri': 'str' }, + 'allow-oob': true } -- 2.14.3
[Qemu-devel] [PATCH v6 23/28] migration: init dst in migration_object_init too
Though we may not need it, now we init both the src/dst migration objects in migration_object_init() so that even incoming migration object would be thread safe (it was not). Reviewed-by: Dr. David Alan Gilbert Signed-off-by: Peter Xu --- migration/migration.c | 28 +++- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/migration/migration.c b/migration/migration.c index 19cb95fa0e..cf3a3f416c 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -104,6 +104,7 @@ enum mig_rp_message_type { dynamic creation of migration */ static MigrationState *current_migration; +static MigrationIncomingState *current_incoming; static bool migration_object_check(MigrationState *ms, Error **errp); static int migration_maybe_pause(MigrationState *s, @@ -119,6 +120,18 @@ void migration_object_init(void) assert(!current_migration); current_migration = MIGRATION_OBJ(object_new(TYPE_MIGRATION)); +/* + * Init the migrate incoming object as well no matter whether + * we'll use it or not. + */ +assert(!current_incoming); +current_incoming = g_new0(MigrationIncomingState, 1); +current_incoming->state = MIGRATION_STATUS_NONE; +qemu_mutex_init(¤t_incoming->rp_mutex); +qemu_event_init(¤t_incoming->main_thread_load_event, false); +qemu_sem_init(¤t_incoming->postcopy_pause_sem_dst, 0); +qemu_sem_init(¤t_incoming->postcopy_pause_sem_fault, 0); + if (!migration_object_check(current_migration, &err)) { error_report_err(err); exit(1); @@ -149,19 +162,8 @@ MigrationState *migrate_get_current(void) MigrationIncomingState *migration_incoming_get_current(void) { -static bool once; -static MigrationIncomingState mis_current; - -if (!once) { -mis_current.state = MIGRATION_STATUS_NONE; -memset(&mis_current, 0, sizeof(MigrationIncomingState)); -qemu_mutex_init(&mis_current.rp_mutex); -qemu_event_init(&mis_current.main_thread_load_event, false); -qemu_sem_init(&mis_current.postcopy_pause_sem_dst, 0); -qemu_sem_init(&mis_current.postcopy_pause_sem_fault, 0); -once = true; -} -return &mis_current; +assert(current_incoming); +return current_incoming; } void migration_incoming_state_destroy(void) -- 2.14.3
[Qemu-devel] [PATCH v6 22/28] migration: final handshake for the resume
Finish the last step to do the final handshake for the recovery. First source sends one MIG_CMD_RESUME to dst, telling that source is ready to resume. Then, dest replies with MIG_RP_MSG_RESUME_ACK to source, telling that dest is ready to resume (after switch to postcopy-active state). When source received the RESUME_ACK, it switches its state to postcopy-active, and finally the recovery is completed. Reviewed-by: Dr. David Alan Gilbert Signed-off-by: Peter Xu --- migration/migration.c | 28 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/migration/migration.c b/migration/migration.c index c2ecebda02..19cb95fa0e 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -1851,7 +1851,8 @@ static int migrate_handle_rp_resume_ack(MigrationState *s, uint32_t value) migrate_set_state(&s->state, MIGRATION_STATUS_POSTCOPY_RECOVER, MIGRATION_STATUS_POSTCOPY_ACTIVE); -/* TODO: notify send thread that time to continue send pages */ +/* Notify send thread that time to continue send pages */ +qemu_sem_post(&s->rp_state.rp_sem); return 0; } @@ -2378,6 +2379,21 @@ typedef enum MigThrError { MIG_THR_ERR_FATAL = 2, } MigThrError; +static int postcopy_resume_handshake(MigrationState *s) +{ +qemu_savevm_send_postcopy_resume(s->to_dst_file); + +while (s->state == MIGRATION_STATUS_POSTCOPY_RECOVER) { +qemu_sem_wait(&s->rp_state.rp_sem); +} + +if (s->state == MIGRATION_STATUS_POSTCOPY_ACTIVE) { +return 0; +} + +return -1; +} + /* Return zero if success, or <0 for error */ static int postcopy_do_resume(MigrationState *s) { @@ -2395,10 +2411,14 @@ static int postcopy_do_resume(MigrationState *s) } /* - * TODO: handshake with dest using MIG_CMD_RESUME, - * MIG_RP_MSG_RESUME_ACK, then switch source state to - * "postcopy-active" + * Last handshake with destination on the resume (destination will + * switch to postcopy-active afterwards) */ +ret = postcopy_resume_handshake(s); +if (ret) { +error_report("%s: handshake failed: %d", __func__, ret); +return ret; +} return 0; } -- 2.14.3
[Qemu-devel] [PATCH v6 12/28] migration: rebuild channel on source
This patch detects the "resume" flag of migration command, rebuild the channels only if the flag is set. Reviewed-by: Dr. David Alan Gilbert Signed-off-by: Peter Xu --- migration/migration.c | 91 +++ 1 file changed, 70 insertions(+), 21 deletions(-) diff --git a/migration/migration.c b/migration/migration.c index 37b7170c20..2088a1d1bf 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -1357,49 +1357,75 @@ bool migration_is_blocked(Error **errp) return false; } -void qmp_migrate(const char *uri, bool has_blk, bool blk, - bool has_inc, bool inc, bool has_detach, bool detach, - bool has_resume, bool resume, Error **errp) +/* Returns true if continue to migrate, or false if error detected */ +static bool migrate_prepare(MigrationState *s, bool blk, bool blk_inc, +bool resume, Error **errp) { Error *local_err = NULL; -MigrationState *s = migrate_get_current(); -const char *p; + +if (resume) { +if (s->state != MIGRATION_STATUS_POSTCOPY_PAUSED) { +error_setg(errp, "Cannot resume if there is no " + "paused migration"); +return false; +} +/* This is a resume, skip init status */ +return true; +} if (migration_is_setup_or_active(s->state) || s->state == MIGRATION_STATUS_CANCELLING || s->state == MIGRATION_STATUS_COLO) { error_setg(errp, QERR_MIGRATION_ACTIVE); -return; +return false; } + if (runstate_check(RUN_STATE_INMIGRATE)) { error_setg(errp, "Guest is waiting for an incoming migration"); -return; +return false; } if (migration_is_blocked(errp)) { -return; +return false; } -if ((has_blk && blk) || (has_inc && inc)) { +if (blk || blk_inc) { if (migrate_use_block() || migrate_use_block_incremental()) { error_setg(errp, "Command options are incompatible with " "current migration capabilities"); -return; +return false; } migrate_set_block_enabled(true, &local_err); if (local_err) { error_propagate(errp, local_err); -return; +return false; } s->must_remove_block_options = true; } -if (has_inc && inc) { +if (blk_inc) { migrate_set_block_incremental(s, true); } migrate_init(s); +return true; +} + +void qmp_migrate(const char *uri, bool has_blk, bool blk, + bool has_inc, bool inc, bool has_detach, bool detach, + bool has_resume, bool resume, Error **errp) +{ +Error *local_err = NULL; +MigrationState *s = migrate_get_current(); +const char *p; + +if (!migrate_prepare(s, has_blk && blk, has_inc && inc, + has_resume && resume, errp)) { +/* Error detected, put into errp */ +return; +} + if (strstart(uri, "tcp:", &p)) { tcp_start_outgoing_migration(s, p, &local_err); #ifdef CONFIG_RDMA @@ -1855,7 +1881,8 @@ out: return NULL; } -static int open_return_path_on_source(MigrationState *ms) +static int open_return_path_on_source(MigrationState *ms, + bool create_thread) { ms->rp_state.from_dst_file = qemu_file_get_return_path(ms->to_dst_file); @@ -1864,6 +1891,12 @@ static int open_return_path_on_source(MigrationState *ms) } trace_open_return_path_on_source(); + +if (!create_thread) { +/* We're done */ +return 0; +} + qemu_thread_create(&ms->rp_state.rp_thread, "return path", source_return_path_thread, ms, QEMU_THREAD_JOINABLE); @@ -2520,6 +2553,9 @@ static void *migration_thread(void *opaque) void migrate_fd_connect(MigrationState *s, Error *error_in) { +int64_t rate_limit; +bool resume = s->state == MIGRATION_STATUS_POSTCOPY_PAUSED; + s->expected_downtime = s->parameters.downtime_limit; s->cleanup_bh = qemu_bh_new(migrate_fd_cleanup, s); if (error_in) { @@ -2528,12 +2564,21 @@ void migrate_fd_connect(MigrationState *s, Error *error_in) return; } -qemu_file_set_blocking(s->to_dst_file, true); -qemu_file_set_rate_limit(s->to_dst_file, - s->parameters.max_bandwidth / XFER_LIMIT_RATIO); +if (resume) { +/* This is a resumed migration */ +rate_limit = INT64_MAX; +} else { +/* This is a fresh new migration */ +rate_limit = s->parameters.max_bandwidth / XFER_LIMIT_RATIO; +s->expected_downtime = s->parameters.downtime_limit; +s->cleanup_bh = qemu_bh_new(migrate_fd_cleanup, s); -/* Notify before starting migration thread */ -notifier_list_notify(&migration_state_notifiers, s); +/* Notify before starting migration th
Re: [Qemu-devel] [PATCH v6 00/28] Migration: postcopy failure recovery
On Thu, Feb 08, 2018 at 06:31:04PM +0800, Peter Xu wrote: [...] > 6. On source, manually trigger a "fake network down" using >"migrate-cancel" command: > > {"execute": "migrate_cancel"} > {"return": {}} > > During postcopy, it'll not really cancel the migration, but pause > it. On both sides, we should see this on stderr: > > qemu-system-x86_64: Detected IO failure for postcopy. Migration paused. > > It means now both sides are in postcopy-pause state. Sorry I forgot to update this part. We need to use migrate-pause in this version to explicitly pause the migration. If on source: { "execute": "migrate-pause" } If on destination, don't forget to run with OOB: { "execute": "migrate-pause", "id": "pause-cmd", "control": { "run-oob": true } } -- Peter Xu
[Qemu-devel] [PATCH v6 26/28] hmp/migration: add migrate_recover command
Sister command to migrate-recover in QMP. Signed-off-by: Peter Xu --- hmp-commands.hx | 13 + hmp.c | 10 ++ hmp.h | 1 + 3 files changed, 24 insertions(+) diff --git a/hmp-commands.hx b/hmp-commands.hx index 28ed5a7a13..7563f3eaa0 100644 --- a/hmp-commands.hx +++ b/hmp-commands.hx @@ -955,7 +955,20 @@ STEXI @findex migrate_incoming Continue an incoming migration using the @var{uri} (that has the same syntax as the -incoming option). +ETEXI +{ +.name = "migrate_recover", +.args_type = "uri:s", +.params = "uri", +.help = "Continue a paused incoming postcopy migration", +.cmd= hmp_migrate_recover, +}, + +STEXI +@item migrate_recover @var{uri} +@findex migrate_recover +Continue a paused incoming postcopy migration using the @var{uri}. ETEXI { diff --git a/hmp.c b/hmp.c index 6f8eec8365..4062d3fdba 100644 --- a/hmp.c +++ b/hmp.c @@ -1519,6 +1519,16 @@ void hmp_migrate_incoming(Monitor *mon, const QDict *qdict) hmp_handle_error(mon, &err); } +void hmp_migrate_recover(Monitor *mon, const QDict *qdict) +{ +Error *err = NULL; +const char *uri = qdict_get_str(qdict, "uri"); + +qmp_migrate_recover(uri, &err); + +hmp_handle_error(mon, &err); +} + /* Kept for backwards compatibility */ void hmp_migrate_set_downtime(Monitor *mon, const QDict *qdict) { diff --git a/hmp.h b/hmp.h index 536cb91caa..0d53fe78d9 100644 --- a/hmp.h +++ b/hmp.h @@ -70,6 +70,7 @@ void hmp_info_snapshots(Monitor *mon, const QDict *qdict); void hmp_migrate_cancel(Monitor *mon, const QDict *qdict); void hmp_migrate_continue(Monitor *mon, const QDict *qdict); void hmp_migrate_incoming(Monitor *mon, const QDict *qdict); +void hmp_migrate_recover(Monitor *mon, const QDict *qdict); void hmp_migrate_set_downtime(Monitor *mon, const QDict *qdict); void hmp_migrate_set_speed(Monitor *mon, const QDict *qdict); void hmp_migrate_set_capability(Monitor *mon, const QDict *qdict); -- 2.14.3
[Qemu-devel] [PATCH v6 14/28] migration: wakeup dst ram-load-thread for recover
On the destination side, we cannot wake up all the threads when we got reconnected. The first thing to do is to wake up the main load thread, so that we can continue to receive valid messages from source again and reply when needed. At this point, we switch the destination VM state from postcopy-paused back to postcopy-recover. Now we are finally ready to do the resume logic. Reviewed-by: Dr. David Alan Gilbert Signed-off-by: Peter Xu --- migration/migration.c | 30 -- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/migration/migration.c b/migration/migration.c index 6c5e422616..6503b26386 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -427,8 +427,34 @@ static void migration_incoming_process(void) void migration_fd_process_incoming(QEMUFile *f) { -migration_incoming_setup(f); -migration_incoming_process(); +MigrationIncomingState *mis = migration_incoming_get_current(); + +if (mis->state == MIGRATION_STATUS_POSTCOPY_PAUSED) { +/* Resumed from a paused postcopy migration */ + +mis->from_src_file = f; +/* Postcopy has standalone thread to do vm load */ +qemu_file_set_blocking(f, true); + +/* Re-configure the return path */ +mis->to_src_file = qemu_file_get_return_path(f); + +migrate_set_state(&mis->state, MIGRATION_STATUS_POSTCOPY_PAUSED, + MIGRATION_STATUS_POSTCOPY_RECOVER); + +/* + * Here, we only wake up the main loading thread (while the + * fault thread will still be waiting), so that we can receive + * commands from source now, and answer it if needed. The + * fault thread will be woken up afterwards until we are sure + * that source is ready to reply to page requests. + */ +qemu_sem_post(&mis->postcopy_pause_sem_dst); +} else { +/* New incoming migration */ +migration_incoming_setup(f); +migration_incoming_process(); +} } void migration_ioc_process_incoming(QIOChannel *ioc) -- 2.14.3
Re: [Qemu-devel] [PATCH 2/2] scsi: add block job opblockers for scsi-block
On 08/02/2018 02:35, Fam Zheng wrote: > On Wed, 02/07 17:36, Paolo Bonzini wrote: >> @@ -2626,6 +2656,36 @@ static void scsi_block_realize(SCSIDevice *dev, Error >> **errp) >> >> scsi_realize(&s->qdev, errp); >> scsi_generic_read_device_identification(&s->qdev); >> + >> +/* For op blockers, due to lack of support for dirty bitmaps. */ >> +error_setg(&sb->mirror_source, >> + "scsi-block does not support acting as a mirroring source"); >> +error_setg(&sb->commit_source, >> + "scsi-block does not support acting as an active commit >> source"); > > An alternative way would be adding BLOCK_OP_TYPE_DIRTY_BITMAP. The error > message > will not be as nice but it can be useful for another (blockjob) operation that > requires dirty bitmap support, or another device that doesn't support dirty > bitmaps. Though there isn't one for now. Yeah, I thought about it. Another possibility is make BLOCK_OP_TYPE_* a bitmask. Then you can easily add a single Error * for multiple blockers, and BLOCK_OP_TYPE_DIRTY_BITMAP can be defined as BLOCK_OP_TYPE_MIRROR_SOURCE|BLOCK_OP_TYPE_COMMIT_SOURCE; likewise for notifiers below. Paolo >> + >> +/* For op blockers, due to lack of support for write notifiers. */ >> +error_setg(&sb->backup_source, >> + "scsi-block does not support acting as a backup source"); >> + >> +sb->insert_bs.notify = scsi_block_insert_bs; >> +blk_add_insert_bs_notifier(s->qdev.conf.blk, &sb->insert_bs); >> +sb->remove_bs.notify = scsi_block_remove_bs; >> +blk_add_remove_bs_notifier(s->qdev.conf.blk, &sb->remove_bs); >> + >> +scsi_block_insert_bs(&sb->insert_bs, s->qdev.conf.blk); >> +} >> + >> +static void scsi_block_unrealize(SCSIDevice *dev, Error **errp) >> +{ >> +SCSIDiskState *s = DO_UPCAST(SCSIDiskState, qdev, dev); >> +SCSIBlockState *sb = DO_UPCAST(SCSIBlockState, sd, s); >> + >> +notifier_remove(&sb->insert_bs); >> +notifier_remove(&sb->remove_bs); >> +scsi_block_remove_bs(&sb->insert_bs, s->qdev.conf.blk); >> +error_free(sb->mirror_source); >> +error_free(sb->commit_source); >> +error_free(sb->backup_source); >> } >> >> typedef struct SCSIBlockReq { >> @@ -3017,6 +3077,7 @@ static void scsi_block_class_initfn(ObjectClass >> *klass, void *data) >> SCSIDiskClass *sdc = SCSI_DISK_BASE_CLASS(klass); >> >> sc->realize = scsi_block_realize; >> +sc->unrealize= scsi_block_unrealize; >> sc->alloc_req= scsi_block_new_request; >> sc->parse_cdb= scsi_block_parse_cdb; >> sdc->dma_readv = scsi_block_dma_readv; >> @@ -3031,6 +3092,7 @@ static const TypeInfo scsi_block_info = { >> .name = "scsi-block", >> .parent= TYPE_SCSI_DISK_BASE, >> .class_init= scsi_block_class_initfn, >> +.instance_size = sizeof(SCSIBlockState), >> }; >> #endif >> >> diff --git a/include/sysemu/block-backend.h b/include/sysemu/block-backend.h >> index c4e52a5fa3..a48a49ca79 100644 >> --- a/include/sysemu/block-backend.h >> +++ b/include/sysemu/block-backend.h >> @@ -182,6 +182,7 @@ void blk_set_guest_block_size(BlockBackend *blk, int >> align); >> void *blk_try_blockalign(BlockBackend *blk, size_t size); >> void *blk_blockalign(BlockBackend *blk, size_t size); >> bool blk_op_is_blocked(BlockBackend *blk, BlockOpType op, Error **errp); >> +void blk_op_block(BlockBackend *blk, BlockOpType op, Error *reason); >> void blk_op_unblock(BlockBackend *blk, BlockOpType op, Error *reason); >> void blk_op_block_all(BlockBackend *blk, Error *reason); >> void blk_op_unblock_all(BlockBackend *blk, Error *reason); >> -- >> 2.14.3 >> >> > > Fam >
[Qemu-devel] [PATCH v6 27/28] migration/qmp: add command migrate-pause
It pauses an ongoing migration. Currently it only supports postcopy. Note that this command will work on either side of the migration. Basically when we trigger this on one side, it'll interrupt the other side as well since the other side will get notified on the disconnect event. However, it's still possible that the other side is not notified, for example, when the network is totally broken, or due to some firewall configuration changes. In that case, we will also need to run the same command on the other side so both sides will go into the paused state. Signed-off-by: Peter Xu --- migration/migration.c | 27 +++ qapi/migration.json | 16 2 files changed, 43 insertions(+) diff --git a/migration/migration.c b/migration/migration.c index bb57ed9ade..139abec0c3 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -1448,6 +1448,33 @@ void qmp_migrate_recover(const char *uri, Error **errp) qemu_start_incoming_migration(uri, errp); } +void qmp_migrate_pause(Error **errp) +{ +MigrationState *ms = migrate_get_current(); +MigrationIncomingState *mis = migration_incoming_get_current(); +int ret; + +if (ms->state == MIGRATION_STATUS_POSTCOPY_ACTIVE) { +/* Source side, during postcopy */ +ret = qemu_file_shutdown(ms->to_dst_file); +if (ret) { +error_setg(errp, "Failed to pause source migration"); +} +return; +} + +if (mis->state == MIGRATION_STATUS_POSTCOPY_ACTIVE) { +ret = qemu_file_shutdown(mis->from_src_file); +if (ret) { +error_setg(errp, "Failed to pause destination migration"); +} +return; +} + +error_setg(errp, "migrate-pause is currently only supported " + "during postcopy-active state"); +} + bool migration_is_blocked(Error **errp) { if (qemu_savevm_state_blocked(errp)) { diff --git a/qapi/migration.json b/qapi/migration.json index dfbcb02d4c..3d9cfeb8f1 100644 --- a/qapi/migration.json +++ b/qapi/migration.json @@ -1192,3 +1192,19 @@ ## { 'command': 'migrate-recover', 'data': { 'uri': 'str' }, 'allow-oob': true } + +## +# @migrate-pause: +# +# Pause a migration. Currently it only supports postcopy. +# +# Returns: nothing. +# +# Example: +# +# -> { "execute": "migrate-pause" } +# <- { "return": {} } +# +# Since: 2.12 +## +{ 'command': 'migrate-pause', 'allow-oob': true } -- 2.14.3
[Qemu-devel] [PATCH v6 17/28] migration: new cmd MIG_CMD_POSTCOPY_RESUME
Introducing this new command to be sent when the source VM is ready to resume the paused migration. What the destination does here is basically release the fault thread to continue service page faults. Reviewed-by: Dr. David Alan Gilbert Signed-off-by: Peter Xu --- migration/savevm.c | 35 +++ migration/savevm.h | 1 + migration/trace-events | 2 ++ 3 files changed, 38 insertions(+) diff --git a/migration/savevm.c b/migration/savevm.c index b9f23b2b85..e6d699e150 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -77,6 +77,7 @@ enum qemu_vm_cmd { MIG_CMD_POSTCOPY_RAM_DISCARD, /* A list of pages to discard that were previously sent during precopy but are dirty. */ +MIG_CMD_POSTCOPY_RESUME, /* resume postcopy on dest */ MIG_CMD_PACKAGED, /* Send a wrapped stream within this stream */ MIG_CMD_RECV_BITMAP, /* Request for recved bitmap on dst */ MIG_CMD_MAX @@ -95,6 +96,7 @@ static struct mig_cmd_args { [MIG_CMD_POSTCOPY_RUN] = { .len = 0, .name = "POSTCOPY_RUN" }, [MIG_CMD_POSTCOPY_RAM_DISCARD] = { .len = -1, .name = "POSTCOPY_RAM_DISCARD" }, +[MIG_CMD_POSTCOPY_RESUME] = { .len = 0, .name = "POSTCOPY_RESUME" }, [MIG_CMD_PACKAGED] = { .len = 4, .name = "PACKAGED" }, [MIG_CMD_RECV_BITMAP] = { .len = -1, .name = "RECV_BITMAP" }, [MIG_CMD_MAX] = { .len = -1, .name = "MAX" }, @@ -955,6 +957,12 @@ void qemu_savevm_send_postcopy_run(QEMUFile *f) qemu_savevm_command_send(f, MIG_CMD_POSTCOPY_RUN, 0, NULL); } +void qemu_savevm_send_postcopy_resume(QEMUFile *f) +{ +trace_savevm_send_postcopy_resume(); +qemu_savevm_command_send(f, MIG_CMD_POSTCOPY_RESUME, 0, NULL); +} + void qemu_savevm_send_recv_bitmap(QEMUFile *f, char *block_name) { size_t len; @@ -1742,6 +1750,30 @@ static int loadvm_postcopy_handle_run(MigrationIncomingState *mis) return LOADVM_QUIT; } +static int loadvm_postcopy_handle_resume(MigrationIncomingState *mis) +{ +if (mis->state != MIGRATION_STATUS_POSTCOPY_RECOVER) { +error_report("%s: illegal resume received", __func__); +/* Don't fail the load, only for this. */ +return 0; +} + +/* + * This means source VM is ready to resume the postcopy migration. + * It's time to switch state and release the fault thread to + * continue service page faults. + */ +migrate_set_state(&mis->state, MIGRATION_STATUS_POSTCOPY_RECOVER, + MIGRATION_STATUS_POSTCOPY_ACTIVE); +qemu_sem_post(&mis->postcopy_pause_sem_fault); + +trace_loadvm_postcopy_handle_resume(); + +/* TODO: Tell source that "we are ready" */ + +return 0; +} + /** * Immediately following this command is a blob of data containing an embedded * chunk of migration stream; read it and load it. @@ -1907,6 +1939,9 @@ static int loadvm_process_command(QEMUFile *f) case MIG_CMD_POSTCOPY_RAM_DISCARD: return loadvm_postcopy_ram_handle_discard(mis, len); +case MIG_CMD_POSTCOPY_RESUME: +return loadvm_postcopy_handle_resume(mis); + case MIG_CMD_RECV_BITMAP: return loadvm_handle_recv_bitmap(mis, len); } diff --git a/migration/savevm.h b/migration/savevm.h index 8126b1cc14..a5f3879191 100644 --- a/migration/savevm.h +++ b/migration/savevm.h @@ -46,6 +46,7 @@ int qemu_savevm_send_packaged(QEMUFile *f, const uint8_t *buf, size_t len); void qemu_savevm_send_postcopy_advise(QEMUFile *f); void qemu_savevm_send_postcopy_listen(QEMUFile *f); void qemu_savevm_send_postcopy_run(QEMUFile *f); +void qemu_savevm_send_postcopy_resume(QEMUFile *f); void qemu_savevm_send_recv_bitmap(QEMUFile *f, char *block_name); void qemu_savevm_send_postcopy_ram_discard(QEMUFile *f, const char *name, diff --git a/migration/trace-events b/migration/trace-events index f451251ad1..d323abb75a 100644 --- a/migration/trace-events +++ b/migration/trace-events @@ -18,6 +18,7 @@ loadvm_postcopy_handle_listen(void) "" loadvm_postcopy_handle_run(void) "" loadvm_postcopy_handle_run_cpu_sync(void) "" loadvm_postcopy_handle_run_vmstart(void) "" +loadvm_postcopy_handle_resume(void) "" loadvm_postcopy_ram_handle_discard(void) "" loadvm_postcopy_ram_handle_discard_end(void) "" loadvm_postcopy_ram_handle_discard_header(const char *ramid, uint16_t len) "%s: %ud" @@ -35,6 +36,7 @@ savevm_send_open_return_path(void) "" savevm_send_ping(uint32_t val) "0x%x" savevm_send_postcopy_listen(void) "" savevm_send_postcopy_run(void) "" +savevm_send_postcopy_resume(void) "" savevm_send_recv_bitmap(char *name) "%s" savevm_state_setup(void) "" savevm_state_header(void) "" -- 2.14.3
[Qemu-devel] [PATCH v6 18/28] migration: new message MIG_RP_MSG_RESUME_ACK
Creating new message to reply for MIG_CMD_POSTCOPY_RESUME. One uint32_t is used as payload to let the source know whether destination is ready to continue the migration. Reviewed-by: Dr. David Alan Gilbert Signed-off-by: Peter Xu --- migration/migration.c | 37 + migration/migration.h | 3 +++ migration/savevm.c | 3 ++- migration/trace-events | 1 + 4 files changed, 43 insertions(+), 1 deletion(-) diff --git a/migration/migration.c b/migration/migration.c index 9374f90dff..00e933f317 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -94,6 +94,7 @@ enum mig_rp_message_type { MIG_RP_MSG_REQ_PAGES_ID, /* data (start: be64, len: be32, id: string) */ MIG_RP_MSG_REQ_PAGES,/* data (start: be64, len: be32) */ MIG_RP_MSG_RECV_BITMAP, /* send recved_bitmap back to source */ +MIG_RP_MSG_RESUME_ACK, /* tell source that we are ready to resume */ MIG_RP_MSG_MAX }; @@ -546,6 +547,14 @@ void migrate_send_rp_recv_bitmap(MigrationIncomingState *mis, trace_migrate_send_rp_recv_bitmap(block_name, res); } +void migrate_send_rp_resume_ack(MigrationIncomingState *mis, uint32_t value) +{ +uint32_t buf; + +buf = cpu_to_be32(value); +migrate_send_rp_message(mis, MIG_RP_MSG_RESUME_ACK, sizeof(buf), &buf); +} + MigrationCapabilityStatusList *qmp_query_migrate_capabilities(Error **errp) { MigrationCapabilityStatusList *head = NULL; @@ -1770,6 +1779,7 @@ static struct rp_cmd_args { [MIG_RP_MSG_REQ_PAGES] = { .len = 12, .name = "REQ_PAGES" }, [MIG_RP_MSG_REQ_PAGES_ID] = { .len = -1, .name = "REQ_PAGES_ID" }, [MIG_RP_MSG_RECV_BITMAP]= { .len = -1, .name = "RECV_BITMAP" }, +[MIG_RP_MSG_RESUME_ACK] = { .len = 4, .name = "RESUME_ACK" }, [MIG_RP_MSG_MAX]= { .len = -1, .name = "MAX" }, }; @@ -1827,6 +1837,25 @@ static int migrate_handle_rp_recv_bitmap(MigrationState *s, char *block_name) return ram_dirty_bitmap_reload(s, block); } +static int migrate_handle_rp_resume_ack(MigrationState *s, uint32_t value) +{ +trace_source_return_path_thread_resume_ack(value); + +if (value != MIGRATION_RESUME_ACK_VALUE) { +error_report("%s: illegal resume_ack value %"PRIu32, + __func__, value); +return -1; +} + +/* Now both sides are active. */ +migrate_set_state(&s->state, MIGRATION_STATUS_POSTCOPY_RECOVER, + MIGRATION_STATUS_POSTCOPY_ACTIVE); + +/* TODO: notify send thread that time to continue send pages */ + +return 0; +} + /* * Handles messages sent on the return path towards the source VM * @@ -1946,6 +1975,14 @@ retry: } break; +case MIG_RP_MSG_RESUME_ACK: +tmp32 = ldl_be_p(buf); +if (migrate_handle_rp_resume_ack(ms, tmp32)) { +mark_source_rp_bad(ms); +goto out; +} +break; + default: break; } diff --git a/migration/migration.h b/migration/migration.h index 6c3f1c4e48..bb81b6c926 100644 --- a/migration/migration.h +++ b/migration/migration.h @@ -22,6 +22,8 @@ #include "hw/qdev.h" #include "io/channel.h" +#define MIGRATION_RESUME_ACK_VALUE (1) + /* State for the incoming migration */ struct MigrationIncomingState { QEMUFile *from_src_file; @@ -243,5 +245,6 @@ int migrate_send_rp_req_pages(MigrationIncomingState *mis, const char* rbname, ram_addr_t start, size_t len); void migrate_send_rp_recv_bitmap(MigrationIncomingState *mis, char *block_name); +void migrate_send_rp_resume_ack(MigrationIncomingState *mis, uint32_t value); #endif diff --git a/migration/savevm.c b/migration/savevm.c index e6d699e150..3ba3ae5327 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -1769,7 +1769,8 @@ static int loadvm_postcopy_handle_resume(MigrationIncomingState *mis) trace_loadvm_postcopy_handle_resume(); -/* TODO: Tell source that "we are ready" */ +/* Tell source that "we are ready" */ +migrate_send_rp_resume_ack(mis, MIGRATION_RESUME_ACK_VALUE); return 0; } diff --git a/migration/trace-events b/migration/trace-events index d323abb75a..7422a395da 100644 --- a/migration/trace-events +++ b/migration/trace-events @@ -120,6 +120,7 @@ source_return_path_thread_entry(void) "" source_return_path_thread_loop_top(void) "" source_return_path_thread_pong(uint32_t val) "0x%x" source_return_path_thread_shut(uint32_t val) "0x%x" +source_return_path_thread_resume_ack(uint32_t v) "%"PRIu32 migrate_global_state_post_load(const char *state) "loaded state: %s" migrate_global_state_pre_save(const char *state) "saved state: %s" migration_thread_low_pending(uint64_t pending) "%" PRIu64 -- 2.14.3
[Qemu-devel] [PATCH v6 28/28] migration/hmp: add migrate_pause command
Wrapper for QMP command "migrate-pause". Signed-off-by: Peter Xu --- hmp-commands.hx | 14 ++ hmp.c | 9 + hmp.h | 1 + 3 files changed, 24 insertions(+) diff --git a/hmp-commands.hx b/hmp-commands.hx index 7563f3eaa0..32549702ee 100644 --- a/hmp-commands.hx +++ b/hmp-commands.hx @@ -969,6 +969,20 @@ STEXI @item migrate_recover @var{uri} @findex migrate_recover Continue a paused incoming postcopy migration using the @var{uri}. +ETEXI + +{ +.name = "migrate_pause", +.args_type = "", +.params = "", +.help = "Pause an ongoing migration (postcopy-only)", +.cmd= hmp_migrate_pause, +}, + +STEXI +@item migrate_pause +@findex migrate_pause +Pause an ongoing migration. Currently it only supports postcopy. ETEXI { diff --git a/hmp.c b/hmp.c index 4062d3fdba..ae6266cb21 100644 --- a/hmp.c +++ b/hmp.c @@ -1529,6 +1529,15 @@ void hmp_migrate_recover(Monitor *mon, const QDict *qdict) hmp_handle_error(mon, &err); } +void hmp_migrate_pause(Monitor *mon, const QDict *qdict) +{ +Error *err = NULL; + +qmp_migrate_pause(&err); + +hmp_handle_error(mon, &err); +} + /* Kept for backwards compatibility */ void hmp_migrate_set_downtime(Monitor *mon, const QDict *qdict) { diff --git a/hmp.h b/hmp.h index 0d53fe78d9..0aa8dca738 100644 --- a/hmp.h +++ b/hmp.h @@ -71,6 +71,7 @@ void hmp_migrate_cancel(Monitor *mon, const QDict *qdict); void hmp_migrate_continue(Monitor *mon, const QDict *qdict); void hmp_migrate_incoming(Monitor *mon, const QDict *qdict); void hmp_migrate_recover(Monitor *mon, const QDict *qdict); +void hmp_migrate_pause(Monitor *mon, const QDict *qdict); void hmp_migrate_set_downtime(Monitor *mon, const QDict *qdict); void hmp_migrate_set_speed(Monitor *mon, const QDict *qdict); void hmp_migrate_set_capability(Monitor *mon, const QDict *qdict); -- 2.14.3
[Qemu-devel] [PATCH v6 21/28] migration: setup ramstate for resume
After we updated the dirty bitmaps of ramblocks, we also need to update the critical fields in RAMState to make sure it is ready for a resume. Signed-off-by: Peter Xu --- migration/ram.c| 40 +++- migration/trace-events | 1 + 2 files changed, 40 insertions(+), 1 deletion(-) diff --git a/migration/ram.c b/migration/ram.c index a2a4b05d5c..d275875f54 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -2250,6 +2250,36 @@ static int ram_init_all(RAMState **rsp) return 0; } +static void ram_state_resume_prepare(RAMState *rs, QEMUFile *out) +{ +RAMBlock *block; +long pages = 0; + +/* + * Postcopy is not using xbzrle/compression, so no need for that. + * Also, since source are already halted, we don't need to care + * about dirty page logging as well. + */ + +RAMBLOCK_FOREACH(block) { +pages += bitmap_count_one(block->bmap, + block->used_length >> TARGET_PAGE_BITS); +} + +/* This may not be aligned with current bitmaps. Recalculate. */ +rs->migration_dirty_pages = pages; + +rs->last_seen_block = NULL; +rs->last_sent_block = NULL; +rs->last_page = 0; +rs->last_version = ram_list.version; + +/* Update RAMState cache of output QEMUFile */ +rs->f = out; + +trace_ram_state_resume_prepare(pages); +} + /* * Each of ram_save_setup, ram_save_iterate and ram_save_complete has * long-running RCU critical section. When rcu-reclaims in the code @@ -3178,8 +3208,16 @@ out: static int ram_resume_prepare(MigrationState *s, void *opaque) { RAMState *rs = *(RAMState **)opaque; +int ret; -return ram_dirty_bitmap_sync_all(s, rs); +ret = ram_dirty_bitmap_sync_all(s, rs); +if (ret) { +return ret; +} + +ram_state_resume_prepare(rs, s->to_dst_file); + +return 0; } static SaveVMHandlers savevm_ram_handlers = { diff --git a/migration/trace-events b/migration/trace-events index 45b1d89217..f5913ff51c 100644 --- a/migration/trace-events +++ b/migration/trace-events @@ -88,6 +88,7 @@ ram_dirty_bitmap_reload_complete(char *str) "%s" ram_dirty_bitmap_sync_start(void) "" ram_dirty_bitmap_sync_wait(void) "" ram_dirty_bitmap_sync_complete(void) "" +ram_state_resume_prepare(long v) "%ld" # migration/migration.c await_return_path_close_on_source_close(void) "" -- 2.14.3
Re: [Qemu-devel] [PATCH v5 17/23] RISC-V VirtIO Machine
On Thu, 8 Feb 2018 14:28:42 +1300 Michael Clark wrote: > RISC-V machine with device-tree, 16550a UART and VirtIO MMIO. > The following machine is implemented: > > - 'virt'; CLINT, PLIC, 16550A UART, VirtIO MMIO, device-tree > > Signed-off-by: Michael Clark > --- > hw/riscv/virt.c | 375 > > include/hw/riscv/virt.h | 74 ++ > 2 files changed, 449 insertions(+) > create mode 100644 hw/riscv/virt.c > create mode 100644 include/hw/riscv/virt.h > > diff --git a/hw/riscv/virt.c b/hw/riscv/virt.c > new file mode 100644 > index 000..46d95b2 > --- /dev/null > +++ b/hw/riscv/virt.c > @@ -0,0 +1,375 @@ > +/* > + * QEMU RISC-V VirtIO Board > + * > + * Copyright (c) 2017 SiFive, Inc. > + * > + * RISC-V machine with 16550a UART and VirtIO MMIO > + * > + * Permission is hereby granted, free of charge, to any person obtaining a > copy > + * of this software and associated documentation files (the "Software"), to > deal > + * in the Software without restriction, including without limitation the > rights > + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell > + * copies of the Software, and to permit persons to whom the Software is > + * furnished to do so, subject to the following conditions: > + * > + * The above copyright notice and this permission notice shall be included in > + * all copies or substantial portions of the Software. > + * > + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR > + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, > + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL > + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER > + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING > FROM, > + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN > + * THE SOFTWARE. > + */ > + > +#include "qemu/osdep.h" > +#include "qemu/log.h" > +#include "qemu/error-report.h" > +#include "hw/hw.h" > +#include "hw/boards.h" > +#include "hw/loader.h" > +#include "hw/sysbus.h" > +#include "hw/char/serial.h" > +#include "target/riscv/cpu.h" > +#include "hw/riscv/riscv_htif.h" > +#include "hw/riscv/riscv_hart.h" > +#include "hw/riscv/sifive_plic.h" > +#include "hw/riscv/sifive_clint.h" > +#include "hw/riscv/sifive_test.h" > +#include "hw/riscv/virt.h" > +#include "chardev/char.h" > +#include "sysemu/arch_init.h" > +#include "sysemu/device_tree.h" > +#include "exec/address-spaces.h" > +#include "elf.h" > + > +static const struct MemmapEntry { > +hwaddr base; > +hwaddr size; > +} virt_memmap[] = { > +[VIRT_DEBUG] ={0x0, 0x100 }, > +[VIRT_MROM] = { 0x1000, 0x2000 }, > +[VIRT_TEST] = { 0x4000, 0x1000 }, > +[VIRT_CLINT] ={ 0x200,0x1 }, > +[VIRT_PLIC] = { 0xc00, 0x400 }, > +[VIRT_UART0] ={ 0x1000, 0x100 }, > +[VIRT_VIRTIO] = { 0x10001000, 0x1000 }, > +[VIRT_DRAM] = { 0x8000,0x0 }, > +}; > + > +static uint64_t identity_translate(void *opaque, uint64_t addr) > +{ > +return addr; > +} > + > +static uint64_t load_kernel(const char *kernel_filename) > +{ > +uint64_t kernel_entry, kernel_high; > + > +if (load_elf(kernel_filename, identity_translate, NULL, > + &kernel_entry, NULL, &kernel_high, > + 0, ELF_MACHINE, 1, 0) < 0) { > +error_report("qemu: could not load kernel '%s'", kernel_filename); > +exit(1); > +} > +return kernel_entry; > +} > + > +static void create_fdt(RISCVVirtState *s, const struct MemmapEntry *memmap, > +uint64_t mem_size, const char *cmdline) > +{ > +void *fdt; > +int cpu; > +uint32_t *cells; > +char *nodename; > +uint32_t plic_phandle, phandle = 1; > +int i; > + > +fdt = s->fdt = create_device_tree(&s->fdt_size); > +if (!fdt) { > +error_report("create_device_tree() failed"); > +exit(1); > +} > + > +qemu_fdt_setprop_string(fdt, "/", "model", "riscv-virtio,qemu"); > +qemu_fdt_setprop_string(fdt, "/", "compatible", "riscv-virtio"); > +qemu_fdt_setprop_cell(fdt, "/", "#size-cells", 0x2); > +qemu_fdt_setprop_cell(fdt, "/", "#address-cells", 0x2); > + > +qemu_fdt_add_subnode(fdt, "/soc"); > +qemu_fdt_setprop(fdt, "/soc", "ranges", NULL, 0); > +qemu_fdt_setprop_string(fdt, "/soc", "compatible", "riscv-virtio-soc"); > +qemu_fdt_setprop_cell(fdt, "/soc", "#size-cells", 0x2); > +qemu_fdt_setprop_cell(fdt, "/soc", "#address-cells", 0x2); > + > +nodename = g_strdup_printf("/memory@%lx", > +(long)memmap[VIRT_DRAM].base); > +qemu_fdt_add_subnode(fdt, nodename); > +qemu_fdt_setprop_cells(fdt, nodename, "reg", > +memmap[VIRT_DRAM].base >> 32, memmap[VIRT_DRAM].base, > +mem_size >> 32, mem_size); > +qemu_fdt_setprop_string(fdt, no
Re: [Qemu-devel] [PULL 2/2] hw/audio/sb16.c: change dolog() to qemu_log_mask()
On 2 February 2018 at 07:50, Gerd Hoffmann wrote: > From: John Arbuckle > > Changes all the occurrances of dolog() to qemu_log_mask(). > > Signed-off-by: John Arbuckle > Message-id: 20180201172744.7504-1-programmingk...@gmail.com > Signed-off-by: Gerd Hoffmann > --- > @@ -735,9 +742,8 @@ static void complete (SB16State *s) > break; > > case 0x42: /* FT2 sets output freq with this, go figure > */ > -#if 0 > -dolog ("cmd 0x42 might not do what it think it should\n"); > -#endif > +qemu_log_mask(LOG_UNIMP, "cmd 0x42 might not do what it think it" > + " should\n"); > case 0x41: > s->freq = dsp_get_hilo (s); > ldebug ("set freq %d\n", s->freq); Hi. The removal of the #if 0 here means that Coverity reports a new warning (CID 1385841) about a potential missing break. The case 0x42 should end either with a "break;" or with a comment "/* fall through */". http://homepages.cae.wisc.edu/~brodskye/sb16doc/sb16doc.html#SamplingRate suggests that "/* fall through */" is correct, since 0x42 is 'set input sample rate', 0x41 is 'set output sample rate', and supposedly the two are equivalent on the hardware. I suspect that may also mean that this log should be a LOG_GUEST_ERROR rather than LOG_UNIMP (or perhaps not a warning at all, since we can't tell if the guest really was trying to program the input frequency). thanks -- PMM
[Qemu-devel] [PATCH v6 24/28] io: let watcher of the channel run in same ctx
Per-thread gcontext is only used in IOThread (please refer to callers of g_main_context_push_thread_default), so this patch only affects anything that will be run in an IOThread. It lets the watcher object be run in the same context as the caller that added the watcher. This patch is critical to make sure that migration stream accept() procedure will also be run in the monitor IOThread rather than the default main thread, so it can survive even if main thread hangs. Signed-off-by: Peter Xu --- io/channel.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/io/channel.c b/io/channel.c index ec4b86de7c..d6018ddfb6 100644 --- a/io/channel.c +++ b/io/channel.c @@ -312,7 +312,7 @@ guint qio_channel_add_watch(QIOChannel *ioc, g_source_set_callback(source, (GSourceFunc)func, user_data, notify); -id = g_source_attach(source, NULL); +id = g_source_attach(source, g_main_context_get_thread_default()); g_source_unref(source); return id; -- 2.14.3
Re: [Qemu-devel] Questions regarding how QEMU initializes virtual peripherals
On Thu, 8 Feb 2018 12:06:44 +0200 Ramy Sameh wrote: > Hello all, > > I am working with QEMU to simulate VersatilePB board. > > I am trying to understand how QEMU initialize the virtual peripherals (e.g. > UART, vectored Interrupt controller .. etc). > > When I traced the code, I found a function called "object_init_with_type" > in object.c, in which the function pointer "ti->instance_init(obj)" seems > to call the peripherals initialization functions. > > *I have couple of questions here:* > 1.) Some peripheral initialization functions are called multiple times such > as pl011_init, why is that ? function is called once for each instance of pl011 object. QEMU uses custom OOM framework (dubbed QOM), good point to start with it is probably to read doc comment in the beginning of include/qom/object.h Device objects are typically inherited from TYPE_DEVICE or its derivatives. Device init sequence typically looks like: foo = object_new(TYPE_FOO); // set_properties on foo, see object_property_set_... // and set special property 'realize' which would call 'realize' method object_property_set_bool(foo, true, "realized"); See qdev_device_add() for details > 2.) Where is the entry point for the whole initialization functionalities > (that will eventually call "object_init_with_type") object_new() & co + object_initialize_with_type() > Thank you. >
Re: [Qemu-devel] [PATCH] S390: Expose s390-specific CPU info
On Thu, 8 Feb 2018 11:24:48 +0100 Christian Borntraeger wrote: > On 02/08/2018 11:16 AM, Cornelia Huck wrote: > > On Thu, 8 Feb 2018 10:48:08 +0100 > > Viktor Mihajlovski wrote: > >> diff --git a/hw/s390x/s390-virtio-ccw.c b/hw/s390x/s390-virtio-ccw.c > >> index 3807dcb..3e6360e 100644 > >> --- a/hw/s390x/s390-virtio-ccw.c > >> +++ b/hw/s390x/s390-virtio-ccw.c > >> @@ -373,7 +373,7 @@ static void s390_machine_reset(void) > >> > >> /* all cpus are stopped - configure and start the ipl cpu only */ > >> s390_ipl_prepare_cpu(ipl_cpu); > >> -s390_cpu_set_state(CPU_STATE_OPERATING, ipl_cpu); > >> +s390_cpu_set_state(CPU_INFOS390_STATE_OPERATING, ipl_cpu); > > > > Exposing the state as a QAPI enum has the unfortunate side effect of > > that new name. It feels slightly awkward to me, as it is a state for > > real decisions and not just for info statements... > > I asked Viktor to use the qapi enum instead of having two sets of defines that > we need to keep in sync. (in fact 3, as the kernel kvm mpstate definition is > also > there). Agreed, using the QAPI enum makes sense. > > But yes, the INFO in that name is somewhat strange. No good idea though. Can we call the enum CpuS390State instead of CpuInfoS390State (while keeping the CpuInfoS390 name)? Or does that violate any QAPI rules?
Re: [Qemu-devel] [Qemu-block] [PATCH] block: early check for blockers on drive-mirror
On 08/02/2018 11:10, Alberto Garcia wrote: > On Wed 07 Feb 2018 05:29:20 PM CET, Paolo Bonzini wrote: >> Even if an op blocker is present for BLOCK_OP_TYPE_MIRROR_SOURCE, >> it is checked a bit late and the result is that the target is >> created even if drive-mirror subsequently fails. Add an early >> check to avoid this. >> >> Signed-off-by: Paolo Bonzini >> --- >> blockdev.c | 5 + >> 1 file changed, 5 insertions(+) >> >> diff --git a/blockdev.c b/blockdev.c >> index 8e977eef11..c7e2e0a00e 100644 >> --- a/blockdev.c >> +++ b/blockdev.c >> @@ -3565,6 +3565,11 @@ void qmp_drive_mirror(DriveMirror *arg, Error **errp) >> return; >> } >> >> +/* Early check to avoid creating target */ >> +if (bdrv_op_is_blocked(bs, BLOCK_OP_TYPE_MIRROR_SOURCE, errp)) { >> +return; >> +} >> + >> aio_context = bdrv_get_aio_context(bs); >> aio_context_acquire(aio_context); > > Do we need to hold the AioContext in order to check for op blockers? In include/block/block_int.h, they are not in the "Protected by AioContext lock" section. Paolo
Re: [Qemu-devel] [RFC PATCH 1/5] vfio/quirks: Add common quirk alloc helper
Hi Alex, On 07/02/18 01:26, Alex Williamson wrote: > This will later be used to include list initialization > > Signed-off-by: Alex Williamson > --- > hw/vfio/pci-quirks.c | 48 +--- > 1 file changed, 21 insertions(+), 27 deletions(-) > > diff --git a/hw/vfio/pci-quirks.c b/hw/vfio/pci-quirks.c > index e5779a7ad35b..10af23217292 100644 > --- a/hw/vfio/pci-quirks.c > +++ b/hw/vfio/pci-quirks.c > @@ -275,6 +275,15 @@ static const MemoryRegionOps vfio_ati_3c3_quirk = { > .endianness = DEVICE_LITTLE_ENDIAN, > }; > > +static VFIOQuirk *vfio_quirk_alloc(int nr_mem) > +{ > +VFIOQuirk *quirk = g_malloc0(sizeof(*quirk)); nit: Peter advised the usage of g_new0 as well for that kind of alloc. > +quirk->mem = g_new0(MemoryRegion, nr_mem); > +quirk->nr_mem = nr_mem; > + > +return quirk; > +} > + > static void vfio_vga_probe_ati_3c3_quirk(VFIOPCIDevice *vdev) > { > VFIOQuirk *quirk; > @@ -288,9 +297,7 @@ static void vfio_vga_probe_ati_3c3_quirk(VFIOPCIDevice > *vdev) > return; > } > > -quirk = g_malloc0(sizeof(*quirk)); > -quirk->mem = g_new0(MemoryRegion, 1); > -quirk->nr_mem = 1; > +quirk = vfio_quirk_alloc(1); > > memory_region_init_io(quirk->mem, OBJECT(vdev), &vfio_ati_3c3_quirk, > vdev, >"vfio-ati-3c3-quirk", 1); > @@ -323,9 +330,7 @@ static void vfio_probe_ati_bar4_quirk(VFIOPCIDevice > *vdev, int nr) > return; > } > > -quirk = g_malloc0(sizeof(*quirk)); > -quirk->mem = g_new0(MemoryRegion, 2); > -quirk->nr_mem = 2; > +quirk = vfio_quirk_alloc(2); > window = quirk->data = g_malloc0(sizeof(*window) + > sizeof(VFIOConfigWindowMatch)); > window->vdev = vdev; > @@ -371,10 +376,9 @@ static void vfio_probe_ati_bar2_quirk(VFIOPCIDevice > *vdev, int nr) > return; > } > > -quirk = g_malloc0(sizeof(*quirk)); > +quirk = vfio_quirk_alloc(1); > mirror = quirk->data = g_malloc0(sizeof(*mirror)); > -mirror->mem = quirk->mem = g_new0(MemoryRegion, 1); > -quirk->nr_mem = 1; > +mirror->mem = quirk->mem; > mirror->vdev = vdev; > mirror->offset = 0x4000; > mirror->bar = nr; > @@ -548,10 +552,8 @@ static void > vfio_vga_probe_nvidia_3d0_quirk(VFIOPCIDevice *vdev) > return; > } > > -quirk = g_malloc0(sizeof(*quirk)); > +quirk = vfio_quirk_alloc(2); > quirk->data = data = g_malloc0(sizeof(*data)); > -quirk->mem = g_new0(MemoryRegion, 2); > -quirk->nr_mem = 2; > data->vdev = vdev; > > memory_region_init_io(&quirk->mem[0], OBJECT(vdev), > &vfio_nvidia_3d4_quirk, > @@ -667,9 +669,7 @@ static void vfio_probe_nvidia_bar5_quirk(VFIOPCIDevice > *vdev, int nr) > return; > } > > -quirk = g_malloc0(sizeof(*quirk)); > -quirk->mem = g_new0(MemoryRegion, 4); > -quirk->nr_mem = 4; > +quirk = vfio_quirk_alloc(4); > bar5 = quirk->data = g_malloc0(sizeof(*bar5) + > (sizeof(VFIOConfigWindowMatch) * 2)); > window = &bar5->window; > @@ -762,10 +762,9 @@ static void vfio_probe_nvidia_bar0_quirk(VFIOPCIDevice > *vdev, int nr) > return; > } > > -quirk = g_malloc0(sizeof(*quirk)); > +quirk = vfio_quirk_alloc(1); > mirror = quirk->data = g_malloc0(sizeof(*mirror)); > -mirror->mem = quirk->mem = g_new0(MemoryRegion, 1); > -quirk->nr_mem = 1; > +mirror->mem = quirk->mem; > mirror->vdev = vdev; > mirror->offset = 0x88000; > mirror->bar = nr; > @@ -781,10 +780,9 @@ static void vfio_probe_nvidia_bar0_quirk(VFIOPCIDevice > *vdev, int nr) > > /* The 0x1800 offset mirror only seems to get used by legacy VGA */ > if (vdev->vga) { > -quirk = g_malloc0(sizeof(*quirk)); > +quirk = vfio_quirk_alloc(1); > mirror = quirk->data = g_malloc0(sizeof(*mirror)); > -mirror->mem = quirk->mem = g_new0(MemoryRegion, 1); > -quirk->nr_mem = 1; > +mirror->mem = quirk->mem; > mirror->vdev = vdev; > mirror->offset = 0x1800; > mirror->bar = nr; > @@ -945,9 +943,7 @@ static void vfio_probe_rtl8168_bar2_quirk(VFIOPCIDevice > *vdev, int nr) > return; > } > > -quirk = g_malloc0(sizeof(*quirk)); > -quirk->mem = g_new0(MemoryRegion, 2); > -quirk->nr_mem = 2; > +quirk = vfio_quirk_alloc(2); > quirk->data = rtl = g_malloc0(sizeof(*rtl)); > rtl->vdev = vdev; > > @@ -1507,9 +1503,7 @@ static void vfio_probe_igd_bar4_quirk(VFIOPCIDevice > *vdev, int nr) > } > > /* Setup our quirk to munge GTT addresses to the VM allocated buffer */ > -quirk = g_malloc0(sizeof(*quirk)); > -quirk->mem = g_new0(MemoryRegion, 2); > -quirk->nr_mem = 2; > +quirk = vfio_quirk_alloc(2); > igd = quirk->data = g_malloc0(sizeof(*igd)); > igd->vdev = vdev; > igd->index = ~0; > Reviewed-by
Re: [Qemu-devel] [RFC PATCH 3/5] vfio/quirks: Automatic ioeventfd enabling for NVIDIA BAR0 quirks
Hi Alex, On 07/02/18 01:26, Alex Williamson wrote: > Record data writes that come through the NVIDIA BAR0 quirk, if we get > enough in a row that we're only passing through, automatically enable > an ioeventfd for it. The primary target for this is the MSI-ACK > that NVIDIA uses to allow the MSI interrupt to re-trigger, which is a > 4-byte write, data value 0x0 to offset 0x704 into the quirk, 0x88704 > into BAR0 MMIO space. For an interrupt latency sensitive micro- > benchmark, this takes us from 83% of performance versus disabling the > quirk entirely (which GeForce cannot do), to to almost 90%. > > Signed-off-by: Alex Williamson > --- > hw/vfio/pci-quirks.c | 89 > +- > hw/vfio/pci.h|2 + > 2 files changed, 89 insertions(+), 2 deletions(-) > > diff --git a/hw/vfio/pci-quirks.c b/hw/vfio/pci-quirks.c > index e4cf4ea2dd9c..e739efe601b1 100644lg > --- a/hw/vfio/pci-quirks.c > +++ b/hw/vfio/pci-quirks.c > @@ -203,6 +203,7 @@ typedef struct VFIOConfigMirrorQuirk { > uint32_t offset; > uint8_t bar; > MemoryRegion *mem; > +uint8_t data[]; Do you foresee other usages of data besides the LastDataSet? > } VFIOConfigMirrorQuirk; > > static uint64_t vfio_generic_quirk_mirror_read(void *opaque, > @@ -297,6 +298,50 @@ static void vfio_ioeventfd_exit(VFIOIOEventFD *ioeventfd) > g_free(ioeventfd); > } > add a comment? user handler in case kvm ioeventfd setup failed? > +static void vfio_ioeventfd_handler(void *opaque) > +{ > +VFIOIOEventFD *ioeventfd = opaque; > + > +if (event_notifier_test_and_clear(&ioeventfd->e)) { > +vfio_region_write(ioeventfd->region, ioeventfd->region_addr, > + ioeventfd->data, ioeventfd->size); > +} > +} > + > +static VFIOIOEventFD *vfio_ioeventfd_init(VFIOPCIDevice *vdev, > + MemoryRegion *mr, hwaddr addr, > + unsigned size, uint64_t data, > + VFIORegion *region, > + hwaddr region_addr) > +{ > +VFIOIOEventFD *ioeventfd = g_malloc0(sizeof(*ioeventfd)); > + > +if (event_notifier_init(&ioeventfd->e, 0)) { > +g_free(ioeventfd); > +return NULL; > +} > + > +ioeventfd->mr = mr; > +ioeventfd->addr = addr; > +ioeventfd->size = size; > +ioeventfd->match_data = true; > +ioeventfd->data = data; > +ioeventfd->region = region; > +ioeventfd->region_addr = region_addr; I found difficult to follow the different addr semantic. I understand region_add is the offset % bar and addr is the offset % mirror region. Maybe more explicit names would help (region = bar_region and region_addr = bar_offset) > + > +qemu_set_fd_handler(event_notifier_get_fd(&ioeventfd->e), > +vfio_ioeventfd_handler, NULL, ioeventfd); > +memory_region_add_eventfd(ioeventfd->mr, ioeventfd->addr, > + ioeventfd->size, ioeventfd->match_data, > + ioeventfd->data, &ioeventfd->e); > + > +info_report("Enabled automatic ioeventfd acceleration for %s region %d, " > +"offset 0x%"HWADDR_PRIx", data 0x%"PRIx64", size %u", > +vdev->vbasedev.name, region->nr, region_addr, data, size); > + > +return ioeventfd; > +} > + > static void vfio_vga_probe_ati_3c3_quirk(VFIOPCIDevice *vdev) > { > VFIOQuirk *quirk; > @@ -732,6 +777,13 @@ static void vfio_probe_nvidia_bar5_quirk(VFIOPCIDevice > *vdev, int nr) > trace_vfio_quirk_nvidia_bar5_probe(vdev->vbasedev.name); > } > > +typedef struct LastDataSet { > +hwaddr addr; > +uint64_t data; > +unsigned size; > +int count; > +} LastDataSet; > + > /* > * Finally, BAR0 itself. We want to redirect any accesses to either > * 0x1800 or 0x88000 through the PCI config space access functions. > @@ -742,6 +794,7 @@ static void vfio_nvidia_quirk_mirror_write(void *opaque, > hwaddr addr, > VFIOConfigMirrorQuirk *mirror = opaque; > VFIOPCIDevice *vdev = mirror->vdev; > PCIDevice *pdev = &vdev->pdev; > +LastDataSet *last = (LastDataSet *)&mirror->data; > > vfio_generic_quirk_mirror_write(opaque, addr, data, size); > > @@ -756,6 +809,38 @@ static void vfio_nvidia_quirk_mirror_write(void *opaque, > hwaddr addr, >addr + mirror->offset, data, size); > trace_vfio_quirk_nvidia_bar0_msi_ack(vdev->vbasedev.name); > } > + > +/* > + * Automatically add an ioeventfd to handle any repeated write with the > + * same data and size above the standard PCI config space header. This > is > + * primarily expected to accelerate the MSI-ACK behavior, such as noted > + * above. Current hardware/drivers should trigger an ioeventfd at config > + * offset 0x704 (region offset 0x88704), with data 0x0, size 4. > + */ > +if (addr > PCI
Re: [Qemu-devel] [RFC PATCH 2/5] vfio/quirks: Add generic support for ioveventfds
Hi Alex, On 07/02/18 01:26, Alex Williamson wrote: > We might wish to handle some quirks via ioeventfds, add a list of > ioeventfds to the quirk. The commit title is a bit misleading as we only add the data type and deletion function. > > Signed-off-by: Alex Williamson > --- > hw/vfio/pci-quirks.c | 17 + > hw/vfio/pci.h| 11 +++ > 2 files changed, 28 insertions(+) > > diff --git a/hw/vfio/pci-quirks.c b/hw/vfio/pci-quirks.c > index 10af23217292..e4cf4ea2dd9c 100644 > --- a/hw/vfio/pci-quirks.c > +++ b/hw/vfio/pci-quirks.c > @@ -12,6 +12,7 @@ > > #include "qemu/osdep.h" > #include "qemu/error-report.h" > +#include "qemu/main-loop.h" > #include "qemu/range.h" > #include "qapi/error.h" > #include "qapi/visitor.h" > @@ -278,12 +279,24 @@ static const MemoryRegionOps vfio_ati_3c3_quirk = { > static VFIOQuirk *vfio_quirk_alloc(int nr_mem) > { > VFIOQuirk *quirk = g_malloc0(sizeof(*quirk)); > +QLIST_INIT(&quirk->ioeventfds); > quirk->mem = g_new0(MemoryRegion, nr_mem); > quirk->nr_mem = nr_mem; > > return quirk; > } > > +static void vfio_ioeventfd_exit(VFIOIOEventFD *ioeventfd) > +{ > +QLIST_REMOVE(ioeventfd, next); > +memory_region_del_eventfd(ioeventfd->mr, ioeventfd->addr, > ioeventfd->size, > + ioeventfd->match_data, ioeventfd->data, > + &ioeventfd->e); > +qemu_set_fd_handler(event_notifier_get_fd(&ioeventfd->e), NULL, NULL, > NULL); > +event_notifier_cleanup(&ioeventfd->e); > +g_free(ioeventfd); > +} > + > static void vfio_vga_probe_ati_3c3_quirk(VFIOPCIDevice *vdev) > { > VFIOQuirk *quirk; > @@ -1668,6 +1681,10 @@ void vfio_bar_quirk_exit(VFIOPCIDevice *vdev, int nr) > int i; > > QLIST_FOREACH(quirk, &bar->quirks, next) { > +while (!QLIST_EMPTY(&quirk->ioeventfds)) { > +vfio_ioeventfd_exit(QLIST_FIRST(&quirk->ioeventfds)); > +} > + > for (i = 0; i < quirk->nr_mem; i++) { > memory_region_del_subregion(bar->region.mem, &quirk->mem[i]); > } > diff --git a/hw/vfio/pci.h b/hw/vfio/pci.h > index f4aa13e021fa..146065c2f715 100644 > --- a/hw/vfio/pci.h > +++ b/hw/vfio/pci.h > @@ -24,9 +24,20 @@ > > struct VFIOPCIDevice; > > +typedef struct VFIOIOEventFD { > +QLIST_ENTRY(VFIOIOEventFD) next; > +MemoryRegion *mr; > +hwaddr addr; > +unsigned size; > +bool match_data; Shouldn't you add the match_data field also in the kernel uapi? Thanks Eric > +uint64_t data; > +EventNotifier e; > +} VFIOIOEventFD;. > + > typedef struct VFIOQuirk { > QLIST_ENTRY(VFIOQuirk) next; > void *data; > +QLIST_HEAD(, VFIOIOEventFD) ioeventfds; > int nr_mem; > MemoryRegion *mem; > } VFIOQuirk; >
[Qemu-devel] [PATCH 1/1] hw/audio/sb16.c: missing break statement
This patch adds a break in the switch() statement of complete(), value 0x42: case 0x42: /* FT2 sets output freq with this, go figure */ qemu_log_mask(LOG_UNIMP, "cmd 0x42 might not do what it think it" " should\n"); break; <--- case 0x41: The issue was found by Coverity (#1385841): CID 1385841: Control flow issues (MISSING_BREAK) The case for value "66" is not terminated by a 'break' statement. Fixes: 8ec660b80e ("hw/audio/sb16.c: change dolog() to qemu_log_mask()") Signed-off-by: Daniel Henrique Barboza CC: John Arbuckle CC: Gerd Hoffmann --- hw/audio/sb16.c | 1 + 1 file changed, 1 insertion(+) diff --git a/hw/audio/sb16.c b/hw/audio/sb16.c index 31de264ab7..b2fdcd8437 100644 --- a/hw/audio/sb16.c +++ b/hw/audio/sb16.c @@ -744,6 +744,7 @@ static void complete (SB16State *s) case 0x42: /* FT2 sets output freq with this, go figure */ qemu_log_mask(LOG_UNIMP, "cmd 0x42 might not do what it think it" " should\n"); +break; case 0x41: s->freq = dsp_get_hilo (s); ldebug ("set freq %d\n", s->freq); -- 2.14.3
Re: [Qemu-devel] [PULL 0/1] Bitmaps patches
On 7 February 2018 at 17:01, John Snow wrote: > The following changes since commit 0833df03f4206a6cf416fbb3d380fa95c8e61fba: > > Merge remote-tracking branch > 'remotes/dgilbert/tags/pull-migration-20180206a' into staging (2018-02-07 > 12:07:23 +) > > are available in the Git repository at: > > https://github.com/jnsnow/qemu.git tags/bitmaps-pull-request > > for you to fetch changes up to 3260cdfffbf00f33923f5f9f6bef45932d7ac28b: > > hbitmap: fix missing restore count when finish deserialization (2018-02-07 > 11:35:49 -0500) > > > > > > Liang Li (1): > hbitmap: fix missing restore count when finish deserialization > > util/hbitmap.c | 1 + > 1 file changed, 1 insertion(+) > > -- Applied, thanks. -- PMM
Re: [Qemu-devel] [PATCH v6 00/28] Migration: postcopy failure recovery
Hi, This series failed docker-quick@centos6 build test. Please find the testing commands and their output below. If you have Docker installed, you can probably reproduce it locally. Type: series Message-id: 20180208103132.28452-1-pet...@redhat.com Subject: [Qemu-devel] [PATCH v6 00/28] Migration: postcopy failure recovery === TEST SCRIPT BEGIN === #!/bin/bash set -e git submodule update --init dtc # Let docker tests dump environment info export SHOW_ENV=1 export J=8 time make docker-test-quick@centos6 === TEST SCRIPT END === Updating 3c8cf5a9c21ff8782164d1def7f44bd888713384 Switched to a new branch 'test' 9fef7a46b1 migration/hmp: add migrate_pause command e5bc8840cf migration/qmp: add command migrate-pause ae62f074ca hmp/migration: add migrate_recover command b6a9d72a90 qmp/migration: new command migrate-recover 9903aa7296 io: let watcher of the channel run in same ctx ef37cc9981 migration: init dst in migration_object_init too b9a7a6376d migration: final handshake for the resume 40d1c0e37c migration: setup ramstate for resume 4faada932e migration: synchronize dirty bitmap for resume 1c86b22e54 migration: introduce SaveVMHandlers.resume_prepare 99d5d3ec65 migration: new message MIG_RP_MSG_RESUME_ACK 011a3e5dcf migration: new cmd MIG_CMD_POSTCOPY_RESUME e8ea13af80 migration: new message MIG_RP_MSG_RECV_BITMAP 0527218572 migration: new cmd MIG_CMD_RECV_BITMAP 060b476de0 migration: wakeup dst ram-load-thread for recover 5c512af7ac migration: new state "postcopy-recover" 3c817a2d6a migration: rebuild channel on source 498feb31bf migration: pass MigrationState to migrate_init() 2bd90bc8c7 qmp: hmp: add migrate "resume" option 4310656e2e migration: allow fault thread to pause e5403449fa migration: allow send_rq to fail 82ff14b4eb migration: allow src return path to pause 27b5a83c3a migration: allow dst vm pause on postcopy e89132a741 migration: implement "postcopy-pause" src logic af8b068080 migration: new postcopy-pause state fb163f98cf migration: provide postcopy_fault_thread_notify() b399ae9ca4 migration: reuse mis->userfault_quit_fd fd22ce7d15 migration: better error handling with QEMUFile === OUTPUT BEGIN === Submodule 'dtc' (git://git.qemu-project.org/dtc.git) registered for path 'dtc' Cloning into '/var/tmp/patchew-tester-tmp-hz60dt17/src/dtc'... Submodule path 'dtc': checked out 'e54388015af1fb4bf04d0bca99caba1074d9cc42' BUILD centos6 GEN /var/tmp/patchew-tester-tmp-hz60dt17/src/docker-src.2018-02-08-06.26.47.32024/qemu.tar Cloning into '/var/tmp/patchew-tester-tmp-hz60dt17/src/docker-src.2018-02-08-06.26.47.32024/qemu.tar.vroot'... done. Your branch is up-to-date with 'origin/test'. Submodule 'dtc' (git://git.qemu-project.org/dtc.git) registered for path 'dtc' Cloning into '/var/tmp/patchew-tester-tmp-hz60dt17/src/docker-src.2018-02-08-06.26.47.32024/qemu.tar.vroot/dtc'... Submodule path 'dtc': checked out 'e54388015af1fb4bf04d0bca99caba1074d9cc42' Submodule 'ui/keycodemapdb' (git://git.qemu.org/keycodemapdb.git) registered for path 'ui/keycodemapdb' Cloning into '/var/tmp/patchew-tester-tmp-hz60dt17/src/docker-src.2018-02-08-06.26.47.32024/qemu.tar.vroot/ui/keycodemapdb'... Submodule path 'ui/keycodemapdb': checked out '6b3d716e2b6472eb7189d3220552280ef3d832ce' COPYRUNNER RUN test-quick in qemu:centos6 Packages installed: SDL-devel-1.2.14-7.el6_7.1.x86_64 bison-2.4.1-5.el6.x86_64 bzip2-devel-1.0.5-7.el6_0.x86_64 ccache-3.1.6-2.el6.x86_64 csnappy-devel-0-6.20150729gitd7bc683.el6.x86_64 flex-2.5.35-9.el6.x86_64 gcc-4.4.7-18.el6.x86_64 gettext-0.17-18.el6.x86_64 git-1.7.1-9.el6_9.x86_64 glib2-devel-2.28.8-9.el6.x86_64 libepoxy-devel-1.2-3.el6.x86_64 libfdt-devel-1.4.0-1.el6.x86_64 librdmacm-devel-1.0.21-0.el6.x86_64 lzo-devel-2.03-3.1.el6_5.1.x86_64 make-3.81-23.el6.x86_64 mesa-libEGL-devel-11.0.7-4.el6.x86_64 mesa-libgbm-devel-11.0.7-4.el6.x86_64 package g++ is not installed pixman-devel-0.32.8-1.el6.x86_64 spice-glib-devel-0.26-8.el6.x86_64 spice-server-devel-0.12.4-16.el6.x86_64 tar-1.23-15.el6_8.x86_64 vte-devel-0.25.1-9.el6.x86_64 xen-devel-4.6.6-2.el6.x86_64 zlib-devel-1.2.3-29.el6.x86_64 Environment variables: PACKAGES=bison bzip2-devel ccache csnappy-devel flex g++ gcc gettext git glib2-devel libepoxy-devel libfdt-devel librdmacm-devel lzo-devel make mesa-libEGL-devel mesa-libgbm-devel pixman-devel SDL-devel spice-glib-devel spice-server-devel tar vte-devel xen-devel zlib-devel HOSTNAME=148c7b7b9879 MAKEFLAGS= -j8 J=8 CCACHE_DIR=/var/tmp/ccache EXTRA_CONFIGURE_OPTS= V= SHOW_ENV=1 PATH=/usr/lib/ccache:/usr/lib64/ccache:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin PWD=/ TARGET_LIST= SHLVL=1 HOME=/root TEST_DIR=/tmp/qemu-test FEATURES= dtc DEBUG= _=/usr/bin/env Configure options: --enable-werror --target-list=x86_64-softmmu,aarch64-softmmu --prefix=/tmp/qemu-test/install No C++ compiler available; disabling C++ specific optional code Install prefix
Re: [Qemu-devel] [PATCH v6 00/28] Migration: postcopy failure recovery
Hi, This series failed build test on s390x host. Please find the details below. Type: series Message-id: 20180208103132.28452-1-pet...@redhat.com Subject: [Qemu-devel] [PATCH v6 00/28] Migration: postcopy failure recovery === TEST SCRIPT BEGIN === #!/bin/bash # Testing script will be invoked under the git checkout with # HEAD pointing to a commit that has the patches applied on top of "base" # branch set -e echo "=== ENV ===" env echo "=== PACKAGES ===" rpm -qa echo "=== TEST BEGIN ===" CC=$HOME/bin/cc INSTALL=$PWD/install BUILD=$PWD/build echo -n "Using CC: " realpath $CC mkdir -p $BUILD $INSTALL SRC=$PWD cd $BUILD $SRC/configure --cc=$CC --prefix=$INSTALL make -j4 # XXX: we need reliable clean up # make check -j4 V=1 make install === TEST SCRIPT END === Updating 3c8cf5a9c21ff8782164d1def7f44bd888713384 From https://github.com/patchew-project/qemu 1e5caa0e23..b256b89c63 master -> master t [tag update]patchew/20180207001615.1156.10547.st...@gimli.home -> patchew/20180207001615.1156.10547.st...@gimli.home * [new tag] patchew/20180208103132.28452-1-pet...@redhat.com -> patchew/20180208103132.28452-1-pet...@redhat.com Auto packing the repository in background for optimum performance. See "git help gc" for manual housekeeping. Switched to a new branch 'test' 9fef7a46b1 migration/hmp: add migrate_pause command e5bc8840cf migration/qmp: add command migrate-pause ae62f074ca hmp/migration: add migrate_recover command b6a9d72a90 qmp/migration: new command migrate-recover 9903aa7296 io: let watcher of the channel run in same ctx ef37cc9981 migration: init dst in migration_object_init too b9a7a6376d migration: final handshake for the resume 40d1c0e37c migration: setup ramstate for resume 4faada932e migration: synchronize dirty bitmap for resume 1c86b22e54 migration: introduce SaveVMHandlers.resume_prepare 99d5d3ec65 migration: new message MIG_RP_MSG_RESUME_ACK 011a3e5dcf migration: new cmd MIG_CMD_POSTCOPY_RESUME e8ea13af80 migration: new message MIG_RP_MSG_RECV_BITMAP 0527218572 migration: new cmd MIG_CMD_RECV_BITMAP 060b476de0 migration: wakeup dst ram-load-thread for recover 5c512af7ac migration: new state "postcopy-recover" 3c817a2d6a migration: rebuild channel on source 498feb31bf migration: pass MigrationState to migrate_init() 2bd90bc8c7 qmp: hmp: add migrate "resume" option 4310656e2e migration: allow fault thread to pause e5403449fa migration: allow send_rq to fail 82ff14b4eb migration: allow src return path to pause 27b5a83c3a migration: allow dst vm pause on postcopy e89132a741 migration: implement "postcopy-pause" src logic af8b068080 migration: new postcopy-pause state fb163f98cf migration: provide postcopy_fault_thread_notify() b399ae9ca4 migration: reuse mis->userfault_quit_fd fd22ce7d15 migration: better error handling with QEMUFile === OUTPUT BEGIN === === ENV === LANG=en_US.UTF-8 XDG_SESSION_ID=47049 USER=fam PWD=/var/tmp/patchew-tester-tmp-wyn6ex2x/src HOME=/home/fam SHELL=/bin/sh SHLVL=2 PATCHEW=/home/fam/patchew/patchew-cli -s http://patchew.org --nodebug LOGNAME=fam DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1012/bus XDG_RUNTIME_DIR=/run/user/1012 PATH=/usr/bin:/bin _=/usr/bin/env === PACKAGES === gpg-pubkey-873529b8-54e386ff glibc-debuginfo-common-2.24-10.fc25.s390x fedora-release-26-1.noarch dejavu-sans-mono-fonts-2.35-4.fc26.noarch xemacs-filesystem-21.5.34-22.20170124hgf412e9f093d4.fc26.noarch bash-4.4.12-7.fc26.s390x freetype-2.7.1-9.fc26.s390x libSM-1.2.2-5.fc26.s390x libmpc-1.0.2-6.fc26.s390x libaio-0.3.110-7.fc26.s390x libverto-0.2.6-7.fc26.s390x perl-Scalar-List-Utils-1.48-1.fc26.s390x iptables-libs-1.6.1-2.fc26.s390x perl-threads-shared-1.57-1.fc26.s390x p11-kit-trust-0.23.9-2.fc26.s390x tcl-8.6.6-2.fc26.s390x libxshmfence-1.2-4.fc26.s390x expect-5.45-23.fc26.s390x perl-Thread-Queue-3.12-1.fc26.noarch perl-encoding-2.19-6.fc26.s390x keyutils-1.5.10-1.fc26.s390x gmp-devel-6.1.2-4.fc26.s390x enchant-1.6.0-16.fc26.s390x net-snmp-libs-5.7.3-17.fc26.s390x python-gobject-base-3.24.1-1.fc26.s390x python3-distro-1.0.3-1.fc26.noarch python3-enchant-1.6.10-1.fc26.noarch python-lockfile-0.11.0-6.fc26.noarch python2-pyparsing-2.1.10-3.fc26.noarch python2-lxml-4.1.1-1.fc26.s390x librados2-10.2.7-2.fc26.s390x trousers-lib-0.3.13-7.fc26.s390x libpaper-1.1.24-14.fc26.s390x libdatrie-0.2.9-4.fc26.s390x libsoup-2.58.2-1.fc26.s390x passwd-0.79-9.fc26.s390x bind99-libs-9.9.10-3.P3.fc26.s390x python3-rpm-4.13.0.2-1.fc26.s390x mock-core-configs-27.4-1.fc26.noarch systemd-233-7.fc26.s390x virglrenderer-0.6.0-1.20170210git76b3da97b.fc26.s390x s390utils-ziomon-1.36.1-3.fc26.s390x s390utils-osasnmpd-1.36.1-3.fc26.s390x libXrandr-1.5.1-2.fc26.s390x libglvnd-glx-1.0.0-1.fc26.s390x texlive-ifxetex-svn19685.0.5-33.fc26.2.noarch texlive-psnfss-svn33946.9.2a-33.fc26.2.noarch texlive-dvipdfmx-def-svn40328-33.fc26.2.noarch texlive-natbib-svn20668.8.31b-33.fc26.2.noarch texlive-xdvi-bin-svn40750-33.20160520.fc26.2.s390x texlive-cm-svn32865.0-33.fc26.2.noarch texlive-beton-svn
Re: [Qemu-devel] [PATCH v6 00/28] Migration: postcopy failure recovery
Hi, This series failed docker-build@min-glib build test. Please find the testing commands and their output below. If you have Docker installed, you can probably reproduce it locally. Type: series Message-id: 20180208103132.28452-1-pet...@redhat.com Subject: [Qemu-devel] [PATCH v6 00/28] Migration: postcopy failure recovery === TEST SCRIPT BEGIN === #!/bin/bash set -e git submodule update --init dtc # Let docker tests dump environment info export SHOW_ENV=1 export J=8 time make docker-test-build@min-glib === TEST SCRIPT END === Updating 3c8cf5a9c21ff8782164d1def7f44bd888713384 Switched to a new branch 'test' 9fef7a46b1 migration/hmp: add migrate_pause command e5bc8840cf migration/qmp: add command migrate-pause ae62f074ca hmp/migration: add migrate_recover command b6a9d72a90 qmp/migration: new command migrate-recover 9903aa7296 io: let watcher of the channel run in same ctx ef37cc9981 migration: init dst in migration_object_init too b9a7a6376d migration: final handshake for the resume 40d1c0e37c migration: setup ramstate for resume 4faada932e migration: synchronize dirty bitmap for resume 1c86b22e54 migration: introduce SaveVMHandlers.resume_prepare 99d5d3ec65 migration: new message MIG_RP_MSG_RESUME_ACK 011a3e5dcf migration: new cmd MIG_CMD_POSTCOPY_RESUME e8ea13af80 migration: new message MIG_RP_MSG_RECV_BITMAP 0527218572 migration: new cmd MIG_CMD_RECV_BITMAP 060b476de0 migration: wakeup dst ram-load-thread for recover 5c512af7ac migration: new state "postcopy-recover" 3c817a2d6a migration: rebuild channel on source 498feb31bf migration: pass MigrationState to migrate_init() 2bd90bc8c7 qmp: hmp: add migrate "resume" option 4310656e2e migration: allow fault thread to pause e5403449fa migration: allow send_rq to fail 82ff14b4eb migration: allow src return path to pause 27b5a83c3a migration: allow dst vm pause on postcopy e89132a741 migration: implement "postcopy-pause" src logic af8b068080 migration: new postcopy-pause state fb163f98cf migration: provide postcopy_fault_thread_notify() b399ae9ca4 migration: reuse mis->userfault_quit_fd fd22ce7d15 migration: better error handling with QEMUFile === OUTPUT BEGIN === Submodule 'dtc' (git://git.qemu-project.org/dtc.git) registered for path 'dtc' Cloning into '/var/tmp/patchew-tester-tmp-3cs0psl3/src/dtc'... Submodule path 'dtc': checked out 'e54388015af1fb4bf04d0bca99caba1074d9cc42' BUILD min-glib GEN /var/tmp/patchew-tester-tmp-3cs0psl3/src/docker-src.2018-02-08-06.29.23.2507/qemu.tar Cloning into '/var/tmp/patchew-tester-tmp-3cs0psl3/src/docker-src.2018-02-08-06.29.23.2507/qemu.tar.vroot'... done. Checking out files: 48% (2785/5781) Checking out files: 49% (2833/5781) Checking out files: 50% (2891/5781) Checking out files: 51% (2949/5781) Checking out files: 52% (3007/5781) Checking out files: 53% (3064/5781) Checking out files: 54% (3122/5781) Checking out files: 55% (3180/5781) Checking out files: 56% (3238/5781) Checking out files: 57% (3296/5781) Checking out files: 58% (3353/5781) Checking out files: 59% (3411/5781) Checking out files: 60% (3469/5781) Checking out files: 61% (3527/5781) Checking out files: 62% (3585/5781) Checking out files: 63% (3643/5781) Checking out files: 64% (3700/5781) Checking out files: 65% (3758/5781) Checking out files: 66% (3816/5781) Checking out files: 67% (3874/5781) Checking out files: 68% (3932/5781) Checking out files: 69% (3989/5781) Checking out files: 70% (4047/5781) Checking out files: 71% (4105/5781) Checking out files: 72% (4163/5781) Checking out files: 73% (4221/5781) Checking out files: 74% (4278/5781) Checking out files: 75% (4336/5781) Checking out files: 76% (4394/5781) Checking out files: 77% (4452/5781) Checking out files: 78% (4510/5781) Checking out files: 79% (4567/5781) Checking out files: 80% (4625/5781) Checking out files: 81% (4683/5781) Checking out files: 82% (4741/5781) Checking out files: 83% (4799/5781) Checking out files: 84% (4857/5781) Checking out files: 85% (4914/5781) Checking out files: 86% (4972/5781) Checking out files: 87% (5030/5781) Checking out files: 88% (5088/5781) Checking out files: 89% (5146/5781) Checking out files: 90% (5203/5781) Checking out files: 91% (5261/5781) Checking out files: 92% (5319/5781) Checking out files: 93% (5377/5781) Checking out files: 94% (5435/5781) Checking out files: 95% (5492/5781) Checking out files: 96% (5550/5781) Checking out files: 97% (5608/5781) Checking out files: 98% (5666/5781) Checking out files: 99% (5724/5781) Checking out files: 100% (5781/5781) Checking out files: 100% (5781/5781), done. Your branch is up-to-date with 'origin/test'. Submodule 'dtc' (git://git.qemu-project.org/dtc.git) registered for path 'dtc' Cloning into '/var/tmp/patchew-tester-tmp-3cs0psl3/src/docker-src.2018-02-08-06.29.23.2507/qemu.tar.vr
Re: [Qemu-devel] [RFC] exec: eliminate ram naming issue as migration
On Thu, 8 Feb 2018 18:18:20 +0800 "Tan, Jianfeng" wrote: > On 2/8/2018 5:51 PM, Igor Mammedov wrote: > > On Thu, 8 Feb 2018 09:20:45 +0800 > > "Tan, Jianfeng" wrote: > > > >> On 2/7/2018 8:06 PM, Igor Mammedov wrote: > >>> On Wed, 7 Feb 2018 07:49:58 + > >>> "Tan, Jianfeng" wrote: > >>> > > -Original Message- > > From: Paolo Bonzini [mailto:pbonz...@redhat.com] > > Sent: Tuesday, February 6, 2018 1:32 AM > > To: Igor Mammedov > > Cc: Tan, Jianfeng; qemu-devel@nongnu.org; Jason Wang; Maxime Coquelin; > > Michael S . Tsirkin > > Subject: Re: [Qemu-devel] [RFC] exec: eliminate ram naming issue as > > migration > > > > On 05/02/2018 18:15, Igor Mammedov wrote: > Then we would have both ram block named pc.ram: > Block NamePSize > pc.ram 4 KiB > /objects/pc.ram2 MiB > > But I assume it's a corner case which not really happen. > >>> Yeah, you're right. :/ I hadn't thought of hotplug. It can happen > >>> indeed. > >> perhaps we should fail object_add memory-backend-foo if it resulted > >> in creating ramblock with duplicate id > > Note that it would only be duplicated with Jianfeng's patch. So I'm > > worried that his patch is worse than what we have now, because it may > > create conflicts with system RAMBlock names are not necessarily > > predictable. Right now, -object creates RAMBlock names that are nicely > > constrained within /object/. > So we are trading off between the benefit it takes and the bad effect it > brings. > > I'm wondering if the above example is the only failed case this patch > leads to, i.e, only there is a ram named "pc.ram" and "/object/pc.ram" > in the src VM? > > Please also consider the second option, that adding an alias name for > RAMBlock; I'm not a big fan for that one, as it just pushes the problem > to OpenStack/Libvirt. > >>> looking at provided CLI examples it's configuration issue on src and dst, > >>> one shall not mix numa and non numa variants. > >> Aha, that's another thing we also want to change. We now add numa at dst > >> node, only because without -numa, we cannot set up the file-baked memory > >> with share=on. > > then shouldn't you start src with the same -numa to begin with, > > changing such things on the fly is not supported. > > Yes, you are describing the best practice. But we are originally trying > to migrate without any changes to QEMU. > > > General rule is that machine on dst has to be the same as on src. > > OK. > > > (with backend not visible to guest it possible might be changed > > but it's hard to tell if something would break due to that > > or would continue working in future since doesn't go along with above rule) > > > >> For example, "-m xG -mem-path xxx" can set up a file-baked memory, but > >> the file is not share-able. > > It could be solved by adding memdev option to machine, > > which would allow to specify backend object. And then on > > top make -mem-path alias new option to clean thing up. > > Do you mean? > > src vm: -m xG > dst vm: -m xG,memdev=pc.ram -object > memory-backend-file,id=pc.ram,size=xG,mem-path=xxx,share=on ... Yep, I've meant something like it src vm: -m xG,memdev=SHARED_RAM -object memory-backend-file,id=SHARED_RAM,size=xG,mem-path=xxx,share=on dst vm: -m xG,memdev=SHARED_RAM -object memory-backend-file,id=SHARED_RAM,size=xG,mem-path=xxx,share=on or it could be -machine FOO,inital_ram_memdev=... maybe making -M optional in this case as size is specified by backend PS: it's not a good idea to use QEMU's internal id 'pc.ram' for user specified objects as it might cause problems.
Re: [Qemu-devel] [PATCH] s390x/sclp: fix event mask handling --> stable 2.11.1?
On 02/02/2018 11:35 AM, Cornelia Huck wrote: > On Fri, 2 Feb 2018 11:33:01 +0100 > Cornelia Huck wrote: > >> On Fri, 2 Feb 2018 10:43:18 +0100 >> Christian Borntraeger wrote: >> >>> On 02/02/2018 10:42 AM, Christian Borntraeger wrote: commit 67915de9f038 ("s390x/event-facility: variable-length event masks") switches the sclp receive/send mask. This broke the sclp lm console. >> >> Hum. Probably should add sclp-lm to my test setup. >> Signed-off-by: Christian Borntraeger Fixes: commit 67915de9f038 ("s390x/event-facility: variable-length event masks") Cc: Cornelia Huck >>> >>> opps. Please fixup yourself Conny :-) >> >> Well, you did cc: the original author :) >> >>> Cc: Jason J. Herne Cc: qemu-sta...@nongnu.org --- hw/s390x/event-facility.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hw/s390x/event-facility.c b/hw/s390x/event-facility.c index b0f71f4554..155a69467b 100644 --- a/hw/s390x/event-facility.c +++ b/hw/s390x/event-facility.c @@ -293,10 +293,10 @@ static void write_event_mask(SCLPEventFacility *ef, SCCB *sccb) ef->receive_mask = be32_to_cpu(tmp_mask); /* return the SCLP's capability masks to the guest */ -tmp_mask = cpu_to_be32(get_host_send_mask(ef)); +tmp_mask = cpu_to_be32(get_host_receive_mask(ef)); copy_mask(WEM_RECEIVE_MASK(we_mask, mask_length), (uint8_t *)&tmp_mask, mask_length, sizeof(tmp_mask)); -tmp_mask = cpu_to_be32(get_host_receive_mask(ef)); +tmp_mask = cpu_to_be32(get_host_send_mask(ef)); copy_mask(WEM_SEND_MASK(we_mask, mask_length), (uint8_t *)&tmp_mask, mask_length, sizeof(tmp_mask)); >>> >> >> Thanks, applied. > > Oh, and as always, I still take R-bs until I prepare a pull req. > Would be good to have that in 2.11.1 stable as well I think
Re: [Qemu-devel] [RFC PATCH 3/5] vfio/quirks: Automatic ioeventfd enabling for NVIDIA BAR0 quirks
Hi Alex, On 08/02/18 12:10, Auger Eric wrote: > Hi Alex, > > On 07/02/18 01:26, Alex Williamson wrote: >> Record data writes that come through the NVIDIA BAR0 quirk, if we get >> enough in a row that we're only passing through, automatically enable >> an ioeventfd for it. The primary target for this is the MSI-ACK >> that NVIDIA uses to allow the MSI interrupt to re-trigger, which is a >> 4-byte write, data value 0x0 to offset 0x704 into the quirk, 0x88704 >> into BAR0 MMIO space. For an interrupt latency sensitive micro- >> benchmark, this takes us from 83% of performance versus disabling the >> quirk entirely (which GeForce cannot do), to to almost 90%. >> >> Signed-off-by: Alex Williamson >> --- >> hw/vfio/pci-quirks.c | 89 >> +- >> hw/vfio/pci.h|2 + >> 2 files changed, 89 insertions(+), 2 deletions(-) >> >> diff --git a/hw/vfio/pci-quirks.c b/hw/vfio/pci-quirks.c >> index e4cf4ea2dd9c..e739efe601b1 100644lg > >> --- a/hw/vfio/pci-quirks.c >> +++ b/hw/vfio/pci-quirks.c >> @@ -203,6 +203,7 @@ typedef struct VFIOConfigMirrorQuirk { >> uint32_t offset; >> uint8_t bar; >> MemoryRegion *mem; >> +uint8_t data[]; > Do you foresee other usages of data besides the LastDataSet? >> } VFIOConfigMirrorQuirk; >> >> static uint64_t vfio_generic_quirk_mirror_read(void *opaque, >> @@ -297,6 +298,50 @@ static void vfio_ioeventfd_exit(VFIOIOEventFD >> *ioeventfd) >> g_free(ioeventfd); >> } >> > add a comment? user handler in case kvm ioeventfd setup failed? Forget that. I got confused. At this point you set an ioeventfd which must be handled on user space. In last patch you plug the kernel vfio handler through the new iotcl and only in case this fails you use the userspace handler. Hope I got it right. Eric >> +static void vfio_ioeventfd_handler(void *opaque) >> +{ >> +VFIOIOEventFD *ioeventfd = opaque; >> + >> +if (event_notifier_test_and_clear(&ioeventfd->e)) { >> +vfio_region_write(ioeventfd->region, ioeventfd->region_addr, >> + ioeventfd->data, ioeventfd->size); >> +} >> +} >> + >> +static VFIOIOEventFD *vfio_ioeventfd_init(VFIOPCIDevice *vdev, >> + MemoryRegion *mr, hwaddr addr, >> + unsigned size, uint64_t data, >> + VFIORegion *region, >> + hwaddr region_addr) >> +{ >> +VFIOIOEventFD *ioeventfd = g_malloc0(sizeof(*ioeventfd)); >> + >> +if (event_notifier_init(&ioeventfd->e, 0)) { >> +g_free(ioeventfd); >> +return NULL; >> +} >> + >> +ioeventfd->mr = mr; >> +ioeventfd->addr = addr; >> +ioeventfd->size = size; >> +ioeventfd->match_data = true; >> +ioeventfd->data = data; >> +ioeventfd->region = region; >> +ioeventfd->region_addr = region_addr; > I found difficult to follow the different addr semantic. > I understand region_add is the offset % bar and addr is the offset % > mirror region. Maybe more explicit names would help (region = bar_region > and region_addr = bar_offset) >> + >> +qemu_set_fd_handler(event_notifier_get_fd(&ioeventfd->e), >> +vfio_ioeventfd_handler, NULL, ioeventfd); >> +memory_region_add_eventfd(ioeventfd->mr, ioeventfd->addr, >> + ioeventfd->size, ioeventfd->match_data, >> + ioeventfd->data, &ioeventfd->e); >> + >> +info_report("Enabled automatic ioeventfd acceleration for %s region %d, >> " >> +"offset 0x%"HWADDR_PRIx", data 0x%"PRIx64", size %u", >> +vdev->vbasedev.name, region->nr, region_addr, data, size); >> + >> +return ioeventfd; >> +} >> + >> static void vfio_vga_probe_ati_3c3_quirk(VFIOPCIDevice *vdev) >> { >> VFIOQuirk *quirk; >> @@ -732,6 +777,13 @@ static void vfio_probe_nvidia_bar5_quirk(VFIOPCIDevice >> *vdev, int nr) >> trace_vfio_quirk_nvidia_bar5_probe(vdev->vbasedev.name); >> } >> >> +typedef struct LastDataSet { >> +hwaddr addr; >> +uint64_t data; >> +unsigned size; >> +int count; >> +} LastDataSet; >> + >> /* >> * Finally, BAR0 itself. We want to redirect any accesses to either >> * 0x1800 or 0x88000 through the PCI config space access functions. >> @@ -742,6 +794,7 @@ static void vfio_nvidia_quirk_mirror_write(void *opaque, >> hwaddr addr, >> VFIOConfigMirrorQuirk *mirror = opaque; >> VFIOPCIDevice *vdev = mirror->vdev; >> PCIDevice *pdev = &vdev->pdev; >> +LastDataSet *last = (LastDataSet *)&mirror->data; >> >> vfio_generic_quirk_mirror_write(opaque, addr, data, size); >> >> @@ -756,6 +809,38 @@ static void vfio_nvidia_quirk_mirror_write(void >> *opaque, hwaddr addr, >>addr + mirror->offset, data, size); >> trace_vfio_quirk_nvidia_bar0_msi_ack(vdev->vbasedev.name); >> } >>
Re: [Qemu-devel] [PATCH v6 00/28] Migration: postcopy failure recovery
Hi, This series failed docker-mingw@fedora build test. Please find the testing commands and their output below. If you have Docker installed, you can probably reproduce it locally. Type: series Message-id: 20180208103132.28452-1-pet...@redhat.com Subject: [Qemu-devel] [PATCH v6 00/28] Migration: postcopy failure recovery === TEST SCRIPT BEGIN === #!/bin/bash set -e git submodule update --init dtc # Let docker tests dump environment info export SHOW_ENV=1 export J=8 time make docker-test-mingw@fedora === TEST SCRIPT END === Updating 3c8cf5a9c21ff8782164d1def7f44bd888713384 Switched to a new branch 'test' 9fef7a46b1 migration/hmp: add migrate_pause command e5bc8840cf migration/qmp: add command migrate-pause ae62f074ca hmp/migration: add migrate_recover command b6a9d72a90 qmp/migration: new command migrate-recover 9903aa7296 io: let watcher of the channel run in same ctx ef37cc9981 migration: init dst in migration_object_init too b9a7a6376d migration: final handshake for the resume 40d1c0e37c migration: setup ramstate for resume 4faada932e migration: synchronize dirty bitmap for resume 1c86b22e54 migration: introduce SaveVMHandlers.resume_prepare 99d5d3ec65 migration: new message MIG_RP_MSG_RESUME_ACK 011a3e5dcf migration: new cmd MIG_CMD_POSTCOPY_RESUME e8ea13af80 migration: new message MIG_RP_MSG_RECV_BITMAP 0527218572 migration: new cmd MIG_CMD_RECV_BITMAP 060b476de0 migration: wakeup dst ram-load-thread for recover 5c512af7ac migration: new state "postcopy-recover" 3c817a2d6a migration: rebuild channel on source 498feb31bf migration: pass MigrationState to migrate_init() 2bd90bc8c7 qmp: hmp: add migrate "resume" option 4310656e2e migration: allow fault thread to pause e5403449fa migration: allow send_rq to fail 82ff14b4eb migration: allow src return path to pause 27b5a83c3a migration: allow dst vm pause on postcopy e89132a741 migration: implement "postcopy-pause" src logic af8b068080 migration: new postcopy-pause state fb163f98cf migration: provide postcopy_fault_thread_notify() b399ae9ca4 migration: reuse mis->userfault_quit_fd fd22ce7d15 migration: better error handling with QEMUFile === OUTPUT BEGIN === Submodule 'dtc' (git://git.qemu-project.org/dtc.git) registered for path 'dtc' Cloning into '/var/tmp/patchew-tester-tmp-j5ruvtlw/src/dtc'... Submodule path 'dtc': checked out 'e54388015af1fb4bf04d0bca99caba1074d9cc42' BUILD fedora GEN /var/tmp/patchew-tester-tmp-j5ruvtlw/src/docker-src.2018-02-08-06.23.42.29455/qemu.tar Cloning into '/var/tmp/patchew-tester-tmp-j5ruvtlw/src/docker-src.2018-02-08-06.23.42.29455/qemu.tar.vroot'... done. Your branch is up-to-date with 'origin/test'. Submodule 'dtc' (git://git.qemu-project.org/dtc.git) registered for path 'dtc' Cloning into '/var/tmp/patchew-tester-tmp-j5ruvtlw/src/docker-src.2018-02-08-06.23.42.29455/qemu.tar.vroot/dtc'... Submodule path 'dtc': checked out 'e54388015af1fb4bf04d0bca99caba1074d9cc42' Submodule 'ui/keycodemapdb' (git://git.qemu.org/keycodemapdb.git) registered for path 'ui/keycodemapdb' Cloning into '/var/tmp/patchew-tester-tmp-j5ruvtlw/src/docker-src.2018-02-08-06.23.42.29455/qemu.tar.vroot/ui/keycodemapdb'... Submodule path 'ui/keycodemapdb': checked out '6b3d716e2b6472eb7189d3220552280ef3d832ce' COPYRUNNER RUN test-mingw in qemu:fedora Packages installed: PyYAML-3.11-13.fc25.x86_64 SDL-devel-1.2.15-21.fc24.x86_64 bc-1.06.95-16.fc24.x86_64 bison-3.0.4-4.fc24.x86_64 bzip2-1.0.6-21.fc25.x86_64 ccache-3.3.4-1.fc25.x86_64 clang-3.9.1-2.fc25.x86_64 findutils-4.6.0-8.fc25.x86_64 flex-2.6.0-3.fc25.x86_64 gcc-6.4.1-1.fc25.x86_64 gcc-c++-6.4.1-1.fc25.x86_64 gettext-0.19.8.1-3.fc25.x86_64 git-2.9.5-3.fc25.x86_64 glib2-devel-2.50.3-1.fc25.x86_64 hostname-3.15-8.fc25.x86_64 libaio-devel-0.3.110-6.fc24.x86_64 libasan-6.4.1-1.fc25.x86_64 libfdt-devel-1.4.2-1.fc25.x86_64 libubsan-6.4.1-1.fc25.x86_64 make-4.1-6.fc25.x86_64 mingw32-SDL-1.2.15-7.fc24.noarch mingw32-bzip2-1.0.6-7.fc24.noarch mingw32-curl-7.47.0-1.fc24.noarch mingw32-glib2-2.50.3-1.fc25.noarch mingw32-gmp-6.1.1-1.fc25.noarch mingw32-gnutls-3.5.5-2.fc25.noarch mingw32-gtk2-2.24.31-2.fc25.noarch mingw32-gtk3-3.22.17-1.fc25.noarch mingw32-libjpeg-turbo-1.5.1-1.fc25.noarch mingw32-libpng-1.6.27-1.fc25.noarch mingw32-libssh2-1.4.3-5.fc24.noarch mingw32-libtasn1-4.9-1.fc25.noarch mingw32-nettle-3.3-1.fc25.noarch mingw32-pixman-0.34.0-1.fc25.noarch mingw32-pkg-config-0.28-6.fc24.x86_64 mingw64-SDL-1.2.15-7.fc24.noarch mingw64-bzip2-1.0.6-7.fc24.noarch mingw64-curl-7.47.0-1.fc24.noarch mingw64-glib2-2.50.3-1.fc25.noarch mingw64-gmp-6.1.1-1.fc25.noarch mingw64-gnutls-3.5.5-2.fc25.noarch mingw64-gtk2-2.24.31-2.fc25.noarch mingw64-gtk3-3.22.17-1.fc25.noarch mingw64-libjpeg-turbo-1.5.1-1.fc25.noarch mingw64-libpng-1.6.27-1.fc25.noarch mingw64-libssh2-1.4.3-5.fc24.noarch mingw64-libtasn1-4.9-1.fc25.noarch mingw64-nettle-3.3-1.fc25.noarch mingw64-pixman-0.34.0-1.fc25.noarch mingw64-pkg-config-0.28-6.fc24.x86_64 nettle-devel-3.3-1.fc25.x86_64 perl-5.24.3-389.fc25.x86_64 pixm
Re: [Qemu-devel] [RFC PATCH 5/5] vfio/quirks: Enable ioeventfd quirks to be handled by vfio directly
Hi Alex, On 07/02/18 01:26, Alex Williamson wrote: > With vfio ioeventfd support, we can program vfio-pci to perform a > specified BAR write when an eventfd is triggered. This allows the > KVM ioeventfd to be wired directly to vfio-pci, entirely avoiding > userspace handling for these events. On the same micro-benchmark > where the ioeventfd got us to almost 90% of performance versus > disabling the GeForce quirks, this gets us to within 95%. > > Signed-off-by: Alex Williamson > --- > hw/vfio/pci-quirks.c | 42 -- > 1 file changed, 36 insertions(+), 6 deletions(-) > > diff --git a/hw/vfio/pci-quirks.c b/hw/vfio/pci-quirks.c > index e739efe601b1..35a4d5197e2d 100644 > --- a/hw/vfio/pci-quirks.c > +++ b/hw/vfio/pci-quirks.c > @@ -16,6 +16,7 @@ > #include "qemu/range.h" > #include "qapi/error.h" > #include "qapi/visitor.h" > +#include > #include "hw/nvram/fw_cfg.h" > #include "pci.h" > #include "trace.h" > @@ -287,13 +288,27 @@ static VFIOQuirk *vfio_quirk_alloc(int nr_mem) > return quirk; > } > > -static void vfio_ioeventfd_exit(VFIOIOEventFD *ioeventfd) > +static void vfio_ioeventfd_exit(VFIOPCIDevice *vdev, VFIOIOEventFD > *ioeventfd) > { > +struct vfio_device_ioeventfd vfio_ioeventfd; > + > QLIST_REMOVE(ioeventfd, next); > + > memory_region_del_eventfd(ioeventfd->mr, ioeventfd->addr, > ioeventfd->size, >ioeventfd->match_data, ioeventfd->data, >&ioeventfd->e); > + > qemu_set_fd_handler(event_notifier_get_fd(&ioeventfd->e), NULL, NULL, > NULL); > + > +vfio_ioeventfd.argsz = sizeof(vfio_ioeventfd); > +vfio_ioeventfd.flags = ioeventfd->size; > +vfio_ioeventfd.data = ioeventfd->data; > +vfio_ioeventfd.offset = ioeventfd->region->fd_offset + > +ioeventfd->region_addr; > +vfio_ioeventfd.fd = -1; > + > +ioctl(vdev->vbasedev.fd, VFIO_DEVICE_IOEVENTFD, &vfio_ioeventfd); > + > event_notifier_cleanup(&ioeventfd->e); > g_free(ioeventfd); > } > @@ -315,6 +330,8 @@ static VFIOIOEventFD *vfio_ioeventfd_init(VFIOPCIDevice > *vdev, >hwaddr region_addr) > { > VFIOIOEventFD *ioeventfd = g_malloc0(sizeof(*ioeventfd)); > +struct vfio_device_ioeventfd vfio_ioeventfd; > +char vfio_enabled = '+'; > > if (event_notifier_init(&ioeventfd->e, 0)) { > g_free(ioeventfd); > @@ -329,15 +346,28 @@ static VFIOIOEventFD *vfio_ioeventfd_init(VFIOPCIDevice > *vdev, > ioeventfd->region = region; > ioeventfd->region_addr = region_addr; > > -qemu_set_fd_handler(event_notifier_get_fd(&ioeventfd->e), > -vfio_ioeventfd_handler, NULL, ioeventfd); > +vfio_ioeventfd.argsz = sizeof(vfio_ioeventfd); > +vfio_ioeventfd.flags = ioeventfd->size; > +vfio_ioeventfd.data = ioeventfd->data; > +vfio_ioeventfd.offset = ioeventfd->region->fd_offset + > +ioeventfd->region_addr; > +vfio_ioeventfd.fd = event_notifier_get_fd(&ioeventfd->e); > + > +if (ioctl(vdev->vbasedev.fd, > + VFIO_DEVICE_IOEVENTFD, &vfio_ioeventfd) != 0) { > +qemu_set_fd_handler(event_notifier_get_fd(&ioeventfd->e), > +vfio_ioeventfd_handler, NULL, ioeventfd); > +vfio_enabled = '-'; > +} > + > memory_region_add_eventfd(ioeventfd->mr, ioeventfd->addr, >ioeventfd->size, ioeventfd->match_data, >ioeventfd->data, &ioeventfd->e); > > info_report("Enabled automatic ioeventfd acceleration for %s region %d, " > -"offset 0x%"HWADDR_PRIx", data 0x%"PRIx64", size %u", > -vdev->vbasedev.name, region->nr, region_addr, data, size); > +"offset 0x%"HWADDR_PRIx", data 0x%"PRIx64", size %u, vfio%c", > +vdev->vbasedev.name, region->nr, region_addr, data, size, > +vfio_enabled); Not sure if this message is really helpful for the end-user to understand what happens. Maybe adding a trace event when everything happens as it should and an error_report if we failed setting up the vfio kernel handler, explaining the sub-optimal performance that can result. Thanks Eric > > return ioeventfd; > } > @@ -1767,7 +1797,7 @@ void vfio_bar_quirk_exit(VFIOPCIDevice *vdev, int nr) > > QLIST_FOREACH(quirk, &bar->quirks, next) { > while (!QLIST_EMPTY(&quirk->ioeventfds)) { > -vfio_ioeventfd_exit(QLIST_FIRST(&quirk->ioeventfds)); > +vfio_ioeventfd_exit(vdev, QLIST_FIRST(&quirk->ioeventfds)); > } > > for (i = 0; i < quirk->nr_mem; i++) { >
Re: [Qemu-devel] [PATCH] s390x/sclp: fix event mask handling --> stable 2.11.1?
On Thu, 8 Feb 2018 12:30:28 +0100 Christian Borntraeger wrote: > On 02/02/2018 11:35 AM, Cornelia Huck wrote: > > On Fri, 2 Feb 2018 11:33:01 +0100 > > Cornelia Huck wrote: > > > >> On Fri, 2 Feb 2018 10:43:18 +0100 > >> Christian Borntraeger wrote: > >> > >>> On 02/02/2018 10:42 AM, Christian Borntraeger wrote: > commit 67915de9f038 ("s390x/event-facility: variable-length event > masks") switches the sclp receive/send mask. This broke the sclp > lm console. > >> > >> Hum. Probably should add sclp-lm to my test setup. > >> > > Signed-off-by: Christian Borntraeger > Fixes: commit 67915de9f038 ("s390x/event-facility: variable-length event > masks") > Cc: Cornelia Huck > >>> > >>> opps. Please fixup yourself Conny :-) > >> > >> Well, you did cc: the original author :) > >> > >>> > Cc: Jason J. Herne > Cc: qemu-sta...@nongnu.org > --- > hw/s390x/event-facility.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/hw/s390x/event-facility.c b/hw/s390x/event-facility.c > index b0f71f4554..155a69467b 100644 > --- a/hw/s390x/event-facility.c > +++ b/hw/s390x/event-facility.c > @@ -293,10 +293,10 @@ static void write_event_mask(SCLPEventFacility > *ef, SCCB *sccb) > ef->receive_mask = be32_to_cpu(tmp_mask); > > /* return the SCLP's capability masks to the guest */ > -tmp_mask = cpu_to_be32(get_host_send_mask(ef)); > +tmp_mask = cpu_to_be32(get_host_receive_mask(ef)); > copy_mask(WEM_RECEIVE_MASK(we_mask, mask_length), (uint8_t > *)&tmp_mask, > mask_length, sizeof(tmp_mask)); > -tmp_mask = cpu_to_be32(get_host_receive_mask(ef)); > +tmp_mask = cpu_to_be32(get_host_send_mask(ef)); > copy_mask(WEM_SEND_MASK(we_mask, mask_length), (uint8_t *)&tmp_mask, > mask_length, sizeof(tmp_mask)); > > >>> > >> > >> Thanks, applied. > > > > Oh, and as always, I still take R-bs until I prepare a pull req. > > > > Would be good to have that in 2.11.1 stable as well I think > FWIW, this is queued in s390-next and will go into a pull request in the next days. Not sure if anything else is needed?
Re: [Qemu-devel] [PATCH v6 0/5] target-arm: add SHA-3, SM3 and SHA512 instruction support
On 7 February 2018 at 11:17, Ard Biesheuvel wrote: > Changes since v5: > - fix use of same register for destination and source in SHA-512 code > - use correct free() function in SHA-3 code > - drop helper for sm3ss1 in SM3 code > - include fixed version of SM4 (correct # of iterations) > - enable SM4 in user mode emulator Thanks -- this version passes all my tests and I've put it into target-arm.next. -- PMM
Re: [Qemu-devel] [PATCH 3/3] MAINTAINERS: add David as additional tcg/s390 maintainer
On 07.02.2018 16:55, Cornelia Huck wrote: > Signed-off-by: Cornelia Huck > --- > MAINTAINERS | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/MAINTAINERS b/MAINTAINERS > index bd2dc7ed7c..b30d2ca23a 100644 > --- a/MAINTAINERS > +++ b/MAINTAINERS > @@ -236,6 +236,7 @@ F: disas/ppc.c > S390 > M: Richard Henderson > M: Alexander Graf > +M: David Hildenbrand > S: Maintained > F: target/s390x/ > F: hw/s390x/ > Thanks for the trust! Acked-by: David Hildenbrand -- Thanks, David / dhildenb
Re: [Qemu-devel] [PATCH 1/1] hw/audio/sb16.c: missing break statement
Hi Daniel, On 02/08/2018 07:57 AM, Daniel Henrique Barboza wrote: > This patch adds a break in the switch() statement of complete(), > value 0x42: > > case 0x42: /* FT2 sets output freq with this, go figure */ > qemu_log_mask(LOG_UNIMP, "cmd 0x42 might not do what it think it" > " should\n"); > break; <--- > case 0x41: It seems this is an intentional fallthrough, I understand cmd 0x42 is expected to do the same of 0x41 and _a bit more_ (see commit 85571bc7415). > > The issue was found by Coverity (#1385841): > > CID 1385841: Control flow issues (MISSING_BREAK) > The case for value "66" is not terminated by a 'break' statement. > > Fixes: 8ec660b80e ("hw/audio/sb16.c: change dolog() to qemu_log_mask()") > Signed-off-by: Daniel Henrique Barboza > CC: John Arbuckle > CC: Gerd Hoffmann > --- > hw/audio/sb16.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/hw/audio/sb16.c b/hw/audio/sb16.c > index 31de264ab7..b2fdcd8437 100644 > --- a/hw/audio/sb16.c > +++ b/hw/audio/sb16.c > @@ -744,6 +744,7 @@ static void complete (SB16State *s) > case 0x42: /* FT2 sets output freq with this, go figure > */ > qemu_log_mask(LOG_UNIMP, "cmd 0x42 might not do what it think it" >" should\n"); > +break; > case 0x41: > s->freq = dsp_get_hilo (s); > ldebug ("set freq %d\n", s->freq); >
Re: [Qemu-devel] [Qemu-ppc] [PATCH v2] spapr: check smp_threads <= vsmt
On Thu, 8 Feb 2018 10:42:41 +0100 Laurent Vivier wrote: > We ignore silently the value of smp_threads when we set > the default VSMT value, and if smp_threads is greater than VSMT > kernel is going into trouble later. > > Fixes: 8904e5a750 > ("spapr: Adjust default VSMT value for better migration compatibility") > > Signed-off-by: Laurent Vivier > --- > Reviewed-by: Greg Kurz > Notes: > v2: display a specific error message when the default VSMT is used > fix subject > > hw/ppc/spapr.c | 6 ++ > 1 file changed, 6 insertions(+) > > diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c > index 32a876be56..11de276cd5 100644 > --- a/hw/ppc/spapr.c > +++ b/hw/ppc/spapr.c > @@ -2311,6 +2311,12 @@ static void spapr_set_vsmt_mode(sPAPRMachineState > *spapr, Error **errp) > * overwhelmingly common case in production systems. > */ > spapr->vsmt = 8; > +if (spapr->vsmt < smp_threads) { > +error_setg(&local_err, "Cannot support %d threads/core" > + " because it must be <= to default VSMT mode (%d)", > + smp_threads, spapr->vsmt); > +goto out; > +} > } > > /* KVM: If necessary, set the SMT mode: */
Re: [Qemu-devel] [PATCH 1/3] MAINTAINERS: add myself as overall s390x maintainer
On 07.02.2018 16:55, Cornelia Huck wrote: > All your mainframes are belong to me. This looks like an easy way to get a lot of expensive hardware :) > > Signed-off-by: Cornelia Huck > --- > MAINTAINERS | 23 +++ > 1 file changed, 23 insertions(+) > > diff --git a/MAINTAINERS b/MAINTAINERS > index bbc3a617c2..e24273a574 100644 > --- a/MAINTAINERS > +++ b/MAINTAINERS > @@ -76,6 +76,29 @@ K: ^Subject:.*(?i)trivial > T: git git://git.corpit.ru/qemu.git trivial-patches > T: git git://github.com/vivier/qemu.git trivial-patches > > +Architecture support > + > +S390 > +M: Cornelia Huck > +S: Supported > +F: default-configs/s390x-softmmu.mak > +F: gdb-xml/s390*.xml > +F: hw/char/sclp*.[hc] > +F: hw/char/terminal3270.c > +F: hw/intc/s390_flic.c > +F: hw/intc/s390_flic_kvm.c > +F: hw/s390x/ > +F: hw/vfio/ccw.c > +F: hw/watchdog/wdt_diag288.c > +F: include/hw/s390x/ > +F: include/hw/watchdog/wdt_diag288.h > +F: pc-bios/s390-ccw/ > +F: pc-bios/s390-ccw.img > +F: target/s390x/ > +K: ^Subject:.*(?i)s390(x|) > +T: git git://github.com/cohuck/qemu.git s390-next > +L: qemu-s3...@nongnu.org > + > Guest CPU cores (TCG): > -- > Overall > -- Thanks, David / dhildenb
[Qemu-devel] [Bug 1663287] Re: Illegal delay slot code causes abort on mips64
** Changed in: qemu Status: Fix Released => New -- You received this bug notification because you are a member of qemu- devel-ml, which is subscribed to QEMU. https://bugs.launchpad.net/bugs/1663287 Title: Illegal delay slot code causes abort on mips64 Status in QEMU: New Bug description: During some randomised testing of an experimental MIPS implementation I found an instruction sequence that also causes aborts on mainline qemu's MIPS support. The problem is triggered by an MSA branch instruction appearing in a delay slot when emulating a processor without MSA support. For example, with the current repository HEAD (f073cd3a2bf1054135271b837c58a7da650dd84b) configured for mips64-softmmu, if I run the attached binary using mips64-softmmu/qemu-system-mips64 -bios ../abort2.bin -machine mipssim -nographic it will report unknown branch 0x13000 Aborted (core dumped) The binary contains the following two instructions: 0028 jr at 47081e61 bz.b w8,0xbfc0798c The jr sets up a jump, and hflags is set accordingly in gen_compute_branch (in target/mips/translate.c). When processing the bz.b, check_insn generates an exception because the instruction isn't support, but gen_msa_branch skips the usual delay slot check for the same reason, and sets more bits in hflags, leading to an abort in gen_branch because the hflags are now invalid. I suspect the best fix is to remove the instruction set condition from the delay slot check in gen_msa_branch. To manage notifications about this bug go to: https://bugs.launchpad.net/qemu/+bug/1663287/+subscriptions
Re: [Qemu-devel] [Qemu-block] [PATCH] block: early check for blockers on drive-mirror
On Wed 07 Feb 2018 05:29:20 PM CET, Paolo Bonzini wrote: > Even if an op blocker is present for BLOCK_OP_TYPE_MIRROR_SOURCE, > it is checked a bit late and the result is that the target is > created even if drive-mirror subsequently fails. Add an early > check to avoid this. > > Signed-off-by: Paolo Bonzini Reviewed-by: Alberto Garcia Berto
Re: [Qemu-devel] [Qemu-stable] [PATCH 00/54] Patch Round-up for stable 2.11.1, freeze on 2018-02-12
Am 06.02.2018 um 20:14 schrieb Michael Roth: Hi everyone, The following new patches are queued for QEMU stable v2.11.1: https://github.com/mdroth/qemu/commits/stable-2.11-staging The release is planned for 2017-02-14: https://wiki.qemu.org/Planning/2.11 Please respond here or CC qemu-sta...@nongnu.org on any patches you think should be included in the release. Of particular importance would be any feedback on the various QEMU patches relating to Spectre/Meltdown mitigation. The current tree has what I understand to be the QEMU components required for x86, s390, and pseries, but feedback/confirmation from the various authors would be greatly appreciated. Hi, I also found the following patches that affect migration: migration: Don't leak IO channels migration: Recover block devices if failure in device state migration/savevm.c: set MAX_VM_CMD_PACKAGED_SIZE to 1ul << 32 In general it seems that migration related patches are often not tagged qemu-stable. David, can you check if there are patches missing? Thank you, Peter
Re: [Qemu-devel] [PULL 0/4] RDMA patches
On 5 February 2018 at 10:26, Marcel Apfelbaum wrote: > The following changes since commit f24ee107a07f093bd7ed475dd48d7ba57ea3d8fe: > > Merge remote-tracking branch 'remotes/kraxel/tags/ui-20180202-pull-request' > into staging (2018-02-02 18:54:11 +) > > are available in the git repository at: > > https://github.com/marcel-apf/qemu tags/rdma-pull-request > > for you to fetch changes up to f172ba1b02724fb66dabd69cd553cfa625b413e5: > > MAINTAINERS: add entry for hw/rdma (2018-02-05 11:53:00 +0200) > > > PVRDMA implementation > > > Marcel Apfelbaum (3): > mem: add share parameter to memory-backend-ram > docs: add pvrdma device documentation. > MAINTAINERS: add entry for hw/rdma > > Yuval Shaia (1): > pvrdma: initial implementation Hi. The technical details of this pullreq are all fine (pgp key, format, etc), and it passes my build tests. But I gave this pullreq a bit of a closer inspection than I normally would, since it's your first, and there are a few things I thought worth bringing up: (1) I notice that some of the new files in this pullreq are licensed as "GPL, version 2", rather than "version 2 or any later version". Did you really mean that? Per 'LICENSE', we have a strong preference for 2-or-later for new code. (2) Some new files have no copyright or license comment at the top of them. Can you fix that, please? (3) Some of the new headers use kernel-internals __u32 etc types. This isn't portable. ('HACKING' has some suggestions for types you might want instead.) (4) One of your patches doesn't have any reviewed-by tags. We don't always manage to review everything, but it is nicer if we can get review, especially for patches from new submaintainers. (5) This is an absolutely enormous diffstat for a single commit: 26 files changed, 5149 insertions(+), 4 deletions(-) thanks -- PMM
Re: [Qemu-devel] [PATCH 1/1] hw/audio/sb16.c: missing break statement
On 8 February 2018 at 12:15, Philippe Mathieu-Daudé wrote: > Hi Daniel, > > On 02/08/2018 07:57 AM, Daniel Henrique Barboza wrote: >> This patch adds a break in the switch() statement of complete(), >> value 0x42: >> >> case 0x42: /* FT2 sets output freq with this, go figure */ >> qemu_log_mask(LOG_UNIMP, "cmd 0x42 might not do what it think it" >> " should\n"); >> break; <--- >> case 0x41: > > It seems this is an intentional fallthrough, I understand cmd 0x42 is > expected to do the same of 0x41 and _a bit more_ (see commit 85571bc7415). Yes, I agree; I wrote a bit about this in this thread: https://lists.gnu.org/archive/html/qemu-devel/2018-02/msg02081.html (though my guess is that actually 0x42 is supposed to do exactly what 0x41 does, and that the LOG_UNIMP should maybe just be removed). thanks -- PMM
Re: [Qemu-devel] [PATCH 1/1] hw/audio/sb16.c: missing break statement
On Thu, Feb 08, 2018 at 09:15:10AM -0300, Philippe Mathieu-Daudé wrote: > Hi Daniel, > > On 02/08/2018 07:57 AM, Daniel Henrique Barboza wrote: > > This patch adds a break in the switch() statement of complete(), > > value 0x42: > > > > case 0x42: /* FT2 sets output freq with this, go figure */ > > qemu_log_mask(LOG_UNIMP, "cmd 0x42 might not do what it think it" > > " should\n"); > > break; <--- > > case 0x41: > > It seems this is an intentional fallthrough, I understand cmd 0x42 is > expected to do the same of 0x41 and _a bit more_ (see commit 85571bc7415). It might be nice to turn on -Wimplicit-fallthrough and then annotate valid locations like this in qemu with /* fallthrough */ Although GCC has an __attribute((fallthrough)), the warning flag impl also looks for that magic comment, and the magic comment is portable to clang too. Regards, Daniel -- |: https://berrange.com -o-https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o-https://fstop138.berrange.com :| |: https://entangle-photo.org-o-https://www.instagram.com/dberrange :|
Re: [Qemu-devel] [PATCH 1/1] hw/audio/sb16.c: missing break statement
On 02/08/2018 10:01 AM, Peter Maydell wrote: > On 8 February 2018 at 12:15, Philippe Mathieu-Daudé wrote: >> Hi Daniel, >> >> On 02/08/2018 07:57 AM, Daniel Henrique Barboza wrote: >>> This patch adds a break in the switch() statement of complete(), >>> value 0x42: >>> >>> case 0x42: /* FT2 sets output freq with this, go figure */ >>> qemu_log_mask(LOG_UNIMP, "cmd 0x42 might not do what it think it" >>> " should\n"); >>> break; <--- >>> case 0x41: >> >> It seems this is an intentional fallthrough, I understand cmd 0x42 is >> expected to do the same of 0x41 and _a bit more_ (see commit 85571bc7415). > > Yes, I agree; I wrote a bit about this in this thread: > https://lists.gnu.org/archive/html/qemu-devel/2018-02/msg02081.html Oh, very useful link! > (though my guess is that actually 0x42 is supposed to do exactly > what 0x41 does, and that the LOG_UNIMP should maybe just be removed). I now understand 0x42 sets the dsp input sampling freq, the model seems to be designed with output in mind, then added input support (using same freq as output). So imho the simpler/safer fix would be: case 0x42: if (dsp_get_hilo(s) != s->freq) { qemu_log_mask(LOG_UNIMP, "input sampling freq different than " "output not implemented"); } /* fallthrough */ case 0x41: ... and the correct fix would be split s->freq in {s->freq_in, s->freq_out} but nobody ever required this during at least 14 years.
[Qemu-devel] [PATCH 1/1] nbd: increase maximum size of the PWRITE_ZERO request
Upstream NBD protocol implementation supports an efficient zero out mechanism over the wire, along with the ability to check whether a client allows using a hole. Accordingly, since PWRITE_ZERO doesn't involve any payload on the wire, increase a maximum size of the PWRITE_ZERO request up to 1Gb (aligned). Moreover, such change will decrease the number of PWRITE_ZERO NBD commands in comparison with the current 32M limit. The benefits of the larger constraint can be examined in a block mirroring over NBD. Signed-off-by: Edgar Kaziakhmedov --- block/nbd.c | 2 +- include/block/nbd.h | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/block/nbd.c b/block/nbd.c index 94220f6d14..3641d9244e 100644 --- a/block/nbd.c +++ b/block/nbd.c @@ -477,7 +477,7 @@ static void nbd_refresh_limits(BlockDriverState *bs, Error **errp) uint32_t max = MIN_NON_ZERO(NBD_MAX_BUFFER_SIZE, s->info.max_block); bs->bl.max_pdiscard = max; -bs->bl.max_pwrite_zeroes = max; +bs->bl.max_pwrite_zeroes = NBD_MAX_PWRITE_ZERO_SIZE; bs->bl.max_transfer = max; if (s->info.opt_block && diff --git a/include/block/nbd.h b/include/block/nbd.h index ee74ec391a..e2f18e2332 100644 --- a/include/block/nbd.h +++ b/include/block/nbd.h @@ -182,6 +182,9 @@ enum { /* Maximum size of a single READ/WRITE data buffer */ #define NBD_MAX_BUFFER_SIZE (32 * 1024 * 1024) +/* Maximum size of a single PWRITE_ZERO request 1Gb */ +#define NBD_MAX_PWRITE_ZERO_SIZE (1024 * 1024 * 1024) + /* Maximum size of an export name. The NBD spec requires 256 and * suggests that servers support up to 4096, but we stick to only the * required size so that we can stack-allocate the names, and because -- 2.11.0
[Qemu-devel] [Bug 1484990] Re: fsfreeze-hook script should also ignored dpkg generated files
qemu 2.11 is in proposed ** Changed in: qemu (Ubuntu) Status: New => Fix Committed -- You received this bug notification because you are a member of qemu- devel-ml, which is subscribed to QEMU. https://bugs.launchpad.net/bugs/1484990 Title: fsfreeze-hook script should also ignored dpkg generated files Status in QEMU: New Status in qemu package in Ubuntu: Fix Committed Bug description: Hello, In the fsfreeze-hook script, the following code check if some of the files should be ignored: # Check whether file $1 is a backup or rpm-generated file and should be ignored is_ignored_file() { case "$1" in *~ | *.bak | *.orig | *.rpmnew | *.rpmorig | *.rpmsave | *.sample) return 0 ;; esac return 1 } The functions should probably also skip dpkg generated files. I've found a list of the different extensions in the systemd source tree: https://github.com/systemd/systemd/blob/master/src/basic/util.c#L1871 To manage notifications about this bug go to: https://bugs.launchpad.net/qemu/+bug/1484990/+subscriptions
[Qemu-devel] [Bug 1350435] Re: tcg.c:1693: tcg fatal error
per former comments, in context qemu 2.11 is in proposed ** Changed in: qemu (Ubuntu) Status: Confirmed => Fix Committed -- You received this bug notification because you are a member of qemu- devel-ml, which is subscribed to QEMU. https://bugs.launchpad.net/bugs/1350435 Title: tcg.c:1693: tcg fatal error Status in launchpad-buildd: Won't Fix Status in QEMU: Fix Released Status in qemu package in Ubuntu: Fix Committed Bug description: this started happening after the launchpad buildd trusty deploy https://code.launchpad.net/~costamagnagianfranco/+archive/ubuntu/firefox/+build/6224439 debconf-updatepo qemu: uncaught target signal 11 (Segmentation fault) - core dumped Segmentation fault (core dumped) qemu: uncaught target signal 11 (Segmentation fault) - core dumped Segmentation fault (core dumped) /build/buildd/qemu-2.0.0+dfsg/tcg/tcg.c:1693: tcg fatal error /build/buildd/qemu-2.0.0+dfsg/tcg/tcg.c:1693: tcg fatal error this seems to be the patch needed https://patches.linaro.org/32473/ To manage notifications about this bug go to: https://bugs.launchpad.net/launchpad-buildd/+bug/1350435/+subscriptions
Re: [Qemu-devel] [PATCH 00/54] Patch Round-up for stable 2.11.1, freeze on 2018-02-12
Hi Michael, On 02/06/2018 04:14 PM, Michael Roth wrote: > The release is planned for 2017-02-14: > > https://wiki.qemu.org/Planning/2.11 > > Please respond here or CC qemu-sta...@nongnu.org on any patches you > think should be included in the release. > > > > Alex Bennée (1): > target/sh4: fix TCG leak during gusa sequence There is also e691e0ed135 "target/sh4: add missing tcg_temp_free() in _decode_opc()"
Re: [Qemu-devel] [PATCH v5 12/14] i.MX: Add i.MX7 SOC implementation.
On 7 February 2018 at 04:24, Andrey Smirnov wrote: > The following interfaces are partially or fully emulated: Hi Andrey. I was just going through this series to apply to target-arm.next, and I noticed that fsl-imx7.c is GPL-2-or-later, but fsl-imx7.h is GPL-2-only. Is that intentional? If this is just an accidental error, and you send an email to say you meant 2-or-later, then I can fix this in my target-arm tree by copying the license paragraphs from fsl-imx7.c to fsl-imx7.h. > --- /dev/null > +++ b/hw/arm/fsl-imx7.c > @@ -0,0 +1,580 @@ > +/* > + * Copyright (c) 2018, Impinj, Inc. > + * > + * i.MX7 SoC definitions > + * > + * Author: Andrey Smirnov > + * > + * Based on hw/arm/fsl-imx6.c > + * > + * This program is free software; you can redistribute it and/or modify > + * it under the terms of the GNU General Public License as published by > + * the Free Software Foundation; either version 2 of the License, or > + * (at your option) any later version. > + * > + * This program is distributed in the hope that it will be useful, > + * but WITHOUT ANY WARRANTY; without even the implied warranty of > + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the > + * GNU General Public License for more details. > + */ > + > --- /dev/null > +++ b/include/hw/arm/fsl-imx7.h > @@ -0,0 +1,221 @@ > +/* > + * Copyright (c) 2017, Impinj, Inc. > + * > + * i.MX7 SoC definitions > + * > + * Author: Andrey Smirnov > + * > + * This program is free software; you can redistribute it and/or modify > + * it under the terms of the GNU General Public License as published by > + * the Free Software Foundation; version 2 of the License. > + * > + * This program is distributed in the hope that it will be useful, > + * but WITHOUT ANY WARRANTY; without even the implied warranty of > + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the > + * GNU General Public License for more details. > + */ > + thanks -- PMM
Re: [Qemu-devel] [PATCH 1/1] hw/audio/sb16.c: missing break statement
On 02/08/2018 10:16 AM, Philippe Mathieu-Daudé wrote: > On 02/08/2018 10:01 AM, Peter Maydell wrote: >> On 8 February 2018 at 12:15, Philippe Mathieu-Daudé wrote: >>> Hi Daniel, >>> >>> On 02/08/2018 07:57 AM, Daniel Henrique Barboza wrote: This patch adds a break in the switch() statement of complete(), value 0x42: case 0x42: /* FT2 sets output freq with this, go figure */ qemu_log_mask(LOG_UNIMP, "cmd 0x42 might not do what it think it" " should\n"); break; <--- case 0x41: >>> >>> It seems this is an intentional fallthrough, I understand cmd 0x42 is >>> expected to do the same of 0x41 and _a bit more_ (see commit 85571bc7415). >> >> Yes, I agree; I wrote a bit about this in this thread: >> https://lists.gnu.org/archive/html/qemu-devel/2018-02/msg02081.html > > Oh, very useful link! > >> (though my guess is that actually 0x42 is supposed to do exactly >> what 0x41 does, and that the LOG_UNIMP should maybe just be removed). > > I now understand 0x42 sets the dsp input sampling freq, the model seems > to be designed with output in mind, then added input support (using same > freq as output). Now I see Fabrice comment "FT2 sets output freq with this, go figure" and agree with him. I like to think this is a bug in Fast Tracker 2, so Peter suggestion about using LOG_GUEST_ERROR here might be clever. > > So imho the simpler/safer fix would be: > > case 0x42: > if (dsp_get_hilo(s) != s->freq) { > qemu_log_mask(LOG_UNIMP, > "input sampling freq different than " > "output not implemented"); > } > /* fallthrough */ > case 0x41: > ... > > and the correct fix would be split s->freq in {s->freq_in, s->freq_out} > but nobody ever required this during at least 14 years. >
Re: [Qemu-devel] [PULL 0/4] RDMA patches
Hi Peter, On 08/02/2018 14:59, Peter Maydell wrote: > On 5 February 2018 at 10:26, Marcel Apfelbaum wrote: >> The following changes since commit f24ee107a07f093bd7ed475dd48d7ba57ea3d8fe: >> >> Merge remote-tracking branch >> 'remotes/kraxel/tags/ui-20180202-pull-request' into staging (2018-02-02 >> 18:54:11 +) >> >> are available in the git repository at: >> >> https://github.com/marcel-apf/qemu tags/rdma-pull-request >> >> for you to fetch changes up to f172ba1b02724fb66dabd69cd553cfa625b413e5: >> >> MAINTAINERS: add entry for hw/rdma (2018-02-05 11:53:00 +0200) >> >> >> PVRDMA implementation >> >> >> Marcel Apfelbaum (3): >> mem: add share parameter to memory-backend-ram >> docs: add pvrdma device documentation. >> MAINTAINERS: add entry for hw/rdma >> >> Yuval Shaia (1): >> pvrdma: initial implementation > > Hi. The technical details of this pullreq are all fine (pgp > key, format, etc), and it passes my build tests. But I gave > this pullreq a bit of a closer inspection than I normally > would, since it's your first, and there are a few things I > thought worth bringing up: Thanks for doing it! > > (1) I notice that some of the new files in this pullreq are licensed > as "GPL, version 2", rather than "version 2 or any later version". > Did you really mean that? Per 'LICENSE', we have a strong preference > for 2-or-later for new code. > No real preference, I will modify the license. > (2) Some new files have no copyright or license comment at the > top of them. Can you fix that, please? > Sure. > (3) Some of the new headers use kernel-internals __u32 etc types. > This isn't portable. ('HACKING' has some suggestions for types you > might want instead.) > We do not "use" the __u32 types, we just copied a kernel file for structures used for communication between the guest driver and the QEMU code. We had a look on how it is done and we use the model that adds macros __u32 -> uint32_t, so the "__types" do not really create such problems. > (4) One of your patches doesn't have any reviewed-by tags. > We don't always manage to review everything, but it is > nicer if we can get review, especially for patches from > new submaintainers. > The patch did receive several questions/comments and all of them were addressed, but indeed no RB tag was given. Since the patch was in the mailing list for over a month and *was* reviewed, I thought is enough. I will ping Eduardo, he had the latest comments for it. > (5) This is an absolutely enormous diffstat for a single commit: > 26 files changed, 5149 insertions(+), 4 deletions(-) > On the github where the project was developed we have thousands of commits, so it can't be used. It was reviewed closely by one reviewer and got a lot of comments from others. That being said, we will try to split it in a few patches and send a new version. Thanks for the comments, Marcel > thanks > -- PMM >
Re: [Qemu-devel] [RFC PATCH] vfio/pci: Add ioeventfd support
Hi Alex, On 07/02/18 17:57, Alex Williamson wrote: > On Wed, 7 Feb 2018 16:46:19 +0100 > Auger Eric wrote: > >> Hi Alex, >> >> On 07/02/18 01:08, Alex Williamson wrote: >>> The ioeventfd here is actually irqfd handling of an ioeventfd such as >>> supported in KVM. A user is able to pre-program a device write to >>> occur when the eventfd triggers. This is yet another instance of >>> eventfd-irqfd triggering between KVM and vfio. The impetus for this >>> is high frequency writes to pages which are virtualized in QEMU. >>> Enabling this near-direct write path for selected registers within >>> the virtualized page can improve performance and reduce overhead. >>> Specifically this is initially targeted at NVIDIA graphics cards where >>> the driver issues a write to an MMIO register within a virtualized >>> region in order to allow the MSI interrupt to re-trigger. >>> >>> Signed-off-by: Alex Williamson >> >> fyi it does not apply anymore on master (conflict in >> include/uapi/linux/vfio.h on GFX stuff) > > Sorry, I should have noted that this was against v4.15, I didn't want > the churn of the merge window since I was benchmarking against this. > Will update for non-RFC. > > ... >>> +long vfio_pci_ioeventfd(struct vfio_pci_device *vdev, loff_t offset, >>> + uint64_t data, int count, int fd) >>> +{ >>> + struct pci_dev *pdev = vdev->pdev; >>> + loff_t pos = offset & VFIO_PCI_OFFSET_MASK; >>> + int ret, bar = VFIO_PCI_OFFSET_TO_INDEX(offset); >>> + struct vfio_pci_ioeventfd *ioeventfd; >>> + int (*handler)(void *, void *); >>> + unsigned long val; >>> + >>> + /* Only support ioeventfds into BARs */ >>> + if (bar > VFIO_PCI_BAR5_REGION_INDEX) >>> + return -EINVAL; >>> + >>> + if (pos + count > pci_resource_len(pdev, bar)) >>> + return -EINVAL; >>> + >>> + /* Disallow ioeventfds working around MSI-X table writes */ >>> + if (bar == vdev->msix_bar && >>> + !(pos + count <= vdev->msix_offset || >>> + pos >= vdev->msix_offset + vdev->msix_size)) >>> + return -EINVAL; >>> + >>> + switch (count) { >>> + case 1: >>> + handler = &vfio_pci_ioeventfd_handler8; >>> + val = data; >>> + break; >>> + case 2: >>> + handler = &vfio_pci_ioeventfd_handler16; >>> + val = le16_to_cpu(data); >>> + break; >>> + case 4: >>> + handler = &vfio_pci_ioeventfd_handler32; >>> + val = le32_to_cpu(data); >>> + break; >>> +#ifdef iowrite64 >>> + case 8: >>> + handler = &vfio_pci_ioeventfd_handler64; >>> + val = le64_to_cpu(data); >>> + break; >>> +#endif >>> + default: >>> + return -EINVAL; >>> + } >>> + >>> + ret = vfio_pci_setup_barmap(vdev, bar); >>> + if (ret) >>> + return ret; >>> + >>> + mutex_lock(&vdev->ioeventfds_lock); >>> + >>> + list_for_each_entry(ioeventfd, &vdev->ioeventfds_list, next) { >>> + if (ioeventfd->pos == pos && ioeventfd->bar == bar && >>> + ioeventfd->data == data && ioeventfd->count == count) { >>> + if (fd == -1) { >>> + vfio_virqfd_disable(&ioeventfd->virqfd); >>> + list_del(&ioeventfd->next); >>> + kfree(ioeventfd); >>> + ret = 0; >>> + } else >>> + ret = -EEXIST; >>> + >>> + goto out_unlock; >>> + } >>> + } >>> + >>> + if (fd < 0) { >>> + ret = -ENODEV; >>> + goto out_unlock; >>> + } >>> + >>> + ioeventfd = kzalloc(sizeof(*ioeventfd), GFP_KERNEL); >>> + if (!ioeventfd) { >>> + ret = -ENOMEM; >>> + goto out_unlock; >>> + } >>> + >>> + ioeventfd->pos = pos; >>> + ioeventfd->bar = bar; >>> + ioeventfd->data = data; >>> + ioeventfd->count = count; >>> + >>> + ret = vfio_virqfd_enable(vdev->barmap[ioeventfd->bar] + ioeventfd->pos, >>> >> nit: bar and pos could be used directly > > Indeed, probably leftover from development. Fixed and re-wrapped the > following lines. > >>> +handler, NULL, (void *)val, >>> +&ioeventfd->virqfd, fd); >>> + if (ret) { >>> + kfree(ioeventfd); >>> + goto out_unlock; >>> + } >>> + >>> + list_add(&ioeventfd->next, &vdev->ioeventfds_list); >>> + >>> +out_unlock: >>> + mutex_unlock(&vdev->ioeventfds_lock); >>> + >>> + return ret; >>> +} >>> diff --git a/include/uapi/linux/vfio.h b/include/uapi/linux/vfio.h >>> index e3301dbd27d4..07966a5f0832 100644 >>> --- a/include/uapi/linux/vfio.h >>> +++ b/include/uapi/linux/vfio.h >>> @@ -503,6 +503,30 @@ struct vfio_pci_hot_reset { >>> >>> #define VFIO_DEVICE_PCI_HOT_RESET _IO(VFIO_TYPE, VFIO_BASE + 13) >>> >>> +/** >>> + * VFIO_DEVICE_IOEVENTFD - _IOW(VFIO_TYPE, VFIO_BASE + 14, >>> + * struct vfio_devic
Re: [Qemu-devel] [PATCH v5 00/14] Initial i.MX7 support
On 7 February 2018 at 04:24, Andrey Smirnov wrote: > Hi everyone, > > This v5 of the patch series containing the work that I've done in > order to enable support for i.MX7 emulation in QEMU. Thanks; I'm applying this to target-arm.next. There are a few minor tweaks I'm going to make in the process, but I think that's better than making you do yet another respin. Those changes are: * dropped stray blank-line-at-end-of-file from a few patches * fixed a couple of over-80-columnns lines * added a ESDHC_UNDOCUMENTED_REG27 define as suggested by Philippe (I didn't reorder the switches to put 'default' last though, as that didn't seem necessary to me) If you get back to me today about the GPL-2-vs-2-or-later question for patch 13 I'll make that change too. Otherwise I'll drop 13 and 14 for the moment. thanks -- PMM
[Qemu-devel] [Bug 1738767] Re: Cannot build QEMU on RHEL6 because of MAP_HUGETLB
This was fixed by the distro updating their glibc-headers pakcage: * Tue Jul 23 2013 Alexandre Oliva - 2.12-1.119 - Add MAP_HUGETLB and MAP_STACK support (#916986). - Update translation for stale file handle error (#970776). The build works in the current centos6 docker image and has been confirmed to build on later RHEL6 (RHEL6.7). -- You received this bug notification because you are a member of qemu- devel-ml, which is subscribed to QEMU. https://bugs.launchpad.net/bugs/1738767 Title: Cannot build QEMU on RHEL6 because of MAP_HUGETLB Status in QEMU: Won't Fix Bug description: Hello, I've just downloaded qemu-2.11.0 sources and I wanted to build QEMU on RHEL6 x86_64, for various targets, amonst which arm-linux-user. The build fails because /usr/include/bits/mman.h does not define MAP_HUGETLB. I think it is needed since commit 541e16904. I'm not sure if RHEL6 is still supported by QEMU? If so, can you fix this problem? Thanks To manage notifications about this bug go to: https://bugs.launchpad.net/qemu/+bug/1738767/+subscriptions
[Qemu-devel] [Bug 1738767] Re: Cannot build QEMU on RHEL6 because of MAP_HUGETLB
I think we can close this bug: the build fails on RHEL6.4, but succeeded on RHEL6.7. Probably related to: https://access.redhat.com/solutions/320613 -- You received this bug notification because you are a member of qemu- devel-ml, which is subscribed to QEMU. https://bugs.launchpad.net/bugs/1738767 Title: Cannot build QEMU on RHEL6 because of MAP_HUGETLB Status in QEMU: Won't Fix Bug description: Hello, I've just downloaded qemu-2.11.0 sources and I wanted to build QEMU on RHEL6 x86_64, for various targets, amonst which arm-linux-user. The build fails because /usr/include/bits/mman.h does not define MAP_HUGETLB. I think it is needed since commit 541e16904. I'm not sure if RHEL6 is still supported by QEMU? If so, can you fix this problem? Thanks To manage notifications about this bug go to: https://bugs.launchpad.net/qemu/+bug/1738767/+subscriptions
Re: [Qemu-devel] [PATCH 1/1] hw/audio/sb16.c: missing break statement
On 8 February 2018 at 13:34, Philippe Mathieu-Daudé wrote: > Now I see Fabrice comment "FT2 sets output freq with this, go figure" > and agree with him. > > I like to think this is a bug in Fast Tracker 2, so Peter suggestion > about using LOG_GUEST_ERROR here might be clever. > >> >> So imho the simpler/safer fix would be: >> >> case 0x42: >> if (dsp_get_hilo(s) != s->freq) { >> qemu_log_mask(LOG_UNIMP, >> "input sampling freq different than " >> "output not implemented"); >> } >> /* fallthrough */ >> case 0x41: >> ... Wouldn't this falsely report a warning for guest code that really is trying to set the input sampling frequency and doesn't care about output? >> and the correct fix would be split s->freq in {s->freq_in, s->freq_out} ...but that would differ from the hardware implementation, which (apparently) uses a single frequency for both. thanks -- PMM
Re: [Qemu-devel] [patch] linux-user/syscall.c: Fix missing break for host_to_target_cmsg
On 07-Feb-2018, at 7:27 PM, Laurent Vivier wrote: Le 07/02/2018 à 10:49, no-re...@patchew.org a écrit : Hi, This series failed build test on s390x host. Please find the details below. ... CC aarch64_be-linux-user/linux-user/syscall.o In file included from /var/tmp/patchew-tester-tmp-ewjgn083/src/linux-user/qemu.h:16:0, from /var/tmp/patchew-tester-tmp-ewjgn083/src/linux-user/syscall.c:118: /var/tmp/patchew-tester-tmp-ewjgn083/src/linux-user/syscall.c: In function ‘do_sendrecvmsg_locked’: /var/tmp/patchew-tester-tmp-ewjgn083/src/linux-user/syscall_defs.h:3 08:61: error: ‘tgt_len’ may be used uninitialized in this function [-Werror=maybe-uninitialized] #define TARGET_CMSG_LEN(len) (sizeof(struct target_cmsghdr) + (len)) ^ /var/tmp/patchew-tester-tmp-ewjgn083/src/linux-user/syscall.c:1797:1 3: note: ‘tgt_len’ was declared here int tgt_len, tgt_space; ^~~ it seems gcc disagrees with Coverity... I think this should fixed like: diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 74378947f0..d7fbe334eb 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -1824,8 +1824,10 @@ static inline abi_long host_to_target_cmsg(struct target_msghdr *target_msgh, tgt_len = sizeof(struct target_timeval); break; default: +tgt_len = len; In my view this will result in assigning a wrong value to ‘tgt_len’ at this ‘switch-case’ condition. Instead looking at the option of initializing ‘tgt_len' to ‘0’. @@ -1789,7 +1789,7 @@ void *target_data = TARGET_CMSG_DATA(target_cmsg); int len = cmsg->cmsg_len - sizeof(struct cmsghdr); -int tgt_len, tgt_space; +int tgt_len = 0, tgt_space; /* We never copy a half-header but may copy half-data; * this is Linux's behaviour in put_cmsg(). Note that @@ -1821,6 +1821,7 @@ default: break; } +break; default: tgt_len = len; break; break; } +break; default: tgt_len = len; break; Peter? Thanks, Laurent
[Qemu-devel] [Bug 1738767] Re: Cannot build QEMU on RHEL6 because of MAP_HUGETLB
OK, since we work on more recent RHEL6 and the submitter is happy with that, let's close this bug as WONTFIX. ** Changed in: qemu Status: New => Won't Fix -- You received this bug notification because you are a member of qemu- devel-ml, which is subscribed to QEMU. https://bugs.launchpad.net/bugs/1738767 Title: Cannot build QEMU on RHEL6 because of MAP_HUGETLB Status in QEMU: Won't Fix Bug description: Hello, I've just downloaded qemu-2.11.0 sources and I wanted to build QEMU on RHEL6 x86_64, for various targets, amonst which arm-linux-user. The build fails because /usr/include/bits/mman.h does not define MAP_HUGETLB. I think it is needed since commit 541e16904. I'm not sure if RHEL6 is still supported by QEMU? If so, can you fix this problem? Thanks To manage notifications about this bug go to: https://bugs.launchpad.net/qemu/+bug/1738767/+subscriptions
Re: [Qemu-devel] [PATCH 1/2] qmp: add query-cpus-fast
On Thu, 8 Feb 2018 08:41:31 +0100 Viktor Mihajlovski wrote: > On 07.02.2018 18:50, Luiz Capitulino wrote: > > The query-cpus command has an extremely serious side effect: > > it always interrupt all running vCPUs so that they can run > > ioctl calls. This can cause a huge performance degradation for > > some workloads. And most of the information retrieved by the > > ioctl calls are not even used by query-cpus. > > > > This commit introduces a replacement for query-cpus called > > query-cpus-fast, which has the following features: > > > > o Never interrupt vCPUs threads. query-cpus-fast only returns > >vCPU information maintained by QEMU itself, which should be > >sufficient for most management software needs > > > > o Make "halted" field optional: we only return it if the > >halted state is maintained by QEMU. But this also gives > >the option of dropping the field in the future (see below) > > > > o Drop irrelevant fields such as "current", "pc" and "arch" > I disagree that arch is irrelevant and would strongly suggest to keep > arch and arch-specific fields. At least in the case of s390 there's a > cpu_state field that can be obtained cheaply. The arch name can be queried with query-target. The only other arch field I'm dropping is pc, which should be considered debug only if anything. Also, if this need to query CPU registers increase, then we probably should port 'info registers' to QMP. Otherwise, we'll eventually run into the performance problem once again. > [...] > > diff --git a/cpus.c b/cpus.c > > index 2cb0af9b22..3b68a8146c 100644 > > --- a/cpus.c > > +++ b/cpus.c > > @@ -2083,6 +2083,50 @@ CpuInfoList *qmp_query_cpus(Error **errp) > > return head; > > } > > > > +/* > > + * fast means: we NEVER interrupt vCPU threads to retrieve > > + * information from KVM. > > + */ > > +CpuInfo2List *qmp_query_cpus_fast(Error **errp) > > +{ > > +MachineState *ms = MACHINE(qdev_get_machine()); > > +MachineClass *mc = MACHINE_GET_CLASS(ms); > > +CpuInfo2List *head = NULL, *cur_item = NULL; > > +CPUState *cpu; > > + > > +CPU_FOREACH(cpu) { > > +CpuInfo2List *info = g_malloc0(sizeof(*info)); > > +info->value = g_malloc0(sizeof(*info->value)); > > + > > +info->value->cpu_index = cpu->cpu_index; > > +info->value->qom_path = object_get_canonical_path(OBJECT(cpu)); > > +info->value->thread_id = cpu->thread_id; > > + > > +info->value->has_props = !!mc->cpu_index_to_instance_props; > > +if (info->value->has_props) { > > +CpuInstanceProperties *props; > > +props = g_malloc0(sizeof(*props)); > > +*props = mc->cpu_index_to_instance_props(ms, cpu->cpu_index); > > +info->value->props = props; > > +} > > + > > +/* if in kernel irqchip is used, we don't have 'halted' */ > > +info->value->has_halted = !kvm_irqchip_in_kernel(); > This is definitely not true for s390. Externally observable CPU state > changes are handled by QEMU there. We may still drop halted if we add a > more appropriate arch-specific field. > > +if (info->value->has_halted) { > > +info->value->halted = cpu->halted; > > +} > [...] >
[Qemu-devel] [PATCH] block: unify blocksize types
BlockSizes structure used in block size probing has uint32_t types for logical and physical sizes. These fields are wrongfully assigned to uint16_t in BlockConf, which results, among other errors, in assigning 0 instead of 65536 (which will be the case in at least future LizardFS block device driver among other things). This commit makes BlockConf's physical_block_size and logical_block_size fields uint32_t to avoid inconsistencies. Signed-off-by: Piotr Sarna --- include/hw/block/block.h | 4 ++-- include/hw/qdev-properties.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/include/hw/block/block.h b/include/hw/block/block.h index 64b9298..c9e6e27 100644 --- a/include/hw/block/block.h +++ b/include/hw/block/block.h @@ -17,8 +17,8 @@ typedef struct BlockConf { BlockBackend *blk; -uint16_t physical_block_size; -uint16_t logical_block_size; +uint32_t physical_block_size; +uint32_t logical_block_size; uint16_t min_io_size; uint32_t opt_io_size; int32_t bootindex; diff --git a/include/hw/qdev-properties.h b/include/hw/qdev-properties.h index 1d61a35..c68d7bf 100644 --- a/include/hw/qdev-properties.h +++ b/include/hw/qdev-properties.h @@ -210,7 +210,7 @@ extern const PropertyInfo qdev_prop_off_auto_pcibar; #define DEFINE_PROP_BIOS_CHS_TRANS(_n, _s, _f, _d) \ DEFINE_PROP_SIGNED(_n, _s, _f, _d, qdev_prop_bios_chs_trans, int) #define DEFINE_PROP_BLOCKSIZE(_n, _s, _f) \ -DEFINE_PROP_UNSIGNED(_n, _s, _f, 0, qdev_prop_blocksize, uint16_t) +DEFINE_PROP_UNSIGNED(_n, _s, _f, 0, qdev_prop_blocksize, uint32_t) #define DEFINE_PROP_PCI_HOST_DEVADDR(_n, _s, _f) \ DEFINE_PROP(_n, _s, _f, qdev_prop_pci_host_devaddr, PCIHostDeviceAddress) #define DEFINE_PROP_MEMORY_REGION(_n, _s, _f) \ -- 2.7.4
Re: [Qemu-devel] [PULL 0/4] RDMA patches
On Thu, Feb 08, 2018 at 12:59:02PM +, Peter Maydell wrote: > On 5 February 2018 at 10:26, Marcel Apfelbaum wrote: > > The following changes since commit f24ee107a07f093bd7ed475dd48d7ba57ea3d8fe: > > > > Merge remote-tracking branch > > 'remotes/kraxel/tags/ui-20180202-pull-request' into staging (2018-02-02 > > 18:54:11 +) > > > > are available in the git repository at: > > > > https://github.com/marcel-apf/qemu tags/rdma-pull-request > > > > for you to fetch changes up to f172ba1b02724fb66dabd69cd553cfa625b413e5: > > > > MAINTAINERS: add entry for hw/rdma (2018-02-05 11:53:00 +0200) > > > > > > PVRDMA implementation > > > > > > Marcel Apfelbaum (3): > > mem: add share parameter to memory-backend-ram > > docs: add pvrdma device documentation. > > MAINTAINERS: add entry for hw/rdma > > > > Yuval Shaia (1): > > pvrdma: initial implementation > > Hi. The technical details of this pullreq are all fine (pgp > key, format, etc), and it passes my build tests. But I gave > this pullreq a bit of a closer inspection than I normally > would, since it's your first, and there are a few things I > thought worth bringing up: > > (1) I notice that some of the new files in this pullreq are licensed > as "GPL, version 2", rather than "version 2 or any later version". > Did you really mean that? Per 'LICENSE', we have a strong preference > for 2-or-later for new code. > > (2) Some new files have no copyright or license comment at the > top of them. Can you fix that, please? > > (3) Some of the new headers use kernel-internals __u32 etc types. > This isn't portable. ('HACKING' has some suggestions for types you > might want instead.) > > (4) One of your patches doesn't have any reviewed-by tags. > We don't always manage to review everything, but it is > nicer if we can get review, especially for patches from > new submaintainers. > > (5) This is an absolutely enormous diffstat for a single commit: > 26 files changed, 5149 insertions(+), 4 deletions(-) > > thanks > -- PMM And one of the reasons is that it pulls in some unneeded stuff. E.g. vmw_pvrdma-abi.h should be pulled into standard-headers from Linux, rather than copy-pasted. -- MST
Re: [Qemu-devel] [PATCH 2/2] qmp: document query-cpus performance issue
On Thu, 8 Feb 2018 09:29:28 + Daniel P. Berrangé wrote: > On Wed, Feb 07, 2018 at 12:50:14PM -0500, Luiz Capitulino wrote: > > Signed-off-by: Luiz Capitulino > > --- > > qapi-schema.json | 4 > > 1 file changed, 4 insertions(+) > > > > diff --git a/qapi-schema.json b/qapi-schema.json > > index 82d6f12b53..0665a14dba 100644 > > --- a/qapi-schema.json > > +++ b/qapi-schema.json > > @@ -526,6 +526,10 @@ > > # > > # Returns a list of information about each virtual CPU. > > # > > +# WARNING: This command incurs a performance penalty for latency > > +# sensitive workloads and hence it's not recommended to > > +# to be used in production. Use query-cpus-fast instead > > I suggest being more explicit about exactly what the problem is, so people > understand implications if they choose to still use it. ie I'll add your text. > > This command causes vCPU threads to exit to userspace, which causes > an small interruption guest CPU execution. This will have a negative > impact on realtime guests and other latency sensitive guest workloads. > It is recommended to use query-cpus-fast instead of this command to > avoid the vCPU interruption. > > Regards, > Daniel
Re: [Qemu-devel] [PULL 0/4] RDMA patches
On 8 February 2018 at 13:38, Marcel Apfelbaum wrote: > Hi Peter, > > On 08/02/2018 14:59, Peter Maydell wrote: >> (3) Some of the new headers use kernel-internals __u32 etc types. >> This isn't portable. ('HACKING' has some suggestions for types you >> might want instead.) >> > > We do not "use" the __u32 types, we just copied a kernel file > for structures used for communication between the guest driver > and the QEMU code. We had a look on how it is done and > we use the model that adds macros __u32 -> uint32_t, > so the "__types" do not really create such problems. If we're using kernel header files, I would recommend using the scripts/update-headers machinery for this, the way we do for other kernel headers. Among other things, the cp_portable function in that script will fix up the type names for you. thanks -- PMM