Re: [Qemu-devel] [PULL] VirtFS update
Adding the correct email address for Anthony. -aneesh Aneesh Kumar K.V aneesh.ku...@linux.vnet.ibm.com writes: Hi Anthony, Please pull the below update for VirtFS The following changes since commit 2f61120c10da9128357510debc8e66880cd2bfdc: Merge remote-tracking branch 'qmp-unstable/queue/qmp' into staging (2014-02-01 23:32:31 +) are available in the git repository at: https://github.com/kvaneesh/qemu.git for-upstream for you to fetch changes up to f8b7ee38b3ed4ec2da5cc0529cf0cf82c8589805: hw/9pfs: fix P9_STATS_GEN handling (2014-02-02 22:09:16 +0530) Kirill A. Shutemov (4): hw/9pfs: fix error handing in local_ioc_getversion() hw/9pfs: handle undefined FS_IOC_GETVERSION case in handle_ioc_getversion() hw/9pfs: make get_st_gen() return ENOTTY error on special files hw/9pfs: fix P9_STATS_GEN handling hw/9pfs/cofile.c | 4 hw/9pfs/virtio-9p-handle.c | 8 +++- hw/9pfs/virtio-9p-local.c | 10 ++ hw/9pfs/virtio-9p-proxy.c | 3 ++- hw/9pfs/virtio-9p.c| 12 ++-- 5 files changed, 25 insertions(+), 12 deletions(-) -aneesh
[Qemu-devel] [PATCH] Revert nand: Don't inherit from Sysbus
This reverts commit 7426aa72c36c908a7d0eae3e38568bb0a70de479. The commit goes into a sensible direction, but it violates qdev design assumptions. Symptom: info qtree crashes for all boards including the device (akita, borzoi, spitz, terrier, tosa, axis-dev88). Peter Crosthwaite is working on a fix, but it's not trivial. Revert the flawed patch for now. Signed-off-by: Markus Armbruster arm...@redhat.com Acked-by: Peter Crosthwaite peter.crosthwa...@xilinx.com --- hw/block/nand.c | 7 +++ 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/hw/block/nand.c b/hw/block/nand.c index a871ce0..a0232d1 100644 --- a/hw/block/nand.c +++ b/hw/block/nand.c @@ -21,7 +21,7 @@ # include hw/hw.h # include hw/block/flash.h # include sysemu/blockdev.h -#include hw/qdev.h +# include hw/sysbus.h #include qemu/error-report.h # define NAND_CMD_READ00x00 @@ -54,8 +54,7 @@ typedef struct NANDFlashState NANDFlashState; struct NANDFlashState { -DeviceState parent_obj; - +SysBusDevice busdev; uint8_t manf_id, chip_id; uint8_t buswidth; /* in BYTES */ int size, pages; @@ -441,7 +440,7 @@ static void nand_class_init(ObjectClass *klass, void *data) static const TypeInfo nand_info = { .name = TYPE_NAND, -.parent= TYPE_DEVICE, +.parent= TYPE_SYS_BUS_DEVICE, .instance_size = sizeof(NANDFlashState), .class_init= nand_class_init, }; -- 1.8.1.4
Re: [Qemu-devel] [PATCH v2] qdev: Keep global allocation counter per bus
Peter Crosthwaite peter.crosthwa...@xilinx.com writes: On Tue, Feb 4, 2014 at 7:28 PM, Markus Armbruster arm...@redhat.com wrote: Markus Armbruster arm...@redhat.com writes: Peter Crosthwaite peter.crosthwa...@xilinx.com writes: On Wed, Jan 8, 2014 at 11:47 PM, Paolo Bonzini pbonz...@redhat.com wrote: Il 08/01/2014 14:40, Andreas Färber ha scritto: Either you fix info qtree to cope with your change to the device graph, or the change needs to be reverted until somebody fixes it or it goes away. Sharing a backtrace would be a start, rather than just throwing around the word crash to justify reverting patches. :) I mentioned the root cause in the previous message: a Device cannot be added to main_system_bus, but that's what the patch does. The fix isn't trivial, because most of the affected board are not even qdevified. So I made progress here with the needed QOMification. Finally I have a sane info qtree WRT NAND: $ arm-softmmu/qemu-system-arm -M spitz -nographic -S (qemu) info qtree bus: main-system-bus type System ... dev: sl-nand, id manf_id = 236 chip_id = 115 irq 0 mmio 0c00/0040 bus: nand type nand-bus dev: nand, id manufacturer_id = 236 chip_id = 115 drive = null With just the proposed revert info qtree does work again, but is bogus: (qemu) info qtree bus: main-system-bus type System ... dev: nand, id manufacturer_id = 236 chip_id = 115 drive = null irq 0 dev: sl-nand, id manf_id = 236 chip_id = 115 irq 0 mmio 0c00/0040 Progress! Patches sometime next week hopefully. I think we can wait that long :) I just ran into the info qtree crash again, and I can't find your fix right now. Got a pointer for me? Hi Markus, That series got very big on me with complications. I think near term we just proceed with the revert. Sorry for the delay. For a straight revert of my patch nand s/SYSBUS/DEVICE patch: Acked-by: Peter Crosthwaite peter.crosthwa...@xilinx.com Done. Thanks!
Re: [Qemu-devel] [PATCH] trace backend: introduce multi tracing backend
(2014/02/04 18:02), Stefan Hajnoczi wrote: On Tue, Feb 04, 2014 at 02:26:13PM +0900, Kazuya Saito wrote: (2014/01/31 19:37), Stefan Hajnoczi wrote: On Tue, Jan 28, 2014 at 01:35:20PM +0900, Kazuya Saito wrote: def h(events): +pass I thought all code generation now happens in backends.common.h(), so this function will not be called anymore? It is called in tracetool.backend.compatible(). So, it is required when selecting only dtrace backend. The same is true for c() defined in this file. It is also required for the same reason as dtrace.h(). tracetool.backend.compatible() is testing for the existence of a function that is not used anywhere else. Backend code doesn't make it obvious why this is necessary. We should either make compatible() work (e.g. by testing body_format and ensuring all formats use the body_ function prefix) or with something explicit like a backend.supported_formats = ['c', 'h'] list. I think that checking bakcend.supported_formats is better. I'll change compatible() like that. +util-obj-$(CONFIG_TRACE_FTRACE) += multi.o ftrace.o How about adding multi.o to util-obj-y just like control.o below? All these object files are added to libqemuutil.a. The linker will only pull in object files that are needed (based on symbol dependencies) so there is no harm in uncoditionally building multi.o. If adding multi.o to util-obj-y, compile error occurs when selecting only dtrace backend. This is because the function trace_print_events(), trace_event_set_state_dynamic_backend() and trace_backend_init() are declared doubly in multi.o and default.o. So, I'm going to leave it. Do you have any suggestions? I guess it should be: ifeq ($(CONFIG_TRACE_DEFAULT),y) util-obj-y += default.o else util-obj-y += multi.o endif Thank you. I'll fix it as above. Thanks, Kazuya Saito
Re: [Qemu-devel] [PATCH] Revert nand: Don't inherit from Sysbus
Am 05.02.2014 09:39, schrieb Markus Armbruster: This reverts commit 7426aa72c36c908a7d0eae3e38568bb0a70de479. The commit goes into a sensible direction, but it violates qdev design assumptions. Symptom: info qtree crashes for all boards including the device (akita, borzoi, spitz, terrier, tosa, axis-dev88). Peter Crosthwaite is working on a fix, but it's not trivial. Revert the flawed patch for now. Signed-off-by: Markus Armbruster arm...@redhat.com Acked-by: Peter Crosthwaite peter.crosthwa...@xilinx.com --- hw/block/nand.c | 7 +++ 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/hw/block/nand.c b/hw/block/nand.c index a871ce0..a0232d1 100644 --- a/hw/block/nand.c +++ b/hw/block/nand.c @@ -21,7 +21,7 @@ # include hw/hw.h # include hw/block/flash.h # include sysemu/blockdev.h -#include hw/qdev.h +# include hw/sysbus.h #include qemu/error-report.h # define NAND_CMD_READ0 0x00 @@ -54,8 +54,7 @@ typedef struct NANDFlashState NANDFlashState; struct NANDFlashState { -DeviceState parent_obj; - +SysBusDevice busdev; Negative on calling it busdev again, that surely has nothing to do with a crash since it's not being used anywhere in this patch. I still have not seen a single backtrace of what is going wrong, only Paolo saying something about adding to main_system_bus in the patch. Clearly that is not in this patch! Where is that happening and why is that so complicated for Peter C. to fix? Andreas uint8_t manf_id, chip_id; uint8_t buswidth; /* in BYTES */ int size, pages; @@ -441,7 +440,7 @@ static void nand_class_init(ObjectClass *klass, void *data) static const TypeInfo nand_info = { .name = TYPE_NAND, -.parent= TYPE_DEVICE, +.parent= TYPE_SYS_BUS_DEVICE, .instance_size = sizeof(NANDFlashState), .class_init= nand_class_init, }; -- SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
Re: [Qemu-devel] [PATCH] sparc/leon3: Initialize stack pointer
On 02/03/2014 10:18 AM, Sebastian Huber wrote: A lot of real world LEON3 systems are shipped with the GRMON boot loader. This boot loader initializes the stack pointer with the end of RAM address. The application can use this to detect the RAM size of a particular board variant. Looks good, thank you Sebastian. Reviewed-by: Fabien Chouteau chout...@adacore.com Signed-off-by: Sebastian Huber sebastian.hu...@embedded-brains.de --- hw/sparc/leon3.c |3 +++ 1 files changed, 3 insertions(+), 0 deletions(-) diff --git a/hw/sparc/leon3.c b/hw/sparc/leon3.c index c583c3d..c16e9e4 100644 --- a/hw/sparc/leon3.c +++ b/hw/sparc/leon3.c @@ -45,6 +45,7 @@ typedef struct ResetData { SPARCCPU *cpu; uint32_t entry;/* save kernel entry in case of reset */ +target_ulong sp;/* initial stack pointer */ } ResetData; static void main_cpu_reset(void *opaque) @@ -58,6 +59,7 @@ static void main_cpu_reset(void *opaque) cpu-halted = 0; env-pc = s-entry; env-npc= s-entry + 4; +env-regbase[6] = s-sp; } void leon3_irq_ack(void *irq_manager, int intno) @@ -133,6 +135,7 @@ static void leon3_generic_hw_init(QEMUMachineInitArgs *args) /* Reset data */ reset_info= g_malloc0(sizeof(ResetData)); reset_info-cpu = cpu; +reset_info-sp= 0x4000 + ram_size; qemu_register_reset(main_cpu_reset, reset_info); /* Allocate IRQ manager */
Re: [Qemu-devel] migration: broken ram_save_pending
* Paolo Bonzini (pbonz...@redhat.com) wrote: Il 04/02/2014 23:17, Alexey Kardashevskiy ha scritto: Well, it will fix it in my particular case but in a long run this does not feel like a fix - there should be a way for migration_thread() to know that ram_save_iterate() sent all dirty pages it had to send, no? No, because new pages might be dirtied while ram_save_iterate() was running. I do not get it, sorry. In my example the ram_save_iterate() sends everything in one go but its caller thinks that it did not and tries again. It's not that the caller thinks that it did not. The caller knows what happens, because migration_bitmap_find_and_reset_dirty updates the migration_dirty_pages count that ram_save_pending uses. So migration_dirty_pages should be 0 when ram_save_pending is entered. However, something gets dirty in between so remaining_size is again 393216 when ram_save_pending returns, after the migration_bitmap_sync call. Because of this the migration thread thinks that ram_save_iterate() _will_ not send everything in one go. At least, this is how I read the code. Perhaps I'm wrong. ;) My reading was a bit different. I think the case Alexey is hitting is: 1 A few dirtied pages 2 but because of the hpratio most of the data is actually zero - indeed most of the target-page sized chunks are zero 3 Thus the data compresses very heavily 4 When the bandwidth/delay calculation happens it's spent a reasonable amount of time transferring a reasonable amount of pages but not actually many bytes on the wire, so the estimate of the available bandwidth available is lower than reality. 5 The max-downtime calculation is a comparison of pending-dirty uncompressed bytes with compressed bandwidth (5) is bound to fail if the compression ratio is particularly high, which because of the hpratio it is if we're just dirtying one word in an entire host page. What I'm not too sure of is you'd think if only a few pages were dirtied that the loop would happen quite quickly and thus the delay would also be small, and so bytes-on-wire would be divided by a small value and thus not be too bad. Dave -- Dr. David Alan Gilbert / dgilb...@redhat.com / Manchester, UK
Re: [Qemu-devel] slirp smb with modern win guests when samba is also running on host
Ping? It's been more than 2 months already... Thanks, /mjt 28.11.2013 23:32, Michael Tokarev wrote: After numerous reports that -smb (or -netdev user,smb=foo) not working with modern windows (win7 and vista are reported as non-working), I started digging myself. And found that indeed it doesn't work, and why. The thing is that modern win tries to connect to port 445 (microsoft-ds) first, and if that fails, it falls back to old port 139 (netbios-ssn). slirp code in qemu only redirects port 139, it does not touch port 445. So the prob is that if samba is also running on the host, guest will try to communicate using port 445, and that will succed, but ofcourse guest will not talk with our samba but with samba running on the host. If samba is not running on the host, guest will fall back to port 139, and will reach the redirecting rule and qemu will spawn smbd correctly. The solution is to redirect both ports (139 and 445), and the fix is a one-liner, adding second call to slirp_add_exec() at the end of net/slirp.c:slirp_smb() function (provided below). But it looks like that is not a proper fix really, since in theory we should redirect both ports to the SAME, single samba instance, but I'm not sure this is possible with slirp. Well, even if two smbd processes will be run on the same config dir, it should not be a problem. The one-liner (not exactly 1 since it touches previous line too) is like this: Signed-off-By: Michael Tokarev m...@tls.msk.ru diff --git a/net/slirp.c b/net/slirp.c index 124e953..a22e976 100644 --- a/net/slirp.c +++ b/net/slirp.c @@ -549,7 +549,8 @@ static int slirp_smb(SlirpState* s, const char *exported_dir snprintf(smb_cmdline, sizeof(smb_cmdline), %s -s %s, CONFIG_SMBD_COMMAND, smb_conf); -if (slirp_add_exec(s-slirp, 0, smb_cmdline, vserver_addr, 139) 0) { +if (slirp_add_exec(s-slirp, 0, smb_cmdline, vserver_addr, 139) 0 || +slirp_add_exec(s-slirp, 0, smb_cmdline, vserver_addr, 445) 0) { slirp_smb_cleanup(s); error_report(conflicting/invalid smbserver address); return -1;
Re: [Qemu-devel] [PATCH] SPARC: Add and use CPU_FEATURE_CASA
On 11/26/2013 03:04 PM, Sebastian Huber wrote: The LEON3 processor has support for the CASA instruction which is normally only available for SPARC V9 processors. Binutils 2.24 and GCC 4.9 will support this instruction for LEON3. GCC uses it to generate C11 atomic operations. The patch looks good. I can't really test it but I assume you did. Thank you Sebastian. Reviewed-by: Fabien Chouteau chout...@adacore.com --- target-sparc/cpu.c |3 +- target-sparc/cpu.h |4 ++- target-sparc/helper.h |4 ++- target-sparc/ldst_helper.c | 26 +--- target-sparc/translate.c | 47 --- 5 files changed, 52 insertions(+), 32 deletions(-) diff --git a/target-sparc/cpu.c b/target-sparc/cpu.c index e7f878e..5806e59 100644 --- a/target-sparc/cpu.c +++ b/target-sparc/cpu.c @@ -458,7 +458,8 @@ static const sparc_def_t sparc_defs[] = { .mmu_trcr_mask = 0x, .nwindows = 8, .features = CPU_DEFAULT_FEATURES | CPU_FEATURE_TA0_SHUTDOWN | -CPU_FEATURE_ASR17 | CPU_FEATURE_CACHE_CTRL | CPU_FEATURE_POWERDOWN, +CPU_FEATURE_ASR17 | CPU_FEATURE_CACHE_CTRL | CPU_FEATURE_POWERDOWN | +CPU_FEATURE_CASA, }, #endif }; diff --git a/target-sparc/cpu.h b/target-sparc/cpu.h index 41194ec..f87d7fb 100644 --- a/target-sparc/cpu.h +++ b/target-sparc/cpu.h @@ -271,12 +271,14 @@ typedef struct sparc_def_t { #define CPU_FEATURE_ASR17(1 15) #define CPU_FEATURE_CACHE_CTRL (1 16) #define CPU_FEATURE_POWERDOWN(1 17) +#define CPU_FEATURE_CASA (1 18) #ifndef TARGET_SPARC64 #define CPU_DEFAULT_FEATURES (CPU_FEATURE_FLOAT | CPU_FEATURE_SWAP | \ CPU_FEATURE_MUL | CPU_FEATURE_DIV | \ CPU_FEATURE_FLUSH | CPU_FEATURE_FSQRT | \ - CPU_FEATURE_FMUL | CPU_FEATURE_FSMULD) + CPU_FEATURE_FMUL | CPU_FEATURE_FSMULD | \ + CPU_FEATURE_CASA) #else #define CPU_DEFAULT_FEATURES (CPU_FEATURE_FLOAT | CPU_FEATURE_SWAP | \ CPU_FEATURE_MUL | CPU_FEATURE_DIV | \ diff --git a/target-sparc/helper.h b/target-sparc/helper.h index 5e0eea1..9c4fd56 100644 --- a/target-sparc/helper.h +++ b/target-sparc/helper.h @@ -22,7 +22,6 @@ DEF_HELPER_1(popc, tl, tl) DEF_HELPER_4(ldda_asi, void, env, tl, int, int) DEF_HELPER_5(ldf_asi, void, env, tl, int, int, int) DEF_HELPER_5(stf_asi, void, env, tl, int, int, int) -DEF_HELPER_5(cas_asi, tl, env, tl, tl, tl, i32) DEF_HELPER_5(casx_asi, tl, env, tl, tl, tl, i32) DEF_HELPER_2(set_softint, void, env, i64) DEF_HELPER_2(clear_softint, void, env, i64) @@ -31,6 +30,9 @@ DEF_HELPER_2(tick_set_count, void, ptr, i64) DEF_HELPER_1(tick_get_count, i64, ptr) DEF_HELPER_2(tick_set_limit, void, ptr, i64) #endif +#if !defined(CONFIG_USER_ONLY) || defined(TARGET_SPARC64) +DEF_HELPER_5(cas_asi, tl, env, tl, tl, tl, i32) +#endif DEF_HELPER_3(check_align, void, env, tl, i32) DEF_HELPER_1(debug, void, env) DEF_HELPER_1(save, void, env) diff --git a/target-sparc/ldst_helper.c b/target-sparc/ldst_helper.c index 2936b58..c51b9b0 100644 --- a/target-sparc/ldst_helper.c +++ b/target-sparc/ldst_helper.c @@ -2224,33 +2224,35 @@ void helper_stf_asi(CPUSPARCState *env, target_ulong addr, int asi, int size, } } -target_ulong helper_cas_asi(CPUSPARCState *env, target_ulong addr, -target_ulong val1, target_ulong val2, uint32_t asi) +target_ulong helper_casx_asi(CPUSPARCState *env, target_ulong addr, + target_ulong val1, target_ulong val2, + uint32_t asi) { target_ulong ret; -val2 = 0xUL; -ret = helper_ld_asi(env, addr, asi, 4, 0); -ret = 0xUL; +ret = helper_ld_asi(env, addr, asi, 8, 0); if (val2 == ret) { -helper_st_asi(env, addr, val1 0xUL, asi, 4); +helper_st_asi(env, addr, val1, asi, 8); } return ret; } +#endif /* TARGET_SPARC64 */ -target_ulong helper_casx_asi(CPUSPARCState *env, target_ulong addr, - target_ulong val1, target_ulong val2, - uint32_t asi) +#if !defined(CONFIG_USER_ONLY) || defined(TARGET_SPARC64) +target_ulong helper_cas_asi(CPUSPARCState *env, target_ulong addr, +target_ulong val1, target_ulong val2, uint32_t asi) { target_ulong ret; -ret = helper_ld_asi(env, addr, asi, 8, 0); +val2 = 0xUL; +ret = helper_ld_asi(env, addr, asi, 4, 0); +ret = 0xUL; if (val2 == ret) { -helper_st_asi(env, addr, val1, asi, 8); +helper_st_asi(env, addr, val1 0xUL, asi, 4); } return ret; } -#endif /* TARGET_SPARC64 */ +#endif /*
Re: [Qemu-devel] [Qemu-trivial] [PATCH] sparc/leon3: Initialize stack pointer
On 02/05/2014 10:02 AM, Fabien Chouteau wrote: On 02/03/2014 10:18 AM, Sebastian Huber wrote: A lot of real world LEON3 systems are shipped with the GRMON boot loader. This boot loader initializes the stack pointer with the end of RAM address. The application can use this to detect the RAM size of a particular board variant. Looks good, thank you Sebastian. Reviewed-by: Fabien Chouteau chout...@adacore.com Sorry Blue you should be in copy. Can you apply this patch please? Thanks,
Re: [Qemu-devel] [PATCH] SPARC: Add and use CPU_FEATURE_CASA
On 02/05/2014 10:21 AM, Fabien Chouteau wrote: On 11/26/2013 03:04 PM, Sebastian Huber wrote: The LEON3 processor has support for the CASA instruction which is normally only available for SPARC V9 processors. Binutils 2.24 and GCC 4.9 will support this instruction for LEON3. GCC uses it to generate C11 atomic operations. The patch looks good. I can't really test it but I assume you did. Thank you Sebastian. Reviewed-by: Fabien Chouteau chout...@adacore.com Sorry Blue you should be in copy. Can you apply this patch please? Thanks,
Re: [Qemu-devel] kvm control qemu-system-aarch64 state
On 4 February 2014 20:40, Christoffer Dall christoffer.d...@linaro.org wrote: On Tue, Feb 04, 2014 at 04:52:08PM +, Peter Maydell wrote: On 4 February 2014 16:37, Claudio Fontana hw.clau...@gmail.com wrote: On 4 February 2014 16:39, Peter Maydell peter.mayd...@linaro.org wrote: On 4 February 2014 15:36, Claudio Fontana hw.clau...@gmail.com wrote: I just wanted to ask what is the current state of kvm control for qemu-system-aarch64. I tried latest mainline but I think it's not all there yet (it complains about missing cpu when I use -M virt and -cpu host, so I suspect some of VOS patches are still missing). Is your aarch64-kvm still the one branch to look at? Nope, this should all work in mainline. If it doesn't it's worth investigating what exactly is going wrong. (Sanity check, you did pass -enable-kvm, right? If you don't then QEMU will complain about -cpu host, because that only exists if KVM is enabled.) I tried both, without -enable-kvm I get the complaint about -cpu host as you mention, but with -enable-kvm and the latest kernel I get: [ 8489.895747] BUG: Bad page state in process qemu-system-aar pfn:0a5cd [ 8489.895816] page:fdfc002444d8 count:-1 mapcount:0 mapping: (null) index:0x0 [ 8489.895870] page flags: 0x0() [ 8489.895916] page dumped because: nonzero _count [ 8489.895957] Modules linked in: [ 8489.896030] CPU: 0 PID: 3031 Comm: qemu-system-aar Tainted: GB 3.13.0cla-09218-g0e47c96-dirty #2 [ 8489.896085] Call trace: [ 8489.896154] [fe095744] dump_backtrace+0x0/0x12c [ 8489.896231] [fe095884] show_stack+0x14/0x1c [ 8489.896307] [fe3db58c] dump_stack+0x70/0x8c [ 8489.896378] [fe1210d8] bad_page+0xe8/0x134 [ 8489.896453] [fe121740] get_page_from_freelist+0x500/0x608 [ 8489.896532] [fe1220d0] __alloc_pages_nodemask+0x110/0x7ec [ 8489.896619] [fe13ce50] handle_mm_fault+0x760/0x980 [ 8489.896704] [fe09a0cc] do_page_fault+0x228/0x378 [ 8489.896773] [fe090104] do_mem_abort+0x3c/0x9c [ 8489.896833] Exception stack(0xfe0020247e30 to 0xfe0020247f50) [ 8489.896918] 7e20: 0001 aa8505b0 03ff [ 8489.897030] 7e40: aa785a84 03ff 0015e5a8 fe00 [ 8489.897142] 7e60: 20247e70 fe00 000c2e48 fe00 20247ea0 fe00 00095490 fe00 [ 8489.897254] 7e80: 20244000 fe00 aa86f118 03ff [ 8489.897366] 7ea0: fea46360 03ff 0009288c fe00 fea46580 03ff fea463e0 03ff [ 8489.897476] 7ec0: fea46360 03ff 000927ec fe00 00f3f710 00012e61 [ 8489.897584] 7ee0: 00f4d1a0 da91 0001 [ 8489.897694] 7f00: 000d 036a 7f7f7f7f 7f7f7f7f 00680ca8 [ 8489.897800] 7f20: 006d 0020 0078 0080 [ 8489.897884] 7f40: 006812b0 aa852598 03ff Ugh, can you let me know the kernel version, qemu version, and exact command line you are using? -Christoffer I think I just configured it wrongly, now it works: kernel is mainline from Jan 28, commit 0e47c969c65e213421450c31043353ebe3c67e0c qemu is mainline from Jan 31, commit 97374ce538883af677fd94803b71df2d55a9a4de I had the kernel configured with CONFIG_ARM64_64K_PAGES and CONFIG_TRANSPARENT_HUGEPAGE. Disabling those fixed it for me. Ciao Claudio
Re: [Qemu-devel] [Qemu-ppc] [V2 PATCH 6/9] target-ppc: Load Quadword
On 31.01.2014, at 20:34, Tom Musta tommu...@gmail.com wrote: This patch adds the Book I (user space) Load Quadword (lq) instruction. This instruction was introduced into Book I in Power ISA V2.07. Previous versions of the architecture supported this as a privileged instruction. Previous versions of the architecture also did not support Little Endian mode. Note that this patch also adds the PPC_64BX flag to the Power8 model, which enables the lq instruction. Signed-off-by: Tom Musta tommu...@gmail.com --- V2: Refactored the user-mode and LE checks per Alex Graf's review. target-ppc/translate.c | 40 target-ppc/translate_init.c |2 +- 2 files changed, 25 insertions(+), 17 deletions(-) diff --git a/target-ppc/translate.c b/target-ppc/translate.c index 6ec4127..e36686e 100644 --- a/target-ppc/translate.c +++ b/target-ppc/translate.c @@ -2872,36 +2872,44 @@ static void gen_ld(DisasContext *ctx) /* lq */ static void gen_lq(DisasContext *ctx) { -#if defined(CONFIG_USER_ONLY) -gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC); -#else -int ra, rd; -TCGv EA; +/* lq is a legal user mode instruction starting in ISA 2.07 */ +bool legal_in_user_mode = (ctx-insns_flags2 PPC2_LSQ_ISA207) != 0; +bool le_is_supported = (ctx-insns_flags2 PPC2_LSQ_ISA207) != 0; -/* Restore CPU state */ -if (unlikely(ctx-mem_idx == 0)) { +if (!legal_in_user_mode is_user_mode(ctx)) { gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC); return; } + +if (!le_is_supported ctx-le_mode) { +gen_exception_err(ctx, POWERPC_EXCP_ALIGN, POWERPC_EXCP_ALIGN_LE); +return; +} + +int ra, rd; +TCGv EA; I would've expected the compiler to emit a warning at this point because you're declaring variables outside of the beginning of a scope? Alex + ra = rA(ctx-opcode); rd = rD(ctx-opcode); if (unlikely((rd 1) || rd == ra)) { gen_inval_exception(ctx, POWERPC_EXCP_INVAL_INVAL); return; } -if (unlikely(ctx-le_mode)) { -/* Little-endian mode is not handled */ -gen_exception_err(ctx, POWERPC_EXCP_ALIGN, POWERPC_EXCP_ALIGN_LE); -return; -} + gen_set_access_type(ctx, ACCESS_INT); EA = tcg_temp_new(); gen_addr_imm_index(ctx, EA, 0x0F); -gen_qemu_ld64(ctx, cpu_gpr[rd], EA); -gen_addr_add(ctx, EA, EA, 8); -gen_qemu_ld64(ctx, cpu_gpr[rd+1], EA); + +if (unlikely(ctx-le_mode)) { +gen_qemu_ld64(ctx, cpu_gpr[rd+1], EA); +gen_addr_add(ctx, EA, EA, 8); +gen_qemu_ld64(ctx, cpu_gpr[rd], EA); +} else { +gen_qemu_ld64(ctx, cpu_gpr[rd], EA); +gen_addr_add(ctx, EA, EA, 8); +gen_qemu_ld64(ctx, cpu_gpr[rd+1], EA); +} tcg_temp_free(EA); -#endif } #endif diff --git a/target-ppc/translate_init.c b/target-ppc/translate_init.c index 886238a..d7bcbba 100644 --- a/target-ppc/translate_init.c +++ b/target-ppc/translate_init.c @@ -7333,7 +7333,7 @@ POWERPC_FAMILY(POWER8)(ObjectClass *oc, void *data) PPC_CACHE | PPC_CACHE_ICBI | PPC_CACHE_DCBZ | PPC_MEM_SYNC | PPC_MEM_EIEIO | PPC_MEM_TLBIE | PPC_MEM_TLBSYNC | - PPC_64B | PPC_ALTIVEC | + PPC_64B | PPC_64BX | PPC_ALTIVEC | PPC_SEGMENT_64B | PPC_SLBI | PPC_POPCNTB | PPC_POPCNTWD; pcc-insns_flags2 = PPC2_VSX | PPC2_VSX207 | PPC2_DFP | PPC2_DBRX | -- 1.7.1
Re: [Qemu-devel] [Qemu-ppc] [V2 PATCH 9/9] target-ppc: Add Store Quadword Conditional
On 31.01.2014, at 20:34, Tom Musta tommu...@gmail.com wrote: This patch adds the Store Quadword Conditionl (stqcx.) instruction which is introduced in Power ISA 2.07. Signed-off-by: Tom Musta tommu...@gmail.com --- V2: Updated linux-user/main.c to use the newly added reserve_val2. linux-user/main.c | 18 +- target-ppc/translate.c | 21 + 2 files changed, 38 insertions(+), 1 deletions(-) diff --git a/linux-user/main.c b/linux-user/main.c index cabc9e1..6330427 100644 --- a/linux-user/main.c +++ b/linux-user/main.c @@ -1490,7 +1490,7 @@ static int do_store_exclusive(CPUPPCState *env) { target_ulong addr; target_ulong page_addr; -target_ulong val; +target_ulong val, val2; int flags; int segv = 0; @@ -1513,6 +1513,13 @@ static int do_store_exclusive(CPUPPCState *env) case 4: segv = get_user_u32(val, addr); break; #if defined(TARGET_PPC64) case 8: segv = get_user_u64(val, addr); break; +case 16: { +segv = get_user_u64(val, addr); +if (!segv) { +segv = get_user_u64(val, addr + 8); +} +break; +} Does this work? After this val contains reserve_val2, but further down that one gets checked against reserve_val so the comparison is broken, no? Alex #endif default: abort(); } @@ -1524,6 +1531,15 @@ static int do_store_exclusive(CPUPPCState *env) case 4: segv = put_user_u32(val, addr); break; #if defined(TARGET_PPC64) case 8: segv = put_user_u64(val, addr); break; +case 16: { +if (val2 == env-reserve_val2) { +segv = put_user_u64(val, addr); +if (!segv) { +segv = put_user_u64(val2, addr + 8); +} +} +break; +} #endif default: abort(); } diff --git a/target-ppc/translate.c b/target-ppc/translate.c index 8257dea..c883680 100644 --- a/target-ppc/translate.c +++ b/target-ppc/translate.c @@ -3329,6 +3329,20 @@ static void gen_conditional_store(DisasContext *ctx, TCGv EA, gen_qemu_st32(ctx, cpu_gpr[reg], EA); } else if (size == 2) { gen_qemu_st16(ctx, cpu_gpr[reg], EA); +#if defined(TARGET_PPC64) +} else if (size == 16) { +TCGv gpr1, gpr2; +if (unlikely(ctx-le_mode)) { +gpr1 = cpu_gpr[reg+1]; +gpr2 = cpu_gpr[reg]; +} else { +gpr1 = cpu_gpr[reg]; +gpr2 = cpu_gpr[reg+1]; +} +gen_qemu_st64(ctx, gpr1, EA); +gen_addr_add(ctx, EA, EA, 8); +gen_qemu_st64(ctx, gpr2, EA); +#endif } else { gen_qemu_st8(ctx, cpu_gpr[reg], EA); } @@ -3341,6 +3355,11 @@ static void gen_conditional_store(DisasContext *ctx, TCGv EA, static void gen_##name(DisasContext *ctx) \ { \ TCGv t0; \ +if (unlikely((len == 16) (rD(ctx-opcode) 1))) { \ +gen_inval_exception(ctx, \ +POWERPC_EXCP_INVAL_INVAL);\ +return; \ +} \ gen_set_access_type(ctx, ACCESS_RES); \ t0 = tcg_temp_local_new();\ gen_addr_reg_index(ctx, t0); \ @@ -3395,6 +3414,7 @@ static void gen_lqarx(DisasContext *ctx) /* stdcx. */ STCX(stdcx_, 8); +STCX(stqcx_, 16); #endif /* defined(TARGET_PPC64) */ /* sync */ @@ -9634,6 +9654,7 @@ GEN_HANDLER2(stwcx_, stwcx., 0x1F, 0x16, 0x04, 0x, PPC_RES), GEN_HANDLER(ldarx, 0x1F, 0x14, 0x02, 0x, PPC_64B), GEN_HANDLER_E(lqarx, 0x1F, 0x14, 0x08, 0, PPC_NONE, PPC2_LSQ_ISA207), GEN_HANDLER2(stdcx_, stdcx., 0x1F, 0x16, 0x06, 0x, PPC_64B), +GEN_HANDLER_E(stqcx_, 0x1F, 0x16, 0x05, 0, PPC_NONE, PPC2_LSQ_ISA207), #endif GEN_HANDLER(sync, 0x1F, 0x16, 0x12, 0x039FF801, PPC_MEM_SYNC), GEN_HANDLER(wait, 0x1F, 0x1E, 0x01, 0x03FFF801, PPC_WAIT), -- 1.7.1
Re: [Qemu-devel] Bug#728876: qemu: smbd forked by qemu uses global directory /var/run/samba/ncalrpc
Ping? Again, more than 2 months passed since initial submission. Thanks, /mjt 29.11.2013 00:15, Michael Tokarev wrote: Jan, there's one more samba-related fix for slirp, also from Michael Büsch. Add my Signed-off-By: Michael Tokarev m...@tls.msk.ru if needed. Thanks, /mjt 06.11.2013 17:01, Michael Büsch wrote: Package: qemu Version: 1.6.0+dfsg-2 Severity: normal Tags: patch The smbd forked by qemu still uses the default ncalrpc directory in /var/run/samba. This may lead to problems, if the directory does not exist (for example if /var/run is a tmpfs and the host smbd was not started). This leads to the following error message from samba and an unworkable smbd: Failed to create pipe directory /var/run/samba/ncalrpc - No such file or directory The attached patch fixes this by pointing smbd to /tmp/qemu-smb.%d.%d/ncalrpc as ncalrpc directory. Smbd will create the actual ncalrpc subdirectory on its own. Using a private directory also avoids possible clashes with the system-smbd.
Re: [Qemu-devel] [PATCH] qemu: Broken -smb with latest SAMBA package. (Unsupported security=share option)
On Sun, 03 Nov 2013 21:06:22 +0100, Jan Kiszka wrote: On 2013-11-01 11:10, Michael Tokarev wrote: 01.11.2013 13:54, Michael Büsch wrote: On Fri, 01 Nov 2013 13:32:49 +0400 Michael Tokarev m...@tls.msk.ru wrote: That looks right. Are you okay adding your Signed-off-by to the patch you initially submitted? If yes, I'll make a formal patch submission upstream. Here you go. Thank you! Adding Jan as slirp maintainer, and my Reviewed-by: Michael Tokarev m...@tls.msk.ru If Jan picks it up, that's fine. If not, I think it can go to the trivial patches queue. Works fine, applied to queues/slirp. But this is not a trivial patch as the fix is not obvious for a reader (unless you know smb.conf semantics by heart). Jan, did you forget to push the queue? Its been more than 2 months ago, and qemu git is still not fixed? Thanks, /mjt
Re: [Qemu-devel] [PATCH] SPARC: Add and use CPU_FEATURE_CASA
On 11/28/2013 10:55 AM, Sebastian Huber wrote: Hello, On 2013-11-26 15:04, Sebastian Huber wrote: The LEON3 processor has support for the CASA instruction which is normally only available for SPARC V9 processors. Binutils 2.24 and GCC 4.9 will support this instruction for LEON3. GCC uses it to generate C11 atomic operations. --- target-sparc/cpu.c |3 +- target-sparc/cpu.h |4 ++- target-sparc/helper.h |4 ++- target-sparc/ldst_helper.c | 26 +--- target-sparc/translate.c | 47 --- 5 files changed, 52 insertions(+), 32 deletions(-) [...] this patch doesn't work since the ASI 0x80 used for the synthetic CAS instruction is not implemented in helper_ld_asi() for !TARGET_SPARC64. I tried to add a case 0x80: /* Primary */ { switch (size) { case 1: ret = ldub_raw(addr); break; case 2: ret = lduw_raw(addr); break; case 4: ret = ldl_raw(addr); break; default: case 8: ret = ldq_raw(addr); break; } } break; but this results in a Qemu segmentation fault. Hello Sebastian, I missed this email. It's easier for me to see you message if I'm in copy, also add Blue Swirl blauwir...@gmail.com in copy for all SPARC patches. ASI 0x80 doesn't make sense in SPARC32 where does this value come from? I guess it's TCGv_i32 r_asi = tcg_const_i32(GET_FIELD(insn, 19, 26));, right?
Re: [Qemu-devel] qemu segfauls with spiceport chardev and isa-serial
* Peter Crosthwaite (peter.crosthwa...@xilinx.com) wrote: On Tue, Feb 4, 2014 at 4:45 AM, Dr. David Alan Gilbert dgilb...@redhat.com wrote: (cc'ing in Peter Crosthwaite and Michael Tokarev due to a serial fifo change - see below!) * Martin Kletzander (mklet...@redhat.com) wrote: Hello, Hi Martin, I don't know about your spice warnings that triggered this but looking down the backtrace I can see something odd: current HEAD (2f61120c10da9128357510debc8e66880cd2bfdc) segfaults when I'm trying to do the following: I add this to qemu's command-line: -chardev spiceport,id=charserial0,name=org.qemu.console.serial.0 \ -device isa-serial,chardev=charserial0,id=serial0 snip Hi Dave, Yes that does looks suss. My bad. Can you confirm your theory by making the proposed change? does it fix the bug? --- a/hw/char/serial.c +++ b/hw/char/serial.c @@ -225,7 +225,7 @@ static gboolean serial_xmit(GIOChannel *chan, GIOCondition cond, void if (s-tsr_retry = 0) { if (s-fcr UART_FCR_FE) { -s-tsr = fifo8_is_full(s-xmit_fifo) ? +s-tsr = fifo8_is_empty(s-xmit_fifo) ? 0 : fifo8_pop(s-xmit_fifo); if (!s-xmit_fifo.num) { s-lsr |= UART_LSR_THRE; Yep, seems reasonable; and Martin says it stops the seg; I wonder if there are any serial tests out there - The other failure mode this could have caused is the replacing of chunks of outbound data by \0's if the fifo was full. Dave -- Dr. David Alan Gilbert / dgilb...@redhat.com / Manchester, UK
Re: [Qemu-devel] qemu segfauls with spiceport chardev and isa-serial
On Tue, Feb 04, 2014 at 07:05:24AM +0100, Martin Kletzander wrote: On Tue, Feb 04, 2014 at 11:40:41AM +1000, Peter Crosthwaite wrote: On Tue, Feb 4, 2014 at 4:45 AM, Dr. David Alan Gilbert dgilb...@redhat.com wrote: (cc'ing in Peter Crosthwaite and Michael Tokarev due to a serial fifo change - see below!) * Martin Kletzander (mklet...@redhat.com) wrote: Hello, Hi Martin, I don't know about your spice warnings that triggered this but looking down the backtrace I can see something odd: current HEAD (2f61120c10da9128357510debc8e66880cd2bfdc) segfaults when I'm trying to do the following: I add this to qemu's command-line: -chardev spiceport,id=charserial0,name=org.qemu.console.serial.0 \ -device isa-serial,chardev=charserial0,id=serial0 and then use spicy to connect to that machine. That spits out the following error: GSpice-Message: main channel: opened port 0x7f74182366e0 org.qemu.console.serial.0: opened (spicy:32386): GSpice-WARNING **: incomplete link header (-104/16) (spicy:32386): GSpice-WARNING **: incomplete link header (-104/16) GSpice-Message: main channel: closed I can see that the console works when the window flashes, so there was some communication done (Im running the kernel inside with console=tty0 console=ttyS0,115200n8 as suggested here: http://lists.freedesktop.org/archives/spice-devel/2014-January/015919.html The full command-line with backtrace of all the threads (with abort()-ing thread being thread #1 follows. Let me know if I can help anyhow. Thanks, Martin Command-line: qemu-system-x86_64 -name rhel7 -S -machine \ pc-i440fx-1.7,accel=kvm,usb=off,dump-guest-core=off -cpu SandyBridge \ -m 4101 -realtime mlock=off -smp 1,sockets=1,cores=1,threads=1 -uuid \ f49fa544-f21d-4267-8958-d82570644f39 -no-user-config -nodefaults \ -chardev \ socket,id=charmonitor,path=/var/lib/libvirt/qemu/rhel7.monitor,server,nowait \ -mon chardev=charmonitor,id=monitor,mode=control -rtc base=utc \ -no-shutdown -boot strict=on -device \ piix3-usb-uhci,id=usb,bus=pci.0,addr=0x1.0x2 -device \ virtio-serial-pci,id=virtio-serial0,bus=pci.0,addr=0x6 -drive \ if=none,id=drive-ide0-0-0,readonly=on,format=raw -device \ ide-cd,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0 -drive \ file=/home/nert/.config/libvirt/images/rhel7.img,if=none,id=drive-virtio-disk0,format=qcow2 \ -device \ virtio-blk-pci,scsi=off,bus=pci.0,addr=0x4,drive=drive-virtio-disk0,id=virtio-disk0,bootindex=1 \ -netdev tap,fd=20,id=hostnet0,vhost=on,vhostfd=21 -device \ virtio-net-pci,netdev=hostnet0,id=net0,mac=52:54:00:42:be:45,bus=pci.0,addr=0x3 \ -chardev spiceport,id=charserial0,name=org.qemu.console.serial.0 \ -device isa-serial,chardev=charserial0,id=serial0 -device \ usb-tablet,id=input0 -vnc 127.0.0.1:0 -spice \ port=5901,tls-port=5902,addr=127.0.0.1,disable-ticketing,x509-dir=/etc/pki/libvirt-spice,seamless-migration=on \ -device \ qxl-vga,id=video0,ram_size=67108864,vram_size=67108864,bus=pci.0,addr=0x2 \ -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x5 Backtrace: snipped boring threads in poll Thread 1 (Thread 0x7fee3da66980 (LWP 32022)): #0 0x7fee344f1f4e in __GI_raise (sig=sig@entry=6) at ../nptl/sysdeps/unix/sysv/linux/raise.c:56 #1 0x7fee344f369f in __GI_abort () at abort.c:89 #2 0x7fee3de72baa in fifo8_pop (fifo=fifo@entry=0x7fee3fc28700) at util/fifo8.c:45 fifo8_pop is aborting because the fifo is empty: if (fifo-num == 0) { abort(); } which seems fair enough #3 0x7fee3dc0c110 in serial_xmit (chan=optimized out, cond=optimized out, opaque=0x7fee3fc286a0) at hw/char/serial.c:228 s-tsr = fifo8_is_full(s-xmit_fifo) ? 0 : fifo8_pop(s-xmit_fifo); Hmm, now I don't know anything about the tsr stuff; but that calls fifo8_pop whenever the fifo isn't *full* - i.e. it still gets called if empty. I think the change here comes from Peter's 8e8638fa87ff04 'char/serial: Use generic Fifo8' changeset from June which did: -s-tsr = fifo_get(s,XMIT_FIFO); -if (!s-xmit_fifo.count) { +s-tsr = fifo8_is_full(s-xmit_fifo) ? +0 : fifo8_pop(s-xmit_fifo); +if (!s-xmit_fifo.num) { which makes me think (without having looked at the old data structure properly) if that should be fifo8_is_empty ? (The old serial fifo_get routine returned 0 if empty rather than aborting). Hi Dave, Yes that does looks suss. My bad. Can you confirm your theory by making the proposed change? does it fix the bug? --- a/hw/char/serial.c +++ b/hw/char/serial.c @@ -225,7 +225,7 @@ static gboolean serial_xmit(GIOChannel *chan,
Re: [Qemu-devel] [PATCH v2 09/35] target-arm: A64: Implement MSR (immediate) instructions
On 5 February 2014 06:23, Peter Crosthwaite peter.crosthwa...@xilinx.com wrote: On Sat, Feb 1, 2014 at 1:45 AM, Peter Maydell peter.mayd...@linaro.org wrote: Implement the MSR (immediate) instructions, which can update the PSTATE SP and DAIF fields. Signed-off-by: Peter Maydell peter.mayd...@linaro.org --- target-arm/cpu.h | 1 + target-arm/helper.h| 2 ++ target-arm/op_helper.c | 25 + target-arm/translate-a64.c | 24 +++- 4 files changed, 51 insertions(+), 1 deletion(-) diff --git a/target-arm/cpu.h b/target-arm/cpu.h index 385cfcd..e66d464 100644 --- a/target-arm/cpu.h +++ b/target-arm/cpu.h @@ -426,6 +426,7 @@ int cpu_arm_handle_mmu_fault (CPUARMState *env, target_ulong address, int rw, #define PSTATE_Z (1U 30) #define PSTATE_N (1U 31) #define PSTATE_NZCV (PSTATE_N | PSTATE_Z | PSTATE_C | PSTATE_V) +#define PSTATE_DAIF (PSTATE_D | PSTATE_A | PSTATE_I | PSTATE_F) #define CACHED_PSTATE_BITS (PSTATE_NZCV) /* Mode values for AArch64 */ #define PSTATE_MODE_EL3h 13 diff --git a/target-arm/helper.h b/target-arm/helper.h index 71b8411..93a27ce 100644 --- a/target-arm/helper.h +++ b/target-arm/helper.h @@ -62,6 +62,8 @@ DEF_HELPER_2(get_cp_reg, i32, env, ptr) DEF_HELPER_3(set_cp_reg64, void, env, ptr, i64) DEF_HELPER_2(get_cp_reg64, i64, env, ptr) +DEF_HELPER_3(msr_i_pstate, void, env, i32, i32) + DEF_HELPER_2(get_r13_banked, i32, env, i32) DEF_HELPER_3(set_r13_banked, void, env, i32, i32) diff --git a/target-arm/op_helper.c b/target-arm/op_helper.c index a918e5b..c812a9f 100644 --- a/target-arm/op_helper.c +++ b/target-arm/op_helper.c @@ -313,6 +313,31 @@ uint64_t HELPER(get_cp_reg64)(CPUARMState *env, void *rip) return value; } +void HELPER(msr_i_pstate)(CPUARMState *env, uint32_t op, uint32_t imm) +{ +/* MSR_i to update PSTATE. This is OK from EL0 only if UMA is set. + * Note that SPSel is never OK from EL0; we rely on handle_msr_i() + * to catch that case at translate time. + */ +if (arm_current_pl(env) == 0 !(env-cp15.c1_sys SCTLR_UMA)) { +raise_exception(env, EXCP_UDEF); +} + +switch (op) { +case 0x05: /* SPSel */ +env-pstate = deposit32(env-pstate, 0, 1, imm); 0,1 hardcoded constants are a bit unfriendly. I guess the current macro set doesnt define _SHIFT and _WIDTH definitions, should they be added? FWIW, I have this macro in my tree which makes short work of defining mask, shift and width constants as a one liner: /* Define SHIFT, LENGTH and MASK constants for a field within a register */ #define FIELD(reg, field, length, shift) \ enum { reg ## _ ## field ## _SHIFT = (shift)}; \ enum { reg ## _ ## field ## _LENGTH = (length)}; \ enum { reg ## _ ## field ## _MASK = (((1ULL (length)) - 1) \ (shift)) }; Usage would be something like FIELD(PSTATE, SPSEL, 1, 0) Hmm. I guess we could use some more consistent structure in defining bit macros. (reg, field, start, len) would be a better argument order though, to match the extract and deposit fns. +break; +case 0x1e: /* DAIFSet */ +env-pstate |= (imm 6) PSTATE_DAIF; +break; +case 0x1f: /* DAIFClear */ +env-pstate = ~((imm 6) PSTATE_DAIF); I wonder whether deposit should be extended with and/or (with existing) versions to allow for consistency in places like this. In SPSel we get the nice deposit based implementation but with the logic function change here were are stuck with open codedness. Set and clearing and fields should be common enough tree wide to warrant it perhaps. I dunno. Deposit is a function mostly because clear old field to zeroes then insert new value is complicated enough that it's easy to miscode it. Plain force-set and force-clear I think is simple enough (and not all that common) that I'm happy to opencode it. One point I need to think about a little more with the DAIF bits is whether we should be keeping them in one place for AArch32 and AArch64 -- at the moment an AArch32 core's IF bits are in cpsr. Having them in one location would make the cpu-exec.c code a bit simpler. thanks -- PMM
Re: [Qemu-devel] [PATCH v2 12/35] target-arm: Convert performance monitor reginfo to accesfn
On 5 February 2014 06:59, Peter Crosthwaite peter.crosthwa...@xilinx.com wrote: cc Alistair, this may conflict with his timer work. On Sat, Feb 1, 2014 at 1:45 AM, Peter Maydell peter.mayd...@linaro.org wrote: @@ -624,37 +606,41 @@ static const ARMCPRegInfo v7_cp_reginfo[] = { { .name = PMCNTENSET, .cp = 15, .crn = 9, .crm = 12, .opc1 = 0, .opc2 = 1, .access = PL0_RW, .resetvalue = 0, .fieldoffset = offsetof(CPUARMState, cp15.c9_pmcnten), - .readfn = pmreg_read, .writefn = pmcntenset_write, - .raw_readfn = raw_read, .raw_writefn = raw_write }, + .writefn = pmcntenset_write, + .accessfn = pmreg_access, + .raw_writefn = raw_write }, A nit but, You're field ordering scheme is inconsistent, here you go, write - access - raw_write { .name = PMCNTENCLR, .cp = 15, .crn = 9, .crm = 12, .opc1 = 0, .opc2 = 2, .access = PL0_RW, .fieldoffset = offsetof(CPUARMState, cp15.c9_pmcnten), - .readfn = pmreg_read, .writefn = pmcntenclr_write, + .accessfn = pmreg_access, + .writefn = pmcntenclr_write, .type = ARM_CP_NO_MIGRATE }, { .name = PMOVSR, .cp = 15, .crn = 9, .crm = 12, .opc1 = 0, .opc2 = 3, .access = PL0_RW, .fieldoffset = offsetof(CPUARMState, cp15.c9_pmovsr), - .readfn = pmreg_read, .writefn = pmovsr_write, - .raw_readfn = raw_read, .raw_writefn = raw_write }, -/* Unimplemented so WI. Strictly speaking write accesses in PL0 should - * respect PMUSERENR. - */ + .accessfn = pmreg_access, + .writefn = pmovsr_write, + .raw_writefn = raw_write }, ... and this is access - write - raw_write. Is there a prescribed order to keep new (or gradually refactored) code consistent? No, I've just been going for whatever looks like it fits reasonably neatly onto not too many lines and is a fairly minimal change to existing structs, mostly. The thing I have been trying to be consistent with is the order for crn/crm/opc1/opc2 fields, which for new registers I've been making be op0/op1/crn/crm/op2, because that's the order the ARM ARM seems to have settled on. Unfortunately a lot of our existing definitions are crn/crm/op1/op2, because at the time there was variance in the ARM docs and that order seemed sensible to me. For the other fields, I think name first; type/state/encoding second; access related fields; read and write accessors; reset stuff is probably not a bad order. But the nice thing about having named fields is it doesn't actually matter what order things go in. thanks -- PMM
Re: [Qemu-devel] [PATCH 13/12] qapi: refine human printing of sizes
On Thu, 30 Jan 2014 17:42:25 +0100 Paolo Bonzini pbonz...@redhat.com wrote: This fixes several bugs or shortcomings of the previous pretty-printer. In particular: * use PRIu64 instead of casting to long long * the exact value is included too * the correct unit of measure (MiB, GiB, etc.) is used. PiB and EiB are added too. * due to an off-by-one error, 512*2^30 was printed as 0.500MiB rather than 512MiB. floor(log2(val)) is equal to 63 - clz(val), while the code used 64. * The desired specification is %g rather than %f, which always uses three decimals in the current code. However %g would switch to scientific notation when the integer part is = 1000 (e.g. 1000*2^30). To keep the code simple, switch to the higher power when the integer part is = 1000; overflow is avoided by using frexp instead of clz. Suggested-by: Eric Blake ebl...@redhat.com Signed-off-by: Paolo Bonzini pbonz...@redhat.com --- qapi/string-output-visitor.c | 23 --- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/qapi/string-output-visitor.c b/qapi/string-output-visitor.c index 67a8798..95dd8fa 100644 --- a/qapi/string-output-visitor.c +++ b/qapi/string-output-visitor.c @@ -15,6 +15,7 @@ #include qapi/visitor-impl.h #include qapi/qmp/qerror.h #include qemu/host-utils.h +#include math.h struct StringOutputVisitor { @@ -47,30 +48,30 @@ static void print_type_size(Visitor *v, uint64_t *obj, const char *name, Error **errp) { StringOutputVisitor *sov = DO_UPCAST(StringOutputVisitor, visitor, v); -static const char suffixes[] = { 'B', 'K', 'M', 'G', 'T' }; +static const char suffixes[] = { 'B', 'K', 'M', 'G', 'T', 'P', 'E' }; uint64_t div, val; char *out; int i; if (!sov-human) { -out = g_strdup_printf(%llu, (long long) *obj); +out = g_strdup_printf(%PRIu64, *obj); string_output_set(sov, out); return; } val = *obj; -/* Compute floor(log2(val)). */ -i = 64 - clz64(val); - -/* Find the power of 1024 that we'll display as the units. */ -i /= 10; -if (i = ARRAY_SIZE(suffixes)) { -i = ARRAY_SIZE(suffixes) - 1; -} +/* The exponent (returned in i) minus one gives us + * floor(log2(val * 1024 / 1000). The correction makes us + * switch to the higher power when the integer part is = 1000. + */ +frexp(val / (1000.0 / 1024.0), i); +i = (i - 1) / 10; +assert(i ARRAY_SIZE(suffixes)); div = 1ULL (i * 10); -out = g_strdup_printf(%0.03f%c, (double)val/div, suffixes[i]); +out = g_strdup_printf(%PRIu64 (%0.3g %c%s), val, + (double)val/div, suffixes[i], i ? iB : ); ERROR: code indent should never use tabs #81: FILE: qapi/string-output-visitor.c:74: +^I^I^I (double)val/div, suffixes[i], i ? iB : );$ string_output_set(sov, out); }
Re: [Qemu-devel] [PATCH 00/12] qdev: cleanup legacy properties
On Thu, 30 Jan 2014 14:09:42 +0100 Paolo Bonzini pbonz...@redhat.com wrote: The conversion of qdev to QOM brought with it legacy properties. Legacy properties are always have a string type (the accessors always call visit_type_str), and were used to support -device syntax while keeping QOM properties strongly typed. For example, an hex8 property is registered twice, once as an integer-typed property and once as a legacy property that enforces base 16 for its input. However, when introducing legacy properties, the hex8/32/64 had a small change applied: the previously-optional 0x prefix became mandatory, and an error was raised if you omitted it. This was in preparation for making the legacy properties read-only, and changing the hex8/32/64 properties to uint8/32/64. This series does exactly this in patches 1-6. On the printing side, legacy properties are used by info qtree to tweak its presentation: strings are quoted, hex8/32/64 properties are printed in hexadecimal, and so on. In this series, patches 7-10 add a human mode to StringOutputVisitors. This mode employs a slightly different presentation, more suitable for human consumption, but its output cannot be sent back to a StringInputVisitor. The main change is that numbers are printed in both decimal and 0x-prefixed hexadecimal. This lets us drop hex8/32/64 property types. Finally, patches 11-12 clean up the type names used for properties. These are always QAPI names, so that in the future QOM introspection can piggyback on QAPI introspection for describing property types. Paolo Bonzini (12): qapi: add size parser to StringInputVisitor qdev: sizes are now parsed by StringInputVisitor qdev: remove legacy parsers for hex8/32/64 qdev: legacy properties are now read-only qdev: legacy properties are just strings qdev: inline qdev_prop_parse qapi: add human mode to StringOutputVisitor qdev: use human mode in info qtree qdev: remove most legacy printers qdev: remove hex8/32/64 property types qdev: add enum property types to QAPI schema qdev: use QAPI type names for properties hw/audio/adlib.c | 2 +- hw/audio/cs4231a.c | 2 +- hw/audio/gus.c | 2 +- hw/audio/pcspk.c | 2 +- hw/audio/sb16.c | 4 +- hw/block/fdc.c | 2 +- hw/char/debugcon.c | 4 +- hw/char/parallel.c | 2 +- hw/char/serial-isa.c | 2 +- hw/core/qdev-properties-system.c | 12 ++- hw/core/qdev-properties.c| 204 +++ hw/core/qdev.c | 38 +-- hw/display/g364fb.c | 2 +- hw/display/tcx.c | 4 +- hw/dma/i82374.c | 2 +- hw/dma/sun4m_iommu.c | 2 +- hw/i386/kvm/i8254.c | 8 +- hw/ide/isa.c | 4 +- hw/ide/qdev.c| 2 +- hw/intc/i8259_common.c | 6 +- hw/isa/pc87312.c | 2 +- hw/misc/applesmc.c | 2 +- hw/misc/debugexit.c | 4 +- hw/misc/eccmemctl.c | 2 +- hw/net/ne2000-isa.c | 2 +- hw/nvram/fw_cfg.c| 4 +- hw/ppc/spapr_pci.c | 16 +-- hw/scsi/megasas.c| 2 +- hw/scsi/scsi-disk.c | 6 +- hw/sd/sdhci.c| 4 +- hw/timer/i8254.c | 2 +- hw/timer/m48t59.c| 4 +- hw/timer/mc146818rtc.c | 14 +-- hw/usb/host-libusb.c | 4 +- hw/virtio/virtio-pci.c | 6 +- include/hw/block/block.h | 6 -- include/hw/qdev-core.h | 1 - include/hw/qdev-dma.h| 2 +- include/hw/qdev-properties.h | 11 -- include/qapi/string-output-visitor.h | 2 +- include/qemu-common.h| 8 -- include/qom/object.h | 3 +- qapi-schema.json | 58 ++ qapi/string-input-visitor.c | 24 + qapi/string-output-visitor.c | 55 +- qdev-monitor.c | 6 +- qom/object.c | 4 +- tests/test-string-output-visitor.c | 2 +- tests/test-visitor-serialization.c | 2 +- 49 files changed, 235 insertions(+), 329 deletions(-) with fixed checkpatch error in 13/12 Reviewed-By: Igor Mammedov imamm...@redhat.com
[Qemu-devel] [PATCH] Remove trailing space from error message
Signed-off-by: Orit Wasserman owass...@redhat.com --- migration.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/migration.c b/migration.c index 25add6f..cc18f6c 100644 --- a/migration.c +++ b/migration.c @@ -482,7 +482,7 @@ void qmp_migrate_set_cache_size(int64_t value, Error **errp) /* Cache should not be larger than guest ram size */ if (value ram_bytes_total()) { error_set(errp, QERR_INVALID_PARAMETER_VALUE, cache size, - exceeds guest ram size ); + exceeds guest ram size); return; } -- 1.8.3.1
Re: [Qemu-devel] [PATCH] Revert nand: Don't inherit from Sysbus
Andreas Färber afaer...@suse.de writes: Am 05.02.2014 09:39, schrieb Markus Armbruster: This reverts commit 7426aa72c36c908a7d0eae3e38568bb0a70de479. The commit goes into a sensible direction, but it violates qdev design assumptions. Symptom: info qtree crashes for all boards including the device (akita, borzoi, spitz, terrier, tosa, axis-dev88). Peter Crosthwaite is working on a fix, but it's not trivial. Revert the flawed patch for now. Signed-off-by: Markus Armbruster arm...@redhat.com Acked-by: Peter Crosthwaite peter.crosthwa...@xilinx.com --- hw/block/nand.c | 7 +++ 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/hw/block/nand.c b/hw/block/nand.c index a871ce0..a0232d1 100644 --- a/hw/block/nand.c +++ b/hw/block/nand.c @@ -21,7 +21,7 @@ # include hw/hw.h # include hw/block/flash.h # include sysemu/blockdev.h -#include hw/qdev.h +# include hw/sysbus.h #include qemu/error-report.h # define NAND_CMD_READ0 0x00 @@ -54,8 +54,7 @@ typedef struct NANDFlashState NANDFlashState; struct NANDFlashState { -DeviceState parent_obj; - +SysBusDevice busdev; Negative on calling it busdev again, that surely has nothing to do with a crash since it's not being used anywhere in this patch. I do not believe in messing with clean reverts such as this one. Any follow-up cleanup should be a separate patch. The easiest way to tell me what cleanup you want could be a patch :) I still have not seen a single backtrace of what is going wrong, only Paolo saying something about adding to main_system_bus in the patch. Clearly that is not in this patch! Where is that happening and why is that so complicated for Peter C. to fix? My commit message should suffice to reproduce: start a qemu for any of the listed boards, run info qtree. But I'm happy to spell it out: $ QEMU_AUDIO_DRV=none ~/work/qemu/bld/arm-softmmu/qemu-system-arm -M akita -nodefaults -display none -monitor stdio -M akita -sd /dev/null -S QEMU 1.7.50 monitor - type 'help' for more information (qemu) info qtree bus: main-system-bus type System dev: scoop, id gpio-in 16 gpio-out 16 irq 0 mmio 1080/1000 dev: spitz-keyboard, id gpio-in 11 gpio-out 7 irq 0 dev: nand, id manufacturer_id = 236 chip_id = 241 drive = null /work/armbru/qemu/hw/core/sysbus.c:209:sysbus_dev_print: Object 0x7f750ab9d910 is not an instance of type sys-bus-device Aborted (core dumped) Backtrace: #0 0x7fffee698c55 in raise () from /lib64/libc.so.6 #1 0x7fffee69a408 in abort () from /lib64/libc.so.6 #2 0x557bef59 in object_dynamic_cast_assert (obj=0x5634d910, typename=typename@entry=0x55943e4d sys-bus-device, file=file@entry= 0x5594a6f0 /work/armbru/qemu/hw/core/sysbus.c, line=line@entry=209, func=func@entry=0x5594a940 __func__.23193 sysbus_dev_print) at /work/armbru/qemu/qom/object.c:484 #3 0x556b3c16 in sysbus_dev_print (mon=0x5625fe00, dev=optimized out, indent=4) at /work/armbru/qemu/hw/core/sysbus.c:209 #4 0x557a2e24 in bus_print_dev (indent=4, dev=0x5634d910, mon= 0x5625fe00, bus=optimized out) at /work/armbru/qemu/qdev-monitor.c:599 #5 qdev_print (indent=4, dev=0x5634d910, mon=0x5625fe00) at /work/armbru/qemu/qdev-monitor.c:621 #6 qbus_print (mon=0x5625fe00, bus=optimized out, indent=2) at /work/armbru/qemu/qdev-monitor.c:636 #7 0x558a8e39 in handle_user_command (mon=mon@entry=0x5625fe00, cmdline=optimized out) at /work/armbru/qemu/monitor.c:4144 #8 0x558a91cb in monitor_command_cb (opaque=0x5625fe00, cmdline=optimized out, readline_opaque=optimized out) at /work/armbru/qemu/monitor.c:4761 #9 0x559276b4 in readline_handle_byte (rs=0x56273c90, ch=optimized out) at /work/armbru/qemu/util/readline.c:371 ---Type return to continue, or q return to quit--- #10 0x558a8f04 in monitor_read (opaque=optimized out, buf=optimized out, size=optimized out) at /work/armbru/qemu/monitor.c:4744 #11 0x557a6eba in qemu_chr_be_write (len=optimized out, buf= 0x7fffcbd0 \r, s=0x5625e400) at /work/armbru/qemu/qemu-char.c:165 #12 fd_chr_read (chan=optimized out, cond=optimized out, opaque= 0x5625e400) at /work/armbru/qemu/qemu-char.c:848 #13 0x776f7a55 in g_main_context_dispatch () from /lib64/libglib-2.0.so.0 #14 0x55775001 in glib_pollfds_poll () at /work/armbru/qemu/main-loop.c:189 #15 os_host_main_loop_wait (timeout=optimized out) at /work/armbru/qemu/main-loop.c:234 #16 main_loop_wait (nonblocking=optimized out) at /work/armbru/qemu/main-loop.c:483
[Qemu-devel] Interrupt handling
According to my understanding of interrupt handling mechanism in QEMU, when some external interrupt comes, related device emulation code (e.g. kbd_update_irq in pckbd.c --- qemu_set_irq ) runs in vcpu thread and io-thread when finds that some interrupt has occured sends signal to vcpu thread to interrupt guest code execution What I am not able to understand is if emulate device related interrupt is raised in vcpu thread and particular architecture's interrupt related registers are set here, why guest cannot process that interrupt at this time? There looks to be some inconsistency in my understanding Can someone help me understand this?
Re: [Qemu-devel] [PATCH] Revert nand: Don't inherit from Sysbus
On 5 February 2014 12:24, Markus Armbruster arm...@redhat.com wrote: As to why it's complicated for Peter to fix, here's what Peter wrote: That series got very big on me with complications. I think near term we just proceed with the revert. Sorry for the delay. I have no reason to second-guess him. Promptly reverting patches that cause regressions when a fix isn't ready is standard operating procedure. We can delay a revert a reasonable amount of time to deliberate what to do, and perhaps find a fix. We did that, and then some: four weeks. We should revert, and try again. Neither harm nor shame in that. I agree in general here, which is why I'm going to apply this patch. While we're talking about regressions: Paolo, do we have a good fix for the PPC boot regression yet or should we revert the patch which caused that? thanks -- PMM
Re: [Qemu-devel] WfW setup and DOS display.sys hanging
[ adding seabios list ] On Di, 2014-02-04 at 20:47 +0100, Kevin Wolf wrote: Hi Gerd, Am 09.01.2014 um 00:20 hat Sebastian geschrieben: Hi, I noticed in newer versions of Qemu (Debian Jessie) a regression causing DISPLAY.SYS from MS-DOS 6.22 to hang the system as soon as loaded. now that you sent a pull request for a SeaBIOS update, I tried what would happen with this one. Sadly, while it does fix my hanging Win 7 boot, DOS still hangs while loading display.sys. [ This is http://www.kraxel.org/cgit/qemu/tag/?id=pull-roms-1 with the 1.7.4 update ] Digged out my prehistoric msdos floppy images. Can confirm the hang. Using default vga (i.e. cirrus). Switching back to lgplvgabios (make -C roms lgplvgabios in qemu src tree) makes the hang go away. Any ideas where to look, or are you going to have a look yourself? When I tried to debug it a while ago, I didn't see anything obvious, but then I didn't invest that much time for it either. perf kvm stat live shows tons of NMIs: VM-EXITSamples Samples% Time% Min Time Max Time Avg time EXCEPTION_NMI 66053899.82%99.40%0us 183us 0.67us ( +- 0.14% ) EXTERNAL_INTERRUPT 1133 0.17% 0.58%0us 43us 2.25us ( +- 4.86% ) IO_INSTRUCTION 18 0.00% 0.01%1us5us 3.39us ( +- 6.50% ) PENDING_INTERRUPT 17 0.00% 0.01%1us 11us 2.15us ( +- 26.24% ) How can one get a trace log of all the kvm tracepoints these days? 'perf list' shows a bunch of kvm trace events, but perf trace -e '*kvm*' doesn't show me anything ... cheers, Gerd I haven't tried out any of the other cases described below. [ keeping full quote for seabios list ] The Windows for Workgroups 3.11 SETUP.EXE file hangs with a cleared screen and the cursor blinking in the top left of the screen. The DOSIDLE.EXE[1] file hangs after printing out some system information. Git-Bisecting returned roms: update vgabios binaries (commit 6eefccc0bb9c34051b1e21880fc3a1c1c8686edd) as the bad commit. I tested the i386-softmmu target on Debian 7.3 (wheezy), x86_64 host and gcc 4.7.2 (Debian 4.7.2-5) without KVM support. [1] Source and binary are available e.g. at http://maribu.home.xs4all.nl/zeurkous/download/mirror/dosidle/ Best Regards, Sebastian
Re: [Qemu-devel] [PATCH V15 01/13] quorum: Create quorum.c, add QuorumSingleAIOCB and QuorumAIOCB.
Le Tuesday 04 Feb 2014 à 13:57:07 (+0100), Kevin Wolf a écrit : Am 03.02.2014 um 22:51 hat Benoît Canet geschrieben: From: Benoît Canet ben...@irqsave.net Signed-off-by: Benoit Canet ben...@irqsave.net Reviewed-by: Max Reitz mre...@redhat.com --- block/Makefile.objs | 1 + block/quorum.c | 54 + 2 files changed, 55 insertions(+) create mode 100644 block/quorum.c diff --git a/block/Makefile.objs b/block/Makefile.objs index 4e8c91e..a2650b9 100644 --- a/block/Makefile.objs +++ b/block/Makefile.objs @@ -3,6 +3,7 @@ block-obj-y += qcow2.o qcow2-refcount.o qcow2-cluster.o qcow2-snapshot.o qcow2-c block-obj-y += qed.o qed-gencb.o qed-l2-cache.o qed-table.o qed-cluster.o block-obj-y += qed-check.o block-obj-$(CONFIG_VHDX) += vhdx.o vhdx-endian.o vhdx-log.o +block-obj-y += quorum.o block-obj-y += parallels.o blkdebug.o blkverify.o block-obj-y += snapshot.o qapi.o block-obj-$(CONFIG_WIN32) += raw-win32.o win32-aio.o diff --git a/block/quorum.c b/block/quorum.c new file mode 100644 index 000..17695d6 --- /dev/null +++ b/block/quorum.c @@ -0,0 +1,54 @@ +/* + * Quorum Block filter + * + * Copyright (C) 2012-2014 Nodalink, EURL. + * + * Author: + * Benoît Canet benoit.ca...@irqsave.net + * + * Based on the design and code of blkverify.c (Copyright (C) 2010 IBM, Corp) + * and blkmirror.c (Copyright (C) 2011 Red Hat, Inc). I think you were planning to respin anyway, so I'll practice my nitpicking: The file is called mirror.c, not blkmirror.c. It's a reference to blkmirror.c by Marcello Tosati. A patch that was never merged. https://www.google.fr/url?sa=trct=jq=esrc=ssource=webcd=1cad=rjaved=0CCkQFjAAurl=https%3A%2F%2Flists.gnu.org%2Farchive%2Fhtml%2Fqemu-devel%2F2011-05%2Fmsg02521.htmlei=FzzyUuOBEeSg0QX9jYCgCgusg=AFQjCNG6W5qbmITacObTAD4ShOZlxky2bAbvm=bv.60799247,d.d2k + * + * This work is licensed under the terms of the GNU GPL, version 2 or later. + * See the COPYING file in the top-level directory. + */ + +#include block/block_int.h + +typedef struct QuorumAIOCB QuorumAIOCB; + +/* Quorum will create one instance of the following structure per operation it + * performs on its children. + * So for each read/write operation coming from the upper layer there will be + * $children_count QuorumSingleAIOCB. + */ +typedef struct QuorumSingleAIOCB { +BlockDriverAIOCB *aiocb; So this isn't a real AIOCB, but it merely points to one. Perhaps something like QuorumChildRequest would be a more precise name? +QEMUIOVector qiov; +uint8_t *buf; The combination of a linear buffer and qiov is unusual. It looks like there may be a reason for it (otherwise qemu_iovec_clone() wouldn't exist), but I don't understand it yet at this point. Could hint at a lack of documentation. I might back come to this later in the patch series. +int ret; +QuorumAIOCB *parent; +} QuorumSingleAIOCB; + +/* Quorum will use the following structure to track progress of each read/write + * operation received by the upper layer. + * This structure hold pointers to the QuorumSingleAIOCB structures instances + * used to do operations on each children and track overall progress. + */ +struct QuorumAIOCB { +BlockDriverAIOCB common; + +/* Request metadata */ +uint64_t sector_num; +int nb_sectors; + +QEMUIOVector *qiov; /* calling IOV */ + +QuorumSingleAIOCB *aios;/* individual AIOs */ +int count; /* number of completed AIOCB */ +int success_count; /* number of successfully completed AIOCB */ +bool *finished; /* completion signal for cancel */ + +bool is_read; +int vote_ret; +}; Kevin
Re: [Qemu-devel] [PATCH] Remove trailing space from error message
On 02/05/2014 04:53 AM, Orit Wasserman wrote: Signed-off-by: Orit Wasserman owass...@redhat.com --- migration.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) Reviewed-by: Eric Blake ebl...@redhat.com diff --git a/migration.c b/migration.c index 25add6f..cc18f6c 100644 --- a/migration.c +++ b/migration.c @@ -482,7 +482,7 @@ void qmp_migrate_set_cache_size(int64_t value, Error **errp) /* Cache should not be larger than guest ram size */ if (value ram_bytes_total()) { error_set(errp, QERR_INVALID_PARAMETER_VALUE, cache size, - exceeds guest ram size ); + exceeds guest ram size); return; } -- Eric Blake eblake redhat com+1-919-301-3266 Libvirt virtualization library http://libvirt.org signature.asc Description: OpenPGP digital signature
Re: [Qemu-devel] [PATCH V2] Add Enhanced Three-Speed Ethernet Controller (eTSEC)
On 12/10/2013 06:20 PM, Alexander Graf wrote: On 10.12.2013, at 18:15, Fabien Chouteau chout...@adacore.com wrote: Unfortunately I won't have time to fix before January. Hello Alex, I fixed the compiler errors and I will send version 3 in few minutes. That works for me. While at it, please also add a patch to enable -net usage with etsec. -net nic,model=ETSEC,vlan=0 already works. Regards,
[Qemu-devel] [PATCH v6] vl.c: Output error on invalid machine type
From: Miroslav Rezanina mreza...@redhat.com Output error message using qemu's error_report() function when user provides the invalid machine type on the command line. This also saves time to find what issue is when you downgrade from one version of qemu to another that doesn't support required machine type yet (the version user downgraded to have to have this patch applied too, of course). Signed-off-by: Miroslav Rezanina mreza...@redhat.com --- v6: - print help instead of list supported machines on error vl.c | 18 -- 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/vl.c b/vl.c index 383be1b..3297c0a 100644 --- a/vl.c +++ b/vl.c @@ -2600,13 +2600,19 @@ static QEMUMachine *machine_parse(const char *name) if (machine) { return machine; } -printf(Supported machines are:\n); -for (m = first_machine; m != NULL; m = m-next) { -if (m-alias) { -printf(%-20s %s (alias of %s)\n, m-alias, m-desc, m-name); + +if (name !is_help_option(name)) { +error_report(Unsupported machine type); +printf(\nUse '-M help' to list supported machines!\n); +} else { +printf(Supported machines are:\n); +for (m = first_machine; m != NULL; m = m-next) { +if (m-alias) { +printf(%-20s %s (alias of %s)\n, m-alias, m-desc, m-name); +} +printf(%-20s %s%s\n, m-name, m-desc, + m-is_default ? (default) : ); } -printf(%-20s %s%s\n, m-name, m-desc, - m-is_default ? (default) : ); } exit(!name || !is_help_option(name)); } -- 1.8.5.3
Re: [Qemu-devel] [PATCH] tests/Makefile: Run qom-test for every architecture
Am 04.02.2014 10:16, schrieb Markus Armbruster: Peter Maydell peter.mayd...@linaro.org writes: Rather than requiring every new architecture to remember to add a line to the Makefile to say that qom-test will work on it, autogenerate the list of supported architectures by looking at the files in default-configs (as configure does), and add qom-test to the test list for all of them automatically. Signed-off-by: Peter Maydell peter.mayd...@linaro.org --- Together with Markus' patch for running the test for all known machines for the architecture, this will avoid the problem of coverage being missed because of forgetting to update a whitelist. I applied this on top of Andreas's rebase of my patch rebased to current master. Applies cleanly and works fine. Reviewed-by: Markus Armbruster arm...@redhat.com Thanks for bringing this one up on my radar again, applied to qom-next (won't do good without Markus' patch but no harm either): https://github.com/afaerber/qemu-cpu/commits/qom-next Andreas -- SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
Re: [Qemu-devel] [PATCH v3 4/9] ide: Drop redundant IDEState member bs
[Note cc: Stefano] Kevin Wolf kw...@redhat.com writes: Am 30.01.2014 um 13:16 hat Markus Armbruster geschrieben: It's a copy of dev-conf.bs. The copy was needed for non-qdevified controllers, which lacked dev. Note how pci_piix3_xen_ide_unplug() cleared the copy. We'll get back to that in the next few commits. Signed-off-by: Markus Armbruster arm...@redhat.com So this pci_piix3_xen_ide_unplug() is what happens here: --- a/hw/ide/piix.c +++ b/hw/ide/piix.c @@ -169,12 +169,9 @@ static int pci_piix_ide_initfn(PCIDevice *dev) static int pci_piix3_xen_ide_unplug(DeviceState *dev) { -PCIIDEState *pci_ide; DriveInfo *di; int i = 0; -pci_ide = PCI_IDE(dev); - for (; i 3; i++) { di = drive_get_by_index(IF_IDE, i); if (di != NULL !di-media_cd) { @@ -183,7 +180,6 @@ static int pci_piix3_xen_ide_unplug(DeviceState *dev) bdrv_detach_dev(di-bdrv, ds); } bdrv_close(di-bdrv); -pci_ide-bus[di-bus].ifs[di-unit].bs = NULL; drive_put_ref(di); } } Probably I'm just missing the obvious, but it seems to me that the copy was cleared here, while the original was left around. This was no problem because the original was unused anyway after device initialisation. Now that the copy doesn't exist any more, we can't clear it, obviously, but why don't we have to clear the original? Won't we still run the device is attached code branches even though the device is really unplugged? It's been a while since I wrote this. Almost 14 months, in fact. No other IDE controller implements DeviceClass method unplug(). I can't remember why the normal code to detach the backend (release_drive()) doesn't do here. Stefano, can you help?
[Qemu-devel] [PATCH] qdev: Fix qdev_try_create() for bus-less devices
Commit 7426aa72c36c908a7d0eae3e38568bb0a70de479 (nand: Don't inherit from Sysbus) made NAND a device rather than SysBus device. This led to all boards using the device (akita, borzoi, spitz, terrier, tosa, axis-dev88) crashing on info qtree. The difference to the bus-less ARMCPU is that the device was still being created by qdev_create() rather than object_new(), which makes assumptions about a NULL BusState being the SysBus. Fix that. A longer-term solution will be to stop using qdev_create(). Reported-by: Markus Armbruster arm...@redhat.com Cc: Peter Crosthwaite peter.crosthwa...@xilinx.com Signed-off-by: Andreas Färber afaer...@suse.de --- hw/core/qdev.c | 14 ++ 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/hw/core/qdev.c b/hw/core/qdev.c index 82a9123..14c8765 100644 --- a/hw/core/qdev.c +++ b/hw/core/qdev.c @@ -131,21 +131,27 @@ DeviceState *qdev_create(BusState *bus, const char *name) DeviceState *qdev_try_create(BusState *bus, const char *type) { DeviceState *dev; +ObjectClass *oc; +DeviceClass *dc; -if (object_class_by_name(type) == NULL) { +oc = object_class_by_name(type); +if (oc == NULL) { return NULL; } +dc = DEVICE_CLASS(oc); dev = DEVICE(object_new(type)); if (!dev) { return NULL; } -if (!bus) { +if (!bus dc-bus_type strcmp(dc-bus_type, System) == 0) { bus = sysbus_get_default(); } -qdev_set_parent_bus(dev, bus); -object_unref(OBJECT(dev)); +if (bus != NULL) { +qdev_set_parent_bus(dev, bus); +object_unref(OBJECT(dev)); +} return dev; } -- 1.8.4.5
Re: [Qemu-devel] [PATCH V15 03/13] quorum: Add quorum_aio_writev and its dependencies.
Le Tuesday 04 Feb 2014 à 14:57:22 (+0100), Kevin Wolf a écrit : Am 03.02.2014 um 22:51 hat Benoît Canet geschrieben: From: Benoît Canet ben...@irqsave.net Signed-off-by: Benoit Canet ben...@irqsave.net --- block/quorum.c | 104 + 1 file changed, 104 insertions(+) Starting with writes before the driver can even open an image is a weird order to do things in. It also doesn't make the review any easier when you don't know how things are initialised. I have done it in this way for better git bisectability: if the driver cannot open the quorum the commit is a preparation work that should be excluded of git bisect commit range. For the write before read order it's this way because quorum writes are simpler. Best regards Benoît diff --git a/block/quorum.c b/block/quorum.c index 157efdf..81bffdd 100644 --- a/block/quorum.c +++ b/block/quorum.c @@ -64,11 +64,115 @@ struct QuorumAIOCB { int vote_ret; }; +static void quorum_aio_cancel(BlockDriverAIOCB *blockacb) +{ +QuorumAIOCB *acb = container_of(blockacb, QuorumAIOCB, common); +BDRVQuorumState *s = acb-bqs; +int i; + +/* cancel all callback */ callbacks +for (i = 0; i s-total; i++) { +bdrv_aio_cancel(acb-aios[i].aiocb); +} +} Don't you want to free acb and similar cleanup? + +static AIOCBInfo quorum_aiocb_info = { +.aiocb_size = sizeof(QuorumAIOCB), +.cancel = quorum_aio_cancel, +}; + +static void quorum_aio_finalize(QuorumAIOCB *acb) +{ +BDRVQuorumState *s = acb-bqs; block/quorum.c: In function 'quorum_aio_finalize': block/quorum.c:86:22: error: unused variable 's' [-Werror=unused-variable] +int ret = 0; + +acb-common.cb(acb-common.opaque, ret); +if (acb-finished) { +*acb-finished = true; +} +g_free(acb-aios); +qemu_aio_release(acb); +} + +static QuorumAIOCB *quorum_aio_get(BDRVQuorumState *s, + BlockDriverState *bs, + QEMUIOVector *qiov, + uint64_t sector_num, + int nb_sectors, + BlockDriverCompletionFunc *cb, + void *opaque) +{ +QuorumAIOCB *acb = qemu_aio_get(quorum_aiocb_info, bs, cb, opaque); +int i; + +acb-bqs = s; Noticed it only here, but it's really in patch 2 (and should be in patch 1): What is acb-bqs good for? Isn't it always the same as acb-common.bs-opaque? +acb-sector_num = sector_num; +acb-nb_sectors = nb_sectors; +acb-qiov = qiov; +acb-aios = g_new0(QuorumSingleAIOCB, s-total); +acb-count = 0; +acb-success_count = 0; +acb-finished = NULL; +acb-is_read = false; +acb-vote_ret = 0; + +for (i = 0; i s-total; i++) { +acb-aios[i].buf = NULL; +acb-aios[i].ret = 0; +acb-aios[i].parent = acb; +} + +return acb; +} Kevin
Re: [Qemu-devel] [PATCH] Revert nand: Don't inherit from Sysbus
On 5 February 2014 13:00, Peter Maydell peter.mayd...@linaro.org wrote: On 5 February 2014 12:24, Markus Armbruster arm...@redhat.com wrote: As to why it's complicated for Peter to fix, here's what Peter wrote: That series got very big on me with complications. I think near term we just proceed with the revert. Sorry for the delay. I have no reason to second-guess him. Promptly reverting patches that cause regressions when a fix isn't ready is standard operating procedure. We can delay a revert a reasonable amount of time to deliberate what to do, and perhaps find a fix. We did that, and then some: four weeks. We should revert, and try again. Neither harm nor shame in that. I agree in general here, which is why I'm going to apply this patch. Following conversation on IRC and Andreas' recent patch: given that the current state of affairs (ie 'info qtest crashes') has been in master for six months, there doesn't seem to be a critically urgent need to act immediately, so I'm going to give it a few days to check that we have a consensus on the best way to deal with this. thanks -- PMM
[Qemu-devel] [PATCH] nand: Don't use qdev_create() in nand_init()
Commit 7426aa72c36c908a7d0eae3e38568bb0a70de479 (nand: Don't inherit from Sysbus) changed the parent type of TYPE_NAND but continued to use qdev_create(), which handled a NULL BusState as SysBus. Use object_new() instead, and reuse the TYPE_NAND define while at it. Reported-by: Markus Armbruster arm...@redhat.com Cc: Peter Crosthwaite peter.crosthwa...@xilinx.com Signed-off-by: Andreas Färber afaer...@suse.de --- hw/block/nand.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/block/nand.c b/hw/block/nand.c index a871ce0..6d7c804 100644 --- a/hw/block/nand.c +++ b/hw/block/nand.c @@ -632,7 +632,7 @@ DeviceState *nand_init(BlockDriverState *bdrv, int manf_id, int chip_id) if (nand_flash_ids[chip_id].size == 0) { hw_error(%s: Unsupported NAND chip ID.\n, __FUNCTION__); } -dev = qdev_create(NULL, nand); +dev = DEVICE(object_new(TYPE_NAND)); qdev_prop_set_uint8(dev, manufacturer_id, manf_id); qdev_prop_set_uint8(dev, chip_id, chip_id); if (bdrv) { -- 1.8.4.5
Re: [Qemu-devel] [PATCH qom-cpu 00/16 v10] target-i386: convert CPU features into properties
On Sun, 15 Dec 2013 23:50:47 +0100 Andreas Färber afaer...@suse.de wrote: Am 27.11.2013 23:28, schrieb Igor Mammedov: Igor Mammedov (16): target-i386: cleanup 'foo' feature handling' target-i386: cleanup 'foo=val' feature handling Thanks, I've queued these on qom-cpu-next: https://github.com/afaerber/qemu-cpu/commits/qom-cpu-next target-i386: cpu: convert 'level' to static property target-i386: cpu: convert 'xlevel' to static property target-i386: cpu: convert 'family' to static property target-i386: cpu: convert 'model' to static property target-i386: cpu: convert 'stepping' to static property target-i386: cpu: convert 'vendor' to static property target-i386: cpu: convert 'model-id' to static property target-i386: cpu: convert 'tsc-frequency' to static property But I still don't see the utility of this conversion after all the discussions we've had... :( It seems there is movement to make DEVICE self describing for purpose of QAPI schema introspection, where static properties would be used (dynamic ones are not suitable for this purpose) The below patches seem to only operate on CPUID bits, which get added as properties in the following patch. target-i386: set [+-]feature using static properties qdev: introduce qdev_prop_find_bit() target-i386: use static properties in check_features_against_host() to print CPUID feature names target-i386: use static properties to list CPUID features I am reading too many occurrences of static properties above that should IMO just be properties. You got permission to use a name-based scheme to iterate over feat-* properties, so why are you still iterating over static properties with a helper searching for offsets rather than QOM properties with feat- prefix? Either we need that scheme for Ok, I'll use feat- prefix, there is not real need for iterating over array when listing properties. automated processing as I understood you, then we should be consequent in using it, or we don't. And I would prefer to keep these mappings in x86 code rather than messing in generic device infrastructure and iterating over *all* properties in your qdev_prop_find_bit() and making generally available new QDEV_* macros QDEV_PROP_FOREACH() and QDEV_CLASS_FOREACH(). Unfortunatly we still need mapping from bit position to name for kvm_check_features_against_host() So there is 2 options: 1st: keep iterating over array local to x86 2nd: drop name reporting in kvm_check_features_against_host() and report bit positions. which one would you preffer? The utility of the feat- prefix AIUI is to go from +foo to feat-foo=on; going from bit position to name should work just as before and could even be consolidated into a single array by using dynamic properties. I can't get you, Could you elaborate more on consolidated into a single array by using dynamic properties. Am I the only one that finds the approach backwards? o.O Regards, Andreas target-i386: remove unused *_feature_name arrays target-i386: cpu: fix invalid use of error_is_set(errp) if errp == NULL -- SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg -- Regards, Igor
Re: [Qemu-devel] [PATCH] nand: Don't use qdev_create() in nand_init()
On Wed, 5 Feb 2014 15:30:53 +0100 Andreas Färber afaer...@suse.de wrote: Commit 7426aa72c36c908a7d0eae3e38568bb0a70de479 (nand: Don't inherit from Sysbus) changed the parent type of TYPE_NAND but continued to use qdev_create(), which handled a NULL BusState as SysBus. Use object_new() instead, and reuse the TYPE_NAND define while at it. Reported-by: Markus Armbruster arm...@redhat.com Cc: Peter Crosthwaite peter.crosthwa...@xilinx.com Signed-off-by: Andreas Färber afaer...@suse.de --- hw/block/nand.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/block/nand.c b/hw/block/nand.c index a871ce0..6d7c804 100644 --- a/hw/block/nand.c +++ b/hw/block/nand.c @@ -632,7 +632,7 @@ DeviceState *nand_init(BlockDriverState *bdrv, int manf_id, int chip_id) if (nand_flash_ids[chip_id].size == 0) { hw_error(%s: Unsupported NAND chip ID.\n, __FUNCTION__); } -dev = qdev_create(NULL, nand); +dev = DEVICE(object_new(TYPE_NAND)); qdev_prop_set_uint8(dev, manufacturer_id, manf_id); qdev_prop_set_uint8(dev, chip_id, chip_id); if (bdrv) { -- 1.8.4.5 Reviewed-By: Igor Mammedov imamm...@redhat.com -- Regards, Igor
Re: [Qemu-devel] [PATCH] Revert nand: Don't inherit from Sysbus
Peter Maydell peter.mayd...@linaro.org writes: On 5 February 2014 13:00, Peter Maydell peter.mayd...@linaro.org wrote: On 5 February 2014 12:24, Markus Armbruster arm...@redhat.com wrote: As to why it's complicated for Peter to fix, here's what Peter wrote: That series got very big on me with complications. I think near term we just proceed with the revert. Sorry for the delay. I have no reason to second-guess him. Promptly reverting patches that cause regressions when a fix isn't ready is standard operating procedure. We can delay a revert a reasonable amount of time to deliberate what to do, and perhaps find a fix. We did that, and then some: four weeks. We should revert, and try again. Neither harm nor shame in that. I agree in general here, which is why I'm going to apply this patch. Following conversation on IRC and Andreas' recent patch: given that the current state of affairs (ie 'info qtest crashes') has been in master for six months, there doesn't seem to be a critically urgent need to act immediately, so I'm going to give it a few days to check that we have a consensus on the best way to deal with this. Waiting a few more days for a fix is fine with me.
Re: [Qemu-devel] [PATCH] qtest: don't report signals if qtest driver enabled
Am 04.02.2014 19:06, schrieb Michael S. Tsirkin: qtest driver always uses signals to kill qemu no need to report it, whatever the accelerator state. Add API to detect qtest driver, and suppress reporting signals in this case. Reported-by: Andreas Färber afaer...@suse.de Signed-off-by: Michael S. Tsirkin m...@redhat.com Tested-by: Andreas Färber afaer...@suse.de We could do some bikeshedding about better names for qtest_driver(), but I'm happy to learn that it was just noise and not a real issue. I'll queue a copy for my qom-test work, but through whose queue should this best go? PMM directly? Thanks, Andreas -- SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
Re: [Qemu-devel] [PATCH] qtest: don't report signals if qtest driver enabled
On Wed, Feb 05, 2014 at 04:05:55PM +0100, Andreas Färber wrote: Am 04.02.2014 19:06, schrieb Michael S. Tsirkin: qtest driver always uses signals to kill qemu no need to report it, whatever the accelerator state. Add API to detect qtest driver, and suppress reporting signals in this case. Reported-by: Andreas Färber afaer...@suse.de Signed-off-by: Michael S. Tsirkin m...@redhat.com Tested-by: Andreas Färber afaer...@suse.de We could do some bikeshedding about better names for qtest_driver(), but I'm happy to learn that it was just noise and not a real issue. I'll queue a copy for my qom-test work, but through whose queue should this best go? PMM directly? Thanks, Andreas It affects acpi tests so for now I have it on my queue. -- SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
Re: [Qemu-devel] [PATCH V15 06/13] quorum: Add quorum mechanism.
Le Tuesday 04 Feb 2014 à 16:40:12 (+0100), Kevin Wolf a écrit : Am 03.02.2014 um 22:51 hat Benoît Canet geschrieben: From: Benoît Canet ben...@irqsave.net Use gnutls's SHA-256 to compare versions. Signed-off-by: Benoit Canet ben...@irqsave.net --- block/Makefile.objs | 2 +- block/quorum.c| 386 +- configure | 36 + docs/qmp/qmp-events.txt | 33 include/monitor/monitor.h | 2 + monitor.c | 2 + 6 files changed, 458 insertions(+), 3 deletions(-) diff --git a/block/Makefile.objs b/block/Makefile.objs index a2650b9..4ca9d43 100644 --- a/block/Makefile.objs +++ b/block/Makefile.objs @@ -3,7 +3,7 @@ block-obj-y += qcow2.o qcow2-refcount.o qcow2-cluster.o qcow2-snapshot.o qcow2-c block-obj-y += qed.o qed-gencb.o qed-l2-cache.o qed-table.o qed-cluster.o block-obj-y += qed-check.o block-obj-$(CONFIG_VHDX) += vhdx.o vhdx-endian.o vhdx-log.o -block-obj-y += quorum.o +block-obj-$(CONFIG_QUORUM) += quorum.o block-obj-y += parallels.o blkdebug.o blkverify.o block-obj-y += snapshot.o qapi.o block-obj-$(CONFIG_WIN32) += raw-win32.o win32-aio.o diff --git a/block/quorum.c b/block/quorum.c index 699b512..837d261 100644 --- a/block/quorum.c +++ b/block/quorum.c @@ -13,7 +13,43 @@ * See the COPYING file in the top-level directory. */ +#include gnutls/gnutls.h +#include gnutls/crypto.h #include block/block_int.h +#include qapi/qmp/qjson.h + +#define HASH_LENGTH 32 + +/* This union holds a vote hash value */ +typedef union QuorumVoteValue { +char h[HASH_LENGTH]; /* SHA-256 hash */ +int64_t l; /* simpler 64 bits hash */ +} QuorumVoteValue; + +/* A vote item */ +typedef struct QuorumVoteItem { +int index; +QLIST_ENTRY(QuorumVoteItem) next; +} QuorumVoteItem; + +/* this structure is a vote version. A version is the set of votes sharing the + * same vote value. + * The set of votes will be tracked with the items field and its cardinality is + * vote_count. + */ +typedef struct QuorumVoteVersion { +QuorumVoteValue value; +int index; +int vote_count; +QLIST_HEAD(, QuorumVoteItem) items; +QLIST_ENTRY(QuorumVoteVersion) next; +} QuorumVoteVersion; + +/* this structure holds a group of vote versions together */ +typedef struct QuorumVotes { +QLIST_HEAD(, QuorumVoteVersion) vote_list; +int (*compare)(QuorumVoteValue *a, QuorumVoteValue *b); +} QuorumVotes; /* the following structure holds the state of one quorum instance */ typedef struct { @@ -60,10 +96,14 @@ struct QuorumAIOCB { int success_count; /* number of successfully completed AIOCB */ bool *finished; /* completion signal for cancel */ +QuorumVotes votes; + bool is_read; int vote_ret; }; +static void quorum_vote(QuorumAIOCB *acb); + static void quorum_aio_cancel(BlockDriverAIOCB *blockacb) { QuorumAIOCB *acb = container_of(blockacb, QuorumAIOCB, common); @@ -81,10 +121,12 @@ static AIOCBInfo quorum_aiocb_info = { .cancel = quorum_aio_cancel, }; +static int quorum_vote_error(QuorumAIOCB *acb); + What's the reason for putting the forward declaration here? This is neither directly before the first user nor at the top. In fact, the next occurence of quorum_vote_error() is the implementation of the function, so the forward declaration is completely unnecessary. static void quorum_aio_finalize(QuorumAIOCB *acb) { BDRVQuorumState *s = acb-bqs; -int ret = 0; +int i, ret = 0; for (i = 0; i s-total; i++) { qemu_vfree(acb-aios[i].buf); @@ -92,6 +134,10 @@ static void quorum_aio_finalize(QuorumAIOCB *acb) acb-aios[i].ret = 0; } +if (acb-vote_ret) { +ret = acb-vote_ret; +} + acb-common.cb(acb-common.opaque, ret); if (acb-finished) { *acb-finished = true; @@ -103,6 +149,27 @@ static void quorum_aio_finalize(QuorumAIOCB *acb) qemu_aio_release(acb); } +static int quorum_sha256_compare(QuorumVoteValue *a, QuorumVoteValue *b) +{ +return memcmp(a-h, b-h, HASH_LENGTH); +} + +static int quorum_64bits_compare(QuorumVoteValue *a, QuorumVoteValue *b) +{ +int64_t i = a-l; +int64_t j = b-l; + +if (i j) { +return -1; +} + +if (i j) { +return 1; +} + +return 0; +} The usual way to implement this is 'return a-l - b-l;', because if you expect memcmp() to return a valid value for the compare function you can't assume that it's normalised to -1/0/1 anyway. As you only ever use the result as a bool, you could alternatively even declare the function as such and do 'return a-l != b-l;'.
[Qemu-devel] [PATCH v6 0/9] Refactor PCI/SHPC/PCIE hotplug to use a more generic hotplug API
changes since v5: - fixed typos Eric pointed to - fix conflict of [5/9] with new patch acpi-build: append description for non-hotplug - rebased on top of todays PCI tree changes since v4: - rebased on top of PCI tree - added wrapper to set hotplug-device property changes since v3: - fixup/add comments as reqused by Peter Crosthwaite - use error_abort to reduce error handling verbosity - fix tests/test-qdev-global-props build failure on make check - rebase on top of current master:133fe7743 (with interface fixes) changes since v2: * s/hotplugable/hotpluggable/ * move hotplug check to an earlier patch: qdev: add hotpluggable property to Device -- Refactor PCI specific hotplug API to a more generic/reusable one. Model it after SCSI-BUS like hotplug API replacing single hotplug callback with hotplug/hot_unplug pair of callbacks as suggested by Paolo. Difference between SCSI-BUS and this approach is that the former is BUS centric while the latter is device centred. Which is evolved from the fact that hotplug callbacks used by ACPI/SHPC/PCIE are implemented by devices rather than by bus and bus serves only as a proxy to forward event to hotplug device. Memory hotplug also exposes tha same usage pattern hence an attempt to generalize hotplug API. Refactoring also simplifies wiring of a hotplug device with a bus, all it needs is to set hotplug-device link on bus, which would potentially allow to do it from configuration file, there is not need to setup hotplug device callbacks on bus synce it can get them via HOTPLUG_DEVICE API of hotplug-device target. In addition device centred hotplug API may be used by bus-less hotplug implementations as well if it's decided to use linkfoo... instead of bus. Patches 8-11 are should be merged as one and are split only for simplifying review (they compile fine but PCI hotplug is broken until the last patch is applyed). git tree for testing: https://github.com/imammedo/qemu/commits/hotplug_dev_inf_v6 tested only ACPI and PCIE hotplug, since SHPC is not functional, tested it under debugger that hotplhug event reaches handler and corresponding interrupt is emited. Igor Mammedov (9): define hotplug interface qdev: add to BusState hotplug-handler link qdev: add hotpluggable property to Device hw/acpi: move typeinfo to the file end qdev:pci: refactor PCIDevice to use generic hotpluggable property acpi/piix4pm: convert ACPI PCI hotplug to use hotplug-handler API pci/shpc: convert SHPC hotplug to use hotplug-handler API pci/pcie: convert PCIE hotplug to use hotplug-handler API hw/pci: switch to a generic hotplug handling for PCIDevice hw/acpi/pcihp.c| 46 ++ hw/acpi/piix4.c| 128 +--- hw/core/Makefile.objs |1 + hw/core/hotplug.c | 48 +++ hw/core/qdev.c | 50 ++- hw/display/cirrus_vga.c|2 +- hw/display/qxl.c |2 +- hw/display/vga-pci.c |2 +- hw/display/vmware_vga.c|2 +- hw/i386/acpi-build.c |4 +- hw/ide/piix.c |4 +- hw/isa/piix4.c |2 +- hw/pci-bridge/pci_bridge_dev.c |9 +++ hw/pci-host/piix.c |6 +- hw/pci/pci.c | 40 + hw/pci/pcie.c | 65 hw/pci/pcie_port.c |8 +++ hw/pci/shpc.c | 124 --- hw/usb/hcd-ehci-pci.c |2 +- hw/usb/hcd-ohci.c |2 +- hw/usb/hcd-uhci.c |2 +- hw/usb/hcd-xhci.c |2 +- include/hw/acpi/acpi.h |1 + include/hw/acpi/pcihp.h| 10 ++- include/hw/hotplug.h | 78 include/hw/pci/pci.h | 13 include/hw/pci/pci_bus.h |2 - include/hw/pci/pcie.h |5 ++ include/hw/pci/shpc.h |8 +++ include/hw/qdev-core.h | 15 + tests/Makefile |2 +- 31 files changed, 463 insertions(+), 222 deletions(-) create mode 100644 hw/core/hotplug.c create mode 100644 include/hw/hotplug.h
[Qemu-devel] [PATCH v6 2/9] qdev: add to BusState hotplug-handler link
It will allow to reuse field with different BUSes, reducing code duplication. Field is intended for replacing 'hotplug_qdev' field in PCIBus and also will allow to avoid adding equivalent field to DimmBus with possiblitity to refactor other BUSes to use it instead of custom field. In addition once all users of allow_hotplug field are converted to new API, link could replace allow_hotplug field in qdev hotplug code. Signed-off-by: Igor Mammedov imamm...@redhat.com --- hw/core/qdev.c |4 include/hw/qdev-core.h | 12 2 files changed, 16 insertions(+), 0 deletions(-) diff --git a/hw/core/qdev.c b/hw/core/qdev.c index 82a9123..c9f0c33 100644 --- a/hw/core/qdev.c +++ b/hw/core/qdev.c @@ -32,6 +32,7 @@ #include qapi/visitor.h #include qapi/qmp/qjson.h #include monitor/monitor.h +#include hw/hotplug.h int qdev_hotplug = 0; static bool qdev_hot_added = false; @@ -870,6 +871,9 @@ static void qbus_initfn(Object *obj) BusState *bus = BUS(obj); QTAILQ_INIT(bus-children); +object_property_add_link(obj, QDEV_HOTPLUG_HANDLER_PROPERTY, + TYPE_HOTPLUG_HANDLER, + (Object **)bus-hotplug_handler, NULL); } static char *default_bus_get_fw_dev_path(DeviceState *dev) diff --git a/include/hw/qdev-core.h b/include/hw/qdev-core.h index 2c4f140..41ec533 100644 --- a/include/hw/qdev-core.h +++ b/include/hw/qdev-core.h @@ -8,6 +8,7 @@ #include qom/object.h #include hw/irq.h #include qapi/error.h +#include hw/hotplug.h enum { DEV_NVECTORS_UNSPECIFIED = -1, @@ -180,14 +181,18 @@ typedef struct BusChild { QTAILQ_ENTRY(BusChild) sibling; } BusChild; +#define QDEV_HOTPLUG_HANDLER_PROPERTY hotplug-handler + /** * BusState: + * @hotplug_device: link to a hotplug device associated with bus. */ struct BusState { Object obj; DeviceState *parent; const char *name; int allow_hotplug; +HotplugHandler *hotplug_handler; int max_index; QTAILQ_HEAD(ChildrenHead, BusChild) children; QLIST_ENTRY(BusState) sibling; @@ -321,4 +326,11 @@ extern int qdev_hotplug; char *qdev_get_dev_path(DeviceState *dev); +static inline void qbus_set_hotplug_handler(BusState *bus, DeviceState *handler, +Error **errp) +{ +object_property_set_link(OBJECT(bus), OBJECT(handler), + QDEV_HOTPLUG_HANDLER_PROPERTY, errp); +bus-allow_hotplug = 1; +} #endif -- 1.7.1
[Qemu-devel] [PATCH v6 3/9] qdev: add hotpluggable property to Device
Currently it's possible to make PCIDevice not hotpluggable by using no_hotplug field of PCIDeviceClass. However it limits this only to PCI devices and prevents from generalizing hotplug code. So add similar field to DeviceClass so it could be reused with other Devices and would allow to replace PCI specific hotplug callbacks with generic implementation. Following patches will replace PCIDeviceClass.no_hotplug with this new property. In addition expose field as hotpluggable readonly property, to make it possible to read its value via QOM interface. Make DeviceClass hotpluggable by default as it was assumed before. Signed-off-by: Igor Mammedov imamm...@redhat.com --- v6: * s/hoplugable/hotpluggable/ v5: * drop 'boolean' from doc comment of hotpluggable field v4: * s/hotplugable/hotpluggable/ v3: * make DeviceClass hotpluggable by default Since PCIDevice still uses internal no_hotlpug checks it shouldn't reggress. And follow up patch that converts PCIDevices to use hotpluggable property will take care about not hotpluggable PCI devices explicitly setting hotpluggable to false in their class_init(). * move generic hotplug checks from 7/11 qdev:pci: refactor PCIDevice to use generic hotplugable property to this patch --- hw/core/qdev.c | 29 + include/hw/qdev-core.h |3 +++ 2 files changed, 32 insertions(+), 0 deletions(-) diff --git a/hw/core/qdev.c b/hw/core/qdev.c index c9f0c33..5c864db 100644 --- a/hw/core/qdev.c +++ b/hw/core/qdev.c @@ -215,6 +215,12 @@ void qdev_unplug(DeviceState *dev, Error **errp) } assert(dc-unplug != NULL); +if (!dc-hotpluggable) { +error_set(errp, QERR_DEVICE_NO_HOTPLUG, + object_get_typename(OBJECT(dev))); +return; +} + qdev_hot_removed = true; if (dc-unplug(dev) 0) { @@ -694,6 +700,11 @@ static void device_set_realized(Object *obj, bool value, Error **err) DeviceClass *dc = DEVICE_GET_CLASS(dev); Error *local_err = NULL; +if (dev-hotplugged !dc-hotpluggable) { +error_set(err, QERR_DEVICE_NO_HOTPLUG, object_get_typename(obj)); +return; +} + if (value !dev-realized) { if (!obj-parent local_err == NULL) { static int unattached_count; @@ -734,6 +745,14 @@ static void device_set_realized(Object *obj, bool value, Error **err) dev-realized = value; } +static bool device_get_hotpluggable(Object *obj, Error **err) +{ +DeviceClass *dc = DEVICE_GET_CLASS(obj); +DeviceState *dev = DEVICE(obj); + +return dc-hotpluggable dev-parent_bus-allow_hotplug; +} + static void device_initfn(Object *obj) { DeviceState *dev = DEVICE(obj); @@ -750,6 +769,8 @@ static void device_initfn(Object *obj) object_property_add_bool(obj, realized, device_get_realized, device_set_realized, NULL); +object_property_add_bool(obj, hotpluggable, + device_get_hotpluggable, NULL, NULL); class = object_get_class(OBJECT(dev)); do { @@ -786,6 +807,14 @@ static void device_class_base_init(ObjectClass *class, void *data) * so do not propagate them to the subclasses. */ klass-props = NULL; + +/* by default all devices were considered as hotpluggable, + * so with intent to check it in generic qdev_unplug() / + * device_set_realized() functions make every device + * hotpluggable. Devices that shouldn't be hotpluggable, + * should override it in their class_init() + */ +klass-hotpluggable = true; } static void device_unparent(Object *obj) diff --git a/include/hw/qdev-core.h b/include/hw/qdev-core.h index 41ec533..08d329d 100644 --- a/include/hw/qdev-core.h +++ b/include/hw/qdev-core.h @@ -50,6 +50,8 @@ struct VMStateDescription; * is changed to %true. Deprecated, new types inheriting directly from * TYPE_DEVICE should use @realize instead, new leaf types should consult * their respective parent type. + * @hotpluggable: indicates if #DeviceClass is hotpluggable, available + * as readonly hotpluggable property of #DeviceState instance * * # Realization # * Devices are constructed in two stages, @@ -110,6 +112,7 @@ typedef struct DeviceClass { * TODO remove once we're there */ bool cannot_instantiate_with_device_add_yet; +bool hotpluggable; /* callbacks */ void (*reset)(DeviceState *dev); -- 1.7.1
[Qemu-devel] [PATCH v6 8/9] pci/pcie: convert PCIE hotplug to use hotplug-handler API
Split pcie_cap_slot_hotplug() into hotplug/unplug callbacks and register them as hotplug-handler interface implementation of PCIE_SLOT device. Replace pci_bus_hotplug() wiring with setting link on PCI BUS hotplug-handler property to PCI_BRIDGE_DEV device. Signed-off-by: Igor Mammedov imamm...@redhat.com --- v2: * keep original non abort behavior of pcie_cap_slot_init() --- hw/pci/pcie.c | 65 ++--- hw/pci/pcie_port.c|8 ++ include/hw/pci/pcie.h |5 3 files changed, 53 insertions(+), 25 deletions(-) diff --git a/hw/pci/pcie.c b/hw/pci/pcie.c index ca60cf2..8ecd11e 100644 --- a/hw/pci/pcie.c +++ b/hw/pci/pcie.c @@ -26,6 +26,7 @@ #include hw/pci/pci_bus.h #include hw/pci/pcie_regs.h #include qemu/range.h +#include qapi/qmp/qerror.h //#define DEBUG_PCIE #ifdef DEBUG_PCIE @@ -216,28 +217,20 @@ static void pcie_cap_slot_event(PCIDevice *dev, PCIExpressHotPlugEvent event) hotplug_event_notify(dev); } -static int pcie_cap_slot_hotplug(DeviceState *qdev, - PCIDevice *pci_dev, PCIHotplugState state) +static void pcie_cap_slot_hotplug_common(PCIDevice *hotplug_dev, + DeviceState *dev, + uint8_t **exp_cap, Error **errp) { -PCIDevice *d = PCI_DEVICE(qdev); -uint8_t *exp_cap = d-config + d-exp.exp_cap; -uint16_t sltsta = pci_get_word(exp_cap + PCI_EXP_SLTSTA); - -/* Don't send event when device is enabled during qemu machine creation: - * it is present on boot, no hotplug event is necessary. We do send an - * event when the device is disabled later. */ -if (state == PCI_COLDPLUG_ENABLED) { -pci_word_test_and_set_mask(exp_cap + PCI_EXP_SLTSTA, - PCI_EXP_SLTSTA_PDS); -return 0; -} +PCIDevice *pci_dev = PCI_DEVICE(dev); +*exp_cap = hotplug_dev-config + hotplug_dev-exp.exp_cap; +uint16_t sltsta = pci_get_word(*exp_cap + PCI_EXP_SLTSTA); PCIE_DEV_PRINTF(pci_dev, hotplug state: %d\n, state); if (sltsta PCI_EXP_SLTSTA_EIS) { /* the slot is electromechanically locked. * This error is propagated up to qdev and then to HMP/QMP. */ -return -EBUSY; +error_setg_errno(errp, -EBUSY, slot is electromechanically locked); } /* TODO: multifunction hot-plug. @@ -245,18 +238,40 @@ static int pcie_cap_slot_hotplug(DeviceState *qdev, * hot plugged/unplugged. */ assert(PCI_FUNC(pci_dev-devfn) == 0); +} -if (state == PCI_HOTPLUG_ENABLED) { +void pcie_cap_slot_hotplug_cb(HotplugHandler *hotplug_dev, DeviceState *dev, + Error **errp) +{ +uint8_t *exp_cap; + +pcie_cap_slot_hotplug_common(PCI_DEVICE(hotplug_dev), dev, exp_cap, errp); + +/* Don't send event when device is enabled during qemu machine creation: + * it is present on boot, no hotplug event is necessary. We do send an + * event when the device is disabled later. */ +if (!dev-hotplugged) { pci_word_test_and_set_mask(exp_cap + PCI_EXP_SLTSTA, PCI_EXP_SLTSTA_PDS); -pcie_cap_slot_event(d, PCI_EXP_HP_EV_PDC); -} else { -object_unparent(OBJECT(pci_dev)); -pci_word_test_and_clear_mask(exp_cap + PCI_EXP_SLTSTA, - PCI_EXP_SLTSTA_PDS); -pcie_cap_slot_event(d, PCI_EXP_HP_EV_PDC); +return; } -return 0; + +pci_word_test_and_set_mask(exp_cap + PCI_EXP_SLTSTA, + PCI_EXP_SLTSTA_PDS); +pcie_cap_slot_event(PCI_DEVICE(hotplug_dev), PCI_EXP_HP_EV_PDC); +} + +void pcie_cap_slot_hot_unplug_cb(HotplugHandler *hotplug_dev, DeviceState *dev, + Error **errp) +{ +uint8_t *exp_cap; + +pcie_cap_slot_hotplug_common(PCI_DEVICE(hotplug_dev), dev, exp_cap, errp); + +object_unparent(OBJECT(dev)); +pci_word_test_and_clear_mask(exp_cap + PCI_EXP_SLTSTA, + PCI_EXP_SLTSTA_PDS); +pcie_cap_slot_event(PCI_DEVICE(hotplug_dev), PCI_EXP_HP_EV_PDC); } /* pci express slot for pci express root/downstream port @@ -305,8 +320,8 @@ void pcie_cap_slot_init(PCIDevice *dev, uint16_t slot) dev-exp.hpev_notified = false; -pci_bus_hotplug(pci_bridge_get_sec_bus(PCI_BRIDGE(dev)), -pcie_cap_slot_hotplug, dev-qdev); +qbus_set_hotplug_handler(BUS(pci_bridge_get_sec_bus(PCI_BRIDGE(dev))), + DEVICE(dev), NULL); } void pcie_cap_slot_reset(PCIDevice *dev) diff --git a/hw/pci/pcie_port.c b/hw/pci/pcie_port.c index 2adb030..fa24877 100644 --- a/hw/pci/pcie_port.c +++ b/hw/pci/pcie_port.c @@ -19,6 +19,7 @@ */ #include hw/pci/pcie_port.h +#include hw/hotplug.h void pcie_port_init_reg(PCIDevice *d) { @@ -149,8 +150,11 @@ static Property pcie_slot_props[] = { static void
[Qemu-devel] [PATCH v6 4/9] hw/acpi: move typeinfo to the file end
do so to avoid not necessary forward declarations and place typeinfo registration at the file end where it's usually expected. Signed-off-by: Igor Mammedov imamm...@redhat.com --- v2: * fix typo in commit message s/usualy/usually/ --- hw/acpi/piix4.c | 92 +++--- 1 files changed, 46 insertions(+), 46 deletions(-) diff --git a/hw/acpi/piix4.c b/hw/acpi/piix4.c index 7a0efcb..0f45e11 100644 --- a/hw/acpi/piix4.c +++ b/hw/acpi/piix4.c @@ -466,52 +466,6 @@ i2c_bus *piix4_pm_init(PCIBus *bus, int devfn, uint32_t smb_io_base, return s-smb.smbus; } -static Property piix4_pm_properties[] = { -DEFINE_PROP_UINT32(smb_io_base, PIIX4PMState, smb_io_base, 0), -DEFINE_PROP_UINT8(ACPI_PM_PROP_S3_DISABLED, PIIX4PMState, disable_s3, 0), -DEFINE_PROP_UINT8(ACPI_PM_PROP_S4_DISABLED, PIIX4PMState, disable_s4, 0), -DEFINE_PROP_UINT8(ACPI_PM_PROP_S4_VAL, PIIX4PMState, s4_val, 2), -DEFINE_PROP_BOOL(acpi-pci-hotplug-with-bridge-support, PIIX4PMState, - use_acpi_pci_hotplug, true), -DEFINE_PROP_END_OF_LIST(), -}; - -static void piix4_pm_class_init(ObjectClass *klass, void *data) -{ -DeviceClass *dc = DEVICE_CLASS(klass); -PCIDeviceClass *k = PCI_DEVICE_CLASS(klass); - -k-no_hotplug = 1; -k-init = piix4_pm_initfn; -k-config_write = pm_write_config; -k-vendor_id = PCI_VENDOR_ID_INTEL; -k-device_id = PCI_DEVICE_ID_INTEL_82371AB_3; -k-revision = 0x03; -k-class_id = PCI_CLASS_BRIDGE_OTHER; -dc-desc = PM; -dc-vmsd = vmstate_acpi; -dc-props = piix4_pm_properties; -/* - * Reason: part of PIIX4 southbridge, needs to be wired up, - * e.g. by mips_malta_init() - */ -dc-cannot_instantiate_with_device_add_yet = true; -} - -static const TypeInfo piix4_pm_info = { -.name = TYPE_PIIX4_PM, -.parent= TYPE_PCI_DEVICE, -.instance_size = sizeof(PIIX4PMState), -.class_init= piix4_pm_class_init, -}; - -static void piix4_pm_register_types(void) -{ -type_register_static(piix4_pm_info); -} - -type_init(piix4_pm_register_types) - static uint64_t gpe_readb(void *opaque, hwaddr addr, unsigned width) { PIIX4PMState *s = opaque; @@ -566,3 +520,49 @@ static void piix4_acpi_system_hot_add_init(MemoryRegion *parent, s-cpu_added_notifier.notify = piix4_cpu_added_req; qemu_register_cpu_added_notifier(s-cpu_added_notifier); } + +static Property piix4_pm_properties[] = { +DEFINE_PROP_UINT32(smb_io_base, PIIX4PMState, smb_io_base, 0), +DEFINE_PROP_UINT8(ACPI_PM_PROP_S3_DISABLED, PIIX4PMState, disable_s3, 0), +DEFINE_PROP_UINT8(ACPI_PM_PROP_S4_DISABLED, PIIX4PMState, disable_s4, 0), +DEFINE_PROP_UINT8(ACPI_PM_PROP_S4_VAL, PIIX4PMState, s4_val, 2), +DEFINE_PROP_BOOL(acpi-pci-hotplug-with-bridge-support, PIIX4PMState, + use_acpi_pci_hotplug, true), +DEFINE_PROP_END_OF_LIST(), +}; + +static void piix4_pm_class_init(ObjectClass *klass, void *data) +{ +DeviceClass *dc = DEVICE_CLASS(klass); +PCIDeviceClass *k = PCI_DEVICE_CLASS(klass); + +k-no_hotplug = 1; +k-init = piix4_pm_initfn; +k-config_write = pm_write_config; +k-vendor_id = PCI_VENDOR_ID_INTEL; +k-device_id = PCI_DEVICE_ID_INTEL_82371AB_3; +k-revision = 0x03; +k-class_id = PCI_CLASS_BRIDGE_OTHER; +dc-desc = PM; +dc-vmsd = vmstate_acpi; +dc-props = piix4_pm_properties; +/* + * Reason: part of PIIX4 southbridge, needs to be wired up, + * e.g. by mips_malta_init() + */ +dc-cannot_instantiate_with_device_add_yet = true; +} + +static const TypeInfo piix4_pm_info = { +.name = TYPE_PIIX4_PM, +.parent= TYPE_PCI_DEVICE, +.instance_size = sizeof(PIIX4PMState), +.class_init= piix4_pm_class_init, +}; + +static void piix4_pm_register_types(void) +{ +type_register_static(piix4_pm_info); +} + +type_init(piix4_pm_register_types) -- 1.7.1
[Qemu-devel] [PATCH v6 1/9] define hotplug interface
Provide a generic hotplug interface for hotplug handlers. Intended for replacing hotplug mechanism used by PCI/PCIE/SHPC code and will be used for memory hotplug. Signed-off-by: Igor Mammedov imamm...@redhat.com --- v4: * s/2013/2014/ in copyright headers v3: * amend commit description as requested by Peter Crosthwaite * add private|public doc comments to type definitions v2: * s/device/handler/ * add hotplug_handler_plug/hotplug_handler_unplug API v1: it's scsi-bus like interface, but abstracted from bus altogether since all current users care about in hotplug handlers, it's hotplug device and hotplugged device and bus only serves as a means to get access to hotplug device and it's callbacks. --- hw/core/Makefile.objs |1 + hw/core/hotplug.c | 48 ++ include/hw/hotplug.h | 78 + 3 files changed, 127 insertions(+), 0 deletions(-) create mode 100644 hw/core/hotplug.c create mode 100644 include/hw/hotplug.h diff --git a/hw/core/Makefile.objs b/hw/core/Makefile.objs index 950146c..9e324be 100644 --- a/hw/core/Makefile.objs +++ b/hw/core/Makefile.objs @@ -2,6 +2,7 @@ common-obj-y += qdev.o qdev-properties.o # irq.o needed for qdev GPIO handling: common-obj-y += irq.o +common-obj-y += hotplug.o common-obj-$(CONFIG_EMPTY_SLOT) += empty_slot.o common-obj-$(CONFIG_XILINX_AXI) += stream.o diff --git a/hw/core/hotplug.c b/hw/core/hotplug.c new file mode 100644 index 000..5573d9d --- /dev/null +++ b/hw/core/hotplug.c @@ -0,0 +1,48 @@ +/* + * Hotplug handler interface. + * + * Copyright (c) 2014 Red Hat Inc. + * + * Authors: + * Igor Mammedov imamm...@redhat.com, + * + * This work is licensed under the terms of the GNU GPL, version 2 or later. + * See the COPYING file in the top-level directory. + */ +#include hw/hotplug.h +#include qemu/module.h + +void hotplug_handler_plug(HotplugHandler *plug_handler, + DeviceState *plugged_dev, + Error **errp) +{ +HotplugHandlerClass *hdc = HOTPLUG_HANDLER_GET_CLASS(plug_handler); + +if (hdc-plug) { +hdc-plug(plug_handler, plugged_dev, errp); +} +} + +void hotplug_handler_unplug(HotplugHandler *plug_handler, +DeviceState *plugged_dev, +Error **errp) +{ +HotplugHandlerClass *hdc = HOTPLUG_HANDLER_GET_CLASS(plug_handler); + +if (hdc-unplug) { +hdc-unplug(plug_handler, plugged_dev, errp); +} +} + +static const TypeInfo hotplug_handler_info = { +.name = TYPE_HOTPLUG_HANDLER, +.parent= TYPE_INTERFACE, +.class_size = sizeof(HotplugHandlerClass), +}; + +static void hotplug_handler_register_types(void) +{ +type_register_static(hotplug_handler_info); +} + +type_init(hotplug_handler_register_types) diff --git a/include/hw/hotplug.h b/include/hw/hotplug.h new file mode 100644 index 000..a6533cb --- /dev/null +++ b/include/hw/hotplug.h @@ -0,0 +1,78 @@ +/* + * Hotplug handler interface. + * + * Copyright (c) 2014 Red Hat Inc. + * + * Authors: + * Igor Mammedov imamm...@redhat.com, + * + * This work is licensed under the terms of the GNU GPL, version 2 or later. + * See the COPYING file in the top-level directory. + */ +#ifndef HOTPLUG_H +#define HOTPLUG_H + +#include qom/object.h +#include qemu/typedefs.h + +#define TYPE_HOTPLUG_HANDLER hotplug-handler + +#define HOTPLUG_HANDLER_CLASS(klass) \ + OBJECT_CLASS_CHECK(HotplugHandlerClass, (klass), TYPE_HOTPLUG_HANDLER) +#define HOTPLUG_HANDLER_GET_CLASS(obj) \ + OBJECT_GET_CLASS(HotplugHandlerClass, (obj), TYPE_HOTPLUG_HANDLER) +#define HOTPLUG_HANDLER(obj) \ + INTERFACE_CHECK(HotplugHandler, (obj), TYPE_HOTPLUG_HANDLER) + + +typedef struct HotplugHandler { +/* private */ +Object Parent; +} HotplugHandler; + +/** + * hotplug_fn: + * @plug_handler: a device performing plug/uplug action + * @plugged_dev: a device that has been (un)plugged + * @errp: returns an error if this function fails + */ +typedef void (*hotplug_fn)(HotplugHandler *plug_handler, + DeviceState *plugged_dev, Error **errp); + +/** + * HotplugDeviceClass: + * + * Interface to be implemented by a device performing + * hardware (un)plug functions. + * + * @parent: Opaque parent interface. + * @plug: plug callback. + * @unplug: unplug callback. + */ +typedef struct HotplugHandlerClass { +/* private */ +InterfaceClass parent; + +/* public */ +hotplug_fn plug; +hotplug_fn unplug; +} HotplugHandlerClass; + +/** + * hotplug_handler_plug: + * + * Call #HotplugHandlerClass.plug callback of @plug_handler. + */ +void hotplug_handler_plug(HotplugHandler *plug_handler, + DeviceState *plugged_dev, + Error **errp); + +/** + * hotplug_handler_unplug: + * + * Call #HotplugHandlerClass.unplug callback of @plug_handler. + */ +void hotplug_handler_unplug(HotplugHandler *plug_handler, +
[Qemu-devel] [PATCH v6 7/9] pci/shpc: convert SHPC hotplug to use hotplug-handler API
Split shpc_device_hotplug() into hotplug/unplug callbacks and register them as hotplug-handler interface implementation of PCI_BRIDGE_DEV device. Replace pci_bus_hotplug() wiring with setting link on PCI BUS hotplug-handler property to PCI_BRIDGE_DEV device. Signed-off-by: Igor Mammedov imamm...@redhat.com --- v2: * drop error_is_set() and check local_error pointer directly * keep original logic, i.e. do not abort in bridge init. --- hw/pci-bridge/pci_bridge_dev.c |9 +++ hw/pci/shpc.c | 124 +--- include/hw/pci/shpc.h |8 +++ 3 files changed, 94 insertions(+), 47 deletions(-) diff --git a/hw/pci-bridge/pci_bridge_dev.c b/hw/pci-bridge/pci_bridge_dev.c index 440e187..e68145c 100644 --- a/hw/pci-bridge/pci_bridge_dev.c +++ b/hw/pci-bridge/pci_bridge_dev.c @@ -26,6 +26,7 @@ #include hw/pci/slotid_cap.h #include exec/memory.h #include hw/pci/pci_bus.h +#include hw/hotplug.h #define TYPE_PCI_BRIDGE_DEV pci-bridge #define PCI_BRIDGE_DEV(obj) \ @@ -136,6 +137,8 @@ static void pci_bridge_dev_class_init(ObjectClass *klass, void *data) { DeviceClass *dc = DEVICE_CLASS(klass); PCIDeviceClass *k = PCI_DEVICE_CLASS(klass); +HotplugHandlerClass *hc = HOTPLUG_HANDLER_CLASS(klass); + k-init = pci_bridge_dev_initfn; k-exit = pci_bridge_dev_exitfn; k-config_write = pci_bridge_dev_write_config; @@ -148,6 +151,8 @@ static void pci_bridge_dev_class_init(ObjectClass *klass, void *data) dc-props = pci_bridge_dev_properties; dc-vmsd = pci_bridge_dev_vmstate; set_bit(DEVICE_CATEGORY_BRIDGE, dc-categories); +hc-plug = shpc_device_hotplug_cb; +hc-unplug = shpc_device_hot_unplug_cb; } static const TypeInfo pci_bridge_dev_info = { @@ -155,6 +160,10 @@ static const TypeInfo pci_bridge_dev_info = { .parent= TYPE_PCI_BRIDGE, .instance_size = sizeof(PCIBridgeDev), .class_init = pci_bridge_dev_class_init, +.interfaces = (InterfaceInfo[]) { +{ TYPE_HOTPLUG_HANDLER }, +{ } +} }; static void pci_bridge_dev_register(void) diff --git a/hw/pci/shpc.c b/hw/pci/shpc.c index 576244b..180faa7 100644 --- a/hw/pci/shpc.c +++ b/hw/pci/shpc.c @@ -7,6 +7,7 @@ #include hw/pci/pci.h #include hw/pci/pci_bus.h #include hw/pci/msi.h +#include qapi/qmp/qerror.h /* TODO: model power only and disabled slot states. */ /* TODO: handle SERR and wakeups */ @@ -490,65 +491,93 @@ static const MemoryRegionOps shpc_mmio_ops = { .max_access_size = 4, }, }; - -static int shpc_device_hotplug(DeviceState *qdev, PCIDevice *affected_dev, - PCIHotplugState hotplug_state) +static void shpc_device_hotplug_common(PCIDevice *affected_dev, int *slot, + SHPCDevice *shpc, Error **errp) { int pci_slot = PCI_SLOT(affected_dev-devfn); -uint8_t state; -uint8_t led; -PCIDevice *d = DO_UPCAST(PCIDevice, qdev, qdev); -SHPCDevice *shpc = d-shpc; -int slot = SHPC_PCI_TO_IDX(pci_slot); -if (pci_slot SHPC_IDX_TO_PCI(0) || slot = shpc-nslots) { -error_report(Unsupported PCI slot %d for standard hotplug - controller. Valid slots are between %d and %d., - pci_slot, SHPC_IDX_TO_PCI(0), - SHPC_IDX_TO_PCI(shpc-nslots) - 1); -return -1; +*slot = SHPC_PCI_TO_IDX(pci_slot); + +if (pci_slot SHPC_IDX_TO_PCI(0) || *slot = shpc-nslots) { +error_setg(errp, Unsupported PCI slot %d for standard hotplug + controller. Valid slots are between %d and %d., + pci_slot, SHPC_IDX_TO_PCI(0), + SHPC_IDX_TO_PCI(shpc-nslots) - 1); +return; +} +} + +void shpc_device_hotplug_cb(HotplugHandler *hotplug_dev, DeviceState *dev, +Error **errp) +{ +Error *local_err = NULL; +PCIDevice *pci_hotplug_dev = PCI_DEVICE(hotplug_dev); +SHPCDevice *shpc = pci_hotplug_dev-shpc; +int slot; + +shpc_device_hotplug_common(PCI_DEVICE(dev), slot, shpc, local_err); +if (local_err) { +error_propagate(errp, local_err); +return; } + /* Don't send event when device is enabled during qemu machine creation: * it is present on boot, no hotplug event is necessary. We do send an * event when the device is disabled later. */ -if (hotplug_state == PCI_COLDPLUG_ENABLED) { +if (!dev-hotplugged) { shpc_set_status(shpc, slot, 0, SHPC_SLOT_STATUS_MRL_OPEN); shpc_set_status(shpc, slot, SHPC_SLOT_STATUS_PRSNT_7_5W, SHPC_SLOT_STATUS_PRSNT_MASK); -return 0; +return; } -if (hotplug_state == PCI_HOTPLUG_DISABLED) { -shpc-config[SHPC_SLOT_EVENT_LATCH(slot)] |= SHPC_SLOT_EVENT_BUTTON; -state = shpc_get_status(shpc, slot, SHPC_SLOT_STATE_MASK); -led = shpc_get_status(shpc, slot, SHPC_SLOT_PWR_LED_MASK); -if
[Qemu-devel] [PATCH v6 9/9] hw/pci: switch to a generic hotplug handling for PCIDevice
make qdev_unplug()/device_set_realized() to call hotplug handler's plug/unplug methods if available and remove not needed anymore hot(un)plug handling from PCIDevice. In case if hotplug handler is not available, revert to the legacy hotplug method for compatibility with not yet converted buses. Signed-off-by: Igor Mammedov imamm...@redhat.com --- v2: * fix test-qdev-global-props build failure during make check --- hw/core/qdev.c | 17 + hw/pci/pci.c | 29 + include/hw/pci/pci.h | 10 -- include/hw/pci/pci_bus.h |2 -- tests/Makefile |2 +- 5 files changed, 15 insertions(+), 45 deletions(-) diff --git a/hw/core/qdev.c b/hw/core/qdev.c index 5c864db..64b66e0 100644 --- a/hw/core/qdev.c +++ b/hw/core/qdev.c @@ -213,7 +213,6 @@ void qdev_unplug(DeviceState *dev, Error **errp) error_set(errp, QERR_BUS_NO_HOTPLUG, dev-parent_bus-name); return; } -assert(dc-unplug != NULL); if (!dc-hotpluggable) { error_set(errp, QERR_DEVICE_NO_HOTPLUG, @@ -223,9 +222,13 @@ void qdev_unplug(DeviceState *dev, Error **errp) qdev_hot_removed = true; -if (dc-unplug(dev) 0) { -error_set(errp, QERR_UNDEFINED_ERROR); -return; +if (dev-parent_bus dev-parent_bus-hotplug_handler) { +hotplug_handler_unplug(dev-parent_bus-hotplug_handler, dev, errp); +} else { +assert(dc-unplug != NULL); +if (dc-unplug(dev) 0) { /* legacy handler */ +error_set(errp, QERR_UNDEFINED_ERROR); +} } } @@ -720,6 +723,12 @@ static void device_set_realized(Object *obj, bool value, Error **err) dc-realize(dev, local_err); } +if (dev-parent_bus dev-parent_bus-hotplug_handler +local_err == NULL) { +hotplug_handler_plug(dev-parent_bus-hotplug_handler, + dev, local_err); +} + if (qdev_get_vmsd(dev) local_err == NULL) { vmstate_register_with_alias_id(dev, -1, qdev_get_vmsd(dev), dev, dev-instance_id_alias, diff --git a/hw/pci/pci.c b/hw/pci/pci.c index d69961f..4e0701d 100644 --- a/hw/pci/pci.c +++ b/hw/pci/pci.c @@ -35,6 +35,7 @@ #include hw/pci/msi.h #include hw/pci/msix.h #include exec/address-spaces.h +#include hw/hotplug.h //#define DEBUG_PCI #ifdef DEBUG_PCI @@ -346,13 +347,6 @@ void pci_bus_irqs(PCIBus *bus, pci_set_irq_fn set_irq, pci_map_irq_fn map_irq, bus-irq_count = g_malloc0(nirq * sizeof(bus-irq_count[0])); } -void pci_bus_hotplug(PCIBus *bus, pci_hotplug_fn hotplug, DeviceState *qdev) -{ -bus-qbus.allow_hotplug = 1; -bus-hotplug = hotplug; -bus-hotplug_qdev = qdev; -} - PCIBus *pci_register_bus(DeviceState *parent, const char *name, pci_set_irq_fn set_irq, pci_map_irq_fn map_irq, void *irq_opaque, @@ -1778,29 +1772,9 @@ static int pci_qdev_init(DeviceState *qdev) } pci_add_option_rom(pci_dev, is_default_rom); -if (bus-hotplug) { -/* Let buses differentiate between hotplug and when device is - * enabled during qemu machine creation. */ -rc = bus-hotplug(bus-hotplug_qdev, pci_dev, - qdev-hotplugged ? PCI_HOTPLUG_ENABLED: - PCI_COLDPLUG_ENABLED); -if (rc != 0) { -int r = pci_unregister_device(pci_dev-qdev); -assert(!r); -return rc; -} -} return 0; } -static int pci_unplug_device(DeviceState *qdev) -{ -PCIDevice *dev = PCI_DEVICE(qdev); - -return dev-bus-hotplug(dev-bus-hotplug_qdev, dev, - PCI_HOTPLUG_DISABLED); -} - PCIDevice *pci_create_multifunction(PCIBus *bus, int devfn, bool multifunction, const char *name) { @@ -2271,7 +2245,6 @@ static void pci_device_class_init(ObjectClass *klass, void *data) { DeviceClass *k = DEVICE_CLASS(klass); k-init = pci_qdev_init; -k-unplug = pci_unplug_device; k-exit = pci_unregister_device; k-bus_type = TYPE_PCI_BUS; k-props = pci_props; diff --git a/include/hw/pci/pci.h b/include/hw/pci/pci.h index c173b6a..693dd6b 100644 --- a/include/hw/pci/pci.h +++ b/include/hw/pci/pci.h @@ -327,15 +327,6 @@ typedef void (*pci_set_irq_fn)(void *opaque, int irq_num, int level); typedef int (*pci_map_irq_fn)(PCIDevice *pci_dev, int irq_num); typedef PCIINTxRoute (*pci_route_irq_fn)(void *opaque, int pin); -typedef enum { -PCI_HOTPLUG_DISABLED, -PCI_HOTPLUG_ENABLED, -PCI_COLDPLUG_ENABLED, -} PCIHotplugState; - -typedef int (*pci_hotplug_fn)(DeviceState *qdev, PCIDevice *pci_dev, - PCIHotplugState state); - #define TYPE_PCI_BUS PCI #define PCI_BUS(obj) OBJECT_CHECK(PCIBus, (obj), TYPE_PCI_BUS) #define TYPE_PCIE_BUS PCIE @@ -354,7 +345,6 @@ PCIBus
[Qemu-devel] [PATCH v6 5/9] qdev:pci: refactor PCIDevice to use generic hotpluggable property
Get rid of PCIDevice specific PCIDeviceClass.no_hotplug and use generic DeviceClass.hotpluggable field instead. Signed-off-by: Igor Mammedov imamm...@redhat.com --- v2: * move generic hotplug checks to qdev: add hotpluggable property to Device patch * s/hotplugable/hotpluggable/ --- hw/acpi/pcihp.c |3 ++- hw/acpi/piix4.c |2 +- hw/display/cirrus_vga.c |2 +- hw/display/qxl.c|2 +- hw/display/vga-pci.c|2 +- hw/display/vmware_vga.c |2 +- hw/i386/acpi-build.c|4 +++- hw/ide/piix.c |4 ++-- hw/isa/piix4.c |2 +- hw/pci-host/piix.c |6 +++--- hw/pci/pci.c| 11 +-- hw/usb/hcd-ehci-pci.c |2 +- hw/usb/hcd-ohci.c |2 +- hw/usb/hcd-uhci.c |2 +- hw/usb/hcd-xhci.c |2 +- include/hw/pci/pci.h|3 --- 16 files changed, 21 insertions(+), 30 deletions(-) diff --git a/hw/acpi/pcihp.c b/hw/acpi/pcihp.c index 1ce6fc2..3bd5a06 100644 --- a/hw/acpi/pcihp.c +++ b/hw/acpi/pcihp.c @@ -105,12 +105,13 @@ static PCIBus *acpi_pcihp_find_hotplug_bus(AcpiPciHpState *s, int bsel) static bool acpi_pcihp_pc_no_hotplug(AcpiPciHpState *s, PCIDevice *dev) { PCIDeviceClass *pc = PCI_DEVICE_GET_CLASS(dev); +DeviceClass *dc = DEVICE_GET_CLASS(dev); /* * ACPI doesn't allow hotplug of bridge devices. Don't allow * hot-unplug of bridge devices unless they were added by hotplug * (and so, not described by acpi). */ -return (pc-is_bridge !dev-qdev.hotplugged) || pc-no_hotplug; +return (pc-is_bridge !dev-qdev.hotplugged) || !dc-hotpluggable; } static void acpi_pcihp_eject_slot(AcpiPciHpState *s, unsigned bsel, unsigned slots) diff --git a/hw/acpi/piix4.c b/hw/acpi/piix4.c index 0f45e11..06a 100644 --- a/hw/acpi/piix4.c +++ b/hw/acpi/piix4.c @@ -536,7 +536,6 @@ static void piix4_pm_class_init(ObjectClass *klass, void *data) DeviceClass *dc = DEVICE_CLASS(klass); PCIDeviceClass *k = PCI_DEVICE_CLASS(klass); -k-no_hotplug = 1; k-init = piix4_pm_initfn; k-config_write = pm_write_config; k-vendor_id = PCI_VENDOR_ID_INTEL; @@ -551,6 +550,7 @@ static void piix4_pm_class_init(ObjectClass *klass, void *data) * e.g. by mips_malta_init() */ dc-cannot_instantiate_with_device_add_yet = true; +dc-hotpluggable = false; } static const TypeInfo piix4_pm_info = { diff --git a/hw/display/cirrus_vga.c b/hw/display/cirrus_vga.c index e4c345f..3a8fc0b 100644 --- a/hw/display/cirrus_vga.c +++ b/hw/display/cirrus_vga.c @@ -2996,7 +2996,6 @@ static void cirrus_vga_class_init(ObjectClass *klass, void *data) DeviceClass *dc = DEVICE_CLASS(klass); PCIDeviceClass *k = PCI_DEVICE_CLASS(klass); -k-no_hotplug = 1; k-init = pci_cirrus_vga_initfn; k-romfile = VGABIOS_CIRRUS_FILENAME; k-vendor_id = PCI_VENDOR_ID_CIRRUS; @@ -3006,6 +3005,7 @@ static void cirrus_vga_class_init(ObjectClass *klass, void *data) dc-desc = Cirrus CLGD 54xx VGA; dc-vmsd = vmstate_pci_cirrus_vga; dc-props = pci_vga_cirrus_properties; +dc-hotpluggable = false; } static const TypeInfo cirrus_vga_info = { diff --git a/hw/display/qxl.c b/hw/display/qxl.c index e4f172e..ec82e00 100644 --- a/hw/display/qxl.c +++ b/hw/display/qxl.c @@ -2299,7 +2299,6 @@ static void qxl_primary_class_init(ObjectClass *klass, void *data) DeviceClass *dc = DEVICE_CLASS(klass); PCIDeviceClass *k = PCI_DEVICE_CLASS(klass); -k-no_hotplug = 1; k-init = qxl_init_primary; k-romfile = vgabios-qxl.bin; k-vendor_id = REDHAT_PCI_VENDOR_ID; @@ -2310,6 +2309,7 @@ static void qxl_primary_class_init(ObjectClass *klass, void *data) dc-reset = qxl_reset_handler; dc-vmsd = qxl_vmstate; dc-props = qxl_properties; +dc-hotpluggable = false; } static const TypeInfo qxl_primary_info = { diff --git a/hw/display/vga-pci.c b/hw/display/vga-pci.c index b3a45c8..f74fc43 100644 --- a/hw/display/vga-pci.c +++ b/hw/display/vga-pci.c @@ -190,7 +190,6 @@ static void vga_class_init(ObjectClass *klass, void *data) DeviceClass *dc = DEVICE_CLASS(klass); PCIDeviceClass *k = PCI_DEVICE_CLASS(klass); -k-no_hotplug = 1; k-init = pci_std_vga_initfn; k-romfile = vgabios-stdvga.bin; k-vendor_id = PCI_VENDOR_ID_QEMU; @@ -198,6 +197,7 @@ static void vga_class_init(ObjectClass *klass, void *data) k-class_id = PCI_CLASS_DISPLAY_VGA; dc-vmsd = vmstate_vga_pci; dc-props = vga_pci_properties; +dc-hotpluggable = false; set_bit(DEVICE_CATEGORY_DISPLAY, dc-categories); } diff --git a/hw/display/vmware_vga.c b/hw/display/vmware_vga.c index aba292c..334e718 100644 --- a/hw/display/vmware_vga.c +++ b/hw/display/vmware_vga.c @@ -1296,7 +1296,6 @@ static void vmsvga_class_init(ObjectClass *klass, void *data) DeviceClass *dc = DEVICE_CLASS(klass); PCIDeviceClass *k = PCI_DEVICE_CLASS(klass); -k-no_hotplug = 1; k-init =
Re: [Qemu-devel] [PATCH 1/2] qom-test: Run for all available machines
Stefano, Am 10.01.2014 14:31, schrieb arm...@redhat.com: From: Markus Armbruster arm...@redhat.com Get available machines via QMP instead of hardcoding a list that's perpetually out of date. A few machines don't work out of the box: [...] * Xen machines can work only when running under the Xen hypervisor. Blacklist them. Signed-off-by: Markus Armbruster arm...@redhat.com --- tests/qom-test.c | 283 +-- 1 file changed, 66 insertions(+), 217 deletions(-) diff --git a/tests/qom-test.c b/tests/qom-test.c index 5e5af7a..3cbd480 100644 --- a/tests/qom-test.c +++ b/tests/qom-test.c @@ -11,6 +11,42 @@ #include glib.h #include string.h #include qemu/osdep.h +#include qapi/qmp/types.h + [...] + +static const char *blacklist_x86[] = { +xenfv, xenpv, NULL +}; [snip] I'm wondering if we could enable these machines conditional to CONFIG_XEN, so I've tried commenting out the two since I have the Xen libraries installed, but I get this: $ make check-qtest V=1 [...] /i386/qom/xenpv: xen be core: can't connect to xenstored xen_init_pv: xen backend core setup failed Broken pipe FAIL [...] /i386/qom/xenfv: Broken pipe FAIL [...] Have you checked whether you can make some code dependent on !qtest_enabled() to make your machines testable by non-Xen users? Regards, Andreas -- SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
[Qemu-devel] [PATCH v6 6/9] acpi/piix4pm: convert ACPI PCI hotplug to use hotplug-handler API
Split piix4_device_hotplug() into hotplug/unplug callbacks and register them as hotplug-handler interface implementation of PIIX4_PM device. Replace pci_bus_hotplug() wiring with setting link on PCI BUS hotplug-handler property to PIIX4_PM device. Signed-off-by: Igor Mammedov imamm...@redhat.com --- v3: * s/Not supported/Unsupported/ * s/propery/property/ * drop trailing dot in the error message v2: * use error_abort to make error handling less verbose --- hw/acpi/pcihp.c | 43 +++ hw/acpi/piix4.c | 36 ++-- include/hw/acpi/acpi.h |1 + include/hw/acpi/pcihp.h | 10 ++ 4 files changed, 60 insertions(+), 30 deletions(-) diff --git a/hw/acpi/pcihp.c b/hw/acpi/pcihp.c index 3bd5a06..f80c480 100644 --- a/hw/acpi/pcihp.c +++ b/hw/acpi/pcihp.c @@ -46,6 +46,7 @@ # define ACPI_PCIHP_DPRINTF(format, ...) do { } while (0) #endif +#define ACPI_PCI_HOTPLUG_STATUS 2 #define ACPI_PCIHP_ADDR 0xae00 #define ACPI_PCIHP_SIZE 0x0014 #define ACPI_PCIHP_LEGACY_SIZE 0x000f @@ -179,29 +180,47 @@ void acpi_pcihp_reset(AcpiPciHpState *s) acpi_pcihp_update(s); } -int acpi_pcihp_device_hotplug(AcpiPciHpState *s, PCIDevice *dev, - PCIHotplugState state) +void acpi_pcihp_device_plug_cb(ACPIREGS *ar, qemu_irq irq, AcpiPciHpState *s, + DeviceState *dev, Error **errp) { -int slot = PCI_SLOT(dev-devfn); -int bsel = acpi_pcihp_get_bsel(dev-bus); +PCIDevice *pdev = PCI_DEVICE(dev); +int slot = PCI_SLOT(pdev-devfn); +int bsel = acpi_pcihp_get_bsel(pdev-bus); if (bsel 0) { -return -1; +error_setg(errp, Unsupported bus. Bus doesn't have property ' + ACPI_PCIHP_PROP_BSEL ' set); +return; } /* Don't send event when device is enabled during qemu machine creation: * it is present on boot, no hotplug event is necessary. We do send an * event when the device is disabled later. */ -if (state == PCI_COLDPLUG_ENABLED) { -return 0; +if (!dev-hotplugged) { +return; } -if (state == PCI_HOTPLUG_ENABLED) { -s-acpi_pcihp_pci_status[bsel].up |= (1U slot); -} else { -s-acpi_pcihp_pci_status[bsel].down |= (1U slot); +s-acpi_pcihp_pci_status[bsel].up |= (1U slot); + +ar-gpe.sts[0] |= ACPI_PCI_HOTPLUG_STATUS; +acpi_update_sci(ar, irq); +} + +void acpi_pcihp_device_unplug_cb(ACPIREGS *ar, qemu_irq irq, AcpiPciHpState *s, + DeviceState *dev, Error **errp) +{ +PCIDevice *pdev = PCI_DEVICE(dev); +int slot = PCI_SLOT(pdev-devfn); +int bsel = acpi_pcihp_get_bsel(pdev-bus); +if (bsel 0) { +error_setg(errp, Unsupported bus. Bus doesn't have property ' + ACPI_PCIHP_PROP_BSEL ' set); +return; } -return 0; +s-acpi_pcihp_pci_status[bsel].down |= (1U slot); + +ar-gpe.sts[0] |= ACPI_PCI_HOTPLUG_STATUS; +acpi_update_sci(ar, irq); } static uint64_t pci_read(void *opaque, hwaddr addr, unsigned int size) diff --git a/hw/acpi/piix4.c b/hw/acpi/piix4.c index 06a..9f21653 100644 --- a/hw/acpi/piix4.c +++ b/hw/acpi/piix4.c @@ -32,6 +32,7 @@ #include hw/acpi/piix4.h #include hw/acpi/pcihp.h #include hw/acpi/cpu_hotplug.h +#include hw/hotplug.h //#define DEBUG @@ -44,8 +45,6 @@ #define GPE_BASE 0xafe0 #define GPE_LEN 4 -#define PIIX4_PCI_HOTPLUG_STATUS 2 - struct pci_status { uint32_t up; /* deprecated, maintained for migration compatibility */ uint32_t down; @@ -311,24 +310,26 @@ static void piix4_pm_powerdown_req(Notifier *n, void *opaque) acpi_pm1_evt_power_down(s-ar); } -static int piix4_acpi_pci_hotplug(DeviceState *qdev, PCIDevice *dev, - PCIHotplugState state) +static void piix4_pci_device_plug_cb(HotplugHandler *hotplug_dev, + DeviceState *dev, Error **errp) { -PIIX4PMState *s = PIIX4_PM(qdev); -int ret = acpi_pcihp_device_hotplug(s-acpi_pci_hotplug, dev, state); -if (ret 0) { -return ret; -} -s-ar.gpe.sts[0] |= PIIX4_PCI_HOTPLUG_STATUS; +PIIX4PMState *s = PIIX4_PM(hotplug_dev); +acpi_pcihp_device_plug_cb(s-ar, s-irq, s-acpi_pci_hotplug, dev, errp); +} -acpi_update_sci(s-ar, s-irq); -return 0; +static void piix4_pci_device_unplug_cb(HotplugHandler *hotplug_dev, + DeviceState *dev, Error **errp) +{ +PIIX4PMState *s = PIIX4_PM(hotplug_dev); +acpi_pcihp_device_unplug_cb(s-ar, s-irq, s-acpi_pci_hotplug, dev, +errp); } -static void piix4_update_bus_hotplug(PCIBus *bus, void *opaque) +static void piix4_update_bus_hotplug(PCIBus *pci_bus, void *opaque) { PIIX4PMState *s = opaque; -pci_bus_hotplug(bus, piix4_acpi_pci_hotplug, DEVICE(s)); + +qbus_set_hotplug_handler(BUS(pci_bus),
[Qemu-devel] Get a vm fd using kvm API's ioctls
Hi all, I'm trying to get the dirty bitmap of a specific VM, using KVM_GET_DIRTY_LOG ioctl. For this purpose, I should be able to get the file descriptor of an existing VM by doing something like : kvm_fd = open(/dev/kvm) ... b = ioctl(KVM_GET_DIRTY_LOG, vm_fd) I also can see, from the API documentation (https://www.kernel.org/doc/Documentation/virtual/kvm/api.txt), that there is the following restriction concerning VM ioctls : Only run VM ioctls from the same process (address space) that was used to create the VM. Is there a way to get the fd of a running VM (created from an other process), or maybe a better/easier manner to get the dirty bitmap ? Any help would be welcome. Thanks, -- Vincent KHERBACHE PhD student at INRIA Sophia Antipolis (FRANCE)
Re: [Qemu-devel] [PATCH v6 2/9] qdev: add to BusState hotplug-handler link
Am 05.02.2014 16:36, schrieb Igor Mammedov: It will allow to reuse field with different BUSes, reducing code duplication. Field is intended for replacing 'hotplug_qdev' field in PCIBus and also will allow to avoid adding equivalent field to DimmBus with possiblitity to refactor other BUSes to use it instead of custom field. In addition once all users of allow_hotplug field are converted to new API, link could replace allow_hotplug field in qdev hotplug code. Signed-off-by: Igor Mammedov imamm...@redhat.com --- hw/core/qdev.c |4 include/hw/qdev-core.h | 12 2 files changed, 16 insertions(+), 0 deletions(-) diff --git a/hw/core/qdev.c b/hw/core/qdev.c index 82a9123..c9f0c33 100644 --- a/hw/core/qdev.c +++ b/hw/core/qdev.c @@ -32,6 +32,7 @@ #include qapi/visitor.h #include qapi/qmp/qjson.h #include monitor/monitor.h +#include hw/hotplug.h int qdev_hotplug = 0; static bool qdev_hot_added = false; @@ -870,6 +871,9 @@ static void qbus_initfn(Object *obj) BusState *bus = BUS(obj); QTAILQ_INIT(bus-children); +object_property_add_link(obj, QDEV_HOTPLUG_HANDLER_PROPERTY, + TYPE_HOTPLUG_HANDLER, + (Object **)bus-hotplug_handler, NULL); Will/should the user ever change that property? If not, we could drop this hunk and change the inline link-setting below to just do it the C way. Otherwise it should probably be using error_abort instead of NULL. Regards, Andreas } static char *default_bus_get_fw_dev_path(DeviceState *dev) diff --git a/include/hw/qdev-core.h b/include/hw/qdev-core.h index 2c4f140..41ec533 100644 --- a/include/hw/qdev-core.h +++ b/include/hw/qdev-core.h @@ -8,6 +8,7 @@ #include qom/object.h #include hw/irq.h #include qapi/error.h +#include hw/hotplug.h enum { DEV_NVECTORS_UNSPECIFIED = -1, @@ -180,14 +181,18 @@ typedef struct BusChild { QTAILQ_ENTRY(BusChild) sibling; } BusChild; +#define QDEV_HOTPLUG_HANDLER_PROPERTY hotplug-handler + /** * BusState: + * @hotplug_device: link to a hotplug device associated with bus. */ struct BusState { Object obj; DeviceState *parent; const char *name; int allow_hotplug; +HotplugHandler *hotplug_handler; int max_index; QTAILQ_HEAD(ChildrenHead, BusChild) children; QLIST_ENTRY(BusState) sibling; @@ -321,4 +326,11 @@ extern int qdev_hotplug; char *qdev_get_dev_path(DeviceState *dev); +static inline void qbus_set_hotplug_handler(BusState *bus, DeviceState *handler, +Error **errp) +{ +object_property_set_link(OBJECT(bus), OBJECT(handler), + QDEV_HOTPLUG_HANDLER_PROPERTY, errp); +bus-allow_hotplug = 1; +} #endif -- SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
Re: [Qemu-devel] [PATCH] Revert nand: Don't inherit from Sysbus
Il 05/02/2014 14:00, Peter Maydell ha scritto: While we're talking about regressions: Paolo, do we have a good fix for the PPC boot regression yet or should we revert the patch which caused that? Yes, Antony tested the patch on Xen. I'll send the patch as soon as possible. Paolo
Re: [Qemu-devel] [PATCH V15 12/13] quorum: Add quorum_open() and quorum_close().
Le Tuesday 04 Feb 2014 à 17:08:07 (+0100), Kevin Wolf a écrit : Am 03.02.2014 um 22:51 hat Benoît Canet geschrieben: From: Benoît Canet ben...@irqsave.net Example of command line: -drive if=virtio,file.driver=quorum,\ file.children.0.file.filename=1.raw,\ file.children.0.node-name=1.raw,\ file.children.0.driver=raw,\ file.children.1.file.filename=2.raw,\ file.children.1.node-name=2.raw,\ file.children.1.driver=raw,\ file.children.2.file.filename=3.raw,\ file.children.2.node-name=3.raw,\ file.children.2.driver=raw,\ file.vote_threshold=2 file.blkverify=on with file.vote_threshold=2 and two files can be passed to emulated blkverify. Signed-off-by: Benoit Canet ben...@irqsave.net --- block/quorum.c | 171 +++ qapi-schema.json | 21 ++- 2 files changed, 191 insertions(+), 1 deletion(-) diff --git a/block/quorum.c b/block/quorum.c index 1e683f8..d2bea29 100644 --- a/block/quorum.c +++ b/block/quorum.c @@ -17,8 +17,12 @@ #include gnutls/crypto.h #include block/block_int.h #include qapi/qmp/qjson.h +#include qapi/qmp/types.h +#include qemu-common.h #define HASH_LENGTH 32 +#define KEY_PREFIX children. +#define KEY_FILENAME_SUFFIX .file.filename /* This union holds a vote hash value */ typedef union QuorumVoteValue { @@ -712,12 +716,179 @@ static bool quorum_recurse_is_first_non_filter(BlockDriverState *bs, return false; } +static int quorum_valid_threshold(int threshold, + int total, + Error **errp) +{ + +if (threshold 1) { +error_set(errp, QERR_INVALID_PARAMETER_VALUE, + vote-threshold, value = 1); +return -ERANGE; +} + +if (threshold total) { +error_setg(errp, threshold may not exceed children count); +return -ERANGE; +} + +return 0; +} + +static int quorum_open(BlockDriverState *bs, + QDict *options, + int flags, + Error **errp) +{ +BDRVQuorumState *s = bs-opaque; +Error *local_err = NULL; +bool *opened; +QDict *sub = NULL; +QList *list = NULL; +const QListEntry *lentry; +const QDictEntry *dentry; +const char *value; +char *next; +int i; +int ret = 0; +unsigned long long threshold = 0; + +qdict_flatten(options); +qdict_extract_subqdict(options, sub, children.); +qdict_array_split(sub, list); + +/* count how many different children are present and validate */ +s-total = !qlist_size(list) ? qdict_size(sub) : qlist_size(list); Which case does qdict_size(sub) address? +if (s-total 2) { +error_setg(local_err, + Number of provided children must be greater than 1); +ret = -EINVAL; +goto exit; +} + +ret = qdict_get_try_int(options, vote-threshold, -1); +/* from QMP */ +if (ret != -1) { +qdict_del(options, vote-threshold); +s-threshold = ret; +/* from command line */ +} else { +/* retrieve the threshold option from the command line */ +value = qdict_get_try_str(options, vote_threshold); +if (!value) { +error_setg(local_err, + vote_threshold must be provided); +ret = -EINVAL; +goto exit; +} +qdict_del(options, vote_threshold); + +ret = parse_uint(value, threshold, next, 10); + +/* no int found - scan fail */ +if (ret 0) { +error_setg(local_err, + invalid vote_threshold specified); +ret = -EINVAL; +goto exit; +} +s-threshold = threshold; +} This part looks seriously wrong. I think you should consider using an QemuOpts like other drivers do (have a look at qcow2, for example), that should parse the integer for you. +/* and validate it against s-total */ +ret = quorum_valid_threshold(s-threshold, s-total, local_err); +if (ret 0) { +goto exit; +} + +/* is the driver in blkverify mode */ +value = qdict_get_try_str(options, blkverify); +if (value !strcmp(value, on) +s-total == 2 s-threshold == 2) { +s-is_blkverify = true; +} else if (value strcmp(value, off)) { +fprintf(stderr, blkverify mode is set by setting blkverify=on +and using two files with vote_threshold=2\n); +} +qdict_del(options, blkverify); And the QemuOpts would also know how to parse a boolean. + +/* allocate the children BlockDriverState array */ +s-bs = g_new0(BlockDriverState *, s-total); +opened = g_new0(bool,
Re: [Qemu-devel] [Qemu-ppc] [V2 PATCH 6/9] target-ppc: Load Quadword
On 2/5/2014 3:43 AM, Alexander Graf wrote: I would've expected the compiler to emit a warning at this point because you're declaring variables outside of the beginning of a scope? I did not see a warning on either of my test platforms (PowerPC/RHEL/GCC 4.4.7, Intel/Ubuntu/GCC 4.6.3). But I will certainly fix.
Re: [Qemu-devel] [PATCH qom-cpu 00/16 v10] target-i386: convert CPU features into properties
Am 05.02.2014 15:40, schrieb Igor Mammedov: On Sun, 15 Dec 2013 23:50:47 +0100 Andreas Färber afaer...@suse.de wrote: Am 27.11.2013 23:28, schrieb Igor Mammedov: Igor Mammedov (16): target-i386: cleanup 'foo' feature handling' target-i386: cleanup 'foo=val' feature handling Thanks, I've queued these on qom-cpu-next: https://github.com/afaerber/qemu-cpu/commits/qom-cpu-next target-i386: cpu: convert 'level' to static property target-i386: cpu: convert 'xlevel' to static property target-i386: cpu: convert 'family' to static property target-i386: cpu: convert 'model' to static property target-i386: cpu: convert 'stepping' to static property target-i386: cpu: convert 'vendor' to static property target-i386: cpu: convert 'model-id' to static property target-i386: cpu: convert 'tsc-frequency' to static property But I still don't see the utility of this conversion after all the discussions we've had... :( It seems there is movement to make DEVICE self describing for purpose of QAPI schema introspection, where static properties would be used (dynamic ones are not suitable for this purpose) Do you have a pointer to such a discussion? Sounds like I was not involved and Anthony probably not either... Andreas -- SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
Re: [Qemu-devel] [Qemu-ppc] [V2 PATCH 9/9] target-ppc: Add Store Quadword Conditional
On 2/5/2014 3:48 AM, Alexander Graf wrote: Does this work? After this val contains reserve_val2, but further down that one gets checked against reserve_val so the comparison is broken, no? Yes. I believe you are correct. Thanks, Alex.
Re: [Qemu-devel] [Qemu-ppc] [V2 PATCH 6/9] target-ppc: Load Quadword
On 02/05/2014 09:12 AM, Tom Musta wrote: On 2/5/2014 3:43 AM, Alexander Graf wrote: I would've expected the compiler to emit a warning at this point because you're declaring variables outside of the beginning of a scope? Only if you enforce C89 compilation. But qemu requires a C99 compiler, where it is not a warning in gcc unless you enable -Wjump-misses-init and have a goto statement that bypasses the declaration. I did not see a warning on either of my test platforms (PowerPC/RHEL/GCC 4.4.7, Intel/Ubuntu/GCC 4.6.3). But I will certainly fix. Whether or not the compiler enforces it, some projects still like to stick to C89 declarations-before-statements, even when otherwise requiring C99 compiler features. -- Eric Blake eblake redhat com+1-919-301-3266 Libvirt virtualization library http://libvirt.org signature.asc Description: OpenPGP digital signature
Re: [Qemu-devel] [PATCH V15 09/13] quorum: Add quorum_co_get_block_status.
Le Tuesday 04 Feb 2014 à 16:49:22 (+0100), Kevin Wolf a écrit : Am 03.02.2014 um 22:51 hat Benoît Canet geschrieben: From: Benoît Canet ben...@irqsave.net Signed-off-by: Benoit Canet ben...@irqsave.net Reviewed-by: Max Reitz mre...@redhat.com --- block/quorum.c | 51 +++ 1 file changed, 51 insertions(+) diff --git a/block/quorum.c b/block/quorum.c index cef4424..677a96d 100644 --- a/block/quorum.c +++ b/block/quorum.c @@ -619,6 +619,56 @@ static void quorum_invalidate_cache(BlockDriverState *bs) } } +static int64_t coroutine_fn quorum_co_get_block_status(BlockDriverState *bs, + int64_t sector_num, + int nb_sectors, + int *pnum) +{ +BDRVQuorumState *s = bs-opaque; +QuorumVoteVersion *winner = NULL; +QuorumVotes result_votes, num_votes; +QuorumVoteValue result_value, num_value; +int i, num; +int64_t result = 0; + +QLIST_INIT(result_votes.vote_list); +QLIST_INIT(num_votes.vote_list); +result_votes.compare = quorum_64bits_compare; +num_votes.compare = quorum_64bits_compare; + +for (i = 0; i s-total; i++) { +result = bdrv_get_block_status(s-bs[i], sector_num, nb_sectors, num); +/* skip failed requests */ +if (result 0) { +continue; +} +result_value.l = result BDRV_BLOCK_DATA; +num_value.l = num; +quorum_count_vote(result_votes, result_value, i); +quorum_count_vote(num_votes, num_value, i); +} This doesn't work. bdrv_get_block_status() doesn't guarantee that it returns all consecutive blocks with the same status. You need to call it in a loop here, or change bdrv_get_block_status() so that it loops itself. I don't see what can be done with the results generated by the loop. Does quorum really need this function ? Best regards Benoît +winner = quorum_get_vote_winner(result_votes); +if (winner-vote_count s-threshold) { +result = -EIO; +goto free_exit; +} +result = winner-value.l; + +winner = quorum_get_vote_winner(num_votes); +if (winner-vote_count s-threshold) { +result = -EIO; +goto free_exit; +} +*pnum = winner-value.l; You can take the status from one group of devices and the number of blocks that share this state from another group?! + +free_exit: +quorum_free_vote_list(result_votes); +quorum_free_vote_list(num_votes); + +return result; +} + static BlockDriver bdrv_quorum = { .format_name= quorum, .protocol_name = quorum, @@ -630,6 +680,7 @@ static BlockDriver bdrv_quorum = { .bdrv_aio_readv = quorum_aio_readv, .bdrv_aio_writev= quorum_aio_writev, .bdrv_invalidate_cache = quorum_invalidate_cache, +.bdrv_co_get_block_status = quorum_co_get_block_status, }; static void bdrv_quorum_init(void) Kevin
Re: [Qemu-devel] [PATCH v6 2/9] qdev: add to BusState hotplug-handler link
On Wed, 05 Feb 2014 16:52:27 +0100 Andreas Färber afaer...@suse.de wrote: Am 05.02.2014 16:36, schrieb Igor Mammedov: It will allow to reuse field with different BUSes, reducing code duplication. Field is intended for replacing 'hotplug_qdev' field in PCIBus and also will allow to avoid adding equivalent field to DimmBus with possiblitity to refactor other BUSes to use it instead of custom field. In addition once all users of allow_hotplug field are converted to new API, link could replace allow_hotplug field in qdev hotplug code. Signed-off-by: Igor Mammedov imamm...@redhat.com --- hw/core/qdev.c |4 include/hw/qdev-core.h | 12 2 files changed, 16 insertions(+), 0 deletions(-) diff --git a/hw/core/qdev.c b/hw/core/qdev.c index 82a9123..c9f0c33 100644 --- a/hw/core/qdev.c +++ b/hw/core/qdev.c @@ -32,6 +32,7 @@ #include qapi/visitor.h #include qapi/qmp/qjson.h #include monitor/monitor.h +#include hw/hotplug.h int qdev_hotplug = 0; static bool qdev_hot_added = false; @@ -870,6 +871,9 @@ static void qbus_initfn(Object *obj) BusState *bus = BUS(obj); QTAILQ_INIT(bus-children); +object_property_add_link(obj, QDEV_HOTPLUG_HANDLER_PROPERTY, + TYPE_HOTPLUG_HANDLER, + (Object **)bus-hotplug_handler, NULL); Will/should the user ever change that property? If not, we could drop this hunk and change the inline link-setting below to just do it the C way. Otherwise it should probably be using error_abort instead of NULL. So far user is expected to set property only one time. But why deviate from QOM an allow user to poke directly into arbitrary bus internals even with help of inline helper below? Link also will allow to keep pointer safe, i.e. hotplug_handler won't disappear suddenly. As for using error_abort in initfn(), this function might be called during hotplug and crash running guest. One way to handle such errors could be passing errp to initfn(), another is shown is this patch: i.e. ignore error in initfn() as it's done in other initfn()-s and handle error at set time in qbus_set_hotplug_handler(), then caller can decide whether do abort or report error up the call stack, i.e. to libvirt via QMP. Regards, Andreas } static char *default_bus_get_fw_dev_path(DeviceState *dev) diff --git a/include/hw/qdev-core.h b/include/hw/qdev-core.h index 2c4f140..41ec533 100644 --- a/include/hw/qdev-core.h +++ b/include/hw/qdev-core.h @@ -8,6 +8,7 @@ #include qom/object.h #include hw/irq.h #include qapi/error.h +#include hw/hotplug.h enum { DEV_NVECTORS_UNSPECIFIED = -1, @@ -180,14 +181,18 @@ typedef struct BusChild { QTAILQ_ENTRY(BusChild) sibling; } BusChild; +#define QDEV_HOTPLUG_HANDLER_PROPERTY hotplug-handler + /** * BusState: + * @hotplug_device: link to a hotplug device associated with bus. */ struct BusState { Object obj; DeviceState *parent; const char *name; int allow_hotplug; +HotplugHandler *hotplug_handler; int max_index; QTAILQ_HEAD(ChildrenHead, BusChild) children; QLIST_ENTRY(BusState) sibling; @@ -321,4 +326,11 @@ extern int qdev_hotplug; char *qdev_get_dev_path(DeviceState *dev); +static inline void qbus_set_hotplug_handler(BusState *bus, DeviceState *handler, +Error **errp) +{ +object_property_set_link(OBJECT(bus), OBJECT(handler), + QDEV_HOTPLUG_HANDLER_PROPERTY, errp); +bus-allow_hotplug = 1; +} #endif -- SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg -- Regards, Igor
Re: [Qemu-devel] [PATCH] pc_piix: enable legacy hotplug for Xen
On Tue, 4 Feb 2014, Sander Eikelenboom wrote: Tuesday, February 4, 2014, 10:55:18 PM, you wrote: Il 04/02/2014 22:32, Michael S. Tsirkin ha scritto: xenfv has no fwcfg and so does not load acpi from QEMU. as such new acpi features don't work. Reported-by: Sander Eikelenboom li...@eikelenboom.it Signed-off-by: Michael S. Tsirkin m...@redhat.com --- Sander, could you pleas econfirm this works for you? Yes this works for me (still on top of the debug patches + pull of the branch igor mentoined), but without -global PIIX4_PM.acpi-pci-hotplug-with-bridge-support=off: No fw cfg. Bailing out. bsel: 0, bus: pci.0 bsel: 0, bus: pci.0 bsel: 0, bus: pci.0 bsel: 0, bus: pci.0 Sander, thanks for testing and reporting the issue in the first place. Just to be clear: does the patch fix PCI passthrough completely or do you still need to pass -global PIIX4_PM.acpi-pci-hotplug-with-bridge-support=off? Sorry but I couldn't quite understand your reply. -- Sander Also, Xen really should switch to fw cfg some day ... Yeah, especially because nowadays -M pc works with Xen. It would be nice if fw_cfg could be enabled even for Xen on all machines except the legacy -M xenfv. Stefano, could you give it a shot now that you'll be soon done with 4.4? Paolo hw/i386/pc_piix.c | 11 +++ 1 file changed, 11 insertions(+) diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c index a327d71..1acd2b2 100644 --- a/hw/i386/pc_piix.c +++ b/hw/i386/pc_piix.c @@ -793,6 +793,17 @@ static QEMUMachine xenfv_machine = { .max_cpus = HVM_MAX_VCPUS, .default_machine_opts = accel=xen, .hot_add_cpu = pc_hot_add_cpu, +.compat_props = (GlobalProperty[]) { +/* xenfv has no fwcfg and so does not load acpi from QEMU. + * as such new acpi features don't work. + */ +{ +.driver = PIIX4_PM, +.property = acpi-pci-hotplug-with-bridge-support, +.value= off, +}, +{ /* end of list */ } +}, }; #endif
Re: [Qemu-devel] migration: broken ram_save_pending
Il 05/02/2014 10:09, Dr. David Alan Gilbert ha scritto: I think the case Alexey is hitting is: 1 A few dirtied pages 2 but because of the hpratio most of the data is actually zero - indeed most of the target-page sized chunks are zero 3 Thus the data compresses very heavily 4 When the bandwidth/delay calculation happens it's spent a reasonable amount of time transferring a reasonable amount of pages but not actually many bytes on the wire, so the estimate of the available bandwidth available is lower than reality. 5 The max-downtime calculation is a comparison of pending-dirty uncompressed bytes with compressed bandwidth (5) is bound to fail if the compression ratio is particularly high, which because of the hpratio it is if we're just dirtying one word in an entire host page. So far so good, but why isn't pending-dirty (aka migration_dirty_pages in the code) zero? Paolo
Re: [Qemu-devel] [PATCH 00/12] qdev: cleanup legacy properties
Il 05/02/2014 12:12, Igor Mammedov ha scritto: with fixed checkpatch error in 13/12 Reviewed-By: Igor Mammedov imamm...@redhat.com Andreas, can you ack it so that I can send a pull request myself? Thanks, Paolo
Re: [Qemu-devel] [PULL 0/8] Block patches
On 31 January 2014 21:19, Stefan Hajnoczi stefa...@redhat.com wrote: The following changes since commit 89e4a51ca9546a7bbe1998c4e3d4a3ac3a0c19be: Merge remote-tracking branch 'stefanha/tags/tracing-pull-request' into staging (2014-01-31 11:13:08 +) are available in the git repository at: git://github.com/stefanha/qemu.git tags/block-pull-request for you to fetch changes up to 1b7650ef2f63d53cf89af25a9f323323cf2423a7: qemu-iotests: only run 071 on qcow2 (2014-01-31 22:05:03 +0100) Applied, thanks. -- PMM
Re: [Qemu-devel] [PATCH] qdev: Fix qdev_try_create() for bus-less devices
Il 05/02/2014 15:09, Andreas Färber ha scritto: diff --git a/hw/core/qdev.c b/hw/core/qdev.c index 82a9123..14c8765 100644 --- a/hw/core/qdev.c +++ b/hw/core/qdev.c @@ -131,21 +131,27 @@ DeviceState *qdev_create(BusState *bus, const char *name) DeviceState *qdev_try_create(BusState *bus, const char *type) { DeviceState *dev; +ObjectClass *oc; +DeviceClass *dc; -if (object_class_by_name(type) == NULL) { +oc = object_class_by_name(type); +if (oc == NULL) { return NULL; } +dc = DEVICE_CLASS(oc); dev = DEVICE(object_new(type)); if (!dev) { return NULL; } -if (!bus) { +if (!bus dc-bus_type strcmp(dc-bus_type, System) == 0) { Should you check instead if dev is-a TYPE_SYSBUS_DEVICE? Does this also leave the nand device out of info qtree, or is it still dumped? Paolo bus = sysbus_get_default(); } -qdev_set_parent_bus(dev, bus); -object_unref(OBJECT(dev)); +if (bus != NULL) { +qdev_set_parent_bus(dev, bus); +object_unref(OBJECT(dev)); +} return dev; }
Re: [Qemu-devel] [PATCH 00/12] qdev: cleanup legacy properties
Am 05.02.2014 17:36, schrieb Paolo Bonzini: Il 05/02/2014 12:12, Igor Mammedov ha scritto: with fixed checkpatch error in 13/12 Reviewed-By: Igor Mammedov imamm...@redhat.com Andreas, can you ack it so that I can send a pull request myself? Since I just raised a question I cannot ack it yet. ;) But I can queue them when we're through (or did I miss something non-qdev?). On the other hand I'd appreciate if you could review Edgar's address space patches since that series starts with memory API refactorings. Regards, Andreas -- SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
Re: [Qemu-devel] [PATCH] pc_piix: enable legacy hotplug for Xen
On Tue, 4 Feb 2014, Paolo Bonzini wrote: Il 04/02/2014 22:32, Michael S. Tsirkin ha scritto: xenfv has no fwcfg and so does not load acpi from QEMU. as such new acpi features don't work. Reported-by: Sander Eikelenboom li...@eikelenboom.it Signed-off-by: Michael S. Tsirkin m...@redhat.com --- Sander, could you pleas econfirm this works for you? Also, Xen really should switch to fw cfg some day ... Yeah, especially because nowadays -M pc works with Xen. It would be nice if fw_cfg could be enabled even for Xen on all machines except the legacy -M xenfv. Stefano, could you give it a shot now that you'll be soon done with 4.4? It might not be that straightforward as Xen emulates some devices in the hypervisor and patches have been recently posted to support multiple device models for a single VM. hw/i386/pc_piix.c | 11 +++ 1 file changed, 11 insertions(+) diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c index a327d71..1acd2b2 100644 --- a/hw/i386/pc_piix.c +++ b/hw/i386/pc_piix.c @@ -793,6 +793,17 @@ static QEMUMachine xenfv_machine = { .max_cpus = HVM_MAX_VCPUS, .default_machine_opts = accel=xen, .hot_add_cpu = pc_hot_add_cpu, +.compat_props = (GlobalProperty[]) { +/* xenfv has no fwcfg and so does not load acpi from QEMU. + * as such new acpi features don't work. + */ +{ +.driver = PIIX4_PM, +.property = acpi-pci-hotplug-with-bridge-support, +.value= off, +}, +{ /* end of list */ } +}, }; #endif
Re: [Qemu-devel] migration: broken ram_save_pending
* Paolo Bonzini (pbonz...@redhat.com) wrote: Il 05/02/2014 10:09, Dr. David Alan Gilbert ha scritto: I think the case Alexey is hitting is: 1 A few dirtied pages 2 but because of the hpratio most of the data is actually zero - indeed most of the target-page sized chunks are zero 3 Thus the data compresses very heavily 4 When the bandwidth/delay calculation happens it's spent a reasonable amount of time transferring a reasonable amount of pages but not actually many bytes on the wire, so the estimate of the available bandwidth available is lower than reality. 5 The max-downtime calculation is a comparison of pending-dirty uncompressed bytes with compressed bandwidth (5) is bound to fail if the compression ratio is particularly high, which because of the hpratio it is if we're just dirtying one word in an entire host page. So far so good, but why isn't pending-dirty (aka migration_dirty_pages in the code) zero? Because: * the code is still running and keeps redirtying a small handful of pages * but because we've underestimated our available bandwidth we never stop it and just throw those pages across immediately Dave -- Dr. David Alan Gilbert / dgilb...@redhat.com / Manchester, UK
Re: [Qemu-devel] [PATCH] qdev: Fix qdev_try_create() for bus-less devices
Am 05.02.2014 17:38, schrieb Paolo Bonzini: Il 05/02/2014 15:09, Andreas Färber ha scritto: diff --git a/hw/core/qdev.c b/hw/core/qdev.c index 82a9123..14c8765 100644 --- a/hw/core/qdev.c +++ b/hw/core/qdev.c @@ -131,21 +131,27 @@ DeviceState *qdev_create(BusState *bus, const char *name) DeviceState *qdev_try_create(BusState *bus, const char *type) { DeviceState *dev; +ObjectClass *oc; +DeviceClass *dc; -if (object_class_by_name(type) == NULL) { +oc = object_class_by_name(type); +if (oc == NULL) { return NULL; } +dc = DEVICE_CLASS(oc); dev = DEVICE(object_new(type)); if (!dev) { return NULL; } -if (!bus) { +if (!bus dc-bus_type strcmp(dc-bus_type, System) == 0) { Should you check instead if dev is-a TYPE_SYSBUS_DEVICE? Hmm, that would catch TYPE_SYS_BUS_DEVICE-derived types as well, which might in theory override bus_type. The ugly thing here is the cyclic dependency betwen qdev and sysbus, therefore no TYPE_SYSTEM_BUS. Does this also leave the nand device out of info qtree, or is it still dumped? As I pointed out several times already, devices that are not on a bus are generally *not* printed by info qtree. It depends on the old qbus concept. Therefore info qtree is not of much use anymore and should be dropped in favor of the qom-list and qom-get operations, which get us all devices and all properties. I had once attached a qom-tree for that and need to put that into a proper patch. Best before the next question pops up. :) Andreas -- SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
Re: [Qemu-devel] [PATCH] pc_piix: enable legacy hotplug for Xen
Il 05/02/2014 17:41, Stefano Stabellini ha scritto: Yeah, especially because nowadays -M pc works with Xen. It would be nice if fw_cfg could be enabled even for Xen on all machines except the legacy -M xenfv. Stefano, could you give it a shot now that you'll be soon done with 4.4? It might not be that straightforward as Xen emulates some devices in the hypervisor and patches have been recently posted to support multiple device models for a single VM. I'm not sure how this is related to fw_cfg? fw_cfg is just a simple key-value store. If hvmloader doesn't use it, it should be a burden. Paolo
Re: [Qemu-devel] [PATCH v6 2/9] qdev: add to BusState hotplug-handler link
Il 05/02/2014 16:52, Andreas Färber ha scritto: +object_property_add_link(obj, QDEV_HOTPLUG_HANDLER_PROPERTY, + TYPE_HOTPLUG_HANDLER, + (Object **)bus-hotplug_handler, NULL); Will/should the user ever change that property? If not, we could drop this hunk and change the inline link-setting below to just do it the C way. Otherwise it should probably be using error_abort instead of NULL. No, they shouldn't. But OTOH it's probably useful in general to _read_ the property, and links handle reference counting nicely too. It's similar to the parent_bus link. I think we should add something like getter/setter for links like we have for object_property_add_str, because in most of the current cases the link should be read-only. It should not hold this series, though. Paolo
Re: [Qemu-devel] migration: broken ram_save_pending
Il 05/02/2014 17:42, Dr. David Alan Gilbert ha scritto: Because: * the code is still running and keeps redirtying a small handful of pages * but because we've underestimated our available bandwidth we never stop it and just throw those pages across immediately Ok, I thought Alexey was saying we are not redirtying that handful of pages. And in turn, this is because the max downtime we have is too low (especially for the default 32 MB/sec default bandwidth; that's also pretty low). Paolo
Re: [Qemu-devel] [PATCH] pc_piix: enable legacy hotplug for Xen
On Wed, 5 Feb 2014, Sander Eikelenboom wrote: On Tue, 4 Feb 2014, Sander Eikelenboom wrote: Tuesday, February 4, 2014, 10:55:18 PM, you wrote: Il 04/02/2014 22:32, Michael S. Tsirkin ha scritto: xenfv has no fwcfg and so does not load acpi from QEMU. as such new acpi features don't work. Reported-by: Sander Eikelenboom li...@eikelenboom.it Signed-off-by: Michael S. Tsirkin m...@redhat.com --- Sander, could you pleas econfirm this works for you? Yes this works for me (still on top of the debug patches + pull of the branch igor mentoined), but without -global PIIX4_PM.acpi-pci-hotplug-with-bridge-support=off: No fw cfg. Bailing out. bsel: 0, bus: pci.0 bsel: 0, bus: pci.0 bsel: 0, bus: pci.0 bsel: 0, bus: pci.0 Sander, thanks for testing and reporting the issue in the first place. Just to be clear: does the patch fix PCI passthrough completely or do you still need to pass -global PIIX4_PM.acpi-pci-hotplug-with-bridge-support=off? Sorry but I couldn't quite understand your reply. It's fixed with the patch, you don't need to pass that global parameter. (i only tested it with igor's upcoming branch and the debug-patches (printk's only) applied though) OK, that's fine, thanks. -- Sander Also, Xen really should switch to fw cfg some day ... Yeah, especially because nowadays -M pc works with Xen. It would be nice if fw_cfg could be enabled even for Xen on all machines except the legacy -M xenfv. Stefano, could you give it a shot now that you'll be soon done with 4.4? Paolo hw/i386/pc_piix.c | 11 +++ 1 file changed, 11 insertions(+) diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c index a327d71..1acd2b2 100644 --- a/hw/i386/pc_piix.c +++ b/hw/i386/pc_piix.c @@ -793,6 +793,17 @@ static QEMUMachine xenfv_machine = { .max_cpus = HVM_MAX_VCPUS, .default_machine_opts = accel=xen, .hot_add_cpu = pc_hot_add_cpu, +.compat_props = (GlobalProperty[]) { +/* xenfv has no fwcfg and so does not load acpi from QEMU. + * as such new acpi features don't work. + */ +{ +.driver = PIIX4_PM, +.property = acpi-pci-hotplug-with-bridge-support, +.value= off, +}, +{ /* end of list */ } +}, }; #endif
Re: [Qemu-devel] [PULL 0/7] Trivial patches for 2014-02-02
On 2 February 2014 16:12, Michael Tokarev m...@tls.msk.ru wrote: There's nothing exciting in there, some really small things here and there. Please pull. Thanks, /mjt The following changes since commit 89e4a51ca9546a7bbe1998c4e3d4a3ac3a0c19be: Merge remote-tracking branch 'stefanha/tags/tracing-pull-request' into staging (2014-01-31 11:13:08 +) are available in the git repository at: git://git.corpit.ru/qemu.git tags/trivial-patches-2014-02-02 for you to fetch changes up to b76afd1072e02fe77e09790fbe1e831700976c5f: tests/.gitignore: Ignore tests/check-qom-interface (2014-02-01 13:56:31 +0400) Applied, thanks. -- PMM
Re: [Qemu-devel] [PATCH qom-cpu 00/16 v10] target-i386: convert CPU features into properties
On Wed, 05 Feb 2014 17:14:27 +0100 Andreas Färber afaer...@suse.de wrote: Am 05.02.2014 15:40, schrieb Igor Mammedov: On Sun, 15 Dec 2013 23:50:47 +0100 Andreas Färber afaer...@suse.de wrote: Am 27.11.2013 23:28, schrieb Igor Mammedov: Igor Mammedov (16): target-i386: cleanup 'foo' feature handling' target-i386: cleanup 'foo=val' feature handling Thanks, I've queued these on qom-cpu-next: https://github.com/afaerber/qemu-cpu/commits/qom-cpu-next target-i386: cpu: convert 'level' to static property target-i386: cpu: convert 'xlevel' to static property target-i386: cpu: convert 'family' to static property target-i386: cpu: convert 'model' to static property target-i386: cpu: convert 'stepping' to static property target-i386: cpu: convert 'vendor' to static property target-i386: cpu: convert 'model-id' to static property target-i386: cpu: convert 'tsc-frequency' to static property But I still don't see the utility of this conversion after all the discussions we've had... :( It seems there is movement to make DEVICE self describing for purpose of QAPI schema introspection, where static properties would be used (dynamic ones are not suitable for this purpose) Do you have a pointer to such a discussion? Sounds like I was not involved and Anthony probably not either... Not at the moment, CCing people who might know more about the topic. But just thinking about creating QAPI schema for devices, it's not really possible to generate one using dynamic properties (unless one resorts to creating every supported device instance), while arrays of static properties are there for every device and simplistically speaking just need conversion to schema format. Andreas -- SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg -- Regards, Igor
Re: [Qemu-devel] [PATCH] pc_piix: enable legacy hotplug for Xen
On Wed, 5 Feb 2014, Paolo Bonzini wrote: Il 05/02/2014 17:41, Stefano Stabellini ha scritto: Yeah, especially because nowadays -M pc works with Xen. It would be nice if fw_cfg could be enabled even for Xen on all machines except the legacy -M xenfv. Stefano, could you give it a shot now that you'll be soon done with 4.4? It might not be that straightforward as Xen emulates some devices in the hypervisor and patches have been recently posted to support multiple device models for a single VM. I'm not sure how this is related to fw_cfg? fw_cfg is just a simple key-value store. If hvmloader doesn't use it, it should be a burden. I was referring to the fact that QEMU might not have all the info that need to be written to fw_cfg when running on Xen: some of the info might be in the hypervisor and some other in another QEMU instance. Or do you think that fw_cfg could be written by multiple entities simultaneously?
Re: [Qemu-devel] [PATCH] pc_piix: enable legacy hotplug for Xen
Wednesday, February 5, 2014, 5:35:32 PM, you wrote: On Tue, 4 Feb 2014, Sander Eikelenboom wrote: Tuesday, February 4, 2014, 10:55:18 PM, you wrote: Il 04/02/2014 22:32, Michael S. Tsirkin ha scritto: xenfv has no fwcfg and so does not load acpi from QEMU. as such new acpi features don't work. Reported-by: Sander Eikelenboom li...@eikelenboom.it Signed-off-by: Michael S. Tsirkin m...@redhat.com --- Sander, could you pleas econfirm this works for you? Yes this works for me (still on top of the debug patches + pull of the branch igor mentoined), but without -global PIIX4_PM.acpi-pci-hotplug-with-bridge-support=off: No fw cfg. Bailing out. bsel: 0, bus: pci.0 bsel: 0, bus: pci.0 bsel: 0, bus: pci.0 bsel: 0, bus: pci.0 Sander, thanks for testing and reporting the issue in the first place. Just to be clear: does the patch fix PCI passthrough completely or do you still need to pass -global PIIX4_PM.acpi-pci-hotplug-with-bridge-support=off? Sorry but I couldn't quite understand your reply. It's fixed with the patch, you don't need to pass that global parameter. (i only tested it with igor's upcoming branch and the debug-patches (printk's only) applied though) -- Sander Also, Xen really should switch to fw cfg some day ... Yeah, especially because nowadays -M pc works with Xen. It would be nice if fw_cfg could be enabled even for Xen on all machines except the legacy -M xenfv. Stefano, could you give it a shot now that you'll be soon done with 4.4? Paolo hw/i386/pc_piix.c | 11 +++ 1 file changed, 11 insertions(+) diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c index a327d71..1acd2b2 100644 --- a/hw/i386/pc_piix.c +++ b/hw/i386/pc_piix.c @@ -793,6 +793,17 @@ static QEMUMachine xenfv_machine = { .max_cpus = HVM_MAX_VCPUS, .default_machine_opts = accel=xen, .hot_add_cpu = pc_hot_add_cpu, +.compat_props = (GlobalProperty[]) { +/* xenfv has no fwcfg and so does not load acpi from QEMU. + * as such new acpi features don't work. + */ +{ +.driver = PIIX4_PM, +.property = acpi-pci-hotplug-with-bridge-support, +.value= off, +}, +{ /* end of list */ } +}, }; #endif
[Qemu-devel] [PATCH qom-next 5/5] tests: Add eepro100 qtest
Signed-off-by: Andreas Färber afaer...@suse.de --- tests/Makefile| 3 +++ tests/eepro100-test.c | 61 +++ 2 files changed, 64 insertions(+) create mode 100644 tests/eepro100-test.c diff --git a/tests/Makefile b/tests/Makefile index 867d931..4f9dd6d 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -72,6 +72,8 @@ gcov-files-pci-y += hw/net/rtl8139.c check-qtest-pci-y += tests/pcnet-test$(EXESUF) gcov-files-pci-y += hw/net/pcnet.c gcov-files-pci-y += hw/net/pcnet-pci.c +check-qtest-pci-y += tests/eepro100-test$(EXESUF) +gcov-files-pci-y += hw/net/eepro100.c check-qtest-i386-y = tests/endianness-test$(EXESUF) check-qtest-i386-y += tests/fdc-test$(EXESUF) @@ -214,6 +216,7 @@ tests/fw_cfg-test$(EXESUF): tests/fw_cfg-test.o $(libqos-pc-obj-y) tests/e1000-test$(EXESUF): tests/e1000-test.o tests/rtl8139-test$(EXESUF): tests/rtl8139-test.o tests/pcnet-test$(EXESUF): tests/pcnet-test.o +tests/eepro100-test$(EXESUF): tests/eepro100-test.o tests/vmxnet3-test$(EXESUF): tests/vmxnet3-test.o tests/qom-test$(EXESUF): tests/qom-test.o tests/blockdev-test$(EXESUF): tests/blockdev-test.o $(libqos-pc-obj-y) diff --git a/tests/eepro100-test.c b/tests/eepro100-test.c new file mode 100644 index 000..4d1dea9 --- /dev/null +++ b/tests/eepro100-test.c @@ -0,0 +1,61 @@ +/* + * QTest testcase for eepro100 NIC + * + * Copyright (c) 2013-2014 SUSE LINUX Products GmbH + * + * This work is licensed under the terms of the GNU GPL, version 2 or later. + * See the COPYING file in the top-level directory. + */ +#include libqtest.h + +#include glib.h +#include string.h +#include qemu/osdep.h + +static void test_nop(gconstpointer data) +{ +const char *model = data; +QTestState *s; +char *args; + +args = g_strdup_printf(-device %s, model); +s = qtest_start(args); + +if (s) { +qtest_quit(s); +} +g_free(args); +} + +static const char *models[] = { +i82550, +i82551, +i82557a, +i82557b, +i82557c, +i82558a, +i82558b, +i82559a, +i82559b, +i82559c, +i82559er, +i82562, +i82801, +}; + +int main(int argc, char **argv) +{ +int i; + +g_test_init(argc, argv, NULL); + +for (i = 0; i ARRAY_SIZE(models); i++) { +char *path; + +path = g_strdup_printf(/%s/eepro100/%s/nop, + qtest_get_arch(), models[i]); +g_test_add_data_func(path, models[i], test_nop); +} + +return g_test_run(); +} -- 1.8.4.5
[Qemu-devel] [PATCH qom-next 0/5] qtest: Prepare PCI NIC tests
Hello Stefan, As discussed late last year, this series starts preparing tests to cover optional NICs. They don't do any functional tests but assure that QOM/PCI refactorings don't break the basic usage of these devices. pcnet-test.c is intended to handle sparc's lance as well. virtio-net is missing among others (is there any ongoing work on virtio qtests?!), but I thought I'd get this out as a start. My goal will be to have every optional device in 2.0 covered by such basic tests. Hopefully it will also encourage people to write functional tests later on and to copy these stubs for new devices! Regards, Andreas Cc: Stefan Hajnoczi stefa...@redhat.com Cc: Anthony Liguori anth...@codemonkey.ws Cc: Paolo Bonzini pbonz...@redhat.com Cc: Peter Maydell peter.mayd...@linaro.org Andreas Färber (5): tests: Add e1000 qtest tests: Add vmxnet3 qtest tests: Add rtl8139 qtest tests: Add PC-Net qtest tests: Add eepro100 qtest tests/Makefile| 22 +++ tests/e1000-test.c| 35 + tests/eepro100-test.c | 61 +++ tests/pcnet-test.c| 35 + tests/rtl8139-test.c | 35 + tests/vmxnet3-test.c | 35 + 6 files changed, 223 insertions(+) create mode 100644 tests/e1000-test.c create mode 100644 tests/eepro100-test.c create mode 100644 tests/pcnet-test.c create mode 100644 tests/rtl8139-test.c create mode 100644 tests/vmxnet3-test.c -- 1.8.4.5
[Qemu-devel] [PATCH 2/4] virtio-mmio: introduce set_guest_notifiers
Same as host notifier of virtio-mmio, most of codes came from virtio-pci. The kvm-arm does not yet support irqfd, need to fix the hard-coded part after kvm-arm gets irqfd support. Signed-off-by: Ying-Shiuan Pan ys...@itri.org.tw --- hw/virtio/virtio-mmio.c | 60 + 1 file changed, 60 insertions(+) diff --git a/hw/virtio/virtio-mmio.c b/hw/virtio/virtio-mmio.c index 558fd2f..f95b7dd 100644 --- a/hw/virtio/virtio-mmio.c +++ b/hw/virtio/virtio-mmio.c @@ -396,6 +396,65 @@ static void virtio_mmio_reset(DeviceState *d) proxy-guest_page_shift = 0; } +static int virtio_mmio_set_guest_notifier(DeviceState *d, int n, bool assign, + bool with_irqfd) +{ +VirtIOMMIOProxy *proxy = VIRTIO_MMIO(d); +VirtIODevice *vdev = virtio_bus_get_device(proxy-bus); +VirtioDeviceClass *vdc = VIRTIO_DEVICE_GET_CLASS(vdev); +VirtQueue *vq = virtio_get_queue(vdev, n); +EventNotifier *notifier = virtio_queue_get_guest_notifier(vq); + +if (assign) { +int r = event_notifier_init(notifier, 0); +if (r 0) { +return r; +} +virtio_queue_set_guest_notifier_fd_handler(vq, true, with_irqfd); +} else { +virtio_queue_set_guest_notifier_fd_handler(vq, false, with_irqfd); +event_notifier_cleanup(notifier); +} + +if (vdc-guest_notifier_mask) { +vdc-guest_notifier_mask(vdev, n, !assign); +} + +return 0; +} + +static int virtio_mmio_set_guest_notifiers(DeviceState *d, int nvqs, bool assign) +{ +VirtIOMMIOProxy *proxy = VIRTIO_MMIO(d); +VirtIODevice *vdev = virtio_bus_get_device(proxy-bus); +/* TODO: need to check if kvm-arm supports irqfd */ +bool with_irqfd = false; +int r, n; + +nvqs = MIN(nvqs, VIRTIO_PCI_QUEUE_MAX); + +for (n = 0; n nvqs; n++) { +if (!virtio_queue_get_num(vdev, n)) { +break; +} + +r = virtio_mmio_set_guest_notifier(d, n, assign, with_irqfd); +if (r 0) { +goto assign_error; +} +} + +return 0; + +assign_error: +/* We get here on assignment failure. Recover by undoing for VQs 0 .. n. */ +assert(assign); +while (--n = 0) { +virtio_mmio_set_guest_notifier(d, n, !assign, false); +} +return r; +} + static int virtio_mmio_set_host_notifier(DeviceState *opaque, int n, bool assign) { VirtIOMMIOProxy *proxy = VIRTIO_MMIO(opaque); @@ -476,6 +535,7 @@ static void virtio_mmio_bus_class_init(ObjectClass *klass, void *data) k-save_config = virtio_mmio_save_config; k-load_config = virtio_mmio_load_config; k-set_host_notifier = virtio_mmio_set_host_notifier; +k-set_guest_notifiers = virtio_mmio_set_guest_notifiers; k-get_features = virtio_mmio_get_features; k-device_plugged = virtio_mmio_device_plugged; k-has_variable_vring_alignment = true; -- 1.8.1.2
[Qemu-devel] [PATCH qom-next 1/5] tests: Add e1000 qtest
Cc: Stefan Hajnoczi stefa...@redhat.com Signed-off-by: Andreas Färber afaer...@suse.de --- tests/Makefile | 7 +++ tests/e1000-test.c | 35 +++ 2 files changed, 42 insertions(+) create mode 100644 tests/e1000-test.c diff --git a/tests/Makefile b/tests/Makefile index 42a52ff..57e21fc 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -64,6 +64,10 @@ check-block-$(CONFIG_POSIX) += tests/qemu-iotests-quick.sh # All QTests for now are POSIX-only, but the dependencies are # really in libqtest, not in the testcases themselves. + +check-qtest-pci-y += tests/e1000-test$(EXESUF) +gcov-files-pci-y += hw/net/e1000.c + check-qtest-i386-y = tests/endianness-test$(EXESUF) check-qtest-i386-y += tests/fdc-test$(EXESUF) gcov-files-i386-y = hw/fdc.c @@ -77,6 +81,8 @@ check-qtest-i386-y += tests/i440fx-test$(EXESUF) check-qtest-i386-y += tests/fw_cfg-test$(EXESUF) check-qtest-i386-y += tests/blockdev-test$(EXESUF) check-qtest-i386-y += tests/qdev-monitor-test$(EXESUF) +check-qtest-i386-y += $(check-qtest-pci-y) +gcov-files-i386-y += $(gcov-files-pci-y) check-qtest-x86_64-y = $(check-qtest-i386-y) gcov-files-i386-y += i386-softmmu/hw/mc146818rtc.c gcov-files-x86_64-y = $(subst i386-softmmu/,x86_64-softmmu/,$(gcov-files-i386-y)) @@ -196,6 +202,7 @@ tests/acpi-test$(EXESUF): tests/acpi-test.o $(libqos-obj-y) tests/tmp105-test$(EXESUF): tests/tmp105-test.o $(libqos-omap-obj-y) tests/i440fx-test$(EXESUF): tests/i440fx-test.o $(libqos-pc-obj-y) tests/fw_cfg-test$(EXESUF): tests/fw_cfg-test.o $(libqos-pc-obj-y) +tests/e1000-test$(EXESUF): tests/e1000-test.o tests/qom-test$(EXESUF): tests/qom-test.o tests/blockdev-test$(EXESUF): tests/blockdev-test.o $(libqos-pc-obj-y) tests/qdev-monitor-test$(EXESUF): tests/qdev-monitor-test.o $(libqos-pc-obj-y) diff --git a/tests/e1000-test.c b/tests/e1000-test.c new file mode 100644 index 000..a053703 --- /dev/null +++ b/tests/e1000-test.c @@ -0,0 +1,35 @@ +/* + * QTest testcase for e1000 NIC + * + * Copyright (c) 2013-2014 SUSE LINUX Products GmbH + * + * This work is licensed under the terms of the GNU GPL, version 2 or later. + * See the COPYING file in the top-level directory. + */ +#include libqtest.h + +#include glib.h +#include string.h +#include qemu/osdep.h + +static void nop(void) +{ +} + +int main(int argc, char **argv) +{ +QTestState *s; +int ret; + +g_test_init(argc, argv, NULL); +qtest_add_func(/e1000/nop, nop); + +s = qtest_start(-device e1000); +ret = g_test_run(); + +if (s) { +qtest_quit(s); +} + +return ret; +} -- 1.8.4.5
[Qemu-devel] [PATCH 3/4] virtio-mmio: start ioeventfd when status gets DRIVER_OK
Signed-off-by: Ying-Shiuan Pan ys...@itri.org.tw --- hw/virtio/virtio-mmio.c | 45 + 1 file changed, 45 insertions(+) diff --git a/hw/virtio/virtio-mmio.c b/hw/virtio/virtio-mmio.c index f95b7dd..11964ee 100644 --- a/hw/virtio/virtio-mmio.c +++ b/hw/virtio/virtio-mmio.c @@ -122,6 +122,42 @@ static int virtio_mmio_set_host_notifier_internal(VirtIOMMIOProxy *proxy, return r; } +static void virtio_mmio_start_ioeventfd(VirtIOMMIOProxy *proxy) +{ +VirtIODevice *vdev = virtio_bus_get_device(proxy-bus); +int n, r; + +if (proxy-ioeventfd_disabled || +proxy-ioeventfd_started) { +return; +} + +for (n = 0; n VIRTIO_PCI_QUEUE_MAX; n++) { +if (!virtio_queue_get_num(vdev, n)) { +continue; +} + +r = virtio_mmio_set_host_notifier_internal(proxy, n, true, true); +if (r 0) { +goto assign_error; +} +} +proxy-ioeventfd_started = true; +return; + +assign_error: +while (--n = 0) { +if (!virtio_queue_get_num(vdev, n)) { +continue; +} + +r = virtio_mmio_set_host_notifier_internal(proxy, n, false, false); +assert(r = 0); +} +proxy-ioeventfd_started = false; +error_report(%s: failed. Fallback to a userspace (slower)., __func__); +} + static void virtio_mmio_stop_ioeventfd(VirtIOMMIOProxy *proxy) { int r; @@ -320,7 +356,16 @@ static void virtio_mmio_write(void *opaque, hwaddr offset, uint64_t value, virtio_update_irq(vdev); break; case VIRTIO_MMIO_STATUS: +if (!(value VIRTIO_CONFIG_S_DRIVER_OK)) { +virtio_mmio_stop_ioeventfd(proxy); +} + virtio_set_status(vdev, value 0xff); + +if (value VIRTIO_CONFIG_S_DRIVER_OK) { +virtio_mmio_start_ioeventfd(proxy); +} + if (vdev-status == 0) { virtio_reset(vdev); } -- 1.8.1.2
[Qemu-devel] [PATCH qom-next 3/5] tests: Add rtl8139 qtest
Signed-off-by: Andreas Färber afaer...@suse.de --- tests/Makefile | 3 +++ tests/rtl8139-test.c | 35 +++ 2 files changed, 38 insertions(+) create mode 100644 tests/rtl8139-test.c diff --git a/tests/Makefile b/tests/Makefile index 323c600..eabdf98 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -67,6 +67,8 @@ check-block-$(CONFIG_POSIX) += tests/qemu-iotests-quick.sh check-qtest-pci-y += tests/e1000-test$(EXESUF) gcov-files-pci-y += hw/net/e1000.c +check-qtest-pci-y += tests/rtl8139-test$(EXESUF) +gcov-files-pci-y += hw/net/rtl8139.c check-qtest-i386-y = tests/endianness-test$(EXESUF) check-qtest-i386-y += tests/fdc-test$(EXESUF) @@ -207,6 +209,7 @@ tests/tmp105-test$(EXESUF): tests/tmp105-test.o $(libqos-omap-obj-y) tests/i440fx-test$(EXESUF): tests/i440fx-test.o $(libqos-pc-obj-y) tests/fw_cfg-test$(EXESUF): tests/fw_cfg-test.o $(libqos-pc-obj-y) tests/e1000-test$(EXESUF): tests/e1000-test.o +tests/rtl8139-test$(EXESUF): tests/rtl8139-test.o tests/vmxnet3-test$(EXESUF): tests/vmxnet3-test.o tests/qom-test$(EXESUF): tests/qom-test.o tests/blockdev-test$(EXESUF): tests/blockdev-test.o $(libqos-pc-obj-y) diff --git a/tests/rtl8139-test.c b/tests/rtl8139-test.c new file mode 100644 index 000..ecce1b2 --- /dev/null +++ b/tests/rtl8139-test.c @@ -0,0 +1,35 @@ +/* + * QTest testcase for Realtek 8139 NIC + * + * Copyright (c) 2013-2014 SUSE LINUX Products GmbH + * + * This work is licensed under the terms of the GNU GPL, version 2 or later. + * See the COPYING file in the top-level directory. + */ +#include libqtest.h + +#include glib.h +#include string.h +#include qemu/osdep.h + +static void nop(void) +{ +} + +int main(int argc, char **argv) +{ +QTestState *s; +int ret; + +g_test_init(argc, argv, NULL); +qtest_add_func(/rtl8139/nop, nop); + +s = qtest_start(-device rtl8139); +ret = g_test_run(); + +if (s) { +qtest_quit(s); +} + +return ret; +} -- 1.8.4.5
[Qemu-devel] [PATCH qom-next 4/5] tests: Add PC-Net qtest
Test PCI only for now. Signed-off-by: Andreas Färber afaer...@suse.de --- tests/Makefile | 4 tests/pcnet-test.c | 35 +++ 2 files changed, 39 insertions(+) create mode 100644 tests/pcnet-test.c diff --git a/tests/Makefile b/tests/Makefile index eabdf98..867d931 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -69,6 +69,9 @@ check-qtest-pci-y += tests/e1000-test$(EXESUF) gcov-files-pci-y += hw/net/e1000.c check-qtest-pci-y += tests/rtl8139-test$(EXESUF) gcov-files-pci-y += hw/net/rtl8139.c +check-qtest-pci-y += tests/pcnet-test$(EXESUF) +gcov-files-pci-y += hw/net/pcnet.c +gcov-files-pci-y += hw/net/pcnet-pci.c check-qtest-i386-y = tests/endianness-test$(EXESUF) check-qtest-i386-y += tests/fdc-test$(EXESUF) @@ -210,6 +213,7 @@ tests/i440fx-test$(EXESUF): tests/i440fx-test.o $(libqos-pc-obj-y) tests/fw_cfg-test$(EXESUF): tests/fw_cfg-test.o $(libqos-pc-obj-y) tests/e1000-test$(EXESUF): tests/e1000-test.o tests/rtl8139-test$(EXESUF): tests/rtl8139-test.o +tests/pcnet-test$(EXESUF): tests/pcnet-test.o tests/vmxnet3-test$(EXESUF): tests/vmxnet3-test.o tests/qom-test$(EXESUF): tests/qom-test.o tests/blockdev-test$(EXESUF): tests/blockdev-test.o $(libqos-pc-obj-y) diff --git a/tests/pcnet-test.c b/tests/pcnet-test.c new file mode 100644 index 000..643b348 --- /dev/null +++ b/tests/pcnet-test.c @@ -0,0 +1,35 @@ +/* + * QTest testcase for PC-Net NIC + * + * Copyright (c) 2013-2014 SUSE LINUX Products GmbH + * + * This work is licensed under the terms of the GNU GPL, version 2 or later. + * See the COPYING file in the top-level directory. + */ +#include libqtest.h + +#include glib.h +#include string.h +#include qemu/osdep.h + +static void pci_nop(void) +{ +} + +int main(int argc, char **argv) +{ +QTestState *s; +int ret; + +g_test_init(argc, argv, NULL); +qtest_add_func(/pcnet/pci/nop, pci_nop); + +s = qtest_start(-device pcnet); +ret = g_test_run(); + +if (s) { +qtest_quit(s); +} + +return ret; +} -- 1.8.4.5
Re: [Qemu-devel] [PATCH] pc_piix: enable legacy hotplug for Xen
Il 05/02/2014 17:54, Stefano Stabellini ha scritto: I'm not sure how this is related to fw_cfg? fw_cfg is just a simple key-value store. If hvmloader doesn't use it, it should be a burden. I was referring to the fact that QEMU might not have all the info that need to be written to fw_cfg when running on Xen: some of the info might be in the hypervisor and some other in another QEMU instance. Or do you think that fw_cfg could be written by multiple entities simultaneously? Wouldn't it be possible to fetch the necessary information via hypercalls or in xenstore? It's possible that some particular fw_cfg entries will be skipped for Xen, but most of them should apply. fw_cfg support would also make it possible to use -kernel/-initrd in Xen HVM machines, for example. Paolo
[Qemu-devel] [PATCH qom-next 2/5] tests: Add vmxnet3 qtest
Signed-off-by: Andreas Färber afaer...@suse.de --- tests/Makefile | 5 + tests/vmxnet3-test.c | 35 +++ 2 files changed, 40 insertions(+) create mode 100644 tests/vmxnet3-test.c diff --git a/tests/Makefile b/tests/Makefile index 57e21fc..323c600 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -83,6 +83,10 @@ check-qtest-i386-y += tests/blockdev-test$(EXESUF) check-qtest-i386-y += tests/qdev-monitor-test$(EXESUF) check-qtest-i386-y += $(check-qtest-pci-y) gcov-files-i386-y += $(gcov-files-pci-y) +check-qtest-i386-y += tests/vmxnet3-test$(EXESUF) +gcov-files-i386-y += hw/net/vmxnet3.c +gcov-files-i386-y += hw/net/vmxnet_rx_pkt.c +gcov-files-i386-y += hw/net/vmxnet_tx_pkt.c check-qtest-x86_64-y = $(check-qtest-i386-y) gcov-files-i386-y += i386-softmmu/hw/mc146818rtc.c gcov-files-x86_64-y = $(subst i386-softmmu/,x86_64-softmmu/,$(gcov-files-i386-y)) @@ -203,6 +207,7 @@ tests/tmp105-test$(EXESUF): tests/tmp105-test.o $(libqos-omap-obj-y) tests/i440fx-test$(EXESUF): tests/i440fx-test.o $(libqos-pc-obj-y) tests/fw_cfg-test$(EXESUF): tests/fw_cfg-test.o $(libqos-pc-obj-y) tests/e1000-test$(EXESUF): tests/e1000-test.o +tests/vmxnet3-test$(EXESUF): tests/vmxnet3-test.o tests/qom-test$(EXESUF): tests/qom-test.o tests/blockdev-test$(EXESUF): tests/blockdev-test.o $(libqos-pc-obj-y) tests/qdev-monitor-test$(EXESUF): tests/qdev-monitor-test.o $(libqos-pc-obj-y) diff --git a/tests/vmxnet3-test.c b/tests/vmxnet3-test.c new file mode 100644 index 000..e3449e7 --- /dev/null +++ b/tests/vmxnet3-test.c @@ -0,0 +1,35 @@ +/* + * QTest testcase for vmxnet3 NIC + * + * Copyright (c) 2013-2014 SUSE LINUX Products GmbH + * + * This work is licensed under the terms of the GNU GPL, version 2 or later. + * See the COPYING file in the top-level directory. + */ +#include libqtest.h + +#include glib.h +#include string.h +#include qemu/osdep.h + +static void nop(void) +{ +} + +int main(int argc, char **argv) +{ +QTestState *s; +int ret; + +g_test_init(argc, argv, NULL); +qtest_add_func(/vmxnet3/nop, nop); + +s = qtest_start(-device vmxnet3); +ret = g_test_run(); + +if (s) { +qtest_quit(s); +} + +return ret; +} -- 1.8.4.5
[Qemu-devel] [PATCH 1/4] virtio-mmio: introduce set_host_notifier()
set_host_notifier() is introduced into virtio-mmio now. Most of codes came from virtio-pci. Signed-off-by: Ying-Shiuan Pan ys...@itri.org.tw --- hw/virtio/virtio-mmio.c | 70 + 1 file changed, 70 insertions(+) diff --git a/hw/virtio/virtio-mmio.c b/hw/virtio/virtio-mmio.c index 8829eb0..558fd2f 100644 --- a/hw/virtio/virtio-mmio.c +++ b/hw/virtio/virtio-mmio.c @@ -23,6 +23,7 @@ #include hw/virtio/virtio.h #include qemu/host-utils.h #include hw/virtio/virtio-bus.h +#include qemu/error-report.h /* #define DEBUG_VIRTIO_MMIO */ @@ -87,11 +88,61 @@ typedef struct { uint32_t guest_page_shift; /* virtio-bus */ VirtioBusState bus; +bool ioeventfd_disabled; +bool ioeventfd_started; } VirtIOMMIOProxy; static void virtio_mmio_bus_new(VirtioBusState *bus, size_t bus_size, VirtIOMMIOProxy *dev); +static int virtio_mmio_set_host_notifier_internal(VirtIOMMIOProxy *proxy, + int n, bool assign, bool set_handler) +{ +VirtIODevice *vdev = virtio_bus_get_device(proxy-bus); +VirtQueue *vq = virtio_get_queue(vdev, n); +EventNotifier *notifier = virtio_queue_get_host_notifier(vq); +int r = 0; + +if (assign) { +r = event_notifier_init(notifier, 1); +if (r 0) { +error_report(%s: unable to init event notifier: %d, + __func__, r); +return r; +} +virtio_queue_set_host_notifier_fd_handler(vq, true, set_handler); +memory_region_add_eventfd(proxy-iomem, VIRTIO_MMIO_QUEUENOTIFY, 4, + true, n, notifier); +} else { +memory_region_del_eventfd(proxy-iomem, VIRTIO_MMIO_QUEUENOTIFY, 4, + true, n, notifier); +virtio_queue_set_host_notifier_fd_handler(vq, false, false); +event_notifier_cleanup(notifier); +} +return r; +} + +static void virtio_mmio_stop_ioeventfd(VirtIOMMIOProxy *proxy) +{ +int r; +int n; +VirtIODevice *vdev = virtio_bus_get_device(proxy-bus); + +if (!proxy-ioeventfd_started) { +return; +} + +for (n = 0; n VIRTIO_PCI_QUEUE_MAX; n++) { +if (!virtio_queue_get_num(vdev, n)) { +continue; +} + +r = virtio_mmio_set_host_notifier_internal(proxy, n, false, false); +assert(r = 0); +} +proxy-ioeventfd_started = false; +} + static uint64_t virtio_mmio_read(void *opaque, hwaddr offset, unsigned size) { VirtIOMMIOProxy *proxy = (VirtIOMMIOProxy *)opaque; @@ -345,6 +396,24 @@ static void virtio_mmio_reset(DeviceState *d) proxy-guest_page_shift = 0; } +static int virtio_mmio_set_host_notifier(DeviceState *opaque, int n, bool assign) +{ +VirtIOMMIOProxy *proxy = VIRTIO_MMIO(opaque); + +/* Stop using ioeventfd for virtqueue kick if the device starts using host + * notifiers. This makes it easy to avoid stepping on each others' toes. + */ +proxy-ioeventfd_disabled = assign; +if (assign) { +virtio_mmio_stop_ioeventfd(proxy); +} +/* We don't need to start here: it's not needed because backend + * currently only stops on status change away from ok, + * reset, vmstop and such. If we do add code to start here, + * need to check vmstate, device state etc. */ +return virtio_mmio_set_host_notifier_internal(proxy, n, assign, false); +} + /* virtio-mmio device */ /* This is called by virtio-bus just after the device is plugged. */ @@ -406,6 +475,7 @@ static void virtio_mmio_bus_class_init(ObjectClass *klass, void *data) k-notify = virtio_mmio_update_irq; k-save_config = virtio_mmio_save_config; k-load_config = virtio_mmio_load_config; +k-set_host_notifier = virtio_mmio_set_host_notifier; k-get_features = virtio_mmio_get_features; k-device_plugged = virtio_mmio_device_plugged; k-has_variable_vring_alignment = true; -- 1.8.1.2
Re: [Qemu-devel] [PATCH v3 4/9] ide: Drop redundant IDEState member bs
On Wed, 5 Feb 2014, Markus Armbruster wrote: [Note cc: Stefano] Kevin Wolf kw...@redhat.com writes: Am 30.01.2014 um 13:16 hat Markus Armbruster geschrieben: It's a copy of dev-conf.bs. The copy was needed for non-qdevified controllers, which lacked dev. Note how pci_piix3_xen_ide_unplug() cleared the copy. We'll get back to that in the next few commits. Signed-off-by: Markus Armbruster arm...@redhat.com So this pci_piix3_xen_ide_unplug() is what happens here: --- a/hw/ide/piix.c +++ b/hw/ide/piix.c @@ -169,12 +169,9 @@ static int pci_piix_ide_initfn(PCIDevice *dev) static int pci_piix3_xen_ide_unplug(DeviceState *dev) { -PCIIDEState *pci_ide; DriveInfo *di; int i = 0; -pci_ide = PCI_IDE(dev); - for (; i 3; i++) { di = drive_get_by_index(IF_IDE, i); if (di != NULL !di-media_cd) { @@ -183,7 +180,6 @@ static int pci_piix3_xen_ide_unplug(DeviceState *dev) bdrv_detach_dev(di-bdrv, ds); } bdrv_close(di-bdrv); -pci_ide-bus[di-bus].ifs[di-unit].bs = NULL; drive_put_ref(di); } } Probably I'm just missing the obvious, but it seems to me that the copy was cleared here, while the original was left around. This was no problem because the original was unused anyway after device initialisation. Now that the copy doesn't exist any more, we can't clear it, obviously, but why don't we have to clear the original? Won't we still run the device is attached code branches even though the device is really unplugged? It's been a while since I wrote this. Almost 14 months, in fact. No other IDE controller implements DeviceClass method unplug(). I can't remember why the normal code to detach the backend (release_drive()) doesn't do here. Stefano, can you help? Too long to be able to remember the exact details :-/ However if you point me to a branch I can give it a try and tell you if the unplug still works as it used to.
Re: [Qemu-devel] [PATCH 01/12] qapi: add size parser to StringInputVisitor
Am 30.01.2014 14:09, schrieb Paolo Bonzini: Signed-off-by: Paolo Bonzini pbonz...@redhat.com --- qapi/string-input-visitor.c | 24 1 file changed, 24 insertions(+) diff --git a/qapi/string-input-visitor.c b/qapi/string-input-visitor.c index 8f1bc41..793548a 100644 --- a/qapi/string-input-visitor.c +++ b/qapi/string-input-visitor.c @@ -14,6 +14,7 @@ #include qapi/string-input-visitor.h #include qapi/visitor-impl.h #include qapi/qmp/qerror.h +#include qemu/option.h struct StringInputVisitor { @@ -41,6 +42,28 @@ static void parse_type_int(Visitor *v, int64_t *obj, const char *name, *obj = val; } +static void parse_type_size(Visitor *v, uint64_t *obj, const char *name, +Error **errp) +{ +StringInputVisitor *siv = DO_UPCAST(StringInputVisitor, visitor, v); +Error *err = NULL; +uint64_t val; + +if (siv-string) { +parse_option_size(name, siv-string, val, err); +} else { +error_set(errp, QERR_INVALID_PARAMETER_TYPE, name ? name : null, + size); error_setg()? Otherwise looks fine. CC'ing Luiz. Andreas +return; +} +if (err) { +error_propagate(errp, err); +return; +} + +*obj = val; +} + static void parse_type_bool(Visitor *v, bool *obj, const char *name, Error **errp) { @@ -128,6 +151,7 @@ StringInputVisitor *string_input_visitor_new(const char *str) v-visitor.type_enum = input_type_enum; v-visitor.type_int = parse_type_int; +v-visitor.type_size = parse_type_size; v-visitor.type_bool = parse_type_bool; v-visitor.type_str = parse_type_str; v-visitor.type_number = parse_type_number; -- SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
[Qemu-devel] [PATCH 4/4] virtio-mmio: add a new property for ioeventfd
Make ioeventfd could be enabled or disabled (default). Since ioeventfd is not yet ready in kvm-arm, without this option, qemu will get a problem if it attempts to initialize ioeventfd. To coincide this option of virtio-mmio with virtio-pci, I would like to also move VIRTIO_PCI_FLAG_USE_IOEVENTFD to 'bool ioeventfd' of VirtIODevice. Any better suggestion? Signed-off-by: Ying-Shiuan Pan ys...@itri.org.tw --- hw/block/virtio-blk.c | 1 + hw/net/virtio-net.c| 1 + hw/virtio/virtio-mmio.c| 3 ++- include/hw/virtio/virtio.h | 1 + 4 files changed, 5 insertions(+), 1 deletion(-) diff --git a/hw/block/virtio-blk.c b/hw/block/virtio-blk.c index 19d0961..befdfdf 100644 --- a/hw/block/virtio-blk.c +++ b/hw/block/virtio-blk.c @@ -756,6 +756,7 @@ static void virtio_blk_device_unrealize(DeviceState *dev, Error **errp) static Property virtio_blk_properties[] = { DEFINE_VIRTIO_BLK_PROPERTIES(VirtIOBlock, blk), +DEFINE_PROP_BOOL(ioeventfd, VirtIOBlock, parent_obj.use_ioeventfd, false), DEFINE_PROP_END_OF_LIST(), }; diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index 3626608..9b75e61 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -1631,6 +1631,7 @@ static Property virtio_net_properties[] = { TX_TIMER_INTERVAL), DEFINE_PROP_INT32(x-txburst, VirtIONet, net_conf.txburst, TX_BURST), DEFINE_PROP_STRING(tx, VirtIONet, net_conf.tx), +DEFINE_PROP_BOOL(ioeventfd, VirtIONet, parent_obj.use_ioeventfd, false), DEFINE_PROP_END_OF_LIST(), }; diff --git a/hw/virtio/virtio-mmio.c b/hw/virtio/virtio-mmio.c index 11964ee..3f7a341 100644 --- a/hw/virtio/virtio-mmio.c +++ b/hw/virtio/virtio-mmio.c @@ -127,7 +127,8 @@ static void virtio_mmio_start_ioeventfd(VirtIOMMIOProxy *proxy) VirtIODevice *vdev = virtio_bus_get_device(proxy-bus); int n, r; -if (proxy-ioeventfd_disabled || +if (!vdev-use_ioeventfd || +proxy-ioeventfd_disabled || proxy-ioeventfd_started) { return; } diff --git a/include/hw/virtio/virtio.h b/include/hw/virtio/virtio.h index 3e54e90..d4cb3bf 100644 --- a/include/hw/virtio/virtio.h +++ b/include/hw/virtio/virtio.h @@ -121,6 +121,7 @@ struct VirtIODevice bool vm_running; VMChangeStateEntry *vmstate; char *bus_name; +bool use_ioeventfd; }; typedef struct VirtioDeviceClass { -- 1.8.1.2
Re: [Qemu-devel] [PATCH 01/12] qapi: add size parser to StringInputVisitor
Il 05/02/2014 18:13, Andreas Färber ha scritto: +error_set(errp, QERR_INVALID_PARAMETER_TYPE, name ? name : null, + size); error_setg()? We're still using error_set for existing errors. In this case, the code is taken from qdev-properties.c. Paolo Otherwise looks fine. CC'ing Luiz.
Re: [Qemu-devel] [PATCH] qdev: Keep global allocation counter per bus
Il 04/02/2014 13:14, Markus Armbruster ha scritto: Paolo Bonzini pbonz...@redhat.com writes: Il 04/02/2014 11:33, Markus Armbruster ha scritto: This breaks migration unless you change bus=ide.0 to bus=ide.1 on the destination. Should be mentioned in release notes. Do we have a place where we collect release notes as we go? Yes, http://wiki.qemu.org/ChangeLog/Next I can record this change there, but I don't seem to have an account. Created one, will send account details offlist. Paolo
[Qemu-devel] [PATCH 0/4] ioeventfd support for virtio-mmio
I added host/guest notifiers support for virtio-mmio, so that qemu can enable vhost-net for kvm-arm. Sorry for that I cannot measure the performance difference because I have only Exynos-5250 arndale boards which only provide a 100 Mbps Ethernet. But in our previous work in kvm-arm (refer: Evaluation of a Server-Grade Software-Only ARM Hypervisor), the vhost-net increased at least 30% in throughput comparing to virtio-net. Ying-Shiuan Pan (4): virtio-mmio: introduce set_host_notifier() virtio-mmio: introduce set_guest_notifiers virtio-mmio: start ioeventfd when status gets DRIVER_OK virtio-mmio: add a new property for ioeventfd hw/block/virtio-blk.c | 1 + hw/net/virtio-net.c| 1 + hw/virtio/virtio-mmio.c| 176 + include/hw/virtio/virtio.h | 1 + 4 files changed, 179 insertions(+) -- 1.8.1.2
[Qemu-devel] [PATCH v3 1/5] rules.mak: Support .cc as a C++ source file suffix
The A64 disassembler libvixl uses .cc as its suffix for C++ source files, so add support for it (we already support .cpp). Signed-off-by: Peter Maydell peter.mayd...@linaro.org Reviewed-by: Richard Henderson r...@twiddle.net --- rules.mak | 6 +- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/rules.mak b/rules.mak index 49edb9b..cd9187e 100644 --- a/rules.mak +++ b/rules.mak @@ -8,6 +8,7 @@ MAKEFLAGS += -rR %.d: %.h: %.c: +%.cc: %.cpp: %.m: %.mak: @@ -54,6 +55,9 @@ endif %.o: %.asm $(call quiet-command,$(AS) $(ASFLAGS) -o $@ $, AS $(TARGET_DIR)$@) +%.o: %.cc + $(call quiet-command,$(CXX) $(QEMU_INCLUDES) $(QEMU_CXXFLAGS) $(QEMU_DGFLAGS) $(CFLAGS) -c -o $@ $, CXX $(TARGET_DIR)$@) + %.o: %.cpp $(call quiet-command,$(CXX) $(QEMU_INCLUDES) $(QEMU_CXXFLAGS) $(QEMU_DGFLAGS) $(CFLAGS) -c -o $@ $, CXX $(TARGET_DIR)$@) @@ -77,7 +81,7 @@ quiet-command = $(if $(V),$1,$(if $(2),@echo $2 $1, @$1)) cc-option = $(if $(shell $(CC) $1 $2 -S -o /dev/null -xc /dev/null \ /dev/null 21 echo OK), $2, $3) -VPATH_SUFFIXES = %.c %.h %.S %.cpp %.m %.mak %.texi %.sh %.rc +VPATH_SUFFIXES = %.c %.h %.S %.cc %.cpp %.m %.mak %.texi %.sh %.rc set-vpath = $(if $1,$(foreach PATTERN,$(VPATH_SUFFIXES),$(eval vpath $(PATTERN) $1))) # find-in-path -- 1.8.5
[Qemu-devel] [PATCH v3 5/5] disas: Implement disassembly output for A64
From: Claudio Fontana claudio.font...@linaro.org Use libvixl to implement disassembly output in debug logs for A64, for use with both AArch64 hosts and targets. Signed-off-by: Claudio Fontana claudio.font...@linaro.org [PMM: * added support for target disassembly * switched to custom QEMUDisassembler so the output format matches what QEMU expects * make sure we correctly fall back to just print hex if we didn't build the AArch64 disassembler because of lack of a C++ compiler * rename from 'aarch64' to 'arm-a64' because this is a disassembler for the A64 instruction set * merge aarch64.c and aarch64-cxx.cc into one C++ file * simplify the aarch64.c-aarch64-cxx.cc interface] Signed-off-by: Peter Maydell peter.mayd...@linaro.org --- configure | 4 +++ disas.c | 14 ++-- disas/Makefile.objs | 5 +++ disas/arm-a64.cc| 87 + disas/libvixl/Makefile.objs | 8 + include/disas/bfd.h | 1 + target-arm/translate-a64.c | 2 +- 7 files changed, 118 insertions(+), 3 deletions(-) create mode 100644 disas/arm-a64.cc create mode 100644 disas/libvixl/Makefile.objs diff --git a/configure b/configure index 236764a..8f3cc20 100755 --- a/configure +++ b/configure @@ -4641,6 +4641,10 @@ for i in $ARCH $TARGET_BASE_ARCH ; do arm) echo CONFIG_ARM_DIS=y $config_target_mak echo CONFIG_ARM_DIS=y config-all-disas.mak +if test -n ${cxx}; then + echo CONFIG_ARM_A64_DIS=y $config_target_mak + echo CONFIG_ARM_A64_DIS=y config-all-disas.mak +fi ;; cris) echo CONFIG_CRIS_DIS=y $config_target_mak diff --git a/disas.c b/disas.c index 0203ef2..79e6944 100644 --- a/disas.c +++ b/disas.c @@ -190,7 +190,7 @@ static int print_insn_od_target(bfd_vma pc, disassemble_info *info) /* Disassemble this for me please... (debugging). 'flags' has the following values: i386 - 1 means 16 bit code, 2 means 64 bit code -arm - bit 0 = thumb, bit 1 = reverse endian +arm - bit 0 = thumb, bit 1 = reverse endian, bit 2 = A64 ppc - nonzero means little endian other targets - unused */ @@ -225,7 +225,15 @@ void target_disas(FILE *out, CPUArchState *env, target_ulong code, } print_insn = print_insn_i386; #elif defined(TARGET_ARM) -if (flags 1) { +if (flags 4) { +/* We might not be compiled with the A64 disassembler + * because it needs a C++ compiler; in that case we will + * fall through to the default print_insn_od case. + */ +#if defined(CONFIG_ARM_A64_DIS) +print_insn = print_insn_arm_a64; +#endif +} else if (flags 1) { print_insn = print_insn_thumb1; } else { print_insn = print_insn_arm; @@ -356,6 +364,8 @@ void disas(FILE *out, void *code, unsigned long size) #elif defined(_ARCH_PPC) s.info.disassembler_options = (char *)any; print_insn = print_insn_ppc; +#elif defined(__aarch64__) defined(CONFIG_ARM_A64_DIS) +print_insn = print_insn_arm_a64; #elif defined(__alpha__) print_insn = print_insn_alpha; #elif defined(__sparc__) diff --git a/disas/Makefile.objs b/disas/Makefile.objs index 3b1e77a..41c2374 100644 --- a/disas/Makefile.objs +++ b/disas/Makefile.objs @@ -1,5 +1,10 @@ + common-obj-$(CONFIG_ALPHA_DIS) += alpha.o common-obj-$(CONFIG_ARM_DIS) += arm.o +common-obj-$(CONFIG_ARM_A64_DIS) += arm-a64.o +common-obj-$(CONFIG_ARM_A64_DIS) += libvixl/ +libvixldir = $(SRC_PATH)/disas/libvixl +$(obj)/arm-a64.o: QEMU_CFLAGS += -I$(libvixldir) common-obj-$(CONFIG_CRIS_DIS) += cris.o common-obj-$(CONFIG_HPPA_DIS) += hppa.o common-obj-$(CONFIG_I386_DIS) += i386.o diff --git a/disas/arm-a64.cc b/disas/arm-a64.cc new file mode 100644 index 000..162be0c --- /dev/null +++ b/disas/arm-a64.cc @@ -0,0 +1,87 @@ +/* + * ARM A64 disassembly output wrapper to libvixl + * Copyright (c) 2013 Linaro Limited + * Written by Claudio Fontana + * + * 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. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see http://www.gnu.org/licenses/. + */ + +#include a64/disasm-a64.h + +extern C { +#include disas/bfd.h +} + +using namespace vixl; + +static Decoder *vixl_decoder = NULL; +static Disassembler *vixl_disasm = NULL; + +/* We don't use libvixl's PrintDisassembler because its output + * is a little unhelpful (trailing newlines, for example). + * Instead we use our own very similar variant so we