Re: [Qemu-devel] [PATCH] block: Add support for vpc Fixed Disk type
Am 01.02.2012 17:51, schrieb Charles Arnold: On 2/1/2012 at 05:15 AM, in message 4f292cd0.20...@redhat.com, Kevin Wolf kw...@redhat.com wrote: Am 01.02.2012 00:04, schrieb Charles Arnold: Thanks Andreas, The 'TODO uuid is missing' comment in the patch is from the original sources (as well as many '//' comments). The vhd footer and header data structures contain a field for a UUID but no code was ever developed to generate one. The revised patch is below after running scripts/checkpatch.pl and fixing the 32 bit issues. - Charles The Virtual Hard Disk Image Format Specification allows for three types of hard disk formats, Fixed, Dynamic, and Differencing. Qemu currently only supports Dynamic disks. This patch adds support for the Fixed Disk format. Usage: Example 1: qemu-img create -f vpc -o type=fixed filename [size] Example 2: qemu-img convert -O vpc -o type=fixed input filename output filename While it is also allowed to specify '-o type=dynamic', the default disk type remains Dynamic and is what is used when the type is left unspecified. Signed-off-by: Charles Arnold carn...@suse.com @@ -186,6 +197,14 @@ static int vpc_open(BlockDriverState *bs, int flags) goto fail; } +/* The footer is all that is needed for fixed disks */ +if (disk_type == VHD_FIXED) { +/* The fixed disk format doesn't use footer-data_offset but it + should be initialized */ +footer-data_offset = be64_to_cpu(0xULL); Why should it be changed? s-footer_buf is only used for updating the footer, so you will change the value that is in the image file. The spec states the following about the data_offset field in the footer, This field is used for dynamic disks and differencing disks, but not fixed disks. For fixed disks, this field should be set to 0x. (Windows initializes all 8 bytes of the field) Which is relevant when creating images (there we do set data_offset to 0x), but not when opening images. If anything, you could check if the value is set right and return an error otherwise. +return 0; This leaves most of BDRVVPCState uninitialised. I can't imagine how bdrv_read/write could possibly work with an image in this state. Something essential seems to be missing here. If vpc_open is opening a fixed disk, there is no dynamic disk header from which to acquire information for filling out the BDRVVPCState structure. However, you are right about the read/write code likely not working with the structure left uninitialised. I'll look into what needs to be done here. The easiest way is probably to set a field in BDRVVPCState that remembers the image type, and have two versions of get_sector_offset(). Dynamic images would use the existing one, and fixed a new trivial one that checks if the sector_num is within the image and returns 512 * sector_num. alloc_block() needs to fail for fixed images. In fact you could even assert() that it doesn't happen. +} + if (bdrv_pread(bs-file, be64_to_cpu(footer-data_offset), buf, HEADER_SIZE) != HEADER_SIZE) goto fail; @@ -533,10 +552,10 @@ static int calculate_geometry(int64_t total_sectors, uint16_t* cyls, return 0; } -static int vpc_create(const char *filename, QEMUOptionParameter *options) +static int vpc_create_dynamic_disk(const char *filename, int64_t total_size) { uint8_t buf[1024]; -struct vhd_footer* footer = (struct vhd_footer*) buf; +struct vhd_footer* footer = (struct vhd_footer *) buf; Don't reformat existing code. Even if scripts/checkpatch.pl complains? What is the policy here if a patch contains changes that are within 3
Re: [Qemu-devel] [RFC Patch 0/7]Qemu: Dynamic host pagecache change
Am 01.02.2012 23:41, schrieb Eric Blake: On 01/31/2012 08:05 PM, Supriya Kannery wrote: For changing host pagecache setting of a running VM, it is important to have a safe way of reopening its image file. Following patchset introduces: * a generic way to reopen image files safely. In this approach, before reopening an image, for each block driver, its state will be stashed. Incase preparation (bdrv_reopen_prepare) for reopening returns success, the stashed state will be cleared (bdrv_reopen_commit) and reopened state will be used further. Incase preparation of reopening returns failure, the state of the driver will be rolled back (bdrv_reopen_abort) to the stashed state. This approach is extended to raw-posix, raw-win32 and vmdk block drivers in this patchset. Once this is reviewed and finalised, I will extend the implementation to other drivers like qcow2, qed etc.. How will this interplay with the goal of passing images in by fd rather than by name? I'd really like to start thinking about how we plan on coordinating situations where an fd has to be reopened in order to switch flags (such as O_RDONLY becoming O_RDWR, or adding or subtracting O_DIRECT), but where SELinux or other isolation means that the management app (such as libvirt) has to do the open and pass the fd via 'getfd' monitor command. That's easy: Either your host OS allows to change the respective flag using fcntl(), which I believe is true for O_DIRECT/O_DSYNC and recent Linux kernels, or you're out of luck. Is there any reason for switching between rw/ro other than modifying the backing file chain (i.e. creating or deleting a snapshot)? Kevin
[Qemu-devel] [Bug 818673] Re: virtio: trying to map MMIO memory
Does this Bug similiar with https://bugzilla.redhat.com/show_bug.cgi?id=771390 ? ** Bug watch added: Red Hat Bugzilla #771390 https://bugzilla.redhat.com/show_bug.cgi?id=771390 -- You received this bug notification because you are a member of qemu- devel-ml, which is subscribed to QEMU. https://bugs.launchpad.net/bugs/818673 Title: virtio: trying to map MMIO memory Status in QEMU: New Bug description: Qemu host is Core i7, running Linux. Guest is Windows XP sp3. Often, qemu will crash shortly after starting (1-5 minutes) with a statement qemu-system-x86_64: virtio: trying to map MMIO memory This has occured with qemu-kvm 0.14, qemu-kvm 0.14.1, qemu-0.15.0-rc0 and qemu 0.15.0-rc1. Qemu is started as such: qemu-system-x86_64 -cpu host -enable-kvm -pidfile /home/rick/qemu/hds/wxp.pid -drive file=/home/rick/qemu/hds/wxp.raw,if=virtio -m 768 -name WinXP -net nic,model=virtio -net user -localtime -usb -vga qxl -device virtio-serial -chardev spicevmc,name=vdagent,id=vdagent -device virtserialport,chardev=vdagent,name=com.redhat.spice.0 -spice port=1234,disable-ticketing -daemonize -monitor telnet:localhost:12341,server,nowait The WXP guest has virtio 1.1.16 drivers for net and scsi, and the most current spice binaries from spice-space.org. To manage notifications about this bug go to: https://bugs.launchpad.net/qemu/+bug/818673/+subscriptions
Re: [Qemu-devel] [RFC Patch 3/7]Qemu: Cmd block_set_hostcache for dynamic cache change
Am 02.02.2012 01:09, schrieb Michael Roth: On 01/31/2012 09:06 PM, Supriya Kannery wrote: New command block_set_hostcache added for dynamically changing host pagecache setting of a block device. Usage: block_set_hostcachedevice option device = block device option = on/off Example: (qemu) block_set_hostcache ide0-hd0 off Signed-off-by: Supriya Kannerysupri...@linux.vnet.ibm.com --- block.c | 54 ++ block.h |2 ++ blockdev.c | 26 ++ blockdev.h |2 ++ hmp-commands.hx | 14 ++ qmp-commands.hx | 27 +++ 6 files changed, 125 insertions(+) Index: qemu/block.c === --- qemu.orig/block.c +++ qemu/block.c @@ -808,6 +808,35 @@ unlink_and_fail: return ret; } +int bdrv_reopen(BlockDriverState *bs, int bdrv_flags) +{ +BlockDriver *drv = bs-drv; +int ret = 0, open_flags; + +/* Quiesce IO for the given block device */ +qemu_aio_flush(); +ret = bdrv_flush(bs); +if (ret != 0) { +qerror_report(QERR_DATA_SYNC_FAILED, bs-device_name); +return ret; +} +open_flags = bs-open_flags; +bdrv_close(bs); + +ret = bdrv_open(bs, bs-filename, bdrv_flags, drv); +if (ret 0) { +/* Reopen failed. Try to open with original flags */ +qerror_report(QERR_REOPEN_FILE_FAILED, bs-filename); +ret = bdrv_open(bs, bs-filename, open_flags, drv); +if (ret 0) { +/* Reopen failed with orig and modified flags */ +abort(); +} +} + +return ret; +} + void bdrv_close(BlockDriverState *bs) { if (bs-drv) { @@ -870,6 +899,33 @@ void bdrv_drain_all(void) } } +int bdrv_change_hostcache(BlockDriverState *bs, bool enable_host_cache) +{ +int bdrv_flags = bs-open_flags; + +/* set hostcache flags (without changing WCE/flush bits) */ +if (enable_host_cache) { +bdrv_flags= ~BDRV_O_NOCACHE; +} else { +bdrv_flags |= BDRV_O_NOCACHE; +} + +/* If no change in flags, no need to reopen */ +if (bdrv_flags == bs-open_flags) { +return 0; +} + +if (bdrv_is_inserted(bs)) { +/* Reopen file with changed set of flags */ +bdrv_flags= ~BDRV_O_CACHE_WB; +return bdrv_reopen(bs, bdrv_flags); It seems like the real interface we're wanting here is bdrv_set_flags(), or something along that line, with the re-opening being more of an implementation detail. For instance, with raw-posix.c:raw_reopen_prepare() we'll end up skipping the re-opening completely if fcntl() is sufficient. It's reopening a BlockDriverState, not necessarily reopening the image file that backs it. bdrv_set_flags() would be good name for what this series is doing, but I've been thinking about adding a way to actually switch the image file as well. We could need this for implementing external snapshots of multiple images atomically. Kevin
Re: [Qemu-devel] [PULL 00/21] ppc patch queue 2012-02-02
Am 02.02.2012 02:49, schrieb Alexander Graf: kvm-all.c|4 + linux-headers/asm-powerpc/kvm.h | 11 +-- linux-headers/asm-powerpc/kvm_para.h | 41 - linux-headers/asm-s390/kvm.h |9 ++ linux-headers/asm-x86/hyperv.h |1 + linux-headers/asm-x86/kvm.h |4 + linux-headers/linux/kvm.h| 78 + linux-headers/linux/kvm_para.h |1 - linux-headers/linux/virtio_ring.h|6 +- target-ppc/cpu.h | 59 - target-ppc/helper.c | 32 ++- target-ppc/helper.h |5 + target-ppc/kvm.c | 10 ++- target-ppc/op_helper.c | 159 +- target-ppc/translate.c | 75 +++- target-ppc/translate_init.c | 48 ++ 16 files changed, 462 insertions(+), 81 deletions(-) Doesn't touch devices, so should be unproblematic to rebase upon. Andreas -- SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
Re: [Qemu-devel] [PATCH] e1000: bounds packet size against buffer size
On Mon, 23 Jan 2012, Anthony Liguori wrote: Otherwise we can write beyond the buffer and corrupt memory. This is tracked as CVE-2012-0029. The stable-1.0 branch looks vulnerable too, shouldn't this patch be backported? Signed-off-by: Anthony Liguori aligu...@us.ibm.com --- hw/e1000.c |3 +++ 1 files changed, 3 insertions(+), 0 deletions(-) diff --git a/hw/e1000.c b/hw/e1000.c index a29c944..86c5416 100644 --- a/hw/e1000.c +++ b/hw/e1000.c @@ -466,6 +466,8 @@ process_tx_desc(E1000State *s, struct e1000_tx_desc *dp) bytes = split_size; if (tp-size + bytes msh) bytes = msh - tp-size; + +bytes = MIN(sizeof(tp-data) - tp-size, bytes); pci_dma_read(s-dev, addr, tp-data + tp-size, bytes); if ((sz = tp-size + bytes) = hdr tp-size hdr) memmove(tp-header, tp-data, hdr); @@ -481,6 +483,7 @@ process_tx_desc(E1000State *s, struct e1000_tx_desc *dp) // context descriptor TSE is not set, while data descriptor TSE is set DBGOUT(TXERR, TCP segmentaion Error\n); } else { +split_size = MIN(sizeof(tp-data) - tp-size, split_size); pci_dma_read(s-dev, addr, tp-data + tp-size, split_size); tp-size += split_size; } -- 1.7.4.1
[Qemu-devel] [Bug 925405] [NEW] VNC server does not work with Mac Screen Sharing
Public bug reported: When connecting to a QEMU instance from a Mac using any VNC settings on the QEMU CLI and any target arch (ARM, Intel, etc.), the connection is attempted but the negotiation never finishes. I've verified this when building QEMU from source (1.0 and HEAD) on Ubuntu, Fedora and Debian or when using Ubuntu (Oneiric) and Debian (Lenny) packages. It does not matter whether I specify authentication (or anything else) on QEMU's side, the behavior is always the same - I see the connection being established using netstat and tcpdump, but QEMU does not seem to send back any pixmap data after the connection setup. Best guess as to why this happens is that the VNC negotiation on QEMU does not like the protocol version and VNC encoding sent by the Mac's built-in VNC client, or that its negotiation logic is subtly broken. I appreciate that it's not meant to be a full VNC server, but it prevents me from using it remotely until a stable Mac build is feasible. Background info: Mac OS X includes a VNC client called Screen Sharing that you can invoke in two different ways: * At a terminal, by typing open vnc://hostname:tcp_port * From any URI-enabled field (such as the Safari URI field), where you can just type the URI as vnc://hostname:tcp_port Please do not confuse the enhanced VNC protocol Apple Remote Desktop uses with Screen Sharing - they are not mutually exclusive, but they are not incompatible either, since what Apple does is to negotiate extra pixmap encoding and authentication options - I use Screen Sharing to access many VNC servers such as vnc4server, tightvncserver, vino, etc. without any issues whatsoever, so the issue I'm reporting is not an issue with Apple's implementation. ** Affects: qemu Importance: Undecided Status: New -- You received this bug notification because you are a member of qemu- devel-ml, which is subscribed to QEMU. https://bugs.launchpad.net/bugs/925405 Title: VNC server does not work with Mac Screen Sharing Status in QEMU: New Bug description: When connecting to a QEMU instance from a Mac using any VNC settings on the QEMU CLI and any target arch (ARM, Intel, etc.), the connection is attempted but the negotiation never finishes. I've verified this when building QEMU from source (1.0 and HEAD) on Ubuntu, Fedora and Debian or when using Ubuntu (Oneiric) and Debian (Lenny) packages. It does not matter whether I specify authentication (or anything else) on QEMU's side, the behavior is always the same - I see the connection being established using netstat and tcpdump, but QEMU does not seem to send back any pixmap data after the connection setup. Best guess as to why this happens is that the VNC negotiation on QEMU does not like the protocol version and VNC encoding sent by the Mac's built-in VNC client, or that its negotiation logic is subtly broken. I appreciate that it's not meant to be a full VNC server, but it prevents me from using it remotely until a stable Mac build is feasible. Background info: Mac OS X includes a VNC client called Screen Sharing that you can invoke in two different ways: * At a terminal, by typing open vnc://hostname:tcp_port * From any URI-enabled field (such as the Safari URI field), where you can just type the URI as vnc://hostname:tcp_port Please do not confuse the enhanced VNC protocol Apple Remote Desktop uses with Screen Sharing - they are not mutually exclusive, but they are not incompatible either, since what Apple does is to negotiate extra pixmap encoding and authentication options - I use Screen Sharing to access many VNC servers such as vnc4server, tightvncserver, vino, etc. without any issues whatsoever, so the issue I'm reporting is not an issue with Apple's implementation. To manage notifications about this bug go to: https://bugs.launchpad.net/qemu/+bug/925405/+subscriptions
[Qemu-devel] [Bug 925412] [NEW] Cannot build on Mac using Xcode 4 and LLVM
Public bug reported: As detailed in the mailing-list and the brew project (see below), QEMU currently either doesn't build with LLVM or builds and crashes upon runtime on Mac OS X Lion (or Snow Leopard if you've upgraded your compiler from gcc-4.2). This seems to be tied to the internal representation of UINT16, but effectively means that you currently cannot run QEMU 1.0 or HEAD (for any target arch - I'm focusing on ARM and Intel) on a Mac. References: [1]: http://lists.gnu.org/archive/html/qemu-devel/2012-01/msg01330.html [2]: https://github.com/mxcl/homebrew/pull/9520 ** Affects: qemu Importance: Undecided Status: New -- You received this bug notification because you are a member of qemu- devel-ml, which is subscribed to QEMU. https://bugs.launchpad.net/bugs/925412 Title: Cannot build on Mac using Xcode 4 and LLVM Status in QEMU: New Bug description: As detailed in the mailing-list and the brew project (see below), QEMU currently either doesn't build with LLVM or builds and crashes upon runtime on Mac OS X Lion (or Snow Leopard if you've upgraded your compiler from gcc-4.2). This seems to be tied to the internal representation of UINT16, but effectively means that you currently cannot run QEMU 1.0 or HEAD (for any target arch - I'm focusing on ARM and Intel) on a Mac. References: [1]: http://lists.gnu.org/archive/html/qemu-devel/2012-01/msg01330.html [2]: https://github.com/mxcl/homebrew/pull/9520 To manage notifications about this bug go to: https://bugs.launchpad.net/qemu/+bug/925412/+subscriptions
Re: [Qemu-devel] general protection fault
Dyweni, On 17.01.12 23:22:29, Dyweni - KVM wrote: I'm getting a very similar error when running oprofile on the host...same version of oprofile... general protection fault: [#1] PREEMPT SMP CPU 5 Modules linked in: iscsi_tcp libiscsi_tcp libiscsi scsi_transport_iscsi vboxnetadp vboxnetflt vboxdrv nvidia(P) Pid: 1498, comm: oprofiled Tainted: P 3.1.6-gentoo-20120114-0749 #1 MSI MS-7578/NF750-G55 (MS-7578) RIP: 0010:[81093758] [81093758] raw_notifier_chain_register+0x18/0x40 RSP: 0018:88022ed4dbb8 EFLAGS: 00010206 RAX: 65526d6562574955 RBX: 8172b4b0 RCX: 81733ff8 RDX: RSI: 8172b4b0 RDI: 817ae968 RBP: 88022ed4dbb8 R08: 81734ef0 R09: R10: 3000 R11: 1600 R12: 81734ef0 R13: e160 R14: 8172b520 R15: 0005 FS: 7f7179020700() GS:88033fd4() knlGS:f75a36c0 CS: 0010 DS: ES: CR0: 80050033 CR2: 0062a000 CR3: 000327cd8000 CR4: 06e0 DR0: 0001 DR1: 0002 DR2: 0001 DR3: 000a DR6: 0ff0 DR7: 0400 Process oprofiled (pid: 1498, threadinfo 88022ed4c000, task 880331635eb0) Stack: 88022ed4dbe8 814fa020 88022ed4dbe8 81093dc0 e160 88022ed4dc48 81470325 88032a5724a8 0005 88033fd4 0008810f95d0 Call Trace: [814fa020] register_cpu_notifier+0x20/0x40 [81093dc0] ? register_die_notifier+0x20/0x30 [81470325] nmi_setup+0x1d5/0x200 [8146e830] ? event_buffer_release+0x50/0x50 [8146d109] oprofile_setup+0x39/0xd0 [8146e890] event_buffer_open+0x60/0xa0 [81119de0] ? file_sb_list_add+0x50/0x60 [8111685e] __dentry_open.clone.17+0x12e/0x330 [81117a2e] nameidata_to_filp+0x4e/0x60 [81126ac2] do_last+0x1b2/0x8f0 [81127313] path_openat+0xd3/0x3c0 [81127714] do_filp_open+0x44/0xa0 [81133724] ? alloc_fd+0xe4/0x130 [81117b3c] do_sys_open+0xfc/0x1d0 [81117c2b] sys_open+0x1b/0x20 [8150763b] system_call_fastpath+0x16/0x1b Code: 5b 41 5c 41 5d 41 5e 41 5f c9 c3 31 c0 eb ed 0f 1f 40 00 55 48 8b 07 48 89 e5 48 85 c0 74 1e 8b 56 10 3b 50 10 7e 09 eb 14 66 90 50 10 7c 0d 48 8d 78 08 48 8b 40 08 48 85 c0 75 ee 48 89 46 RIP [81093758] raw_notifier_chain_register+0x18/0x40 RSP 88022ed4dbb8 ---[ end trace 8dcb6b8322e14541 ]--- I tried to create a similar setup but can't see which instruction could trigger the gp. If you have the object files available, could you send me the obj dump of raw_notifier_chain_register() of the host setup with something like: objdump -Sdl kernel/notifier.o Is there any special in your oprofile setup? On Tue, 17 Jan 2012 22:40:58 -0600, Dyweni - KVM wrote: I'm getting the following error from my guest kernel when running oprofile within qemu-kvm: general protection fault: [#1] Modules linked in: Pid: 896, comm: oprofiled Not tainted 3.2.0-rc7-20120117-0605 #1 Bochs Bochs EIP: 0060:[] EFLAGS: 00010086 CPU: 0 EIP is at nmi_cpu_setup.clone.6+0x2e/0xb0 EAX: EBX: df89894c ECX: c0010005 EDX: ESI: 0001 EDI: c168e5c0 EBP: df8addf4 ESP: df8adde4 DS: 007b ES: 007b FS: GS: 0033 SS: 0068 Process oprofiled (pid: 896, ti=df8ac000 task=df82f780 task.ti=df8ac000) Stack: df898980 0004 fff0 d4520880 df8ade08 c1406d4b c1618dfa df8ade14 c140464f dc792de0 df8ade28 c1405963 d4520880 dc792de0 df8ade4c cbfa c111c7fe df84c000 df8ade44 dc77ef80 df8adeec Call Trace: [] nmi_setup+0xab/0xd0 [] oprofile_setup+0x2f/0xb0 [] event_buffer_open+0x63/0x90 [] __dentry_open.clone.17+0x1aa/0x2d0 [] ? do_lookup+0x3e/0x370 [] nameidata_to_filp+0x52/0x70 [] ? event_buffer_release+0x40/0x40 [] do_last+0x1e6/0x740 [] path_openat+0x9a/0x320 [] ? page_add_new_anon_rmap+0x74/0x80 [] do_filp_open+0x30/0x80 [] ? alloc_fd+0x2c/0xd0 [] do_sys_open+0xeb/0x1c0 [] sys_open+0x29/0x40 [] sysenter_do_call+0x12/0x22 Code: 57 56 53 83 ec 04 a1 90 e5 68 c1 8b 3d 44 a5 78 c1 8b 1d 8c e5 68 c1 89 45 f0 8b 07 85 c0 74 1d 31 f6 8d 76 00 8b 0b 85 c9 74 08 32 89 43 04 89 53 08 83 c6 01 83 c3 0c 3b 37 72 e8 8b 77 04 EIP: [] nmi_cpu_setup.clone.6+0x2e/0xb0 SS:ESP 0068:df8adde4 ---[ end trace e22f1adcb9f592c1 ]--- Running oprofile in qemu-kvm guests is not supported, though an gp should not be triggered by the oprofile driver. Do you see anything in dmesg of the host when the guest gp triggers? Same here, could you send me the objdump of nmi_cpu_setup() and nmi_setup() (guest kernel)? objdump -Sdl arch/x86/oprofile/nmi_int.o Thanks, -Robert --
Re: [Qemu-devel] general protection fault
On 01/18/2012 06:40 AM, Dyweni - KVM wrote: Hi All, I'm not sure who this falls to, so I've included all all parties that I thought may be relevant. I'm getting the following error from my guest kernel when running oprofile within qemu-kvm: kvm does not virtualize a PMU before Linux 3.3, so oprofile is not supported. The facilities for identifying the PMU to the guest are very lacking, so it's hard to make this fail gracefully. On a Linux 3.3 host, you can provide a PMU to the guest, but only using latest qemu and providing -cpu host or similar. This only works on Intel hosts for now. -- error compiling committee.c: too many arguments to function
Re: [Qemu-devel] [vdsm] oVirt Live Snapshots
Can someone explain what is DB in this wiki page? See, Live snapshots operation extend regular snapshots as follow: * Create a locked snapshot in DB On 2012-1-30 19:00, Federico Simoncelli wrote: Hi, oVirt, and more specifically VDSM, is currently implementing the live snapshot feature using the API/commands provided by libvirt and qemu. It would be great if you could review the design and the current open issues at: http://ovirt.org/wiki/Live_Snapshots Thank you, -- Shu Mingshum...@linux.vnet.ibm.com IBM China Systems and Technology Laboratory
Re: [Qemu-devel] [vdsm] oVirt Live Snapshots
- Original Message - From: Shu Ming shum...@linux.vnet.ibm.com To: Federico Simoncelli fsimo...@redhat.com Cc: qemu-devel@nongnu.org, libvir-l...@redhat.com, VDSM Project Development vdsm-de...@lists.fedorahosted.org, Dave Allan dal...@redhat.com, Eric Blake ebl...@redhat.com Sent: Thursday, February 2, 2012 1:59:01 PM Subject: Re: [vdsm] oVirt Live Snapshots Can someone explain what is DB in this wiki page? It is the ovirt-engine database, where the VMs/images information and status is stored. That part of the wiki should be improved. See, Live snapshots operation extend regular snapshots as follow: • Create a locked snapshot in DB -- Federico
Re: [Qemu-devel] git bisect results: ec757c67c40a56492001487e69272f62144fd124 breaks windows boot in qemu-kvm
On February 1, 2012 at 11:05 PM Erik Rull erik.r...@rdsoftware.de wrote: Jan Kiszka wrote: On 2012-02-01 13:52, Erik Rull wrote: Hi all, first of all I'm a bit confused: What is the difference between qemu with command line option --enable-kvm and qemu-kvm? It seems to be a difference in code so far, from the performance point of view it seems to be the same... Now my issue that lead me to a git bisect on qemu-kvm: The following commit / merge breaks my windows guest boot sequence and causes resets infinitely: Cannot confirm yet, but I have no ACPI-free Windows installation at hand. Where does it reset, after the BIOS? ec757c67c40a56492001487e69272f62144fd124 Merge branch 'upstream-merge' into next Thu, 5 Jan 2012 11:00:07 + (13:00 +0200)Avi Kivitya...@redhat.com Interesting: qemu with --enable-kvm master and the same command line options as qemu-kvm runs perfect. My command line options are: qemu-system-x86_64 -serial /dev/ttyS2 -readconfig /etc/ich9-ehci-uhci.cfg -device usb-host,bus=ehci.0 -device usb-tablet -drive file=/dev/sda2,cache=off -m 1024 -net nic,macaddr=$MACADDR -net tap,script=/etc/qemu-ifup -no-acpi -monitor stdio -L /usr/X11R6/share/qemu -boot c -localtime Is the BIOS at /usr/X11R6/share/qemu in sync with the qemu version you try? Does leaving out options change the picture? Jan It happens directly after the windows boot progress bar is completed (I boot without logo) With the -no-kvm-irqchip it seems to be fine... Best regards, Erik Hi Jan, I tested with an ACPI-enabled windows. Results: -no-acpi: Continuous reboots like the no-acpi-windows-version without -no-acpi: boots! So I tested the no-acpi-windows-version without -no-acpi option - still rebooting And without -no-acpi and -no-kvm-irqchip = works again Best regards, Erik
Re: [Qemu-devel] git bisect results: ec757c67c40a56492001487e69272f62144fd124 breaks windows boot in qemu-kvm
On 2012-02-02 14:18, Erik Rull wrote: On February 1, 2012 at 11:05 PM Erik Rull erik.r...@rdsoftware.de wrote: Jan Kiszka wrote: On 2012-02-01 13:52, Erik Rull wrote: Hi all, first of all I'm a bit confused: What is the difference between qemu with command line option --enable-kvm and qemu-kvm? It seems to be a difference in code so far, from the performance point of view it seems to be the same... Now my issue that lead me to a git bisect on qemu-kvm: The following commit / merge breaks my windows guest boot sequence and causes resets infinitely: Cannot confirm yet, but I have no ACPI-free Windows installation at hand. Where does it reset, after the BIOS? ec757c67c40a56492001487e69272f62144fd124 Merge branch 'upstream-merge' into next Thu, 5 Jan 2012 11:00:07 + (13:00 +0200)Avi Kivitya...@redhat.com Interesting: qemu with --enable-kvm master and the same command line options as qemu-kvm runs perfect. My command line options are: qemu-system-x86_64 -serial /dev/ttyS2 -readconfig /etc/ich9-ehci-uhci.cfg -device usb-host,bus=ehci.0 -device usb-tablet -drive file=/dev/sda2,cache=off -m 1024 -net nic,macaddr=$MACADDR -net tap,script=/etc/qemu-ifup -no-acpi -monitor stdio -L /usr/X11R6/share/qemu -boot c -localtime Is the BIOS at /usr/X11R6/share/qemu in sync with the qemu version you try? Does leaving out options change the picture? Jan It happens directly after the windows boot progress bar is completed (I boot without logo) With the -no-kvm-irqchip it seems to be fine... Best regards, Erik Hi Jan, I tested with an ACPI-enabled windows. Results: -no-acpi: Continuous reboots like the no-acpi-windows-version without -no-acpi: boots! So I tested the no-acpi-windows-version without -no-acpi option - still rebooting And without -no-acpi and -no-kvm-irqchip = works again Interesting. Need to install such a version, I guess. What about no-acpi-windows and upstream qemu with kvm and -machine kernel_irqchip=on? Jan -- Siemens AG, Corporate Technology, CT T DE IT 1 Corporate Competence Center Embedded Linux
[Qemu-devel] [Bug 925405] Re: VNC server does not work with Mac Screen Sharing
** Also affects: ubuntu Importance: Undecided Status: New -- You received this bug notification because you are a member of qemu- devel-ml, which is subscribed to QEMU. https://bugs.launchpad.net/bugs/925405 Title: VNC server does not work with Mac Screen Sharing Status in QEMU: New Status in Ubuntu: New Bug description: When connecting to a QEMU instance from a Mac using any VNC settings on the QEMU CLI and any target arch (ARM, Intel, etc.), the connection is attempted but the negotiation never finishes. I've verified this when building QEMU from source (1.0 and HEAD) on Ubuntu, Fedora and Debian or when using Ubuntu (Oneiric) and Debian (Lenny) packages. It does not matter whether I specify authentication (or anything else) on QEMU's side, the behavior is always the same - I see the connection being established using netstat and tcpdump, but QEMU does not seem to send back any pixmap data after the connection setup. Best guess as to why this happens is that the VNC negotiation on QEMU does not like the protocol version and VNC encoding sent by the Mac's built-in VNC client, or that its negotiation logic is subtly broken. I appreciate that it's not meant to be a full VNC server, but it prevents me from using it remotely until a stable Mac build is feasible. Background info: Mac OS X includes a VNC client called Screen Sharing that you can invoke in two different ways: * At a terminal, by typing open vnc://hostname:tcp_port * From any URI-enabled field (such as the Safari URI field), where you can just type the URI as vnc://hostname:tcp_port Please do not confuse the enhanced VNC protocol Apple Remote Desktop uses with Screen Sharing - they are not mutually exclusive, but they are not incompatible either, since what Apple does is to negotiate extra pixmap encoding and authentication options - I use Screen Sharing to access many VNC servers such as vnc4server, tightvncserver, vino, etc. without any issues whatsoever, so the issue I'm reporting is not an issue with Apple's implementation. To manage notifications about this bug go to: https://bugs.launchpad.net/qemu/+bug/925405/+subscriptions
[Qemu-devel] [Bug 925412] Re: Cannot build on Mac using Xcode 4 and LLVM
** Also affects: ubuntu Importance: Undecided Status: New ** No longer affects: ubuntu -- You received this bug notification because you are a member of qemu- devel-ml, which is subscribed to QEMU. https://bugs.launchpad.net/bugs/925412 Title: Cannot build on Mac using Xcode 4 and LLVM Status in QEMU: New Bug description: As detailed in the mailing-list and the brew project (see below), QEMU currently either doesn't build with LLVM or builds and crashes upon runtime on Mac OS X Lion (or Snow Leopard if you've upgraded your compiler from gcc-4.2). This seems to be tied to the internal representation of UINT16, but effectively means that you currently cannot run QEMU 1.0 or HEAD (for any target arch - I'm focusing on ARM and Intel) on a Mac. References: [1]: http://lists.gnu.org/archive/html/qemu-devel/2012-01/msg01330.html [2]: https://github.com/mxcl/homebrew/pull/9520 To manage notifications about this bug go to: https://bugs.launchpad.net/qemu/+bug/925412/+subscriptions
[Qemu-devel] [PATCH] This patch is used to move some struct definition, like QEMUTimer, QEMUClock, from .c to .h.
Tested on i386 platform. Signed-off-by: Wei Yangweiy...@linux.vnet.ibm.com --- qemu-timer.c | 40 qemu-timer.h | 41 + 2 files changed, 41 insertions(+), 40 deletions(-) diff --git a/qemu-timer.c b/qemu-timer.c index cd026c6..2b5cc48 100644 --- a/qemu-timer.c +++ b/qemu-timer.c @@ -46,46 +46,6 @@ #include qemu-timer.h -/***/ -/* timers */ - -#define QEMU_CLOCK_REALTIME 0 -#define QEMU_CLOCK_VIRTUAL 1 -#define QEMU_CLOCK_HOST 2 - -struct QEMUClock { -int type; -int enabled; - -QEMUTimer *active_timers; - -NotifierList reset_notifiers; -int64_t last; -}; - -struct QEMUTimer { -QEMUClock *clock; -int64_t expire_time; /* in nanoseconds */ -int scale; -QEMUTimerCB *cb; -void *opaque; -struct QEMUTimer *next; -}; - -struct qemu_alarm_timer { -char const *name; -int (*start)(struct qemu_alarm_timer *t); -void (*stop)(struct qemu_alarm_timer *t); -void (*rearm)(struct qemu_alarm_timer *t, int64_t nearest_delta_ns); -#if defined(__linux__) -int fd; -timer_t timer; -#elif defined(_WIN32) -HANDLE timer; -#endif -char expired; -char pending; -}; static struct qemu_alarm_timer *alarm_timer; diff --git a/qemu-timer.h b/qemu-timer.h index 67ca72e..5bf2fc7 100644 --- a/qemu-timer.h +++ b/qemu-timer.h @@ -20,6 +20,47 @@ typedef struct QEMUClock QEMUClock; typedef void QEMUTimerCB(void *opaque); +/***/ +/* timers */ + +#define QEMU_CLOCK_REALTIME 0 +#define QEMU_CLOCK_VIRTUAL 1 +#define QEMU_CLOCK_HOST 2 + +struct QEMUClock { +int type; +int enabled; + +QEMUTimer *active_timers; + +NotifierList reset_notifiers; +int64_t last; +}; + +struct QEMUTimer { +QEMUClock *clock; +int64_t expire_time; /* in nanoseconds */ +int scale; +QEMUTimerCB *cb; +void *opaque; +struct QEMUTimer *next; +}; + +struct qemu_alarm_timer { +char const *name; +int (*start)(struct qemu_alarm_timer *t); +void (*stop)(struct qemu_alarm_timer *t); +void (*rearm)(struct qemu_alarm_timer *t, int64_t nearest_delta_ns); +#if defined(__linux__) +int fd; +timer_t timer; +#elif defined(_WIN32) +HANDLE timer; +#endif +char expired; +char pending; +}; + /* The real time clock should be used only for stuff which does not change the virtual machine state, as it is run even if the virtual machine is stopped. The real time clock has a frequency of 1000 -- 1.7.4.1
Re: [Qemu-devel] git bisect results: ec757c67c40a56492001487e69272f62144fd124 breaks windows boot in qemu-kvm
On February 2, 2012 at 2:21 PM Jan Kiszka jan.kis...@siemens.com wrote: On 2012-02-02 14:18, Erik Rull wrote: On February 1, 2012 at 11:05 PM Erik Rull erik.r...@rdsoftware.de wrote: Jan Kiszka wrote: On 2012-02-01 13:52, Erik Rull wrote: Hi all, first of all I'm a bit confused: What is the difference between qemu with command line option --enable-kvm and qemu-kvm? It seems to be a difference in code so far, from the performance point of view it seems to be the same... Now my issue that lead me to a git bisect on qemu-kvm: The following commit / merge breaks my windows guest boot sequence and causes resets infinitely: Cannot confirm yet, but I have no ACPI-free Windows installation at hand. Where does it reset, after the BIOS? ec757c67c40a56492001487e69272f62144fd124 Merge branch 'upstream-merge' into next Thu, 5 Jan 2012 11:00:07 + (13:00 +0200)Avi Kivitya...@redhat.com Interesting: qemu with --enable-kvm master and the same command line options as qemu-kvm runs perfect. My command line options are: qemu-system-x86_64 -serial /dev/ttyS2 -readconfig /etc/ich9-ehci-uhci.cfg -device usb-host,bus=ehci.0 -device usb-tablet -drive file=/dev/sda2,cache=off -m 1024 -net nic,macaddr=$MACADDR -net tap,script=/etc/qemu-ifup -no-acpi -monitor stdio -L /usr/X11R6/share/qemu -boot c -localtime Is the BIOS at /usr/X11R6/share/qemu in sync with the qemu version you try? Does leaving out options change the picture? Jan It happens directly after the windows boot progress bar is completed (I boot without logo) With the -no-kvm-irqchip it seems to be fine... Best regards, Erik Hi Jan, I tested with an ACPI-enabled windows. Results: -no-acpi: Continuous reboots like the no-acpi-windows-version without -no-acpi: boots! So I tested the no-acpi-windows-version without -no-acpi option - still rebooting And without -no-acpi and -no-kvm-irqchip = works again Interesting. Need to install such a version, I guess. What about no-acpi-windows and upstream qemu with kvm and -machine kernel_irqchip=on? Jan Boots with and without -no-acpi Best regards, Erik P.S. Too many options for me :-)
[Qemu-devel] [PATCH 2/2] Run pod2man with --utf8 option to enable utf8 in manpages
This option makes no difference for manpages which contains only ascii chars. But for manpages with actual UTF8 characters (qemu docs contains these), this change allows to see real characters instead of mojibakes or substitutes. Signed-off-By: Michael Tokarev m...@tls.msk.ru --- Makefile |9 + 1 files changed, 5 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index 2560b59..737cda2 100644 --- a/Makefile +++ b/Makefile @@ -337,28 +337,29 @@ QMP/qmp-commands.txt: $(SRC_PATH)/qmp-commands.hx qemu-img-cmds.texi: $(SRC_PATH)/qemu-img-cmds.hx $(call quiet-command,sh $(SRC_PATH)/scripts/hxtool -t $ $@, GEN $@) +POD2MAN = pod2man --utf8 qemu.1: qemu-doc.texi qemu-options.texi qemu-monitor.texi $(call quiet-command, \ perl -Ww -- $(SRC_PATH)/scripts/texi2pod.pl $ qemu.pod \ - pod2man --section=1 --center= --release= qemu.pod $@, \ + $(POD2MAN) --section=1 --center= --release= qemu.pod $@, \ GEN $@) qemu-img.1: qemu-img.texi qemu-img-cmds.texi $(call quiet-command, \ perl -Ww -- $(SRC_PATH)/scripts/texi2pod.pl $ qemu-img.pod \ - pod2man --section=1 --center= --release= qemu-img.pod $@, \ + $(POD2MAN) --section=1 --center= --release= qemu-img.pod $@, \ GEN $@) fsdev/virtfs-proxy-helper.1: fsdev/virtfs-proxy-helper.texi $(call quiet-command, \ perl -Ww -- $(SRC_PATH)/scripts/texi2pod.pl $ fsdev/virtfs-proxy-helper.pod \ - pod2man --section=1 --center= --release= fsdev/virtfs-proxy-helper.pod $@, \ + $(POD2MAN) --section=1 --center= --release= fsdev/virtfs-proxy-helper.pod $@, \ GEN $@) qemu-nbd.8: qemu-nbd.texi $(call quiet-command, \ perl -Ww -- $(SRC_PATH)/scripts/texi2pod.pl $ qemu-nbd.pod \ - pod2man --section=8 --center= --release= qemu-nbd.pod $@, \ + $(POD2MAN) --section=8 --center= --release= qemu-nbd.pod $@, \ GEN $@) dvi: qemu-doc.dvi qemu-tech.dvi -- 1.7.2.5
[Qemu-devel] [PATCH 1/2] Support @documentencoding in scripts/texi2pod.pl
Currently our texi2pod ignores @documentencoding even if it is set properly in *.texi files. This results in a mojibake in documents generated from qemu.pod (which is generated from qemu-doc.texi by texi2pod), because the rest of the tools assumes ASCII encoding. This patch recognizes first @documentencoding in input and places it at the beginning of output as =encoding directive. Signed-Off-By: Michael Tokarev m...@tls.msk.ru --- scripts/texi2pod.pl |9 + 1 files changed, 9 insertions(+), 0 deletions(-) diff --git a/scripts/texi2pod.pl b/scripts/texi2pod.pl index 9ed056a..94097fb 100755 --- a/scripts/texi2pod.pl +++ b/scripts/texi2pod.pl @@ -36,6 +36,7 @@ $fnno = 1; $inf = ; $ibase = ; @ipath = (); +$encoding = undef; while ($_ = shift) { if (/^-D(.*)$/) { @@ -97,6 +98,12 @@ while($inf) { /^\@setfilename\s+([^.]+)/ and $fn = $1, next; /^\@settitle\s+([^.]+)/ and $tl = postprocess($1), next; +# Look for document encoding +/^\@documentencoding\s+([^.]+)/ and do { +$encoding = $1 unless defined $encoding; +next; +}; + # Identify a man title but keep only the one we are interested in. /^\@c\s+man\s+title\s+([A-Za-z0-9-]+)\s+(.+)/ and do { if (exists $defs{$1}) { @@ -336,6 +343,8 @@ $inf = pop @instack; die No filename or title\n unless defined $fn defined $tl; +print =encoding $encoding\n\n if defined $encoding; + $sects{NAME} = $fn \- $tl\n; $sects{FOOTNOTES} .= =back\n if exists $sects{FOOTNOTES}; -- 1.7.2.5
Re: [Qemu-devel] git bisect results: ec757c67c40a56492001487e69272f62144fd124 breaks windows boot in qemu-kvm
On 2012-02-02 15:07, Erik Rull wrote: On February 2, 2012 at 2:21 PM Jan Kiszka jan.kis...@siemens.com wrote: On 2012-02-02 14:18, Erik Rull wrote: On February 1, 2012 at 11:05 PM Erik Rull erik.r...@rdsoftware.de wrote: Jan Kiszka wrote: On 2012-02-01 13:52, Erik Rull wrote: Hi all, first of all I'm a bit confused: What is the difference between qemu with command line option --enable-kvm and qemu-kvm? It seems to be a difference in code so far, from the performance point of view it seems to be the same... Now my issue that lead me to a git bisect on qemu-kvm: The following commit / merge breaks my windows guest boot sequence and causes resets infinitely: Cannot confirm yet, but I have no ACPI-free Windows installation at hand. Where does it reset, after the BIOS? ec757c67c40a56492001487e69272f62144fd124 Merge branch 'upstream-merge' into next Thu, 5 Jan 2012 11:00:07 + (13:00 +0200)Avi Kivitya...@redhat.com Interesting: qemu with --enable-kvm master and the same command line options as qemu-kvm runs perfect. My command line options are: qemu-system-x86_64 -serial /dev/ttyS2 -readconfig /etc/ich9-ehci-uhci.cfg -device usb-host,bus=ehci.0 -device usb-tablet -drive file=/dev/sda2,cache=off -m 1024 -net nic,macaddr=$MACADDR -net tap,script=/etc/qemu-ifup -no-acpi -monitor stdio -L /usr/X11R6/share/qemu -boot c -localtime Is the BIOS at /usr/X11R6/share/qemu in sync with the qemu version you try? Does leaving out options change the picture? Jan It happens directly after the windows boot progress bar is completed (I boot without logo) With the -no-kvm-irqchip it seems to be fine... Best regards, Erik Hi Jan, I tested with an ACPI-enabled windows. Results: -no-acpi: Continuous reboots like the no-acpi-windows-version without -no-acpi: boots! So I tested the no-acpi-windows-version without -no-acpi option - still rebooting And without -no-acpi and -no-kvm-irqchip = works again Interesting. Need to install such a version, I guess. What about no-acpi-windows and upstream qemu with kvm and -machine kernel_irqchip=on? Jan Boots with and without -no-acpi Ok... Either I fixed something magically, or the feature gap makes the difference. In any case, need to reproduce. Best regards, Erik P.S. Too many options for me :-) Not just for you. :) Jan -- Siemens AG, Corporate Technology, CT T DE IT 1 Corporate Competence Center Embedded Linux
Re: [Qemu-devel] [PATCH 2/2] Run pod2man with --utf8 option to enable utf8 in manpages
On 2 February 2012 14:16, Michael Tokarev m...@tls.msk.ru wrote: +POD2MAN = pod2man --utf8 qemu.1: qemu-doc.texi qemu-options.texi qemu-monitor.texi $(call quiet-command, \ perl -Ww -- $(SRC_PATH)/scripts/texi2pod.pl $ qemu.pod \ - pod2man --section=1 --center= --release= qemu.pod $@, \ + $(POD2MAN) --section=1 --center= --release= qemu.pod $@, \ GEN $@) qemu-img.1: qemu-img.texi qemu-img-cmds.texi $(call quiet-command, \ perl -Ww -- $(SRC_PATH)/scripts/texi2pod.pl $ qemu-img.pod \ - pod2man --section=1 --center= --release= qemu-img.pod $@, \ + $(POD2MAN) --section=1 --center= --release= qemu-img.pod $@, \ GEN $@) fsdev/virtfs-proxy-helper.1: fsdev/virtfs-proxy-helper.texi $(call quiet-command, \ perl -Ww -- $(SRC_PATH)/scripts/texi2pod.pl $ fsdev/virtfs-proxy-helper.pod \ - pod2man --section=1 --center= --release= fsdev/virtfs-proxy-helper.pod $@, \ + $(POD2MAN) --section=1 --center= --release= fsdev/virtfs-proxy-helper.pod $@, \ GEN $@) qemu-nbd.8: qemu-nbd.texi $(call quiet-command, \ perl -Ww -- $(SRC_PATH)/scripts/texi2pod.pl $ qemu-nbd.pod \ - pod2man --section=8 --center= --release= qemu-nbd.pod $@, \ + $(POD2MAN) --section=8 --center= --release= qemu-nbd.pod $@, \ GEN $@) So why does '--utf8' qualify as a common option that we specify just once in the POD2MAN variable, but --center= and --release= don't? Maybe we could reduce the duplication here with a makefile function? -- PMM
Re: [Qemu-devel] [PATCH 2/2] Run pod2man with --utf8 option to enable utf8 in manpages
On 02.02.2012 18:32, Peter Maydell wrote: On 2 February 2012 14:16, Michael Tokarev m...@tls.msk.ru wrote: +POD2MAN = pod2man --utf8 qemu.1: qemu-doc.texi qemu-options.texi qemu-monitor.texi $(call quiet-command, \ perl -Ww -- $(SRC_PATH)/scripts/texi2pod.pl $ qemu.pod \ - pod2man --section=1 --center= --release= qemu.pod $@, \ + $(POD2MAN) --section=1 --center= --release= qemu.pod $@, \ [] So why does '--utf8' qualify as a common option that we specify just once in the POD2MAN variable, but --center= and --release= don't? Maybe --release is ok here, but I don't think --center is. Because, well, --release is the same for every manpage (it corresponds to qemu release number of something of this kind), but --center may actually be used one day with different values for different manpages. Besides, this is a task for another patch, since this one only thing this patch does is addresses the --utf8 issue. Maybe it is so trivial that adding --release here actually does fit nicely too. I don't care either way, what matters is to fix the mojibake which currently exists in qemu.1 manpage. Maybe we could reduce the duplication here with a makefile function? I'm not sure it is worth the extra complexity. The way it is now is more visible than a function. Just IMHO anyway. Thanks, /mjt
Re: [Qemu-devel] [PATCH 2/2] Run pod2man with --utf8 option to enable utf8 in manpages
On 2 February 2012 14:46, Michael Tokarev m...@tls.msk.ru wrote: Besides, this is a task for another patch, since this one only thing this patch does is addresses the --utf8 issue. Maybe it is so trivial that adding --release here actually does fit nicely too. I don't care either way, what matters is to fix the mojibake which currently exists in qemu.1 manpage. If you don't care about fixing the duplication (which I understand) you could just add --utf8 to all the pod2man command lines. -- PMM
Re: [Qemu-devel] [PATCH 2/2] Run pod2man with --utf8 option to enable utf8 in manpages
On 02.02.2012 18:49, Peter Maydell wrote: On 2 February 2012 14:46, Michael Tokarev m...@tls.msk.ru wrote: Besides, this is a task for another patch, since this one only thing this patch does is addresses the --utf8 issue. Maybe it is so trivial that adding --release here actually does fit nicely too. I don't care either way, what matters is to fix the mojibake which currently exists in qemu.1 manpage. If you don't care about fixing the duplication (which I understand) you could just add --utf8 to all the pod2man command lines. The good side-effect of doing it like this is an ability to override POD2MAN on command line, just in case --utf8 does not work somehow. Thanks, /mjt
Re: [Qemu-devel] [PATCH] e1000: bounds packet size against buffer size
On 02.02.2012 15:15, Stefano Stabellini wrote: On Mon, 23 Jan 2012, Anthony Liguori wrote: Otherwise we can write beyond the buffer and corrupt memory. This is tracked as CVE-2012-0029. The stable-1.0 branch looks vulnerable too, shouldn't this patch be backported? This goes on since forever - for example, this patch applies to 0.12 too (modulo pci_dma_read() changes which makes the context differ). It applies cleanly to 1.0 stable. /mjt Signed-off-by: Anthony Liguori aligu...@us.ibm.com --- hw/e1000.c |3 +++ 1 files changed, 3 insertions(+), 0 deletions(-) diff --git a/hw/e1000.c b/hw/e1000.c index a29c944..86c5416 100644 --- a/hw/e1000.c +++ b/hw/e1000.c @@ -466,6 +466,8 @@ process_tx_desc(E1000State *s, struct e1000_tx_desc *dp) bytes = split_size; if (tp-size + bytes msh) bytes = msh - tp-size; + +bytes = MIN(sizeof(tp-data) - tp-size, bytes); pci_dma_read(s-dev, addr, tp-data + tp-size, bytes); if ((sz = tp-size + bytes) = hdr tp-size hdr) memmove(tp-header, tp-data, hdr); @@ -481,6 +483,7 @@ process_tx_desc(E1000State *s, struct e1000_tx_desc *dp) // context descriptor TSE is not set, while data descriptor TSE is set DBGOUT(TXERR, TCP segmentaion Error\n); } else { +split_size = MIN(sizeof(tp-data) - tp-size, split_size); pci_dma_read(s-dev, addr, tp-data + tp-size, split_size); tp-size += split_size; } -- 1.7.4.1
Re: [Qemu-devel] [PATCH] e1000: bounds packet size against buffer size
Am 02.02.2012 16:24, schrieb Michael Tokarev: On 02.02.2012 15:15, Stefano Stabellini wrote: On Mon, 23 Jan 2012, Anthony Liguori wrote: Otherwise we can write beyond the buffer and corrupt memory. This is tracked as CVE-2012-0029. The stable-1.0 branch looks vulnerable too, shouldn't this patch be backported? This goes on since forever - for example, this patch applies to 0.12 too (modulo pci_dma_read() changes which makes the context differ). It applies cleanly to 1.0 stable. Therefore we should cc qemu-stable. :) Andreas Signed-off-by: Anthony Liguori aligu...@us.ibm.com --- hw/e1000.c |3 +++ 1 files changed, 3 insertions(+), 0 deletions(-) diff --git a/hw/e1000.c b/hw/e1000.c index a29c944..86c5416 100644 --- a/hw/e1000.c +++ b/hw/e1000.c @@ -466,6 +466,8 @@ process_tx_desc(E1000State *s, struct e1000_tx_desc *dp) bytes = split_size; if (tp-size + bytes msh) bytes = msh - tp-size; + +bytes = MIN(sizeof(tp-data) - tp-size, bytes); pci_dma_read(s-dev, addr, tp-data + tp-size, bytes); if ((sz = tp-size + bytes) = hdr tp-size hdr) memmove(tp-header, tp-data, hdr); @@ -481,6 +483,7 @@ process_tx_desc(E1000State *s, struct e1000_tx_desc *dp) // context descriptor TSE is not set, while data descriptor TSE is set DBGOUT(TXERR, TCP segmentaion Error\n); } else { +split_size = MIN(sizeof(tp-data) - tp-size, split_size); pci_dma_read(s-dev, addr, tp-data + tp-size, split_size); tp-size += split_size; } -- 1.7.4.1 -- SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
Re: [Qemu-devel] building qemu on Oracle Solaris 11 x64
Solaris can be a bit tricky since it supports 32 and 64-bit applications. Oracle Solaris 11 disabled 32-bit boot but still supports 32-bit applications. Are the rest of the libraries in the generated Makefile 32-bit or 64-bit? On Solaris, it's fairly easy to tell since the 64-bit libraries are /lib/64 (or various links to 64 such as amd64 - 64 or sparcv9 - 64). 2012/1/31 Günther Schmidt gue.schm...@web.de: Hi everyone, I'm trying to build qemu on Oracle Solars 11 x64. I've figure out that I need to set the --disable-guest-agent for ./configure, but there are other errors I do not know how to fix. Setting LD_LIBRARY_PATH to /usr/lib/mps/amd64 helps but at least one error still remains: ld: fatal: file cac.o: wrong ELF class: ELFCLASS64 ld: fatal: file processing errors. No output written to vscclient collect2: ld returned 1 exit status Has anyone here successfully build qemu on Oracle Solaris 11 x64? Günther
[Qemu-devel] Is there any document about qemu's kernel boot loader?
Hi, recently I am focusing on KVM(kernel virtualization machine), in which the device simulation employ the Qemu’s code directly. Still, the Qemu can run the Guest OS alone, from kernel boot to device simulation. Device simulation is somehow easy to comprehend. As for kernel boot, is there any detailed document? I need some to make it clearer. Thanks in advance.
[Qemu-devel] Question about IDE TRIM Command
Hi all I have a question about IDE TRIM Command. As you know, QEMU have supported TRIM command since QEMU 0.15.0. Some QEMU disk images such as qcow2 support bdrv_discard function which will be called when guest OS executes ATA TRIM command. So, I think qcow2 image has a function to delete the disk pages which are recognized as discarded by guest OS. I think that to enable TRIM Command, we have to emulate guest HDD as Solid State Drive. However, it seems QEMU does not emulate guest HDD as Solid State Drive. Thus, I think that bdrv_discard functions in qemu images are never called by guest OS. Is my thinking correct? Thanks, Kazushi Takahashi
[Qemu-devel] Question about IDE TRIM Command
Hi all I have a question about IDE TRIM Command. As you know, QEMU have supported TRIM command since QEMU 0.15.0. Some QEMU disk images such as qcow2 support bdrv_discard function which will be called when guest OS executes ATA TRIM command. So, I think qcow2 image has a function to delete the disk pages which are recognized as discarded by guest OS. I think that to enable TRIM Command, we have to emulate guest HDD as Solid State Drive. However, it seems QEMU does not emulate guest HDD as Solid State Drive. Thus, I think that bdrv_discard functions in qemu images are never called by guest OS. Is my thinking correct? Thanks, Kazushi Takahashi
[Qemu-devel] [RFC] Next gen kvm api
The kvm api has been accumulating cruft for several years now. This is due to feature creep, fixing mistakes, experience gained by the maintainers and developers on how to do things, ports to new architectures, and simply as a side effect of a code base that is developed slowly and incrementally. While I don't think we can justify a complete revamp of the API now, I'm writing this as a thought experiment to see where a from-scratch API can take us. Of course, if we do implement this, the new and old APIs will have to be supported side by side for several years. Syscalls kvm currently uses the much-loved ioctl() system call as its entry point. While this made it easy to add kvm to the kernel unintrusively, it does have downsides: - overhead in the entry path, for the ioctl dispatch path and vcpu mutex (low but measurable) - semantic mismatch: kvm really wants a vcpu to be tied to a thread, and a vm to be tied to an mm_struct, but the current API ties them to file descriptors, which can move between threads and processes. We check that they don't, but we don't want to. Moving to syscalls avoids these problems, but introduces new ones: - adding new syscalls is generally frowned upon, and kvm will need several - syscalls into modules are harder and rarer than into core kernel code - will need to add a vcpu pointer to task_struct, and a kvm pointer to mm_struct Syscalls that operate on the entire guest will pick it up implicitly from the mm_struct, and syscalls that operate on a vcpu will pick it up from current. State accessors --- Currently vcpu state is read and written by a bunch of ioctls that access register sets that were added (or discovered) along the years. Some state is stored in the vcpu mmap area. These will be replaced by a pair of syscalls that read or write the entire state, or a subset of the state, in a tag/value format. A register will be described by a tuple: set: the register set to which it belongs; either a real set (GPR, x87, SSE/AVX, segment, cpuid, MSRs) or a fake set (for eflags/rip/IDT/interrupt shadow/pending exception/etc.) number: register number within a set size: for self-description, and to allow expanding registers like SSE-AVX or eax-rax attributes: read-write, read-only, read-only for guest but read-write for host value Device model Currently kvm virtualizes or emulates a set of x86 cores, with or without local APICs, a 24-input IOAPIC, a PIC, a PIT, and a number of PCI devices assigned from the host. The API allows emulating the local APICs in userspace. The new API will do away with the IOAPIC/PIC/PIT emulation and defer them to userspace. Note: this may cause a regression for older guests that don't support MSI or kvmclock. Device assignment will be done using VFIO, that is, without direct kvm involvement. Local APICs will be mandatory, but it will be possible to hide them from the guest. This means that it will no longer be possible to emulate an APIC in userspace, but it will be possible to virtualize an APIC-less core - userspace will play with the LINT0/LINT1 inputs (configured as EXITINT and NMI) to queue interrupts and NMIs. The communications between the local APIC and the IOAPIC/PIC will be done over a socketpair, emulating the APIC bus protocol. Ioeventfd/irqfd --- As the ioeventfd/irqfd mechanism has been quite successful, it will be retained, and perhaps supplemented with a way to assign an mmio region to a socketpair carrying transactions. This allows a device model to be implemented out-of-process. The socketpair can also be used to implement a replacement for coalesced mmio, by not waiting for responses on write transactions when enabled. Synchronization of coalesced mmio will be implemented in the kernel, not userspace as now: when a non-coalesced mmio is needed, the kernel will first flush the coalesced mmio queue(s). Guest memory management --- Instead of managing each memory slot individually, a single API will be provided that replaces the entire guest physical memory map atomically. This matches the implementation (using RCU) and plugs holes in the current API, where you lose the dirty log in the window between the last call to KVM_GET_DIRTY_LOG and the call to KVM_SET_USER_MEMORY_REGION that removes the slot. Slot-based dirty logging will be replaced by range-based and work-based dirty logging; that is what pages are dirty in this range, which may be smaller than a slot and don't return more than N pages. We may want to place the log in user memory instead of kernel memory, to reduce pinned memory and increase flexibility. vcpu fd mmap area - Currently we mmap() a few pages of the vcpu fd for fast user/kernel communications. This will be replaced by a more orthodox pointer parameter to sys_kvm_enter_guest(), that will be accessed using get_user() and put_user(). This is slower than the current situation, but better for things
[Qemu-devel] [PATCH 00/16] access qdev properties via QOM
This series, on top of Anthony's qom-upstream.13, fixes several qdev bugs, and adds enough functionality to QOM, to the point that all property accesses go through QOM rather than poking into the structs. In particular, device initialization goes through the regular, non-legacy properties; command-line option goes through the legacy interface. However, one important change is that if the two are equivalent, the legacy interface will not be registered anymore. Patches 1 and 2 are bugfixes. Patches 3 to 5 add wrappers to access properties easily as QObjects, Objects or C types. Patches 6 switches command-line operation and info qtree to the QOM legacy properties. Patches 7 to 11 progressively remove functionality from the legacy properties when the normal ones are just as good. Patch 12 switches property free to the normal QOM way. Patches 13 to 15 switches device initialization to use the QOM non-legacy properties (except for PROP_PTR). Patch 16 finally switches default values to use the QOM non-legacy properties. Paolo Bonzini (16): qdev: fix hot-unplug qom: store object with correct type in interface links qom: do not include qdev header file qom: add QObject-based property get/set wrappers qom: add property get/set wrappers for C types qdev: remove direct calls to print/parse qdev: allow reusing get/set for legacy property qdev: remove parse method for string properties qdev: remove parse/print methods for mac properties qdev: make the non-legacy pci address property accept an integer qdev: remove parse/print methods for pointer properties qdev: let QOM free properties qdev: fix off-by-one qdev: access properties via QOM qdev: inline qdev_prop_set into qdev_prop_set_ptr qdev: initialize properties via QOM hw/qdev-addr.c|5 +- hw/qdev-monitor.c | 30 ++-- hw/qdev-properties.c | 387 ++--- hw/qdev.c | 32 +++-- hw/qdev.h | 14 +- include/qemu/object.h | 94 qmp.c | 17 +-- qom/object.c | 149 +-- vl.c |1 + 9 files changed, 487 insertions(+), 242 deletions(-) -- 1.7.7.6
[Qemu-devel] [PATCH 01/16] qdev: fix hot-unplug
The reference that is returned by qdev_device_add is never given back, so that device_del does not cause the refcount to go to zero (and thus does nothing). Signed-off-by: Paolo Bonzini pbonz...@redhat.com --- vl.c |1 + 1 files changed, 1 insertions(+), 0 deletions(-) diff --git a/vl.c b/vl.c index d88a18c..c63af69 100644 --- a/vl.c +++ b/vl.c @@ -1746,6 +1746,7 @@ static int device_init_func(QemuOpts *opts, void *opaque) dev = qdev_device_add(opts); if (!dev) return -1; +object_unref(OBJECT(dev)); return 0; } -- 1.7.7.6
[Qemu-devel] [PATCH 02/16] qom: store object with correct type in interface links
When a link property's type is an interface, the code expects the implementation object (not the parent object) to be stored in the variable. The parent object does not contain the right vtable. Signed-off-by: Paolo Bonzini pbonz...@redhat.com --- qom/object.c |3 ++- 1 files changed, 2 insertions(+), 1 deletions(-) diff --git a/qom/object.c b/qom/object.c index cd517f6..de6484d 100644 --- a/qom/object.c +++ b/qom/object.c @@ -749,7 +749,8 @@ static void object_set_link_property(Object *obj, Visitor *v, void *opaque, target_type = g_strdup(type[5]); target_type[strlen(target_type) - 2] = 0; -if (object_dynamic_cast(target, target_type)) { +target = object_dynamic_cast(target, target_type); +if (target) { object_ref(target); *child = target; } else { -- 1.7.7.6
[Qemu-devel] [PATCH 12/16] qdev: let QOM free properties
Drop the special free callback. Instead, register a regular release method in the non-legacy property. Signed-off-by: Paolo Bonzini pbonz...@redhat.com --- hw/qdev-properties.c | 19 --- hw/qdev.c|8 +--- hw/qdev.h|2 +- 3 files changed, 14 insertions(+), 15 deletions(-) diff --git a/hw/qdev-properties.c b/hw/qdev-properties.c index 627d335..7efcc78 100644 --- a/hw/qdev-properties.c +++ b/hw/qdev-properties.c @@ -510,9 +510,10 @@ PropertyInfo qdev_prop_hex64 = { /* --- string --- */ -static void free_string(DeviceState *dev, Property *prop) +static void release_string(Object *obj, const char *name, void *opaque) { -g_free(*(char **)qdev_get_prop_ptr(dev, prop)); +Property *prop = opaque; +g_free(*(char **)qdev_get_prop_ptr(DEVICE(obj), prop)); } static int print_string(DeviceState *dev, Property *prop, char *dest, size_t len) @@ -572,7 +573,7 @@ PropertyInfo qdev_prop_string = { .type = PROP_TYPE_STRING, .size = sizeof(char*), .print = print_string, -.free = free_string, +.release = release_string, .get = get_string, .set = set_string, }; @@ -592,8 +593,10 @@ static int parse_drive(DeviceState *dev, const char *str, void **ptr) return 0; } -static void free_drive(DeviceState *dev, Property *prop) +static void release_drive(Object *obj, const char *name, void *opaque) { +DeviceState *dev = DEVICE(obj); +Property *prop = opaque; BlockDriverState **ptr = qdev_get_prop_ptr(dev, prop); if (*ptr) { @@ -667,7 +670,7 @@ PropertyInfo qdev_prop_drive = { .size = sizeof(BlockDriverState *), .get = get_drive, .set = set_drive, -.free = free_drive, +.release = release_drive, }; /* --- character device --- */ @@ -686,8 +689,10 @@ static int parse_chr(DeviceState *dev, const char *str, void **ptr) return 0; } -static void free_chr(DeviceState *dev, Property *prop) +static void release_chr(Object *obj, const char *name, void *opaque) { +DeviceState *dev = DEVICE(obj); +Property *prop = opaque; CharDriverState **ptr = qdev_get_prop_ptr(dev, prop); if (*ptr) { @@ -721,7 +726,7 @@ PropertyInfo qdev_prop_chr = { .size = sizeof(CharDriverState*), .get = get_chr, .set = set_chr, -.free = free_chr, +.release = release_chr, }; /* --- netdev device --- */ diff --git a/hw/qdev.c b/hw/qdev.c index 660ee38..f719f14 100644 --- a/hw/qdev.c +++ b/hw/qdev.c @@ -595,7 +595,7 @@ void qdev_property_add_static(DeviceState *dev, Property *prop, object_property_add(OBJECT(dev), prop-name, prop-info-name, prop-info-get, prop-info-set, -NULL, +prop-info-release, prop, errp); } @@ -626,7 +626,6 @@ static void device_finalize(Object *obj) { DeviceState *dev = DEVICE(obj); BusState *bus; -Property *prop; DeviceClass *dc = DEVICE_GET_CLASS(dev); if (dev-state == DEV_STATE_INITIALIZED) { @@ -645,11 +644,6 @@ static void device_finalize(Object *obj) } } QTAILQ_REMOVE(dev-parent_bus-children, dev, sibling); -for (prop = qdev_get_props(dev); prop prop-name; prop++) { -if (prop-info-free) { -prop-info-free(dev, prop); -} -} } void device_reset(DeviceState *dev) diff --git a/hw/qdev.h b/hw/qdev.h index 1d9143f..dbd8928 100644 --- a/hw/qdev.h +++ b/hw/qdev.h @@ -143,9 +143,9 @@ struct PropertyInfo { int64_t max; int (*parse)(DeviceState *dev, Property *prop, const char *str); int (*print)(DeviceState *dev, Property *prop, char *dest, size_t len); -void (*free)(DeviceState *dev, Property *prop); ObjectPropertyAccessor *get; ObjectPropertyAccessor *set; +ObjectPropertyRelease *release; }; typedef struct GlobalProperty { -- 1.7.7.6
[Qemu-devel] [PATCH 07/16] qdev: allow reusing get/set for legacy property
In some cases, a legacy property does need a special print method but not a special parse method. In this case, we can reuse the get/set from the static (non-legacy) property. If neither parse nor print is needed, though, do not register the legacy property at all. The previous patch ensures that the right fallback will be used. Signed-off-by: Paolo Bonzini pbonz...@redhat.com --- hw/qdev-monitor.c|5 ++--- hw/qdev-properties.c |6 +++--- hw/qdev.c| 11 +++ 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/hw/qdev-monitor.c b/hw/qdev-monitor.c index 64505b4..e21bd50 100644 --- a/hw/qdev-monitor.c +++ b/hw/qdev-monitor.c @@ -489,8 +489,8 @@ static void qdev_print_props(Monitor *mon, DeviceState *dev, Property *props, { if (!props) return; -while (props-name) { -Error *err; +for (; props-name; props++) { +Error *err = NULL; char *value; char *legacy_name = g_strdup_printf(legacy-%s, props-name); if (object_property_get_type(OBJECT(dev), legacy_name, NULL)) { @@ -507,7 +507,6 @@ static void qdev_print_props(Monitor *mon, DeviceState *dev, Property *props, qdev_printf(%s-prop: %s = %s\n, prefix, props-name, value *value ? value : null); g_free(value); -props++; } } diff --git a/hw/qdev-properties.c b/hw/qdev-properties.c index 7c41140..16f9b22 100644 --- a/hw/qdev-properties.c +++ b/hw/qdev-properties.c @@ -1025,13 +1025,13 @@ void error_set_from_qdev_prop_error(Error **errp, int ret, DeviceState *dev, int qdev_prop_parse(DeviceState *dev, const char *name, const char *value) { char *legacy_name; -Error *err; +Error *err = NULL; legacy_name = g_strdup_printf(legacy-%s, name); if (object_property_get_type(OBJECT(dev), legacy_name, NULL)) { -object_property_set_str(OBJECT(dev), legacy_name, value, err); +object_property_set_str(OBJECT(dev), value, legacy_name, err); } else { -object_property_set_str(OBJECT(dev), name, value, err); +object_property_set_str(OBJECT(dev), value, name, err); } g_free(legacy_name); diff --git a/hw/qdev.c b/hw/qdev.c index a731e41..660ee38 100644 --- a/hw/qdev.c +++ b/hw/qdev.c @@ -550,21 +550,24 @@ static void qdev_set_legacy_property(Object *obj, Visitor *v, void *opaque, * Do not use this is new code! Properties added through this interface will * be given names and types in the legacy namespace. * - * Legacy properties are always processed as strings. The format of the string - * depends on the property type. + * Legacy properties are string versions of other OOM properties. The format + * of the string depends on the property type. */ void qdev_property_add_legacy(DeviceState *dev, Property *prop, Error **errp) { gchar *name, *type; +if (!prop-info-print !prop-info-parse) { +return; +} name = g_strdup_printf(legacy-%s, prop-name); type = g_strdup_printf(legacy%s, prop-info-legacy_name ?: prop-info-name); object_property_add(OBJECT(dev), name, type, -prop-info-print ? qdev_get_legacy_property : NULL, -prop-info-parse ? qdev_set_legacy_property : NULL, +prop-info-print ? qdev_get_legacy_property : prop-info-get, +prop-info-parse ? qdev_set_legacy_property : prop-info-set, NULL, prop, errp); -- 1.7.7.6
[Qemu-devel] [PATCH 14/16] qdev: access properties via QOM
Do not poke anymore in the struct when accessing qdev properties. Instead, ask the object to set the right value. Signed-off-by: Paolo Bonzini pbonz...@redhat.com --- hw/qdev-addr.c |5 +++- hw/qdev-properties.c | 67 ++--- hw/qdev.h|1 - 3 files changed, 50 insertions(+), 23 deletions(-) diff --git a/hw/qdev-addr.c b/hw/qdev-addr.c index 5976dcd..8daa733 100644 --- a/hw/qdev-addr.c +++ b/hw/qdev-addr.c @@ -71,5 +71,8 @@ PropertyInfo qdev_prop_taddr = { void qdev_prop_set_taddr(DeviceState *dev, const char *name, target_phys_addr_t value) { -qdev_prop_set(dev, name, value, PROP_TYPE_TADDR); +Error *errp = NULL; +object_property_set_int(OBJECT(dev), value, name, errp); +assert(!errp); + } diff --git a/hw/qdev-properties.c b/hw/qdev-properties.c index 30abae2..ab7f522 100644 --- a/hw/qdev-properties.c +++ b/hw/qdev-properties.c @@ -1065,7 +1065,7 @@ int qdev_prop_parse(DeviceState *dev, const char *name, const char *value) return 0; } -void qdev_prop_set(DeviceState *dev, const char *name, void *src, enum PropertyType type) +static void qdev_prop_set(DeviceState *dev, const char *name, void *src, enum PropertyType type) { Property *prop; @@ -1085,52 +1085,63 @@ void qdev_prop_set(DeviceState *dev, const char *name, void *src, enum PropertyT void qdev_prop_set_bit(DeviceState *dev, const char *name, bool value) { -qdev_prop_set(dev, name, value, PROP_TYPE_BIT); +Error *errp = NULL; +object_property_set_bool(OBJECT(dev), value, name, errp); +assert(!errp); } void qdev_prop_set_uint8(DeviceState *dev, const char *name, uint8_t value) { -qdev_prop_set(dev, name, value, PROP_TYPE_UINT8); +Error *errp = NULL; +object_property_set_int(OBJECT(dev), value, name, errp); +assert(!errp); } void qdev_prop_set_uint16(DeviceState *dev, const char *name, uint16_t value) { -qdev_prop_set(dev, name, value, PROP_TYPE_UINT16); +Error *errp = NULL; +object_property_set_int(OBJECT(dev), value, name, errp); +assert(!errp); } void qdev_prop_set_uint32(DeviceState *dev, const char *name, uint32_t value) { -qdev_prop_set(dev, name, value, PROP_TYPE_UINT32); +Error *errp = NULL; +object_property_set_int(OBJECT(dev), value, name, errp); +assert(!errp); } void qdev_prop_set_int32(DeviceState *dev, const char *name, int32_t value) { -qdev_prop_set(dev, name, value, PROP_TYPE_INT32); +Error *errp = NULL; +object_property_set_int(OBJECT(dev), value, name, errp); +assert(!errp); } void qdev_prop_set_uint64(DeviceState *dev, const char *name, uint64_t value) { -qdev_prop_set(dev, name, value, PROP_TYPE_UINT64); +Error *errp = NULL; +object_property_set_int(OBJECT(dev), value, name, errp); +assert(!errp); } void qdev_prop_set_string(DeviceState *dev, const char *name, char *value) { -qdev_prop_set(dev, name, value, PROP_TYPE_STRING); +Error *errp = NULL; +object_property_set_str(OBJECT(dev), value, name, errp); +assert(!errp); } int qdev_prop_set_drive(DeviceState *dev, const char *name, BlockDriverState *value) { -int res; - -res = bdrv_attach_dev(value, dev); -if (res 0) { -error_report(Can't attach drive %s to %s.%s: %s, - bdrv_get_device_name(value), - dev-id ? dev-id : object_get_typename(OBJECT(dev)), - name, strerror(-res)); +Error *errp = NULL; +object_property_set_str(OBJECT(dev), bdrv_get_device_name(value), +name, errp); +if (errp) { +qerror_report_err(errp); +error_free(errp); return -1; } -qdev_prop_set(dev, name, value, PROP_TYPE_DRIVE); return 0; } @@ -1142,22 +1153,36 @@ void qdev_prop_set_drive_nofail(DeviceState *dev, const char *name, BlockDriverS } void qdev_prop_set_chr(DeviceState *dev, const char *name, CharDriverState *value) { -qdev_prop_set(dev, name, value, PROP_TYPE_CHR); +Error *errp = NULL; +assert(value-label); +object_property_set_str(OBJECT(dev), value-label, name, errp); +assert(!errp); } void qdev_prop_set_netdev(DeviceState *dev, const char *name, VLANClientState *value) { -qdev_prop_set(dev, name, value, PROP_TYPE_NETDEV); +Error *errp = NULL; +assert(value-name); +object_property_set_str(OBJECT(dev), value-name, name, errp); +assert(!errp); } void qdev_prop_set_vlan(DeviceState *dev, const char *name, VLANState *value) { -qdev_prop_set(dev, name, value, PROP_TYPE_VLAN); +Error *errp = NULL; +object_property_set_int(OBJECT(dev), value ? value-id : -1, name, errp); +assert(!errp); } void qdev_prop_set_macaddr(DeviceState *dev, const char *name, uint8_t *value) { -qdev_prop_set(dev, name, value, PROP_TYPE_MACADDR); +Error *errp = NULL; +char str[2 * 6 + 5 + 1]; +snprintf(str, sizeof(str),
[Qemu-devel] [PATCH 15/16] qdev: inline qdev_prop_set into qdev_prop_set_ptr
qdev_prop_set is not needed anymore except for hacks, simplify it and inline it. Signed-off-by: Paolo Bonzini pbonz...@redhat.com --- hw/qdev-properties.c | 26 +++--- 1 files changed, 7 insertions(+), 19 deletions(-) diff --git a/hw/qdev-properties.c b/hw/qdev-properties.c index ab7f522..d7e5356 100644 --- a/hw/qdev-properties.c +++ b/hw/qdev-properties.c @@ -1065,24 +1065,6 @@ int qdev_prop_parse(DeviceState *dev, const char *name, const char *value) return 0; } -static void qdev_prop_set(DeviceState *dev, const char *name, void *src, enum PropertyType type) -{ -Property *prop; - -prop = qdev_prop_find(dev, name); -if (!prop) { -fprintf(stderr, %s: property \%s.%s\ not found\n, -__FUNCTION__, object_get_typename(OBJECT(dev)), name); -abort(); -} -if (prop-info-type != type) { -fprintf(stderr, %s: property \%s.%s\ type mismatch\n, -__FUNCTION__, object_get_typename(OBJECT(dev)), name); -abort(); -} -qdev_prop_cpy(dev, prop, src); -} - void qdev_prop_set_bit(DeviceState *dev, const char *name, bool value) { Error *errp = NULL; @@ -1187,7 +1169,13 @@ void qdev_prop_set_macaddr(DeviceState *dev, const char *name, uint8_t *value) void qdev_prop_set_ptr(DeviceState *dev, const char *name, void *value) { -qdev_prop_set(dev, name, value, PROP_TYPE_PTR); +Property *prop; +void **ptr; + +prop = qdev_prop_find(dev, name); +assert(prop prop-info-type == PROP_TYPE_PTR); +ptr = qdev_get_prop_ptr(dev, prop); +*ptr = value; } void qdev_prop_set_defaults(DeviceState *dev, Property *props) -- 1.7.7.6
Re: [Qemu-devel] [PATCH 01/16] qdev: fix hot-unplug
On 02/02/2012 10:45 AM, Paolo Bonzini wrote: The reference that is returned by qdev_device_add is never given back, so that device_del does not cause the refcount to go to zero (and thus does nothing). Signed-off-by: Paolo Bonzinipbonz...@redhat.com --- vl.c |1 + 1 files changed, 1 insertions(+), 0 deletions(-) diff --git a/vl.c b/vl.c index d88a18c..c63af69 100644 --- a/vl.c +++ b/vl.c @@ -1746,6 +1746,7 @@ static int device_init_func(QemuOpts *opts, void *opaque) dev = qdev_device_add(opts); if (!dev) return -1; +object_unref(OBJECT(dev)); return 0; Is this still needed with qom-upstream.14? I fixed a bug on .14 that involved child properties that was making device-del sometimes fail. If it is, what's your test case? I have a device_del test case that seems to be working right now without this patch. Regards, Anthony Liguori }
Re: [Qemu-devel] [PATCH 02/16] qom: store object with correct type in interface links
On 02/02/2012 10:45 AM, Paolo Bonzini wrote: When a link property's type is an interface, the code expects the implementation object (not the parent object) to be stored in the variable. The parent object does not contain the right vtable. Signed-off-by: Paolo Bonzinipbonz...@redhat.com --- qom/object.c |3 ++- 1 files changed, 2 insertions(+), 1 deletions(-) diff --git a/qom/object.c b/qom/object.c index cd517f6..de6484d 100644 --- a/qom/object.c +++ b/qom/object.c @@ -749,7 +749,8 @@ static void object_set_link_property(Object *obj, Visitor *v, void *opaque, target_type = g_strdup(type[5]); target_type[strlen(target_type) - 2] = 0; -if (object_dynamic_cast(target, target_type)) { +target = object_dynamic_cast(target, target_type); +if (target) { object_ref(target); *child = target; Very good catch. Regards, Anthony Liguori } else {
[Qemu-devel] [PATCH 08/16] qdev: remove parse method for string properties
We need the print method to put double quotes, but parsing is not special. Signed-off-by: Paolo Bonzini pbonz...@redhat.com --- hw/qdev-properties.c | 11 --- 1 files changed, 0 insertions(+), 11 deletions(-) diff --git a/hw/qdev-properties.c b/hw/qdev-properties.c index 16f9b22..0a293af 100644 --- a/hw/qdev-properties.c +++ b/hw/qdev-properties.c @@ -510,16 +510,6 @@ PropertyInfo qdev_prop_hex64 = { /* --- string --- */ -static int parse_string(DeviceState *dev, Property *prop, const char *str) -{ -char **ptr = qdev_get_prop_ptr(dev, prop); - -if (*ptr) -g_free(*ptr); -*ptr = g_strdup(str); -return 0; -} - static void free_string(DeviceState *dev, Property *prop) { g_free(*(char **)qdev_get_prop_ptr(dev, prop)); @@ -581,7 +571,6 @@ PropertyInfo qdev_prop_string = { .name = string, .type = PROP_TYPE_STRING, .size = sizeof(char*), -.parse = parse_string, .print = print_string, .free = free_string, .get = get_string, -- 1.7.7.6
[Qemu-devel] [PATCH 10/16] qdev: make the non-legacy pci address property accept an integer
PCI addresses are set with qdev_prop_uint32. Thus we make the QOM property accept a device and function encoded in an 8-bit integer, instead of the magic dd.f hex string. Signed-off-by: Paolo Bonzini pbonz...@redhat.com --- hw/qdev-properties.c | 25 +++-- 1 files changed, 7 insertions(+), 18 deletions(-) diff --git a/hw/qdev-properties.c b/hw/qdev-properties.c index 4fb5cf8..e4bcc6d 100644 --- a/hw/qdev-properties.c +++ b/hw/qdev-properties.c @@ -950,30 +950,19 @@ static int print_pci_devfn(DeviceState *dev, Property *prop, char *dest, size_t } } -static void get_pci_devfn(Object *obj, Visitor *v, void *opaque, - const char *name, Error **errp) -{ -DeviceState *dev = DEVICE(obj); -Property *prop = opaque; -uint32_t *ptr = qdev_get_prop_ptr(dev, prop); -char buffer[32]; -char *p = buffer; - -buffer[0] = 0; -if (*ptr != -1) { -snprintf(buffer, sizeof(buffer), %02x.%x, *ptr 3, *ptr 7); -} -visit_type_str(v, p, name, errp); -} - PropertyInfo qdev_prop_pci_devfn = { .name = pci-devfn, .type = PROP_TYPE_UINT32, .size = sizeof(uint32_t), .parse = parse_pci_devfn, .print = print_pci_devfn, -.get = get_pci_devfn, -.set = set_generic, +.get = get_int32, +.set = set_int32, +/* FIXME: this should be -1...255, but the address is stored + * into an uint32_t rather than int32_t. + */ +.min = 0, +.max = 0xULL, }; /* --- public helpers --- */ -- 1.7.7.6
[Qemu-devel] [PATCH 09/16] qdev: remove parse/print methods for mac properties
Signed-off-by: Paolo Bonzini pbonz...@redhat.com --- hw/qdev-properties.c | 61 ++--- 1 files changed, 42 insertions(+), 19 deletions(-) diff --git a/hw/qdev-properties.c b/hw/qdev-properties.c index 0a293af..4fb5cf8 100644 --- a/hw/qdev-properties.c +++ b/hw/qdev-properties.c @@ -848,46 +848,69 @@ PropertyInfo qdev_prop_ptr = { * 01:02:03:04:05:06 * 01-02-03-04-05-06 */ -static int parse_mac(DeviceState *dev, Property *prop, const char *str) +static void get_mac(Object *obj, Visitor *v, void *opaque, +const char *name, Error **errp) +{ +DeviceState *dev = DEVICE(obj); +Property *prop = opaque; +MACAddr *mac = qdev_get_prop_ptr(dev, prop); +char buffer[2 * 6 + 5 + 1]; +char *p = buffer; + +snprintf(buffer, sizeof(buffer), %02x:%02x:%02x:%02x:%02x:%02x, + mac-a[0], mac-a[1], mac-a[2], + mac-a[3], mac-a[4], mac-a[5]); + +visit_type_str(v, p, name, errp); +} + +static void set_mac(Object *obj, Visitor *v, void *opaque, +const char *name, Error **errp) { +DeviceState *dev = DEVICE(obj); +Property *prop = opaque; MACAddr *mac = qdev_get_prop_ptr(dev, prop); +Error *local_err = NULL; int i, pos; -char *p; +char *str, *p; + +if (dev-state != DEV_STATE_CREATED) { +error_set(errp, QERR_PERMISSION_DENIED); +return; +} + +visit_type_str(v, str, name, local_err); +if (local_err) { +error_propagate(errp, local_err); +return; +} for (i = 0, pos = 0; i 6; i++, pos += 3) { if (!qemu_isxdigit(str[pos])) -return -EINVAL; +goto inval; if (!qemu_isxdigit(str[pos+1])) -return -EINVAL; +goto inval; if (i == 5) { if (str[pos+2] != '\0') -return -EINVAL; +goto inval; } else { if (str[pos+2] != ':' str[pos+2] != '-') -return -EINVAL; +goto inval; } mac-a[i] = strtol(str+pos, p, 16); } -return 0; -} - -static int print_mac(DeviceState *dev, Property *prop, char *dest, size_t len) -{ -MACAddr *mac = qdev_get_prop_ptr(dev, prop); +return; -return snprintf(dest, len, %02x:%02x:%02x:%02x:%02x:%02x, -mac-a[0], mac-a[1], mac-a[2], -mac-a[3], mac-a[4], mac-a[5]); +inval: +error_set_from_qdev_prop_error(errp, EINVAL, dev, prop, str); } PropertyInfo qdev_prop_macaddr = { .name = macaddr, .type = PROP_TYPE_MACADDR, .size = sizeof(MACAddr), -.parse = parse_mac, -.print = print_mac, -.get = get_generic, -.set = set_generic, +.get = get_mac, +.set = set_mac, }; /* --- pci address --- */ -- 1.7.7.6
[Qemu-devel] [PATCH 16/16] qdev: initialize properties via QOM
Similarly, use the object properties also to set the default values of the qdev properties. This requires reordering registration and initialization. Signed-off-by: Paolo Bonzini pbonz...@redhat.com --- hw/qdev-properties.c | 20 +++- hw/qdev.c|4 ++-- hw/qdev.h| 11 +++ 3 files changed, 16 insertions(+), 19 deletions(-) diff --git a/hw/qdev-properties.c b/hw/qdev-properties.c index d7e5356..760240e 100644 --- a/hw/qdev-properties.c +++ b/hw/qdev-properties.c @@ -26,17 +26,6 @@ static void bit_prop_set(DeviceState *dev, Property *props, bool val) *p = ~mask; } -static void qdev_prop_cpy(DeviceState *dev, Property *props, void *src) -{ -if (props-info-type == PROP_TYPE_BIT) { -bool *defval = src; -bit_prop_set(dev, props, *defval); -} else { -char *dst = qdev_get_prop_ptr(dev, props); -memcpy(dst, src, props-info-size); -} -} - /* Bit */ static int parse_bit(DeviceState *dev, Property *prop, const char *str) { @@ -1180,12 +1169,17 @@ void qdev_prop_set_ptr(DeviceState *dev, const char *name, void *value) void qdev_prop_set_defaults(DeviceState *dev, Property *props) { +Object *obj = OBJECT(dev); if (!props) return; while (props-name) { -if (props-defval) { -qdev_prop_cpy(dev, props, props-defval); +Error *errp = NULL; +if (props-qtype == QTYPE_QBOOL) { +object_property_set_bool(obj, props-defval, props-name, errp); +} else if (props-qtype == QTYPE_QINT) { +object_property_set_int(obj, props-defval, props-name, errp); } +assert(!errp); props++; } } diff --git a/hw/qdev.c b/hw/qdev.c index f719f14..dc1d1a1 100644 --- a/hw/qdev.c +++ b/hw/qdev.c @@ -86,11 +86,11 @@ void qdev_set_parent_bus(DeviceState *dev, BusState *bus) dev-parent_bus = bus; QTAILQ_INSERT_HEAD(bus-children, dev, sibling); -qdev_prop_set_defaults(dev, dev-parent_bus-info-props); for (prop = qdev_get_bus_info(dev)-props; prop prop-name; prop++) { qdev_property_add_legacy(dev, prop, NULL); qdev_property_add_static(dev, prop, NULL); } +qdev_prop_set_defaults(dev, dev-parent_bus-info-props); } /* Create a new device. This only initializes the device state structure @@ -612,13 +612,13 @@ static void device_initfn(Object *obj) dev-instance_id_alias = -1; dev-state = DEV_STATE_CREATED; -qdev_prop_set_defaults(dev, qdev_get_props(dev)); for (prop = qdev_get_props(dev); prop prop-name; prop++) { qdev_property_add_legacy(dev, prop, NULL); qdev_property_add_static(dev, prop, NULL); } object_property_add_str(OBJECT(dev), type, qdev_get_type, NULL, NULL); +qdev_prop_set_defaults(dev, qdev_get_props(dev)); } /* Unlink device from bus and free the structure. */ diff --git a/hw/qdev.h b/hw/qdev.h index c0e5600..60c226b 100644 --- a/hw/qdev.h +++ b/hw/qdev.h @@ -112,8 +112,9 @@ struct Property { const char *name; PropertyInfo *info; int offset; -int bitnr; -void *defval; +uint8_t bitnr; +uint8_t qtype; +int64_t defval; }; enum PropertyType { @@ -252,7 +253,8 @@ extern PropertyInfo qdev_prop_pci_devfn; .info = (_prop), \ .offset= offsetof(_state, _field) \ + type_check(_type,typeof_field(_state, _field)), \ -.defval= (_type[]) { _defval }, \ +.qtype = QTYPE_QINT,\ +.defval= (_type)_defval,\ } #define DEFINE_PROP_BIT(_name, _state, _field, _bit, _defval) { \ .name = (_name),\ @@ -260,7 +262,8 @@ extern PropertyInfo qdev_prop_pci_devfn; .bitnr= (_bit), \ .offset= offsetof(_state, _field)\ + type_check(uint32_t,typeof_field(_state, _field)), \ -.defval= (bool[]) { (_defval) }, \ +.qtype = QTYPE_QBOOL,\ +.defval= (bool)_defval, \ } #define DEFINE_PROP_UINT8(_n, _s, _f, _d) \ -- 1.7.7.6
Re: [Qemu-devel] [PATCH 01/16] qdev: fix hot-unplug
On 02/02/2012 06:03 PM, Anthony Liguori wrote: Is this still needed with qom-upstream.14? I fixed a bug on .14 that involved child properties that was making device-del sometimes fail. Not sure, I tried with .13 but, from the look of it, it should still be there. Regarding the .13-.14 diff: - you need QTAILQ_FOREACH_SAFE in object_property_del_child. - you need to check for the existence of the non-aliased name when accessing the alias table, because s390 does not have PCI. If it is, what's your test case? I check that the device disappears from info qtree. I check with gdb that after object_unparent the refcount is zero. Paolo
[Qemu-devel] [PATCH 13/16] qdev: fix off-by-one
Integer properties did not work. Signed-off-by: Paolo Bonzini pbonz...@redhat.com --- hw/qdev-properties.c |6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-) diff --git a/hw/qdev-properties.c b/hw/qdev-properties.c index 7efcc78..30abae2 100644 --- a/hw/qdev-properties.c +++ b/hw/qdev-properties.c @@ -151,7 +151,7 @@ static void set_int8(Object *obj, Visitor *v, void *opaque, error_propagate(errp, local_err); return; } -if (value prop-info-min value = prop-info-max) { +if (value = prop-info-min value = prop-info-max) { *ptr = value; } else { error_set(errp, QERR_PROPERTY_VALUE_OUT_OF_RANGE, @@ -259,7 +259,7 @@ static void set_int16(Object *obj, Visitor *v, void *opaque, error_propagate(errp, local_err); return; } -if (value prop-info-min value = prop-info-max) { +if (value = prop-info-min value = prop-info-max) { *ptr = value; } else { error_set(errp, QERR_PROPERTY_VALUE_OUT_OF_RANGE, @@ -333,7 +333,7 @@ static void set_int32(Object *obj, Visitor *v, void *opaque, error_propagate(errp, local_err); return; } -if (value prop-info-min value = prop-info-max) { +if (value = prop-info-min value = prop-info-max) { *ptr = value; } else { error_set(errp, QERR_PROPERTY_VALUE_OUT_OF_RANGE, -- 1.7.7.6
[Qemu-devel] [PATCH 04/16] qom: add QObject-based property get/set wrappers
Move the creation of QmpInputVisitor and QmpOutputVisitor from qmp.c to qom/object.c, since it's the only practical way to access object properties. Signed-off-by: Paolo Bonzini pbonz...@redhat.com --- include/qemu/object.h | 24 qmp.c | 17 ++--- qom/object.c | 29 + 3 files changed, 55 insertions(+), 15 deletions(-) diff --git a/include/qemu/object.h b/include/qemu/object.h index 947cf29..71090f2 100644 --- a/include/qemu/object.h +++ b/include/qemu/object.h @@ -542,6 +542,18 @@ void object_property_get(Object *obj, struct Visitor *v, const char *name, struct Error **errp); /** + * object_property_get_qobject: + * @obj: the object + * @name: the name of the property + * @errp: returns an error if this function fails + * + * Returns: the value of the property, converted to QObject, or NULL if + * an error occurs. + */ +struct QObject *object_property_get_qobject(Object *obj, const char *name, +struct Error **errp); + +/** * object_property_set: * @obj: the object * @v: the visitor that will be used to write the property value. This should @@ -556,6 +568,18 @@ void object_property_set(Object *obj, struct Visitor *v, const char *name, struct Error **errp); /** + * object_property_set_qobject: + * @obj: the object + * @ret: The value that will be written to the property. + * @name: the name of the property + * @errp: returns an error if this function fails + * + * Writes a property to a object. + */ +void object_property_set_qobject(Object *obj, struct QObject *qobj, + const char *name, struct Error **errp); + +/** * @object_property_get_type: * @obj: the object * @name: the name of the property diff --git a/qmp.c b/qmp.c index 45052cc..c7a81cc 100644 --- a/qmp.c +++ b/qmp.c @@ -21,8 +21,6 @@ #include kvm.h #include arch_init.h #include hw/qdev.h -#include qapi/qmp-input-visitor.h -#include qapi/qmp-output-visitor.h #include blockdev.h NameInfo *qmp_query_name(Error **errp) @@ -198,7 +196,6 @@ int qmp_qom_set(Monitor *mon, const QDict *qdict, QObject **ret) const char *property = qdict_get_str(qdict, property); QObject *value = qdict_get(qdict, value); Error *local_err = NULL; -QmpInputVisitor *mi; Object *obj; obj = object_resolve_path(path, NULL); @@ -207,10 +204,7 @@ int qmp_qom_set(Monitor *mon, const QDict *qdict, QObject **ret) goto out; } -mi = qmp_input_visitor_new(value); -object_property_set(obj, qmp_input_get_visitor(mi), property, local_err); - -qmp_input_visitor_cleanup(mi); +object_property_set_qobject(obj, value, property, local_err); out: if (local_err) { @@ -227,7 +221,6 @@ int qmp_qom_get(Monitor *mon, const QDict *qdict, QObject **ret) const char *path = qdict_get_str(qdict, path); const char *property = qdict_get_str(qdict, property); Error *local_err = NULL; -QmpOutputVisitor *mo; Object *obj; obj = object_resolve_path(path, NULL); @@ -236,13 +229,7 @@ int qmp_qom_get(Monitor *mon, const QDict *qdict, QObject **ret) goto out; } -mo = qmp_output_visitor_new(); -object_property_get(obj, qmp_output_get_visitor(mo), property, local_err); -if (!local_err) { -*ret = qmp_output_get_qobject(mo); -} - -qmp_output_visitor_cleanup(mo); +*ret = object_property_get_qobject(obj, property, local_err); out: if (local_err) { diff --git a/qom/object.c b/qom/object.c index 299e146..13c8bec 100644 --- a/qom/object.c +++ b/qom/object.c @@ -13,6 +13,8 @@ #include qemu/object.h #include qemu-common.h #include qapi/qapi-visit-core.h +#include qapi/qmp-input-visitor.h +#include qapi/qmp-output-visitor.h #define MAX_INTERFACES 32 @@ -646,6 +648,33 @@ void object_property_set(Object *obj, Visitor *v, const char *name, } } +void object_property_set_qobject(Object *obj, QObject *value, + const char *name, Error **errp) +{ +QmpInputVisitor *mi; +mi = qmp_input_visitor_new(value); +object_property_set(obj, qmp_input_get_visitor(mi), name, errp); + +qmp_input_visitor_cleanup(mi); +} + +QObject *object_property_get_qobject(Object *obj, const char *name, + Error **errp) +{ +QObject *ret = NULL; +Error *local_err = NULL; +QmpOutputVisitor *mo; + +mo = qmp_output_visitor_new(); +object_property_get(obj, qmp_output_get_visitor(mo), name, local_err); +if (!local_err) { +ret = qmp_output_get_qobject(mo); +} +error_propagate(errp, local_err); +qmp_output_visitor_cleanup(mo); +return ret; +} + const char *object_property_get_type(Object *obj, const char *name, Error **errp) { ObjectProperty *prop = object_property_find(obj, name); -- 1.7.7.6
[Qemu-devel] [PATCH 03/16] qom: do not include qdev header file
Signed-off-by: Paolo Bonzini pbonz...@redhat.com --- qom/object.c |2 -- 1 files changed, 0 insertions(+), 2 deletions(-) diff --git a/qom/object.c b/qom/object.c index de6484d..299e146 100644 --- a/qom/object.c +++ b/qom/object.c @@ -13,8 +13,6 @@ #include qemu/object.h #include qemu-common.h #include qapi/qapi-visit-core.h -#include hw/qdev.h -// FIXME remove above #define MAX_INTERFACES 32 -- 1.7.7.6
[Qemu-devel] [Bug 818673] Re: virtio: trying to map MMIO memory
Yes, I would say it is the same bug. I will test the driver that Vadim linked in Comment 33 (https://bugzilla.redhat.com/show_bug.cgi?id=771390#c33) and report back. Thanks, Mike, for posting here. -- You received this bug notification because you are a member of qemu- devel-ml, which is subscribed to QEMU. https://bugs.launchpad.net/bugs/818673 Title: virtio: trying to map MMIO memory Status in QEMU: New Bug description: Qemu host is Core i7, running Linux. Guest is Windows XP sp3. Often, qemu will crash shortly after starting (1-5 minutes) with a statement qemu-system-x86_64: virtio: trying to map MMIO memory This has occured with qemu-kvm 0.14, qemu-kvm 0.14.1, qemu-0.15.0-rc0 and qemu 0.15.0-rc1. Qemu is started as such: qemu-system-x86_64 -cpu host -enable-kvm -pidfile /home/rick/qemu/hds/wxp.pid -drive file=/home/rick/qemu/hds/wxp.raw,if=virtio -m 768 -name WinXP -net nic,model=virtio -net user -localtime -usb -vga qxl -device virtio-serial -chardev spicevmc,name=vdagent,id=vdagent -device virtserialport,chardev=vdagent,name=com.redhat.spice.0 -spice port=1234,disable-ticketing -daemonize -monitor telnet:localhost:12341,server,nowait The WXP guest has virtio 1.1.16 drivers for net and scsi, and the most current spice binaries from spice-space.org. To manage notifications about this bug go to: https://bugs.launchpad.net/qemu/+bug/818673/+subscriptions
[Qemu-devel] [PATCH 05/16] qom: add property get/set wrappers for C types
Add more wrappers that create a QObject and free it around a property set, and that convert a QObject to a C type for a property get. Signed-off-by: Paolo Bonzini pbonz...@redhat.com --- include/qemu/object.h | 70 ++ qom/object.c | 115 + 2 files changed, 176 insertions(+), 9 deletions(-) diff --git a/include/qemu/object.h b/include/qemu/object.h index 71090f2..1dcaea2 100644 --- a/include/qemu/object.h +++ b/include/qemu/object.h @@ -554,6 +554,76 @@ struct QObject *object_property_get_qobject(Object *obj, const char *name, struct Error **errp); /** + * object_property_set_str: + * @value: the value to be written to the property + * @name: the name of the property + * @errp: returns an error if this function fails + * + * Writes a string value to a property. + */ +void object_property_set_str(Object *obj, const char *value, + const char *name, struct Error **errp); + +/** + * object_property_get_str: + * @obj: the object + * @name: the name of the property + * @errp: returns an error if this function fails + * + * Returns: the value of the property, converted to a C string, or NULL if + * an error occurs (including when the property value is not a string). + * The caller should free the string. + */ +char *object_property_get_str(Object *obj, const char *name, + struct Error **errp); + +/** + * object_property_set_bool: + * @value: the value to be written to the property + * @name: the name of the property + * @errp: returns an error if this function fails + * + * Writes a bool value to a property. + */ +void object_property_set_bool(Object *obj, bool value, + const char *name, struct Error **errp); + +/** + * object_property_get_bool: + * @obj: the object + * @name: the name of the property + * @errp: returns an error if this function fails + * + * Returns: the value of the property, converted to a boolean, or NULL if + * an error occurs (including when the property value is not a bool). + */ +bool object_property_get_bool(Object *obj, const char *name, + struct Error **errp); + +/** + * object_property_set_int: + * @value: the value to be written to the property + * @name: the name of the property + * @errp: returns an error if this function fails + * + * Writes an integer value to a property. + */ +void object_property_set_int(Object *obj, int64_t value, + const char *name, struct Error **errp); + +/** + * object_property_get_int: + * @obj: the object + * @name: the name of the property + * @errp: returns an error if this function fails + * + * Returns: the value of the property, converted to an integer, or NULL if + * an error occurs (including when the property value is not an integer). + */ +int64_t object_property_get_int(Object *obj, const char *name, +struct Error **errp); + +/** * object_property_set: * @obj: the object * @v: the visitor that will be used to write the property value. This should diff --git a/qom/object.c b/qom/object.c index 13c8bec..f1a1261 100644 --- a/qom/object.c +++ b/qom/object.c @@ -15,6 +15,10 @@ #include qapi/qapi-visit-core.h #include qapi/qmp-input-visitor.h #include qapi/qmp-output-visitor.h +#include qobject.h +#include qbool.h +#include qint.h +#include qstring.h #define MAX_INTERFACES 32 @@ -675,6 +679,99 @@ QObject *object_property_get_qobject(Object *obj, const char *name, return ret; } +void object_property_set_str(Object *obj, const char *value, + const char *name, Error **errp) +{ +QString *qstr = qstring_from_str(value); +object_property_set_qobject(obj, QOBJECT(qstr), name, errp); + +QDECREF(qstr); +} + +char *object_property_get_str(Object *obj, const char *name, + Error **errp) +{ +QObject *ret = object_property_get_qobject(obj, name, errp); +QString *qstring; +char *retval; + +if (!ret) { +return NULL; +} +qstring = qobject_to_qstring(ret); +if (!qstring) { +error_set(errp, QERR_INVALID_PARAMETER_TYPE, name, string); +retval = NULL; +} else { +retval = g_strdup(qstring_get_str(qstring)); +} + +QDECREF(qstring); +return retval; +} + +void object_property_set_bool(Object *obj, bool value, + const char *name, Error **errp) +{ +QBool *qbool = qbool_from_int(value); +object_property_set_qobject(obj, QOBJECT(qbool), name, errp); + +QDECREF(qbool); +} + +bool object_property_get_bool(Object *obj, const char *name, + Error **errp) +{ +QObject *ret = object_property_get_qobject(obj, name, errp); +QBool *qbool; +bool retval; + +if (!ret) { +return false; +} +qbool =
[Qemu-devel] [PATCH 06/16] qdev: remove direct calls to print/parse
There's no need to call into -parse and -print manually. The QOM legacy properties do that for us. Furthermore, in some cases legacy and static properties have exactly the same behavior, and we could drop the legacy properties right away. Add an appropriate fallback to prepare for this. Signed-off-by: Paolo Bonzini pbonz...@redhat.com --- hw/qdev-monitor.c| 27 --- hw/qdev-properties.c | 26 ++ hw/qdev.c|9 + 3 files changed, 35 insertions(+), 27 deletions(-) diff --git a/hw/qdev-monitor.c b/hw/qdev-monitor.c index b8d8a9e..64505b4 100644 --- a/hw/qdev-monitor.c +++ b/hw/qdev-monitor.c @@ -487,21 +487,26 @@ static void qbus_print(Monitor *mon, BusState *bus, int indent); static void qdev_print_props(Monitor *mon, DeviceState *dev, Property *props, const char *prefix, int indent) { -char buf[64]; - if (!props) return; while (props-name) { -/* - * TODO Properties without a print method are just for dirty - * hacks. qdev_prop_ptr is the only such PropertyInfo. It's - * marked for removal. The test props-info-print should be - * removed along with it. - */ -if (props-info-print) { -props-info-print(dev, props, buf, sizeof(buf)); -qdev_printf(%s-prop: %s = %s\n, prefix, props-name, buf); +Error *err; +char *value; +char *legacy_name = g_strdup_printf(legacy-%s, props-name); +if (object_property_get_type(OBJECT(dev), legacy_name, NULL)) { +value = object_property_get_str(OBJECT(dev), legacy_name, err); +} else { +value = object_property_get_str(OBJECT(dev), props-name, err); +} +g_free(legacy_name); + +if (err) { +error_free(err); +continue; } +qdev_printf(%s-prop: %s = %s\n, prefix, props-name, +value *value ? value : null); +g_free(value); props++; } } diff --git a/hw/qdev-properties.c b/hw/qdev-properties.c index d34df30..7c41140 100644 --- a/hw/qdev-properties.c +++ b/hw/qdev-properties.c @@ -1024,24 +1024,18 @@ void error_set_from_qdev_prop_error(Error **errp, int ret, DeviceState *dev, int qdev_prop_parse(DeviceState *dev, const char *name, const char *value) { -Property *prop; -int ret; +char *legacy_name; +Error *err; -prop = qdev_prop_find(dev, name); -/* - * TODO Properties without a parse method are just for dirty - * hacks. qdev_prop_ptr is the only such PropertyInfo. It's - * marked for removal. The test !prop-info-parse should be - * removed along with it. - */ -if (!prop || !prop-info-parse) { -qerror_report(QERR_PROPERTY_NOT_FOUND, object_get_typename(OBJECT(dev)), name); -return -1; +legacy_name = g_strdup_printf(legacy-%s, name); +if (object_property_get_type(OBJECT(dev), legacy_name, NULL)) { +object_property_set_str(OBJECT(dev), legacy_name, value, err); +} else { +object_property_set_str(OBJECT(dev), name, value, err); } -ret = prop-info-parse(dev, prop, value); -if (ret 0) { -Error *err; -error_set_from_qdev_prop_error(err, ret, dev, prop, value); +g_free(legacy_name); + +if (err) { qerror_report_err(err); error_free(err); return -1; diff --git a/hw/qdev.c b/hw/qdev.c index e3b53b7..a731e41 100644 --- a/hw/qdev.c +++ b/hw/qdev.c @@ -581,6 +581,15 @@ void qdev_property_add_legacy(DeviceState *dev, Property *prop, void qdev_property_add_static(DeviceState *dev, Property *prop, Error **errp) { +/* + * TODO qdev_prop_ptr does not have getters or setters. It must + * go now that it can be replaced with links. The test should be + * removed along with it, all static properties are read/write. + */ +if (!prop-info-get !prop-info-set) { +return; +} + object_property_add(OBJECT(dev), prop-name, prop-info-name, prop-info-get, prop-info-set, NULL, -- 1.7.7.6
[Qemu-devel] [PATCH 11/16] qdev: remove parse/print methods for pointer properties
Pointer properties (except for PROP_PTR of course) should not need a legacy counterpart. In the future, relative paths will ensure that QEMU will support the same syntax as now for drives etc.. Signed-off-by: Paolo Bonzini pbonz...@redhat.com --- hw/qdev-properties.c | 128 -- 1 files changed, 72 insertions(+), 56 deletions(-) diff --git a/hw/qdev-properties.c b/hw/qdev-properties.c index e4bcc6d..627d335 100644 --- a/hw/qdev-properties.c +++ b/hw/qdev-properties.c @@ -579,9 +579,8 @@ PropertyInfo qdev_prop_string = { /* --- drive --- */ -static int parse_drive(DeviceState *dev, Property *prop, const char *str) +static int parse_drive(DeviceState *dev, const char *str, void **ptr) { -BlockDriverState **ptr = qdev_get_prop_ptr(dev, prop); BlockDriverState *bs; bs = bdrv_find(str); @@ -603,35 +602,30 @@ static void free_drive(DeviceState *dev, Property *prop) } } -static int print_drive(DeviceState *dev, Property *prop, char *dest, size_t len) +static const char *print_drive(void *ptr) { -BlockDriverState **ptr = qdev_get_prop_ptr(dev, prop); -return snprintf(dest, len, %s, -*ptr ? bdrv_get_device_name(*ptr) : null); +return bdrv_get_device_name(ptr); } -static void get_generic(Object *obj, Visitor *v, void *opaque, - const char *name, Error **errp) +static void get_pointer(Object *obj, Visitor *v, Property *prop, +const char *(*print)(void *ptr), +const char *name, Error **errp) { DeviceState *dev = DEVICE(obj); -Property *prop = opaque; void **ptr = qdev_get_prop_ptr(dev, prop); -char buffer[1024]; -char *p = buffer; +char *p; -buffer[0] = 0; -if (*ptr) { -prop-info-print(dev, prop, buffer, sizeof(buffer)); -} +p = (char *) (*ptr ? print(*ptr) : ); visit_type_str(v, p, name, errp); } -static void set_generic(Object *obj, Visitor *v, void *opaque, +static void set_pointer(Object *obj, Visitor *v, Property *prop, +int (*parse)(DeviceState *dev, const char *str, void **ptr), const char *name, Error **errp) { DeviceState *dev = DEVICE(obj); -Property *prop = opaque; Error *local_err = NULL; +void **ptr = qdev_get_prop_ptr(dev, prop); char *str; int ret; @@ -650,36 +644,45 @@ static void set_generic(Object *obj, Visitor *v, void *opaque, error_set_from_qdev_prop_error(errp, EINVAL, dev, prop, str); return; } -ret = prop-info-parse(dev, prop, str); +ret = parse(dev, str, ptr); error_set_from_qdev_prop_error(errp, ret, dev, prop, str); g_free(str); } +static void get_drive(Object *obj, Visitor *v, void *opaque, + const char *name, Error **errp) +{ +get_pointer(obj, v, opaque, print_drive, name, errp); +} + +static void set_drive(Object *obj, Visitor *v, void *opaque, + const char *name, Error **errp) +{ +set_pointer(obj, v, opaque, parse_drive, name, errp); +} + PropertyInfo qdev_prop_drive = { .name = drive, .type = PROP_TYPE_DRIVE, .size = sizeof(BlockDriverState *), -.parse = parse_drive, -.print = print_drive, -.get = get_generic, -.set = set_generic, +.get = get_drive, +.set = set_drive, .free = free_drive, }; /* --- character device --- */ -static int parse_chr(DeviceState *dev, Property *prop, const char *str) +static int parse_chr(DeviceState *dev, const char *str, void **ptr) { -CharDriverState **ptr = qdev_get_prop_ptr(dev, prop); - -*ptr = qemu_chr_find(str); -if (*ptr == NULL) { +CharDriverState *chr = qemu_chr_find(str); +if (chr == NULL) { return -ENOENT; } -if ((*ptr)-avail_connections 1) { +if (chr-avail_connections 1) { return -EEXIST; } ---(*ptr)-avail_connections; +*ptr = chr; +--chr-avail_connections; return 0; } @@ -693,62 +696,75 @@ static void free_chr(DeviceState *dev, Property *prop) } -static int print_chr(DeviceState *dev, Property *prop, char *dest, size_t len) +static const char *print_chr(void *ptr) { -CharDriverState **ptr = qdev_get_prop_ptr(dev, prop); +CharDriverState *chr = ptr; -if (*ptr (*ptr)-label) { -return snprintf(dest, len, %s, (*ptr)-label); -} else { -return snprintf(dest, len, null); -} +return chr-label ? chr-label : ; +} + +static void get_chr(Object *obj, Visitor *v, void *opaque, +const char *name, Error **errp) +{ +get_pointer(obj, v, opaque, print_chr, name, errp); +} + +static void set_chr(Object *obj, Visitor *v, void *opaque, +const char *name, Error **errp) +{ +set_pointer(obj, v, opaque, parse_chr, name, errp); } PropertyInfo qdev_prop_chr = { .name = chr, .type = PROP_TYPE_CHR,
[Qemu-devel] [Bug 818673] Re: virtio: trying to map MMIO memory
well, the link in the redhat bug, comment 33, is no good apparently. I will follow that bug, and test when I see Vadim has posted a new driver to test. -- You received this bug notification because you are a member of qemu- devel-ml, which is subscribed to QEMU. https://bugs.launchpad.net/bugs/818673 Title: virtio: trying to map MMIO memory Status in QEMU: New Bug description: Qemu host is Core i7, running Linux. Guest is Windows XP sp3. Often, qemu will crash shortly after starting (1-5 minutes) with a statement qemu-system-x86_64: virtio: trying to map MMIO memory This has occured with qemu-kvm 0.14, qemu-kvm 0.14.1, qemu-0.15.0-rc0 and qemu 0.15.0-rc1. Qemu is started as such: qemu-system-x86_64 -cpu host -enable-kvm -pidfile /home/rick/qemu/hds/wxp.pid -drive file=/home/rick/qemu/hds/wxp.raw,if=virtio -m 768 -name WinXP -net nic,model=virtio -net user -localtime -usb -vga qxl -device virtio-serial -chardev spicevmc,name=vdagent,id=vdagent -device virtserialport,chardev=vdagent,name=com.redhat.spice.0 -spice port=1234,disable-ticketing -daemonize -monitor telnet:localhost:12341,server,nowait The WXP guest has virtio 1.1.16 drivers for net and scsi, and the most current spice binaries from spice-space.org. To manage notifications about this bug go to: https://bugs.launchpad.net/qemu/+bug/818673/+subscriptions
[Qemu-devel] [PATCH] usb: Resolve warnings about unassigned bus on usb device creation
When creating an USB device the old way, there is no way to specify the target bus. Thus the warning issued by usb_create makes no sense and rather confuses our users. Resolve this by passing a bus reference to the usbdevice_init handler and letting those handlers forward it to usb_create. Signed-off-by: Jan Kiszka jan.kis...@siemens.com --- hw/usb-bt.c |4 ++-- hw/usb-bus.c| 18 -- hw/usb-msd.c|4 ++-- hw/usb-net.c|4 ++-- hw/usb-serial.c |8 hw/usb.h|7 --- usb-bsd.c |4 ++-- usb-linux.c |4 ++-- vl.c|7 --- 9 files changed, 26 insertions(+), 34 deletions(-) diff --git a/hw/usb-bt.c b/hw/usb-bt.c index bf8c470..291242f 100644 --- a/hw/usb-bt.c +++ b/hw/usb-bt.c @@ -498,14 +498,14 @@ static int usb_bt_initfn(USBDevice *dev) return 0; } -USBDevice *usb_bt_init(HCIInfo *hci) +USBDevice *usb_bt_init(USBBus *bus, HCIInfo *hci) { USBDevice *dev; struct USBBtState *s; if (!hci) return NULL; -dev = usb_create_simple(NULL /* FIXME */, usb-bt-dongle); +dev = usb_create_simple(bus, usb-bt-dongle); if (!dev) { return NULL; } diff --git a/hw/usb-bus.c b/hw/usb-bus.c index aeef908..aae5b0c 100644 --- a/hw/usb-bus.c +++ b/hw/usb-bus.c @@ -203,14 +203,15 @@ typedef struct LegacyUSBFactory { const char *name; const char *usbdevice_name; -USBDevice *(*usbdevice_init)(const char *params); +USBDevice *(*usbdevice_init)(USBBus *bus, const char *params); } LegacyUSBFactory; static GSList *legacy_usb_factory; void usb_qdev_register(DeviceInfo *info, const char *usbdevice_name, - USBDevice *(*usbdevice_init)(const char *params)) + USBDevice *(*usbdevice_init)(USBBus *bus, +const char *params)) { info-bus_info = usb_bus_info; info-init = usb_qdev_init; @@ -231,17 +232,6 @@ USBDevice *usb_create(USBBus *bus, const char *name) { DeviceState *dev; -#if 1 -/* temporary stopgap until all usb is properly qdev-ified */ -if (!bus) { -bus = usb_bus_find(-1); -if (!bus) -return NULL; -error_report(%s: no bus specified, using \%s\ for \%s\, -__FUNCTION__, bus-qbus.name, name); -} -#endif - dev = qdev_create(bus-qbus, name); return USB_DEVICE(dev); } @@ -572,7 +562,7 @@ USBDevice *usbdevice_create(const char *cmdline) } return usb_create_simple(bus, f-name); } -return f-usbdevice_init(params); +return f-usbdevice_init(bus, params); } static TypeInfo usb_device_type_info = { diff --git a/hw/usb-msd.c b/hw/usb-msd.c index ceb01e0..823f072 100644 --- a/hw/usb-msd.c +++ b/hw/usb-msd.c @@ -568,7 +568,7 @@ static int usb_msd_initfn(USBDevice *dev) return 0; } -static USBDevice *usb_msd_init(const char *filename) +static USBDevice *usb_msd_init(USBBus *bus, const char *filename) { static int nr=0; char id[8]; @@ -611,7 +611,7 @@ static USBDevice *usb_msd_init(const char *filename) } /* create guest device */ -dev = usb_create(NULL /* FIXME */, usb-storage); +dev = usb_create(bus, usb-storage); if (!dev) { return NULL; } diff --git a/hw/usb-net.c b/hw/usb-net.c index 57b58ac..c9884e1 100644 --- a/hw/usb-net.c +++ b/hw/usb-net.c @@ -1353,7 +1353,7 @@ static int usb_net_initfn(USBDevice *dev) return 0; } -static USBDevice *usb_net_init(const char *cmdline) +static USBDevice *usb_net_init(USBBus *bus, const char *cmdline) { USBDevice *dev; QemuOpts *opts; @@ -1371,7 +1371,7 @@ static USBDevice *usb_net_init(const char *cmdline) return NULL; } -dev = usb_create(NULL /* FIXME */, usb-net); +dev = usb_create(bus, usb-net); if (!dev) { return NULL; } diff --git a/hw/usb-serial.c b/hw/usb-serial.c index de49607..8c7861d 100644 --- a/hw/usb-serial.c +++ b/hw/usb-serial.c @@ -492,7 +492,7 @@ static int usb_serial_initfn(USBDevice *dev) return 0; } -static USBDevice *usb_serial_init(const char *filename) +static USBDevice *usb_serial_init(USBBus *bus, const char *filename) { USBDevice *dev; CharDriverState *cdrv; @@ -535,7 +535,7 @@ static USBDevice *usb_serial_init(const char *filename) if (!cdrv) return NULL; -dev = usb_create(NULL /* FIXME */, usb-serial); +dev = usb_create(bus, usb-serial); if (!dev) { return NULL; } @@ -549,7 +549,7 @@ static USBDevice *usb_serial_init(const char *filename) return dev; } -static USBDevice *usb_braille_init(const char *unused) +static USBDevice *usb_braille_init(USBBus *bus, const char *unused) { USBDevice *dev; CharDriverState *cdrv; @@ -558,7 +558,7 @@ static USBDevice *usb_braille_init(const char *unused) if (!cdrv) return NULL; -dev = usb_create(NULL
Re: [Qemu-devel] [PATCH v11 0/9] ARM: Samsung Exynos4210-based boards support.
On 30 January 2012 07:38, Evgeny Voevodin e.voevo...@samsung.com wrote: This set of patches adds support for Samsung Exynos4210-based boards NURI and SMDKC210. Tested on Linux kernel v3.x series. Usage: -smp 2 option is mandatory for now. If it is then the board should complain about -smp 1. As it is, you get a huge pile of Timer with period zero, disabling debug printout to the terminal... -- PMM
Re: [Qemu-devel] [PATCH 01/16] qdev: fix hot-unplug
On 02/02/2012 11:29 AM, Paolo Bonzini wrote: On 02/02/2012 06:03 PM, Anthony Liguori wrote: Is this still needed with qom-upstream.14? I fixed a bug on .14 that involved child properties that was making device-del sometimes fail. Not sure, I tried with .13 but, from the look of it, it should still be there. Regarding the .13-.14 diff: - you need QTAILQ_FOREACH_SAFE in object_property_del_child. Ack. - you need to check for the existence of the non-aliased name when accessing the alias table, because s390 does not have PCI. I don't think that's the right strategy as it means that s390 only works if we don't include the PCI objects in the build (regardless of whether it uses PCI). This would be defeated if/when we move to having all device objects in a single shared library used by all of the qemu executables. I'd prefer to just drop the aliases for s390. I don't see a lot of value in it and I don't think there are tons of s390 users that will be affected. If it is, what's your test case? I check that the device disappears from info qtree. I check with gdb that after object_unparent the refcount is zero. Ah, okay, I'll look at this more closely. Thanks. Regards, Anthony Liguori Paolo
Re: [Qemu-devel] [PATCH 04/16] qom: add QObject-based property get/set wrappers
On 02/02/2012 10:45 AM, Paolo Bonzini wrote: Move the creation of QmpInputVisitor and QmpOutputVisitor from qmp.c to qom/object.c, since it's the only practical way to access object properties. Signed-off-by: Paolo Bonzinipbonz...@redhat.com --- include/qemu/object.h | 24 qmp.c | 17 ++--- qom/object.c | 29 + 3 files changed, 55 insertions(+), 15 deletions(-) I don't want object.h to have a dependency on QObject. We need to phase out QObject. Couple things: 1) We shouldn't use generic interfaces to read/write properties from objects. We should use type-safe accessors provided by the types themselves. 2) If we want to get fancy, we can add property_set_int, etc. and then implement (1) via header files that just call these functions. Regards, Anthony Liguori diff --git a/include/qemu/object.h b/include/qemu/object.h index 947cf29..71090f2 100644 --- a/include/qemu/object.h +++ b/include/qemu/object.h @@ -542,6 +542,18 @@ void object_property_get(Object *obj, struct Visitor *v, const char *name, struct Error **errp); /** + * object_property_get_qobject: + * @obj: the object + * @name: the name of the property + * @errp: returns an error if this function fails + * + * Returns: the value of the property, converted to QObject, or NULL if + * an error occurs. + */ +struct QObject *object_property_get_qobject(Object *obj, const char *name, +struct Error **errp); + +/** * object_property_set: * @obj: the object * @v: the visitor that will be used to write the property value. This should @@ -556,6 +568,18 @@ void object_property_set(Object *obj, struct Visitor *v, const char *name, struct Error **errp); /** + * object_property_set_qobject: + * @obj: the object + * @ret: The value that will be written to the property. + * @name: the name of the property + * @errp: returns an error if this function fails + * + * Writes a property to a object. + */ +void object_property_set_qobject(Object *obj, struct QObject *qobj, + const char *name, struct Error **errp); + +/** * @object_property_get_type: * @obj: the object * @name: the name of the property diff --git a/qmp.c b/qmp.c index 45052cc..c7a81cc 100644 --- a/qmp.c +++ b/qmp.c @@ -21,8 +21,6 @@ #include kvm.h #include arch_init.h #include hw/qdev.h -#include qapi/qmp-input-visitor.h -#include qapi/qmp-output-visitor.h #include blockdev.h NameInfo *qmp_query_name(Error **errp) @@ -198,7 +196,6 @@ int qmp_qom_set(Monitor *mon, const QDict *qdict, QObject **ret) const char *property = qdict_get_str(qdict, property); QObject *value = qdict_get(qdict, value); Error *local_err = NULL; -QmpInputVisitor *mi; Object *obj; obj = object_resolve_path(path, NULL); @@ -207,10 +204,7 @@ int qmp_qom_set(Monitor *mon, const QDict *qdict, QObject **ret) goto out; } -mi = qmp_input_visitor_new(value); -object_property_set(obj, qmp_input_get_visitor(mi), property,local_err); - -qmp_input_visitor_cleanup(mi); +object_property_set_qobject(obj, value, property,local_err); out: if (local_err) { @@ -227,7 +221,6 @@ int qmp_qom_get(Monitor *mon, const QDict *qdict, QObject **ret) const char *path = qdict_get_str(qdict, path); const char *property = qdict_get_str(qdict, property); Error *local_err = NULL; -QmpOutputVisitor *mo; Object *obj; obj = object_resolve_path(path, NULL); @@ -236,13 +229,7 @@ int qmp_qom_get(Monitor *mon, const QDict *qdict, QObject **ret) goto out; } -mo = qmp_output_visitor_new(); -object_property_get(obj, qmp_output_get_visitor(mo), property,local_err); -if (!local_err) { -*ret = qmp_output_get_qobject(mo); -} - -qmp_output_visitor_cleanup(mo); +*ret = object_property_get_qobject(obj, property,local_err); out: if (local_err) { diff --git a/qom/object.c b/qom/object.c index 299e146..13c8bec 100644 --- a/qom/object.c +++ b/qom/object.c @@ -13,6 +13,8 @@ #include qemu/object.h #include qemu-common.h #include qapi/qapi-visit-core.h +#include qapi/qmp-input-visitor.h +#include qapi/qmp-output-visitor.h #define MAX_INTERFACES 32 @@ -646,6 +648,33 @@ void object_property_set(Object *obj, Visitor *v, const char *name, } } +void object_property_set_qobject(Object *obj, QObject *value, + const char *name, Error **errp) +{ +QmpInputVisitor *mi; +mi = qmp_input_visitor_new(value); +object_property_set(obj, qmp_input_get_visitor(mi), name, errp); + +qmp_input_visitor_cleanup(mi); +} + +QObject *object_property_get_qobject(Object *obj, const char *name, + Error **errp) +{ +QObject *ret = NULL; +Error *local_err = NULL;
Re: [Qemu-devel] [PATCH 01/16] qdev: fix hot-unplug
On 02.02.2012, at 20:01, Anthony Liguori wrote: On 02/02/2012 11:29 AM, Paolo Bonzini wrote: On 02/02/2012 06:03 PM, Anthony Liguori wrote: Is this still needed with qom-upstream.14? I fixed a bug on .14 that involved child properties that was making device-del sometimes fail. Not sure, I tried with .13 but, from the look of it, it should still be there. Regarding the .13-.14 diff: - you need QTAILQ_FOREACH_SAFE in object_property_del_child. Ack. - you need to check for the existence of the non-aliased name when accessing the alias table, because s390 does not have PCI. I don't think that's the right strategy as it means that s390 only works if we don't include the PCI objects in the build (regardless of whether it uses PCI). This would be defeated if/when we move to having all device objects in a single shared library used by all of the qemu executables. I'd prefer to just drop the aliases for s390. I don't see a lot of value in it and I don't think there are tons of s390 users that will be affected. The reason for the aliases is to make -drive and -net work. If you have alternatives to aliases there, I'm happy to go with them. Alex
Re: [Qemu-devel] [PATCH 04/16] qom: add QObject-based property get/set wrappers
On 02/02/2012 08:06 PM, Anthony Liguori wrote: I don't want object.h to have a dependency on QObject. We need to phase out QObject. The header doesn't. Couple things: 1) We shouldn't use generic interfaces to read/write properties from objects. We should use type-safe accessors provided by the types themselves. 2) If we want to get fancy, we can add property_set_int, etc. and then implement (1) via header files that just call these functions. That's what patch 5 does. But writing visitors in C is a royal PITA. The only sane way to do so is via QObject. Paolo
Re: [Qemu-devel] [PATCH 04/16] qom: add QObject-based property get/set wrappers
Am 02.02.2012 20:06, schrieb Anthony Liguori: On 02/02/2012 10:45 AM, Paolo Bonzini wrote: Move the creation of QmpInputVisitor and QmpOutputVisitor from qmp.c to qom/object.c, since it's the only practical way to access object properties. Signed-off-by: Paolo Bonzinipbonz...@redhat.com --- include/qemu/object.h | 24 qmp.c | 17 ++--- qom/object.c | 29 + 3 files changed, 55 insertions(+), 15 deletions(-) I don't want object.h to have a dependency on QObject. We need to phase out QObject. We did get that dependency though by your move of the property code to object.c. As you will see shortly, we now need qobject-obj-y and qapi-obj-y plus some stubs to make the user emulators compile with QOM. Andreas -- SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
Re: [Qemu-devel] [PATCH 04/16] qom: add QObject-based property get/set wrappers
On 02/02/2012 08:24 PM, Paolo Bonzini wrote: 1) We shouldn't use generic interfaces to read/write properties from objects. We should use type-safe accessors provided by the types themselves. That doesn't change the fact that we need simple wrappers using C types (at various levels: object_property_set_qobject, object_property_set, qdev_set_*) to implement these type-safe accessors on top of dynamic properties. 2) If we want to get fancy, we can add property_set_int, etc. and then implement (1) via header files that just call these functions. That's what patch 5 does. But writing visitors in C is a royal PITA. The only sane way to do so is via QObject. BTW, I don't really think it's possible to proceed on this except by accepting compromises. We need to be the #1 QOM client, _now_ or it will remain buggy bitrot. Paolo
Re: [Qemu-devel] Get only TCG code without execution
Hi, I have modified QEMU to act as a TCG compiler and give me the TCG code for the whole binary. However, I cannot find a way to obtain the last address in the binary. The symbol table loaded into syminfos contains only the address of the last symbol. Not the address of the last machine instruction. I can obtain this if I can obtain the length of the last section in the ELF. How can I do that in QEMU? Thanks, Rajat. On Sat, Jan 21, 2012 at 12:21 AM, Jamie Lokier ja...@shareable.org wrote: 陳韋任 wrote: What's load/store exclusive implementation? It's how some architectures do atomic operations, instead of having atomic instructions like x86 does. And as a general emulator, QEMU shouldn't implement any architecture-specific memory model, right? What comes into my mind is QEMU only need to follow guest memory operations when translates guest binary to TCG ops. When translate TCG ops to host binary, it also has to be careful not to mess up the memory ordering. The error occurs when emulating two or more guest CPUs in parallel using two or more host CPUs for speed. Then not mess up the memory ordering may require barrier instructions in the host binary code, depending on the guest and host architectures. Without barrier instructions, the CPUs reorder memory accesses even if the instruction order is kept the same. This reordering done by the CPU is called the memory model. TCG cannot currently produce these barrier instructions, and it's not clear if it will ever be able to do so efficiently. -- Jamie -- Rajat Goyal 5th year undergraduate student Master of Technology in Mathematics and Computing - Integrated Program Department of Mathematics IIT Delhi
Re: [Qemu-devel] [PATCH 04/16] qom: add QObject-based property get/set wrappers
On 02/02/2012 01:24 PM, Paolo Bonzini wrote: On 02/02/2012 08:06 PM, Anthony Liguori wrote: I don't want object.h to have a dependency on QObject. We need to phase out QObject. The header doesn't. Couple things: 1) We shouldn't use generic interfaces to read/write properties from objects. We should use type-safe accessors provided by the types themselves. 2) If we want to get fancy, we can add property_set_int, etc. and then implement (1) via header files that just call these functions. That's what patch 5 does. But writing visitors in C is a royal PITA. The only sane way to do so is via QObject. You just need a variant visitor. It's pretty simple to do, essentially: typedef struct VariantVisitor { Visitor parent; enum { VV_INT, VV_STR } kind; union { int64_t v_int; char *v_str }; } VariantVisitor; /* input */ static void visit_int(...) { v-kind = TYPE_INT; v-v_int = *value; } /* output */ static void visit_int(...) { assert(v-kind == TYPE_INT); *value = v-v_int; } void variant_visitor_set_int(VariantVisitor *v, int64_t value) { v-kind = TYPE_INT; v-v_int = value; } The only types that matter are int and string so the variant visitor is pretty simple. Regards, Anthony Liguori Paolo
[Qemu-devel] [PULL] w32 patch queue
Hi, here are some w32 related patches which were already published and reviewed on qemu-devel: http://patchwork.ozlabs.org/patch/132797/ http://patchwork.ozlabs.org/patch/138690/ Regards, Stefan Weil The following changes since commit d34e8f6e9d3a396c3327aa9807c83f9e1f4a7bd7: main-loop: For tools, initialize timers as part of qemu_init_main_loop() (2012-02-01 14:45:02 -0600) are available in the git repository at: git://qemu.weilnetz.de/qemu.git w32 Stefan Weil (2): w32: Build windows and console executables w32: Initialise critical section before starting thread (fix #922131) Makefile.target | 16 +++- qemu-thread-win32.c |9 +++-- 2 files changed, 22 insertions(+), 3 deletions(-)
[Qemu-devel] [PATCH v2 0/8] qemu-ga: add support for Windows
These patches apply on top of qemu.git master, and can also be obtained from: git://github.com/mdroth/qemu.git qga-win32-v2 Luiz/Gal, I decided not to roll the suspend/hibernate stuff into this series since the s3 situation isn't fully sorted out yet. The file structure is a little different now, posix/linux-specific stuff goes in qga/commands-posix.c, win32-specific stuff in qga/commands-win32.c, but other than that it should be a straightforward rebase if this gets merged first. CHANGES SINCE V1: - Dropped guest-set-support-level patch dependency - Rebased on master and re-tested - Spelling/grammar fixes in commits/comments OVERVIEW: These patches add support for Windows to the QEMU guest agent. With these patches the following guest agent commands are supported on Windows: guest-ping guest-info guest-sync guest-shutdown The guest-file* commands can essentially be enabled for Windows as-is, but since mingw does not honor the O_NONBLOCK flag, they'll need to be reworked if we're to retain the current non-blocking behavior. The rest of the commands are currently stubbed out for Windows (qemu-ga will return an unsupported error), but it should be easy to implement these going forward with basic Windows support/infrastructure in place. The build was tested using Fedora15 with a MinGW cross-build target via: configure --enable-guest-agent --cross-prefix=i686-pc-mingw32- make qemu-ga.exe The executable was tested using Windows XP SP3, and partially tested using Windows Server 2008 and Windows 7 (no I/O for the latter 2, having issues with virtio-win drivers). GLib 2.28+ for Windows is required. You can install qemu-ga as a load-on-boot service by running: ./qemu-ga --service install And start/stop manually via: net start qemu-ga net stop qemu-ga Many thanks to Gal Hammer for contributing the service integration and shutdown code. Makefile |2 +- Makefile.objs |8 +- configure |2 +- qapi-schema-guest.json | 118 -- qemu-ga.c | 413 ++- qga/channel-posix.c| 246 +++ qga/channel-win32.c| 337 + qga/channel.h | 33 +++ qga/commands-posix.c | 528 +++ qga/commands-win32.c | 130 ++ qga/commands.c | 73 ++ qga/guest-agent-commands.c | 585 qga/guest-agent-core.h |3 +- qga/service-win32.c| 114 + qga/service-win32.h| 30 +++ 15 files changed, 1782 insertions(+), 840 deletions(-)
[Qemu-devel] [PATCH v2 2/8] qemu-ga: move channel/transport functionality into wrapper class
This is mostly in preparation for the win32 port, which won't use GIO channels for reasons that will be made clearer later. Here the GAChannel class is just a loose wrapper around GIOChannel calls/callbacks, but we also roll in the logic/configuration for various channel types and managing unix socket connections, which makes the abstraction much more complete and further aids in the win32 port since isa-serial/unix-listen will not be supported initially. There's also a bit of refactoring in the main logic to consolidate the exit paths so we can do common cleanup for things like pid files, which weren't always cleaned up previously. Signed-off-by: Michael Roth mdr...@linux.vnet.ibm.com --- Makefile.objs |1 + qemu-ga.c | 306 qga/channel-posix.c| 246 ++ qga/channel.h | 33 + qga/guest-agent-core.h |2 +- 5 files changed, 355 insertions(+), 233 deletions(-) create mode 100644 qga/channel-posix.c create mode 100644 qga/channel.h diff --git a/Makefile.objs b/Makefile.objs index b942625..27ff919 100644 --- a/Makefile.objs +++ b/Makefile.objs @@ -425,6 +425,7 @@ common-obj-y += qmp.o hmp.o # guest agent qga-nested-y = guest-agent-commands.o guest-agent-command-state.o +qga-nested-y += channel-posix.o qga-obj-y = $(addprefix qga/, $(qga-nested-y)) qga-obj-y += qemu-ga.o qemu-sockets.o module.o qemu-option.o qga-obj-$(CONFIG_WIN32) += oslib-win32.o diff --git a/qemu-ga.c b/qemu-ga.c index 29e4f64..2e8af02 100644 --- a/qemu-ga.c +++ b/qemu-ga.c @@ -15,9 +15,7 @@ #include stdbool.h #include glib.h #include getopt.h -#include termios.h #include syslog.h -#include qemu_socket.h #include json-streamer.h #include json-parser.h #include qint.h @@ -28,19 +26,15 @@ #include qerror.h #include error_int.h #include qapi/qmp-core.h +#include qga/channel.h #define QGA_VIRTIO_PATH_DEFAULT /dev/virtio-ports/org.qemu.guest_agent.0 #define QGA_PIDFILE_DEFAULT /var/run/qemu-ga.pid -#define QGA_BAUDRATE_DEFAULT B38400 /* for isa-serial channels */ -#define QGA_TIMEOUT_DEFAULT 30*1000 /* ms */ struct GAState { JSONMessageParser parser; GMainLoop *main_loop; -GIOChannel *conn_channel; -GIOChannel *listen_channel; -const char *path; -const char *method; +GAChannel *channel; bool virtio; /* fastpath to check for virtio to deal with poll() quirks */ GACommandState *command_state; GLogLevelFlags log_level; @@ -59,7 +53,7 @@ static void quit_handler(int sig) } } -static void register_signal_handlers(void) +static gboolean register_signal_handlers(void) { struct sigaction sigact; int ret; @@ -70,12 +64,14 @@ static void register_signal_handlers(void) ret = sigaction(SIGINT, sigact, NULL); if (ret == -1) { g_error(error configuring signal handler: %s, strerror(errno)); -exit(EXIT_FAILURE); +return false; } ret = sigaction(SIGTERM, sigact, NULL); if (ret == -1) { g_error(error configuring signal handler: %s, strerror(errno)); +return false; } +return true; } static void usage(const char *cmd) @@ -100,8 +96,6 @@ static void usage(const char *cmd) , cmd, QGA_VERSION, QGA_VIRTIO_PATH_DEFAULT, QGA_PIDFILE_DEFAULT); } -static void conn_channel_close(GAState *s); - static const char *ga_log_level_str(GLogLevelFlags level) { switch (level G_LOG_LEVEL_MASK) { @@ -210,40 +204,13 @@ fail: exit(EXIT_FAILURE); } -static int conn_channel_send_buf(GIOChannel *channel, const char *buf, - gsize count) -{ -GError *err = NULL; -gsize written = 0; -GIOStatus status; - -while (count) { -status = g_io_channel_write_chars(channel, buf, count, written, err); -g_debug(sending data, count: %d, (int)count); -if (err != NULL) { -g_warning(error sending newline: %s, err-message); -return err-code; -} -if (status == G_IO_STATUS_ERROR || status == G_IO_STATUS_EOF) { -return -EPIPE; -} - -if (status == G_IO_STATUS_NORMAL) { -count -= written; -} -} - -return 0; -} - -static int conn_channel_send_payload(GIOChannel *channel, QObject *payload) +static int send_response(GAState *s, QObject *payload) { -int ret = 0; const char *buf; QString *payload_qstr; -GError *err = NULL; +GIOStatus status; -g_assert(payload channel); +g_assert(payload s-channel); payload_qstr = qobject_to_json(payload); if (!payload_qstr) { @@ -252,24 +219,13 @@ static int conn_channel_send_payload(GIOChannel *channel, QObject *payload) qstring_append_chr(payload_qstr, '\n'); buf = qstring_get_str(payload_qstr); -ret = conn_channel_send_buf(channel, buf, strlen(buf)); -if (ret) { -goto out_free; -} - -g_io_channel_flush(channel,
[Qemu-devel] [PATCH v2 1/8] qemu-ga: Add schema documentation for types
Document guest agent schema types in similar fashion as qmp schema types. Signed-off-by: Michael Roth mdr...@linux.vnet.ibm.com --- qapi-schema-guest.json | 118 +++- 1 files changed, 97 insertions(+), 21 deletions(-) diff --git a/qapi-schema-guest.json b/qapi-schema-guest.json index 5f8a18d..706925d 100644 --- a/qapi-schema-guest.json +++ b/qapi-schema-guest.json @@ -37,17 +37,42 @@ { 'command': 'guest-ping' } ## -# @guest-info: +# @GuestAgentCommandInfo: # -# Get some information about the guest agent. +# Information about guest agent commands. # -# Since: 0.15.0 +# @name: name of the command +# +# @enabled: whether command is currently enabled by guest admin +# +# Since 1.1.0 ## { 'type': 'GuestAgentCommandInfo', 'data': { 'name': 'str', 'enabled': 'bool' } } + +## +# @GuestAgentInfo +# +# Information about guest agent. +# +# @version: guest agent version +# +# @supported_commands: Information about guest agent commands +# +# Since 0.15.0 +## { 'type': 'GuestAgentInfo', 'data': { 'version': 'str', 'supported_commands': ['GuestAgentCommandInfo'] } } +## +# @guest-info: +# +# Get some information about the guest agent. +# +# Returns: @GuestAgentInfo +# +# Since: 0.15.0 +## { 'command': 'guest-info', 'returns': 'GuestAgentInfo' } @@ -98,6 +123,23 @@ 'data': { 'handle': 'int' } } ## +# @GuestFileRead +# +# Result of guest agent file-read operation +# +# @count: number of bytes read (note: count is *before* +# base64-encoding is applied) +# +# @buf-b64: base64-encoded bytes read +# +# @eof: whether EOF was encountered during read operation. +# +# Since: 0.15.0 +## +{ 'type': 'GuestFileRead', + 'data': { 'count': 'int', 'buf-b64': 'str', 'eof': 'bool' } } + +## # @guest-file-read: # # Read from an open file in the guest. Data will be base64-encoded @@ -106,19 +148,30 @@ # # @count: #optional maximum number of bytes to read (default is 4KB) # -# Returns: GuestFileRead on success. Note: count is number of bytes read -# *before* base64 encoding bytes read. +# Returns: @GuestFileRead on success. # # Since: 0.15.0 ## -{ 'type': 'GuestFileRead', - 'data': { 'count': 'int', 'buf-b64': 'str', 'eof': 'bool' } } - { 'command': 'guest-file-read', 'data':{ 'handle': 'int', '*count': 'int' }, 'returns': 'GuestFileRead' } ## +# @GuestFileWrite +# +# Result of guest agent file-write operation +# +# @count: number of bytes written (note: count is actual bytes +# written, after base64-decoding of provided buffer) +# +# @eof: whether EOF was encountered during write operation. +# +# Since: 0.15.0 +## +{ 'type': 'GuestFileWrite', + 'data': { 'count': 'int', 'eof': 'bool' } } + +## # @guest-file-write: # # Write to an open file in the guest. @@ -130,17 +183,29 @@ # @count: #optional bytes to write (actual bytes, after base64-decode), # default is all content in buf-b64 buffer after base64 decoding # -# Returns: GuestFileWrite on success. Note: count is the number of bytes -# base64-decoded bytes written +# Returns: @GuestFileWrite on success. # # Since: 0.15.0 ## -{ 'type': 'GuestFileWrite', - 'data': { 'count': 'int', 'eof': 'bool' } } { 'command': 'guest-file-write', 'data':{ 'handle': 'int', 'buf-b64': 'str', '*count': 'int' }, 'returns': 'GuestFileWrite' } + +## +# @GuestFileSeek +# +# Result of guest agent file-seek operation +# +# @position: current file position +# +# @eof: whether EOF was encountered during file seek +# +# Since: 0.15.0 +## +{ 'type': 'GuestFileSeek', + 'data': { 'position': 'int', 'eof': 'bool' } } + ## # @guest-file-seek: # @@ -154,13 +219,10 @@ # # @whence: SEEK_SET, SEEK_CUR, or SEEK_END, as with fseek() # -# Returns: GuestFileSeek on success. +# Returns: @GuestFileSeek on success. # # Since: 0.15.0 ## -{ 'type': 'GuestFileSeek', - 'data': { 'position': 'int', 'eof': 'bool' } } - { 'command': 'guest-file-seek', 'data':{ 'handle': 'int', 'offset': 'int', 'whence': 'int' }, 'returns': 'GuestFileSeek' } @@ -180,18 +242,32 @@ 'data': { 'handle': 'int' } } ## -# @guest-fsfreeze-status: +# @GuestFsFreezeStatus # -# Get guest fsfreeze state. error state indicates failure to thaw 1 or more -# previously frozen filesystems, or failure to open a previously cached -# filesytem (filesystem unmounted/directory changes, etc). +# An enumation of filesystem freeze states # -# Returns: GuestFsfreezeStatus (thawed, frozen, etc., as defined below) +# @thawed: filesystems thawed/unfrozen +# +# @frozen: all non-network guest filesystems frozen +# +# @error: failure to thaw 1 or more +# previously frozen filesystems, or failure to open a previously +# cached filesytem (filesystem unmounted/directory changes, etc). # # Since: 0.15.0 ## { 'enum': 'GuestFsfreezeStatus', 'data': [ 'thawed', 'frozen', 'error' ] } + +## +# @guest-fsfreeze-status: +# +# Get guest fsfreeze state. error state indicates
Re: [Qemu-devel] [PATCH 04/16] qom: add QObject-based property get/set wrappers
On 02/02/2012 01:29 PM, Paolo Bonzini wrote: On 02/02/2012 08:24 PM, Paolo Bonzini wrote: 1) We shouldn't use generic interfaces to read/write properties from objects. We should use type-safe accessors provided by the types themselves. That doesn't change the fact that we need simple wrappers using C types (at various levels: object_property_set_qobject, object_property_set, qdev_set_*) to implement these type-safe accessors on top of dynamic properties. 2) If we want to get fancy, we can add property_set_int, etc. and then implement (1) via header files that just call these functions. That's what patch 5 does. But writing visitors in C is a royal PITA. The only sane way to do so is via QObject. BTW, I don't really think it's possible to proceed on this except by accepting compromises. We need to be the #1 QOM client, _now_ or it will remain buggy bitrot. Not disagreeing at all with the goal, just the implementation :-) We can pretty easily avoid a QObject dependency. I can throw together that patch if you'd like. Regards, Anthony Liguori Paolo
Re: [Qemu-devel] [PATCH 01/16] qdev: fix hot-unplug
On 02/02/2012 01:07 PM, Alexander Graf wrote: On 02.02.2012, at 20:01, Anthony Liguori wrote: On 02/02/2012 11:29 AM, Paolo Bonzini wrote: On 02/02/2012 06:03 PM, Anthony Liguori wrote: Is this still needed with qom-upstream.14? I fixed a bug on .14 that involved child properties that was making device-del sometimes fail. Not sure, I tried with .13 but, from the look of it, it should still be there. Regarding the .13-.14 diff: - you need QTAILQ_FOREACH_SAFE in object_property_del_child. Ack. - you need to check for the existence of the non-aliased name when accessing the alias table, because s390 does not have PCI. I don't think that's the right strategy as it means that s390 only works if we don't include the PCI objects in the build (regardless of whether it uses PCI). This would be defeated if/when we move to having all device objects in a single shared library used by all of the qemu executables. I'd prefer to just drop the aliases for s390. I don't see a lot of value in it and I don't think there are tons of s390 users that will be affected. The reason for the aliases is to make -drive and -net work. If you have alternatives to aliases there, I'm happy to go with them. We can simply do a const char *target_get_virtio_net_type(void) in arch_init.c. Not pretty, but we can later fix the -drive/-net calls to not require this. Regards, Anthony Liguori Alex
Re: [Qemu-devel] [PATCH 09/16] qdev: remove parse/print methods for mac properties
On 02/02/2012 10:45 AM, Paolo Bonzini wrote: Signed-off-by: Paolo Bonzinipbonz...@redhat.com --- hw/qdev-properties.c | 61 ++--- 1 files changed, 42 insertions(+), 19 deletions(-) diff --git a/hw/qdev-properties.c b/hw/qdev-properties.c index 0a293af..4fb5cf8 100644 --- a/hw/qdev-properties.c +++ b/hw/qdev-properties.c @@ -848,46 +848,69 @@ PropertyInfo qdev_prop_ptr = { * 01:02:03:04:05:06 * 01-02-03-04-05-06 */ -static int parse_mac(DeviceState *dev, Property *prop, const char *str) +static void get_mac(Object *obj, Visitor *v, void *opaque, +const char *name, Error **errp) +{ +DeviceState *dev = DEVICE(obj); +Property *prop = opaque; +MACAddr *mac = qdev_get_prop_ptr(dev, prop); +char buffer[2 * 6 + 5 + 1]; +char *p = buffer; + +snprintf(buffer, sizeof(buffer), %02x:%02x:%02x:%02x:%02x:%02x, + mac-a[0], mac-a[1], mac-a[2], + mac-a[3], mac-a[4], mac-a[5]); + +visit_type_str(v,p, name, errp); +} Part of me wonders, given that we can structure properties in a more friendly way, would we still do macs as strings? Would we instead do a list of ints or something like that? Regards, Anthony Liguori
Re: [Qemu-devel] [PATCH 10/16] qdev: make the non-legacy pci address property accept an integer
On 02/02/2012 10:45 AM, Paolo Bonzini wrote: PCI addresses are set with qdev_prop_uint32. Thus we make the QOM property accept a device and function encoded in an 8-bit integer, instead of the magic dd.f hex string. Signed-off-by: Paolo Bonzinipbonz...@redhat.com Isn't this a compatibility breaker? Won't this break libvirt's usage of -device addr=0.2 ? Regards, Anthony Liguori --- hw/qdev-properties.c | 25 +++-- 1 files changed, 7 insertions(+), 18 deletions(-) diff --git a/hw/qdev-properties.c b/hw/qdev-properties.c index 4fb5cf8..e4bcc6d 100644 --- a/hw/qdev-properties.c +++ b/hw/qdev-properties.c @@ -950,30 +950,19 @@ static int print_pci_devfn(DeviceState *dev, Property *prop, char *dest, size_t } } -static void get_pci_devfn(Object *obj, Visitor *v, void *opaque, - const char *name, Error **errp) -{ -DeviceState *dev = DEVICE(obj); -Property *prop = opaque; -uint32_t *ptr = qdev_get_prop_ptr(dev, prop); -char buffer[32]; -char *p = buffer; - -buffer[0] = 0; -if (*ptr != -1) { -snprintf(buffer, sizeof(buffer), %02x.%x, *ptr 3, *ptr 7); -} -visit_type_str(v,p, name, errp); -} - PropertyInfo qdev_prop_pci_devfn = { .name = pci-devfn, .type = PROP_TYPE_UINT32, .size = sizeof(uint32_t), .parse = parse_pci_devfn, .print = print_pci_devfn, -.get = get_pci_devfn, -.set = set_generic, +.get = get_int32, +.set = set_int32, +/* FIXME: this should be -1...255, but the address is stored + * into an uint32_t rather than int32_t. + */ +.min = 0, +.max = 0xULL, }; /* --- public helpers --- */
Re: [Qemu-devel] [PATCH 04/16] qom: add QObject-based property get/set wrappers
On 02/02/2012 08:36 PM, Anthony Liguori wrote: The only types that matter are int and string so the variant visitor is pretty simple. Sure, only ~150 lines of code. I also do not disagree with the goals (mine and yours), just with the priorities. :) Paolo
Re: [Qemu-devel] [PATCH 10/16] qdev: make the non-legacy pci address property accept an integer
On 02/02/2012 09:07 PM, Anthony Liguori wrote: Signed-off-by: Paolo Bonzinipbonz...@redhat.com Isn't this a compatibility breaker? Won't this break libvirt's usage of -device addr=0.2 ? Nope, the legacy property still keeps the dd.f format. This is only for QOM (and internal use by qdev). Paolo
[Qemu-devel] [PATCH v2 8/8] qemu-ga: add win32 guest-shutdown command
Implement guest-shutdown RPC for Windows. Functionally this should be equivalent to the posix implementation. Original patch by Gal Hammer gham...@redhat.com Signed-off-by: Michael Roth mdr...@linux.vnet.ibm.com --- qga/commands-win32.c | 41 - 1 files changed, 40 insertions(+), 1 deletions(-) diff --git a/qga/commands-win32.c b/qga/commands-win32.c index d96f1ad..4aa0f0d 100644 --- a/qga/commands-win32.c +++ b/qga/commands-win32.c @@ -15,9 +15,48 @@ #include qga-qmp-commands.h #include qerror.h +#ifndef SHTDN_REASON_FLAG_PLANNED +#define SHTDN_REASON_FLAG_PLANNED 0x8000 +#endif + void qmp_guest_shutdown(bool has_mode, const char *mode, Error **err) { -error_set(err, QERR_UNSUPPORTED); +HANDLE token; +TOKEN_PRIVILEGES priv; +UINT shutdown_flag = EWX_FORCE; + +slog(guest-shutdown called, mode: %s, mode); + +if (!has_mode || strcmp(mode, powerdown) == 0) { +shutdown_flag |= EWX_POWEROFF; +} else if (strcmp(mode, halt) == 0) { +shutdown_flag |= EWX_SHUTDOWN; +} else if (strcmp(mode, reboot) == 0) { +shutdown_flag |= EWX_REBOOT; +} else { +error_set(err, QERR_INVALID_PARAMETER_VALUE, mode, + halt|powerdown|reboot); +return; +} + +/* Request a shutdown privilege, but try to shut down the system + anyway. */ +if (OpenProcessToken(GetCurrentProcess(), +TOKEN_ADJUST_PRIVILEGES|TOKEN_QUERY, token)) +{ +LookupPrivilegeValue(NULL, SE_SHUTDOWN_NAME, +priv.Privileges[0].Luid); + +priv.PrivilegeCount = 1; +priv.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED; + +AdjustTokenPrivileges(token, FALSE, priv, 0, NULL, 0); +} + +if (!ExitWindowsEx(shutdown_flag, SHTDN_REASON_FLAG_PLANNED)) { +slog(guest-shutdown failed: %d, GetLastError()); +error_set(err, QERR_UNDEFINED_ERROR); +} } int64_t qmp_guest_file_open(const char *path, bool has_mode, const char *mode, Error **err) -- 1.7.4.1
[Qemu-devel] [PATCH v2 3/8] qemu-ga: separate out common commands from posix-specific ones
Many of the current RPC implementations are very much POSIX-specific and require complete re-writes for Windows. There are however a small set of core guest agent commands that are common to both, and other commands such as guest-file-* which *may* be portable. So we introduce commands.c for the latter, and will rename guest-agent-commands.c to commands-posix.c in a future commit. Windows implementations will go in commands-win32.c, eventually. Signed-off-by: Michael Roth mdr...@linux.vnet.ibm.com --- Makefile.objs |2 +- qga/commands.c | 73 qga/guest-agent-commands.c | 59 +--- qga/guest-agent-core.h |1 + 4 files changed, 76 insertions(+), 59 deletions(-) create mode 100644 qga/commands.c diff --git a/Makefile.objs b/Makefile.objs index 27ff919..d70cebe 100644 --- a/Makefile.objs +++ b/Makefile.objs @@ -424,7 +424,7 @@ common-obj-y += qmp.o hmp.o ## # guest agent -qga-nested-y = guest-agent-commands.o guest-agent-command-state.o +qga-nested-y = commands.o guest-agent-commands.o guest-agent-command-state.o qga-nested-y += channel-posix.o qga-obj-y = $(addprefix qga/, $(qga-nested-y)) qga-obj-y += qemu-ga.o qemu-sockets.o module.o qemu-option.o diff --git a/qga/commands.c b/qga/commands.c new file mode 100644 index 000..b27407d --- /dev/null +++ b/qga/commands.c @@ -0,0 +1,73 @@ +/* + * QEMU Guest Agent common/cross-platform command implementations + * + * Copyright IBM Corp. 2012 + * + * Authors: + * Michael Roth mdr...@linux.vnet.ibm.com + * + * This work is licensed under the terms of the GNU GPL, version 2 or later. + * See the COPYING file in the top-level directory. + */ + +#include glib.h +#include qga/guest-agent-core.h +#include qga-qmp-commands.h +#include qerror.h + +/* Note: in some situations, like with the fsfreeze, logging may be + * temporarilly disabled. if it is necessary that a command be able + * to log for accounting purposes, check ga_logging_enabled() beforehand, + * and use the QERR_QGA_LOGGING_DISABLED to generate an error + */ +void slog(const gchar *fmt, ...) +{ +va_list ap; + +va_start(ap, fmt); +g_logv(syslog, G_LOG_LEVEL_INFO, fmt, ap); +va_end(ap); +} + +int64_t qmp_guest_sync(int64_t id, Error **errp) +{ +return id; +} + +void qmp_guest_ping(Error **err) +{ +slog(guest-ping called); +} + +struct GuestAgentInfo *qmp_guest_info(Error **err) +{ +GuestAgentInfo *info = g_malloc0(sizeof(GuestAgentInfo)); +GuestAgentCommandInfo *cmd_info; +GuestAgentCommandInfoList *cmd_info_list; +char **cmd_list_head, **cmd_list; + +info-version = g_strdup(QGA_VERSION); + +cmd_list_head = cmd_list = qmp_get_command_list(); +if (*cmd_list_head == NULL) { +goto out; +} + +while (*cmd_list) { +cmd_info = g_malloc0(sizeof(GuestAgentCommandInfo)); +cmd_info-name = strdup(*cmd_list); +cmd_info-enabled = qmp_command_is_enabled(cmd_info-name); + +cmd_info_list = g_malloc0(sizeof(GuestAgentCommandInfoList)); +cmd_info_list-value = cmd_info; +cmd_info_list-next = info-supported_commands; +info-supported_commands = cmd_info_list; + +g_free(*cmd_list); +cmd_list++; +} + +out: +g_free(cmd_list_head); +return info; +} diff --git a/qga/guest-agent-commands.c b/qga/guest-agent-commands.c index a09c8ca..126127a 100644 --- a/qga/guest-agent-commands.c +++ b/qga/guest-agent-commands.c @@ -1,5 +1,5 @@ /* - * QEMU Guest Agent commands + * QEMU Guest Agent POSIX-specific command implementations * * Copyright IBM Corp. 2011 * @@ -30,63 +30,6 @@ static GAState *ga_state; -/* Note: in some situations, like with the fsfreeze, logging may be - * temporarilly disabled. if it is necessary that a command be able - * to log for accounting purposes, check ga_logging_enabled() beforehand, - * and use the QERR_QGA_LOGGING_DISABLED to generate an error - */ -static void slog(const char *fmt, ...) -{ -va_list ap; - -va_start(ap, fmt); -g_logv(syslog, G_LOG_LEVEL_INFO, fmt, ap); -va_end(ap); -} - -int64_t qmp_guest_sync(int64_t id, Error **errp) -{ -return id; -} - -void qmp_guest_ping(Error **err) -{ -slog(guest-ping called); -} - -struct GuestAgentInfo *qmp_guest_info(Error **err) -{ -GuestAgentInfo *info = g_malloc0(sizeof(GuestAgentInfo)); -GuestAgentCommandInfo *cmd_info; -GuestAgentCommandInfoList *cmd_info_list; -char **cmd_list_head, **cmd_list; - -info-version = g_strdup(QGA_VERSION); - -cmd_list_head = cmd_list = qmp_get_command_list(); -if (*cmd_list_head == NULL) { -goto out; -} - -while (*cmd_list) { -cmd_info = g_malloc0(sizeof(GuestAgentCommandInfo)); -cmd_info-name = strdup(*cmd_list); -cmd_info-enabled = qmp_command_is_enabled(cmd_info-name); - -
Re: [Qemu-devel] [PATCH 01/16] qdev: fix hot-unplug
On 02.02.2012, at 21:03, Anthony Liguori wrote: On 02/02/2012 01:07 PM, Alexander Graf wrote: On 02.02.2012, at 20:01, Anthony Liguori wrote: On 02/02/2012 11:29 AM, Paolo Bonzini wrote: On 02/02/2012 06:03 PM, Anthony Liguori wrote: Is this still needed with qom-upstream.14? I fixed a bug on .14 that involved child properties that was making device-del sometimes fail. Not sure, I tried with .13 but, from the look of it, it should still be there. Regarding the .13-.14 diff: - you need QTAILQ_FOREACH_SAFE in object_property_del_child. Ack. - you need to check for the existence of the non-aliased name when accessing the alias table, because s390 does not have PCI. I don't think that's the right strategy as it means that s390 only works if we don't include the PCI objects in the build (regardless of whether it uses PCI). This would be defeated if/when we move to having all device objects in a single shared library used by all of the qemu executables. I'd prefer to just drop the aliases for s390. I don't see a lot of value in it and I don't think there are tons of s390 users that will be affected. The reason for the aliases is to make -drive and -net work. If you have alternatives to aliases there, I'm happy to go with them. We can simply do a const char *target_get_virtio_net_type(void) in arch_init.c. Not pretty, but we can later fix the -drive/-net calls to not require this. Anything that works. The only reason to have the aliases for me really was to not have target awareness in -drive and -net. So if you're feeling better with an arch callback, I'm definitely fine with that too. Alex
[Qemu-devel] [PATCH v2 6/8] qemu-ga: add initial win32 support
This adds a win32 channel implementation that makes qemu-ga functional on Windows using virtio-serial (unix-listen/isa-serial not currently implemented). Unlike with the posix implementation, we do not use GIOChannel for the following reasons: - glib calls stat() on an fd to check whether S_IFCHR is set, which is the case for virtio-serial on win32. Because of that, a one-time check to determine whether the channel is readable is done by making a call to PeekConsoleInput(), which reports the underlying handle is not a valid console handle, and thus we can never read from the channel. - if one goes as far as to trick glib into thinking it is a normal file descripter, the buffering is done in such a way that data written to the output stream will subsequently result in that same data being read back as if it were input, causing an error loop. furthermore, a forced flush of the channel only moves the data into a secondary buffer managed by glib, so there's no way to prevent output from getting read back as input. The implementation here ties into the glib main loop by implementing a custom GSource that continually submits asynchronous/overlapped I/O to fill an GAChannel-managed read buffer, and tells glib to poll the corresponding event handle for a completion whenever there is no data/RPC in the read buffer to notify the main application about. Signed-off-by: Michael Roth mdr...@linux.vnet.ibm.com --- Makefile.objs |2 +- qemu-ga.c |4 + qga/channel-win32.c | 337 +++ 3 files changed, 342 insertions(+), 1 deletions(-) create mode 100644 qga/channel-win32.c diff --git a/Makefile.objs b/Makefile.objs index 18e79ce..e1cb54a 100644 --- a/Makefile.objs +++ b/Makefile.objs @@ -426,7 +426,7 @@ common-obj-y += qmp.o hmp.o qga-nested-y = commands.o guest-agent-command-state.o qga-nested-$(CONFIG_POSIX) += commands-posix.o channel-posix.o -qga-nested-$(CONFIG_WIN32) += commands-win32.o +qga-nested-$(CONFIG_WIN32) += commands-win32.o channel-win32.o qga-obj-y = $(addprefix qga/, $(qga-nested-y)) qga-obj-y += qemu-ga.o module.o qga-obj-$(CONFIG_WIN32) += oslib-win32.o diff --git a/qemu-ga.c b/qemu-ga.c index 93ebc3e..8e517b5 100644 --- a/qemu-ga.c +++ b/qemu-ga.c @@ -30,7 +30,11 @@ #include qapi/qmp-core.h #include qga/channel.h +#ifndef _WIN32 #define QGA_VIRTIO_PATH_DEFAULT /dev/virtio-ports/org.qemu.guest_agent.0 +#else +#define QGA_VIRTIO_PATH_DEFAULT .\\Global\\org.qemu.guest_agent.0 +#endif #define QGA_PIDFILE_DEFAULT /var/run/qemu-ga.pid struct GAState { diff --git a/qga/channel-win32.c b/qga/channel-win32.c new file mode 100644 index 000..9d8601a --- /dev/null +++ b/qga/channel-win32.c @@ -0,0 +1,337 @@ +#include stdlib.h +#include stdio.h +#include stdbool.h +#include glib.h +#include windows.h +#include errno.h +#include io.h +#include qga/guest-agent-core.h +#include qga/channel.h + +typedef struct GAChannelReadState { +guint thread_id; +uint8_t *buf; +size_t buf_size; +size_t cur; /* current buffer start */ +size_t pending; /* pending buffered bytes to read */ +OVERLAPPED ov; +bool ov_pending; /* whether on async read is outstanding */ +} GAChannelReadState; + +struct GAChannel { +HANDLE handle; +GAChannelCallback cb; +gpointer user_data; +GAChannelReadState rstate; +GIOCondition pending_events; /* TODO: use GAWatch.pollfd.revents */ +GSource *source; +}; + +typedef struct GAWatch { +GSource source; +GPollFD pollfd; +GAChannel *channel; +GIOCondition events_mask; +} GAWatch; + +/* + * Called by glib prior to polling to set up poll events if polling is needed. + * + */ +static gboolean ga_channel_prepare(GSource *source, gint *timeout_ms) +{ +GAWatch *watch = (GAWatch *)source; +GAChannel *c = (GAChannel *)watch-channel; +GAChannelReadState *rs = c-rstate; +DWORD count_read, count_to_read = 0; +bool success; +GIOCondition new_events = 0; + +g_debug(prepare); +/* go ahead and submit another read if there's room in the buffer + * and no previous reads are outstanding + */ +if (!rs-ov_pending) { +if (rs-cur + rs-pending = rs-buf_size) { +if (rs-cur) { +memmove(rs-buf, rs-buf + rs-cur, rs-pending); +rs-cur = 0; +} +} +count_to_read = rs-buf_size - rs-cur - rs-pending; +} + +if (rs-ov_pending || count_to_read = 0) { +goto out; +} + +/* submit the read */ +success = ReadFile(c-handle, rs-buf + rs-cur + rs-pending, + count_to_read, count_read, rs-ov); +if (success) { +rs-pending += count_read; +rs-ov_pending = false; +} else { +if (GetLastError() == ERROR_IO_PENDING) { +rs-ov_pending = true; +} else { +new_events |= G_IO_ERR; +} +} + +out: +/* dont block
[Qemu-devel] [PATCH v2 4/8] qemu-ga: rename guest-agent-commands.c - commands-posix.c
Signed-off-by: Michael Roth mdr...@linux.vnet.ibm.com --- Makefile.objs |2 +- qga/commands-posix.c | 528 qga/guest-agent-commands.c | 528 3 files changed, 529 insertions(+), 529 deletions(-) create mode 100644 qga/commands-posix.c delete mode 100644 qga/guest-agent-commands.c diff --git a/Makefile.objs b/Makefile.objs index d70cebe..2e2efb4 100644 --- a/Makefile.objs +++ b/Makefile.objs @@ -424,7 +424,7 @@ common-obj-y += qmp.o hmp.o ## # guest agent -qga-nested-y = commands.o guest-agent-commands.o guest-agent-command-state.o +qga-nested-y = commands.o commands-posix.o guest-agent-command-state.o qga-nested-y += channel-posix.o qga-obj-y = $(addprefix qga/, $(qga-nested-y)) qga-obj-y += qemu-ga.o qemu-sockets.o module.o qemu-option.o diff --git a/qga/commands-posix.c b/qga/commands-posix.c new file mode 100644 index 000..126127a --- /dev/null +++ b/qga/commands-posix.c @@ -0,0 +1,528 @@ +/* + * QEMU Guest Agent POSIX-specific command implementations + * + * Copyright IBM Corp. 2011 + * + * Authors: + * Michael Roth mdr...@linux.vnet.ibm.com + * + * This work is licensed under the terms of the GNU GPL, version 2 or later. + * See the COPYING file in the top-level directory. + */ + +#include glib.h + +#if defined(__linux__) +#include mntent.h +#include linux/fs.h + +#if defined(__linux__) defined(FIFREEZE) +#define CONFIG_FSFREEZE +#endif +#endif + +#include sys/types.h +#include sys/ioctl.h +#include qga/guest-agent-core.h +#include qga-qmp-commands.h +#include qerror.h +#include qemu-queue.h + +static GAState *ga_state; + +void qmp_guest_shutdown(bool has_mode, const char *mode, Error **err) +{ +int ret; +const char *shutdown_flag; + +slog(guest-shutdown called, mode: %s, mode); +if (!has_mode || strcmp(mode, powerdown) == 0) { +shutdown_flag = -P; +} else if (strcmp(mode, halt) == 0) { +shutdown_flag = -H; +} else if (strcmp(mode, reboot) == 0) { +shutdown_flag = -r; +} else { +error_set(err, QERR_INVALID_PARAMETER_VALUE, mode, + halt|powerdown|reboot); +return; +} + +ret = fork(); +if (ret == 0) { +/* child, start the shutdown */ +setsid(); +fclose(stdin); +fclose(stdout); +fclose(stderr); + +ret = execl(/sbin/shutdown, shutdown, shutdown_flag, +0, +hypervisor initiated shutdown, (char*)NULL); +if (ret) { +slog(guest-shutdown failed: %s, strerror(errno)); +} +exit(!!ret); +} else if (ret 0) { +error_set(err, QERR_UNDEFINED_ERROR); +} +} + +typedef struct GuestFileHandle { +uint64_t id; +FILE *fh; +QTAILQ_ENTRY(GuestFileHandle) next; +} GuestFileHandle; + +static struct { +QTAILQ_HEAD(, GuestFileHandle) filehandles; +} guest_file_state; + +static void guest_file_handle_add(FILE *fh) +{ +GuestFileHandle *gfh; + +gfh = g_malloc0(sizeof(GuestFileHandle)); +gfh-id = fileno(fh); +gfh-fh = fh; +QTAILQ_INSERT_TAIL(guest_file_state.filehandles, gfh, next); +} + +static GuestFileHandle *guest_file_handle_find(int64_t id) +{ +GuestFileHandle *gfh; + +QTAILQ_FOREACH(gfh, guest_file_state.filehandles, next) +{ +if (gfh-id == id) { +return gfh; +} +} + +return NULL; +} + +int64_t qmp_guest_file_open(const char *path, bool has_mode, const char *mode, Error **err) +{ +FILE *fh; +int fd; +int64_t ret = -1; + +if (!has_mode) { +mode = r; +} +slog(guest-file-open called, filepath: %s, mode: %s, path, mode); +fh = fopen(path, mode); +if (!fh) { +error_set(err, QERR_OPEN_FILE_FAILED, path); +return -1; +} + +/* set fd non-blocking to avoid common use cases (like reading from a + * named pipe) from hanging the agent + */ +fd = fileno(fh); +ret = fcntl(fd, F_GETFL); +ret = fcntl(fd, F_SETFL, ret | O_NONBLOCK); +if (ret == -1) { +error_set(err, QERR_QGA_COMMAND_FAILED, fcntl() failed); +fclose(fh); +return -1; +} + +guest_file_handle_add(fh); +slog(guest-file-open, handle: %d, fd); +return fd; +} + +void qmp_guest_file_close(int64_t handle, Error **err) +{ +GuestFileHandle *gfh = guest_file_handle_find(handle); +int ret; + +slog(guest-file-close called, handle: %ld, handle); +if (!gfh) { +error_set(err, QERR_FD_NOT_FOUND, handle); +return; +} + +ret = fclose(gfh-fh); +if (ret == -1) { +error_set(err, QERR_QGA_COMMAND_FAILED, fclose() failed); +return; +} + +QTAILQ_REMOVE(guest_file_state.filehandles, gfh, next); +g_free(gfh); +} + +struct GuestFileRead *qmp_guest_file_read(int64_t handle, bool has_count, +
[Qemu-devel] [PATCH v2 7/8] qemu-ga: add Windows service integration
This allows qemu-ga to function as a Windows service: - to install the service (will auto-start on boot): qemu-ga --service install - to start the service: net start qemu-ga - to stop the service: net stop qemu-ga - to uninstall service: qemu-ga --service uninstall Original patch by Gal Hammer gham...@redhat.com Signed-off-by: Michael Roth mdr...@linux.vnet.ibm.com --- Makefile.objs |2 +- qemu-ga.c | 103 -- qga/service-win32.c | 114 +++ qga/service-win32.h | 30 + 4 files changed, 244 insertions(+), 5 deletions(-) create mode 100644 qga/service-win32.c create mode 100644 qga/service-win32.h diff --git a/Makefile.objs b/Makefile.objs index e1cb54a..3b08e70 100644 --- a/Makefile.objs +++ b/Makefile.objs @@ -426,7 +426,7 @@ common-obj-y += qmp.o hmp.o qga-nested-y = commands.o guest-agent-command-state.o qga-nested-$(CONFIG_POSIX) += commands-posix.o channel-posix.o -qga-nested-$(CONFIG_WIN32) += commands-win32.o channel-win32.o +qga-nested-$(CONFIG_WIN32) += commands-win32.o channel-win32.o service-win32.o qga-obj-y = $(addprefix qga/, $(qga-nested-y)) qga-obj-y += qemu-ga.o module.o qga-obj-$(CONFIG_WIN32) += oslib-win32.o diff --git a/qemu-ga.c b/qemu-ga.c index 8e517b5..92f81ed 100644 --- a/qemu-ga.c +++ b/qemu-ga.c @@ -29,6 +29,10 @@ #include error_int.h #include qapi/qmp-core.h #include qga/channel.h +#ifdef _WIN32 +#include qga/service-win32.h +#include windows.h +#endif #ifndef _WIN32 #define QGA_VIRTIO_PATH_DEFAULT /dev/virtio-ports/org.qemu.guest_agent.0 @@ -46,11 +50,19 @@ struct GAState { GLogLevelFlags log_level; FILE *log_file; bool logging_enabled; +#ifdef _WIN32 +GAService service; +#endif }; static struct GAState *ga_state; -#ifndef _WIN32 +#ifdef _WIN32 +DWORD WINAPI service_ctrl_handler(DWORD ctrl, DWORD type, LPVOID data, + LPVOID ctx); +VOID WINAPI service_main(DWORD argc, TCHAR *argv[]); +#endif + static void quit_handler(int sig) { g_debug(received signal num %d, quitting, sig); @@ -60,6 +72,7 @@ static void quit_handler(int sig) } } +#ifndef _WIN32 static gboolean register_signal_handlers(void) { struct sigaction sigact; @@ -95,8 +108,9 @@ static void usage(const char *cmd) -f, --pidfile specify pidfile (default is %s)\n -v, --verbose log extra debugging information\n -V, --version print version information and exit\n -#ifndef _WIN32 -d, --daemonize become a daemon\n +#ifdef _WIN32 + -s, --service service commands: install, uninstall\n #endif -b, --blacklist comma-separated list of RPCs to disable (no spaces, \?\ to list available RPCs)\n @@ -394,10 +408,64 @@ static gboolean channel_init(GAState *s, const gchar *method, const gchar *path) return true; } +#ifdef _WIN32 +DWORD WINAPI service_ctrl_handler(DWORD ctrl, DWORD type, LPVOID data, + LPVOID ctx) +{ +DWORD ret = NO_ERROR; +GAService *service = ga_state-service; + +switch (ctrl) +{ +case SERVICE_CONTROL_STOP: +case SERVICE_CONTROL_SHUTDOWN: +quit_handler(SIGTERM); +service-status.dwCurrentState = SERVICE_STOP_PENDING; +SetServiceStatus(service-status_handle, service-status); +break; + +default: +ret = ERROR_CALL_NOT_IMPLEMENTED; +} +return ret; +} + +VOID WINAPI service_main(DWORD argc, TCHAR *argv[]) +{ +GAService *service = ga_state-service; + +service-status_handle = RegisterServiceCtrlHandlerEx(QGA_SERVICE_NAME, +service_ctrl_handler, NULL); + +if (service-status_handle == 0) { +g_critical(Failed to register extended requests function!\n); +return; +} + +service-status.dwServiceType = SERVICE_WIN32; +service-status.dwCurrentState = SERVICE_RUNNING; +service-status.dwControlsAccepted = SERVICE_ACCEPT_STOP | SERVICE_ACCEPT_SHUTDOWN; +service-status.dwWin32ExitCode = NO_ERROR; +service-status.dwServiceSpecificExitCode = NO_ERROR; +service-status.dwCheckPoint = 0; +service-status.dwWaitHint = 0; +SetServiceStatus(service-status_handle, service-status); + +g_main_loop_run(ga_state-main_loop); + +service-status.dwCurrentState = SERVICE_STOPPED; +SetServiceStatus(service-status_handle, service-status); +} +#endif + int main(int argc, char **argv) { -const char *sopt = hVvdm:p:l:f:b:; +const char *sopt = hVvdm:p:l:f:b:s:; const char *method = NULL, *path = NULL, *pidfile = QGA_PIDFILE_DEFAULT; +const char *log_file_name = NULL; +#ifdef _WIN32 +const char *service = NULL; +#endif const struct option lopt[] = { { help, 0, NULL, 'h' }, { version, 0, NULL, 'V' }, @@ -408,6 +476,9 @@ int main(int argc, char **argv) { path, 0, NULL, 'p' },
[Qemu-devel] [PATCH v2 5/8] qemu-ga: fixes for win32 build of qemu-ga
Various stubs and #ifdefs to compile for Windows using mingw cross-build. Still has 1 linker error due to a dependency on the forthcoming win32 versions of the GAChannel/transport class. Signed-off-by: Michael Roth mdr...@linux.vnet.ibm.com --- Makefile |2 +- Makefile.objs|9 +++-- configure|2 +- qemu-ga.c| 16 + qga/commands-win32.c | 91 ++ 5 files changed, 114 insertions(+), 6 deletions(-) create mode 100644 qga/commands-win32.c diff --git a/Makefile b/Makefile index 2560b59..9baa532 100644 --- a/Makefile +++ b/Makefile @@ -199,7 +199,7 @@ QGALIB_GEN=$(addprefix $(qapi-dir)/, qga-qapi-types.h qga-qapi-visit.h qga-qmp-c $(QGALIB_OBJ): $(QGALIB_GEN) $(GENERATED_HEADERS) $(qga-obj-y) qemu-ga.o: $(QGALIB_GEN) $(GENERATED_HEADERS) -qemu-ga$(EXESUF): qemu-ga.o $(qga-obj-y) $(qapi-obj-y) $(tools-obj-y) $(qobject-obj-y) $(version-obj-y) $(QGALIB_OBJ) +qemu-ga$(EXESUF): qemu-ga.o $(qga-obj-y) $(tools-obj-y) $(qapi-obj-y) $(qobject-obj-y) $(version-obj-y) $(QGALIB_OBJ) QEMULIBS=libhw32 libhw64 libuser libdis libdis-user diff --git a/Makefile.objs b/Makefile.objs index 2e2efb4..18e79ce 100644 --- a/Makefile.objs +++ b/Makefile.objs @@ -424,12 +424,13 @@ common-obj-y += qmp.o hmp.o ## # guest agent -qga-nested-y = commands.o commands-posix.o guest-agent-command-state.o -qga-nested-y += channel-posix.o +qga-nested-y = commands.o guest-agent-command-state.o +qga-nested-$(CONFIG_POSIX) += commands-posix.o channel-posix.o +qga-nested-$(CONFIG_WIN32) += commands-win32.o qga-obj-y = $(addprefix qga/, $(qga-nested-y)) -qga-obj-y += qemu-ga.o qemu-sockets.o module.o qemu-option.o +qga-obj-y += qemu-ga.o module.o qga-obj-$(CONFIG_WIN32) += oslib-win32.o -qga-obj-$(CONFIG_POSIX) += oslib-posix.o +qga-obj-$(CONFIG_POSIX) += oslib-posix.o qemu-sockets.o qemu-option.o vl.o: QEMU_CFLAGS+=$(GPROF_CFLAGS) diff --git a/configure b/configure index 3b0b300..aaf8171 100755 --- a/configure +++ b/configure @@ -508,7 +508,7 @@ if test $mingw32 = yes ; then bindir=\${prefix} sysconfdir=\${prefix} confsuffix= - guest_agent=no + libs_qga=-lws2_32 -lwinmm $lib_qga fi werror= diff --git a/qemu-ga.c b/qemu-ga.c index 2e8af02..93ebc3e 100644 --- a/qemu-ga.c +++ b/qemu-ga.c @@ -15,7 +15,9 @@ #include stdbool.h #include glib.h #include getopt.h +#ifndef _WIN32 #include syslog.h +#endif #include json-streamer.h #include json-parser.h #include qint.h @@ -44,6 +46,7 @@ struct GAState { static struct GAState *ga_state; +#ifndef _WIN32 static void quit_handler(int sig) { g_debug(received signal num %d, quitting, sig); @@ -73,6 +76,7 @@ static gboolean register_signal_handlers(void) } return true; } +#endif static void usage(const char *cmd) { @@ -87,7 +91,9 @@ static void usage(const char *cmd) -f, --pidfile specify pidfile (default is %s)\n -v, --verbose log extra debugging information\n -V, --version print version information and exit\n +#ifndef _WIN32 -d, --daemonize become a daemon\n +#endif -b, --blacklist comma-separated list of RPCs to disable (no spaces, \?\ to list available RPCs)\n -h, --helpdisplay this help and exit\n @@ -143,9 +149,13 @@ static void ga_log(const gchar *domain, GLogLevelFlags level, } level = G_LOG_LEVEL_MASK; +#ifndef _WIN32 if (domain strcmp(domain, syslog) == 0) { syslog(LOG_INFO, %s: %s, level_str, msg); } else if (level s-log_level) { +#else +if (level s-log_level) { +#endif g_get_current_time(time); fprintf(s-log_file, %lu.%lu: %s: %s\n, time.tv_sec, time.tv_usec, level_str, msg); @@ -153,6 +163,7 @@ static void ga_log(const gchar *domain, GLogLevelFlags level, } } +#ifndef _WIN32 static void become_daemon(const char *pidfile) { pid_t pid, sid; @@ -203,6 +214,7 @@ fail: g_critical(failed to daemonize); exit(EXIT_FAILURE); } +#endif static int send_response(GAState *s, QObject *payload) { @@ -466,10 +478,12 @@ int main(int argc, char **argv) } } +#ifndef _WIN32 if (daemonize) { g_debug(starting daemon); become_daemon(pidfile); } +#endif s = g_malloc0(sizeof(GAState)); s-log_file = log_file; @@ -482,10 +496,12 @@ int main(int argc, char **argv) ga_command_state_init_all(s-command_state); json_message_parser_init(s-parser, process_event); ga_state = s; +#ifndef _WIN32 if (!register_signal_handlers()) { g_critical(failed to register signal handlers); goto out_bad; } +#endif s-main_loop = g_main_loop_new(NULL, false); if (!channel_init(ga_state, method, path)) { diff --git a/qga/commands-win32.c b/qga/commands-win32.c new file mode 100644 index 000..d96f1ad --- /dev/null +++
Re: [Qemu-devel] [PATCH 04/16] qom: add QObject-based property get/set wrappers
On 02/02/2012 01:21 PM, Andreas Färber wrote: Am 02.02.2012 20:06, schrieb Anthony Liguori: On 02/02/2012 10:45 AM, Paolo Bonzini wrote: Move the creation of QmpInputVisitor and QmpOutputVisitor from qmp.c to qom/object.c, since it's the only practical way to access object properties. Signed-off-by: Paolo Bonzinipbonz...@redhat.com --- include/qemu/object.h | 24 qmp.c | 17 ++--- qom/object.c | 29 + 3 files changed, 55 insertions(+), 15 deletions(-) I don't want object.h to have a dependency on QObject. We need to phase out QObject. We did get that dependency though by your move of the property code to object.c. As you will see shortly, we now need qobject-obj-y and qapi-obj-y plus some stubs to make the user emulators compile with QOM. That's an implementation detail of Error, that's not because QObject is used anywhere in QOM. Regards, Anthony Liguori Andreas
Re: [Qemu-devel] [PATCH 04/16] qom: add QObject-based property get/set wrappers
On 02/02/2012 02:08 PM, Paolo Bonzini wrote: On 02/02/2012 08:36 PM, Anthony Liguori wrote: The only types that matter are int and string so the variant visitor is pretty simple. Sure, only ~150 lines of code. I also do not disagree with the goals (mine and yours), just with the priorities. :) That's fine, it's a priority for me, so I'm happy to send a patch to your series. I think it's important to maintain strict modularity at the core layer of QOM. Regards, Anthony Liguori Paolo
[Qemu-devel] [PATCH 02/15] target-alpha: Clean includes
The change in cpu.h is needed when HOST_LONG_BITS is defined in qemu-common.h. Cc: Richard Henderson r...@twiddle.net Signed-off-by: Stefan Weil s...@weilnetz.de --- target-alpha/cpu.h |1 + target-alpha/translate.c |5 - 2 files changed, 1 insertions(+), 5 deletions(-) diff --git a/target-alpha/cpu.h b/target-alpha/cpu.h index 9d61d45..5cd6fd8 100644 --- a/target-alpha/cpu.h +++ b/target-alpha/cpu.h @@ -21,6 +21,7 @@ #define __CPU_ALPHA_H__ #include config.h +#include qemu-common.h #define TARGET_LONG_BITS 64 diff --git a/target-alpha/translate.c b/target-alpha/translate.c index a961159..1d2142b 100644 --- a/target-alpha/translate.c +++ b/target-alpha/translate.c @@ -17,15 +17,10 @@ * License along with this library; if not, see http://www.gnu.org/licenses/. */ -#include stdint.h -#include stdlib.h -#include stdio.h - #include cpu.h #include disas.h #include host-utils.h #include tcg-op.h -#include qemu-common.h #include helper.h #define GEN_HELPER 1 -- 1.7.7.3
[Qemu-devel] [PATCH 15/15] Move definition of HOST_LONG_BITS to qemu-common.h
Like the related macro TCG_TARGET_LONG, HOST_LONG_BITS can be determined by the C preprocessor. It is also not used in Makefiles. So there is no need to calculate it in configure, and it can be defined in qemu-common.h. Signed-off-by: Stefan Weil s...@weilnetz.de --- configure | 12 qemu-common.h |9 + 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/configure b/configure index 3b0b300..6dec57d 100755 --- a/configure +++ b/configure @@ -1266,17 +1266,6 @@ esac fi -# host long bits test, actually a pointer size test -cat $TMPC EOF -int sizeof_pointer_is_8[sizeof(void *) == 8 ? 1 : -1]; -EOF -if compile_object; then -hostlongbits=64 -else -hostlongbits=32 -fi - - ## # NPTL probe @@ -2927,7 +2916,6 @@ fi if test $bigendian = yes ; then echo HOST_WORDS_BIGENDIAN=y $config_host_mak fi -echo HOST_LONG_BITS=$hostlongbits $config_host_mak if test $mingw32 = yes ; then echo CONFIG_WIN32=y $config_host_mak rc_version=`cat $source_path/VERSION` diff --git a/qemu-common.h b/qemu-common.h index 8b69a9e..bd0b1bd 100644 --- a/qemu-common.h +++ b/qemu-common.h @@ -65,6 +65,15 @@ typedef struct Monitor Monitor; #define TIME_MAX LONG_MAX #endif +/* HOST_LONG_BITS is the size of a native pointer in bits. */ +#if UINTPTR_MAX == UINT32_MAX +# define HOST_LONG_BITS 32 +#elif UINTPTR_MAX == UINT64_MAX +# define HOST_LONG_BITS 64 +#else +# error Unknown pointer size +#endif + #ifndef CONFIG_IOVEC #define CONFIG_IOVEC struct iovec { -- 1.7.7.3
[Qemu-devel] [PATCH 09/15] target-mips: Clean includes
Remove some include statements which are not needed. Cc: Aurelien Jarno aurel...@aurel32.net Signed-off-by: Stefan Weil s...@weilnetz.de --- target-mips/translate.c |7 --- 1 files changed, 0 insertions(+), 7 deletions(-) diff --git a/target-mips/translate.c b/target-mips/translate.c index d5b1c76..8361d88 100644 --- a/target-mips/translate.c +++ b/target-mips/translate.c @@ -20,16 +20,9 @@ * License along with this library; if not, see http://www.gnu.org/licenses/. */ -#include stdarg.h -#include stdlib.h -#include stdio.h -#include string.h -#include inttypes.h - #include cpu.h #include disas.h #include tcg-op.h -#include qemu-common.h #include helper.h #define GEN_HELPER 1 -- 1.7.7.3
[Qemu-devel] [PATCH 05/15] target-i386: Clean includes
Remove some include statements which are not needed. Signed-off-by: Stefan Weil s...@weilnetz.de --- target-i386/helper.c|6 -- target-i386/op_helper.c |1 - 2 files changed, 0 insertions(+), 7 deletions(-) diff --git a/target-i386/helper.c b/target-i386/helper.c index 2586aff..87c6a8f 100644 --- a/target-i386/helper.c +++ b/target-i386/helper.c @@ -16,14 +16,8 @@ * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, see http://www.gnu.org/licenses/. */ -#include stdarg.h -#include stdlib.h -#include stdio.h -#include string.h -#include inttypes.h #include cpu.h -#include qemu-common.h #include kvm.h #ifndef CONFIG_USER_ONLY #include sysemu.h diff --git a/target-i386/op_helper.c b/target-i386/op_helper.c index 1005b01..51a3b52 100644 --- a/target-i386/op_helper.c +++ b/target-i386/op_helper.c @@ -22,7 +22,6 @@ #include dyngen-exec.h #include host-utils.h #include ioport.h -#include qemu-common.h #include qemu-log.h #include cpu-defs.h #include helper.h -- 1.7.7.3
[Qemu-devel] [PATCH 11/15] target-s390x: Clean includes
The change in cpu.h is needed when HOST_LONG_BITS is defined in qemu-common.h. Signed-off-by: Stefan Weil s...@weilnetz.de --- target-s390x/cpu.h |3 +++ target-s390x/helper.c|5 - target-s390x/translate.c |5 - 3 files changed, 3 insertions(+), 10 deletions(-) diff --git a/target-s390x/cpu.h b/target-s390x/cpu.h index b8893b3..e892bec 100644 --- a/target-s390x/cpu.h +++ b/target-s390x/cpu.h @@ -19,6 +19,9 @@ #ifndef CPU_S390X_H #define CPU_S390X_H +#include config.h +#include qemu-common.h + #define TARGET_LONG_BITS 64 #define ELF_MACHINEEM_S390 diff --git a/target-s390x/helper.c b/target-s390x/helper.c index 10cc9dd..c0ec890 100644 --- a/target-s390x/helper.c +++ b/target-s390x/helper.c @@ -18,13 +18,8 @@ * License along with this library; if not, see http://www.gnu.org/licenses/. */ -#include stdio.h -#include stdlib.h -#include string.h - #include cpu.h #include gdbstub.h -#include qemu-common.h #include qemu-timer.h #ifndef CONFIG_USER_ONLY #include sysemu.h diff --git a/target-s390x/translate.c b/target-s390x/translate.c index ee15672..71f9dcd 100644 --- a/target-s390x/translate.c +++ b/target-s390x/translate.c @@ -17,11 +17,6 @@ * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, see http://www.gnu.org/licenses/. */ -#include stdarg.h -#include stdlib.h -#include stdio.h -#include string.h -#include inttypes.h /* #define DEBUG_ILLEGAL_INSTRUCTIONS */ /* #define DEBUG_INLINE_BRANCHES */ -- 1.7.7.3
[Qemu-devel] [PATCH 14/15] target-xtensa: Clean includes
Remove some include statements which are not needed. Cc: Max Filippov jcmvb...@gmail.com Signed-off-by: Stefan Weil s...@weilnetz.de --- target-xtensa/core-dc232b.c |1 - target-xtensa/core-fsf.c|1 - target-xtensa/helper.c |1 - 3 files changed, 0 insertions(+), 3 deletions(-) diff --git a/target-xtensa/core-dc232b.c b/target-xtensa/core-dc232b.c index 4d9bd55..21b287d 100644 --- a/target-xtensa/core-dc232b.c +++ b/target-xtensa/core-dc232b.c @@ -1,7 +1,6 @@ #include cpu.h #include exec-all.h #include gdbstub.h -#include qemu-common.h #include host-utils.h #include core-dc232b/core-isa.h diff --git a/target-xtensa/core-fsf.c b/target-xtensa/core-fsf.c index 7650462..763b8e5 100644 --- a/target-xtensa/core-fsf.c +++ b/target-xtensa/core-fsf.c @@ -1,7 +1,6 @@ #include cpu.h #include exec-all.h #include gdbstub.h -#include qemu-common.h #include host-utils.h #include core-fsf/core-isa.h diff --git a/target-xtensa/helper.c b/target-xtensa/helper.c index 2a0cb1a..1264c83 100644 --- a/target-xtensa/helper.c +++ b/target-xtensa/helper.c @@ -28,7 +28,6 @@ #include cpu.h #include exec-all.h #include gdbstub.h -#include qemu-common.h #include host-utils.h #if !defined(CONFIG_USER_ONLY) #include hw/loader.h -- 1.7.7.3
[Qemu-devel] [PATCH 10/15] target-ppc: Clean includes
Remove some include statements which are not needed. Cc: Alexander Graf ag...@suse.de Signed-off-by: Stefan Weil s...@weilnetz.de --- target-ppc/helper.c|6 -- target-ppc/translate.c |6 -- 2 files changed, 0 insertions(+), 12 deletions(-) diff --git a/target-ppc/helper.c b/target-ppc/helper.c index 5847453..455dcc0 100644 --- a/target-ppc/helper.c +++ b/target-ppc/helper.c @@ -16,15 +16,9 @@ * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, see http://www.gnu.org/licenses/. */ -#include stdarg.h -#include stdlib.h -#include stdio.h -#include string.h -#include inttypes.h #include cpu.h #include helper_regs.h -#include qemu-common.h #include kvm.h #include kvm_ppc.h #include cpus.h diff --git a/target-ppc/translate.c b/target-ppc/translate.c index 66eae30..74ad855 100644 --- a/target-ppc/translate.c +++ b/target-ppc/translate.c @@ -17,16 +17,10 @@ * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, see http://www.gnu.org/licenses/. */ -#include stdarg.h -#include stdlib.h -#include stdio.h -#include string.h -#include inttypes.h #include cpu.h #include disas.h #include tcg-op.h -#include qemu-common.h #include host-utils.h #include helper.h -- 1.7.7.3
[Qemu-devel] [PATCH 08/15] target-microblaze: Clean includes
The change in cpu.h is needed when HOST_LONG_BITS is defined in qemu-common.h. Signed-off-by: Stefan Weil s...@weilnetz.de --- target-microblaze/cpu.h |3 +++ target-microblaze/helper.c|5 - target-microblaze/mmu.c |4 target-microblaze/translate.c |8 4 files changed, 3 insertions(+), 17 deletions(-) diff --git a/target-microblaze/cpu.h b/target-microblaze/cpu.h index 3ecaeee..4092506 100644 --- a/target-microblaze/cpu.h +++ b/target-microblaze/cpu.h @@ -19,6 +19,9 @@ #ifndef CPU_MICROBLAZE_H #define CPU_MICROBLAZE_H +#include config.h +#include qemu-common.h + #define TARGET_LONG_BITS 32 #define CPUState struct CPUMBState diff --git a/target-microblaze/helper.c b/target-microblaze/helper.c index 2cf2802..e1355ff 100644 --- a/target-microblaze/helper.c +++ b/target-microblaze/helper.c @@ -17,11 +17,6 @@ * License along with this library; if not, see http://www.gnu.org/licenses/. */ -#include stdio.h -#include string.h -#include assert.h - -#include config.h #include cpu.h #include host-utils.h diff --git a/target-microblaze/mmu.c b/target-microblaze/mmu.c index 281fc8d..7c34ac0 100644 --- a/target-microblaze/mmu.c +++ b/target-microblaze/mmu.c @@ -16,11 +16,7 @@ * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, see http://www.gnu.org/licenses/. */ -#include stdio.h -#include stdlib.h -#include assert.h -#include config.h #include cpu.h #define D(x) diff --git a/target-microblaze/translate.c b/target-microblaze/translate.c index 96ce2ec..725c2dd 100644 --- a/target-microblaze/translate.c +++ b/target-microblaze/translate.c @@ -17,19 +17,11 @@ * License along with this library; if not, see http://www.gnu.org/licenses/. */ -#include stdarg.h -#include stdlib.h -#include stdio.h -#include string.h -#include inttypes.h -#include assert.h - #include cpu.h #include disas.h #include tcg-op.h #include helper.h #include microblaze-decode.h -#include qemu-common.h #define GEN_HELPER 1 #include helper.h -- 1.7.7.3
[Qemu-devel] [PATCH 13/15] target-unicore32: Clean includes
The change in cpu.h is needed when HOST_LONG_BITS is defined in qemu-common.h. Signed-off-by: Stefan Weil s...@weilnetz.de --- target-unicore32/cpu.h|2 ++ target-unicore32/helper.c |4 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/target-unicore32/cpu.h b/target-unicore32/cpu.h index b4e72cf..f725634 100644 --- a/target-unicore32/cpu.h +++ b/target-unicore32/cpu.h @@ -20,6 +20,8 @@ #define CPUStatestruct CPUState_UniCore32 +#include config.h +#include qemu-common.h #include cpu-defs.h #include softfloat.h diff --git a/target-unicore32/helper.c b/target-unicore32/helper.c index b5b1cb7..ee7f82b 100644 --- a/target-unicore32/helper.c +++ b/target-unicore32/helper.c @@ -5,14 +5,10 @@ * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. */ -#include stdio.h -#include stdlib.h -#include string.h #include cpu.h #include gdbstub.h #include helper.h -#include qemu-common.h #include host-utils.h static inline void set_feature(CPUState *env, int feature) -- 1.7.7.3
[Qemu-devel] [PATCH 04/15] target-cris: Clean includes
The change in cpu.h is needed when HOST_LONG_BITS is defined in qemu-common.h. Cc: Edgar E. Iglesias edgar.igles...@gmail.com Signed-off-by: Stefan Weil s...@weilnetz.de --- target-cris/cpu.h |3 +++ target-cris/helper.c|4 target-cris/mmu.c |5 - target-cris/translate.c |7 --- 4 files changed, 3 insertions(+), 16 deletions(-) diff --git a/target-cris/cpu.h b/target-cris/cpu.h index 453afbb..222a062 100644 --- a/target-cris/cpu.h +++ b/target-cris/cpu.h @@ -20,6 +20,9 @@ #ifndef CPU_CRIS_H #define CPU_CRIS_H +#include config.h +#include qemu-common.h + #define TARGET_LONG_BITS 32 #define CPUState struct CPUCRISState diff --git a/target-cris/helper.c b/target-cris/helper.c index 5bc6d81..dd7f18e 100644 --- a/target-cris/helper.c +++ b/target-cris/helper.c @@ -18,10 +18,6 @@ * License along with this library; if not, see http://www.gnu.org/licenses/. */ -#include stdio.h -#include string.h - -#include config.h #include cpu.h #include mmu.h #include host-utils.h diff --git a/target-cris/mmu.c b/target-cris/mmu.c index d481e39..5cd8f27 100644 --- a/target-cris/mmu.c +++ b/target-cris/mmu.c @@ -20,11 +20,6 @@ #ifndef CONFIG_USER_ONLY -#include stdio.h -#include string.h -#include stdlib.h - -#include config.h #include cpu.h #include mmu.h diff --git a/target-cris/translate.c b/target-cris/translate.c index 70abf8a..cbdc72c 100644 --- a/target-cris/translate.c +++ b/target-cris/translate.c @@ -23,19 +23,12 @@ * The condition code translation is in need of attention. */ -#include stdarg.h -#include stdlib.h -#include stdio.h -#include string.h -#include inttypes.h - #include cpu.h #include disas.h #include tcg-op.h #include helper.h #include mmu.h #include crisv32-decode.h -#include qemu-common.h #define GEN_HELPER 1 #include helper.h -- 1.7.7.3
Re: [Qemu-devel] [PATCH 10/15] target-ppc: Clean includes
On 02.02.2012, at 22:12, Stefan Weil wrote: Remove some include statements which are not needed. Are these redundant or do they just happen to be unnecessary because of unused debug #ifdefs? Alex Cc: Alexander Graf ag...@suse.de Signed-off-by: Stefan Weil s...@weilnetz.de --- target-ppc/helper.c|6 -- target-ppc/translate.c |6 -- 2 files changed, 0 insertions(+), 12 deletions(-) diff --git a/target-ppc/helper.c b/target-ppc/helper.c index 5847453..455dcc0 100644 --- a/target-ppc/helper.c +++ b/target-ppc/helper.c @@ -16,15 +16,9 @@ * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, see http://www.gnu.org/licenses/. */ -#include stdarg.h -#include stdlib.h -#include stdio.h -#include string.h -#include inttypes.h #include cpu.h #include helper_regs.h -#include qemu-common.h #include kvm.h #include kvm_ppc.h #include cpus.h diff --git a/target-ppc/translate.c b/target-ppc/translate.c index 66eae30..74ad855 100644 --- a/target-ppc/translate.c +++ b/target-ppc/translate.c @@ -17,16 +17,10 @@ * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, see http://www.gnu.org/licenses/. */ -#include stdarg.h -#include stdlib.h -#include stdio.h -#include string.h -#include inttypes.h #include cpu.h #include disas.h #include tcg-op.h -#include qemu-common.h #include host-utils.h #include helper.h -- 1.7.7.3
[Qemu-devel] [PATCH 06/15] target-lm32: Clean includes
config.h was missing in cpu.h. Cc: Michael Walle mich...@walle.cc Signed-off-by: Stefan Weil s...@weilnetz.de --- target-lm32/cpu.h |1 + target-lm32/helper.c|5 - target-lm32/translate.c |8 3 files changed, 1 insertions(+), 13 deletions(-) diff --git a/target-lm32/cpu.h b/target-lm32/cpu.h index 037ef52..b6b6b4c 100644 --- a/target-lm32/cpu.h +++ b/target-lm32/cpu.h @@ -24,6 +24,7 @@ #define CPUState struct CPULM32State +#include config.h #include qemu-common.h #include cpu-defs.h struct CPULM32State; diff --git a/target-lm32/helper.c b/target-lm32/helper.c index fc0b444..2637c03 100644 --- a/target-lm32/helper.c +++ b/target-lm32/helper.c @@ -17,11 +17,6 @@ * License along with this library; if not, see http://www.gnu.org/licenses/. */ -#include stdio.h -#include string.h -#include assert.h - -#include config.h #include cpu.h #include host-utils.h diff --git a/target-lm32/translate.c b/target-lm32/translate.c index 0be105d..c80e48b 100644 --- a/target-lm32/translate.c +++ b/target-lm32/translate.c @@ -17,18 +17,10 @@ * License along with this library; if not, see http://www.gnu.org/licenses/. */ -#include stdarg.h -#include stdlib.h -#include stdio.h -#include string.h -#include inttypes.h -#include assert.h - #include cpu.h #include disas.h #include helper.h #include tcg-op.h -#include qemu-common.h #include hw/lm32_pic.h -- 1.7.7.3
Re: [Qemu-devel] [PATCH 14/15] target-xtensa: Clean includes
Remove some include statements which are not needed. Cc: Max Filippov jcmvb...@gmail.com Signed-off-by: Stefan Weil s...@weilnetz.de Acked-by: Max Filippov jcmvb...@gmail.com Thanks. -- Max
[Qemu-devel] [PATCH 12/15] target-sh4: Clean includes
Remove some include statements which are not needed. Cc: Aurelien Jarno aurel...@aurel32.net Signed-off-by: Stefan Weil s...@weilnetz.de --- target-sh4/translate.c |6 -- 1 files changed, 0 insertions(+), 6 deletions(-) diff --git a/target-sh4/translate.c b/target-sh4/translate.c index aacf96d..dd0ee4b 100644 --- a/target-sh4/translate.c +++ b/target-sh4/translate.c @@ -16,11 +16,6 @@ * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, see http://www.gnu.org/licenses/. */ -#include stdarg.h -#include stdlib.h -#include stdio.h -#include string.h -#include inttypes.h #define DEBUG_DISAS #define SH4_DEBUG_DISAS @@ -29,7 +24,6 @@ #include cpu.h #include disas.h #include tcg-op.h -#include qemu-common.h #include helper.h #define GEN_HELPER 1 -- 1.7.7.3
[Qemu-devel] [PATCH 07/15] target-m68k: Clean includes
config.h was missing in cpu.h. Signed-off-by: Stefan Weil s...@weilnetz.de --- target-m68k/cpu.h |1 + target-m68k/helper.c|5 - target-m68k/translate.c |6 -- 3 files changed, 1 insertions(+), 11 deletions(-) diff --git a/target-m68k/cpu.h b/target-m68k/cpu.h index 0667f82..4cc3a35 100644 --- a/target-m68k/cpu.h +++ b/target-m68k/cpu.h @@ -24,6 +24,7 @@ #define CPUState struct CPUM68KState +#include config.h #include qemu-common.h #include cpu-defs.h diff --git a/target-m68k/helper.c b/target-m68k/helper.c index 674c8e6..fa675bf 100644 --- a/target-m68k/helper.c +++ b/target-m68k/helper.c @@ -18,12 +18,7 @@ * License along with this library; if not, see http://www.gnu.org/licenses/. */ -#include stdio.h -#include string.h - -#include config.h #include cpu.h -#include qemu-common.h #include gdbstub.h #include helpers.h diff --git a/target-m68k/translate.c b/target-m68k/translate.c index 0e7f1fe..2bdd9dd 100644 --- a/target-m68k/translate.c +++ b/target-m68k/translate.c @@ -17,13 +17,7 @@ * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, see http://www.gnu.org/licenses/. */ -#include stdarg.h -#include stdlib.h -#include stdio.h -#include string.h -#include inttypes.h -#include config.h #include cpu.h #include disas.h #include tcg-op.h -- 1.7.7.3
[Qemu-devel] [PATCH 01/15] Remove macro HOST_LONG_SIZE
HOST_LONG_SIZE is simply the size of a pointer value. There is no need for this macro. Signed-off-by: Stefan Weil s...@weilnetz.de --- cpu-defs.h |2 -- thunk.h|4 ++-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/cpu-defs.h b/cpu-defs.h index 57a709b..4527cbf 100644 --- a/cpu-defs.h +++ b/cpu-defs.h @@ -60,8 +60,6 @@ typedef uint64_t target_ulong __attribute__((aligned(TARGET_LONG_ALIGNMENT))); #error TARGET_LONG_SIZE undefined #endif -#define HOST_LONG_SIZE (HOST_LONG_BITS / 8) - #define EXCP_INTERRUPT 0x1 /* async interruption */ #define EXCP_HLT0x10001 /* hlt instruction reached */ #define EXCP_DEBUG 0x10002 /* cpu stopped after a breakpoint or singlestep */ diff --git a/thunk.h b/thunk.h index 109c541..9810743 100644 --- a/thunk.h +++ b/thunk.h @@ -99,7 +99,7 @@ static inline int thunk_type_size(const argtype *type_ptr, int is_host) case TYPE_PTRVOID: case TYPE_PTR: if (is_host) { -return HOST_LONG_SIZE; +return sizeof(void *); } else { return TARGET_ABI_BITS / 8; } @@ -136,7 +136,7 @@ static inline int thunk_type_align(const argtype *type_ptr, int is_host) case TYPE_PTRVOID: case TYPE_PTR: if (is_host) { -return HOST_LONG_SIZE; +return sizeof(void *); } else { return TARGET_ABI_BITS / 8; } -- 1.7.7.3
[Qemu-devel] [PATCH 00/15] Clean some includes and definitions
Hi, I tried to move the definition of HOST_LONG_BITS from configure to qemu-common.h. While doing this, I noticed that the different QEMU targets use includes in non-uniform ways. So the simple goal resulted in quite a lot of patches. Patch 1 simply removes a derived macro. This patch is independent of the others. The next patches try to implement a more uniform include scheme for the TCG targets than today: * cpu.h always starts with config.h and qemu-common.h. * config.h is not needed before cpu.h * qemu-common.h is not needed after cpu.h. * Standard includes are not needed because they are already in qemu-common.h This also avoids potential errors when qemu-common.h is included without a preceding config.h. Future code changes should be easier as soon as all targets use a uniform include scheme. The last patch finally achieves my initial goal. Regards, Stefan Weil [PATCH 01/15] Remove macro HOST_LONG_SIZE [PATCH 02/15] target-alpha: Clean includes [PATCH 03/15] target-arm: Clean includes [PATCH 04/15] target-cris: Clean includes [PATCH 05/15] target-i386: Clean includes [PATCH 06/15] target-lm32: Clean includes [PATCH 07/15] target-m68k: Clean includes [PATCH 08/15] target-microblaze: Clean includes [PATCH 09/15] target-mips: Clean includes [PATCH 10/15] target-ppc: Clean includes [PATCH 11/15] target-s390x: Clean includes [PATCH 12/15] target-sh4: Clean includes [PATCH 13/15] target-unicore32: Clean includes [PATCH 14/15] target-xtensa: Clean includes [PATCH 15/15] Move definition of HOST_LONG_BITS to qemu-common.h