Re: [Qemu-devel] [PATCH] linux-user: Define AT_RANDOM to support target dynamic linkers that do ASLR
On Wed, Jun 01, 2011 at 05:33:55PM +0200, Richard Henderson wrote: On 06/01/2011 06:47 AM, cedric.vinc...@st.com wrote: On Wed, Jun 01, 2011 at 03:26:09PM +0200, Richard Henderson wrote: 16 bytes, not 16 bits. You're right it's not 16 bits, it's sizeof(uintptr_t) actually: No, it's not. unsigned char k_rand_bytes[16]; elf_addr_t __user *u_rand_bytes; ... /* * Generate 16 random bytes for userspace PRNG seeding. */ get_random_bytes(k_rand_bytes, sizeof(k_rand_bytes)); u_rand_bytes = (elf_addr_t __user *) STACK_ALLOC(p, sizeof(k_rand_bytes)); if (__copy_to_user(u_rand_bytes, k_rand_bytes, sizeof(k_rand_bytes))) return -EFAULT; ... NEW_AUX_ENT(AT_RANDOM, (elf_addr_t)(unsigned long)u_rand_bytes); It's clearer to me now, thanks. Frankly, it's trivial to do this right in create_elf_tables. Grab 16 bytes at SP right at the beginning of the function, fill it with whatever random values seem good. I suggest at minimum a command-line argument to force a particular AT_RANDOM value, for repeatability. OK, I will submit you such a patch soon. Thanks, Cédric.
Re: [Qemu-devel] [RFC]QEMU disk I/O limits
On Thu, Jun 2, 2011 at 5:33 PM, Michal Suchanek hramr...@centrum.cz wrote: On 1 June 2011 05:12, Zhi Yong Wu wu...@linux.vnet.ibm.com wrote: On Tue, May 31, 2011 at 03:55:49PM -0400, Vivek Goyal wrote: Date: Tue, 31 May 2011 15:55:49 -0400 From: Vivek Goyal vgo...@redhat.com To: Zhi Yong Wu wu...@linux.vnet.ibm.com Cc: kw...@redhat.com, aligu...@us.ibm.com, stefa...@linux.vnet.ibm.com, k...@vger.kernel.org, guijianf...@cn.fujitsu.com, qemu-devel@nongnu.org, wu...@cn.ibm.com, herb...@gondor.hengli.com.au, luow...@cn.ibm.com, zh...@cn.ibm.com, zhaoy...@cn.ibm.com, l...@redhat.com, rahar...@us.ibm.com Subject: Re: [Qemu-devel] [RFC]QEMU disk I/O limits User-Agent: Mutt/1.5.21 (2010-09-15) On Mon, May 30, 2011 at 01:09:23PM +0800, Zhi Yong Wu wrote: [..] 3.) How the users enable and play with it QEMU -drive option will be extended so that disk I/O limits can be specified on its command line, such as -drive [iops=xxx,][throughput=xxx] or -drive [iops_rd=xxx,][iops_wr=xxx,][throughput=xxx] etc. When this argument is specified, it means that disk I/O limits feature is enabled for this drive disk. How does throughput interface look like? is it bytes per second or something else? HI, Vivek, It will be a value based on bytes per second. Do we have read and write variants for throughput as we have for iops. QEMU code has two variants rd_bytes, wr_bytes, but we maybe need to get their bytes per second. if you have bytes interface(as kenrel does), then bps_rd and bps_wr might be good names too for thoughput interface. I agree with you, and can change them as your suggestions. Changing them this way is not going to be an improvement. While rd_bytes and wr_bytes lack the time interval specification bps_rd and right, rd_bytes and wr_bytes lack. bps_wr is ambiguous. Is that bits? bytes? Sure, there should be some if we implement them, they will be bytes. distinction by capitalization but that does not apply since qemu arguments are all lowercase. Michal, maybe you misunderstand what i mean. I mean that two variables rd_bytes and wr_bytes exist in block.c file, and are not qemu arguments. But bps_rd and bps_wr wil be added as qemu arguments. Regards, Zhiyong Wu Thanks Michal -- To unsubscribe from this list: send the line unsubscribe kvm in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html -- Regards, Zhi Yong Wu
Re: [Qemu-devel] [PULL v5 00/25] SCSI subsystem improvements
On 06/02/2011 04:54 PM, Andreas Färber wrote: Unfortunately that pulled in the v5 version, breaking simple trace build. Paolo, do you have differential patches for your v6 already? Yes, sending them today. Paolo
[Qemu-devel] Hello Would You Like To Earn
Hello qemu-devel Would you like to earn an extra $200 everyday?, for just 45 minutes work? You could quit your job and make double the money at home working for yourself. visit-http:tinyurl.com/3ot9sgy Regards, Jenny Smith Survey Human Resources Dept.
[Qemu-devel] Hello Would You Like To Earn
Hello qemu-devel Would you like to earn an extra $200 everyday?, for just 45 minutes work? You could quit your job and make double the money at home working for yourself. visit-http:tinyurl.com/3ot9sgy Regards, Jenny Smith Survey Human Resources Dept.
[Qemu-devel] Hello Would You Like To Earn
Hello qemu-devel Would you like to earn an extra $200 everyday?, for just 45 minutes work? You could quit your job and make double the money at home working for yourself. visit-http:tinyurl.com/3ot9sgy Regards, Jenny Smith Survey Human Resources Dept.
[Qemu-devel] Hello Would You Like To Earn
Hello qemu-devel Would you like to earn an extra $200 everyday?, for just 45 minutes work? You could quit your job and make double the money at home working for yourself. visit-http:tinyurl.com/3ot9sgy Regards, Jenny Smith Survey Human Resources Dept.
Re: [Qemu-devel] QMP: RFC: I/O error info query-stop-reason
On Thu, Jun 02, 2011 at 03:01:24PM -0300, Luiz Capitulino wrote: On Thu, 02 Jun 2011 09:02:30 -0500 Anthony Liguori anth...@codemonkey.ws wrote: On 06/02/2011 08:24 AM, Jiri Denemark wrote: On Thu, Jun 02, 2011 at 08:08:35 -0500, Anthony Liguori wrote: On 06/02/2011 04:06 AM, Daniel P. Berrange wrote: B. query-stop-reason I also have a simple solution for item 2. The vm_stop() accepts a reason argument, so we could store it somewhere and return it as a string, like: -{ execute: query-stop-reason } - { return: { reason: user } } Valid reasons could be: user, debug, shutdown, diskfull (hey, this should be ioerror, no?), watchdog, panic, savevm, loadvm, migrate. Also note that we have a STOP event. It should be extended with the stop reason too, for completeness. Can we just extend query-block? Primarily we want 'query-stop-reason' to tell us what caused the VM CPUs to stop. If that reason was 'ioerror', then 'query-block' could be used to find out which particular block device(s) caused the IO error to occurr get the reason that was in the BLOCK_IO_ERROR event. My concern is that we're over abstracting here. We're not going to add additional stop reasons in the future. Maybe just add an 'io-error': True to query-state. Sure, adding a new field to query-state response would work as well. And it seems like a good idea to me since one already needs to call query-status to check if CPUs are stopped or not so it makes sense to incorporate the additional information there as well. And if you want to be safe for the future, the new field doesn't have to be boolean 'io-error' but it can be the string 'reason' which Luiz suggested above. String enumerations are a Bad Thing. It's impossible to figure out what strings are valid and it lacks type safety. Adding more booleans provides better type safety, and when we move to QAPI with a queryable schema, provides a way to figure out exactly what combinations are supported by QEMU. To summarize: 1. Add a 'io-error' field to query-status (which is only present if field 'running' is false) This isn't really enough. There are many reasons why a VM may have transitioned to the paused state, of which IO Error is merely one. The query-status needs to be able to report what the reason for the transitioning to the paused state is. 2. Extend query-block to contain error information associated with the device. This is interesting, because this information will be available even if the error didn't cause the VM to stop Apps will only look for this data, if the query-status stop reason indicates that it was stopped due to an I/O error. Regards, Daniel -- |: http://berrange.com -o-http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|
[Qemu-devel] Hello Would You Like To Earn
Hello qemu-devel Would you like to earn an extra $200 everyday?, for just 45 minutes work? You could quit your job and make double the money at home working for yourself. visit-http:tinyurl.com/3ot9sgy Regards, Jenny Smith Survey Human Resources Dept.
[Qemu-devel] Hello Would You Like To Earn
Hello qemu-devel Would you like to earn an extra $200 everyday?, for just 45 minutes work? You could quit your job and make double the money at home working for yourself. visit-http:tinyurl.com/3ot9sgy Regards, Jenny Smith Survey Human Resources Dept.
[Qemu-devel] [PATCH 2/5] PPC: fix sregs usage on booke
When compiling qemu with kvm support on BookE PPC machines, I get the following error: cc1: warnings being treated as errors /tmp/qemu/target-ppc/kvm.c: In function 'kvm_arch_get_registers': /tmp/qemu/target-ppc/kvm.c:188: error: unused variable 'sregs' This is due to overly ambitious #ifdef'ery introduced in 90dc88. Fix it by keeping code that doesn't depend on new headers alive for the compiler, but never executed due to failing capability checks. CC: Scott Wood scottw...@freescale.com Signed-off-by: Alexander Graf ag...@suse.de --- target-ppc/kvm.c | 10 -- 1 files changed, 4 insertions(+), 6 deletions(-) diff --git a/target-ppc/kvm.c b/target-ppc/kvm.c index ccf4668..e7b1b10 100644 --- a/target-ppc/kvm.c +++ b/target-ppc/kvm.c @@ -45,9 +45,7 @@ const KVMCapabilityInfo kvm_arch_required_capabilities[] = { static int cap_interrupt_unset = false; static int cap_interrupt_level = false; static int cap_segstate; -#ifdef KVM_CAP_PPC_BOOKE_SREGS static int cap_booke_sregs; -#endif /* XXX We have a race condition where we actually have a level triggered * interrupt, but the infrastructure can't expose that yet, so the guest @@ -222,13 +220,13 @@ int kvm_arch_get_registers(CPUState *env) for (i = 0;i 32; i++) env-gpr[i] = regs.gpr[i]; -#ifdef KVM_CAP_PPC_BOOKE_SREGS if (cap_booke_sregs) { ret = kvm_vcpu_ioctl(env, KVM_GET_SREGS, sregs); if (ret 0) { return ret; } +#ifdef KVM_CAP_PPC_BOOKE_SREGS if (sregs.u.e.features KVM_SREGS_E_BASE) { env-spr[SPR_BOOKE_CSRR0] = sregs.u.e.csrr0; env-spr[SPR_BOOKE_CSRR1] = sregs.u.e.csrr1; @@ -325,16 +323,16 @@ int kvm_arch_get_registers(CPUState *env) env-spr[SPR_BOOKE_PID2] = sregs.u.e.impl.fsl.pid2; } } -} #endif +} -#ifdef KVM_CAP_PPC_SEGSTATE if (cap_segstate) { ret = kvm_vcpu_ioctl(env, KVM_GET_SREGS, sregs); if (ret 0) { return ret; } +#ifdef KVM_CAP_PPC_SEGSTATE ppc_store_sdr1(env, sregs.u.s.sdr1); /* Sync SLB */ @@ -357,8 +355,8 @@ int kvm_arch_get_registers(CPUState *env) env-IBAT[0][i] = sregs.u.s.ppc32.ibat[i] 0x; env-IBAT[1][i] = sregs.u.s.ppc32.ibat[i] 32; } -} #endif +} return 0; } -- 1.6.0.2
[Qemu-devel] [PATCH 3/5] PPC: install mpc8544ds.dtb
We don't install mpc8544ds.dtb, which means that -M mpc8544ds doesn't work when installed. Fix it by installing the file. Signed-off-by: Alexander Graf ag...@suse.de --- Makefile |1 + 1 files changed, 1 insertions(+), 0 deletions(-) diff --git a/Makefile b/Makefile index 2b0438c..b6466e7 100644 --- a/Makefile +++ b/Makefile @@ -185,6 +185,7 @@ ppc_rom.bin openbios-sparc32 openbios-sparc64 openbios-ppc \ pxe-e1000.rom pxe-eepro100.rom pxe-ne2k_pci.rom \ pxe-pcnet.rom pxe-rtl8139.rom pxe-virtio.rom \ bamboo.dtb petalogix-s3adsp1800.dtb petalogix-ml605.dtb \ +mpc8544ds.dtb \ multiboot.bin linuxboot.bin \ s390-zipl.rom \ spapr-rtas.bin slof.bin -- 1.6.0.2
[Qemu-devel] [PATCH 5/5] PPC: fix mpc8544ds pci default devices
After the Qdev'ification of the MPC8544DS board and PCI bus, the internal PCI bus name changed from pci to pci.0. Reflect this change in the search for that bus. This patch enables networking on e500 guests again. Signed-off-by: Alexander Graf ag...@suse.de --- hw/ppce500_mpc8544ds.c |2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/hw/ppce500_mpc8544ds.c b/hw/ppce500_mpc8544ds.c index 17b0165..6b57fbf 100644 --- a/hw/ppce500_mpc8544ds.c +++ b/hw/ppce500_mpc8544ds.c @@ -275,7 +275,7 @@ static void mpc8544ds_init(ram_addr_t ram_size, mpic[pci_irq_nrs[0]], mpic[pci_irq_nrs[1]], mpic[pci_irq_nrs[2]], mpic[pci_irq_nrs[3]], NULL); -pci_bus = (PCIBus *)qdev_get_child_bus(dev, pci); +pci_bus = (PCIBus *)qdev_get_child_bus(dev, pci.0); if (!pci_bus) printf(couldn't create PCI controller!\n); -- 1.6.0.2
[Qemu-devel] [PULL 0/5] PPC patch queue June 03 2011
Howdy, This is my current PPC patch queue, containing a compile fix for ppc64 and some fixes I've come along while trying to get the e500 target working in autotest. Please pull. The following changes since commit 578c7b2ca8ee9e97fa8693b1a83d517e8e3f962e: Juha Riihim?ki (1): audio: fix integer overflow expression are available in the git repository at: git://repo.or.cz/qemu/agraf.git ppc-next Alexander Graf (4): PPC: fix sregs usage on booke PPC: install mpc8544ds.dtb Fix segfault on screendump with -nographic PPC: fix mpc8544ds pci default devices Stefan Weil (1): ppc: Fix compilation for ppc64-softmmu Makefile|1 + console.c |2 +- hw/ppce500_mpc8544ds.c |2 +- target-ppc/kvm.c| 10 -- target-ppc/translate_init.c | 12 ++-- 5 files changed, 13 insertions(+), 14 deletions(-)
[Qemu-devel] [PATCH 12/13] s390x: fix cksm instruction
The cksm instruction was implemented incorrectly, rendering UDP and TCP checksum calculation wrong, making an emulated s390x Linux guest break in most networking operations. This patch fixes odd end checksum calculation, takes the input register as input for the checksum and optimizes the overflow pieces by a bit. Signed-off-by: Alexander Graf ag...@suse.de --- target-s390x/op_helper.c | 28 1 files changed, 8 insertions(+), 20 deletions(-) diff --git a/target-s390x/op_helper.c b/target-s390x/op_helper.c index 49760a4..db03a79 100644 --- a/target-s390x/op_helper.c +++ b/target-s390x/op_helper.c @@ -1731,25 +1731,15 @@ void HELPER(sqdbr)(uint32_t f1, uint32_t f2) env-fregs[f1].d = float64_sqrt(env-fregs[f2].d, env-fpu_status); } -static inline uint64_t cksm_overflow(uint64_t cksm) -{ -if (cksm 0xULL) { -cksm = 0xULL; -cksm++; -} -return cksm; -} - /* checksum */ void HELPER(cksm)(uint32_t r1, uint32_t r2) { uint64_t src = get_address_31fix(r2); uint64_t src_len = env-regs[(r2 + 1) 15]; -uint64_t cksm = 0; +uint64_t cksm = (uint32_t)env-regs[r1]; while (src_len = 4) { cksm += ldl(src); -cksm = cksm_overflow(cksm); /* move to next word */ src_len -= 4; @@ -1760,26 +1750,24 @@ void HELPER(cksm)(uint32_t r1, uint32_t r2) case 0: break; case 1: -cksm += ldub(src); -cksm = cksm_overflow(cksm); +cksm += ldub(src) 24; break; case 2: -cksm += lduw(src); -cksm = cksm_overflow(cksm); +cksm += lduw(src) 16; break; case 3: -/* XXX check if this really is correct */ -cksm += lduw(src) 8; -cksm += ldub(src + 2); -cksm = cksm_overflow(cksm); +cksm += lduw(src) 16; +cksm += ldub(src + 2) 8; break; } /* indicate we've processed everything */ +env-regs[r2] = src + src_len; env-regs[(r2 + 1) 15] = 0; /* store result */ -env-regs[r1] = (env-regs[r1] 0xULL) | (uint32_t)cksm; +env-regs[r1] = (env-regs[r1] 0xULL) | +((uint32_t)cksm + (cksm 32)); } static inline uint32_t cc_calc_ltgt_32(CPUState *env, int32_t src, -- 1.6.0.2
[Qemu-devel] [PATCH 09/13] target-s390x: Add missing tcg_temp_free_i64() in disas_s390_insn(), opc == 0x90
From: Stefan Weil w...@mail.berlios.de Signed-off-by: Stefan Weil w...@mail.berlios.de Signed-off-by: Alexander Graf ag...@suse.de --- target-s390x/translate.c |1 + 1 files changed, 1 insertions(+), 0 deletions(-) diff --git a/target-s390x/translate.c b/target-s390x/translate.c index c5a3930..81b8c5b 100644 --- a/target-s390x/translate.c +++ b/target-s390x/translate.c @@ -4621,6 +4621,7 @@ static void disas_s390_insn(DisasContext *s) } tcg_gen_add_i64(tmp, tmp, tmp3); } +tcg_temp_free_i64(tmp); tcg_temp_free_i64(tmp2); tcg_temp_free_i64(tmp3); tcg_temp_free_i64(tmp4); -- 1.6.0.2
[Qemu-devel] [PATCH 4/5] Fix segfault on screendump with -nographic
When running -nographic and calling screendump on the monitor, qemu segfaults. Fix the invalid pointer dereference by checking for NULL. Signed-off-by: Alexander Graf ag...@suse.de --- console.c |2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/console.c b/console.c index 871c1d4..9c6addf 100644 --- a/console.c +++ b/console.c @@ -180,7 +180,7 @@ void vga_hw_screen_dump(const char *filename) active_console = consoles[0]; /* There is currently no way of specifying which screen we want to dump, so always dump the first one. */ -if (consoles[0]-hw_screen_dump) +if (consoles[0] consoles[0]-hw_screen_dump) consoles[0]-hw_screen_dump(consoles[0]-hw, filename); active_console = previous_active_console; } -- 1.6.0.2
[Qemu-devel] [PATCH 04/13] target-s390x: Fix duplicate call of tcg_temp_new_i64
From: Stefan Weil w...@mail.berlios.de tmp2 = tcg_temp_new_i64() is already executed unconditionally, so there is no need to call it a second time for 64 bit hosts. Signed-off-by: Stefan Weil w...@mail.berlios.de Signed-off-by: Alexander Graf ag...@suse.de --- target-s390x/translate.c |1 - 1 files changed, 0 insertions(+), 1 deletions(-) diff --git a/target-s390x/translate.c b/target-s390x/translate.c index 865a9df..141a72f 100644 --- a/target-s390x/translate.c +++ b/target-s390x/translate.c @@ -2068,7 +2068,6 @@ do_mh: tcg_gen_qemu_ld32u(tmp2, tmp, get_mem_index(s)); tcg_gen_trunc_i64_i32(TCGV_HIGH(regs[i]), tmp2); #else -tmp2 = tcg_temp_new_i64(); tcg_gen_qemu_ld32u(tmp2, tmp, get_mem_index(s)); tcg_gen_shl_i64(tmp2, tmp2, tmp4); tcg_gen_ext32u_i64(regs[i], regs[i]); -- 1.6.0.2
[Qemu-devel] [PATCH 07/13] target-s390x: Add missing tcg_temp_free_i64() in disas_b2()
From: Stefan Weil w...@mail.berlios.de Signed-off-by: Stefan Weil w...@mail.berlios.de Signed-off-by: Alexander Graf ag...@suse.de --- target-s390x/translate.c |2 ++ 1 files changed, 2 insertions(+), 0 deletions(-) diff --git a/target-s390x/translate.c b/target-s390x/translate.c index a11cb19..f3f42a9 100644 --- a/target-s390x/translate.c +++ b/target-s390x/translate.c @@ -2964,6 +2964,8 @@ static void disas_b2(DisasContext *s, int op, uint32_t insn) /* we need to keep cc_op intact */ s-is_jmp = DISAS_JUMP; tcg_temp_free_i64(tmp); +tcg_temp_free_i64(tmp2); +tcg_temp_free_i64(tmp3); break; case 0x20: /* SERVC R1,R2 [RRE] */ /* SCLP Service call (PV hypercall) */ -- 1.6.0.2
[Qemu-devel] [PATCH 03/13] target-s390x: Fix wrong argument in call of tcg_gen_shl_i64()
From: Stefan Weil w...@mail.berlios.de tcg_gen_shl_i64 needs a 3rd argument of type TCGv_i64. Set tmp4 so it can be used here. v2: Don't call tcg_const_i64() inside of the loop because it creates additional code. Signed-off-by: Stefan Weil w...@mail.berlios.de Signed-off-by: Alexander Graf ag...@suse.de --- target-s390x/translate.c |4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/target-s390x/translate.c b/target-s390x/translate.c index 8e71df3..865a9df 100644 --- a/target-s390x/translate.c +++ b/target-s390x/translate.c @@ -2056,7 +2056,7 @@ do_mh: even for very long ones... */ tmp = get_address(s, 0, b2, d2); tmp3 = tcg_const_i64(stm_len); -tmp4 = tcg_const_i64(32); +tmp4 = tcg_const_i64(op == 0x26 ? 32 : 4); for (i = r1;; i = (i + 1) % 16) { switch (op) { case 0x4: @@ -2070,7 +2070,7 @@ do_mh: #else tmp2 = tcg_temp_new_i64(); tcg_gen_qemu_ld32u(tmp2, tmp, get_mem_index(s)); -tcg_gen_shl_i64(tmp2, tmp2, 4); +tcg_gen_shl_i64(tmp2, tmp2, tmp4); tcg_gen_ext32u_i64(regs[i], regs[i]); tcg_gen_or_i64(regs[i], regs[i], tmp2); #endif -- 1.6.0.2
[Qemu-devel] [PATCH 1/5] ppc: Fix compilation for ppc64-softmmu
From: Stefan Weil w...@mail.berlios.de When QEMU was configured with --enable-debug-tcg, compilation fails in spr_write_booke206_mmucsr0() and in spr_write_booke_pid(). Similar changes are also needed in conditional code which is normally unused. Cc: Alexander Graf ag...@suse.de Signed-off-by: Stefan Weil w...@mail.berlios.de Signed-off-by: Alexander Graf ag...@suse.de --- target-ppc/translate_init.c | 12 ++-- 1 files changed, 6 insertions(+), 6 deletions(-) diff --git a/target-ppc/translate_init.c b/target-ppc/translate_init.c index b511afa..fc50ae3 100644 --- a/target-ppc/translate_init.c +++ b/target-ppc/translate_init.c @@ -73,7 +73,7 @@ static void spr_read_generic (void *opaque, int gprn, int sprn) gen_load_spr(cpu_gpr[gprn], sprn); #ifdef PPC_DUMP_SPR_ACCESSES { -TCGv t0 = tcg_const_i32(sprn); +TCGv_i32 t0 = tcg_const_i32(sprn); gen_helper_load_dump_spr(t0); tcg_temp_free_i32(t0); } @@ -85,7 +85,7 @@ static void spr_write_generic (void *opaque, int sprn, int gprn) gen_store_spr(sprn, cpu_gpr[gprn]); #ifdef PPC_DUMP_SPR_ACCESSES { -TCGv t0 = tcg_const_i32(sprn); +TCGv_i32 t0 = tcg_const_i32(sprn); gen_helper_store_dump_spr(t0); tcg_temp_free_i32(t0); } @@ -1367,16 +1367,16 @@ static void spr_write_e500_l1csr0 (void *opaque, int sprn, int gprn) static void spr_write_booke206_mmucsr0 (void *opaque, int sprn, int gprn) { -TCGv t0 = tcg_const_i32(sprn); +TCGv_i32 t0 = tcg_const_i32(sprn); gen_helper_booke206_tlbflush(t0); -tcg_temp_free(t0); +tcg_temp_free_i32(t0); } static void spr_write_booke_pid (void *opaque, int sprn, int gprn) { -TCGv t0 = tcg_const_i32(sprn); +TCGv_i32 t0 = tcg_const_i32(sprn); gen_helper_booke_setpid(t0, cpu_gpr[gprn]); -tcg_temp_free(t0); +tcg_temp_free_i32(t0); } #endif -- 1.6.0.2
[Qemu-devel] [PATCH 05/13] target-s390x: Add missing tcg_temp_free_i64() in gen_jcc()
From: Stefan Weil w...@mail.berlios.de Signed-off-by: Stefan Weil w...@mail.berlios.de Signed-off-by: Alexander Graf ag...@suse.de --- target-s390x/translate.c |1 + 1 files changed, 1 insertions(+), 0 deletions(-) diff --git a/target-s390x/translate.c b/target-s390x/translate.c index 141a72f..6ec77ec 100644 --- a/target-s390x/translate.c +++ b/target-s390x/translate.c @@ -1095,6 +1095,7 @@ static void gen_jcc(DisasContext *s, uint32_t mask, int skip) tcg_gen_brcondi_i64(TCG_COND_EQ, tmp64, 0, skip); break; default: +tcg_temp_free_i64(tmp64); goto do_dynamic; } tcg_temp_free_i64(tmp64); -- 1.6.0.2
[Qemu-devel] [PATCH 10/13] target-s390x: Add missing tcg_temp_free_i32()
From: Stefan Weil w...@mail.berlios.de Signed-off-by: Stefan Weil w...@mail.berlios.de Signed-off-by: Alexander Graf ag...@suse.de --- target-s390x/translate.c |3 +++ 1 files changed, 3 insertions(+), 0 deletions(-) diff --git a/target-s390x/translate.c b/target-s390x/translate.c index 81b8c5b..5828b5f 100644 --- a/target-s390x/translate.c +++ b/target-s390x/translate.c @@ -1078,9 +1078,12 @@ static void gen_jcc(DisasContext *s, uint32_t mask, int skip) tcg_gen_brcondi_i32(TCG_COND_EQ, tmp, 0, skip); break; default: +tcg_temp_free_i32(tmp); +tcg_temp_free_i32(tmp2); goto do_dynamic; } tcg_temp_free_i32(tmp); +tcg_temp_free_i32(tmp2); account_inline_branch(s); break; case CC_OP_TM_64: -- 1.6.0.2
[Qemu-devel] [PULL 00/13] s390x patch queue June 03 2011
Hi, This is my current patch queue for s390x related work. It contains: * compile fixes * add temp_frees where missing * fix LMH, CKSM instructions * update bootloader for increased bootup speed * implement LRVGR instruction With these patches, networking finally works for emulated s390x guests. Please pull. Alex The following changes since commit 578c7b2ca8ee9e97fa8693b1a83d517e8e3f962e: Juha Riihim?ki (1): audio: fix integer overflow expression are available in the git repository at: git://repo.or.cz/qemu/agraf.git s390-next Alexander Graf (4): s390x: update zipl rom s390x: free tmp explicitly in every opcode for disas_a5() s390x: fix cksm instruction s390x: implement lrvgr Stefan Weil (9): target-s390x: Fix build for non-linux hosts target-s390x: Fix wrong argument in call of tcg_gen_shl_i64() target-s390x: Fix duplicate call of tcg_temp_new_i64 target-s390x: Add missing tcg_temp_free_i64() in gen_jcc() target-s390x: Add missing tcg_temp_free_i64() in do_mh() target-s390x: Add missing tcg_temp_free_i64() in disas_b2() target-s390x: Add missing tcg_temp_free_i64() in disas_s390_insn(), opc == 0x8e target-s390x: Add missing tcg_temp_free_i64() in disas_s390_insn(), opc == 0x90 target-s390x: Add missing tcg_temp_free_i32() pc-bios/s390-zipl.rom| Bin 3336 - 3304 bytes target-s390x/helper.c|5 - target-s390x/op_helper.c | 28 target-s390x/translate.c | 31 +++ 4 files changed, 35 insertions(+), 29 deletions(-)
[Qemu-devel] [PATCH 11/13] s390x: free tmp explicitly in every opcode for disas_a5()
The disas_a5() function provided a TCG tmp variable which was populated by the respective opcode implementations, but freed at the end of the function in generic code. That makes it really hard for code review, so let's move the freeing to the same scope as the actual allocation. Signed-off-by: Alexander Graf ag...@suse.de --- target-s390x/translate.c | 13 - 1 files changed, 12 insertions(+), 1 deletions(-) diff --git a/target-s390x/translate.c b/target-s390x/translate.c index 5828b5f..afeb5e6 100644 --- a/target-s390x/translate.c +++ b/target-s390x/translate.c @@ -2334,18 +2334,22 @@ static void disas_a5(DisasContext *s, int op, int r1, int i2) case 0x0: /* IIHH R1,I2 [RI] */ tmp = tcg_const_i64(i2); tcg_gen_deposit_i64(regs[r1], regs[r1], tmp, 48, 16); +tcg_temp_free_i64(tmp); break; case 0x1: /* IIHL R1,I2 [RI] */ tmp = tcg_const_i64(i2); tcg_gen_deposit_i64(regs[r1], regs[r1], tmp, 32, 16); +tcg_temp_free_i64(tmp); break; case 0x2: /* IILH R1,I2 [RI] */ tmp = tcg_const_i64(i2); tcg_gen_deposit_i64(regs[r1], regs[r1], tmp, 16, 16); +tcg_temp_free_i64(tmp); break; case 0x3: /* IILL R1,I2 [RI] */ tmp = tcg_const_i64(i2); tcg_gen_deposit_i64(regs[r1], regs[r1], tmp, 0, 16); +tcg_temp_free_i64(tmp); break; case 0x4: /* NIHH R1,I2 [RI] */ case 0x8: /* OIHH R1,I2 [RI] */ @@ -2370,6 +2374,7 @@ static void disas_a5(DisasContext *s, int op, int r1, int i2) set_cc_nz_u32(s, tmp32); tcg_temp_free_i64(tmp2); tcg_temp_free_i32(tmp32); +tcg_temp_free_i64(tmp); break; case 0x5: /* NIHL R1,I2 [RI] */ case 0x9: /* OIHL R1,I2 [RI] */ @@ -2395,6 +2400,7 @@ static void disas_a5(DisasContext *s, int op, int r1, int i2) set_cc_nz_u32(s, tmp32); tcg_temp_free_i64(tmp2); tcg_temp_free_i32(tmp32); +tcg_temp_free_i64(tmp); break; case 0x6: /* NILH R1,I2 [RI] */ case 0xa: /* OILH R1,I2 [RI] */ @@ -2420,6 +2426,7 @@ static void disas_a5(DisasContext *s, int op, int r1, int i2) set_cc_nz_u32(s, tmp32); tcg_temp_free_i64(tmp2); tcg_temp_free_i32(tmp32); +tcg_temp_free_i64(tmp); break; case 0x7: /* NILL R1,I2 [RI] */ case 0xb: /* OILL R1,I2 [RI] */ @@ -2443,29 +2450,33 @@ static void disas_a5(DisasContext *s, int op, int r1, int i2) set_cc_nz_u32(s, tmp32);/* signedness should not matter here */ tcg_temp_free_i64(tmp2); tcg_temp_free_i32(tmp32); +tcg_temp_free_i64(tmp); break; case 0xc: /* LLIHH R1,I2 [RI] */ tmp = tcg_const_i64( ((uint64_t)i2) 48 ); store_reg(r1, tmp); +tcg_temp_free_i64(tmp); break; case 0xd: /* LLIHL R1,I2 [RI] */ tmp = tcg_const_i64( ((uint64_t)i2) 32 ); store_reg(r1, tmp); +tcg_temp_free_i64(tmp); break; case 0xe: /* LLILH R1,I2 [RI] */ tmp = tcg_const_i64( ((uint64_t)i2) 16 ); store_reg(r1, tmp); +tcg_temp_free_i64(tmp); break; case 0xf: /* LLILL R1,I2 [RI] */ tmp = tcg_const_i64(i2); store_reg(r1, tmp); +tcg_temp_free_i64(tmp); break; default: LOG_DISAS(illegal a5 operation 0x%x\n, op); gen_illegal_opcode(s, 2); return; } -tcg_temp_free_i64(tmp); } static void disas_a7(DisasContext *s, int op, int r1, int i2) -- 1.6.0.2
[Qemu-devel] [PATCH 08/13] target-s390x: Add missing tcg_temp_free_i64() in disas_s390_insn(), opc == 0x8e
From: Stefan Weil w...@mail.berlios.de Signed-off-by: Stefan Weil w...@mail.berlios.de Signed-off-by: Alexander Graf ag...@suse.de --- target-s390x/translate.c |2 ++ 1 files changed, 2 insertions(+), 0 deletions(-) diff --git a/target-s390x/translate.c b/target-s390x/translate.c index f3f42a9..c5a3930 100644 --- a/target-s390x/translate.c +++ b/target-s390x/translate.c @@ -4596,6 +4596,8 @@ static void disas_s390_insn(DisasContext *s) store_reg32(r1, tmp32_1); tcg_gen_trunc_i64_i32(tmp32_2, tmp2); store_reg32(r1 + 1, tmp32_2); +tcg_temp_free_i64(tmp); +tcg_temp_free_i64(tmp2); break; case 0x98: /* LM R1,R3,D2(B2) [RS] */ case 0x90: /* STMR1,R3,D2(B2) [RS] */ -- 1.6.0.2
[Qemu-devel] [PATCH 01/13] s390x: update zipl rom
The zipl bootloader rom we have has seen some dramatic speedups upstream, so let's update it to improve the experience when booting a guest image. This binary is based on commit id 9a0842dd9823d529f721b418d554f17c72e009e3. Signed-off-by: Alexander Graf ag...@suse.de --- pc-bios/s390-zipl.rom | Bin 3336 - 3304 bytes 1 files changed, 0 insertions(+), 0 deletions(-) diff --git a/pc-bios/s390-zipl.rom b/pc-bios/s390-zipl.rom index f7af9b155dc27500d4619ea6c9eb530d27a79f5d..3115128efe465a024b2deb780573358ae1b829a4 100644 GIT binary patch literal 3304 zcmZuzdvH`8UOC?hP%xJ4gtbake-C44GpDB0K-eVH#`h2rHiy0klJiXfJjJU*wBL2 zu98~fSXolRYISAmgBTqR@7m3wA0`I)nZJR#L3~;o=?oM|YfFXzU;XuD|ar0V{^ z`#9hEp1#LuDZ07)R6y-GN2%*p3mEJg$a6YO#cyIM?;njz8yBuGsr!Vy9C#g~; zyiW#_?m-n26a}9nAQk{6b4=2VKlANSdN%kze)ESiF5IK@-#vl{v!wIqmBgG(I; zszC{;8J?$xMOxbrnAZjk_ed-V3;$L_-iM}H_`TaqVYS8}c=HzSU*iryUs+sP{4^w zqAE3m$cYFa?aMt+;anBfG)3%DgH!bB3ds3B6|_MNk4%q3$HZk#-Rp?R5xYhK7w zYsiR^3`T_?PQ@b9F55G7^GmS47{+^B3fe!Q*p;9io8tEf9?gpLwlt%54FDrvbz} zYS?RrmyNjB9xGvd+%!i@RG3ZWRPG37gQwNtD8c^E(olKsM?XyAO`ZODN}~$ADfH z%j@X0j-osyXXdIQ5vEb9mJCQ%?j~9WX?Ue30ShUC#X1=cs6Ov3cu0kCnJqBC?iqh z2)5)zFK`^EF5o*F5#^dAB7)`+bfPZc@keeq;u4sekbB;+0V7mN7LbTCH4cB5Jt$F z+^FdZ?=tB1(7()ka$L|BeKtXo_CjCC)5JgcmZhIL!fRcew){j=c8^6c^wf*idZ zg!=^K4YiU)zfE^I615YyB5pbcEVRB2;N6JTVYYGYUyxV`+pF~6YPHVrYx+6J9ETP| z(;GqeY5JgEFJzyzkJUh7MMu)IHd|l857{Za_s9d)8y{(|E(~MB$XHDP=v}=9aj_ z$y_;22Y`{QWQfSH==A{#oH%eny5@yIyj)oM!5wVLT{=+!V+V(GV=!@FrMme z#KY7cRZSkG1DqAc1H1R;LNpUz15e=RvcH8cHU!ae?R97byTAgMp#EIIFEnrhvYx) zEWY;G-FW8g7CfJ|lX$+!y{@^QvQtU%xj18M5#*7d)|?GgHl#3vo1Ah`f(dR}35 z%VMNPlh2wf$U3BJq!(*H`sZ~gk_}OKKedn(%?b)T`7AojNu$xiPAnTl-V^l7(!?T zwd+$S=rAx9w9kpfkOOpcy%S4tFV;8OU=FKQzX(?EGh9GRfG^vgX9diJ_+hP9(`T zVkt;ib0dLFgNxaaga@h#-5ZU-3me*F(G)@V+}pIWrbr4pZc3+aksb)-b%zcZE!-ii z8LhMbD8_hueB2i|Vw|sIOwe3ROpZ@pk8gHNbkqO(;mB@A28dX5qj;vbbrdL?*HSJ z_U5Gl16D=ePbpyYVXlUsYku3nFo@@vqaazfy`aWTJC_eCz~T8fR%_vB(M=EN323l z)Cc{Jh3JxoGVvdX9Cur@7j006$7^$Pls%Y~TDs2Hwne_4~16qW7~UiqR{wWR%~ zXXB15^vjSQ0G}$_Xw~oTRJ;UmTeo25%8nxufB~*3r*mxLnV*Jx!`IX}$X!_JyYq z-p2J=cGSJ3`(R|AG$YsKV-0U$;EO=v|+iL7lUO0ocxH9426A5%)W$j-C)#PM`}H zpfHRipm=Jjs8WI4(a}^)AVjTLS(#)`a-VV3_7CL0RAARCQSey!NzDBMK|9)yKO zxbMCm%Mz_)_3ber_l8C?%yHt3d4tbFK4W}!+}ljeypfdZq%7u?XG0Y#k-I=kvFaR zcj|u6M`o8iG3cPF0-;(F=(EqEZ5Zr#7sc;JmX_r)-tA=u^ip#kMneNP#5S1DT8XF z_a8M$2H^#d;$62qdEQUv0se1B;fe{~H!-Ev~b@2ISP3wse)E3V0-jy@^$!5_ zla;k4z|@C;r$9HmE?L8^v~PA7QC=i~ydaS|*plRwPyqb~%4_5_t*K-WaiTq4a zrwkY8-g##+WWswiG-GIxQ@d?#Oi2I4rovI!R|C5A}w(-jsKfpLC0ixFcEp2icI%; z$MH5`S7@nrEwuw2Q)ptvIeoegQK{bBsrR1TF-N$A7d_~f@%tTFXn;PQ1Oi8{29l zPu~+GS!G-mOBg=$E(r1^3I^Ce%$I6*!dbgL?J@|3)p9HyvgriyYtyuCXtEGd zLlMJ4zqnOLmFBHtw|w*B%L`k#_{!wIV{-LF@!W+nf9@ChGO!C0bG1Ln0q9uhW zo;3PQ46rryNkqH4hiy{Y?G!0aNKO`a3@|IXviId$W|V(kfoGGJ7{Y%Xs!hwC z;HS44ksYQoZNF#_b~k1k-rDnDPBID4-md_jcJS)zdg?YEIz+^hxshd=(6P(PPBe z%5i3CsriMPE})vvlHQ{aG!uPXiw@MHW0^G@mQ?t3n6e_kaU!JwNwyyf_Z|~{ z?$5qwzHsjG@Vzq@edWIUF_PCZ!%-foc_d;2h0pnr3)!fDZaK38MLpWN8mwrTU0 z_ScSreBshpw{~pn?CSnnk?oH956rl=JrJIj;Eg9x$BpvfRr*`RQf6e(|dL$}_zF zy4ARJ+42iZ(3=-_=Eii2K#T(5i=5KN4H1@pkSet77m4WF!i^sz5~sd?S{tLBfu zADLZ0XYRbuHq2jOnm@+6h{PaC?dYiKOKVWm|o`lqA+SuU#u+tBBe=cfo|TjjR+ z=Jt)WDc;`E)+#%?;;rqSo8|VlD+{K6Qv{cp5D$*rtfO+?trcx?LCS1t|xlh;;kbb zBa+OqP}1ryS!B{8a#L4tXX`AvBHq!#YMzX5+$s}Yu-(}k?~s5j-rJFou-LP6#D`K^ gQS=FXtXw{_RMI)+9tQeds~{`}VD$3JT%7a#uHJ^%m! literal 3336 zcmZuzeQ*@z8GrU}!=CwoO@Ixl{ev#L=cZaAwY_|;lp4po`M#rtvN`5laQn#p@LPe zB}Fa$I8w2#wS5(-WJL#L%d9k+hWl==q@GXbpA61t^!ygyhlb*O=Cf6se~(y2GI zd+$E`eEgo@`#jIP^6D;gTcSKp7#iaohVUWTn=4ov`sJ7r_)?nZKit2Bw0?HUFlJu zpc2{XeaIHvY^wG@Ls@`c1@V-M+JPT1nzbK~v=%3d(LO#(zL|(nL8(1+MA+f(|@o z(uBSVQ~`-Dt9@S%nJE=tH-`H)uQwV(gn!FH{{zDShPn-Z~0PO(Q(rhwHbv-h$6E z*Ayn{t|f{Wi^o-F#~j?+FU`l~QH4k~Au6h(yOHKxAKjOrW}Qk{xi5e-qOEF!0n zmRmQOO3RsBSMxb#=05!3tJIU7==xljYtL1N2CT*1lRv0c2c8y27SgmKiXHvnRbq zaCiztoRmZUI-sn_wdQD^mqO+#XwRiWDpW{KRs+%sXyo;UD2V?*f{|iutKEo4d+o` zfbIu_rJrRF%h`PuU^q-;WEE+!G+_xuax!=j0z9l2mM**fck!NFlfBAXqG-g@t%zCZ zT9;WH60lMkjhLbA$;;32H^`eLFAae|L%_LC9fUq5BZG;xemH%29TEEy6SPR%Vyi zD|x5?G2}JywcHV~dt9!Ehl{@NSE%QmauHGX(q*vd3_{wHTN}fMkd!8e|#J==7#s zMJDVuSD;?PcEn3X!JqQ85jvajbeMe)e+cb5C4WG!3Xoi{1(p1L*c^iwO}%S?JfP(7 zsb`C^C~VbWp$ZiwyknF^{$RuySqza$xbJMy_@+AV_5AQG^Qn3TZlHR=A({8gly` zJf9t}v{4((RJs(oDt);$z!}wpw=wbrYJHIAmmPxSZ7}t;JOcecD7Kl^dtD1vQG`{v zq!LvZa!`o+B89XL(rR3FM1UtgJlKz@T;r+dI#AbCkZ9Wv~Ap@eP)pPhZ)`xjg zp4+_02;TjS67_{BT7_aJz`K3!QCR$)`~VCIT^^h)N?ylhn+^;A9fPBKkg)P-|x}@ zQL=V;vcR#pn*kHB^9C4^N`6+RO5)0443{K%N{+0efDQ}7)N!-8$PAPXYX*IX-8 zMqxLSFxQrp#R(y+A!=!Ga(8eq(*|)k=Ke(k$j7KT?^fK06iYgmT-@c^mGJ0t;_Op zzUTrW$8sX;((j4GDO)D}h=@IHji_bCEeG0ohqlxa-Yp=R{ypT#^UdShd z_g6HUghi4)7F+11Bzqihgh=yKd}#CQjb2s{TBdbGUhG~gbj)w#T!i0_~M^GK$j zkz5tW`O7()=58thpgaQ{@O$uGtPWQLCNoN)tJ@GotAuIo5L3wgVNT!6Z}2Mp5zJ zp551@!O9#6QWEkH`ts?5TcHa*_6H`p}J#uL3!EiaX})vC~08$aY%7JZ%Ip``s+ z3OVO0jqOlhr?}FxFMClnG1f`g!g~$!T7+4RO5utQ7N5qH7sTtpopyzwgNCYxnb3XH zNkLj?XS`l8SFmhuis~a?FW2bxF?~yuIa!JYPT5Lvv5*)%8yhUzhoS+!?^+m)Pw_? zt0VRQ2`=n31)hQZ8_IS+Rxh3ocxlu$JvMIX_aY-Ynrcf@!2C$hG6Fg0`Tvxgw
[Qemu-devel] [PATCH 02/13] target-s390x: Fix build for non-linux hosts
From: Stefan Weil w...@mail.berlios.de linux/kvm.h is not always available for compilation. Neither linux/kvm.h nor kvm.h are needed, so remove both which also fixes the build problem for non-linux hosts. Cc: Alexander Graf ag...@suse.de Signed-off-by: Stefan Weil w...@mail.berlios.de Signed-off-by: Alexander Graf ag...@suse.de --- target-s390x/helper.c |5 - 1 files changed, 0 insertions(+), 5 deletions(-) diff --git a/target-s390x/helper.c b/target-s390x/helper.c index c79af46..745d8c5 100644 --- a/target-s390x/helper.c +++ b/target-s390x/helper.c @@ -28,11 +28,6 @@ #include qemu-common.h #include qemu-timer.h -#if !defined(CONFIG_USER_ONLY) -#include linux/kvm.h -#include kvm.h -#endif - //#define DEBUG_S390 //#define DEBUG_S390_PTE //#define DEBUG_S390_STDOUT -- 1.6.0.2
[Qemu-devel] [PATCH 13/13] s390x: implement lrvgr
The LRVGR instruction was missing. Implement it, so everyone's happy. Reported-by: Balazs Kutil bku...@novell.com Signed-off-by: Alexander Graf ag...@suse.de --- target-s390x/translate.c |3 +++ 1 files changed, 3 insertions(+), 0 deletions(-) diff --git a/target-s390x/translate.c b/target-s390x/translate.c index afeb5e6..eda4624 100644 --- a/target-s390x/translate.c +++ b/target-s390x/translate.c @@ -3473,6 +3473,9 @@ static void disas_b9(DisasContext *s, int op, int r1, int r2) tcg_temp_free_i64(tmp2); tcg_temp_free_i64(tmp3); break; +case 0x0f: /* LRVGRR1,R2 [RRE] */ +tcg_gen_bswap64_i64(regs[r1], regs[r2]); +break; case 0x1f: /* LRVR R1,R2 [RRE] */ tmp32_1 = load_reg32(r2); tcg_gen_bswap32_i32(tmp32_1, tmp32_1); -- 1.6.0.2
[Qemu-devel] [PATCH 06/13] target-s390x: Add missing tcg_temp_free_i64() in do_mh()
From: Stefan Weil w...@mail.berlios.de Signed-off-by: Stefan Weil w...@mail.berlios.de Signed-off-by: Alexander Graf ag...@suse.de --- target-s390x/translate.c |1 + 1 files changed, 1 insertions(+), 0 deletions(-) diff --git a/target-s390x/translate.c b/target-s390x/translate.c index 6ec77ec..a11cb19 100644 --- a/target-s390x/translate.c +++ b/target-s390x/translate.c @@ -2094,6 +2094,7 @@ do_mh: tcg_gen_add_i64(tmp, tmp, tmp3); } tcg_temp_free_i64(tmp); +tcg_temp_free_i64(tmp3); tcg_temp_free_i64(tmp4); break; case 0x2c: /* STCMH R1,M3,D2(B2) [RSY] */ -- 1.6.0.2
Re: [Qemu-devel] QMP: RFC: I/O error info query-stop-reason
On 06/03/2011 04:26 AM, Daniel P. Berrange wrote: On Thu, Jun 02, 2011 at 03:01:24PM -0300, Luiz Capitulino wrote: On Thu, 02 Jun 2011 09:02:30 -0500 Anthony Liguorianth...@codemonkey.ws wrote: On 06/02/2011 08:24 AM, Jiri Denemark wrote: On Thu, Jun 02, 2011 at 08:08:35 -0500, Anthony Liguori wrote: On 06/02/2011 04:06 AM, Daniel P. Berrange wrote: B. query-stop-reason I also have a simple solution for item 2. The vm_stop() accepts a reason argument, so we could store it somewhere and return it as a string, like: - { execute: query-stop-reason } - { return: { reason: user } } Valid reasons could be: user, debug, shutdown, diskfull (hey, this should be ioerror, no?), watchdog, panic, savevm, loadvm, migrate. Also note that we have a STOP event. It should be extended with the stop reason too, for completeness. Can we just extend query-block? Primarily we want 'query-stop-reason' to tell us what caused the VM CPUs to stop. If that reason was 'ioerror', then 'query-block' could be used to find out which particular block device(s) caused the IO error to occurrget the reason that was in the BLOCK_IO_ERROR event. My concern is that we're over abstracting here. We're not going to add additional stop reasons in the future. Maybe just add an 'io-error': True to query-state. Sure, adding a new field to query-state response would work as well. And it seems like a good idea to me since one already needs to call query-status to check if CPUs are stopped or not so it makes sense to incorporate the additional information there as well. And if you want to be safe for the future, the new field doesn't have to be boolean 'io-error' but it can be the string 'reason' which Luiz suggested above. String enumerations are a Bad Thing. It's impossible to figure out what strings are valid and it lacks type safety. Adding more booleans provides better type safety, and when we move to QAPI with a queryable schema, provides a way to figure out exactly what combinations are supported by QEMU. To summarize: 1. Add a 'io-error' field to query-status (which is only present if field 'running' is false) This isn't really enough. There are many reasons why a VM may have transitioned to the paused state, of which IO Error is merely one. The query-status needs to be able to report what the reason for the transitioning to the paused state is. No, there's only two reasons: 1) IO Error (and user configured pause on I/O error) 2) The result of some user action (an explicit stop, live migration, etc.) The fact that all of these things call vm_stop() internal is an implementation detail. Adding a string parameter to vm_stop() of a reason may seem like an easy thing to do but you're taking something that is an internal concept in QEMU and making it part of an interface that needs to be supported forever. That's why I'm suggesting modelling a user visible concept (I/O errors stop a guest) instead of trying to model an internal QEMU concept (vm_stop()). If you have other user visible concepts that you want to know about, please share the use-cases and we can think about how to model it such that it's not exposing internal QEMU details. Regards, Anthony Liguori 2. Extend query-block to contain error information associated with the device. This is interesting, because this information will be available even if the error didn't cause the VM to stop Apps will only look for this data, if the query-status stop reason indicates that it was stopped due to an I/O error. Regards, Daniel
Re: [Qemu-devel] QMP: RFC: I/O error info query-stop-reason
On Fri, Jun 03, 2011 at 07:43:24AM -0500, Anthony Liguori wrote: On 06/03/2011 04:26 AM, Daniel P. Berrange wrote: On Thu, Jun 02, 2011 at 03:01:24PM -0300, Luiz Capitulino wrote: On Thu, 02 Jun 2011 09:02:30 -0500 Anthony Liguorianth...@codemonkey.ws wrote: On 06/02/2011 08:24 AM, Jiri Denemark wrote: On Thu, Jun 02, 2011 at 08:08:35 -0500, Anthony Liguori wrote: On 06/02/2011 04:06 AM, Daniel P. Berrange wrote: B. query-stop-reason I also have a simple solution for item 2. The vm_stop() accepts a reason argument, so we could store it somewhere and return it as a string, like: - { execute: query-stop-reason } - { return: { reason: user } } Valid reasons could be: user, debug, shutdown, diskfull (hey, this should be ioerror, no?), watchdog, panic, savevm, loadvm, migrate. Also note that we have a STOP event. It should be extended with the stop reason too, for completeness. Can we just extend query-block? Primarily we want 'query-stop-reason' to tell us what caused the VM CPUs to stop. If that reason was 'ioerror', then 'query-block' could be used to find out which particular block device(s) caused the IO error to occurrget the reason that was in the BLOCK_IO_ERROR event. My concern is that we're over abstracting here. We're not going to add additional stop reasons in the future. Maybe just add an 'io-error': True to query-state. Sure, adding a new field to query-state response would work as well. And it seems like a good idea to me since one already needs to call query-status to check if CPUs are stopped or not so it makes sense to incorporate the additional information there as well. And if you want to be safe for the future, the new field doesn't have to be boolean 'io-error' but it can be the string 'reason' which Luiz suggested above. String enumerations are a Bad Thing. It's impossible to figure out what strings are valid and it lacks type safety. Adding more booleans provides better type safety, and when we move to QAPI with a queryable schema, provides a way to figure out exactly what combinations are supported by QEMU. To summarize: 1. Add a 'io-error' field to query-status (which is only present if field 'running' is false) This isn't really enough. There are many reasons why a VM may have transitioned to the paused state, of which IO Error is merely one. The query-status needs to be able to report what the reason for the transitioning to the paused state is. No, there's only two reasons: 1) IO Error (and user configured pause on I/O error) 2) The result of some user action (an explicit stop, live migration, etc.) The fact that all of these things call vm_stop() internal is an implementation detail. Adding a string parameter to vm_stop() of a reason may seem like an easy thing to do but you're taking something that is an internal concept in QEMU and making it part of an interface that needs to be supported forever. That's why I'm suggesting modelling a user visible concept (I/O errors stop a guest) instead of trying to model an internal QEMU concept (vm_stop()). If you have other user visible concepts that you want to know about, please share the use-cases and we can think about how to model it such that it's not exposing internal QEMU details. None of the requested info is exposing internal QEMU impl details with one exception. The reasons are either administrative commands, host OS failures, guest OS failures, or the exception, KVM internal emulation failure. The core problem is that an app connects to QEMU, finds it is paused, and wants to decide what action to take. If the guest is paused due to a previous admin 'stop' command, it will allow resuming. If it is paused due to guest OS poweroff, it might decide to issue a 'system_reset' command and then 'resume'. If it is paused due to watchdog, it might decide it wants to pmemsave the guest OS, and then system_reset+resume. If it is paused because KVM hit an emulation failure, it may wish to attach to the debugger interface and capture VM/QEMU state. The other problem is that a sysadmin finds a guest unexpectedly paused, and the mgmt app can't tell it why and they want to troubleshoot the problem. QEMU should be able to tell the sysadmin why it is in this state, so they can proceed with trouble shooting in a suitable direction, whether the host OS, KVM itself, or the guest OS, or the mgt tool. Daniel -- |: http://berrange.com -o-http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|
[Qemu-devel] [PATCH] scsi: fix tracing of scsi requests with simple backend
The simple backend only supports a maximum of 6 arguments. Split the scsi_req_parsed event in two parts to cope with the limit. Signed-off-by: Paolo Bonzini pbonz...@redhat.com --- hw/scsi-bus.c |6 +- trace-events |3 ++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/hw/scsi-bus.c b/hw/scsi-bus.c index 837f24e..ad6a730 100644 --- a/hw/scsi-bus.c +++ b/hw/scsi-bus.c @@ -413,7 +413,11 @@ int scsi_req_parse(SCSIRequest *req, uint8_t *buf) scsi_req_xfer_mode(req); req-cmd.lba = scsi_req_lba(req); trace_scsi_req_parsed(req-dev-id, req-lun, req-tag, buf[0], - req-cmd.mode, req-cmd.xfer, req-cmd.lba); + req-cmd.mode, req-cmd.xfer); +if (req-cmd.lba != -1) { +trace_scsi_req_parsed_lba(req-dev-id, req-lun, req-tag, buf[0], + req-cmd.lba); +} return 0; } diff --git a/trace-events b/trace-events index 3137a15..e0e9574 100644 --- a/trace-events +++ b/trace-events @@ -210,7 +210,8 @@ disable scsi_req_alloc(int target, int lun, int tag) target %d lun %d tag %d disable scsi_req_data(int target, int lun, int tag, int len) target %d lun %d tag %d len %d disable scsi_req_dequeue(int target, int lun, int tag) target %d lun %d tag %d disable scsi_req_continue(int target, int lun, int tag) target %d lun %d tag %d -disable scsi_req_parsed(int target, int lun, int tag, int cmd, int mode, int xfer, uint64_t lba) target %d lun %d tag %d command %d dir %d length %d lba %PRIu64 +disable scsi_req_parsed(int target, int lun, int tag, int cmd, int mode, int xfer) target %d lun %d tag %d command %d dir %d length %d +disable scsi_req_parsed_lba(int target, int lun, int tag, int cmd, uint64_t lba) target %d lun %d tag %d command %d lba %PRIu64 disable scsi_req_parse_bad(int target, int lun, int tag, int cmd) target %d lun %d tag %d command %d # vl.c -- 1.7.4.4
Re: [Qemu-devel] QMP: RFC: I/O error info query-stop-reason
On 06/03/2011 07:57 AM, Daniel P. Berrange wrote: On Fri, Jun 03, 2011 at 07:43:24AM -0500, Anthony Liguori wrote: On 06/03/2011 04:26 AM, Daniel P. Berrange wrote: errors stop a guest) instead of trying to model an internal QEMU concept (vm_stop()). If you have other user visible concepts that you want to know about, please share the use-cases and we can think about how to model it such that it's not exposing internal QEMU details. None of the requested info is exposing internal QEMU impl details with one exception. The reasons are either administrative commands, host OS failures, guest OS failures, or the exception, KVM internal emulation failure. The core problem is that an app connects to QEMU, finds it is paused, and wants to decide what action to take. If the guest is paused due to a previous admin 'stop' command, Let's be very clear here. QEMU does not provide a way to figure out what the previous QMP user did. That is not a use case we support today and it's not one we can support by just adding a reason to stop. It's far more complicated than just that. it will allow resuming. If it is paused due to guest OS poweroff, This is legitimate but only occurs if you use -no-shutdown. So having a query-state have a powered-off flag would be a Good Thing. it might decide to issue a 'system_reset' command and then 'resume'. If it is paused due to watchdog, I think what we're getting at is the need for an enumeration. So let's introduce one. Here's what I propose: SQMP query-status Return a json-object with the following information: - running: true if the VM is running, or false if it is paused (json-bool) - singlestep: true if the VM is in single step mode, false otherwise (json-bool) - status: one of the following values (json-string) (optional) prelaunch - QEMU was started with -S and guest has not started running - guest is actively running singlestep - guest is running in single step mode paused - guest has been paused via the 'stop' command postmigrate - guest is paused following a successful 'migrate' shutdown - guest is shut down (and -no-shutdown is in use) io-error - the last IOP has failed and the device is configured to pause on I/O errors watchdog-error - the watchdog action is configured to pause and has been triggered Example: - { execute: query-status } - { return: { running: true, singlestep: false, status: running } } EQMP Regards, Anthony Liguori it might decide it wants to pmemsave the guest OS, and then system_reset+resume. If it is paused because KVM hit an emulation failure, it may wish to attach to the debugger interface and capture VM/QEMU state. The other problem is that a sysadmin finds a guest unexpectedly paused, and the mgmt app can't tell it why and they want to troubleshoot the problem. QEMU should be able to tell the sysadmin why it is in this state, so they can proceed with trouble shooting in a suitable direction, whether the host OS, KVM itself, or the guest OS, or the mgt tool. Daniel
Re: [Qemu-devel] QMP: RFC: I/O error info query-stop-reason
On Fri, Jun 03, 2011 at 08:26:56AM -0500, Anthony Liguori wrote: On 06/03/2011 07:57 AM, Daniel P. Berrange wrote: On Fri, Jun 03, 2011 at 07:43:24AM -0500, Anthony Liguori wrote: On 06/03/2011 04:26 AM, Daniel P. Berrange wrote: errors stop a guest) instead of trying to model an internal QEMU concept (vm_stop()). If you have other user visible concepts that you want to know about, please share the use-cases and we can think about how to model it such that it's not exposing internal QEMU details. None of the requested info is exposing internal QEMU impl details with one exception. The reasons are either administrative commands, host OS failures, guest OS failures, or the exception, KVM internal emulation failure. The core problem is that an app connects to QEMU, finds it is paused, and wants to decide what action to take. If the guest is paused due to a previous admin 'stop' command, Let's be very clear here. QEMU does not provide a way to figure out what the previous QMP user did. That is not a use case we support today and it's not one we can support by just adding a reason to stop. It's far more complicated than just that. it will allow resuming. If it is paused due to guest OS poweroff, This is legitimate but only occurs if you use -no-shutdown. So having a query-state have a powered-off flag would be a Good Thing. it might decide to issue a 'system_reset' command and then 'resume'. If it is paused due to watchdog, I think what we're getting at is the need for an enumeration. So let's introduce one. Here's what I propose: SQMP query-status Return a json-object with the following information: - running: true if the VM is running, or false if it is paused (json-bool) - singlestep: true if the VM is in single step mode, false otherwise (json-bool) - status: one of the following values (json-string) (optional) prelaunch - QEMU was started with -S and guest has not started running - guest is actively running singlestep - guest is running in single step mode paused - guest has been paused via the 'stop' command postmigrate - guest is paused following a successful 'migrate' shutdown - guest is shut down (and -no-shutdown is in use) io-error - the last IOP has failed and the device is configured to pause on I/O errors watchdog-error - the watchdog action is configured to pause and has been triggered Perhaps I didn't communicate well, but this pretty much matches what I was trying to ask for in my previous message, so gets my vote! Daniel -- |: http://berrange.com -o-http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|
Re: [Qemu-devel] QMP: RFC: I/O error info query-stop-reason
On 2011-06-03 15:26, Anthony Liguori wrote: I think what we're getting at is the need for an enumeration. So let's introduce one. Here's what I propose: SQMP query-status Return a json-object with the following information: - running: true if the VM is running, or false if it is paused (json-bool) - singlestep: true if the VM is in single step mode, false otherwise (json-bool) - status: one of the following values (json-string) (optional) prelaunch - QEMU was started with -S and guest has not started running - guest is actively running singlestep - guest is running in single step mode singlestep is just a subset of debug stops. Better use the latter. paused - guest has been paused via the 'stop' command postmigrate - guest is paused following a successful 'migrate' shutdown - guest is shut down (and -no-shutdown is in use) io-error - the last IOP has failed and the device is configured to pause on I/O errors watchdog-error - the watchdog action is configured to pause and has been triggered And panic or internal-error. Jan -- Siemens AG, Corporate Technology, CT T DE IT 1 Corporate Competence Center Embedded Linux
Re: [Qemu-devel] QMP: RFC: I/O error info query-stop-reason
On Fri, 3 Jun 2011 14:39:41 +0100 Daniel P. Berrange berra...@redhat.com wrote: On Fri, Jun 03, 2011 at 08:26:56AM -0500, Anthony Liguori wrote: On 06/03/2011 07:57 AM, Daniel P. Berrange wrote: On Fri, Jun 03, 2011 at 07:43:24AM -0500, Anthony Liguori wrote: On 06/03/2011 04:26 AM, Daniel P. Berrange wrote: errors stop a guest) instead of trying to model an internal QEMU concept (vm_stop()). If you have other user visible concepts that you want to know about, please share the use-cases and we can think about how to model it such that it's not exposing internal QEMU details. None of the requested info is exposing internal QEMU impl details with one exception. The reasons are either administrative commands, host OS failures, guest OS failures, or the exception, KVM internal emulation failure. The core problem is that an app connects to QEMU, finds it is paused, and wants to decide what action to take. If the guest is paused due to a previous admin 'stop' command, Let's be very clear here. QEMU does not provide a way to figure out what the previous QMP user did. That is not a use case we support today and it's not one we can support by just adding a reason to stop. It's far more complicated than just that. it will allow resuming. If it is paused due to guest OS poweroff, This is legitimate but only occurs if you use -no-shutdown. So having a query-state have a powered-off flag would be a Good Thing. it might decide to issue a 'system_reset' command and then 'resume'. If it is paused due to watchdog, I think what we're getting at is the need for an enumeration. So let's introduce one. Here's what I propose: SQMP query-status Return a json-object with the following information: - running: true if the VM is running, or false if it is paused (json-bool) - singlestep: true if the VM is in single step mode, false otherwise (json-bool) - status: one of the following values (json-string) (optional) prelaunch - QEMU was started with -S and guest has not started running - guest is actively running singlestep - guest is running in single step mode paused - guest has been paused via the 'stop' command postmigrate - guest is paused following a successful 'migrate' shutdown - guest is shut down (and -no-shutdown is in use) io-error - the last IOP has failed and the device is configured to pause on I/O errors watchdog-error - the watchdog action is configured to pause and has been triggered Perhaps I didn't communicate well, but this pretty much matches what I was trying to ask for in my previous message, so gets my vote! Mine too, I like it. Expect patches next week :) My only comment is that, in case this an improved version of query-status we could have a new command (like query-statys2 or query-vm-status).
Re: [Qemu-devel] QMP: RFC: I/O error info query-stop-reason
On 06/03/2011 08:41 AM, Jan Kiszka wrote: On 2011-06-03 15:26, Anthony Liguori wrote: I think what we're getting at is the need for an enumeration. So let's introduce one. Here's what I propose: SQMP query-status Return a json-object with the following information: - running: true if the VM is running, or false if it is paused (json-bool) - singlestep: true if the VM is in single step mode, false otherwise (json-bool) - status: one of the following values (json-string) (optional) prelaunch - QEMU was started with -S and guest has not started running - guest is actively running singlestep - guest is running in single step mode singlestep is just a subset of debug stops. Better use the latter. paused - guest has been paused via the 'stop' command postmigrate - guest is paused following a successful 'migrate' shutdown - guest is shut down (and -no-shutdown is in use) io-error - the last IOP has failed and the device is configured to pause on I/O errors watchdog-error - the watchdog action is configured to pause and has been triggered And panic or internal-error. Can you add the request help spec text too? Is internal-error a KVM emulation error? If so, I'd rather make it kvm-emulation-error. Regards, Anthony Liguori Jan
Re: [Qemu-devel] QMP: RFC: I/O error info query-stop-reason
On 06/03/2011 08:44 AM, Luiz Capitulino wrote: On Fri, 3 Jun 2011 14:39:41 +0100 Daniel P. Berrangeberra...@redhat.com wrote: On Fri, Jun 03, 2011 at 08:26:56AM -0500, Anthony Liguori wrote: On 06/03/2011 07:57 AM, Daniel P. Berrange wrote: On Fri, Jun 03, 2011 at 07:43:24AM -0500, Anthony Liguori wrote: On 06/03/2011 04:26 AM, Daniel P. Berrange wrote: errors stop a guest) instead of trying to model an internal QEMU concept (vm_stop()). If you have other user visible concepts that you want to know about, please share the use-cases and we can think about how to model it such that it's not exposing internal QEMU details. None of the requested info is exposing internal QEMU impl details with one exception. The reasons are either administrative commands, host OS failures, guest OS failures, or the exception, KVM internal emulation failure. The core problem is that an app connects to QEMU, finds it is paused, and wants to decide what action to take. If the guest is paused due to a previous admin 'stop' command, Let's be very clear here. QEMU does not provide a way to figure out what the previous QMP user did. That is not a use case we support today and it's not one we can support by just adding a reason to stop. It's far more complicated than just that. it will allow resuming. If it is paused due to guest OS poweroff, This is legitimate but only occurs if you use -no-shutdown. So having a query-state have a powered-off flag would be a Good Thing. it might decide to issue a 'system_reset' command and then 'resume'. If it is paused due to watchdog, I think what we're getting at is the need for an enumeration. So let's introduce one. Here's what I propose: SQMP query-status Return a json-object with the following information: - running: true if the VM is running, or false if it is paused (json-bool) - singlestep: true if the VM is in single step mode, false otherwise (json-bool) - status: one of the following values (json-string) (optional) prelaunch - QEMU was started with -S and guest has not started running - guest is actively running singlestep - guest is running in single step mode paused - guest has been paused via the 'stop' command postmigrate - guest is paused following a successful 'migrate' shutdown - guest is shut down (and -no-shutdown is in use) io-error - the last IOP has failed and the device is configured to pause on I/O errors watchdog-error - the watchdog action is configured to pause and has been triggered Perhaps I didn't communicate well, but this pretty much matches what I was trying to ask for in my previous message, so gets my vote! Mine too, I like it. Expect patches next week :) My only comment is that, in case this an improved version of query-status we could have a new command (like query-statys2 or query-vm-status). No, let's just keep query-status and add the new field. For compatibility, you need to fall back to using running/singlestep anyway. Regards, Anthony Liguori
Re: [Qemu-devel] QMP: RFC: I/O error info query-stop-reason
On 2011-06-03 15:51, Anthony Liguori wrote: On 06/03/2011 08:41 AM, Jan Kiszka wrote: On 2011-06-03 15:26, Anthony Liguori wrote: I think what we're getting at is the need for an enumeration. So let's introduce one. Here's what I propose: SQMP query-status Return a json-object with the following information: - running: true if the VM is running, or false if it is paused (json-bool) - singlestep: true if the VM is in single step mode, false otherwise (json-bool) - status: one of the following values (json-string) (optional) prelaunch - QEMU was started with -S and guest has not started running - guest is actively running singlestep - guest is running in single step mode singlestep is just a subset of debug stops. Better use the latter. paused - guest has been paused via the 'stop' command postmigrate - guest is paused following a successful 'migrate' shutdown - guest is shut down (and -no-shutdown is in use) io-error - the last IOP has failed and the device is configured to pause on I/O errors watchdog-error - the watchdog action is configured to pause and has been triggered And panic or internal-error. Can you add the request help spec text too? Is internal-error a KVM emulation error? If so, I'd rather make it kvm-emulation-error. It would currently map on VMSTOP_PANIC, which is KVM_EXIT_UNKNOWN, KVM_EXIT_INTERNAL_ERROR or something arch-specific. Moreover, people may put TCG errors or whatever under this stop reason in the future. If we wanted kvm-emulation-error, we would have to introduce VMSTOP_KVM_EMULATION_ERROR. But I think internal error is sufficiently precise for this purpose: Fatal internal error that prevents further guest execution. Jan -- Siemens AG, Corporate Technology, CT T DE IT 1 Corporate Competence Center Embedded Linux
Re: [Qemu-devel] QMP: RFC: I/O error info query-stop-reason
On Fri, Jun 03, 2011 at 08:51:29AM -0500, Anthony Liguori wrote: On 06/03/2011 08:41 AM, Jan Kiszka wrote: On 2011-06-03 15:26, Anthony Liguori wrote: I think what we're getting at is the need for an enumeration. So let's introduce one. Here's what I propose: SQMP query-status Return a json-object with the following information: - running: true if the VM is running, or false if it is paused (json-bool) - singlestep: true if the VM is in single step mode, false otherwise (json-bool) - status: one of the following values (json-string) (optional) prelaunch - QEMU was started with -S and guest has not started running - guest is actively running singlestep - guest is running in single step mode singlestep is just a subset of debug stops. Better use the latter. paused - guest has been paused via the 'stop' command postmigrate - guest is paused following a successful 'migrate' shutdown - guest is shut down (and -no-shutdown is in use) io-error - the last IOP has failed and the device is configured to pause on I/O errors watchdog-error - the watchdog action is configured to pause and has been triggered And panic or internal-error. Can you add the request help spec text too? Is internal-error a KVM emulation error? If so, I'd rather make it kvm-emulation-error. Yeah, its for the kvm-all.c code which calls vm_stop(VMSTOP_PANIC); when it gets either an internal error, or an unhandled exit. Regards, Daniel -- |: http://berrange.com -o-http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|
Re: [Qemu-devel] [PATCH 00/11] cpu model bug fixes and definition corrections (v2)
(CCing Marcelo, Avi, and kvm mailing list, so they can help answering the uq/master patch flow question) On Fri, Jun 03, 2011 at 12:51:42AM +0200, Jan Kiszka wrote: On 2011-06-02 21:34, Eduardo Habkost wrote: Ouch, the subject prefix is completely wrong because of broken git-send-email config on my side, sorry. Please ignore the 'RHEL6 qemu-kvm' prefix, it is actually supposed to go to the main Qemu tree. Some of my review comments on John's original version still apply. Same for the advice on the patch flow (uq/master for kvm stuff). Just to make sure I didn't miss anything: 1) uq/master flow: considering that most of the series is not KVM-specific but depends on patch 02/11 (Allow an optional qemu_early_init_vcpu()) what is the best approach? Should the whole series go through uq/master, or just patch 02/11? In the case of the latter, shall the rest of the series wait for the patch to be merged upstream, or should patch 02/11 go to both branches at the same time? 2) Reviewing cpu_x86_cpuid() cpuid hacking code dropping -enable-nesting: should it hold the series, or may it be addressed after this series enter the tree? 3) Other recommendations for the qemu_early_init_vcpu() code (checkpatch.sh, return code evaluation, KVMState vs. VCPU): I will address those issues and send a new version. Something else I may have missed? -- Eduardo
Re: [Qemu-devel] [PATCH 00/11] cpu model bug fixes and definition corrections (v2)
On 2011-06-03 16:38, Eduardo Habkost wrote: (CCing Marcelo, Avi, and kvm mailing list, so they can help answering the uq/master patch flow question) On Fri, Jun 03, 2011 at 12:51:42AM +0200, Jan Kiszka wrote: On 2011-06-02 21:34, Eduardo Habkost wrote: Ouch, the subject prefix is completely wrong because of broken git-send-email config on my side, sorry. Please ignore the 'RHEL6 qemu-kvm' prefix, it is actually supposed to go to the main Qemu tree. Some of my review comments on John's original version still apply. Same for the advice on the patch flow (uq/master for kvm stuff). Just to make sure I didn't miss anything: 1) uq/master flow: considering that most of the series is not KVM-specific but depends on patch 02/11 (Allow an optional qemu_early_init_vcpu()) what is the best approach? Should the whole series go through uq/master, or just patch 02/11? In the case of the latter, shall the rest of the series wait for the patch to be merged upstream, or should patch 02/11 go to both branches at the same time? I would suggest to break out those patches that touch KVM infrastructure, post them for uq/master, and declare the rest of the series to depend on them. 2) Reviewing cpu_x86_cpuid() cpuid hacking code dropping -enable-nesting: should it hold the series, or may it be addressed after this series enter the tree? No that does not need to block the series. I would just recommend checking if there is anything in that diff directly related. If not, let's address it separately. 3) Other recommendations for the qemu_early_init_vcpu() code (checkpatch.sh, return code evaluation, KVMState vs. VCPU): I will address those issues and send a new version. Find some proposal for a refactored kvm_arch_get_supported_cpuid API below. Something else I may have missed? Nothing critical, I'm just hoping someone finds the time to fix sysconfigs loading when starting qemu from a build directory. :) Thanks, Jan ---8--- From: Jan Kiszka jan.kis...@siemens.com kvm: x86: Pass KVMState to kvm_arch_get_supported_cpuid kvm_arch_get_supported_cpuid checks for global cpuid restrictions, it does not require any CPUState reference. Changing its interface allows to call it before any VCPU is initialized. Signed-off-by: Jan Kiszka jan.kis...@siemens.com --- kvm.h |2 +- target-i386/cpuid.c | 20 target-i386/kvm.c | 30 +++--- 3 files changed, 28 insertions(+), 24 deletions(-) diff --git a/kvm.h b/kvm.h index d565dba..243b063 100644 --- a/kvm.h +++ b/kvm.h @@ -157,7 +157,7 @@ bool kvm_arch_stop_on_emulation_error(CPUState *env); int kvm_check_extension(KVMState *s, unsigned int extension); -uint32_t kvm_arch_get_supported_cpuid(CPUState *env, uint32_t function, +uint32_t kvm_arch_get_supported_cpuid(KVMState *env, uint32_t function, uint32_t index, int reg); void kvm_cpu_synchronize_state(CPUState *env); void kvm_cpu_synchronize_post_reset(CPUState *env); diff --git a/target-i386/cpuid.c b/target-i386/cpuid.c index 79e7580..e1ae3af 100644 --- a/target-i386/cpuid.c +++ b/target-i386/cpuid.c @@ -1144,10 +1144,12 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index, uint32_t count, break; case 7: if (kvm_enabled()) { -*eax = kvm_arch_get_supported_cpuid(env, 0x7, count, R_EAX); -*ebx = kvm_arch_get_supported_cpuid(env, 0x7, count, R_EBX); -*ecx = kvm_arch_get_supported_cpuid(env, 0x7, count, R_ECX); -*edx = kvm_arch_get_supported_cpuid(env, 0x7, count, R_EDX); +KVMState *s = env-kvm_state; + +*eax = kvm_arch_get_supported_cpuid(s, 0x7, count, R_EAX); +*ebx = kvm_arch_get_supported_cpuid(s, 0x7, count, R_EBX); +*ecx = kvm_arch_get_supported_cpuid(s, 0x7, count, R_ECX); +*edx = kvm_arch_get_supported_cpuid(s, 0x7, count, R_EDX); } else { *eax = 0; *ebx = 0; @@ -1179,10 +1181,12 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index, uint32_t count, break; } if (kvm_enabled()) { -*eax = kvm_arch_get_supported_cpuid(env, 0xd, count, R_EAX); -*ebx = kvm_arch_get_supported_cpuid(env, 0xd, count, R_EBX); -*ecx = kvm_arch_get_supported_cpuid(env, 0xd, count, R_ECX); -*edx = kvm_arch_get_supported_cpuid(env, 0xd, count, R_EDX); +KVMState *s = env-kvm_state; + +*eax = kvm_arch_get_supported_cpuid(s, 0xd, count, R_EAX); +*ebx = kvm_arch_get_supported_cpuid(s, 0xd, count, R_EBX); +*ecx = kvm_arch_get_supported_cpuid(s, 0xd, count, R_ECX); +*edx = kvm_arch_get_supported_cpuid(s, 0xd, count, R_EDX); } else { *eax = 0; *ebx = 0; diff --git a/target-i386/kvm.c b/target-i386/kvm.c index 1ae2d61..fbdf612 100644 ---
Re: [Qemu-devel] [PATCH v2 1/2] pxa2xx_lcd: add proper rotation support
On Wednesday 01 June 2011 12:28:06 Vasily Khoruzhick wrote: Until now, pxa2xx_lcd only supported 90deg rotation, but some machines (for example Zipit Z2) needs 270deg rotation. Signed-off-by: Vasily Khoruzhick anars...@gmail.com --- v2: codestyle fixes hw/framebuffer.c |2 + hw/pxa2xx_lcd.c | 86 +++-- input.c | 34 +++- qemu-options.hx |9 + vl.c | 11 ++- 5 files changed, 122 insertions(+), 20 deletions(-) diff --git a/hw/framebuffer.c b/hw/framebuffer.c index 24cdf25..5e9ab5e 100644 --- a/hw/framebuffer.c +++ b/hw/framebuffer.c @@ -78,6 +78,8 @@ void framebuffer_update_display( dest = ds_get_data(ds); if (dest_col_pitch 0) dest -= dest_col_pitch * (cols - 1); +if (dest_row_pitch 0) +dest -= dest_row_pitch * (rows - 1); first = -1; addr = pd; diff --git a/hw/pxa2xx_lcd.c b/hw/pxa2xx_lcd.c index e524802..a560bb0 100644 --- a/hw/pxa2xx_lcd.c +++ b/hw/pxa2xx_lcd.c @@ -665,7 +665,7 @@ static void pxa2xx_palette_parse(PXA2xxLCDState *s, int ch, int bpp) } } -static void pxa2xx_lcdc_dma0_redraw_horiz(PXA2xxLCDState *s, +static void pxa2xx_lcdc_dma0_redraw_rot0(PXA2xxLCDState *s, target_phys_addr_t addr, int *miny, int *maxy) { int src_width, dest_width; @@ -692,7 +692,7 @@ static void pxa2xx_lcdc_dma0_redraw_horiz(PXA2xxLCDState *s, fn, s-dma_ch[0].palette, miny, maxy); } -static void pxa2xx_lcdc_dma0_redraw_vert(PXA2xxLCDState *s, +static void pxa2xx_lcdc_dma0_redraw_rot90(PXA2xxLCDState *s, target_phys_addr_t addr, int *miny, int *maxy) { int src_width, dest_width; @@ -720,6 +720,61 @@ static void pxa2xx_lcdc_dma0_redraw_vert(PXA2xxLCDState *s, miny, maxy); } +static void pxa2xx_lcdc_dma0_redraw_rot180(PXA2xxLCDState *s, +target_phys_addr_t addr, int *miny, int *maxy) +{ +int src_width, dest_width; +drawfn fn = NULL; +if (s-dest_width) +fn = s-line_fn[s-transp][s-bpp]; +if (!fn) +return; + +src_width = (s-xres + 3) ~3; /* Pad to a 4 pixels multiple */ +if (s-bpp == pxa_lcdc_19pbpp || s-bpp == pxa_lcdc_18pbpp) +src_width *= 3; +else if (s-bpp pxa_lcdc_16bpp) +src_width *= 4; +else if (s-bpp pxa_lcdc_8bpp) +src_width *= 2; + +dest_width = s-xres * s-dest_width; +*miny = 0; +framebuffer_update_display(s-ds, + addr, s-xres, s-yres, + src_width, -dest_width, -s-dest_width, + s-invalidated, + fn, s-dma_ch[0].palette, miny, maxy); +} + +static void pxa2xx_lcdc_dma0_redraw_rot270(PXA2xxLCDState *s, + target_phys_addr_t addr, int *miny, int *maxy) +{ +int src_width, dest_width; +drawfn fn = NULL; +if (s-dest_width) +fn = s-line_fn[s-transp][s-bpp]; +if (!fn) +return; + +src_width = (s-xres + 3) ~3; /* Pad to a 4 pixels multiple */ +if (s-bpp == pxa_lcdc_19pbpp || s-bpp == pxa_lcdc_18pbpp) +src_width *= 3; +else if (s-bpp pxa_lcdc_16bpp) +src_width *= 4; +else if (s-bpp pxa_lcdc_8bpp) +src_width *= 2; + +dest_width = s-yres * s-dest_width; +*miny = 0; +framebuffer_update_display(s-ds, + addr, s-xres, s-yres, + src_width, -s-dest_width, dest_width, + s-invalidated, + fn, s-dma_ch[0].palette, + miny, maxy); +} + static void pxa2xx_lcdc_resize(PXA2xxLCDState *s) { int width, height; @@ -730,10 +785,11 @@ static void pxa2xx_lcdc_resize(PXA2xxLCDState *s) height = LCCR2_LPP(s-control[2]) + 1; if (width != s-xres || height != s-yres) { -if (s-orientation) +if (s-orientation == 90 || s-orientation == 270) { qemu_console_resize(s-ds, height, width); -else +} else { qemu_console_resize(s-ds, width, height); +} s-invalidated = 1; s-xres = width; s-yres = height; @@ -797,10 +853,11 @@ static void pxa2xx_update_display(void *opaque) } if (miny = 0) { -if (s-orientation) +if (s-orientation == 90 || s-orientation == 270) { dpy_update(s-ds, miny, 0, maxy - miny, s-xres); -else +} else { dpy_update(s-ds, 0, miny, s-xres, maxy - miny); +} } pxa2xx_lcdc_int_update(s); @@ -822,10 +879,19 @@ static void pxa2xx_lcdc_orientation(void *opaque, int angle) { PXA2xxLCDState *s = (PXA2xxLCDState *) opaque; -if (angle) { -s-dma_ch[0].redraw = pxa2xx_lcdc_dma0_redraw_vert; -} else { -
[Qemu-devel] [PATCH v3 1/2] pxa2xx_lcd: add proper rotation support
Until now, pxa2xx_lcd only supported 90deg rotation, but some machines (for example Zipit Z2) needs 270deg rotation. Signed-off-by: Vasily Khoruzhick anars...@gmail.com --- v2: codestyle fixes v3: fix dpy_update calls for 180 and 360 deg. rotation. hw/framebuffer.c |2 + hw/pxa2xx_lcd.c | 101 -- input.c | 34 +- qemu-options.hx |9 + vl.c | 11 +- 5 files changed, 136 insertions(+), 21 deletions(-) diff --git a/hw/framebuffer.c b/hw/framebuffer.c index 24cdf25..5e9ab5e 100644 --- a/hw/framebuffer.c +++ b/hw/framebuffer.c @@ -78,6 +78,8 @@ void framebuffer_update_display( dest = ds_get_data(ds); if (dest_col_pitch 0) dest -= dest_col_pitch * (cols - 1); +if (dest_row_pitch 0) +dest -= dest_row_pitch * (rows - 1); first = -1; addr = pd; diff --git a/hw/pxa2xx_lcd.c b/hw/pxa2xx_lcd.c index e524802..3db900b 100644 --- a/hw/pxa2xx_lcd.c +++ b/hw/pxa2xx_lcd.c @@ -665,7 +665,7 @@ static void pxa2xx_palette_parse(PXA2xxLCDState *s, int ch, int bpp) } } -static void pxa2xx_lcdc_dma0_redraw_horiz(PXA2xxLCDState *s, +static void pxa2xx_lcdc_dma0_redraw_rot0(PXA2xxLCDState *s, target_phys_addr_t addr, int *miny, int *maxy) { int src_width, dest_width; @@ -692,7 +692,7 @@ static void pxa2xx_lcdc_dma0_redraw_horiz(PXA2xxLCDState *s, fn, s-dma_ch[0].palette, miny, maxy); } -static void pxa2xx_lcdc_dma0_redraw_vert(PXA2xxLCDState *s, +static void pxa2xx_lcdc_dma0_redraw_rot90(PXA2xxLCDState *s, target_phys_addr_t addr, int *miny, int *maxy) { int src_width, dest_width; @@ -720,6 +720,61 @@ static void pxa2xx_lcdc_dma0_redraw_vert(PXA2xxLCDState *s, miny, maxy); } +static void pxa2xx_lcdc_dma0_redraw_rot180(PXA2xxLCDState *s, +target_phys_addr_t addr, int *miny, int *maxy) +{ +int src_width, dest_width; +drawfn fn = NULL; +if (s-dest_width) +fn = s-line_fn[s-transp][s-bpp]; +if (!fn) +return; + +src_width = (s-xres + 3) ~3; /* Pad to a 4 pixels multiple */ +if (s-bpp == pxa_lcdc_19pbpp || s-bpp == pxa_lcdc_18pbpp) +src_width *= 3; +else if (s-bpp pxa_lcdc_16bpp) +src_width *= 4; +else if (s-bpp pxa_lcdc_8bpp) +src_width *= 2; + +dest_width = s-xres * s-dest_width; +*miny = 0; +framebuffer_update_display(s-ds, + addr, s-xres, s-yres, + src_width, -dest_width, -s-dest_width, + s-invalidated, + fn, s-dma_ch[0].palette, miny, maxy); +} + +static void pxa2xx_lcdc_dma0_redraw_rot270(PXA2xxLCDState *s, + target_phys_addr_t addr, int *miny, int *maxy) +{ +int src_width, dest_width; +drawfn fn = NULL; +if (s-dest_width) +fn = s-line_fn[s-transp][s-bpp]; +if (!fn) +return; + +src_width = (s-xres + 3) ~3; /* Pad to a 4 pixels multiple */ +if (s-bpp == pxa_lcdc_19pbpp || s-bpp == pxa_lcdc_18pbpp) +src_width *= 3; +else if (s-bpp pxa_lcdc_16bpp) +src_width *= 4; +else if (s-bpp pxa_lcdc_8bpp) +src_width *= 2; + +dest_width = s-yres * s-dest_width; +*miny = 0; +framebuffer_update_display(s-ds, + addr, s-xres, s-yres, + src_width, -s-dest_width, dest_width, + s-invalidated, + fn, s-dma_ch[0].palette, + miny, maxy); +} + static void pxa2xx_lcdc_resize(PXA2xxLCDState *s) { int width, height; @@ -730,10 +785,11 @@ static void pxa2xx_lcdc_resize(PXA2xxLCDState *s) height = LCCR2_LPP(s-control[2]) + 1; if (width != s-xres || height != s-yres) { -if (s-orientation) +if (s-orientation == 90 || s-orientation == 270) { qemu_console_resize(s-ds, height, width); -else +} else { qemu_console_resize(s-ds, width, height); +} s-invalidated = 1; s-xres = width; s-yres = height; @@ -797,10 +853,24 @@ static void pxa2xx_update_display(void *opaque) } if (miny = 0) { -if (s-orientation) -dpy_update(s-ds, miny, 0, maxy - miny, s-xres); -else +switch (s-orientation) { +case 0: dpy_update(s-ds, 0, miny, s-xres, maxy - miny); +break; +case 90: +dpy_update(s-ds, miny, 0, maxy - miny, s-xres); +break; +case 180: +maxy = s-yres - maxy; +miny = s-yres - miny; +dpy_update(s-ds, 0, maxy, s-xres, miny - maxy); +break; +case 270: +maxy = s-yres - maxy; +miny = s-yres - miny; +dpy_update(s-ds,
Re: [Qemu-devel] [PATCH v3 1/2] pxa2xx_lcd: add proper rotation support
On Friday 03 June 2011 18:36:36 Vasily Khoruzhick wrote: Until now, pxa2xx_lcd only supported 90deg rotation, but some machines (for example Zipit Z2) needs 270deg rotation. Signed-off-by: Vasily Khoruzhick anars...@gmail.com --- v2: codestyle fixes v3: fix dpy_update calls for 180 and 360 deg. rotation. s/360/270
[Qemu-devel] [PATCH v3 2/2] Add support for Zipit Z2 machine
Zipit Z2 is small PXA270 based handheld. Signed-off-by: Vasily Khoruzhick anars...@gmail.com --- v2: codestyle fixes, added VMStateDescription for LCD device and AER915, traces clean up. v3: no changes Makefile.target |1 + hw/z2.c | 352 +++ 2 files changed, 353 insertions(+), 0 deletions(-) create mode 100644 hw/z2.c diff --git a/Makefile.target b/Makefile.target index 602d50d..5750499 100644 --- a/Makefile.target +++ b/Makefile.target @@ -358,6 +358,7 @@ obj-arm-y += omap2.o omap_dss.o soc_dma.o omap_gptimer.o omap_synctimer.o \ obj-arm-y += omap_sx1.o palm.o tsc210x.o obj-arm-y += nseries.o blizzard.o onenand.o vga.o cbus.o tusb6010.o usb-musb.o obj-arm-y += mst_fpga.o mainstone.o +obj-arm-y += z2.o obj-arm-y += musicpal.o bitbang_i2c.o marvell_88w8618_audio.o obj-arm-y += framebuffer.o obj-arm-y += syborg.o syborg_fb.o syborg_interrupt.o syborg_keyboard.o diff --git a/hw/z2.c b/hw/z2.c new file mode 100644 index 000..3e3591a --- /dev/null +++ b/hw/z2.c @@ -0,0 +1,352 @@ +/* + * PXA270-based Zipit Z2 device + * + * Copyright (c) 2011 by Vasily Khoruzhick anars...@gmail.com + * + * Code is based on mainstone platform. + * + * This code is licensed under the GNU GPL v2. + */ + +#include hw.h +#include pxa.h +#include arm-misc.h +#include devices.h +#include i2c.h +#include ssi.h +#include boards.h +#include sysemu.h +#include flash.h +#include blockdev.h +#include console.h +#include audio/audio.h + +#if 0 +#define DPRINTF(fmt, ...) \ +printf(fmt, ## __VA_ARGS__) +#else +#define DPRINTF(fmt, ...) +#endif + +static struct keymap map[0x100] = { +[0 ... 0xff] = { -1, -1 }, +[0x3b] = {0, 0}, /* Option = F1 */ +[0xc8] = {0, 1}, /* Up */ +[0xd0] = {0, 2}, /* Down */ +[0xcb] = {0, 3}, /* Left */ +[0xcd] = {0, 4}, /* Right */ +[0xcf] = {0, 5}, /* End */ +[0x0d] = {0, 6}, /* KPPLUS */ +[0xc7] = {1, 0}, /* Home */ +[0x10] = {1, 1}, /* Q */ +[0x17] = {1, 2}, /* I */ +[0x22] = {1, 3}, /* G */ +[0x2d] = {1, 4}, /* X */ +[0x1c] = {1, 5}, /* Enter */ +[0x0c] = {1, 6}, /* KPMINUS */ +[0xc9] = {2, 0}, /* PageUp */ +[0x11] = {2, 1}, /* W */ +[0x18] = {2, 2}, /* O */ +[0x23] = {2, 3}, /* H */ +[0x2e] = {2, 4}, /* C */ +[0x38] = {2, 5}, /* LeftAlt */ +[0xd1] = {3, 0}, /* PageDown */ +[0x12] = {3, 1}, /* E */ +[0x19] = {3, 2}, /* P */ +[0x24] = {3, 3}, /* J */ +[0x2f] = {3, 4}, /* V */ +[0x2a] = {3, 5}, /* LeftShift */ +[0x01] = {4, 0}, /* Esc */ +[0x13] = {4, 1}, /* R */ +[0x1e] = {4, 2}, /* A */ +[0x25] = {4, 3}, /* K */ +[0x30] = {4, 4}, /* B */ +[0x1d] = {4, 5}, /* LeftCtrl */ +[0x0f] = {5, 0}, /* Tab */ +[0x14] = {5, 1}, /* T */ +[0x1f] = {5, 2}, /* S */ +[0x26] = {5, 3}, /* L */ +[0x31] = {5, 4}, /* N */ +[0x39] = {5, 5}, /* Space */ +[0x3c] = {6, 0}, /* Stop = F2 */ +[0x15] = {6, 1}, /* Y */ +[0x20] = {6, 2}, /* D */ +[0x0e] = {6, 3}, /* Backspace */ +[0x32] = {6, 4}, /* M */ +[0x33] = {6, 5}, /* Comma */ +[0x3d] = {7, 0}, /* Play = F3 */ +[0x16] = {7, 1}, /* U */ +[0x21] = {7, 2}, /* F */ +[0x2c] = {7, 3}, /* Z */ +[0x27] = {7, 4}, /* Semicolon */ +[0x34] = {7, 5}, /* Dot */ +}; + +#define Z2_RAM_SIZE 0x0200 +#define Z2_FLASH_BASE 0x +#define Z2_FLASH_SIZE 0x0080 + +static struct arm_boot_info z2_binfo = { +.loader_start = PXA2XX_SDRAM_BASE, +.ram_size = Z2_RAM_SIZE, +}; + +#define Z2_GPIO_SD_DETECT 96 +#define Z2_GPIO_AC_IN 0 +#define Z2_GPIO_KEY_ON 1 +#define Z2_GPIO_LCD_CS 88 + +typedef struct { +SSISlave ssidev; +int32_t selected; +int32_t enabled; +uint8_t buf[3]; +uint32_t cur_reg; +int pos; +} ZipitLCD; + +static uint32_t zipit_lcd_transfer(SSISlave *dev, uint32_t value) +{ +ZipitLCD *z = FROM_SSI_SLAVE(ZipitLCD, dev); +uint16_t val; +if (z-selected) { +z-buf[z-pos] = value 0xff; +z-pos++; +} +if (z-pos == 3) { +switch (z-buf[0]) { +case 0x74: +DPRINTF(%s: reg: 0x%.2x\n, __func__, z-buf[2]); +z-cur_reg = z-buf[2]; +break; +case 0x76: +val = z-buf[1] 8 | z-buf[2]; +DPRINTF(%s: value: 0x%.4x\n, __func__, val); +if (z-cur_reg == 0x22 val == 0x) { +z-enabled = 1; +printf(%s: LCD enabled\n, __func__); +} else if (z-cur_reg == 0x10 val == 0x) { +z-enabled = 0; +printf(%s: LCD disabled\n, __func__); +} +break; +default: +fprintf(stderr, %s: unknown command!\n, __func__); +break; +} +z-pos = 0; +} +return 0; +} + +static void z2_lcd_cs(void *opaque, int line, int level) +{ +ZipitLCD *z2_lcd = opaque; +z2_lcd-selected = !level; +} + +static int
[Qemu-devel] [PATCH] cirrus_vga: reset lfb_addr after a pci config write if the BAR is unmapped
From: Stefano Stabellini stefano.stabell...@eu.citrix.com If the cirrus_vga PCI BAR is unmapped than we should not only reset map_addr but also lfb_addr, otherwise we'll keep trying to map the old lfb_addr in map_linear_vram. Signed-off-by: Stefano Stabellini stefano.stabell...@eu.citrix.com --- hw/cirrus_vga.c |5 - 1 files changed, 4 insertions(+), 1 deletions(-) diff --git a/hw/cirrus_vga.c b/hw/cirrus_vga.c index 722cac7..3c5043e 100644 --- a/hw/cirrus_vga.c +++ b/hw/cirrus_vga.c @@ -3088,8 +3088,11 @@ static void pci_cirrus_write_config(PCIDevice *d, CirrusVGAState *s = pvs-cirrus_vga; pci_default_write_config(d, address, val, len); -if (s-vga.map_addr d-io_regions[0].addr == PCI_BAR_UNMAPPED) +if (s-vga.map_addr d-io_regions[0].addr == PCI_BAR_UNMAPPED) { s-vga.map_addr = 0; +s-vga.lfb_addr = 0; +s-vga.lfb_end = 0; +} cirrus_update_memory_access(s); } -- 1.7.2.3
[Qemu-devel] [PATCH] xen: avoid tracking the region 0xa0000 - 0xbffff
From: Stefano Stabellini stefano.stabell...@eu.citrix.com Xen can only do dirty bit tracking for one memory region, so we should explicitly avoid trying to track the legacy VGA region between 0xa and 0xb, rather than trying and failing. Signed-off-by: Stefano Stabellini stefano.stabell...@eu.citrix.com --- xen-all.c |4 1 files changed, 4 insertions(+), 0 deletions(-) diff --git a/xen-all.c b/xen-all.c index 9a5c3ec..1fdc2e8 100644 --- a/xen-all.c +++ b/xen-all.c @@ -218,6 +218,10 @@ static int xen_add_to_physmap(XenIOState *state, if (get_physmapping(state, start_addr, size)) { return 0; } +/* do not try to map legacy VGA memory */ +if (start_addr = 0xa start_addr + size = 0xb) { +return -1; +} if (size = 0) { return -1; } -- 1.7.2.3
[Qemu-devel] [PATCH v3] configure: Don't create symlinks to nonexistent targets
When we create the symlinks to source tree files, don't create them if the file is not actually present in the source tree; this will happen if the file is in a git submodule that wasn't checked out. This also avoids the odd effect where an in-source-tree configure will end up creating the missing file as a symlink to itself. Signed-off-by: Peter Maydell peter.mayd...@linaro.org --- v1-v2: remove debug printing v2-v3: don't use test constructs marked by POSIX as obsolete, as pointed out by Paolo Bonzini configure |4 +++- 1 files changed, 3 insertions(+), 1 deletions(-) diff --git a/configure b/configure index a318d37..7f8ad24 100755 --- a/configure +++ b/configure @@ -3564,7 +3564,9 @@ for bios_file in $source_path/pc-bios/*.bin $source_path/pc-bios/*.rom $source_p done mkdir -p $DIRS for f in $FILES ; do -test -e $f || symlink $source_path/$f $f +if [ -e $source_path/$f ] ! [ -e $f ]; then +symlink $source_path/$f $f +fi done # temporary config to build submodules -- 1.7.1
Re: [Qemu-devel] [PATCH] target-arm: Fix compilation failure for 64 bit hosts
On Thu, May 26, 2011 at 12:03:36PM +0100, Peter Maydell wrote: Use the correct _ptr aliases for manipulating the pointer to the fp_status; this fixes a compilation failure on 64 bit hosts. Signed-off-by: Peter Maydell peter.mayd...@linaro.org --- Apologies for the build breakage. target-arm/translate.c | 18 +- 1 files changed, 9 insertions(+), 9 deletions(-) Thanks, applied. diff --git a/target-arm/translate.c b/target-arm/translate.c index 1501db1..f5507ec 100644 --- a/target-arm/translate.c +++ b/target-arm/translate.c @@ -980,20 +980,20 @@ static inline void gen_vfp_F1_ld0(int dp) #define VFP_GEN_ITOF(name) \ static inline void gen_vfp_##name(int dp, int neon) \ { \ -TCGv statusptr = tcg_temp_new_i32(); \ +TCGv_ptr statusptr = tcg_temp_new_ptr(); \ int offset; \ if (neon) { \ offset = offsetof(CPUState, vfp.standard_fp_status); \ } else { \ offset = offsetof(CPUState, vfp.fp_status); \ } \ -tcg_gen_addi_i32(statusptr, cpu_env, offset); \ +tcg_gen_addi_ptr(statusptr, cpu_env, offset); \ if (dp) { \ gen_helper_vfp_##name##d(cpu_F0d, cpu_F0s, statusptr); \ } else { \ gen_helper_vfp_##name##s(cpu_F0s, cpu_F0s, statusptr); \ } \ -tcg_temp_free_i32(statusptr); \ +tcg_temp_free_ptr(statusptr); \ } VFP_GEN_ITOF(uito) @@ -1003,20 +1003,20 @@ VFP_GEN_ITOF(sito) #define VFP_GEN_FTOI(name) \ static inline void gen_vfp_##name(int dp, int neon) \ { \ -TCGv statusptr = tcg_temp_new_i32(); \ +TCGv_ptr statusptr = tcg_temp_new_ptr(); \ int offset; \ if (neon) { \ offset = offsetof(CPUState, vfp.standard_fp_status); \ } else { \ offset = offsetof(CPUState, vfp.fp_status); \ } \ -tcg_gen_addi_i32(statusptr, cpu_env, offset); \ +tcg_gen_addi_ptr(statusptr, cpu_env, offset); \ if (dp) { \ gen_helper_vfp_##name##d(cpu_F0s, cpu_F0d, statusptr); \ } else { \ gen_helper_vfp_##name##s(cpu_F0s, cpu_F0s, statusptr); \ } \ -tcg_temp_free_i32(statusptr); \ +tcg_temp_free_ptr(statusptr); \ } VFP_GEN_FTOI(toui) @@ -1029,21 +1029,21 @@ VFP_GEN_FTOI(tosiz) static inline void gen_vfp_##name(int dp, int shift, int neon) \ { \ TCGv tmp_shift = tcg_const_i32(shift); \ -TCGv statusptr = tcg_temp_new_i32(); \ +TCGv_ptr statusptr = tcg_temp_new_ptr(); \ int offset; \ if (neon) { \ offset = offsetof(CPUState, vfp.standard_fp_status); \ } else { \ offset = offsetof(CPUState, vfp.fp_status); \ } \ -tcg_gen_addi_i32(statusptr, cpu_env, offset); \ +tcg_gen_addi_ptr(statusptr, cpu_env, offset); \ if (dp) { \ gen_helper_vfp_##name##d(cpu_F0d, cpu_F0d, tmp_shift, statusptr); \ } else { \ gen_helper_vfp_##name##s(cpu_F0s, cpu_F0s, tmp_shift, statusptr); \ } \ tcg_temp_free_i32(tmp_shift); \ -tcg_temp_free_i32(statusptr); \ +tcg_temp_free_ptr(statusptr); \ } VFP_GEN_FIX(tosh) VFP_GEN_FIX(tosl) -- 1.7.1 -- Aurelien Jarno GPG: 1024D/F1BCDB73 aurel...@aurel32.net http://www.aurel32.net
Re: [Qemu-devel] [PULL 0/5] PPC patch queue June 03 2011
On Thu, Jun 02, 2011 at 08:32:58AM +0200, Alexander Graf wrote: Howdy, This is my current PPC patch queue, containing a compile fix for ppc64 and some fixes I've come along while trying to get the e500 target working in autotest. Please pull. Done. The following changes since commit 578c7b2ca8ee9e97fa8693b1a83d517e8e3f962e: Juha Riihim?ki (1): audio: fix integer overflow expression are available in the git repository at: git://repo.or.cz/qemu/agraf.git ppc-next Alexander Graf (4): PPC: fix sregs usage on booke PPC: install mpc8544ds.dtb Fix segfault on screendump with -nographic PPC: fix mpc8544ds pci default devices Stefan Weil (1): ppc: Fix compilation for ppc64-softmmu Makefile|1 + console.c |2 +- hw/ppce500_mpc8544ds.c |2 +- target-ppc/kvm.c| 10 -- target-ppc/translate_init.c | 12 ++-- 5 files changed, 13 insertions(+), 14 deletions(-) -- Aurelien Jarno GPG: 1024D/F1BCDB73 aurel...@aurel32.net http://www.aurel32.net
Re: [Qemu-devel] [PATCH-v3 1/2] tcg: Fix unused-but-set-variable warning
On Tue, May 31, 2011 at 09:53:48AM +0200, Christophe Fergeau wrote: Based on a patch from Hans de Goede hdego...@redhat.com This warning is new in gcc 4.6. Acked-by: Amit Shah amit.s...@redhat.com Signed-off-by: Christophe Fergeau cferg...@redhat.com --- tcg/tcg.c |4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) Thanks, applied. diff --git a/tcg/tcg.c b/tcg/tcg.c index 8748c05..e53b54c 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -585,7 +585,7 @@ void tcg_register_helper(void *func, const char *name) void tcg_gen_callN(TCGContext *s, TCGv_ptr func, unsigned int flags, int sizemask, TCGArg ret, int nargs, TCGArg *args) { -#ifdef TCG_TARGET_I386 +#if defined(TCG_TARGET_I386) TCG_TARGET_REG_BITS 64 int call_type; #endif int i; @@ -612,7 +612,7 @@ void tcg_gen_callN(TCGContext *s, TCGv_ptr func, unsigned int flags, *gen_opc_ptr++ = INDEX_op_call; nparam = gen_opparam_ptr++; -#ifdef TCG_TARGET_I386 +#if defined(TCG_TARGET_I386) TCG_TARGET_REG_BITS 64 call_type = (flags TCG_CALL_TYPE_MASK); #endif if (ret != TCG_CALL_DUMMY_ARG) { -- 1.7.5.2 -- Aurelien Jarno GPG: 1024D/F1BCDB73 aurel...@aurel32.net http://www.aurel32.net
Re: [Qemu-devel] [PULL 00/13] s390x patch queue June 03 2011
On Thu, Jun 02, 2011 at 08:51:30AM +0200, Alexander Graf wrote: Hi, This is my current patch queue for s390x related work. It contains: * compile fixes * add temp_frees where missing * fix LMH, CKSM instructions * update bootloader for increased bootup speed * implement LRVGR instruction With these patches, networking finally works for emulated s390x guests. Please pull. Alex Thanks, pulled. The following changes since commit 578c7b2ca8ee9e97fa8693b1a83d517e8e3f962e: Juha Riihim?ki (1): audio: fix integer overflow expression are available in the git repository at: git://repo.or.cz/qemu/agraf.git s390-next Alexander Graf (4): s390x: update zipl rom s390x: free tmp explicitly in every opcode for disas_a5() s390x: fix cksm instruction s390x: implement lrvgr Stefan Weil (9): target-s390x: Fix build for non-linux hosts target-s390x: Fix wrong argument in call of tcg_gen_shl_i64() target-s390x: Fix duplicate call of tcg_temp_new_i64 target-s390x: Add missing tcg_temp_free_i64() in gen_jcc() target-s390x: Add missing tcg_temp_free_i64() in do_mh() target-s390x: Add missing tcg_temp_free_i64() in disas_b2() target-s390x: Add missing tcg_temp_free_i64() in disas_s390_insn(), opc == 0x8e target-s390x: Add missing tcg_temp_free_i64() in disas_s390_insn(), opc == 0x90 target-s390x: Add missing tcg_temp_free_i32() pc-bios/s390-zipl.rom| Bin 3336 - 3304 bytes target-s390x/helper.c|5 - target-s390x/op_helper.c | 28 target-s390x/translate.c | 31 +++ 4 files changed, 35 insertions(+), 29 deletions(-) -- Aurelien Jarno GPG: 1024D/F1BCDB73 aurel...@aurel32.net http://www.aurel32.net
Re: [Qemu-devel] [PATCH 2/3] Use the correct header in the TCG MIPS code to find cacheflush() on OpenBSD.
On Wed, May 25, 2011 at 11:06:00PM -0400, Brad wrote: Use the correct header in the TCG MIPS code to find cacheflush() on OpenBSD to fix compilation of the MIPS host support for OpenBSD/mips64 based architecures. Signed-off-by: Brad Smith b...@comstyle.com --- tcg/mips/tcg-target.h |4 1 files changed, 4 insertions(+), 0 deletions(-) Thanks, applied. diff --git a/tcg/mips/tcg-target.h b/tcg/mips/tcg-target.h index 0028bfa..8cb7d88 100644 --- a/tcg/mips/tcg-target.h +++ b/tcg/mips/tcg-target.h @@ -102,7 +102,11 @@ enum { /* guest base is supported */ #define TCG_TARGET_HAS_GUEST_BASE +#ifdef __OpenBSD__ +#include machine/sysarch.h +#else #include sys/cachectl.h +#endif static inline void flush_icache_range(unsigned long start, unsigned long stop) { -- 1.7.5 -- This message has been scanned for viruses and dangerous content by MailScanner, and is believed to be clean. -- Aurelien Jarno GPG: 1024D/F1BCDB73 aurel...@aurel32.net http://www.aurel32.net
Re: [Qemu-devel] [PATCH] PPC: E500: Implement reboot controller
On Thu, 2 Jun 2011 13:57:50 +0200 Alexander Graf ag...@suse.de wrote: diff --git a/pc-bios/mpc8544ds.dts b/pc-bios/mpc8544ds.dts index 872152d..9b95bfd 100644 --- a/pc-bios/mpc8544ds.dts +++ b/pc-bios/mpc8544ds.dts @@ -82,6 +82,12 @@ compatible = chrp,open-pic; device_type = open-pic; }; + +global-utilities@e {//global utilities block +compatible = fsl,mpc8548-guts; +reg = 0xe 0x1000; +fsl,has-rstcr; +}; }; We're not providing a full mpc8548 (or mpc8544) guts, only the rstcr register. Currently Linux looks for a node with the name global-utilities and a property fsl,has-rstcr, so there's no compatibility reason for a misleading compatible, either. I'd go with compatible = fsl,guts-rstcr (what we've been using internally, and would be a nicer thing to bind against than what the kernel currently does). Or if the goal is to provide more guts registers later, use fsl,mpc8544-guts and have qemu log a warning if other accesses are made. -Scott
Re: [Qemu-devel] [PATCH 0/2] tcg: If DEBUG_TCGV, distinguish TCGv_ptr from TCGv_i32/TCGv_i64
On Fri, May 27, 2011 at 01:12:11PM +0100, Peter Maydell wrote: This patch series enhances the type checking of TCG values done when compiling with debugging enabled, so that it can detect confusion of TCGv_ptr values with whichever of TCGv_i32 and TCGv_i64 corresponds to the pointer-width type on the compile host. This means that such errors will always be compile failures, rather than only failing on one of the two kinds of compile host. In particular, this would have caught the recent compile error I introduced... I've tested this on both 32 and 64 bit hosts, with a full compile for all targets. Note that to get a clean debug compile for both hosts (whether with or without this patchset) you'll need to have applied the following recent patches which all fix compile problems: * http://patchwork.ozlabs.org/patch/97559/ (target-arm: Fix compilation failure for 64 bit hosts) * http://patchwork.ozlabs.org/patch/97418/ (target-s390x: Fix wrong argument in call of tcg_gen_shl_i64()) * http://patchwork.ozlabs.org/patch/96665/ (ppc: Fix compilation for ppc64-softmmu) Peter Maydell (2): tcg/tcg-op.h: Fix prototypes for ld/st functions on 64 bit hosts tcg: If DEBUG_TCGV, distinguish TCGv_ptr from TCGv_i32/TCGv_i64 tcg/tcg-op.h | 48 +++- tcg/tcg.h| 52 ++-- 2 files changed, 61 insertions(+), 39 deletions(-) Thanks, both applied. -- Aurelien Jarno GPG: 1024D/F1BCDB73 aurel...@aurel32.net http://www.aurel32.net
Re: [Qemu-devel] ARM: BKPT instructions should raise prefetch aborts with IFSR type 00010
On Wed, May 18, 2011 at 12:00:46PM +0200, Alex Zuepke wrote: Hi, Peter Maydell schrieb: On 25 March 2011 10:54, Alex Zuepke azue...@sysgo.com wrote: while digging through some problems with BKPT exceptions on ARM, I discovered that QEMU does not update IFSR on prefetch aborts. This should be done since ARMv6 according to ARM docs. Please include. This patch is the wrong approach to fixing this bug -- the updating of the IFSR needs to be done when the exception is taken, not when we translate the breakpoint instruction. I'll put this on my todo list. If you happen to have a convenient test case demonstrating the problem, that would make a fix happen faster ;-) -- PMM I tried to fix it, new patch attached. But I'm not sure if it is required for semihosting as well. On ARMv7-M bkpt works differently, and debug registers aren't implemented yet, so I didn't touch it. Thanks, applied. In the future, could you please send the patch inline, or at least attach a patch that can be applied with git am? -- Aurelien Jarno GPG: 1024D/F1BCDB73 aurel...@aurel32.net http://www.aurel32.net
Re: [Qemu-devel] [PATCH] PPC: E500: Implement reboot controller
On 03.06.2011, at 19:00, Scott Wood wrote: On Thu, 2 Jun 2011 13:57:50 +0200 Alexander Graf ag...@suse.de wrote: diff --git a/pc-bios/mpc8544ds.dts b/pc-bios/mpc8544ds.dts index 872152d..9b95bfd 100644 --- a/pc-bios/mpc8544ds.dts +++ b/pc-bios/mpc8544ds.dts @@ -82,6 +82,12 @@ compatible = chrp,open-pic; device_type = open-pic; }; + +global-utilities@e {//global utilities block +compatible = fsl,mpc8548-guts; +reg = 0xe 0x1000; +fsl,has-rstcr; +}; }; We're not providing a full mpc8548 (or mpc8544) guts, only the rstcr register. Do you have any pointers to what the guts is? Currently Linux looks for a node with the name global-utilities and a property fsl,has-rstcr, so there's no compatibility reason for a misleading compatible, either. I'd go with compatible = fsl,guts-rstcr (what we've been using internally, and would be a nicer thing to bind against than what the kernel currently does). Or if the goal is to provide more guts registers later, use fsl,mpc8544-guts and have qemu log a warning if other accesses are made. What's the difference between the two revisions? Ideally, we should try to emulate real hardware, so implementing the real deal would certainly be the better option. Alex
[Qemu-devel] [PATCH] PPC: E500: Implement reboot controller
When Linux reboots an e500 VM, it writes to a magic register in the global-utilities device indicated by the device tree. We were not emulating that device so far, renedering the VM reboot-less. This patch implements that device with only the reboot functionality implemented and adds it to the device tree. With this patch applied, I can successfully reboot a -M mpc8544ds VM. Signed-off-by: Alexander Graf ag...@suse.de --- Makefile.target|2 +- hw/ppce500_mpc8544ds.c |4 ++ hw/ppce500_util.c | 94 pc-bios/mpc8544ds.dtb | Bin 12288 - 2257 bytes pc-bios/mpc8544ds.dts |6 +++ 5 files changed, 105 insertions(+), 1 deletions(-) create mode 100644 hw/ppce500_util.c diff --git a/Makefile.target b/Makefile.target index 602d50d..3c99bf8 100644 --- a/Makefile.target +++ b/Makefile.target @@ -258,7 +258,7 @@ endif obj-ppc-y += ppc4xx_devs.o ppc4xx_pci.o ppc405_uc.o ppc405_boards.o obj-ppc-y += ppc440.o ppc440_bamboo.o # PowerPC E500 boards -obj-ppc-y += ppce500_mpc8544ds.o +obj-ppc-y += ppce500_mpc8544ds.o ppce500_util.o # PowerPC 440 Xilinx ML507 reference board. obj-ppc-y += virtex_ml507.o obj-ppc-$(CONFIG_KVM) += kvm_ppc.o diff --git a/hw/ppce500_mpc8544ds.c b/hw/ppce500_mpc8544ds.c index 6b57fbf..8bcce15 100644 --- a/hw/ppce500_mpc8544ds.c +++ b/hw/ppce500_mpc8544ds.c @@ -50,6 +50,7 @@ #define MPC8544_PCI_REGS_SIZE 0x1000 #define MPC8544_PCI_IO 0xE100 #define MPC8544_PCI_IOLEN 0x1 +#define MPC8544_UTIL_BASE (MPC8544_CCSRBAR_BASE + 0xe) struct boot_info { @@ -270,6 +271,9 @@ static void mpc8544ds_init(ram_addr_t ram_size, serial_hds[0], 1, 1); } +/* General Utility device */ +sysbus_create_simple(e500-util, MPC8544_UTIL_BASE, NULL); + /* PCI */ dev = sysbus_create_varargs(e500-pcihost, MPC8544_PCI_REGS_BASE, mpic[pci_irq_nrs[0]], mpic[pci_irq_nrs[1]], diff --git a/hw/ppce500_util.c b/hw/ppce500_util.c new file mode 100644 index 000..4440c21 --- /dev/null +++ b/hw/ppce500_util.c @@ -0,0 +1,94 @@ +/* + * QEMU PowerPC E500 global util pseudo-device + * + * Copyright (C) 2011 Freescale Semiconductor, Inc. All rights reserved. + * + * Author: Alexander Graf, a...@csgraf.de + * + * This 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. + */ + +#include hw.h +#include sysemu.h +#include sysbus.h + +#define E500_UTIL_MMIO_SIZE0x1000 +#define E500_UTIL_ADDR_RSTCR 0xb0 +#define E500_UTIL_RSTCR_RESET 0x02 + +struct PPCE500UtilState { +SysBusDevice busdev; +int mmio_map; +}; + +typedef struct PPCE500UtilState PPCE500UtilState; + +static uint32_t e500_util_read32(void *opaque, target_phys_addr_t addr) +{ +uint32_t value = 0; + +addr = 0xfff; +switch (addr) { +default: +break; +} + +return value; +} + +static CPUReadMemoryFunc * const e500_util_read[] = { +NULL, +NULL, +e500_util_read32, +}; + +static void e500_util_write32(void *opaque, target_phys_addr_t addr, + uint32_t value) +{ +addr = 0xfff; + +switch (addr) { +case E500_UTIL_ADDR_RSTCR: +if (value E500_UTIL_RSTCR_RESET) { +qemu_system_reset_request(); +} +break; +default: +break; +} +} + +static CPUWriteMemoryFunc * const e500_util_write[] = { +NULL, +NULL, +e500_util_write32, +}; + +static int e500_util_initfn(SysBusDevice *dev) +{ +PPCE500UtilState *s; +int iomem; + +s = FROM_SYSBUS(PPCE500UtilState, sysbus_from_qdev(dev)); + +iomem = cpu_register_io_memory(e500_util_read, e500_util_write, s, + DEVICE_BIG_ENDIAN); +sysbus_init_mmio(dev, E500_UTIL_MMIO_SIZE, iomem); + +return 0; +} + +static SysBusDeviceInfo e500_util_info = { +.init = e500_util_initfn, +.qdev.name= e500-util, +.qdev.size= sizeof(PPCE500UtilState), +}; + +static void e500_pci_register(void) +{ +sysbus_register_withprop(e500_util_info); +} +device_init(e500_pci_register); diff --git a/pc-bios/mpc8544ds.dtb b/pc-bios/mpc8544ds.dtb index 3299546696bf21f53f8ce2c9eba7fcb740c547da..9a1eba0019ca6eada134650fb0866342fa0066e3 100644 GIT binary patch delta 254 zcmZojxG1P`f%o5A1_q9c3=9kw3=HfkKw1Nc1%X%qh=G7H7bvbX(NK8fZXcFW}pZQ zP*4ga1H?=qIz1;pDKSU4v?Mbpvm`UM*dfb2!JvS3?TI!`RY_b98bGk}XV4EOgUL zONv2~Kmd~G0AgPTJ`fjdCrAtk7?pqo$b7IJ19E}V(HT2Fe0W{sB?|1MENsNY4YH t9_P(1to)3Ofs?1OZDx#~Y{00zIh$RZkr!lrMq;sUQE^Ff(d4Ndb^tUEDtiC` literal 12288 zcmeHIJ8u~5Z)um5MBxr1r@SLgOEgBs)q$VJkovDTp5sUCx{MlzVY^28Sx5qJ!T+ zNtKdA{{NFM0PEYG{D@_IA$pB`MMG$W079^cH)ez$l2eEs)#rP_+*gHo3YTJMqG zBwZpUakiCed@SvMesQ;EYNxd_U6{cdbiVg__RzQev7m*jTt`E)mFIB*j_Li~Xkc
Re: [Qemu-devel] [PATCH] linux-user: add pselect6 syscall support
On 05/18/2011 03:14 AM, Mike Frysinger wrote: Some architectures (like Blackfin) only implement pselect6 (and skip select/newselect). So add support for it using existing newselect code. There is a blackfin qemu? Anyways, with this patch pselect01 ltp testcase starts failing. Looks like (at least on arm), arg6 is set and valid pointer, but arg7[0] is 0, which quite doesn't work as lock_user read target... Checking if arg7==0 and setting sig_ptr to null in that case makes the testcase to work, but is that correct? Riku Signed-off-by: Mike Frysingervap...@gentoo.org --- linux-user/syscall.c | 145 +++--- 1 files changed, 126 insertions(+), 19 deletions(-) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 6e7d88e..b35c437 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -550,6 +550,15 @@ _syscall5(int, sys_ppoll, struct pollfd *, fds, nfds_t, nfds, size_t, sigsetsize) #endif +#if defined(TARGET_NR_pselect6) +#ifndef __NR_pselect6 +# define __NR_pselect6 -1 +#endif +#define __NR_sys_pselect6 __NR_pselect6 +_syscall6(int, sys_pselect6, int, nfds, fd_set *, readfds, fd_set *, writefds, + fd_set *, exceptfds, struct timespec *, timeout, void *, sig); +#endif + extern int personality(int); extern int flock(int, int); extern int setfsuid(int); @@ -787,6 +796,20 @@ static inline abi_long copy_from_user_fdset(fd_set *fds, return 0; } +static inline abi_ulong copy_from_user_fdset_ptr(fd_set *fds, fd_set **fds_ptr, + abi_ulong target_fds_addr, + int n) +{ +if (target_fds_addr) { +if (copy_from_user_fdset(fds, target_fds_addr, n)) +return -TARGET_EFAULT; +*fds_ptr = fds; +} else { +*fds_ptr = NULL; +} +return 0; +} + static inline abi_long copy_to_user_fdset(abi_ulong target_fds_addr, const fd_set *fds, int n) @@ -952,6 +975,7 @@ static inline abi_long copy_to_user_mq_attr(abi_ulong target_mq_attr_addr, } #endif +#if defined(TARGET_NR_select) || defined(TARGET_NR__newselect) /* do_select() must return target values and target errnos. */ static abi_long do_select(int n, abi_ulong rfd_addr, abi_ulong wfd_addr, @@ -962,26 +986,17 @@ static abi_long do_select(int n, struct timeval tv, *tv_ptr; abi_long ret; -if (rfd_addr) { -if (copy_from_user_fdset(rfds, rfd_addr, n)) -return -TARGET_EFAULT; -rfds_ptr =rfds; -} else { -rfds_ptr = NULL; +ret = copy_from_user_fdset_ptr(rfds,rfds_ptr, rfd_addr, n); +if (ret) { +return ret; } -if (wfd_addr) { -if (copy_from_user_fdset(wfds, wfd_addr, n)) -return -TARGET_EFAULT; -wfds_ptr =wfds; -} else { -wfds_ptr = NULL; +ret = copy_from_user_fdset_ptr(wfds,wfds_ptr, wfd_addr, n); +if (ret) { +return ret; } -if (efd_addr) { -if (copy_from_user_fdset(efds, efd_addr, n)) -return -TARGET_EFAULT; -efds_ptr =efds; -} else { -efds_ptr = NULL; +ret = copy_from_user_fdset_ptr(efds,efds_ptr, efd_addr, n); +if (ret) { +return ret; } if (target_tv_addr) { @@ -1008,6 +1023,7 @@ static abi_long do_select(int n, return ret; } +#endif static abi_long do_pipe2(int host_pipe[], int flags) { @@ -5569,7 +5585,98 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1, #endif #ifdef TARGET_NR_pselect6 case TARGET_NR_pselect6: - goto unimplemented_nowarn; +{ +abi_long rfd_addr, wfd_addr, efd_addr, n, ts_addr; +fd_set rfds, wfds, efds; +fd_set *rfds_ptr, *wfds_ptr, *efds_ptr; +struct timespec ts, *ts_ptr; + +/* + * The 6th arg is actually two args smashed together, + * so we cannot use the C library. + */ +sigset_t set; +struct { +sigset_t *set; +size_t size; +} sig, *sig_ptr; + +abi_ulong arg_sigset, arg_sigsize, *arg7; +target_sigset_t *target_sigset; + +n = arg1; +rfd_addr = arg2; +wfd_addr = arg3; +efd_addr = arg4; +ts_addr = arg5; + +ret = copy_from_user_fdset_ptr(rfds,rfds_ptr, rfd_addr, n); +if (ret) { +goto fail; +} +ret = copy_from_user_fdset_ptr(wfds,wfds_ptr, wfd_addr, n); +if (ret) { +goto fail; +} +ret = copy_from_user_fdset_ptr(efds,efds_ptr, efd_addr, n); +if (ret) { +goto fail; +} + +/* + * This takes a timespec, and
Re: [Qemu-devel] [PATCH] PPC: E500: Implement reboot controller
On 03.06.2011, at 19:00, Scott Wood wrote: On Thu, 2 Jun 2011 13:57:50 +0200 Alexander Graf ag...@suse.de wrote: diff --git a/pc-bios/mpc8544ds.dts b/pc-bios/mpc8544ds.dts index 872152d..9b95bfd 100644 --- a/pc-bios/mpc8544ds.dts +++ b/pc-bios/mpc8544ds.dts @@ -82,6 +82,12 @@ compatible = chrp,open-pic; device_type = open-pic; }; + +global-utilities@e {//global utilities block +compatible = fsl,mpc8548-guts; +reg = 0xe 0x1000; +fsl,has-rstcr; +}; }; We're not providing a full mpc8548 (or mpc8544) guts, only the rstcr register. Currently Linux looks for a node with the name global-utilities and a property fsl,has-rstcr, so there's no compatibility reason for a misleading compatible, either. I'd go with compatible = fsl,guts-rstcr (what we've been using internally, and would be a nicer thing to bind against than what the kernel currently does). Or if the goal is to provide more guts registers later, use fsl,mpc8544-guts and have qemu log a warning if other accesses are made. Ugh - 8544 is the SoC we're emulating - sorry, it's evening already :). So yes, implementing an mpc8544-guts is certainly what we want! Alex
[Qemu-devel] [RFC 00/10]: QMP/HMP: Introduce tray handling commands
In a recent discussion on the mailing list regarding the introduction of the BLOCK_TRAY_OPEN and BLOCK_TRAY_CLOSE events[1], it was mentioned that we need to fix the eject command and maybe introduce new commands first. Here's a my proposal. This series introduces three new commands: o blockdev-tray-open: opens the drive tray. Also Supports removing the inserted media. The BLOCK_TRAY_OPEN event is emitted if this command succeeds. o blockdev-tray-close: closes a drive tray. The BLOCK_TRAY_CLOSE event is emitted. o blockdev-media-insert: Inserts a media in the tray. The tray must empty and already opened. No event is emitted. The existing 'eject' and 'change' commands are completely rewriten in terms of the new commands. Besides fixing some bad behaviors, this also makes it possible for the events to be automtically emitted. Ejecting a device inside the guest (or closing its tray) also causes the events to be emitted. Everything which applies for the virtual tray seems to work as expected for the host's tray. But more testing is needed. QMP/qmp-events.txt | 30 ++ block.c| 36 +++- block.h|6 +- block/raw.c|2 +- blockdev.c | 157 blockdev.h |3 + hw/ide/atapi.c |2 +- hw/ide/core.c |6 +- hw/scsi-disk.c |8 +- hw/virtio-blk.c|6 +- monitor.c |6 ++ monitor.h |2 + qmp-commands.hx| 84 13 files changed, 294 insertions(+), 54 deletions(-)
[Qemu-devel] [RFC 07/10] QMP: Introduce the blockdev-media-insert command
This command inserts a new media in an already opened tray. It's only available in QMP. Please, check the command's documentation (being introduced in this commit) for a detailed description. Signed-off-by: Luiz Capitulino lcapitul...@redhat.com --- blockdev.c | 52 blockdev.h |1 + qmp-commands.hx | 32 3 files changed, 85 insertions(+), 0 deletions(-) diff --git a/blockdev.c b/blockdev.c index 943905d..14c8312 100644 --- a/blockdev.c +++ b/blockdev.c @@ -721,6 +721,58 @@ static int tray_close(const char *device) return 0; } +static int media_insert(const char *device, const char *mediafile, +const char *format) +{ +BlockDriver *drv = NULL; +BlockDriverState *bs; +int bdrv_flags; + +bs = bdrv_removable_find(device); +if (!bs) { +return -1; +} + +if (bdrv_is_locked(bs)) { +qerror_report(QERR_DEVICE_LOCKED, bdrv_get_device_name(bs)); +return -1; +} + +if (bdrv_is_inserted(bs)) { +/* FIXME: will report undefined error in QMP */ +return -1; +} + +if (!bs-tray_open) { +/* FIXME: will report undefined error in QMP */ +return 1; +} + +if (format) { +drv = bdrv_find_whitelisted_format(format); +if (!drv) { +qerror_report(QERR_INVALID_BLOCK_FORMAT, format); +return -1; +} +} + +bdrv_flags = bdrv_is_read_only(bs) ? 0 : BDRV_O_RDWR; +bdrv_flags |= bdrv_is_snapshot(bs) ? BDRV_O_SNAPSHOT : 0; +if (bdrv_open(bs, mediafile, bdrv_flags, drv) 0) { +qerror_report(QERR_OPEN_FILE_FAILED, mediafile); +return -1; +} + +return 0; +} + +int do_media_insert(Monitor *mon, const QDict *qdict, QObject **ret_data) +{ +return media_insert(qdict_get_str(qdict, device), +qdict_get_str(qdict, media), +qdict_get_try_str(qdict, format)); +} + int do_tray_close(Monitor *mon, const QDict *qdict, QObject **ret_data) { return tray_close(qdict_get_str(qdict, device)); diff --git a/blockdev.h b/blockdev.h index 975e91a..4dfd869 100644 --- a/blockdev.h +++ b/blockdev.h @@ -67,5 +67,6 @@ int do_snapshot_blkdev(Monitor *mon, const QDict *qdict, QObject **ret_data); int do_block_resize(Monitor *mon, const QDict *qdict, QObject **ret_data); int do_tray_open(Monitor *mon, const QDict *qdict, QObject **ret_data); int do_tray_close(Monitor *mon, const QDict *qdict, QObject **ret_data); +int do_media_insert(Monitor *mon, const QDict *qdict, QObject **ret_data); #endif diff --git a/qmp-commands.hx b/qmp-commands.hx index fdf9750..fe50593 100644 --- a/qmp-commands.hx +++ b/qmp-commands.hx @@ -480,6 +480,38 @@ Example: EQMP { +.name = blockdev-media-insert, +.args_type = device:B,media:F,format:s?, +.mhandler.cmd_new = do_media_insert, +}, + +SQMP +blockdev-media-insert +- + +Insert a new media in a removable drive. The tray must be empty and already +opened. The tray is not automatically closed (please, see blockdev-tray-open +and blockdev-tray-close commands). + +Arguments: + +- device: device name (json-string) +- media: media file path (json-string) +- format: media file format (json-string, optional) + +Example: + +- { execute: blockdev-media-insert, + arguments: { device: ide1-cd0, +media: /srv/images/Fedora-12-x86_64-DVD.iso } } +- { return: {} } + +Note: If the media is encrypted, the command block_passwd has to be used to + set the media's password. + +EQMP + +{ .name = migrate, .args_type = detach:-d,blk:-b,inc:-i,uri:s, .params = [-d] [-b] [-i] uri, -- 1.7.4.4
[Qemu-devel] [RFC 08/10] QMP: Introduce the BLOCK_TRAY_OPEN and BLOCK_TRAY_CLOSE events
They are emitted when the tray is opened or closed, either by the guest or by monitor commands. Signed-off-by: Luiz Capitulino lcapitul...@redhat.com --- QMP/qmp-events.txt | 30 ++ block.c| 22 ++ monitor.c |6 ++ monitor.h |2 ++ 4 files changed, 60 insertions(+), 0 deletions(-) diff --git a/QMP/qmp-events.txt b/QMP/qmp-events.txt index 0ce5d4e..51a93d0 100644 --- a/QMP/qmp-events.txt +++ b/QMP/qmp-events.txt @@ -26,6 +26,36 @@ Example: Note: If action is stop, a STOP event will eventually follow the BLOCK_IO_ERROR event. +BLOCK_TRAY_CLOSE + + +Emitted when a removable disk media tray is closed. + +Data: + +- device: device name (json-string) + +Example: + +{ event: BLOCK_TRAY_CLOSE, +data: { device: ide1-cd0 }, +timestamp: { seconds: 1265044280, microseconds: 450456 } } + +BLOCK_TRAY_OPEN +--- + +Emitted when a removable disk media tray is opened. + +Data: + +- device: device name (json-string) + +Example: + +{ event: BLOCK_TRAY_OPEN, +data: { device: ide1-cd0 }, +timestamp: { seconds: 1265044230, microseconds: 450486 } } + RESET - diff --git a/block.c b/block.c index 3df5a4f..9224f22 100644 --- a/block.c +++ b/block.c @@ -1656,6 +1656,17 @@ int bdrv_is_allocated(BlockDriverState *bs, int64_t sector_num, int nb_sectors, return bs-drv-bdrv_is_allocated(bs, sector_num, nb_sectors, pnum); } +static void bdrv_eject_mon_event(const BlockDriverState *bdrv, int tray_open) +{ +QObject *data; +int event; + +data = qobject_from_jsonf({ 'device': %s }, bdrv-device_name); +event = tray_open ? QEVENT_BLOCK_TRAY_OPEN : QEVENT_BLOCK_TRAY_CLOSE; +monitor_protocol_event(event, data); +qobject_decref(data); +} + void bdrv_error_mon_event(const BlockDriverState *bdrv, BlockMonEventAction action, int is_read) { @@ -2776,6 +2787,17 @@ int bdrv_eject(BlockDriverState *bs, int eject_flag, int force) ret = 0; } if (ret = 0) { +if (bs-tray_open != eject_flag) { +if (bs-device_name[0] != '\0') { +/* + * FIXME: raw_eject() calls bdrv_eject(), which makes the + * event be emitted twice. The check above will prevent that + * from happening, * but we need a better way to deal with + * this... + */ +bdrv_eject_mon_event(bs, eject_flag); +} +} bs-tray_open = eject_flag; } diff --git a/monitor.c b/monitor.c index f63cce0..22353b5 100644 --- a/monitor.c +++ b/monitor.c @@ -453,6 +453,12 @@ void monitor_protocol_event(MonitorEvent event, QObject *data) case QEVENT_BLOCK_IO_ERROR: event_name = BLOCK_IO_ERROR; break; +case QEVENT_BLOCK_TRAY_OPEN: +event_name = BLOCK_TRAY_OPEN; +break; +case QEVENT_BLOCK_TRAY_CLOSE: +event_name = BLOCK_TRAY_CLOSE; +break; case QEVENT_RTC_CHANGE: event_name = RTC_CHANGE; break; diff --git a/monitor.h b/monitor.h index 4f2d328..fca1e18 100644 --- a/monitor.h +++ b/monitor.h @@ -30,6 +30,8 @@ typedef enum MonitorEvent { QEVENT_VNC_INITIALIZED, QEVENT_VNC_DISCONNECTED, QEVENT_BLOCK_IO_ERROR, +QEVENT_BLOCK_TRAY_OPEN, +QEVENT_BLOCK_TRAY_CLOSE, QEVENT_RTC_CHANGE, QEVENT_WATCHDOG, QEVENT_SPICE_CONNECTED, -- 1.7.4.4
[Qemu-devel] [RFC 04/10] HMP: info block: Print the 'tray-open' key
It's printed before the [not inserted] or the file fields, like this: (qemu) info block ide0-hd0: removable=0 file=disks/test.img ro=0 drv=qcow2 encrypted=0 ide1-cd0: removable=1 locked=0 tray-open=0 file=/Fedora-14-x86_64-DVD.iso ro=1 drv=raw encrypted=0 floppy0: removable=1 locked=0 tray-open=0 [not inserted] sd0: removable=1 locked=0 tray-open=0 [not inserted] (qemu) TODO: Confirm this won't break libvirt. Signed-off-by: Luiz Capitulino lcapitul...@redhat.com --- block.c |1 + 1 files changed, 1 insertions(+), 0 deletions(-) diff --git a/block.c b/block.c index e1b9057..3df5a4f 100644 --- a/block.c +++ b/block.c @@ -1698,6 +1698,7 @@ static void bdrv_print_dict(QObject *obj, void *opaque) if (qdict_get_bool(bs_dict, removable)) { monitor_printf(mon, locked=%d, qdict_get_bool(bs_dict, locked)); +monitor_printf(mon, tray-open=%d, qdict_get_bool(bs_dict, tray-open)); } if (qdict_haskey(bs_dict, inserted)) { -- 1.7.4.4
[Qemu-devel] [RFC 01/10] block: bdrv_eject(): Add 'force' parameter
It's purpose is to skip the media locked test. This is going to be used by the blockdev-tray-open QMP command. Signed-off-by: Luiz Capitulino lcapitul...@redhat.com --- block.c|4 ++-- block.h|2 +- block/raw.c|2 +- hw/ide/atapi.c |2 +- hw/scsi-disk.c |2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/block.c b/block.c index effa86f..a3d0556 100644 --- a/block.c +++ b/block.c @@ -2752,12 +2752,12 @@ int bdrv_media_changed(BlockDriverState *bs) /** * If eject_flag is TRUE, eject the media. Otherwise, close the tray */ -int bdrv_eject(BlockDriverState *bs, int eject_flag) +int bdrv_eject(BlockDriverState *bs, int eject_flag, int force) { BlockDriver *drv = bs-drv; int ret; -if (bs-locked) { +if (bs-locked !force) { return -EBUSY; } diff --git a/block.h b/block.h index da7d39c..131812c 100644 --- a/block.h +++ b/block.h @@ -186,7 +186,7 @@ int bdrv_is_inserted(BlockDriverState *bs); int bdrv_media_changed(BlockDriverState *bs); int bdrv_is_locked(BlockDriverState *bs); void bdrv_set_locked(BlockDriverState *bs, int locked); -int bdrv_eject(BlockDriverState *bs, int eject_flag); +int bdrv_eject(BlockDriverState *bs, int eject_flag, int force); void bdrv_set_change_cb(BlockDriverState *bs, void (*change_cb)(void *opaque, int reason), void *opaque); diff --git a/block/raw.c b/block/raw.c index b0f72d6..0e23c7c 100644 --- a/block/raw.c +++ b/block/raw.c @@ -77,7 +77,7 @@ static int raw_is_inserted(BlockDriverState *bs) static int raw_eject(BlockDriverState *bs, int eject_flag) { -return bdrv_eject(bs-file, eject_flag); +return bdrv_eject(bs-file, eject_flag, 0); } static int raw_set_locked(BlockDriverState *bs, int locked) diff --git a/hw/ide/atapi.c b/hw/ide/atapi.c index fe2fb0b..8af6e23 100644 --- a/hw/ide/atapi.c +++ b/hw/ide/atapi.c @@ -897,7 +897,7 @@ static void cmd_start_stop_unit(IDEState *s, uint8_t* buf) eject = (buf[4] 1) 1; if (eject) { -err = bdrv_eject(s-bs, !start); +err = bdrv_eject(s-bs, !start, 0); } switch (err) { diff --git a/hw/scsi-disk.c b/hw/scsi-disk.c index a8c7372..d3f982e 100644 --- a/hw/scsi-disk.c +++ b/hw/scsi-disk.c @@ -872,7 +872,7 @@ static int scsi_disk_emulate_command(SCSIDiskReq *r, uint8_t *outbuf) case START_STOP: if (s-drive_kind == SCSI_CD (req-cmd.buf[4] 2)) { /* load/eject medium */ -bdrv_eject(s-bs, !(req-cmd.buf[4] 1)); +bdrv_eject(s-bs, !(req-cmd.buf[4] 1), 0); } break; case ALLOW_MEDIUM_REMOVAL: -- 1.7.4.4
[Qemu-devel] [RFC 05/10] QMP: Introduce the blockdev-tray-open command
This command opens a removable media drive's tray. It's only available in QMP. The do_tray_open() function is split into two smaller functions because next commits will also use them. Please, check the command's documentation (being introduced in this commit) for a detailed description. XXX: Should we return an error if the tray is already open? Signed-off-by: Luiz Capitulino lcapitul...@redhat.com --- blockdev.c | 46 ++ blockdev.h |1 + qmp-commands.hx | 27 +++ 3 files changed, 74 insertions(+), 0 deletions(-) diff --git a/blockdev.c b/blockdev.c index 6e0eb83..b1c705c 100644 --- a/blockdev.c +++ b/blockdev.c @@ -665,6 +665,52 @@ static int eject_device(Monitor *mon, BlockDriverState *bs, int force) return 0; } +static BlockDriverState *bdrv_removable_find(const char *name) +{ +BlockDriverState *bs; + +bs = bdrv_find(name); +if (!bs) { +qerror_report(QERR_DEVICE_NOT_FOUND, name); +return NULL; +} + +if (!bdrv_is_removable(bs)) { +qerror_report(QERR_DEVICE_NOT_REMOVABLE, bdrv_get_device_name(bs)); +return NULL; +} + +return bs; +} + +static int tray_open(const char *device, int remove, int force) +{ +BlockDriverState *bs; + +bs = bdrv_removable_find(device); +if (!bs) { +return -1; +} + +if (bdrv_eject(bs, 1, force) 0) { +/* FIXME: will report undefined error in QMP */ +return -1; +} + +if (remove) { +bdrv_close(bs); +} + +return 0; +} + +int do_tray_open(Monitor *mon, const QDict *qdict, QObject **ret_data) +{ +return tray_open(qdict_get_str(qdict, device), + qdict_get_try_bool(qdict, remove, 0), + qdict_get_try_bool(qdict, force, 0)); +} + int do_eject(Monitor *mon, const QDict *qdict, QObject **ret_data) { BlockDriverState *bs; diff --git a/blockdev.h b/blockdev.h index 3587786..5e46aae 100644 --- a/blockdev.h +++ b/blockdev.h @@ -65,5 +65,6 @@ int do_change_block(Monitor *mon, const char *device, int do_drive_del(Monitor *mon, const QDict *qdict, QObject **ret_data); int do_snapshot_blkdev(Monitor *mon, const QDict *qdict, QObject **ret_data); int do_block_resize(Monitor *mon, const QDict *qdict, QObject **ret_data); +int do_tray_open(Monitor *mon, const QDict *qdict, QObject **ret_data); #endif diff --git a/qmp-commands.hx b/qmp-commands.hx index 8393f22..58ab132 100644 --- a/qmp-commands.hx +++ b/qmp-commands.hx @@ -153,6 +153,33 @@ Examples: EQMP { +.name = blockdev-tray-open, +.args_type = device:B,force:-f,remove:-r, +.mhandler.cmd_new = do_tray_open, +}, + +SQMP +blockdev-tray-open +-- + +Open a removable media drive's tray. + +Arguments: + +- device: device name (json-string) +- force: force ejection (json-bool, optional) +- remove: remove the media (json-bool, optional) + +Example: + +- { execute: blockdev-tray-open, arguments: { device: ide1-cd0 } } +- { return: {} } + +Note: The tray remains open after this command is issued + +EQMP + +{ .name = screendump, .args_type = filename:F, .params = filename, -- 1.7.4.4
[Qemu-devel] [RFC 09/10] QMP/HMP: eject: Use blockdev-tray-open
This commit rewrites eject as a special case of the blockdev-tray-open command. In other words, do_eject() just calls tray_open(). This brings the following behavior *changes* to both QMP and HMP: 1. Before this commit eject was capable of closing the BlockDriverState associated with *any* device (ie. removable or not, by using '-f'). Now it's only capable of closing the BlockDriverState of removable devices 2. Ejecting the host's cdrom now works 3. After the eject command is ran the tray is left open Please, also note that the use of this command will emit the BLOCK_TRAY_OPEN event in QMP. Signed-off-by: Luiz Capitulino lcapitul...@redhat.com --- blockdev.c | 12 ++-- 1 files changed, 2 insertions(+), 10 deletions(-) diff --git a/blockdev.c b/blockdev.c index 14c8312..36c56fd 100644 --- a/blockdev.c +++ b/blockdev.c @@ -787,16 +787,8 @@ int do_tray_open(Monitor *mon, const QDict *qdict, QObject **ret_data) int do_eject(Monitor *mon, const QDict *qdict, QObject **ret_data) { -BlockDriverState *bs; -int force = qdict_get_try_bool(qdict, force, 0); -const char *filename = qdict_get_str(qdict, device); - -bs = bdrv_find(filename); -if (!bs) { -qerror_report(QERR_DEVICE_NOT_FOUND, filename); -return -1; -} -return eject_device(mon, bs, force); +return tray_open(qdict_get_str(qdict, device), 1, + qdict_get_try_bool(qdict, force, 0)); } int do_block_set_passwd(Monitor *mon, const QDict *qdict, -- 1.7.4.4
[Qemu-devel] [RFC 02/10] block: Rename bdrv_mon_event()
Rename it to bdrv_error_mon_event() in order to better communicate its purpose. Signed-off-by: Luiz Capitulino lcapitul...@redhat.com --- block.c |4 ++-- block.h |4 ++-- hw/ide/core.c |6 +++--- hw/scsi-disk.c |6 +++--- hw/virtio-blk.c |6 +++--- 5 files changed, 13 insertions(+), 13 deletions(-) diff --git a/block.c b/block.c index a3d0556..959eedd 100644 --- a/block.c +++ b/block.c @@ -1656,8 +1656,8 @@ int bdrv_is_allocated(BlockDriverState *bs, int64_t sector_num, int nb_sectors, return bs-drv-bdrv_is_allocated(bs, sector_num, nb_sectors, pnum); } -void bdrv_mon_event(const BlockDriverState *bdrv, -BlockMonEventAction action, int is_read) +void bdrv_error_mon_event(const BlockDriverState *bdrv, + BlockMonEventAction action, int is_read) { QObject *data; const char *action_str; diff --git a/block.h b/block.h index 131812c..c71bf32 100644 --- a/block.h +++ b/block.h @@ -50,8 +50,8 @@ typedef enum { BDRV_ACTION_REPORT, BDRV_ACTION_IGNORE, BDRV_ACTION_STOP } BlockMonEventAction; -void bdrv_mon_event(const BlockDriverState *bdrv, -BlockMonEventAction action, int is_read); +void bdrv_error_mon_event(const BlockDriverState *bdrv, + BlockMonEventAction action, int is_read); void bdrv_info_print(Monitor *mon, const QObject *data); void bdrv_info(Monitor *mon, QObject **ret_data); void bdrv_stats_print(Monitor *mon, const QObject *data); diff --git a/hw/ide/core.c b/hw/ide/core.c index 45410e8..96c153e 100644 --- a/hw/ide/core.c +++ b/hw/ide/core.c @@ -440,7 +440,7 @@ static int ide_handle_rw_error(IDEState *s, int error, int op) BlockErrorAction action = bdrv_get_on_error(s-bs, is_read); if (action == BLOCK_ERR_IGNORE) { -bdrv_mon_event(s-bs, BDRV_ACTION_IGNORE, is_read); +bdrv_error_mon_event(s-bs, BDRV_ACTION_IGNORE, is_read); return 0; } @@ -448,7 +448,7 @@ static int ide_handle_rw_error(IDEState *s, int error, int op) || action == BLOCK_ERR_STOP_ANY) { s-bus-dma-ops-set_unit(s-bus-dma, s-unit); s-bus-dma-ops-add_status(s-bus-dma, op); -bdrv_mon_event(s-bs, BDRV_ACTION_STOP, is_read); +bdrv_error_mon_event(s-bs, BDRV_ACTION_STOP, is_read); vm_stop(VMSTOP_DISKFULL); } else { if (op BM_STATUS_DMA_RETRY) { @@ -457,7 +457,7 @@ static int ide_handle_rw_error(IDEState *s, int error, int op) } else { ide_rw_error(s); } -bdrv_mon_event(s-bs, BDRV_ACTION_REPORT, is_read); +bdrv_error_mon_event(s-bs, BDRV_ACTION_REPORT, is_read); } return 1; diff --git a/hw/scsi-disk.c b/hw/scsi-disk.c index d3f982e..d641309 100644 --- a/hw/scsi-disk.c +++ b/hw/scsi-disk.c @@ -204,7 +204,7 @@ static int scsi_handle_rw_error(SCSIDiskReq *r, int error, int type) BlockErrorAction action = bdrv_get_on_error(s-bs, is_read); if (action == BLOCK_ERR_IGNORE) { -bdrv_mon_event(s-bs, BDRV_ACTION_IGNORE, is_read); +bdrv_error_mon_event(s-bs, BDRV_ACTION_IGNORE, is_read); return 0; } @@ -214,7 +214,7 @@ static int scsi_handle_rw_error(SCSIDiskReq *r, int error, int type) type = SCSI_REQ_STATUS_RETRY_TYPE_MASK; r-status |= SCSI_REQ_STATUS_RETRY | type; -bdrv_mon_event(s-bs, BDRV_ACTION_STOP, is_read); +bdrv_error_mon_event(s-bs, BDRV_ACTION_STOP, is_read); vm_stop(VMSTOP_DISKFULL); } else { if (type == SCSI_REQ_STATUS_RETRY_READ) { @@ -234,7 +234,7 @@ static int scsi_handle_rw_error(SCSIDiskReq *r, int error, int type) SENSE_CODE(IO_ERROR)); break; } -bdrv_mon_event(s-bs, BDRV_ACTION_REPORT, is_read); +bdrv_error_mon_event(s-bs, BDRV_ACTION_REPORT, is_read); } return 1; } diff --git a/hw/virtio-blk.c b/hw/virtio-blk.c index 91e0394..99db00a 100644 --- a/hw/virtio-blk.c +++ b/hw/virtio-blk.c @@ -69,7 +69,7 @@ static int virtio_blk_handle_rw_error(VirtIOBlockReq *req, int error, VirtIOBlock *s = req-dev; if (action == BLOCK_ERR_IGNORE) { -bdrv_mon_event(s-bs, BDRV_ACTION_IGNORE, is_read); +bdrv_error_mon_event(s-bs, BDRV_ACTION_IGNORE, is_read); return 0; } @@ -77,11 +77,11 @@ static int virtio_blk_handle_rw_error(VirtIOBlockReq *req, int error, || action == BLOCK_ERR_STOP_ANY) { req-next = s-rq; s-rq = req; -bdrv_mon_event(s-bs, BDRV_ACTION_STOP, is_read); +bdrv_error_mon_event(s-bs, BDRV_ACTION_STOP, is_read); vm_stop(VMSTOP_DISKFULL); } else { virtio_blk_req_complete(req, VIRTIO_BLK_S_IOERR); -bdrv_mon_event(s-bs, BDRV_ACTION_REPORT, is_read); +bdrv_error_mon_event(s-bs, BDRV_ACTION_REPORT, is_read); } return 1; -- 1.7.4.4
[Qemu-devel] [RFC 10/10] QMP/HMP: change: Use QMP tray commands
This commit rewrites change in terms of blockdev-tray-open, blockdev-media-insert and blockdev-tray-close. There should be no visible changes in HMP or QMP, except that the use of this command causes the BLOCK_TRAY_OPEN *and* BLOCK_TRAY_CLOSE events to emitted. Signed-off-by: Luiz Capitulino lcapitul...@redhat.com --- blockdev.c | 43 +-- 1 files changed, 9 insertions(+), 34 deletions(-) diff --git a/blockdev.c b/blockdev.c index 36c56fd..e9edcb3 100644 --- a/blockdev.c +++ b/blockdev.c @@ -648,23 +648,6 @@ out: return ret; } -static int eject_device(Monitor *mon, BlockDriverState *bs, int force) -{ -if (!force) { -if (!bdrv_is_removable(bs)) { -qerror_report(QERR_DEVICE_NOT_REMOVABLE, - bdrv_get_device_name(bs)); -return -1; -} -if (bdrv_is_locked(bs)) { -qerror_report(QERR_DEVICE_LOCKED, bdrv_get_device_name(bs)); -return -1; -} -} -bdrv_close(bs); -return 0; -} - static BlockDriverState *bdrv_removable_find(const char *name) { BlockDriverState *bs; @@ -819,30 +802,22 @@ int do_change_block(Monitor *mon, const char *device, const char *filename, const char *fmt) { BlockDriverState *bs; -BlockDriver *drv = NULL; -int bdrv_flags; -bs = bdrv_find(device); -if (!bs) { -qerror_report(QERR_DEVICE_NOT_FOUND, device); +if (tray_open(device, 1, 0) 0) { /* XXX: should we force? */ return -1; } -if (fmt) { -drv = bdrv_find_whitelisted_format(fmt); -if (!drv) { -qerror_report(QERR_INVALID_BLOCK_FORMAT, fmt); -return -1; -} -} -if (eject_device(mon, bs, 0) 0) { + +if (media_insert(device, filename, fmt) 0) { return -1; } -bdrv_flags = bdrv_is_read_only(bs) ? 0 : BDRV_O_RDWR; -bdrv_flags |= bdrv_is_snapshot(bs) ? BDRV_O_SNAPSHOT : 0; -if (bdrv_open(bs, filename, bdrv_flags, drv) 0) { -qerror_report(QERR_OPEN_FILE_FAILED, filename); + +if (tray_close(device) 0) { +/* XXX: open the tray and remove the media? */ return -1; } + +bs = bdrv_find(device); /* XXX: bdrv_find() is called 4 times */ +assert(bs != NULL); return monitor_read_bdrv_key_start(mon, bs, NULL, NULL); } -- 1.7.4.4
[Qemu-devel] [RFC 03/10] QMP: query-block: Add the 'tray-open' key
As its name implies this new key informs the device's tray status to clients. It's only present if the device is a removable one. Signed-off-by: Luiz Capitulino lcapitul...@redhat.com --- block.c |5 + qmp-commands.hx |2 ++ 2 files changed, 7 insertions(+), 0 deletions(-) diff --git a/block.c b/block.c index 959eedd..e1b9057 100644 --- a/block.c +++ b/block.c @@ -1740,6 +1740,11 @@ void bdrv_info(Monitor *mon, QObject **ret_data) bs-device_name, bs-removable, bs-locked); +if (bs-removable) { +QDict *dict = qobject_to_qdict(bs_obj); +qdict_put(dict, tray-open, qbool_from_int(bs-tray_open)); +} + if (bs-drv) { QObject *obj; QDict *bs_dict = qobject_to_qdict(bs_obj); diff --git a/qmp-commands.hx b/qmp-commands.hx index a9f109a..8393f22 100644 --- a/qmp-commands.hx +++ b/qmp-commands.hx @@ -1043,6 +1043,8 @@ Each json-object contain the following: - Possible values: unknown - removable: true if the device is removable, false otherwise (json-bool) - locked: true if the device is locked, false otherwise (json-bool) +- tray-open: true if the device's tray is open, false otherwise. Only present + for removable media (json-bool) - inserted: only present if the device is inserted, it is a json-object containing the following: - file: device file name (json-string) -- 1.7.4.4
[Qemu-devel] [RFC 06/10] QMP: Introduce the blockdev-tray-close command
This command closes a removable media drive's tray. It's only available in QMP. Please, check the command's documentation (being introduced in this commit) for a detailed description. XXX: Should we return an error if the tray is already closed? Signed-off-by: Luiz Capitulino lcapitul...@redhat.com --- blockdev.c | 22 ++ blockdev.h |1 + qmp-commands.hx | 23 +++ 3 files changed, 46 insertions(+), 0 deletions(-) diff --git a/blockdev.c b/blockdev.c index b1c705c..943905d 100644 --- a/blockdev.c +++ b/blockdev.c @@ -704,6 +704,28 @@ static int tray_open(const char *device, int remove, int force) return 0; } +static int tray_close(const char *device) +{ +BlockDriverState *bs; + +bs = bdrv_removable_find(device); +if (!bs) { +return -1; +} + +if (bdrv_eject(bs, 0, 0) 0) { +/* FIXME: will report undefined error in QMP */ +return -1; +} + +return 0; +} + +int do_tray_close(Monitor *mon, const QDict *qdict, QObject **ret_data) +{ +return tray_close(qdict_get_str(qdict, device)); +} + int do_tray_open(Monitor *mon, const QDict *qdict, QObject **ret_data) { return tray_open(qdict_get_str(qdict, device), diff --git a/blockdev.h b/blockdev.h index 5e46aae..975e91a 100644 --- a/blockdev.h +++ b/blockdev.h @@ -66,5 +66,6 @@ int do_drive_del(Monitor *mon, const QDict *qdict, QObject **ret_data); int do_snapshot_blkdev(Monitor *mon, const QDict *qdict, QObject **ret_data); int do_block_resize(Monitor *mon, const QDict *qdict, QObject **ret_data); int do_tray_open(Monitor *mon, const QDict *qdict, QObject **ret_data); +int do_tray_close(Monitor *mon, const QDict *qdict, QObject **ret_data); #endif diff --git a/qmp-commands.hx b/qmp-commands.hx index 58ab132..fdf9750 100644 --- a/qmp-commands.hx +++ b/qmp-commands.hx @@ -153,6 +153,29 @@ Examples: EQMP { +.name = blockdev-tray-close, +.args_type = device:B, +.mhandler.cmd_new = do_tray_close, +}, + +SQMP +blockdev-tray-close +--- + +Close a removable media drive's tray. + +Arguments: + +- device: device name (json-string) + +Example: + +- { execute: blockdev-tray-close, arguments: { device: ide1-cd0 } } +- { return: {} } + +EQMP + +{ .name = blockdev-tray-open, .args_type = device:B,force:-f,remove:-r, .mhandler.cmd_new = do_tray_open, -- 1.7.4.4
Re: [Qemu-devel] [PATCH] qemu-kvm: fix pulseaudio detection in configure
On Fri, Apr 29, 2011 at 05:59:19PM +0200, Marc-Antoine Perennou wrote: pulse/simple.h does not include stdlib.h We cannot use NULL since it may not be defined Use 0 instead I am unable to reproduce this issue, even with gcc-4.6. Also please note that NULL is defined in stddef.h, not stdlib.h. stddef.h is included from sys/types.h which is included from pulse/simple.h. Do you have more information about the issue. Signed-off-by: Marc-Antoine Perennou marc-anto...@perennou.com --- configure |2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/configure b/configure index ea8b676..d67c3ce 100755 --- a/configure +++ b/configure @@ -1567,7 +1567,7 @@ for drv in $audio_drv_list; do pa) audio_drv_probe $drv pulse/simple.h -lpulse-simple -lpulse \ -pa_simple *s = NULL; pa_simple_free(s); return 0; +pa_simple *s = 0; pa_simple_free(s); return 0; It should be ((void*)0) instead of simply 0. libs_softmmu=-lpulse -lpulse-simple $libs_softmmu audio_pt_int=yes ;; -- 1.7.5.52.ge839f.dirty -- Aurelien Jarno GPG: 1024D/F1BCDB73 aurel...@aurel32.net http://www.aurel32.net
Re: [Qemu-devel] [PATCH v3] hw/pc: Support system flash memory with -pflash parameter
Ping? Cc:ed Anthony the maintainer of pc.c On Mon, Apr 18, 2011 at 10:46:40AM +0200, Aurelien Jarno wrote: On Thu, Mar 31, 2011 at 11:25:26AM -0700, Jordan Justen wrote: If -pflash is specified and -bios is specified then pflash will be mapped just below the system rom using hw/pflash_cfi01.c. If -pflash is specified on the command line, but -bios is not specified, then 'bios.bin' will NOT be loaded, and instead the -pflash flash image will be mapped just below 4GB in place of the normal rom image. Signed-off-by: Jordan Justen jordan.l.jus...@intel.com --- default-configs/i386-softmmu.mak |1 + default-configs/x86_64-softmmu.mak |1 + hw/pc.c| 161 +++- 3 files changed, 125 insertions(+), 38 deletions(-) Reviewed-by: Aurelien Jarno aurel...@aurel32.net diff --git a/default-configs/i386-softmmu.mak b/default-configs/i386-softmmu.mak index 55589fa..8697cd4 100644 --- a/default-configs/i386-softmmu.mak +++ b/default-configs/i386-softmmu.mak @@ -21,3 +21,4 @@ CONFIG_PIIX_PCI=y CONFIG_SOUND=y CONFIG_HPET=y CONFIG_APPLESMC=y +CONFIG_PFLASH_CFI01=y diff --git a/default-configs/x86_64-softmmu.mak b/default-configs/x86_64-softmmu.mak index 8895028..eca9284 100644 --- a/default-configs/x86_64-softmmu.mak +++ b/default-configs/x86_64-softmmu.mak @@ -21,3 +21,4 @@ CONFIG_PIIX_PCI=y CONFIG_SOUND=y CONFIG_HPET=y CONFIG_APPLESMC=y +CONFIG_PFLASH_CFI01=y diff --git a/hw/pc.c b/hw/pc.c index 6939c04..4812310 100644 --- a/hw/pc.c +++ b/hw/pc.c @@ -41,6 +41,7 @@ #include sysemu.h #include blockdev.h #include ui/qemu-spice.h +#include flash.h /* output Bochs bios info messages */ //#define DEBUG_BIOS @@ -957,6 +958,124 @@ void pc_cpus_init(const char *cpu_model) } } +static void pc_isa_bios_init(ram_addr_t ram_offset, int ram_size) +{ +int isa_bios_size; + +/* map the last 128KB of the BIOS in ISA space */ +isa_bios_size = ram_size; +if (isa_bios_size (128 * 1024)) { +isa_bios_size = 128 * 1024; +} +ram_offset = ram_offset + ram_size - isa_bios_size; +cpu_register_physical_memory(0x10 - isa_bios_size, + isa_bios_size, + ram_offset | IO_MEM_ROM); +} + +static int pc_system_rom_init(void) +{ +int ret; +int bios_size; +ram_addr_t bios_offset; +char *filename; + +/* BIOS load */ +if (bios_name == NULL) { +bios_name = BIOS_FILENAME; +} +filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name); +if (filename) { +bios_size = get_image_size(filename); +} else { +bios_size = -1; +} + +if (bios_size = 0 || (bios_size % 65536) != 0) { +ret = -1; +} else { +bios_offset = qemu_ram_alloc(NULL, pc.bios, bios_size); +ret = rom_add_file_fixed(bios_name, (uint32_t)(-bios_size), -1); +} + +if (ret != 0) { +fprintf(stderr, qemu: could not load PC BIOS '%s'\n, bios_name); +exit(1); +} + +if (filename) { +qemu_free(filename); +} + +pc_isa_bios_init(bios_offset, bios_size); + +/* map all the bios at the top of memory */ +cpu_register_physical_memory((uint32_t)(-bios_size), + bios_size, bios_offset | IO_MEM_ROM); + +return bios_size; +} + +static void pc_system_flash_init(DriveInfo *pflash_drv, int rom_size) +{ +BlockDriverState *bdrv; +int64_t size; +target_phys_addr_t phys_addr; +ram_addr_t addr; +int sector_bits, sector_size; + +bdrv = NULL; + +bdrv = pflash_drv-bdrv; +size = bdrv_getlength(pflash_drv-bdrv); +sector_bits = 12; +sector_size = 1 sector_bits; + +if ((size % sector_size) != 0) { +fprintf(stderr, +qemu: -pflash size must be a multiple of 0x%x\n, +sector_size); +exit(1); +} + +phys_addr = 0x1ULL - rom_size - size; +addr = qemu_ram_alloc(NULL, system.flash, size); +DPRINTF(flash addr: 0x%lx\n, (int64_t)phys_addr); +pflash_cfi01_register(phys_addr, addr, bdrv, + sector_size, size sector_bits, + 4, 0x, 0x, 0x, 0x, 0); + +if (rom_size == 0) { +pc_isa_bios_init(addr, size); +} +} + +static void pc_system_firmware_init(void) +{ +int flash_present, rom_present; +int rom_size; +DriveInfo *pflash_drv; + +pflash_drv = drive_get(IF_PFLASH, 0, 0); +flash_present = (pflash_drv != NULL); + +/* Load rom if -bios is used or if -pflash is not used */ +rom_present = ((bios_name != NULL) || !flash_present); + +/* If rom
Re: [Qemu-devel] [PATCH] multiboot: set boot_device to first partition
On Thu, Apr 28, 2011 at 04:11:11PM +0200, Arun Thomas wrote: The multiboot info struct's 'boot_device' field has 'part1' set to 0x01, which maps to the second primary partition. To specify the first primary partition, 'part1' should be set to 0x00, since partition numbers start from zero according to the multiboot spec. Signed-off-by: Arun Thomas arun.tho...@gmail.com --- hw/multiboot.c |2 +- 1 files changed, 1 insertions(+), 1 deletions(-) Thanks, applied. diff --git a/hw/multiboot.c b/hw/multiboot.c index 394ed01..6e6cfb9 100644 --- a/hw/multiboot.c +++ b/hw/multiboot.c @@ -307,7 +307,7 @@ int load_multiboot(void *fw_cfg, | MULTIBOOT_FLAGS_MMAP); stl_p(bootinfo + MBI_MEM_LOWER, 640); stl_p(bootinfo + MBI_MEM_UPPER, (ram_size / 1024) - 1024); -stl_p(bootinfo + MBI_BOOT_DEVICE, 0x8001); /* XXX: use the -boot switch? */ +stl_p(bootinfo + MBI_BOOT_DEVICE, 0x8000); /* XXX: use the -boot switch? */ stl_p(bootinfo + MBI_MMAP_ADDR, ADDR_E820_MAP); mb_debug(multiboot: mh_entry_addr = %#x\n, mh_entry_addr); -- tg: (d16e0f0..) bootdev (depends on: master) -- Aurelien Jarno GPG: 1024D/F1BCDB73 aurel...@aurel32.net http://www.aurel32.net
Re: [Qemu-devel] [PATCH] target-arm: Move VLD/VST multiple into helper functions
On Mon, May 02, 2011 at 05:01:24PM +0100, Peter Maydell wrote: On 20 April 2011 15:52, Peter Maydell peter.mayd...@linaro.org wrote: Move VLD/VST multiple into helper functions, as some cases can generate more TCG ops than the maximum per-instruction limit and certainly more than the recommended 20. I've had a review comment in private email that this patch slows down ffmpeg by a little over 4% (in a linux-user execution run where about 5% of instructions were an affected vld/vst). So perhaps the right approach is to increase the max-ops-per-insn limit and update the guidance in tcg/README instead? Does this patch fixes a real issue (ie most probably a crash), or it is just to make the arm target compliant with the README? Two remarks there: - The guidance in tcg/README is probably true for complex helpers in the sense of doing a lot of logic/arithmetic operations for which the TCG instruction set if not really rich and for which the compiler can do a lot better. When the instruction is emulated mostly by load/store ops, there isn't much possible optimizations left. - Your patch calls the slow version of the _mmu functions, which doesn't use the QEMU TLB. It is therefore normal to expect a slow down. Unfortunately the fast version of _mmu functions are not really usable from an helper, or at least they need a lot of code to convert an mmu index to the right function. It is something I have on my TODO list for some months, haven't found time to look at it. -- Aurelien Jarno GPG: 1024D/F1BCDB73 aurel...@aurel32.net http://www.aurel32.net
Re: [Qemu-devel] [PATCH] linux-user: add pselect6 syscall support
On Fri, Jun 3, 2011 at 14:10, riku voipio wrote: On 05/18/2011 03:14 AM, Mike Frysinger wrote: Some architectures (like Blackfin) only implement pselect6 (and skip select/newselect). So add support for it using existing newselect code. There is a blackfin qemu? i posted it to the list for feedback, but i havent followed up since Anyways, with this patch pselect01 ltp testcase starts failing. Looks like (at least on arm), arg6 is set and valid pointer, but arg7[0] is 0, which quite doesn't work as lock_user read target... Checking if arg7==0 and setting sig_ptr to null in that case makes the testcase to work, but is that correct? looking at the kernel code, it accepts a 6th arg which contains a NULL pointer (and then just ignores it), so i'll do the same -mike
[Qemu-devel] [PATCH v2] linux-user: add pselect6 syscall support
Some architectures (like Blackfin) only implement pselect6 (and skip select/newselect). So add support for it. Signed-off-by: Mike Frysinger vap...@gentoo.org --- v2 - handle null sigptr in a valid 6th sig struct linux-user/syscall.c | 149 +++-- 1 files changed, 130 insertions(+), 19 deletions(-) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 5cb27c7..793d4bf 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -550,6 +550,15 @@ _syscall5(int, sys_ppoll, struct pollfd *, fds, nfds_t, nfds, size_t, sigsetsize) #endif +#if defined(TARGET_NR_pselect6) +#ifndef __NR_pselect6 +# define __NR_pselect6 -1 +#endif +#define __NR_sys_pselect6 __NR_pselect6 +_syscall6(int, sys_pselect6, int, nfds, fd_set *, readfds, fd_set *, writefds, + fd_set *, exceptfds, struct timespec *, timeout, void *, sig); +#endif + extern int personality(int); extern int flock(int, int); extern int setfsuid(int); @@ -787,6 +796,20 @@ static inline abi_long copy_from_user_fdset(fd_set *fds, return 0; } +static inline abi_ulong copy_from_user_fdset_ptr(fd_set *fds, fd_set **fds_ptr, + abi_ulong target_fds_addr, + int n) +{ +if (target_fds_addr) { +if (copy_from_user_fdset(fds, target_fds_addr, n)) +return -TARGET_EFAULT; +*fds_ptr = fds; +} else { +*fds_ptr = NULL; +} +return 0; +} + static inline abi_long copy_to_user_fdset(abi_ulong target_fds_addr, const fd_set *fds, int n) @@ -952,6 +975,7 @@ static inline abi_long copy_to_user_mq_attr(abi_ulong target_mq_attr_addr, } #endif +#if defined(TARGET_NR_select) || defined(TARGET_NR__newselect) /* do_select() must return target values and target errnos. */ static abi_long do_select(int n, abi_ulong rfd_addr, abi_ulong wfd_addr, @@ -962,26 +986,17 @@ static abi_long do_select(int n, struct timeval tv, *tv_ptr; abi_long ret; -if (rfd_addr) { -if (copy_from_user_fdset(rfds, rfd_addr, n)) -return -TARGET_EFAULT; -rfds_ptr = rfds; -} else { -rfds_ptr = NULL; +ret = copy_from_user_fdset_ptr(rfds, rfds_ptr, rfd_addr, n); +if (ret) { +return ret; } -if (wfd_addr) { -if (copy_from_user_fdset(wfds, wfd_addr, n)) -return -TARGET_EFAULT; -wfds_ptr = wfds; -} else { -wfds_ptr = NULL; +ret = copy_from_user_fdset_ptr(wfds, wfds_ptr, wfd_addr, n); +if (ret) { +return ret; } -if (efd_addr) { -if (copy_from_user_fdset(efds, efd_addr, n)) -return -TARGET_EFAULT; -efds_ptr = efds; -} else { -efds_ptr = NULL; +ret = copy_from_user_fdset_ptr(efds, efds_ptr, efd_addr, n); +if (ret) { +return ret; } if (target_tv_addr) { @@ -1008,6 +1023,7 @@ static abi_long do_select(int n, return ret; } +#endif static abi_long do_pipe2(int host_pipe[], int flags) { @@ -5569,7 +5585,102 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1, #endif #ifdef TARGET_NR_pselect6 case TARGET_NR_pselect6: - goto unimplemented_nowarn; +{ +abi_long rfd_addr, wfd_addr, efd_addr, n, ts_addr; +fd_set rfds, wfds, efds; +fd_set *rfds_ptr, *wfds_ptr, *efds_ptr; +struct timespec ts, *ts_ptr; + +/* + * The 6th arg is actually two args smashed together, + * so we cannot use the C library. + */ +sigset_t set; +struct { +sigset_t *set; +size_t size; +} sig, *sig_ptr; + +abi_ulong arg_sigset, arg_sigsize, *arg7; +target_sigset_t *target_sigset; + +n = arg1; +rfd_addr = arg2; +wfd_addr = arg3; +efd_addr = arg4; +ts_addr = arg5; + +ret = copy_from_user_fdset_ptr(rfds, rfds_ptr, rfd_addr, n); +if (ret) { +goto fail; +} +ret = copy_from_user_fdset_ptr(wfds, wfds_ptr, wfd_addr, n); +if (ret) { +goto fail; +} +ret = copy_from_user_fdset_ptr(efds, efds_ptr, efd_addr, n); +if (ret) { +goto fail; +} + +/* + * This takes a timespec, and not a timeval, so we cannot + * use the do_select() helper ... + */ +if (ts_addr) { +if (target_to_host_timespec(ts, ts_addr)) { +goto efault; +} +ts_ptr = ts; +} else { +ts_ptr = NULL; +} + +/* Extract the two packed args
Re: [Qemu-devel] [RESEND2 PATCH] exec: Implement qemu_ram_free_from_ptr()
On Tue, May 03, 2011 at 12:48:09PM -0600, Alex Williamson wrote: Required for regions mapped via qemu_ram_alloc_from_ptr(). VFIO and ivshmem will make use of this to remove mappings when devices are hot unplugged. Signed-off-by: Alex Williamson alex.william...@redhat.com --- Trying to clean out my patch queuer;, I've proposed this twice, Cam has proposed this once, it's an obvious missing interface. Please apply. cpu-common.h |1 + exec.c | 13 + 2 files changed, 14 insertions(+), 0 deletions(-) Thanks, applied. diff --git a/cpu-common.h b/cpu-common.h index 96c02ae..db98b6b 100644 --- a/cpu-common.h +++ b/cpu-common.h @@ -50,6 +50,7 @@ ram_addr_t qemu_ram_alloc_from_ptr(DeviceState *dev, const char *name, ram_addr_t size, void *host); ram_addr_t qemu_ram_alloc(DeviceState *dev, const char *name, ram_addr_t size); void qemu_ram_free(ram_addr_t addr); +void qemu_ram_free_from_ptr(ram_addr_t addr); void qemu_ram_remap(ram_addr_t addr, ram_addr_t length); /* This should only be used for ram local to a device. */ void *qemu_get_ram_ptr(ram_addr_t addr); diff --git a/exec.c b/exec.c index a0678a4..1870ee7 100644 --- a/exec.c +++ b/exec.c @@ -2954,6 +2954,19 @@ ram_addr_t qemu_ram_alloc(DeviceState *dev, const char *name, ram_addr_t size) return qemu_ram_alloc_from_ptr(dev, name, size, NULL); } +void qemu_ram_free_from_ptr(ram_addr_t addr) +{ +RAMBlock *block; + +QLIST_FOREACH(block, ram_list.blocks, next) { +if (addr == block-offset) { +QLIST_REMOVE(block, next); +qemu_free(block); +return; +} +} +} + void qemu_ram_free(ram_addr_t addr) { RAMBlock *block; -- Aurelien Jarno GPG: 1024D/F1BCDB73 aurel...@aurel32.net http://www.aurel32.net
Re: [Qemu-devel] [PATCH] virtio-9p: Remove statement without effect (fix warning from cppcheck)
On Sat, May 07, 2011 at 10:23:49PM +0200, Stefan Weil wrote: cppcheck report: virtio-9p.c:197: warning: Redundant assignment of flags to itself Cc: Venkateswararao Jujjuri jv...@linux.vnet.ibm.com Signed-off-by: Stefan Weil w...@mail.berlios.de --- hw/9pfs/virtio-9p.c |1 - 1 files changed, 0 insertions(+), 1 deletions(-) Thanks, applied. diff --git a/hw/9pfs/virtio-9p.c b/hw/9pfs/virtio-9p.c index ac5a1d0..d31b34a 100644 --- a/hw/9pfs/virtio-9p.c +++ b/hw/9pfs/virtio-9p.c @@ -194,7 +194,6 @@ static int v9fs_do_open2(V9fsState *s, char *fullname, uid_t uid, gid_t gid, cred.fc_uid = uid; cred.fc_gid = gid; cred.fc_mode = mode 0; -flags = flags; return s-ops-open2(s-ctx, fullname, flags, cred); } -- 1.7.2.5 -- Aurelien Jarno GPG: 1024D/F1BCDB73 aurel...@aurel32.net http://www.aurel32.net
Re: [Qemu-devel] [PATCH] configure: check for -Wendif-labels support
On Tue, May 17, 2011 at 05:08:43PM -0400, Mike Frysinger wrote: Older gcc compilers do not support -Wendif-labels, so move it from the hardcoded list to the dynamically detected list. Signed-off-by: Mike Frysinger vap...@gentoo.org --- configure |4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) Thanks, applied. diff --git a/configure b/configure index 019bc8d..8b775a4 100755 --- a/configure +++ b/configure @@ -229,7 +229,7 @@ sdl_config=${cross_prefix}${SDL_CONFIG-sdl-config} # default flags for all hosts QEMU_CFLAGS=-fno-strict-aliasing $QEMU_CFLAGS CFLAGS=-g $CFLAGS -QEMU_CFLAGS=-Wall -Wundef -Wendif-labels -Wwrite-strings -Wmissing-prototypes $QEMU_CFLAGS +QEMU_CFLAGS=-Wall -Wundef -Wwrite-strings -Wmissing-prototypes $QEMU_CFLAGS QEMU_CFLAGS=-Wstrict-prototypes -Wredundant-decls $QEMU_CFLAGS QEMU_CFLAGS=-D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE $QEMU_CFLAGS QEMU_CFLAGS=-D_FORTIFY_SOURCE=2 $QEMU_CFLAGS @@ -1035,7 +1035,7 @@ fi gcc_flags=-Wold-style-declaration -Wold-style-definition -Wtype-limits gcc_flags=-Wformat-security -Wformat-y2k -Winit-self -Wignored-qualifiers $gcc_flags gcc_flags=-Wmissing-include-dirs -Wempty-body -Wnested-externs $gcc_flags -gcc_flags=-fstack-protector-all $gcc_flags +gcc_flags=-fstack-protector-all -Wendif-labels $gcc_flags cat $TMPC EOF int main(void) { return 0; } EOF -- 1.7.5.rc3 -- Aurelien Jarno GPG: 1024D/F1BCDB73 aurel...@aurel32.net http://www.aurel32.net
Re: [Qemu-devel] [PATCH] qemu-kvm: fix pulseaudio detection in configure
On Fri, 3 Jun 2011, Aurelien Jarno wrote: On Fri, Apr 29, 2011 at 05:59:19PM +0200, Marc-Antoine Perennou wrote: pulse/simple.h does not include stdlib.h We cannot use NULL since it may not be defined Use 0 instead I am unable to reproduce this issue, even with gcc-4.6. Also please note that NULL is defined in stddef.h, not stdlib.h. stddef.h is included from sys/types.h which is included from pulse/simple.h. Do you have more information about the issue. Signed-off-by: Marc-Antoine Perennou marc-anto...@perennou.com --- configure |2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/configure b/configure index ea8b676..d67c3ce 100755 --- a/configure +++ b/configure @@ -1567,7 +1567,7 @@ for drv in $audio_drv_list; do pa) audio_drv_probe $drv pulse/simple.h -lpulse-simple -lpulse \ -pa_simple *s = NULL; pa_simple_free(s); return 0; +pa_simple *s = 0; pa_simple_free(s); return 0; It should be ((void*)0) instead of simply 0. No it shouldn't. libs_softmmu=-lpulse -lpulse-simple $libs_softmmu audio_pt_int=yes ;; -- 1.7.5.52.ge839f.dirty -- mailto:av1...@comtv.ru
Re: [Qemu-devel] [PATCH] qemu-kvm: fix pulseaudio detection in configure
On Sat, Jun 04, 2011 at 01:57:23AM +0400, malc wrote: On Fri, 3 Jun 2011, Aurelien Jarno wrote: On Fri, Apr 29, 2011 at 05:59:19PM +0200, Marc-Antoine Perennou wrote: pulse/simple.h does not include stdlib.h We cannot use NULL since it may not be defined Use 0 instead I am unable to reproduce this issue, even with gcc-4.6. Also please note that NULL is defined in stddef.h, not stdlib.h. stddef.h is included from sys/types.h which is included from pulse/simple.h. Do you have more information about the issue. Signed-off-by: Marc-Antoine Perennou marc-anto...@perennou.com --- configure |2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/configure b/configure index ea8b676..d67c3ce 100755 --- a/configure +++ b/configure @@ -1567,7 +1567,7 @@ for drv in $audio_drv_list; do pa) audio_drv_probe $drv pulse/simple.h -lpulse-simple -lpulse \ -pa_simple *s = NULL; pa_simple_free(s); return 0; +pa_simple *s = 0; pa_simple_free(s); return 0; It should be ((void*)0) instead of simply 0. No it shouldn't. If we want to replace #include stddef.h, which should use the same code, that is: | #ifndef __cplusplus | #define NULL ((void *)0) | #else /* C++ */ | #define NULL 0 | #endif /* C++ */ Given we are writing C code and not C++ code, NULL is defined as ((void *)0). -- Aurelien Jarno GPG: 1024D/F1BCDB73 aurel...@aurel32.net http://www.aurel32.net
Re: [Qemu-devel] [PATCH v3] hw/pc: Support system flash memory with -pflash parameter
On Fri, Jun 3, 2011 at 13:36, Aurelien Jarno aurel...@aurel32.net wrote: Ping? Cc:ed Anthony the maintainer of pc.c Sorry, I've been meaning to rebase this and add your reviewed-by. Would that be the right next step in this case? -Jordan On Mon, Apr 18, 2011 at 10:46:40AM +0200, Aurelien Jarno wrote: On Thu, Mar 31, 2011 at 11:25:26AM -0700, Jordan Justen wrote: If -pflash is specified and -bios is specified then pflash will be mapped just below the system rom using hw/pflash_cfi01.c. If -pflash is specified on the command line, but -bios is not specified, then 'bios.bin' will NOT be loaded, and instead the -pflash flash image will be mapped just below 4GB in place of the normal rom image. Signed-off-by: Jordan Justen jordan.l.jus...@intel.com --- default-configs/i386-softmmu.mak | 1 + default-configs/x86_64-softmmu.mak | 1 + hw/pc.c | 161 +++- 3 files changed, 125 insertions(+), 38 deletions(-) Reviewed-by: Aurelien Jarno aurel...@aurel32.net diff --git a/default-configs/i386-softmmu.mak b/default-configs/i386-softmmu.mak index 55589fa..8697cd4 100644 --- a/default-configs/i386-softmmu.mak +++ b/default-configs/i386-softmmu.mak @@ -21,3 +21,4 @@ CONFIG_PIIX_PCI=y CONFIG_SOUND=y CONFIG_HPET=y CONFIG_APPLESMC=y +CONFIG_PFLASH_CFI01=y diff --git a/default-configs/x86_64-softmmu.mak b/default-configs/x86_64-softmmu.mak index 8895028..eca9284 100644 --- a/default-configs/x86_64-softmmu.mak +++ b/default-configs/x86_64-softmmu.mak @@ -21,3 +21,4 @@ CONFIG_PIIX_PCI=y CONFIG_SOUND=y CONFIG_HPET=y CONFIG_APPLESMC=y +CONFIG_PFLASH_CFI01=y diff --git a/hw/pc.c b/hw/pc.c index 6939c04..4812310 100644 --- a/hw/pc.c +++ b/hw/pc.c @@ -41,6 +41,7 @@ #include sysemu.h #include blockdev.h #include ui/qemu-spice.h +#include flash.h /* output Bochs bios info messages */ //#define DEBUG_BIOS @@ -957,6 +958,124 @@ void pc_cpus_init(const char *cpu_model) } } +static void pc_isa_bios_init(ram_addr_t ram_offset, int ram_size) +{ + int isa_bios_size; + + /* map the last 128KB of the BIOS in ISA space */ + isa_bios_size = ram_size; + if (isa_bios_size (128 * 1024)) { + isa_bios_size = 128 * 1024; + } + ram_offset = ram_offset + ram_size - isa_bios_size; + cpu_register_physical_memory(0x10 - isa_bios_size, + isa_bios_size, + ram_offset | IO_MEM_ROM); +} + +static int pc_system_rom_init(void) +{ + int ret; + int bios_size; + ram_addr_t bios_offset; + char *filename; + + /* BIOS load */ + if (bios_name == NULL) { + bios_name = BIOS_FILENAME; + } + filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name); + if (filename) { + bios_size = get_image_size(filename); + } else { + bios_size = -1; + } + + if (bios_size = 0 || (bios_size % 65536) != 0) { + ret = -1; + } else { + bios_offset = qemu_ram_alloc(NULL, pc.bios, bios_size); + ret = rom_add_file_fixed(bios_name, (uint32_t)(-bios_size), -1); + } + + if (ret != 0) { + fprintf(stderr, qemu: could not load PC BIOS '%s'\n, bios_name); + exit(1); + } + + if (filename) { + qemu_free(filename); + } + + pc_isa_bios_init(bios_offset, bios_size); + + /* map all the bios at the top of memory */ + cpu_register_physical_memory((uint32_t)(-bios_size), + bios_size, bios_offset | IO_MEM_ROM); + + return bios_size; +} + +static void pc_system_flash_init(DriveInfo *pflash_drv, int rom_size) +{ + BlockDriverState *bdrv; + int64_t size; + target_phys_addr_t phys_addr; + ram_addr_t addr; + int sector_bits, sector_size; + + bdrv = NULL; + + bdrv = pflash_drv-bdrv; + size = bdrv_getlength(pflash_drv-bdrv); + sector_bits = 12; + sector_size = 1 sector_bits; + + if ((size % sector_size) != 0) { + fprintf(stderr, + qemu: -pflash size must be a multiple of 0x%x\n, + sector_size); + exit(1); + } + + phys_addr = 0x1ULL - rom_size - size; + addr = qemu_ram_alloc(NULL, system.flash, size); + DPRINTF(flash addr: 0x%lx\n, (int64_t)phys_addr); + pflash_cfi01_register(phys_addr, addr, bdrv, + sector_size, size sector_bits, + 4, 0x, 0x, 0x, 0x, 0); + + if (rom_size == 0) { + pc_isa_bios_init(addr, size); + } +} + +static void pc_system_firmware_init(void) +{ + int flash_present, rom_present; + int rom_size; + DriveInfo *pflash_drv; + + pflash_drv = drive_get(IF_PFLASH, 0, 0); +
[Qemu-devel] [PATCH v2][ 07/21] qapi: add qapi-commands.py code generator
This is the code generator for qapi command marshaling/dispatch. Currently only generators for synchronous qapi/qmp functions are supported. This script generates the following files: $(prefix)qmp-marshal.c: command marshal/dispatch functions for each QMP command defined in the schema. Functions generated by qapi-visit.py are used to convert qobjects recieved from the wire into function parameters, and uses the same visiter functions to convert native C return values to qobjects from transmission back over the wire. $(prefix)qmp-commands.h: Function prototypes for the QMP commands specified in the schema. $(prefix) is used in the same manner as with qapi-types.py Signed-off-by: Michael Roth mdr...@linux.vnet.ibm.com --- scripts/qapi-commands.py | 468 ++ 1 files changed, 468 insertions(+), 0 deletions(-) create mode 100644 scripts/qapi-commands.py diff --git a/scripts/qapi-commands.py b/scripts/qapi-commands.py new file mode 100644 index 000..9d7b132 --- /dev/null +++ b/scripts/qapi-commands.py @@ -0,0 +1,468 @@ +from ordereddict import OrderedDict +from qapi import * +import sys +import os +import getopt + +def generate_visit_struct_body(field_prefix, members): +ret = +if len(field_prefix): +field_prefix = field_prefix + . +for argname, argentry, optional, structured in parse_args(members): +if optional: +ret += mcgen(''' +visit_start_optional(m, (*obj)-%(c_prefix)shas_%(c_name)s, %(name)s, errp); +if ((*obj)-%(prefix)shas_%(c_name)s) { +''', + c_prefix=c_var(field_prefix), prefix=field_prefix, + c_name=c_var(argname), name=argname) +push_indent() + +if structured: +ret += mcgen(''' +visit_start_struct(m, NULL, , %(name)s, errp); +''', + name=argname) +ret += generate_visit_struct_body(field_prefix + argname, argentry) +ret += mcgen(''' +visit_end_struct(m, errp); +''') +else: +ret += mcgen(''' +visit_type_%(type)s(m, (*obj)-%(c_prefix)s%(c_name)s, %(name)s, errp); +''', + c_prefix=c_var(field_prefix), prefix=field_prefix, + type=type_name(argentry), c_name=c_var(argname), + name=argname) + +if optional: +pop_indent() +ret += mcgen(''' +} +visit_end_optional(m, errp); +''') +return ret + +def generate_visit_struct(name, members): +ret = mcgen(''' + +void visit_type_%(name)s(Visiter *m, %(name)s ** obj, const char *name, Error **errp) +{ +visit_start_struct(m, (void **)obj, %(name)s, name, errp); +''', +name=name) +push_indent() +ret += generate_visit_struct_body(, members) +pop_indent() + +ret += mcgen(''' +visit_end_struct(m, errp); +} +''') +return ret + +def generate_visit_list(name, members): +return mcgen(''' + +void visit_type_%(name)sList(Visiter *m, %(name)sList ** obj, const char *name, Error **errp) +{ +GenericList *i; + +visit_start_list(m, name, errp); + +for (i = visit_next_list(m, (GenericList **)obj, errp); i; i = visit_next_list(m, i, errp)) { +%(name)sList *native_i = (%(name)sList *)i; +visit_type_%(name)s(m, native_i-value, NULL, errp); +} + +visit_end_list(m, errp); +} +''', +name=name) + +def generate_visit_handle(name, typeinfo): +return mcgen(''' + +void visit_type_%(name)s(Visiter *m, %(name)s ** obj, const char *name, Error **errp) +{ +visit_start_handle(m, (void **)obj, %(name)s, name, errp); +visit_type_%(type_name)s(m, (*obj)-handle, handle, errp); +visit_end_handle(m, errp); +} +''', +name=name, type_name=type_name(typeinfo)) + +def generate_visit_enum(name, members): +return mcgen(''' + +void visit_type_%(name)s(Visiter *m, %(name)s * obj, const char *name, Error **errp) +{ +visit_type_enum(m, (int *)obj, %(name)s, name, errp); +} +''', + name=name) + +def generate_visit_union(name, members): +ret = generate_visit_enum('%sKind' % name, members.keys()) + +ret += mcgen(''' + +void visit_type_%(name)s(Visiter *m, %(name)s ** obj, const char *name, Error **errp) +{ +} +''', + name=name) + +return ret + +def generate_declaration(name, members, genlist=True): +ret = mcgen(''' + +void visit_type_%(name)s(Visiter *m, %(name)s ** obj, const char *name, Error **errp); +''', +name=name) + +if genlist: +ret += mcgen(''' +void visit_type_%(name)sList(Visiter *m, %(name)sList ** obj, const char *name, Error **errp); +''', + name=name) + +return ret + +def generate_decl_enum(name, members,
[Qemu-devel] [PATCH v2][ 01/21] Add hard build dependency on glib
From: Anthony Liguori aligu...@us.ibm.com GLib is an extremely common library that has a portable thread implementation along with tons of other goodies. GLib and GObject have a fantastic amount of infrastructure we can leverage in QEMU including an object oriented programming infrastructure. Short term, it has a very nice thread pool implementation that we could leverage in something like virtio-9p. It also has a test harness implementation that this series will use. Signed-off-by: Anthony Liguori aligu...@us.ibm.com Signed-off-by: Michael Roth mdr...@linux.vnet.ibm.com --- Makefile|2 ++ Makefile.objs |2 ++ Makefile.target |1 + configure | 13 + 4 files changed, 18 insertions(+), 0 deletions(-) diff --git a/Makefile b/Makefile index d7944c8..cf318c8 100644 --- a/Makefile +++ b/Makefile @@ -106,6 +106,8 @@ audio/audio.o audio/fmodaudio.o: QEMU_CFLAGS += $(FMOD_CFLAGS) QEMU_CFLAGS+=$(CURL_CFLAGS) +QEMU_CFLAGS+=$(GLIB_CFLAGS) + ui/cocoa.o: ui/cocoa.m ui/sdl.o audio/sdlaudio.o ui/sdl_zoom.o baum.o: QEMU_CFLAGS += $(SDL_CFLAGS) diff --git a/Makefile.objs b/Makefile.objs index 66ffad4..eb264d9 100644 --- a/Makefile.objs +++ b/Makefile.objs @@ -366,3 +366,5 @@ vl.o: QEMU_CFLAGS+=$(GPROF_CFLAGS) vl.o: QEMU_CFLAGS+=$(SDL_CFLAGS) +vl.o: QEMU_CFLAGS+=$(GLIB_CFLAGS) + diff --git a/Makefile.target b/Makefile.target index 602d50d..1082228 100644 --- a/Makefile.target +++ b/Makefile.target @@ -204,6 +204,7 @@ QEMU_CFLAGS += $(VNC_TLS_CFLAGS) QEMU_CFLAGS += $(VNC_SASL_CFLAGS) QEMU_CFLAGS += $(VNC_JPEG_CFLAGS) QEMU_CFLAGS += $(VNC_PNG_CFLAGS) +QEMU_CFLAGS += $(GLIB_CFLAGS) # xen backend driver support obj-i386-$(CONFIG_XEN) += xen_machine_pv.o xen_domainbuild.o diff --git a/configure b/configure index a318d37..5a7ec17 100755 --- a/configure +++ b/configure @@ -1766,6 +1766,18 @@ EOF fi ## +# glib support probe +if $pkg_config --modversion gthread-2.0 gio-2.0 /dev/null 21 ; then +glib_cflags=`$pkg_config --cflags gthread-2.0 gio-2.0 2/dev/null` +glib_libs=`$pkg_config --libs gthread-2.0 gio-2.0 2/dev/null` +libs_softmmu=$glib_libs $libs_softmmu +libs_tools=$glib_libs $libs_tools +else +echo glib-2.0 required to compile QEMU +exit 1 +fi + +## # kvm probe if test $kvm != no ; then cat $TMPC EOF @@ -2939,6 +2951,7 @@ if test $bluez = yes ; then echo CONFIG_BLUEZ=y $config_host_mak echo BLUEZ_CFLAGS=$bluez_cflags $config_host_mak fi +echo GLIB_CFLAGS=$glib_cflags $config_host_mak if test $xen = yes ; then echo CONFIG_XEN=y $config_host_mak echo CONFIG_XEN_CTRL_INTERFACE_VERSION=$xen_ctrl_version $config_host_mak -- 1.7.0.4
[Qemu-devel] [PATCH v2][ 21/21] qapi: add QAPI code generation documentation
Signed-off-by: Michael Roth mdr...@linux.vnet.ibm.com --- docs/qapi-code-gen.txt | 316 1 files changed, 316 insertions(+), 0 deletions(-) create mode 100644 docs/qapi-code-gen.txt diff --git a/docs/qapi-code-gen.txt b/docs/qapi-code-gen.txt new file mode 100644 index 000..35ab9ef --- /dev/null +++ b/docs/qapi-code-gen.txt @@ -0,0 +1,316 @@ += How to use the QAPI code generator = + +* Note: as of this writing, QMP does not use QAPI. Eventually QMP +commands will be converted to use QAPI internally. The following +information describes QMP/QAPI as it will exist after the +conversion. + +QAPI is a native C API within QEMU which provides management-level +functionality to internal/external users. For external +users/processes, this interface is made available by a JSON-based +QEMU Monitor protocol that is provided by the QMP server. + +To map QMP-defined interfaces to the native C QAPI implementations, +a JSON-based schema is used to define types and function +signatures, and a set of scripts is used to generate types/signatures, +and marshaling/dispatch code. The QEMU Guest Agent also uses these +scripts, paired with a seperate schema, to generate +marshaling/dispatch code for the guest agent server running in the +guest. + +This document will describe how the schemas, scripts, and resulting +code is used. + + +== QMP/Guest agent schema == + +This file defines the types, commands, and events used by QMP. It should +fully describe the interface used by QMP. + +This file is designed to be loosely based on JSON although it's technically +executable Python. While dictionaries are used, they are parsed as +OrderedDicts so that ordering is preserved. + +There are two basic syntaxes used, type definitions and command definitions. + +The first syntax defines a type and is represented by a dictionary. There are +two kinds of types that are supported: complex user-defined types, and enums. + +A complex type is a dictionary containing a single key who's value is a +dictionary. This corresponds to a struct in C or an Object in JSON. An +example of a complex type is: + + { 'type': 'MyType', + 'data' { 'member1': 'str', 'member2': 'int', '*member3': 'str } } + +The use of '*' as a prefix to the name means the member is optional. Optional +members should always be added to the end of the dictionary to preserve +backwards compatibility. + +An enumeration type is a dictionary containing a single key who's value is a +list of strings. An example enumeration is: + + { 'enum': 'MyEnum', 'data': [ 'value1', 'value2', 'value3' ] } + +Generally speaking, complex types and enums should always use CamelCase for +the type names. + +Commands are defined by using a list containing three members. The first +member is the command name, the second member is a dictionary containing +arguments, and the third member is the return type. + +An example command is: + + { 'command': 'my-command', + 'data': { 'arg1': 'str', '*arg2': 'str' }, + 'returns': 'str' ] + +Command names should be all lower case with words separated by a hyphen. + + +== Code generation == + +Schemas are fed into 3 scripts to generate all the code/files that, paired +with the core QAPI libraries, comprise everything required to take JSON +commands read in by a QMP/guest agent server, unmarshal the arguments into +the underlying C types, call into the corresponding C function, and map the +response back to a QMP/guest agent response to be returned to the user. + +As an example, we'll use the following schema, which describes a single +complex user-defined type (which will produce a C struct, along with a list +node structure that can be used to chain together a list of such types in +case we want to accept/return a list of this type with a command), and a +command which takes that type as a parameter and returns the same type: + +mdroth@illuin:~/w/qemu2.git$ cat example-schema.json +{ 'type': 'UserDefOne', + 'data': { 'integer': 'int', 'string': 'str' } } + +{ 'command': 'my-command', + 'data':{'arg1': 'UserDefOne'}, + 'returns': 'UserDefOne' } +mdroth@illuin:~/w/qemu2.git$ + +=== scripts/qapi-types.py === + +Used to generate the C types defined by a schema. The following files are +created: + +$(prefix)qapi-types.h - C types corresponding to types defined in +the schema you pass in +$(prefix)qapi-types.c - Cleanup functions for the above C types + +The $(prefix) is an optional parameter used as a namespace to keep the +generated code from one schema/code-generation separated from others so code +can be generated/used from multiple schemas without clobbering previously +created code. + +Example: + +mdroth@illuin:~/w/qemu2.git$ python scripts/qapi-types.py \ + --output-dir=qapi-generated --prefix=example- example-schema.json +mdroth@illuin:~/w/qemu2.git$ cat qapi-generated/example-qapi-types.c +/* AUTOMATICALLY
[Qemu-devel] [QAPI+QGA 2/3] QAPI code generation infrastructure v2
This is Set 2/3 of the QAPI+QGA patchsets. These patches apply on top of qapi-backport-set1-v1, and can also be obtained from: git://repo.or.cz/qemu/mdroth.git qapi-backport-set2-v2 (Set1+2 are a backport of some of the QAPI-related work from Anthony's glib tree. The main goal is to get the basic code generation infrastructure in place so that it can be used by the guest agent to implement a QMP-like guest interface, and so that future work regarding the QMP conversion to QAPI can be decoupled from the infrastructure bits. Set3 is the Qemu Guest Agent (virtagent), rebased on the new code QAPI code generation infrastructure. This is the first user of QAPI, QMP will follow.) ___ This patchset introduces the following: - Hard dependency on GLib. This has been floating around the list for a while. Currently the only users are the unit tests for this patchset and the guest agent. We can make both of these a configure option, but based on previous discussions a hard dependency will likely be introduced with subsequent QAPI patches. - A couple additional qlist utility functions used by QAPI. - QAPI schema-based code generation for synchronous QMP/QGA commands and types, and Visiter/dispatch infrastructure to handle marshaling/unmarshaling/dispatch between QAPI and the QMP/QGA wire protocols. - Documentation and unit tests for visiter functions and synchronous command/type generation. CHANGES SINCE V1: - Fixed build issue that was missed due to deprecated files being present in source tree. Thanks to Matsuda Daiki for sending fixes. - Fixed grammatical errors in documentation pointed out by Luiz. - Added generated code to the make clean target. CHANGES SINCE V0 (QAPI Infrastructure Round 1): - Fixed known memory leaks in generated code - Stricter error-handling in generated code - Removed currently unused code (generators for events and async/proxied QMP/QGA commands and definition used by the not-yet-introduced QMP server replacement) - Added documentation for code generation scripts/schemas/usage - Addressed review comments from Luiz and Stefan Makefile| 22 ++ Makefile.objs |9 + Makefile.target |1 + configure | 13 ++ docs/qapi-code-gen.txt | 316 + module.h|2 + qapi-schema-test.json | 16 ++ qapi/qapi-dealloc-visiter.c | 127 qapi/qapi-dealloc-visiter.h | 26 +++ qapi/qapi-types-core.h | 21 ++ qapi/qapi-visit-core.h | 187 + qapi/qmp-core.h | 43 qapi/qmp-dispatch.c | 73 +++ qapi/qmp-input-visiter.c| 239 ++ qapi/qmp-input-visiter.h| 26 +++ qapi/qmp-output-visiter.c | 180 + qapi/qmp-output-visiter.h | 27 +++ qapi/qmp-registry.c | 27 +++ qlist.h | 11 + scripts/ordereddict.py | 128 scripts/qapi-commands.py| 468 +++ scripts/qapi-types.py | 221 scripts/qapi-visit.py | 223 scripts/qapi.py | 181 + test-qmp-commands.c | 113 +++ test-visiter.c | 214 26 files changed, 2914 insertions(+), 0 deletions(-)
[Qemu-devel] [PATCH v2][ 03/21] qapi: add module init types for qapi
Signed-off-by: Michael Roth mdr...@linux.vnet.ibm.com --- module.h |2 ++ 1 files changed, 2 insertions(+), 0 deletions(-) diff --git a/module.h b/module.h index 9263f1c..ef66730 100644 --- a/module.h +++ b/module.h @@ -24,12 +24,14 @@ typedef enum { MODULE_INIT_BLOCK, MODULE_INIT_DEVICE, MODULE_INIT_MACHINE, +MODULE_INIT_QAPI, MODULE_INIT_MAX } module_init_type; #define block_init(function) module_init(function, MODULE_INIT_BLOCK) #define device_init(function) module_init(function, MODULE_INIT_DEVICE) #define machine_init(function) module_init(function, MODULE_INIT_MACHINE) +#define qapi_init(function) module_init(function, MODULE_INIT_QAPI) void register_module_init(void (*fn)(void), module_init_type type); -- 1.7.0.4
[Qemu-devel] [PATCH v2][ 10/21] qapi: add QMP input visiter
A type of Visiter class that is used to walk a qobject's structure and assign each entry to the corresponding native C type. Command marshaling function will use this to pull out QMP command parameters recieved over the wire and pass them as native arguments to the corresponding C functions. Signed-off-by: Michael Roth mdr...@linux.vnet.ibm.com --- qapi/qmp-input-visiter.c | 239 ++ qapi/qmp-input-visiter.h | 26 + 2 files changed, 265 insertions(+), 0 deletions(-) create mode 100644 qapi/qmp-input-visiter.c create mode 100644 qapi/qmp-input-visiter.h diff --git a/qapi/qmp-input-visiter.c b/qapi/qmp-input-visiter.c new file mode 100644 index 000..6767e39 --- /dev/null +++ b/qapi/qmp-input-visiter.c @@ -0,0 +1,239 @@ +#include qmp-input-visiter.h +#include qemu-queue.h +#include qemu-common.h +#include qemu-objects.h +#include qerror.h + +#define QAPI_OBJECT_SIZE 512 + +#define QIV_STACK_SIZE 1024 + +typedef struct StackObject +{ +QObject *obj; +QListEntry *entry; +} StackObject; + +struct QmpInputVisiter +{ +Visiter visiter; +QObject *obj; +StackObject stack[QIV_STACK_SIZE]; +int nb_stack; +}; + +static QmpInputVisiter *to_qiv(Visiter *v) +{ +return container_of(v, QmpInputVisiter, visiter); +} + +static QObject *qmp_input_get_object(QmpInputVisiter *qiv, const char *name) +{ +QObject *qobj; + +if (qiv-nb_stack == 0) { +qobj = qiv-obj; +} else { +qobj = qiv-stack[qiv-nb_stack - 1].obj; +} + +if (name qobject_type(qobj) == QTYPE_QDICT) { +return qdict_get(qobject_to_qdict(qobj), name); +} else if (qiv-nb_stack 0 qobject_type(qobj) == QTYPE_QLIST) { +return qlist_entry_obj(qiv-stack[qiv-nb_stack - 1].entry); +} + +return qobj; +} + +static void qmp_input_push(QmpInputVisiter *qiv, QObject *obj) +{ +qiv-stack[qiv-nb_stack].obj = obj; +if (qobject_type(obj) == QTYPE_QLIST) { +qiv-stack[qiv-nb_stack].entry = qlist_first(qobject_to_qlist(obj)); +} +qiv-nb_stack++; + +assert(qiv-nb_stack QIV_STACK_SIZE); // FIXME +} + +static void qmp_input_pop(QmpInputVisiter *qiv) +{ +qiv-nb_stack--; +assert(qiv-nb_stack = 0); // FIXME +} + +static void qmp_input_start_struct(Visiter *v, void **obj, const char *kind, const char *name, Error **errp) +{ +QmpInputVisiter *qiv = to_qiv(v); +QObject *qobj = qmp_input_get_object(qiv, name); + +if (!qobj || qobject_type(qobj) != QTYPE_QDICT) { +error_set(errp, QERR_INVALID_PARAMETER_TYPE, name, object); +return; +} + +qmp_input_push(qiv, qobj); + +if (obj) { +*obj = qemu_mallocz(QAPI_OBJECT_SIZE); +} +} + +static void qmp_input_end_struct(Visiter *v, Error **errp) +{ +QmpInputVisiter *qiv = to_qiv(v); + +qmp_input_pop(qiv); +} + +static void qmp_input_start_list(Visiter *v, const char *name, Error **errp) +{ +QmpInputVisiter *qiv = to_qiv(v); +QObject *qobj = qmp_input_get_object(qiv, name); + +if (!qobj || qobject_type(qobj) != QTYPE_QLIST) { +error_set(errp, QERR_INVALID_PARAMETER_TYPE, name, list); +return; +} + +qmp_input_push(qiv, qobj); +} + +static GenericList *qmp_input_next_list(Visiter *v, GenericList **list, Error **errp) +{ +QmpInputVisiter *qiv = to_qiv(v); +GenericList *entry; +StackObject *so = qiv-stack[qiv-nb_stack - 1]; + +if (so-entry == NULL) { +return NULL; +} + +entry = qemu_mallocz(sizeof(*entry)); +if (*list) { +so-entry = qlist_next(so-entry); +if (so-entry == NULL) { +qemu_free(entry); +return NULL; +} +(*list)-next = entry; +} +*list = entry; + + +return entry; +} + +static void qmp_input_end_list(Visiter *v, Error **errp) +{ +QmpInputVisiter *qiv = to_qiv(v); + +qmp_input_pop(qiv); +} + +static void qmp_input_type_int(Visiter *v, int64_t *obj, const char *name, Error **errp) +{ +QmpInputVisiter *qiv = to_qiv(v); +QObject *qobj = qmp_input_get_object(qiv, name); + +if (!qobj || qobject_type(qobj) != QTYPE_QINT) { +error_set(errp, QERR_INVALID_PARAMETER_TYPE, name, integer); +return; +} + +*obj = qint_get_int(qobject_to_qint(qobj)); +} + +static void qmp_input_type_bool(Visiter *v, bool *obj, const char *name, Error **errp) +{ +QmpInputVisiter *qiv = to_qiv(v); +QObject *qobj = qmp_input_get_object(qiv, name); + +if (!qobj || qobject_type(qobj) != QTYPE_QBOOL) { +error_set(errp, QERR_INVALID_PARAMETER_TYPE, name, boolean); +return; +} + +*obj = qbool_get_int(qobject_to_qbool(qobj)); +} + +static void qmp_input_type_str(Visiter *v, char **obj, const char *name, Error **errp) +{ +QmpInputVisiter *qiv = to_qiv(v); +QObject *qobj = qmp_input_get_object(qiv, name); + +if (!qobj || qobject_type(qobj) != QTYPE_QSTRING) { +error_set(errp, QERR_INVALID_PARAMETER_TYPE, name,
[Qemu-devel] [PATCH v4][ 7/7] guest agent: Makefile, build qemu-ga
This allows us to build qemu-ga with make qemu-ga. It pulls in the qemu-tools deps, but does not currently build by default. This may change to avoid bitrot and help with host-side-only unit tests. Signed-off-by: Michael Roth mdr...@linux.vnet.ibm.com --- Makefile | 22 +- qemu-ga.c | 10 ++ 2 files changed, 27 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index 944e85e..bc86156 100644 --- a/Makefile +++ b/Makefile @@ -123,7 +123,7 @@ version-obj-$(CONFIG_WIN32) += version.o ## qemu-img.o: qemu-img-cmds.h -qemu-img.o qemu-tool.o qemu-nbd.o qemu-io.o cmd.o: $(GENERATED_HEADERS) +qemu-img.o qemu-tool.o qemu-nbd.o qemu-io.o cmd.o qemu-ga.o: $(GENERATED_HEADERS) qemu-img$(EXESUF): qemu-img.o qemu-tool.o qemu-error.o $(oslib-obj-y) $(trace-obj-y) $(block-obj-y) $(qobject-obj-y) $(version-obj-y) qemu-timer-common.o @@ -146,7 +146,7 @@ check-qfloat: check-qfloat.o qfloat.o $(CHECK_PROG_DEPS) check-qjson: check-qjson.o qfloat.o qint.o qdict.o qstring.o qlist.o qbool.o qjson.o json-streamer.o json-lexer.o json-parser.o error.o qerror.o qemu-error.o $(CHECK_PROG_DEPS) qapi-dir := qapi-generated -$(qapi-obj-y) test-visiter.o test-qmp-commands.o: QEMU_CFLAGS += -I $(qapi-dir) +$(qapi-obj-y) test-visiter.o test-qmp-commands.o qemu-ga$(EXESUF): QEMU_CFLAGS += -I $(qapi-dir) $(qapi-dir)/test-qapi-types.c: $(qapi-dir)/test-qapi-types.h $(qapi-dir)/test-qapi-types.h: $(SRC_PATH)/qapi-schema-test.json $(SRC_PATH)/scripts/qapi-types.py @@ -158,20 +158,32 @@ $(qapi-dir)/test-qmp-commands.h: $(qapi-dir)/test-qmp-marshal.c $(qapi-dir)/test-qmp-marshal.c: $(SRC_PATH)/qapi-schema-test.json $(SRC_PATH)/scripts/qapi-commands.py $(call quiet-command,python $(SRC_PATH)/scripts/qapi-commands.py -o $(qapi-dir) -p test- $, GEN $@) +$(qapi-dir)/qga-qapi-types.c: $(qapi-dir)/qga-qapi-types.h +$(qapi-dir)/qga-qapi-types.h: $(SRC_PATH)/qapi-schema-guest.json $(SRC_PATH)/scripts/qapi-types.py + $(call quiet-command,python $(SRC_PATH)/scripts/qapi-types.py -o $(qapi-dir) -p qga- $, GEN $@) +$(qapi-dir)/qga-qapi-visit.c: $(qapi-dir)/qga-qapi-visit.h +$(qapi-dir)/qga-qapi-visit.h: $(SRC_PATH)/qapi-schema-guest.json $(SRC_PATH)/scripts/qapi-visit.py + $(call quiet-command,python $(SRC_PATH)/scripts/qapi-visit.py -o $(qapi-dir) -p qga- $, GEN $@) +$(qapi-dir)/qga-qmp-marshal.c: $(SRC_PATH)/qapi-schema-guest.json $(SRC_PATH)/scripts/qapi-commands.py + $(call quiet-command,python $(SRC_PATH)/scripts/qapi-commands.py -o $(qapi-dir) -p qga- $, GEN $@) + test-visiter.o: $(addprefix $(qapi-dir)/, test-qapi-types.c test-qapi-types.h test-qapi-visit.c test-qapi-visit.h) test-visiter: test-visiter.o qfloat.o qint.o qdict.o qstring.o qlist.o qbool.o $(qapi-obj-y) error.o osdep.o qemu-malloc.o $(oslib-obj-y) qjson.o json-streamer.o json-lexer.o json-parser.o qerror.o qemu-error.o qemu-tool.o $(qapi-dir)/test-qapi-visit.o $(qapi-dir)/test-qapi-types.o test-qmp-commands.o: $(addprefix $(qapi-dir)/, test-qapi-types.c test-qapi-types.h test-qapi-visit.c test-qapi-visit.h test-qmp-marshal.c test-qmp-commands.h) test-qmp-commands: test-qmp-commands.o qfloat.o qint.o qdict.o qstring.o qlist.o qbool.o $(qapi-obj-y) error.o osdep.o qemu-malloc.o $(oslib-obj-y) qjson.o json-streamer.o json-lexer.o json-parser.o qerror.o qemu-error.o qemu-tool.o $(qapi-dir)/test-qapi-visit.o $(qapi-dir)/test-qapi-types.o $(qapi-dir)/test-qmp-marshal.o module.o +qemu-ga.o: $(qapi-dir)/qga-qapi-types.c $(qapi-dir)/qga-qapi-types.h $(qapi-dir)/qga-qapi-visit.c $(qapi-dir)/qga-qmp-marshal.c +qemu-ga$(EXESUF): qemu-ga.o qemu-tool.o qemu-error.o error.o $(oslib-obj-y) $(trace-obj-y) $(block-obj-y) $(qobject-obj-y) $(version-obj-y) $(qapi-obj-y) qemu-timer-common.o qemu-sockets.o qga/guest-agent-commands.o qga/guest-agent-command-state.o qga/guest-agent-worker.o $(qapi-dir)/qga-qapi-visit.o $(qapi-dir)/qga-qmp-marshal.o module.o qapi/qmp-dispatch.o qapi/qmp-registry.o + QEMULIBS=libhw32 libhw64 libuser libdis libdis-user clean: # avoid old build problems by removing potentially incorrect old files rm -f config.mak op-i386.h opc-i386.h gen-op-i386.h op-arm.h opc-arm.h gen-op-arm.h rm -f qemu-options.def - rm -f *.o *.d *.a $(TOOLS) TAGS cscope.* *.pod *~ */*~ - rm -f slirp/*.o slirp/*.d audio/*.o audio/*.d block/*.o block/*.d net/*.o net/*.d fsdev/*.o fsdev/*.d ui/*.o ui/*.d + rm -f *.o *.d *.a $(TOOLS) qemu-ga TAGS cscope.* *.pod *~ */*~ + rm -f slirp/*.o slirp/*.d audio/*.o audio/*.d block/*.o block/*.d net/*.o net/*.d fsdev/*.o fsdev/*.d ui/*.o ui/*.d $(qapi-dir)/* qga/*.o qga/*.d rm -f qemu-img-cmds.h rm -f trace.c trace.h trace.c-timestamp trace.h-timestamp rm -f trace-dtrace.dtrace trace-dtrace.dtrace-timestamp @@ -364,4 +376,4 @@ tarbin: $(mandir)/man8/qemu-nbd.8 # Include
[Qemu-devel] [PATCH v2][ 02/21] qlist: add qlist_first()/qlist_next()
Signed-off-by: Michael Roth mdr...@linux.vnet.ibm.com --- qlist.h | 11 +++ 1 files changed, 11 insertions(+), 0 deletions(-) diff --git a/qlist.h b/qlist.h index dbe7b92..cd2d23e 100644 --- a/qlist.h +++ b/qlist.h @@ -16,6 +16,7 @@ #include qobject.h #include qemu-queue.h #include qemu-common.h +#include qemu-queue.h typedef struct QListEntry { QObject *value; @@ -50,4 +51,14 @@ QObject *qlist_peek(QList *qlist); int qlist_empty(const QList *qlist); QList *qobject_to_qlist(const QObject *obj); +static inline QListEntry *qlist_first(QList *qlist) +{ +return QTAILQ_FIRST(qlist-head); +} + +static inline QListEntry *qlist_next(QListEntry *entry) +{ +return QTAILQ_NEXT(entry, next); +} + #endif /* QLIST_H */ -- 1.7.0.4
[Qemu-devel] [PATCH v2][ 05/21] qapi: add qapi-types.py code generator
This is the code generator for qapi types. It will generation the following files: $(prefix)qapi-types.h - C types corresponding to types defined in the schema you pass in $(prefix)qapi-types.c - Cleanup functions for the above C types The $(prefix) is used to as a namespace to keep the generated code from one schema/code-generation separated from others so code and be generated from multiple schemas with clobbering previously created code. Signed-off-by: Michael Roth mdr...@linux.vnet.ibm.com --- scripts/qapi-types.py | 221 + 1 files changed, 221 insertions(+), 0 deletions(-) create mode 100644 scripts/qapi-types.py diff --git a/scripts/qapi-types.py b/scripts/qapi-types.py new file mode 100644 index 000..15603f3 --- /dev/null +++ b/scripts/qapi-types.py @@ -0,0 +1,221 @@ +from ordereddict import OrderedDict +from qapi import * +import sys +import os +import getopt + +def generate_fwd_struct(name, members): +return mcgen(''' +typedef struct %(name)s %(name)s; + +typedef struct %(name)sList +{ +%(name)s *value; +struct %(name)sList *next; +} %(name)sList; +''', + name=name) + +def generate_struct(structname, fieldname, members): +ret = mcgen(''' +struct %(name)s +{ +''', + name=structname) + +for argname, argentry, optional, structured in parse_args(members): +if optional: +ret += mcgen(''' +bool has_%(c_name)s; +''', + c_name=c_var(argname)) +if structured: +push_indent() +ret += generate_struct(, argname, argentry) +pop_indent() +else: +ret += mcgen(''' +%(c_type)s %(c_name)s; +''', + c_type=c_type(argentry), c_name=c_var(argname)) + +if len(fieldname): +fieldname = + fieldname +ret += mcgen(''' +}%(field)s; +''', +field=fieldname) + +return ret + +def generate_handle(name, typeinfo): +return mcgen(''' +typedef struct %(name)s +{ +%(c_type)s handle; +} %(name)s; + +typedef struct %(name)sList +{ +%(name)s *value; +struct %(name)sList *next; +} %(name)sList; +''', + name=name, c_type=c_type(typeinfo)) + +def generate_enum(name, values): +ret = mcgen(''' +typedef enum %(name)s +{ +''', +name=name) + +i = 1 +for value in values: +ret += mcgen(''' +%(abbrev)s_%(value)s = %(i)d, +''', + abbrev=de_camel_case(name).upper(), + value=c_var(value).upper(), + i=i) +i += 1 + +ret += mcgen(''' +} %(name)s; +''', + name=name) + +return ret + +def generate_union(name, typeinfo): +ret = mcgen(''' +struct %(name)s +{ +%(name)sKind kind; +union { +''', +name=name) + +for key in typeinfo: +ret += mcgen(''' +%(c_type)s %(c_name)s; +''', + c_type=c_type(typeinfo[key]), + c_name=c_var(key)) + +ret += mcgen(''' +}; +}; +''') + +return ret + +def generate_type_cleanup_decl(name): +ret = mcgen(''' +void qapi_free_%(type)s(%(c_type)s obj); +''', +c_type=c_type(name),type=name) +return ret + +def generate_type_cleanup(name): +ret = mcgen(''' +void qapi_free_%(type)s(%(c_type)s obj) +{ +QapiDeallocVisiter *md; +Visiter *v; + +if (!obj) { +return; +} + +md = qapi_dealloc_visiter_new(); +v = qapi_dealloc_get_visiter(md); +visit_type_%(type)s(v, obj, NULL, NULL); +qapi_dealloc_visiter_cleanup(md); +} +''', +c_type=c_type(name),type=name) +return ret + + +try: +opts, args = getopt.gnu_getopt(sys.argv[1:], p:o:, [prefix=, output-dir=]) +except getopt.GetoptError, err: +print str(err) +sys.exit(1) + +output_dir = +prefix = +c_file = 'qapi-types.c' +h_file = 'qapi-types.h' + +for o, a in opts: +if o in (-p, --prefix): +prefix = a +elif o in (-o, --output-dir): +output_dir = a + / + +c_file = output_dir + prefix + c_file +h_file = output_dir + prefix + h_file + +if os.path.isdir(output_dir) == False: +os.makedirs(output_dir) + +fdef = open(c_file, 'w') +fdecl = open(h_file, 'w') + +fdef.write(mcgen(''' +/* AUTOMATICALLY GENERATED, DO NOT MODIFY */ + +#include qapi/qapi-dealloc-visiter.h +#include %(prefix)sqapi-types.h +#include %(prefix)sqapi-visit.h + +''', prefix=prefix)) + +fdecl.write(mcgen(''' +/* AUTOMATICALLY GENERATED, DO NOT MODIFY */ +#ifndef %(guard)s +#define %(guard)s + +#include qapi/qapi-types-core.h +''', + guard=guardname(h_file))) + +exprs = parse_schema(sys.stdin) + +for expr in exprs: +ret = \n +if expr.has_key('type'): +ret += generate_fwd_struct(expr['type'], expr['data']) +elif expr.has_key('enum'): +add_enum(expr['enum']) +ret += generate_enum(expr['enum'],
[Qemu-devel] [PATCH v2][ 11/21] qapi: add QMP output visiter
Type of Visiter class that serves as the inverse of the input visiter: it takes a series of native C types and uses their values to construct a corresponding QObject. The command marshaling/dispatcher functions will use this to convert the output of QMP functions into a QObject that can be sent over the wire. Signed-off-by: Michael Roth mdr...@linux.vnet.ibm.com --- qapi/qmp-output-visiter.c | 180 + qapi/qmp-output-visiter.h | 27 +++ 2 files changed, 207 insertions(+), 0 deletions(-) create mode 100644 qapi/qmp-output-visiter.c create mode 100644 qapi/qmp-output-visiter.h diff --git a/qapi/qmp-output-visiter.c b/qapi/qmp-output-visiter.c new file mode 100644 index 000..4a7cb36 --- /dev/null +++ b/qapi/qmp-output-visiter.c @@ -0,0 +1,180 @@ +#include qmp-output-visiter.h +#include qemu-queue.h +#include qemu-common.h +#include qemu-objects.h + +typedef struct QStackEntry +{ +QObject *value; +QTAILQ_ENTRY(QStackEntry) node; +} QStackEntry; + +typedef QTAILQ_HEAD(QStack, QStackEntry) QStack; + +struct QmpOutputVisiter +{ +Visiter visiter; +QStack stack; +}; + +#define qmp_output_add(qov, name, value) qmp_output_add_obj(qov, name, QOBJECT(value)) +#define qmp_output_push(qov, value) qmp_output_push_obj(qov, QOBJECT(value)) + +static QmpOutputVisiter *to_qov(Visiter *v) +{ +return container_of(v, QmpOutputVisiter, visiter); +} + +static void qmp_output_push_obj(QmpOutputVisiter *qov, QObject *value) +{ +QStackEntry *e = qemu_mallocz(sizeof(*e)); + +e-value = value; +QTAILQ_INSERT_HEAD(qov-stack, e, node); +} + +static QObject *qmp_output_pop(QmpOutputVisiter *qov) +{ +QStackEntry *e = QTAILQ_FIRST(qov-stack); +QObject *value; +QTAILQ_REMOVE(qov-stack, e, node); +value = e-value; +qemu_free(e); +return value; +} + +static QObject *qmp_output_first(QmpOutputVisiter *qov) +{ +QStackEntry *e = QTAILQ_LAST(qov-stack, QStack); +return e-value; +} + +static QObject *qmp_output_last(QmpOutputVisiter *qov) +{ +QStackEntry *e = QTAILQ_FIRST(qov-stack); +return e-value; +} + +static void qmp_output_add_obj(QmpOutputVisiter *qov, const char *name, QObject *value) +{ +QObject *cur; + +if (QTAILQ_EMPTY(qov-stack)) { +qmp_output_push_obj(qov, value); +return; +} + +cur = qmp_output_last(qov); + +switch (qobject_type(cur)) { +case QTYPE_QDICT: +qdict_put_obj(qobject_to_qdict(cur), name, value); +break; +case QTYPE_QLIST: +qlist_append_obj(qobject_to_qlist(cur), value); +break; +default: +qobject_decref(qmp_output_pop(qov)); +qmp_output_push_obj(qov, value); +break; +} +} + +static void qmp_output_start_struct(Visiter *v, void **obj, const char *kind, const char *name, Error **errp) +{ +QmpOutputVisiter *qov = to_qov(v); +QDict *dict = qdict_new(); + +qmp_output_add(qov, name, dict); +qmp_output_push(qov, dict); +} + +static void qmp_output_end_struct(Visiter *v, Error **errp) +{ +QmpOutputVisiter *qov = to_qov(v); +qmp_output_pop(qov); +} + +static void qmp_output_start_list(Visiter *v, const char *name, Error **errp) +{ +QmpOutputVisiter *qov = to_qov(v); +QList *list = qlist_new(); + +qmp_output_add(qov, name, list); +qmp_output_push(qov, list); +} + +static GenericList *qmp_output_next_list(Visiter *v, GenericList **list, Error **errp) +{ +GenericList *retval = *list; +*list = retval-next; +return retval; +} + +static void qmp_output_end_list(Visiter *v, Error **errp) +{ +QmpOutputVisiter *qov = to_qov(v); +qmp_output_pop(qov); +} + +static void qmp_output_type_int(Visiter *v, int64_t *obj, const char *name, Error **errp) +{ +QmpOutputVisiter *qov = to_qov(v); +qmp_output_add(qov, name, qint_from_int(*obj)); +} + +static void qmp_output_type_bool(Visiter *v, bool *obj, const char *name, Error **errp) +{ +QmpOutputVisiter *qov = to_qov(v); +qmp_output_add(qov, name, qbool_from_int(*obj)); +} + +static void qmp_output_type_str(Visiter *v, char **obj, const char *name, Error **errp) +{ +QmpOutputVisiter *qov = to_qov(v); +qmp_output_add(qov, name, qstring_from_str(*obj)); +} + +static void qmp_output_type_number(Visiter *v, double *obj, const char *name, Error **errp) +{ +QmpOutputVisiter *qov = to_qov(v); +qmp_output_add(qov, name, qfloat_from_double(*obj)); +} + +static void qmp_output_type_enum(Visiter *v, int *obj, const char *kind, const char *name, Error **errp) +{ +int64_t value = *obj; +qmp_output_type_int(v, value, name, errp); +} + +QObject *qmp_output_get_qobject(QmpOutputVisiter *qov) +{ +return qmp_output_first(qov); +} + +Visiter *qmp_output_get_visiter(QmpOutputVisiter *v) +{ +return v-visiter; +} + +QmpOutputVisiter *qmp_output_visiter_new(void) +{ +QmpOutputVisiter *v; + +v = qemu_mallocz(sizeof(*v)); + +v-visiter.start_struct =
[Qemu-devel] [PATCH v2][ 04/21] qapi: add ordereddict/qapi.py helper libraries
Signed-off-by: Michael Roth mdr...@linux.vnet.ibm.com --- scripts/ordereddict.py | 128 ++ scripts/qapi.py| 181 2 files changed, 309 insertions(+), 0 deletions(-) create mode 100644 scripts/ordereddict.py create mode 100644 scripts/qapi.py diff --git a/scripts/ordereddict.py b/scripts/ordereddict.py new file mode 100644 index 000..e17269f --- /dev/null +++ b/scripts/ordereddict.py @@ -0,0 +1,128 @@ +# Copyright (c) 2009 Raymond Hettinger +# +# Permission is hereby granted, free of charge, to any person +# obtaining a copy of this software and associated documentation files +# (the Software), to deal in the Software without restriction, +# including without limitation the rights to use, copy, modify, merge, +# publish, distribute, sublicense, and/or sell copies of the Software, +# and to permit persons to whom the Software is furnished to do so, +# subject to the following conditions: +# +# The above copyright notice and this permission notice shall be +# included in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +# OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +# OTHER DEALINGS IN THE SOFTWARE. + +from UserDict import DictMixin + +class OrderedDict(dict, DictMixin): + +def __init__(self, *args, **kwds): +if len(args) 1: +raise TypeError('expected at most 1 arguments, got %d' % len(args)) +try: +self.__end +except AttributeError: +self.clear() +self.update(*args, **kwds) + +def clear(self): +self.__end = end = [] +end += [None, end, end] # sentinel node for doubly linked list +self.__map = {} # key -- [key, prev, next] +dict.clear(self) + +def __setitem__(self, key, value): +if key not in self: +end = self.__end +curr = end[1] +curr[2] = end[1] = self.__map[key] = [key, curr, end] +dict.__setitem__(self, key, value) + +def __delitem__(self, key): +dict.__delitem__(self, key) +key, prev, next = self.__map.pop(key) +prev[2] = next +next[1] = prev + +def __iter__(self): +end = self.__end +curr = end[2] +while curr is not end: +yield curr[0] +curr = curr[2] + +def __reversed__(self): +end = self.__end +curr = end[1] +while curr is not end: +yield curr[0] +curr = curr[1] + +def popitem(self, last=True): +if not self: +raise KeyError('dictionary is empty') +if last: +key = reversed(self).next() +else: +key = iter(self).next() +value = self.pop(key) +return key, value + +def __reduce__(self): +items = [[k, self[k]] for k in self] +tmp = self.__map, self.__end +del self.__map, self.__end +inst_dict = vars(self).copy() +self.__map, self.__end = tmp +if inst_dict: +return (self.__class__, (items,), inst_dict) +return self.__class__, (items,) + +def keys(self): +return list(self) + +setdefault = DictMixin.setdefault +update = DictMixin.update +pop = DictMixin.pop +values = DictMixin.values +items = DictMixin.items +iterkeys = DictMixin.iterkeys +itervalues = DictMixin.itervalues +iteritems = DictMixin.iteritems + +def __repr__(self): +if not self: +return '%s()' % (self.__class__.__name__,) +return '%s(%r)' % (self.__class__.__name__, self.items()) + +def copy(self): +return self.__class__(self) + +@classmethod +def fromkeys(cls, iterable, value=None): +d = cls() +for key in iterable: +d[key] = value +return d + +def __eq__(self, other): +if isinstance(other, OrderedDict): +if len(self) != len(other): +return False +for p, q in zip(self.items(), other.items()): +if p != q: +return False +return True +return dict.__eq__(self, other) + +def __ne__(self, other): +return not self == other + diff --git a/scripts/qapi.py b/scripts/qapi.py new file mode 100644 index 000..422b6bd --- /dev/null +++ b/scripts/qapi.py @@ -0,0 +1,181 @@ +from ordereddict import OrderedDict + +def tokenize(data): +while len(data): +if data[0] in ['{', '}', ':', ',', '[',
Re: [Qemu-devel] [PATCH] qemu-kvm: fix pulseaudio detection in configure
On Sat, 4 Jun 2011, Aurelien Jarno wrote: On Sat, Jun 04, 2011 at 01:57:23AM +0400, malc wrote: On Fri, 3 Jun 2011, Aurelien Jarno wrote: On Fri, Apr 29, 2011 at 05:59:19PM +0200, Marc-Antoine Perennou wrote: pulse/simple.h does not include stdlib.h We cannot use NULL since it may not be defined Use 0 instead I am unable to reproduce this issue, even with gcc-4.6. Also please note that NULL is defined in stddef.h, not stdlib.h. stddef.h is included from sys/types.h which is included from pulse/simple.h. Do you have more information about the issue. Signed-off-by: Marc-Antoine Perennou marc-anto...@perennou.com --- configure |2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/configure b/configure index ea8b676..d67c3ce 100755 --- a/configure +++ b/configure @@ -1567,7 +1567,7 @@ for drv in $audio_drv_list; do pa) audio_drv_probe $drv pulse/simple.h -lpulse-simple -lpulse \ -pa_simple *s = NULL; pa_simple_free(s); return 0; +pa_simple *s = 0; pa_simple_free(s); return 0; It should be ((void*)0) instead of simply 0. No it shouldn't. If we want to replace #include stddef.h, which should use the same code, that is: | #ifndef __cplusplus | #define NULL ((void *)0) | #else /* C++ */ | #define NULL 0 | #endif /* C++ */ Given we are writing C code and not C++ code, NULL is defined as ((void *)0). Doesn't make a dent of a differnce how particular implementation defines NULL, 6.2.3.3#3 covers it, what i'm trying to get across is that your strong should is wrong. -- mailto:av1...@comtv.ru
[Qemu-devel] [PATCH v2][ 12/21] qapi: add QAPI dealloc visiter
Type of Visiter class that can be passed into a qapi-generated C type's visiter function to free() any heap-allocated data types. Signed-off-by: Michael Roth mdr...@linux.vnet.ibm.com --- qapi/qapi-dealloc-visiter.c | 127 +++ qapi/qapi-dealloc-visiter.h | 26 + 2 files changed, 153 insertions(+), 0 deletions(-) create mode 100644 qapi/qapi-dealloc-visiter.c create mode 100644 qapi/qapi-dealloc-visiter.h diff --git a/qapi/qapi-dealloc-visiter.c b/qapi/qapi-dealloc-visiter.c new file mode 100644 index 000..fe5e68d --- /dev/null +++ b/qapi/qapi-dealloc-visiter.c @@ -0,0 +1,127 @@ +#include qapi-dealloc-visiter.h +#include qemu-queue.h +#include qemu-common.h +#include qemu-objects.h + +typedef struct StackEntry +{ +void *value; +QTAILQ_ENTRY(StackEntry) node; +} StackEntry; + +struct QapiDeallocVisiter +{ +Visiter visiter; +QTAILQ_HEAD(, StackEntry) stack; +}; + +static QapiDeallocVisiter *to_qov(Visiter *v) +{ +return container_of(v, QapiDeallocVisiter, visiter); +} + +static void qapi_dealloc_push(QapiDeallocVisiter *qov, void *value) +{ +StackEntry *e = qemu_mallocz(sizeof(*e)); + +e-value = value; +QTAILQ_INSERT_HEAD(qov-stack, e, node); +} + +static void *qapi_dealloc_pop(QapiDeallocVisiter *qov) +{ +StackEntry *e = QTAILQ_FIRST(qov-stack); +QObject *value; +QTAILQ_REMOVE(qov-stack, e, node); +value = e-value; +qemu_free(e); +return value; +} + +static void qapi_dealloc_start_struct(Visiter *v, void **obj, const char *kind, const char *name, Error **errp) +{ +QapiDeallocVisiter *qov = to_qov(v); +qapi_dealloc_push(qov, obj); +} + +static void qapi_dealloc_end_struct(Visiter *v, Error **errp) +{ +QapiDeallocVisiter *qov = to_qov(v); +void **obj = qapi_dealloc_pop(qov); +if (obj *obj) { +qemu_free(*obj); +} +} + +static void qapi_dealloc_start_list(Visiter *v, const char *name, Error **errp) +{ +} + +static GenericList *qapi_dealloc_next_list(Visiter *v, GenericList **list, Error **errp) +{ +GenericList *retval = *list; +if (retval-value) { +qemu_free(retval-value); +} +*list = retval-next; +return retval; +} + +static void qapi_dealloc_end_list(Visiter *v, Error **errp) +{ +} + +static void qapi_dealloc_type_str(Visiter *v, char **obj, const char *name, Error **errp) +{ +if (obj *obj) { +qemu_free(*obj); +} +} + +static void qapi_dealloc_type_int(Visiter *v, int64_t *obj, const char *name, Error **errp) +{ +} + +static void qapi_dealloc_type_bool(Visiter *v, bool *obj, const char *name, Error **errp) +{ +} + +static void qapi_dealloc_type_number(Visiter *v, double *obj, const char *name, Error **errp) +{ +} + +static void qapi_dealloc_type_enum(Visiter *v, int *obj, const char *kind, const char *name, Error **errp) +{ +} + +Visiter *qapi_dealloc_get_visiter(QapiDeallocVisiter *v) +{ +return v-visiter; +} + +void qapi_dealloc_visiter_cleanup(QapiDeallocVisiter *v) +{ +qemu_free(v); +} + +QapiDeallocVisiter *qapi_dealloc_visiter_new(void) +{ +QapiDeallocVisiter *v; + +v = qemu_mallocz(sizeof(*v)); + +v-visiter.start_struct = qapi_dealloc_start_struct; +v-visiter.end_struct = qapi_dealloc_end_struct; +v-visiter.start_list = qapi_dealloc_start_list; +v-visiter.next_list = qapi_dealloc_next_list; +v-visiter.end_list = qapi_dealloc_end_list; +v-visiter.type_enum = qapi_dealloc_type_enum; +v-visiter.type_int = qapi_dealloc_type_int; +v-visiter.type_bool = qapi_dealloc_type_bool; +v-visiter.type_str = qapi_dealloc_type_str; +v-visiter.type_number = qapi_dealloc_type_number; + +QTAILQ_INIT(v-stack); + +return v; +} diff --git a/qapi/qapi-dealloc-visiter.h b/qapi/qapi-dealloc-visiter.h new file mode 100644 index 000..9192fc8 --- /dev/null +++ b/qapi/qapi-dealloc-visiter.h @@ -0,0 +1,26 @@ +/* + * Dealloc Visiter + * + * Copyright IBM, Corp. 2011 + * + * Authors: + * Michael Roth mdr...@linux.vnet.ibm.com + * + * This work is licensed under the terms of the GNU LGPL, version 2.1 or later. + * See the COPYING.LIB file in the top-level directory. + * + */ + +#ifndef QAPI_DEALLOC_VISITER_H +#define QAPI_DEALLOC_VISITER_H + +#include qapi-visit-core.h + +typedef struct QapiDeallocVisiter QapiDeallocVisiter; + +QapiDeallocVisiter *qapi_dealloc_visiter_new(void); +void qapi_dealloc_visiter_cleanup(QapiDeallocVisiter *d); + +Visiter *qapi_dealloc_get_visiter(QapiDeallocVisiter *v); + +#endif -- 1.7.0.4
[Qemu-devel] [PATCH v2][ 16/21] qapi: test schema used for unit tests
This is how QMP commands/parameters/types would be defined. We use a subset of that functionality here to implement functions/types for unit testing. Signed-off-by: Michael Roth mdr...@linux.vnet.ibm.com --- qapi-schema-test.json | 16 1 files changed, 16 insertions(+), 0 deletions(-) create mode 100644 qapi-schema-test.json diff --git a/qapi-schema-test.json b/qapi-schema-test.json new file mode 100644 index 000..3c8d56b --- /dev/null +++ b/qapi-schema-test.json @@ -0,0 +1,16 @@ +# *-*- Mode: Python -*-* + +# for testing nested structs +{ 'type': 'UserDefOne', + 'data': { 'integer': 'int', 'string': 'str' } } + +{ 'type': 'UserDefTwo', + 'data': { 'string': 'str', +'dict': { 'string': 'str', + 'dict': { 'userdef': 'UserDefOne', 'string': 'str' }, + '*dict2': { 'userdef': 'UserDefOne', 'string': 'str' } } } } + +# testing commands +{ 'command': 'user_def_cmd', 'data': {} } +{ 'command': 'user_def_cmd1', 'data': {'ud1a': 'UserDefOne'} } +{ 'command': 'user_def_cmd2', 'data': {'ud1a': 'UserDefOne', 'ud1b': 'UserDefOne'}, 'returns': 'UserDefTwo' } -- 1.7.0.4
[Qemu-devel] [PATCH v2][ 06/21] qapi: add qapi-visit.py code generator
This is the code generator for qapi visiter functions used to marshal/unmarshal/dealloc qapi types. It generates the following 2 files: $(prefix)qapi-visit.c: visiter function for a particular c type, used to automagically convert qobjects into the corresponding C type and vice-versa, and well as for deallocation memory for an existing C type $(prefix)qapi-visit.h: declarations for previously mentioned visiter functions $(prefix) is used as decribed for qapi-types.py Signed-off-by: Michael Roth mdr...@linux.vnet.ibm.com --- scripts/qapi-visit.py | 223 + 1 files changed, 223 insertions(+), 0 deletions(-) create mode 100644 scripts/qapi-visit.py diff --git a/scripts/qapi-visit.py b/scripts/qapi-visit.py new file mode 100644 index 000..c228709 --- /dev/null +++ b/scripts/qapi-visit.py @@ -0,0 +1,223 @@ +from ordereddict import OrderedDict +from qapi import * +import sys +import os +import getopt + +def generate_visit_struct_body(field_prefix, members): +ret = +if len(field_prefix): +field_prefix = field_prefix + . +for argname, argentry, optional, structured in parse_args(members): +if optional: +ret += mcgen(''' +visit_start_optional(m, (obj *obj) ? (*obj)-%(c_prefix)shas_%(c_name)s : NULL, %(name)s, errp); +if ((*obj)-%(prefix)shas_%(c_name)s) { +''', + c_prefix=c_var(field_prefix), prefix=field_prefix, + c_name=c_var(argname), name=argname) +push_indent() + +if structured: +ret += mcgen(''' +visit_start_struct(m, NULL, , %(name)s, errp); +''', + name=argname) +ret += generate_visit_struct_body(field_prefix + argname, argentry) +ret += mcgen(''' +visit_end_struct(m, errp); +''') +else: +ret += mcgen(''' +visit_type_%(type)s(m, (obj *obj) ? (*obj)-%(c_prefix)s%(c_name)s : NULL, %(name)s, errp); +''', + c_prefix=c_var(field_prefix), prefix=field_prefix, + type=type_name(argentry), c_name=c_var(argname), + name=argname) + +if optional: +pop_indent() +ret += mcgen(''' +} +visit_end_optional(m, errp); +''') +return ret + +def generate_visit_struct(name, members): +ret = mcgen(''' + +void visit_type_%(name)s(Visiter *m, %(name)s ** obj, const char *name, Error **errp) +{ +visit_start_struct(m, (void **)obj, %(name)s, name, errp); +''', +name=name) +push_indent() +ret += generate_visit_struct_body(, members) +pop_indent() + +ret += mcgen(''' +visit_end_struct(m, errp); +} +''') +return ret + +def generate_visit_list(name, members): +return mcgen(''' + +void visit_type_%(name)sList(Visiter *m, %(name)sList ** obj, const char *name, Error **errp) +{ +GenericList *i; + +visit_start_list(m, name, errp); + +for (i = visit_next_list(m, (GenericList **)obj, errp); i; i = visit_next_list(m, i, errp)) { +%(name)sList *native_i = (%(name)sList *)i; +visit_type_%(name)s(m, native_i-value, NULL, errp); +} + +visit_end_list(m, errp); +} +''', +name=name) + +def generate_visit_handle(name, typeinfo): +return mcgen(''' + +void visit_type_%(name)s(Visiter *m, %(name)s ** obj, const char *name, Error **errp) +{ +visit_start_handle(m, (void **)obj, %(name)s, name, errp); +visit_type_%(type_name)s(m, (*obj)-handle, handle, errp); +visit_end_handle(m, errp); +} +''', +name=name, type_name=type_name(typeinfo)) + +def generate_visit_enum(name, members): +return mcgen(''' + +void visit_type_%(name)s(Visiter *m, %(name)s * obj, const char *name, Error **errp) +{ +visit_type_enum(m, (int *)obj, %(name)s, name, errp); +} +''', + name=name) + +def generate_visit_union(name, members): +ret = generate_visit_enum('%sKind' % name, members.keys()) + +ret += mcgen(''' + +void visit_type_%(name)s(Visiter *m, %(name)s ** obj, const char *name, Error **errp) +{ +} +''', + name=name) + +return ret + +def generate_declaration(name, members, genlist=True): +ret = mcgen(''' + +void visit_type_%(name)s(Visiter *m, %(name)s ** obj, const char *name, Error **errp); +''', +name=name) + +if genlist: +ret += mcgen(''' +void visit_type_%(name)sList(Visiter *m, %(name)sList ** obj, const char *name, Error **errp); +''', + name=name) + +return ret + +def generate_decl_enum(name, members, genlist=True): +return mcgen(''' + +void visit_type_%(name)s(Visiter *m, %(name)s * obj, const char *name, Error **errp); +''', +name=name) + +try: +opts, args = getopt.gnu_getopt(sys.argv[1:], p:o:, [prefix=, output-dir=])