[Qemu-devel] [Bug 592028] [NEW] sparc32plus user test failed
Public bug reported: Hello, I try to execute on linux machine sparc binary (simple hello word application) using qemu-sparc32plus and get segfault.Before test I copy all libraries and headers (/usr/lib, /lib/, /usr/local/lib /usr/include /usr/local/include) from original solaris workstation to separate directory on linux machine: /usr/cross/sysroot I also copy statically builded qemu binaries and hello_world app in /usr/cross/sysroot/bin and start app as: chroot /usr/cross/sysroot qemu-sparc32plus bin/hello_world but also I get segfault. As I see all necessary shared libs and interpreter (/usr/lib/ld.so.1) exists in apropriate directories: /usr/lib, /lib/, /usr/local/lib under new sysroot = /usr/cross/sysroot. I also try to run simple sparc32 app using qemu-sparc32plus but also get segfault. After that I try to run tests from linux-user-test-0.3 packet but they also fail with qemu-sparc32plus emulation. I try to perform such test on different type of systems (see further) and several version of qemu (builded from sources qemu-0.12.4 qemu-0.11.1 with configure make ). Probably I miss something in configuration or perform some wrong step with qemu-sparc32plus, could you please clarify is sparc32plus user mode emulation is sucessfuly exists in the latest versions of qemu? configuration of original Solaris sparc station where I build app: bash-3.00# uname -a SunOS fs650 5.10 Generic_137111-07 sun4us sparc FJSV,GPUZC-M bash-3.00# gcc --version gcc (GCC) 3.4.6 Copyright (C) 2006 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. bash-3.00# psrinfo -v Status of virtual processor 0 as of: 05/27/2010 12:23:06 on-line since 05/13/2010 18:40:47. The sparcv9 processor operates at 1889 MHz, and has a sparcv9 floating point processor. skipped 1 - 6. Status of virtual processor 7 as of: 05/27/2010 12:23:06 on-line since 05/13/2010 18:41:14. The sparcv9 processor operates at 1889 MHz, and has a sparcv9 floating point processor. source: bash-3.00# cat sample.c #include stdio.h int main(int argc, char* argv[]) { printf(Hello word!\n); return 0; } compilation string: bash-3.00# g++ -m32 -mcpu=v9 sample.c bash-3.00# file a.out a.out: ELF 32-bit MSB executable SPARC32PLUS Version 1, V8+ Required, dynamically linked, not stripped, no debugging information available configuration of 1st test machine - Debian Testing : /home/dima# uname -a Linux T291-2 2.6.32-trunk-686 #1 SMP Sun Jan 10 06:32:16 UTC 2010 i686 GNU/Linux /home/dima# cat /etc/issue Debian GNU/Linux squeeze/sid /home/dima# cat /proc/cpuinfo processor : 0 vendor_id : GenuineIntel cpu family : 6 model : 15 model name : Intel(R) Pentium(R) Dual CPU E2160 @ 1.80GHz stepping: 13 cpu MHz : 1799.624 cache size : 1024 KB physical id : 0 siblings: 2 core id : 0 cpu cores : 2 apicid : 0 initial apicid : 0 fdiv_bug: no hlt_bug : no f00f_bug: no coma_bug: no fpu : yes fpu_exception : yes cpuid level : 10 wp : yes flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe lm constant_tsc arch_perfmon pebs bts aperfmperf pni dtes64 monitor ds_cpl est tm2 ssse3 cx16 xtpr pdcm lahf_lm bogomips: 3599.24 clflush size: 64 cache_alignment : 64 address sizes : 36 bits physical, 48 bits virtual power management: processor : 1 ...skipped.. address sizes : 36 bits physical, 48 bits virtual power management: configuration of 2nd test machine - Debian Lenny stable: d...@debian:~/Desktop/linux-user-test-0.3$ uname -a Linux debian 2.6.26-1-686 #1 SMP Sat Jan 10 18:29:31 UTC 2009 i686 GNU/Linux d...@debian:~/Desktop/linux-user-test-0.3$ gcc --version gcc (Debian 4.3.2-1.1) 4.3.2 Copyright (C) 2008 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. cpu - intel q6600 configuration of 3rd test machine: vmware image of SLES 11 cat /etc/issue Welcome to SUSE Linux Enterprise Server 11 (x86_64) - Kernel \r (\l). cat /proc/cpuinfo processor : 0 vendor_id : GenuineIntel cpu family : 6 model : 15 model name : Intel(R) Xeon(R) CPU E5345 @ 2.33GHz stepping: 8 cpu MHz : 2333.330 cache size : 4096 KB fpu : yes fpu_exception : yes cpuid level : 10 wp : yes flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss syscall lm constant_tsc arch_perfmon pebs bts rep_good nopl pni ssse3 cx16
Re: [Qemu-devel] Disable PS/2 mouse
On 06/09/2010 05:35 PM, Gerd Hoffmann wrote: Hi, with 0.12.4 it is still the case that a total idle vm takes about 6-8% of a 2.4GHz Xeon Core. I see that order of magitude too, no matter whenever usb is on or off. With older qemu and usbtablet it used to be up to 25%. Is it possible to dynamically control the refresh internally within qemu so VMs without a connected VNC client will have rare refreshes or no refresh at all? I hope it's not the OS who polls it. cheers, Gerd
Re: [Qemu-devel] [PATCH] configure: add an option to disable vlans
Markus Armbruster arm...@redhat.com writes: Michael S. Tsirkin m...@redhat.com writes: Everyone ok with disabling vlans with no config option? Wrong question. You got to ask anyone *not* ok with disabling vlans with no config option? We do use socket devices in the form -net nic,model=e1000,vlan=X,mac=MMM -net socket,vlan=X,mcast=Y:Z but presumably this can just be rewritten as -netdev socket,id=netX,mcast=Y:Z -device e1000,netdev=netX,mac=MMM It's only the case of a nic connected to multiple backends by a VLAN that's being deprecated here, not any of the previously supported backends? Cheers, Chris.
Re: [Qemu-devel] Disable PS/2 mouse
On 06/10/2010 09:12 AM, Dor Laor wrote: On 06/09/2010 05:35 PM, Gerd Hoffmann wrote: Hi, with 0.12.4 it is still the case that a total idle vm takes about 6-8% of a 2.4GHz Xeon Core. I see that order of magitude too, no matter whenever usb is on or off. With older qemu and usbtablet it used to be up to 25%. Is it possible to dynamically control the refresh internally within qemu so VMs without a connected VNC client will have rare refreshes or no refresh at all? I hope it's not the OS who polls it. vnc/vga or usb tablet? For the vga it happens already, with no vnc client connected vnc zaps the refresh timer and stops calling vga_hw_update(), thus vga stops doing framebuffer dirty tracking too. For usb hid devices: No idea how they work and whenever we can put them into sleep somehow (with/without guest cooperation). cheers, Gerd
[Qemu-devel] [Bug 538908] Re: qemu-system-cris crashes after a few seconds
** Summary changed: - qemu-cris crashes after a few seconds + qemu-system-cris crashes after a few seconds ** Tags added: qemu-system-cris -- qemu-system-cris crashes after a few seconds https://bugs.launchpad.net/bugs/538908 You received this bug notification because you are a member of qemu- devel-ml, which is subscribed to QEMU. Status in QEMU: New Status in “qemu” package in Ubuntu: New Bug description: qemu-system-cris crashes after a few seconds. Running the binary without any options loads the qemu window and it sits there waiting for me to do something. About a minute later it crashes. Dump attached. Running Linux 2.6.27-17-generic on Ubuntu 8.10. Athlon XP 3000+ 2GB RAM
[Qemu-devel] [Bug 592056] [NEW] qemu segmentation fault when create qcow2 image with qemu-img command
Public bug reported: Host OS: ia32e kvm.git Commit:cf18597a046413e9f0dd8df3ad6715a88766be51 qemu-kvm Commit:3f505ec990599aeb960ed7031a2bb7b233ea4927 Host Kernel Version:2.6.35-rc2+ Hardware:Westmere-HEDT Bug detailed description: -- when use qemu-img command to create qcow image, segmentation fault will happen. dmesg: qemu-img[1883] general protection ip:32f0477d20 sp:7fff9c89b308 error:0 in libc-2.5.so[32f040+14a000] Bisected commit ea25559830a1a025e534dea634158c0141c71894 in qemu-kvm tree bring up this issue. Reproduce steps: 1.boot up into KVM ia32e host 2.use command: qemu-img create -b /path/to/file.img -f qcow2 /path/to/qcow.img 3.it displays: segmentation fault ** Affects: qemu Importance: Undecided Status: New -- qemu segmentation fault when create qcow2 image with qemu-img command https://bugs.launchpad.net/bugs/592056 You received this bug notification because you are a member of qemu- devel-ml, which is subscribed to QEMU. Status in QEMU: New Bug description: Host OS: ia32e kvm.git Commit:cf18597a046413e9f0dd8df3ad6715a88766be51 qemu-kvm Commit:3f505ec990599aeb960ed7031a2bb7b233ea4927 Host Kernel Version:2.6.35-rc2+ Hardware:Westmere-HEDT Bug detailed description: -- when use qemu-img command to create qcow image, segmentation fault will happen. dmesg: qemu-img[1883] general protection ip:32f0477d20 sp:7fff9c89b308 error:0 in libc-2.5.so[32f040+14a000] Bisected commit ea25559830a1a025e534dea634158c0141c71894 in qemu-kvm tree bring up this issue. Reproduce steps: 1.boot up into KVM ia32e host 2.use command: qemu-img create -b /path/to/file.img -f qcow2 /path/to/qcow.img 3.it displays: segmentation fault
[Qemu-devel] Re: [PATCH] sparc32 esp fix spurious interrupts in chip reset
2010/6/9 Blue Swirl blauwir...@gmail.com: On Fri, Jun 4, 2010 at 8:30 PM, Artyom Tarasenko atar4q...@googlemail.com wrote: 2010/6/4 Blue Swirl blauwir...@gmail.com: On Tue, Jun 1, 2010 at 8:16 PM, Artyom Tarasenko atar4q...@googlemail.com wrote: 2010/6/1 Blue Swirl blauwir...@gmail.com: On Tue, Jun 1, 2010 at 7:56 PM, Artyom Tarasenko atar4q...@googlemail.com wrote: 2010/6/1 Blue Swirl blauwir...@gmail.com: On Sun, May 30, 2010 at 10:35 PM, Artyom Tarasenko atar4q...@googlemail.com wrote: lower interrupt during chip reset. Otherwise the ESP_RSTAT register may get out of sync with the IRQ line status. This effect became visible after commit 65899fe3 Hard reset handlers should not touch qemu_irqs, because on cold start, the receiving end may be unprepared to handle the signal. Wouldn't the real hardware lower irq on the hardware reset? Yes, but since qemu_irqs have no state, and on a cold start or system reset all other devices are guaranteed to be reset, the callback would be useless. And if it would not, would it still clear the corresponding bit in the ESP_RSTAT register? All registers are set to zero in the lines below. See 0d0a7e69e853639b123798877e019c3c7ee6634a, bc26e55a6615dc594be425d293db40d5cdcdb84b and 42f1ced228c9b616cfa2b69846025271618e4ef5. For ESP there are two other sources of reset: signal from DMA and chip reset command. On those cases, lowering IRQ makes sense. So the correct fix is to refactor the reset handling a bit. Does this patch also fix your test case? It does, but +static void esp_soft_reset(DeviceState *d) +{ + ESPState *s = container_of(d, ESPState, busdev.qdev); + + qemu_irq_lower(s-irq); Shouldn't it be esp_lower_irq(s)? What's going to happen to the DMA_INTR bit if dma was the source of the irq? Again, the registers are zeroed in esp_hard_reset(). How does it zero the _DMA_ registers? And sparc32_dma does share the IRQ line with ESP, doesn't it? I'd suppose DMA registers are separate and they would not be cleared by for example ESP chip reset command. The IRQ goes from ESP to DMA, DMA has another line going to interrupt controller. But do we have separate DMA lines in qemu? If we do, I'm absolutely fine with qemu_irq_lower(s-irq) . If we don't, imagine the following scenario: DMA rises an IRQ, then esp chip reset happens, and then... DMA can't rise the IRQ anymore. What ESP does with its IRQ line does not stop DMA from using its line. Then I'm fine with your patch. -- Regards, Artyom Tarasenko solaris/sparc under qemu blog: http://tyom.blogspot.com/
Re: [Qemu-devel] [RFC PATCH 3/6] RAMBlock: Add a name field
I may have been a bit misleading here. What we really want to do is use the same matching algorithm as is used by the rest of the device state. Currently this is a vmstate name and [arbitrary] numeric id. I don't remember whether there's a convenient link from a device to its associated vmstate - if there isn't there probably should be. DeviceState-info-vmsd-name for the name. Dunno about the numeric id, I think savevm.c doesn't export it. cheers, Gerd
Re: [Qemu-devel] [PATCH] configure: add an option to disable vlans
On Thu, Jun 10, 2010 at 08:20:56AM +0100, Chris Webb wrote: Markus Armbruster arm...@redhat.com writes: Michael S. Tsirkin m...@redhat.com writes: Everyone ok with disabling vlans with no config option? Wrong question. You got to ask anyone *not* ok with disabling vlans with no config option? We do use socket devices in the form -net nic,model=e1000,vlan=X,mac=MMM -net socket,vlan=X,mcast=Y:Z but presumably this can just be rewritten as -netdev socket,id=netX,mcast=Y:Z -device e1000,netdev=netX,mac=MMM It's only the case of a nic connected to multiple backends by a VLAN that's being deprecated here, not any of the previously supported backends? Cheers, Chris. Exactly.
Re: [Qemu-devel] [Bug 592056] [NEW] qemu segmentation fault when create qcow2 image with qemu-img command
Am 10.06.2010 09:41, schrieb xudong: when use qemu-img command to create qcow image, segmentation fault will happen. dmesg: qemu-img[1883] general protection ip:32f0477d20 sp:7fff9c89b308 error:0 in libc-2.5.so[32f040+14a000] Bisected commit ea25559830a1a025e534dea634158c0141c71894 in qemu-kvm tree bring up this issue. Can you please provide a backtrace? I couldn't reproduce this in a quick attempt, so I can't get it myself.
[Qemu-devel] files in kvm/libkvm/ doesn't make
hi, guys. I have changed some files in the folder kvm/libkvm/. But when I make, it doesn't work. What should I do to correct this? Thanks.
Re: [Qemu-devel] [PATCH] Add an error_report when failing to open due to block-drv-whitelist
Am 09.06.2010 21:28, schrieb Ryan Harper: When configure qemu with --block-drv-whitelist we don't report when we are blocked by the white list and the resulting error message is misleading: ./configure --target-list=x86_64-softmmu \ --block-drv-whitelist=qcow2,raw,host_device,host_cdrom x86_64-softmmu/qemu-system-x86_64 -L pc-bios -m 512 -drive \ file=fedora9_32_20G.qcow2,if=ide -monitor stdio qemu: could not open disk image fedora9_32_20G.qcow2: Inappropriate ioctl for device Which might lead one to look at the bdrv probe functions for floppy/cdrom because we indeed will get an ioctl failure stored in errno and we report this in vl.c when we get a non-zero return value from bdrv_open(). This patch adds an error report when we fail the whitelist and changes the errno value to ENOPROTOOPT which was the closest thing I could think of that matched the actual error. Now we get the following output on whitelist failure: x86_64-softmmu/qemu-system-x86_64 -L pc-bios -m 512 -drive \ file=fedora9_32_20G.qcow2,if=ide -monitor stdio qemu-system-x86_64: -drive file=fedora9_32_20G.qcow2,if=ide: block-drv-whitelist prevents using format 'file' qemu: could not open disk image fedora9_32_20G.qcow2: Protocol not supported Signed-off-by: Ryan Harper ry...@us.ibm.com --- block.c |3 +++ 1 files changed, 3 insertions(+), 0 deletions(-) diff --git a/block.c b/block.c index 39724c1..ffcf7f2 100644 --- a/block.c +++ b/block.c @@ -403,6 +403,9 @@ static int bdrv_open_common(BlockDriverState *bs, const char *filename, pstrcpy(bs-filename, sizeof(bs-filename), filename); if (use_bdrv_whitelist !bdrv_is_whitelisted(drv)) { +error_report(block-drv-whitelist prevents using format '%s', drv-format_name); +/* reset errno since we're failing because of whitelist restrictions */ +errno = EPROTONOSUPPORT; Any code that relies on this errno is broken. errno isn't part of the bdrv_open interface. In fact, last week I have sent a patch to fix the error message to use the return value instead, Anthony just needs to pull. The error_report may be a good idea, though. Kevin
RE: [Qemu-devel] [Bug 592056] [NEW] qemu segmentation fault when create qcow2 image with qemu-img command
The commit dafac85ed4f43d694c1b438ec6d14e18d225e600 works fine, I git diff the two dafac85ed4f43d694c1b438ec6d14e18d225e600 and ea25559830a1a025e534dea634158c0141c71894, and revert qemu-img.c to dafac85ed4f43d694c1b438ec6d14e18d225e600 , then everything is OK. Thanks, Xudong -Original Message- From: Kevin Wolf [mailto:kw...@redhat.com] Sent: 2010年6月10日 16:59 To: Bug 592056 Cc: Hao, Xudong; qemu-devel@nongnu.org Subject: Re: [Qemu-devel] [Bug 592056] [NEW] qemu segmentation fault when create qcow2 image with qemu-img command Am 10.06.2010 09:41, schrieb xudong: when use qemu-img command to create qcow image, segmentation fault will happen. dmesg: qemu-img[1883] general protection ip:32f0477d20 sp:7fff9c89b308 error:0 in libc-2.5.so[32f040+14a000] Bisected commit ea25559830a1a025e534dea634158c0141c71894 in qemu-kvm tree bring up this issue. Can you please provide a backtrace? I couldn't reproduce this in a quick attempt, so I can't get it myself.
[Qemu-devel] [PATCH 01/17] vl.c: Remove double include of netinet/in.h for Solaris
From: Jes Sorensen jes.soren...@redhat.com vl.c: netinet/in.h is already included once above for the Signed-off-by: Jes Sorensen jes.soren...@redhat.com Acked-by: Andreas Faerber afaer...@opensolaris.org Acked-by: Juan Quintela quint...@redhat.com Acked-by: Richard Henderson r...@redhat.com --- vl.c |1 - 1 files changed, 0 insertions(+), 1 deletions(-) diff --git a/vl.c b/vl.c index 6d08ec8..55fc527 100644 --- a/vl.c +++ b/vl.c @@ -70,7 +70,6 @@ #include sys/ethernet.h #include sys/sockio.h #include netinet/arp.h -#include netinet/in.h #include netinet/in_systm.h #include netinet/ip.h #include netinet/ip_icmp.h // must come after ip.h -- 1.6.5.2
[Qemu-devel] [PATCH 04/17] vl.c: Move host_main_loop_wait() to OS specific files.
From: Jes Sorensen jes.soren...@redhat.com Move host_main_loop_wait() to OS specific files. Create qemu-os-posix.h and provide empty inline for the POSIX case. Signed-off-by: Jes Sorensen jes.soren...@redhat.com Acked-by: Juan Quintela quint...@redhat.com Acked-by: Richard Henderson r...@redhat.com --- os-win32.c | 43 +++ qemu-os-posix.h | 33 + qemu-os-win32.h |1 + sysemu.h|4 vl.c| 52 +--- 5 files changed, 82 insertions(+), 51 deletions(-) create mode 100644 qemu-os-posix.h diff --git a/os-win32.c b/os-win32.c index 5a464cc..1f7e28b 100644 --- a/os-win32.c +++ b/os-win32.c @@ -109,3 +109,46 @@ void qemu_del_wait_object(HANDLE handle, WaitObjectFunc *func, void *opaque) if (found) w-num--; } + +void os_host_main_loop_wait(int *timeout) +{ +int ret, ret2, i; +PollingEntry *pe; + +/* XXX: need to suppress polling by better using win32 events */ +ret = 0; +for(pe = first_polling_entry; pe != NULL; pe = pe-next) { +ret |= pe-func(pe-opaque); +} +if (ret == 0) { +int err; +WaitObjects *w = wait_objects; + +ret = WaitForMultipleObjects(w-num, w-events, FALSE, *timeout); +if (WAIT_OBJECT_0 + 0 = ret ret = WAIT_OBJECT_0 + w-num - 1) { +if (w-func[ret - WAIT_OBJECT_0]) +w-func[ret - WAIT_OBJECT_0](w-opaque[ret - WAIT_OBJECT_0]); + +/* Check for additional signaled events */ +for(i = (ret - WAIT_OBJECT_0 + 1); i w-num; i++) { + +/* Check if event is signaled */ +ret2 = WaitForSingleObject(w-events[i], 0); +if(ret2 == WAIT_OBJECT_0) { +if (w-func[i]) +w-func[i](w-opaque[i]); +} else if (ret2 == WAIT_TIMEOUT) { +} else { +err = GetLastError(); +fprintf(stderr, WaitForSingleObject error %d %d\n, i, err); +} +} +} else if (ret == WAIT_TIMEOUT) { +} else { +err = GetLastError(); +fprintf(stderr, WaitForMultipleObjects error %d %d\n, ret, err); +} +} + +*timeout = 0; +} diff --git a/qemu-os-posix.h b/qemu-os-posix.h new file mode 100644 index 000..96d1036 --- /dev/null +++ b/qemu-os-posix.h @@ -0,0 +1,33 @@ +/* + * posix specific declarations + * + * Copyright (c) 2003-2008 Fabrice Bellard + * Copyright (c) 2010 Jes Sorensen jes.soren...@redhat.com + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the Software), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#ifndef QEMU_OS_POSIX_H +#define QEMU_OS_POSIX_H + +static inline void os_host_main_loop_wait(int *timeout) +{ +} + +#endif diff --git a/qemu-os-win32.h b/qemu-os-win32.h index be108ad..4d1cac8 100644 --- a/qemu-os-win32.h +++ b/qemu-os-win32.h @@ -40,4 +40,5 @@ typedef void WaitObjectFunc(void *opaque); int qemu_add_wait_object(HANDLE handle, WaitObjectFunc *func, void *opaque); void qemu_del_wait_object(HANDLE handle, WaitObjectFunc *func, void *opaque); +void os_host_main_loop_wait(int *timeout); #endif diff --git a/sysemu.h b/sysemu.h index 13fc9a9..5e4feae 100644 --- a/sysemu.h +++ b/sysemu.h @@ -12,6 +12,10 @@ #include qemu-os-win32.h #endif +#ifdef CONFIG_POSIX +#include qemu-os-posix.h +#endif + /* vl.c */ extern const char *bios_name; diff --git a/vl.c b/vl.c index 8927559..4097762 100644 --- a/vl.c +++ b/vl.c @@ -1722,56 +1722,6 @@ void qemu_system_powerdown_request(void) qemu_notify_event(); } -#ifdef _WIN32 -static void host_main_loop_wait(int *timeout) -{ -int ret, ret2, i; -PollingEntry *pe; - - -/* XXX: need to suppress polling by better using win32 events */ -ret = 0; -for(pe = first_polling_entry; pe != NULL; pe = pe-next) { -ret |= pe-func(pe-opaque); -} -if (ret == 0) { -
[Qemu-devel] [PATCH 02/17] Create qemu-os-win32.h and move WIN32 specific declarations there
From: Jes Sorensen jes.soren...@redhat.com Create qemu-os-win32.h for WIN32 specific declarations. Move polling handling declaration into this file from sysemu.h Signed-off-by: Jes Sorensen jes.soren...@redhat.com Acked-by: Juan Quintela quint...@redhat.com Acked-by: Richard Henderson r...@redhat.com --- qemu-os-win32.h | 43 +++ sysemu.h| 17 + 2 files changed, 44 insertions(+), 16 deletions(-) create mode 100644 qemu-os-win32.h diff --git a/qemu-os-win32.h b/qemu-os-win32.h new file mode 100644 index 000..be108ad --- /dev/null +++ b/qemu-os-win32.h @@ -0,0 +1,43 @@ +/* + * win32 specific declarations + * + * Copyright (c) 2003-2008 Fabrice Bellard + * Copyright (c) 2010 Jes Sorensen jes.soren...@redhat.com + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the Software), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#ifndef QEMU_OS_WIN32_H +#define QEMU_OS_WIN32_H + +/* Polling handling */ + +/* return TRUE if no sleep should be done afterwards */ +typedef int PollingFunc(void *opaque); + +int qemu_add_polling_cb(PollingFunc *func, void *opaque); +void qemu_del_polling_cb(PollingFunc *func, void *opaque); + +/* Wait objects handling */ +typedef void WaitObjectFunc(void *opaque); + +int qemu_add_wait_object(HANDLE handle, WaitObjectFunc *func, void *opaque); +void qemu_del_wait_object(HANDLE handle, WaitObjectFunc *func, void *opaque); + +#endif diff --git a/sysemu.h b/sysemu.h index 879446a..13fc9a9 100644 --- a/sysemu.h +++ b/sysemu.h @@ -9,6 +9,7 @@ #ifdef _WIN32 #include windows.h +#include qemu-os-win32.h #endif /* vl.c */ @@ -71,22 +72,6 @@ int qemu_savevm_state_complete(Monitor *mon, QEMUFile *f); void qemu_savevm_state_cancel(Monitor *mon, QEMUFile *f); int qemu_loadvm_state(QEMUFile *f); -#ifdef _WIN32 -/* Polling handling */ - -/* return TRUE if no sleep should be done afterwards */ -typedef int PollingFunc(void *opaque); - -int qemu_add_polling_cb(PollingFunc *func, void *opaque); -void qemu_del_polling_cb(PollingFunc *func, void *opaque); - -/* Wait objects handling */ -typedef void WaitObjectFunc(void *opaque); - -int qemu_add_wait_object(HANDLE handle, WaitObjectFunc *func, void *opaque); -void qemu_del_wait_object(HANDLE handle, WaitObjectFunc *func, void *opaque); -#endif - /* SLIRP */ void do_info_slirp(Monitor *mon); -- 1.6.5.2
[Qemu-devel] [PATCH 03/17] Introduce os-win32.c and move polling functions from vl.c
From: Jes Sorensen jes.soren...@redhat.com This introduces os-win32.c. It is meant to carry win32 specific functions thata are not relevant for all of QEMU as well as win32 versions of various pieces like signal handling etc. Move win32 polling handler helper functions from vl.c to os-win32.c Signed-off-by: Jes Sorensen jes.soren...@redhat.com Acked-by: Juan Quintela quint...@redhat.com Acked-by: Richard Henderson r...@redhat.com --- Makefile.objs |1 + os-win32.c| 111 + vl.c | 80 - 3 files changed, 112 insertions(+), 80 deletions(-) create mode 100644 os-win32.c diff --git a/Makefile.objs b/Makefile.objs index 9796dcb..58fdb03 100644 --- a/Makefile.objs +++ b/Makefile.objs @@ -144,6 +144,7 @@ hw-obj-$(CONFIG_ECC) += ecc.o hw-obj-$(CONFIG_NAND) += nand.o hw-obj-$(CONFIG_PFLASH_CFI01) += pflash_cfi01.o hw-obj-$(CONFIG_PFLASH_CFI02) += pflash_cfi02.o +hw-obj-$(CONFIG_WIN32) += os-win32.o hw-obj-$(CONFIG_M48T59) += m48t59.o hw-obj-$(CONFIG_ESCC) += escc.o diff --git a/os-win32.c b/os-win32.c new file mode 100644 index 000..5a464cc --- /dev/null +++ b/os-win32.c @@ -0,0 +1,111 @@ +/* + * os-win32.c + * + * Copyright (c) 2003-2008 Fabrice Bellard + * Copyright (c) 2010 Red Hat, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the Software), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +#include windows.h +#include unistd.h +#include fcntl.h +#include signal.h +#include time.h +#include errno.h +#include sys/time.h +#include config-host.h +#include sysemu.h + +/***/ +/* Polling handling */ + +typedef struct PollingEntry { +PollingFunc *func; +void *opaque; +struct PollingEntry *next; +} PollingEntry; + +static PollingEntry *first_polling_entry; + +int qemu_add_polling_cb(PollingFunc *func, void *opaque) +{ +PollingEntry **ppe, *pe; +pe = qemu_mallocz(sizeof(PollingEntry)); +pe-func = func; +pe-opaque = opaque; +for(ppe = first_polling_entry; *ppe != NULL; ppe = (*ppe)-next); +*ppe = pe; +return 0; +} + +void qemu_del_polling_cb(PollingFunc *func, void *opaque) +{ +PollingEntry **ppe, *pe; +for(ppe = first_polling_entry; *ppe != NULL; ppe = (*ppe)-next) { +pe = *ppe; +if (pe-func == func pe-opaque == opaque) { +*ppe = pe-next; +qemu_free(pe); +break; +} +} +} + +/***/ +/* Wait objects support */ +typedef struct WaitObjects { +int num; +HANDLE events[MAXIMUM_WAIT_OBJECTS + 1]; +WaitObjectFunc *func[MAXIMUM_WAIT_OBJECTS + 1]; +void *opaque[MAXIMUM_WAIT_OBJECTS + 1]; +} WaitObjects; + +static WaitObjects wait_objects = {0}; + +int qemu_add_wait_object(HANDLE handle, WaitObjectFunc *func, void *opaque) +{ +WaitObjects *w = wait_objects; + +if (w-num = MAXIMUM_WAIT_OBJECTS) +return -1; +w-events[w-num] = handle; +w-func[w-num] = func; +w-opaque[w-num] = opaque; +w-num++; +return 0; +} + +void qemu_del_wait_object(HANDLE handle, WaitObjectFunc *func, void *opaque) +{ +int i, found; +WaitObjects *w = wait_objects; + +found = 0; +for (i = 0; i w-num; i++) { +if (w-events[i] == handle) +found = 1; +if (found) { +w-events[i] = w-events[i + 1]; +w-func[i] = w-func[i + 1]; +w-opaque[i] = w-opaque[i + 1]; +} +} +if (found) +w-num--; +} diff --git a/vl.c b/vl.c index 55fc527..8927559 100644 --- a/vl.c +++ b/vl.c @@ -1497,86 +1497,6 @@ int qemu_set_fd_handler(int fd, return qemu_set_fd_handler2(fd, NULL, fd_read, fd_write, opaque); } -#ifdef _WIN32 -/***/ -/* Polling handling */ - -typedef struct PollingEntry { -PollingFunc *func; -void *opaque; -struct PollingEntry *next;
[Qemu-devel] [PATCH 06/17] Move win32 early signal handling setup to os_setup_signal_handling()
From: Jes Sorensen jes.soren...@redhat.com Move win32 early signal handling setup to os_setup_signal_handling() Signed-off-by: Jes Sorensen jes.soren...@redhat.com Acked-by: Juan Quintela quint...@redhat.com Acked-by: Richard Henderson r...@redhat.com --- os-win32.c | 29 + qemu-os-posix.h |2 -- sysemu.h|2 ++ vl.c| 30 -- 4 files changed, 31 insertions(+), 32 deletions(-) diff --git a/os-win32.c b/os-win32.c index 1f7e28b..dfa90bc 100644 --- a/os-win32.c +++ b/os-win32.c @@ -152,3 +152,32 @@ void os_host_main_loop_wait(int *timeout) *timeout = 0; } + +static BOOL WINAPI qemu_ctrl_handler(DWORD type) +{ +exit(STATUS_CONTROL_C_EXIT); +return TRUE; +} + +void os_setup_signal_handling(void) +{ +/* Note: cpu_interrupt() is currently not SMP safe, so we force + QEMU to run on a single CPU */ +HANDLE h; +DWORD mask, smask; +int i; + +SetConsoleCtrlHandler(qemu_ctrl_handler, TRUE); + +h = GetCurrentProcess(); +if (GetProcessAffinityMask(h, mask, smask)) { +for(i = 0; i 32; i++) { +if (mask (1 i)) +break; +} +if (i != 32) { +mask = 1 i; +SetProcessAffinityMask(h, mask); +} +} +} diff --git a/qemu-os-posix.h b/qemu-os-posix.h index ff5adb1..96d1036 100644 --- a/qemu-os-posix.h +++ b/qemu-os-posix.h @@ -30,6 +30,4 @@ static inline void os_host_main_loop_wait(int *timeout) { } -void os_setup_signal_handling(void); - #endif diff --git a/sysemu.h b/sysemu.h index 5e4feae..e3643ad 100644 --- a/sysemu.h +++ b/sysemu.h @@ -79,6 +79,8 @@ int qemu_loadvm_state(QEMUFile *f); /* SLIRP */ void do_info_slirp(Monitor *mon); +void os_setup_signal_handling(void); + typedef enum DisplayType { DT_DEFAULT, diff --git a/vl.c b/vl.c index 29c9697..264710d 100644 --- a/vl.c +++ b/vl.c @@ -1986,14 +1986,6 @@ static int balloon_parse(const char *arg) return -1; } -#ifdef _WIN32 -static BOOL WINAPI qemu_ctrl_handler(DWORD type) -{ -exit(STATUS_CONTROL_C_EXIT); -return TRUE; -} -#endif - #ifndef _WIN32 static void termsig_handler(int signal) @@ -2459,29 +2451,7 @@ int main(int argc, char **argv, char **envp) qemu_cache_utils_init(envp); QLIST_INIT (vm_change_state_head); -#ifndef _WIN32 os_setup_signal_handling(); -#else -SetConsoleCtrlHandler(qemu_ctrl_handler, TRUE); -/* Note: cpu_interrupt() is currently not SMP safe, so we force - QEMU to run on a single CPU */ -{ -HANDLE h; -DWORD mask, smask; -int i; -h = GetCurrentProcess(); -if (GetProcessAffinityMask(h, mask, smask)) { -for(i = 0; i 32; i++) { -if (mask (1 i)) -break; -} -if (i != 32) { -mask = 1 i; -SetProcessAffinityMask(h, mask); -} -} -} -#endif module_call_init(MODULE_INIT_MACHINE); machine = find_default_machine(); -- 1.6.5.2
[Qemu-devel] [PATCH 09/17] Move find_datadir to OS specific files.
From: Jes Sorensen jes.soren...@redhat.com This moves the win32 and POSIX versions of find_datadir() to OS specific files, and removes some #ifdef clutter from vl.c Signed-off-by: Jes Sorensen jes.soren...@redhat.com Acked-by: Juan Quintela quint...@redhat.com Acked-by: Richard Henderson r...@redhat.com --- os-posix.c | 64 ++ os-win32.c | 23 +++ sysemu.h |2 + vl.c | 91 +--- 4 files changed, 90 insertions(+), 90 deletions(-) diff --git a/os-posix.c b/os-posix.c index 01dbec2..621ad06 100644 --- a/os-posix.c +++ b/os-posix.c @@ -28,6 +28,7 @@ #include signal.h #include sys/types.h #include sys/wait.h +#include libgen.h /* Needed early for CONFIG_BSD etc. */ #include config-host.h @@ -66,3 +67,66 @@ void os_setup_signal_handling(void) act.sa_flags = SA_NOCLDSTOP; sigaction(SIGCHLD, act, NULL); } + +/* Find a likely location for support files using the location of the binary. + For installed binaries this will be $bindir/../share/qemu. When + running from the build tree this will be $bindir/../pc-bios. */ +#define SHARE_SUFFIX /share/qemu +#define BUILD_SUFFIX /pc-bios +char *os_find_datadir(const char *argv0) +{ +char *dir; +char *p = NULL; +char *res; +char buf[PATH_MAX]; +size_t max_len; + +#if defined(__linux__) +{ +int len; +len = readlink(/proc/self/exe, buf, sizeof(buf) - 1); +if (len 0) { +buf[len] = 0; +p = buf; +} +} +#elif defined(__FreeBSD__) +{ +static int mib[4] = {CTL_KERN, KERN_PROC, KERN_PROC_PATHNAME, -1}; +size_t len = sizeof(buf) - 1; + +*buf = '\0'; +if (!sysctl(mib, sizeof(mib)/sizeof(*mib), buf, len, NULL, 0) +*buf) { +buf[sizeof(buf) - 1] = '\0'; +p = buf; +} +} +#endif +/* If we don't have any way of figuring out the actual executable + location then try argv[0]. */ +if (!p) { +p = realpath(argv0, buf); +if (!p) { +return NULL; +} +} +dir = dirname(p); +dir = dirname(dir); + +max_len = strlen(dir) + +MAX(strlen(SHARE_SUFFIX), strlen(BUILD_SUFFIX)) + 1; +res = qemu_mallocz(max_len); +snprintf(res, max_len, %s%s, dir, SHARE_SUFFIX); +if (access(res, R_OK)) { +snprintf(res, max_len, %s%s, dir, BUILD_SUFFIX); +if (access(res, R_OK)) { +qemu_free(res); +res = NULL; +} +} + +return res; +} +#undef SHARE_SUFFIX +#undef BUILD_SUFFIX diff --git a/os-win32.c b/os-win32.c index a936f7a..1758538 100644 --- a/os-win32.c +++ b/os-win32.c @@ -181,3 +181,26 @@ void os_setup_early_signal_handling(void) } } } + +/* Look for support files in the same directory as the executable. */ +char *os_find_datadir(const char *argv0) +{ +char *p; +char buf[MAX_PATH]; +DWORD len; + +len = GetModuleFileName(NULL, buf, sizeof(buf) - 1); +if (len == 0) { +return NULL; +} + +buf[len] = 0; +p = buf + len - 1; +while (p != buf *p != '\\') +p--; +*p = 0; +if (access(buf, R_OK) == 0) { +return qemu_strdup(buf); +} +return NULL; +} diff --git a/sysemu.h b/sysemu.h index bb05cf4..72f3734 100644 --- a/sysemu.h +++ b/sysemu.h @@ -79,7 +79,9 @@ int qemu_loadvm_state(QEMUFile *f); /* SLIRP */ void do_info_slirp(Monitor *mon); +/* OS specific functions */ void os_setup_early_signal_handling(void); +char *os_find_datadir(const char *argv0); typedef enum DisplayType { diff --git a/vl.c b/vl.c index 1fd839d..3e56121 100644 --- a/vl.c +++ b/vl.c @@ -1986,95 +1986,6 @@ static int balloon_parse(const char *arg) return -1; } -#ifdef _WIN32 -/* Look for support files in the same directory as the executable. */ -static char *find_datadir(const char *argv0) -{ -char *p; -char buf[MAX_PATH]; -DWORD len; - -len = GetModuleFileName(NULL, buf, sizeof(buf) - 1); -if (len == 0) { -return NULL; -} - -buf[len] = 0; -p = buf + len - 1; -while (p != buf *p != '\\') -p--; -*p = 0; -if (access(buf, R_OK) == 0) { -return qemu_strdup(buf); -} -return NULL; -} -#else /* !_WIN32 */ - -/* Find a likely location for support files using the location of the binary. - For installed binaries this will be $bindir/../share/qemu. When - running from the build tree this will be $bindir/../pc-bios. */ -#define SHARE_SUFFIX /share/qemu -#define BUILD_SUFFIX /pc-bios -static char *find_datadir(const char *argv0) -{ -char *dir; -char *p = NULL; -char *res; -char buf[PATH_MAX]; -size_t max_len; - -#if defined(__linux__) -{ -int len; -len = readlink(/proc/self/exe, buf, sizeof(buf) - 1); -if (len 0) { -buf[len] = 0; -p = buf; -} -}
[Qemu-devel] [PATCH 05/17] Introduce os-posix.c and create os_setup_signal_handling()
From: Jes Sorensen jes.soren...@redhat.com Introcuce os-posix.c and move posix specific signal handling there. Signed-off-by: Jes Sorensen jes.soren...@redhat.com Acked-by: Juan Quintela quint...@redhat.com Acked-by: Richard Henderson r...@redhat.com --- Makefile.objs |1 + os-posix.c | 41 + qemu-os-posix.h |2 ++ vl.c|8 +--- 4 files changed, 45 insertions(+), 7 deletions(-) create mode 100644 os-posix.c diff --git a/Makefile.objs b/Makefile.objs index 58fdb03..2d94677 100644 --- a/Makefile.objs +++ b/Makefile.objs @@ -145,6 +145,7 @@ hw-obj-$(CONFIG_NAND) += nand.o hw-obj-$(CONFIG_PFLASH_CFI01) += pflash_cfi01.o hw-obj-$(CONFIG_PFLASH_CFI02) += pflash_cfi02.o hw-obj-$(CONFIG_WIN32) += os-win32.o +hw-obj-$(CONFIG_POSIX) += os-posix.o hw-obj-$(CONFIG_M48T59) += m48t59.o hw-obj-$(CONFIG_ESCC) += escc.o diff --git a/os-posix.c b/os-posix.c new file mode 100644 index 000..914a4d1 --- /dev/null +++ b/os-posix.c @@ -0,0 +1,41 @@ +/* + * os-posix.c + * + * Copyright (c) 2003-2008 Fabrice Bellard + * Copyright (c) 2010 Red Hat, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the Software), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include unistd.h +#include fcntl.h +#include signal.h + +/* Needed early for CONFIG_BSD etc. */ +#include config-host.h +#include sysemu.h + +void os_setup_signal_handling(void) +{ +struct sigaction act; +sigfillset(act.sa_mask); +act.sa_flags = 0; +act.sa_handler = SIG_IGN; +sigaction(SIGPIPE, act, NULL); +} diff --git a/qemu-os-posix.h b/qemu-os-posix.h index 96d1036..ff5adb1 100644 --- a/qemu-os-posix.h +++ b/qemu-os-posix.h @@ -30,4 +30,6 @@ static inline void os_host_main_loop_wait(int *timeout) { } +void os_setup_signal_handling(void); + #endif diff --git a/vl.c b/vl.c index 4097762..29c9697 100644 --- a/vl.c +++ b/vl.c @@ -2460,13 +2460,7 @@ int main(int argc, char **argv, char **envp) QLIST_INIT (vm_change_state_head); #ifndef _WIN32 -{ -struct sigaction act; -sigfillset(act.sa_mask); -act.sa_flags = 0; -act.sa_handler = SIG_IGN; -sigaction(SIGPIPE, act, NULL); -} +os_setup_signal_handling(); #else SetConsoleCtrlHandler(qemu_ctrl_handler, TRUE); /* Note: cpu_interrupt() is currently not SMP safe, so we force -- 1.6.5.2
[Qemu-devel] [PATCH v4 00/17] clean up vl.c code
From: Jes Sorensen jes.soren...@redhat.com v4 of the vl.c clean up patch. This one just fixes a merge conflict due to some recent changes to vl.c, and I added the Acked-By: lines I received for v3. Consider it a house-keeping update to make it easier to merge. The patches try to clean up the vl.c code by separating out OS specific code into OS specific files. Basically it is focused on moving things into os-posix.c for most UNIX/Linux systems, and os-win32.c for win32 specific bits. Cheers, Jes Jes Sorensen (17): vl.c: Remove double include of netinet/in.h for Solaris Create qemu-os-win32.h and move WIN32 specific declarations there Introduce os-win32.c and move polling functions from vl.c vl.c: Move host_main_loop_wait() to OS specific files. Introduce os-posix.c and create os_setup_signal_handling() Move win32 early signal handling setup to os_setup_signal_handling() Rename os_setup_signal_handling() to os_setup_early_signal_handling() Move main signal handler setup to os specificfiles. Move find_datadir to OS specific files. Rename qemu-options.h to qemu-options.def Introduce OS specific cmdline argument handling and move SMB arg to os-posix.c Move runas handling from vl.c to OS specific files. Move chroot handling to OS specific files. Move daemonize handling to OS specific files Make os_change_process_uid and os_change_root os-posix.c local Move line-buffering setup to OS specific files. Move set_proc_name() to OS specific files. Makefile.objs |8 +- os-posix.c | 329 + os-win32.c | 221 + qemu-options.h | 41 + qemu-os-posix.h | 39 + qemu-os-win32.h | 52 ++ sysemu.h| 27 ++-- vl.c| 491 ++- 8 files changed, 713 insertions(+), 495 deletions(-) create mode 100644 os-posix.c create mode 100644 os-win32.c create mode 100644 qemu-options.h create mode 100644 qemu-os-posix.h create mode 100644 qemu-os-win32.h
[Qemu-devel] [PATCH 07/17] Rename os_setup_signal_handling() to os_setup_early_signal_handling()
From: Jes Sorensen jes.soren...@redhat.com Rename os_setup_signal_handling() to os_setup_early_signal_handling() Signed-off-by: Jes Sorensen jes.soren...@redhat.com Acked-by: Juan Quintela quint...@redhat.com Acked-by: Richard Henderson r...@redhat.com --- os-posix.c |2 +- os-win32.c |2 +- sysemu.h |2 +- vl.c |2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/os-posix.c b/os-posix.c index 914a4d1..948f662 100644 --- a/os-posix.c +++ b/os-posix.c @@ -31,7 +31,7 @@ #include config-host.h #include sysemu.h -void os_setup_signal_handling(void) +void os_setup_early_signal_handling(void) { struct sigaction act; sigfillset(act.sa_mask); diff --git a/os-win32.c b/os-win32.c index dfa90bc..a936f7a 100644 --- a/os-win32.c +++ b/os-win32.c @@ -159,7 +159,7 @@ static BOOL WINAPI qemu_ctrl_handler(DWORD type) return TRUE; } -void os_setup_signal_handling(void) +void os_setup_early_signal_handling(void) { /* Note: cpu_interrupt() is currently not SMP safe, so we force QEMU to run on a single CPU */ diff --git a/sysemu.h b/sysemu.h index e3643ad..bb05cf4 100644 --- a/sysemu.h +++ b/sysemu.h @@ -79,7 +79,7 @@ int qemu_loadvm_state(QEMUFile *f); /* SLIRP */ void do_info_slirp(Monitor *mon); -void os_setup_signal_handling(void); +void os_setup_early_signal_handling(void); typedef enum DisplayType { diff --git a/vl.c b/vl.c index 264710d..a8fcb65 100644 --- a/vl.c +++ b/vl.c @@ -2451,7 +2451,7 @@ int main(int argc, char **argv, char **envp) qemu_cache_utils_init(envp); QLIST_INIT (vm_change_state_head); -os_setup_signal_handling(); +os_setup_early_signal_handling(); module_call_init(MODULE_INIT_MACHINE); machine = find_default_machine(); -- 1.6.5.2
[Qemu-devel] [PATCH 16/17] Move line-buffering setup to OS specific files.
From: Jes Sorensen jes.soren...@redhat.com Move line-buffering setup to OS specific files. Signed-off-by: Jes Sorensen jes.soren...@redhat.com Acked-by: Juan Quintela quint...@redhat.com Acked-by: Richard Henderson r...@redhat.com --- os-posix.c |5 + qemu-os-posix.h |1 + qemu-os-win32.h |2 ++ vl.c|5 + 4 files changed, 9 insertions(+), 4 deletions(-) diff --git a/os-posix.c b/os-posix.c index 3a96c91..9bae8fe 100644 --- a/os-posix.c +++ b/os-posix.c @@ -298,3 +298,8 @@ void os_pidfile_error(void) } else fprintf(stderr, Could not acquire pid file: %s\n, strerror(errno)); } + +void os_set_line_buffering(void) +{ +setvbuf(stdout, NULL, _IOLBF, 0); +} diff --git a/qemu-os-posix.h b/qemu-os-posix.h index 8be583d..cb210ba 100644 --- a/qemu-os-posix.h +++ b/qemu-os-posix.h @@ -30,6 +30,7 @@ static inline void os_host_main_loop_wait(int *timeout) { } +void os_set_line_buffering(void); void os_setup_signal_handling(void); void os_daemonize(void); void os_setup_post(void); diff --git a/qemu-os-win32.h b/qemu-os-win32.h index 39df333..5a97d8d 100644 --- a/qemu-os-win32.h +++ b/qemu-os-win32.h @@ -45,5 +45,7 @@ void os_host_main_loop_wait(int *timeout); static inline void os_setup_signal_handling(void) {} static inline void os_daemonize(void) {} static inline void os_setup_post(void) {} +/* Win32 doesn't support line-buffering and requires size = 2 */ +static inline void os_set_line_buffering(void) {} #endif diff --git a/vl.c b/vl.c index 8902477..f18886a 100644 --- a/vl.c +++ b/vl.c @@ -3215,10 +3215,7 @@ int main(int argc, char **argv, char **envp) exit(1); } -#ifndef _WIN32 -/* Win32 doesn't support line-buffering and requires size = 2 */ -setvbuf(stdout, NULL, _IOLBF, 0); -#endif +os_set_line_buffering(); if (init_timer_alarm() 0) { fprintf(stderr, could not initialize alarm timer\n); -- 1.6.5.2
[Qemu-devel] [PATCH 14/17] Move daemonize handling to OS specific files
From: Jes Sorensen jes.soren...@redhat.com Move daemonize handling from vl.c to OS specific files. Provide dummy stubs for Win32. Signed-off-by: Jes Sorensen jes.soren...@redhat.com Acked-by: Juan Quintela quint...@redhat.com Acked-by: Richard Henderson r...@redhat.com --- os-posix.c | 102 os-win32.c |5 +++ qemu-os-posix.h |2 + qemu-os-win32.h |2 + sysemu.h|1 + vl.c| 106 ++- 6 files changed, 115 insertions(+), 103 deletions(-) diff --git a/os-posix.c b/os-posix.c index 6417d16..1672e06 100644 --- a/os-posix.c +++ b/os-posix.c @@ -39,6 +39,8 @@ static struct passwd *user_pwd; static const char *chroot_dir; +static int daemonize; +static int fds[2]; void os_setup_early_signal_handling(void) { @@ -160,6 +162,9 @@ void os_parse_cmd_args(int index, const char *optarg) case QEMU_OPTION_chroot: chroot_dir = optarg; break; +case QEMU_OPTION_daemonize: +daemonize = 1; +break; } return; } @@ -196,3 +201,100 @@ void os_change_root(void) } } + +void os_daemonize(void) +{ +if (daemonize) { + pid_t pid; + + if (pipe(fds) == -1) + exit(1); + + pid = fork(); + if (pid 0) { + uint8_t status; + ssize_t len; + + close(fds[1]); + + again: +len = read(fds[0], status, 1); +if (len == -1 (errno == EINTR)) +goto again; + +if (len != 1) +exit(1); +else if (status == 1) { +fprintf(stderr, Could not acquire pidfile: %s\n, strerror(errno)); +exit(1); +} else +exit(0); + } else if (pid 0) +exit(1); + + close(fds[0]); + qemu_set_cloexec(fds[1]); + + setsid(); + + pid = fork(); + if (pid 0) + exit(0); + else if (pid 0) + exit(1); + + umask(027); + +signal(SIGTSTP, SIG_IGN); +signal(SIGTTOU, SIG_IGN); +signal(SIGTTIN, SIG_IGN); +} +} + +void os_setup_post(void) +{ +int fd = 0; + +if (daemonize) { + uint8_t status = 0; + ssize_t len; + +again1: + len = write(fds[1], status, 1); + if (len == -1 (errno == EINTR)) + goto again1; + + if (len != 1) + exit(1); + +if (chdir(/)) { +perror(not able to chdir to /); +exit(1); +} + TFR(fd = qemu_open(/dev/null, O_RDWR)); + if (fd == -1) + exit(1); +} + +os_change_root(); +os_change_process_uid(); + +if (daemonize) { +dup2(fd, 0); +dup2(fd, 1); +dup2(fd, 2); + +close(fd); +} +} + +void os_pidfile_error(void) +{ +if (daemonize) { +uint8_t status = 1; +if (write(fds[1], status, 1) != 1) { +perror(daemonize. Writing to pipe\n); +} +} else +fprintf(stderr, Could not acquire pid file: %s\n, strerror(errno)); +} diff --git a/os-win32.c b/os-win32.c index aefc535..d98fd77 100644 --- a/os-win32.c +++ b/os-win32.c @@ -214,3 +214,8 @@ void os_parse_cmd_args(int index, const char *optarg) { return; } + +void os_pidfile_error(void) +{ +fprintf(stderr, Could not acquire pid file: %s\n, strerror(errno)); +} diff --git a/qemu-os-posix.h b/qemu-os-posix.h index 91c7b68..9b07660 100644 --- a/qemu-os-posix.h +++ b/qemu-os-posix.h @@ -33,5 +33,7 @@ static inline void os_host_main_loop_wait(int *timeout) void os_setup_signal_handling(void); void os_change_process_uid(void); void os_change_root(void); +void os_daemonize(void); +void os_setup_post(void); #endif diff --git a/qemu-os-win32.h b/qemu-os-win32.h index e2a97d2..c4aa84a 100644 --- a/qemu-os-win32.h +++ b/qemu-os-win32.h @@ -45,5 +45,7 @@ void os_host_main_loop_wait(int *timeout); static inline void os_setup_signal_handling(void) {} static inline void os_change_process_uid(void) {} static inline void os_change_root(void) {} +static inline void os_daemonize(void) {} +static inline void os_setup_post(void) {} #endif diff --git a/sysemu.h b/sysemu.h index 2162b1d..346cccd 100644 --- a/sysemu.h +++ b/sysemu.h @@ -83,6 +83,7 @@ void do_info_slirp(Monitor *mon); void os_setup_early_signal_handling(void); char *os_find_datadir(const char *argv0); void os_parse_cmd_args(int index, const char *optarg); +void os_pidfile_error(void); typedef enum DisplayType { diff --git a/vl.c b/vl.c index c5f0e63..8902477 100644 --- a/vl.c +++ b/vl.c @@ -216,9 +216,6 @@ int no_shutdown = 0; int cursor_hide = 1; int graphic_rotate = 0; uint8_t irq0override = 1; -#ifndef _WIN32 -int daemonize = 0; -#endif const char *watchdog; const char *option_rom[MAX_OPTION_ROMS]; int nb_option_roms; @@ -2301,15 +2298,9 @@ int main(int argc, char **argv, char **envp) const char *loadvm =
[Qemu-devel] [PATCH 08/17] Move main signal handler setup to os specificfiles.
From: Jes Sorensen jes.soren...@redhat.com Move main signal handler setup to os specific files. Signed-off-by: Jes Sorensen jes.soren...@redhat.com Acked-by: Juan Quintela quint...@redhat.com Acked-by: Richard Henderson r...@redhat.com --- os-posix.c | 27 +++ qemu-os-posix.h |2 ++ qemu-os-win32.h |3 +++ vl.c| 33 + 4 files changed, 33 insertions(+), 32 deletions(-) diff --git a/os-posix.c b/os-posix.c index 948f662..01dbec2 100644 --- a/os-posix.c +++ b/os-posix.c @@ -26,6 +26,8 @@ #include unistd.h #include fcntl.h #include signal.h +#include sys/types.h +#include sys/wait.h /* Needed early for CONFIG_BSD etc. */ #include config-host.h @@ -39,3 +41,28 @@ void os_setup_early_signal_handling(void) act.sa_handler = SIG_IGN; sigaction(SIGPIPE, act, NULL); } + +static void termsig_handler(int signal) +{ +qemu_system_shutdown_request(); +} + +static void sigchld_handler(int signal) +{ +waitpid(-1, NULL, WNOHANG); +} + +void os_setup_signal_handling(void) +{ +struct sigaction act; + +memset(act, 0, sizeof(act)); +act.sa_handler = termsig_handler; +sigaction(SIGINT, act, NULL); +sigaction(SIGHUP, act, NULL); +sigaction(SIGTERM, act, NULL); + +act.sa_handler = sigchld_handler; +act.sa_flags = SA_NOCLDSTOP; +sigaction(SIGCHLD, act, NULL); +} diff --git a/qemu-os-posix.h b/qemu-os-posix.h index 96d1036..ff5adb1 100644 --- a/qemu-os-posix.h +++ b/qemu-os-posix.h @@ -30,4 +30,6 @@ static inline void os_host_main_loop_wait(int *timeout) { } +void os_setup_signal_handling(void); + #endif diff --git a/qemu-os-win32.h b/qemu-os-win32.h index 4d1cac8..e7e2ee3 100644 --- a/qemu-os-win32.h +++ b/qemu-os-win32.h @@ -41,4 +41,7 @@ int qemu_add_wait_object(HANDLE handle, WaitObjectFunc *func, void *opaque); void qemu_del_wait_object(HANDLE handle, WaitObjectFunc *func, void *opaque); void os_host_main_loop_wait(int *timeout); + +static inline void os_setup_signal_handling(void) {} + #endif diff --git a/vl.c b/vl.c index a8fcb65..1fd839d 100644 --- a/vl.c +++ b/vl.c @@ -1986,35 +1986,6 @@ static int balloon_parse(const char *arg) return -1; } -#ifndef _WIN32 - -static void termsig_handler(int signal) -{ -qemu_system_shutdown_request(); -} - -static void sigchld_handler(int signal) -{ -waitpid(-1, NULL, WNOHANG); -} - -static void sighandler_setup(void) -{ -struct sigaction act; - -memset(act, 0, sizeof(act)); -act.sa_handler = termsig_handler; -sigaction(SIGINT, act, NULL); -sigaction(SIGHUP, act, NULL); -sigaction(SIGTERM, act, NULL); - -act.sa_handler = sigchld_handler; -act.sa_flags = SA_NOCLDSTOP; -sigaction(SIGCHLD, act, NULL); -} - -#endif - #ifdef _WIN32 /* Look for support files in the same directory as the executable. */ static char *find_datadir(const char *argv0) @@ -3556,10 +3527,8 @@ int main(int argc, char **argv, char **envp) cpu_synchronize_all_post_init(); -#ifndef _WIN32 /* must be after terminal init, SDL library changes signal handlers */ -sighandler_setup(); -#endif +os_setup_signal_handling(); set_numa_modes(); -- 1.6.5.2
[Qemu-devel] [PATCH 10/17] Rename qemu-options.h to qemu-options.def
From: Jes Sorensen jes.soren...@redhat.com Rename qemu-options.h to qemu-options.def as it is not a header file for general use and this leaves space for a proper qemu-options.h Signed-off-by: Jes Sorensen jes.soren...@redhat.com Acked-by: Juan Quintela quint...@redhat.com Acked-by: Richard Henderson r...@redhat.com --- Makefile.objs |4 ++-- vl.c |6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Makefile.objs b/Makefile.objs index 2d94677..124afe7 100644 --- a/Makefile.objs +++ b/Makefile.objs @@ -258,8 +258,8 @@ vl.o: QEMU_CFLAGS+=$(GPROF_CFLAGS) vl.o: QEMU_CFLAGS+=$(SDL_CFLAGS) -vl.o: qemu-options.h +vl.o: qemu-options.def -qemu-options.h: $(SRC_PATH)/qemu-options.hx +qemu-options.def: $(SRC_PATH)/qemu-options.hx $(call quiet-command,sh $(SRC_PATH)/hxtool -h $ $@, GEN $(TARGET_DIR)$@) diff --git a/vl.c b/vl.c index 3e56121..214b9c1 100644 --- a/vl.c +++ b/vl.c @@ -1875,7 +1875,7 @@ static void help(int exitcode) #define DEF(option, opt_arg, opt_enum, opt_help, arch_mask) \ opt_help #define DEFHEADING(text) stringify(text) \n -#include qemu-options.h +#include qemu-options.def #undef DEF #undef DEFHEADING #undef GEN_DOCS @@ -1903,7 +1903,7 @@ enum { #define DEF(option, opt_arg, opt_enum, opt_help, arch_mask) \ opt_enum, #define DEFHEADING(text) -#include qemu-options.h +#include qemu-options.def #undef DEF #undef DEFHEADING #undef GEN_DOCS @@ -1921,7 +1921,7 @@ static const QEMUOption qemu_options[] = { #define DEF(option, opt_arg, opt_enum, opt_help, arch_mask) \ { option, opt_arg, opt_enum, arch_mask }, #define DEFHEADING(text) -#include qemu-options.h +#include qemu-options.def #undef DEF #undef DEFHEADING #undef GEN_DOCS -- 1.6.5.2
[Qemu-devel] [PATCH 17/17] Move set_proc_name() to OS specific files.
From: Jes Sorensen jes.soren...@redhat.com Move handling to change process name to POSIX specific files plus add a better error message to cover the case where the feature isn't supported. Signed-off-by: Jes Sorensen jes.soren...@redhat.com Acked-by: Juan Quintela quint...@redhat.com Acked-by: Richard Henderson r...@redhat.com --- os-posix.c | 24 qemu-os-posix.h |1 + qemu-os-win32.h |1 + vl.c| 19 +-- 4 files changed, 27 insertions(+), 18 deletions(-) diff --git a/os-posix.c b/os-posix.c index 9bae8fe..d89020d 100644 --- a/os-posix.c +++ b/os-posix.c @@ -37,6 +37,10 @@ #include net/slirp.h #include qemu-options.h +#ifdef CONFIG_LINUX +#include sys/prctl.h +#endif + static struct passwd *user_pwd; static const char *chroot_dir; static int daemonize; @@ -139,6 +143,26 @@ char *os_find_datadir(const char *argv0) #undef SHARE_SUFFIX #undef BUILD_SUFFIX +void os_set_proc_name(const char *s) +{ +#if defined(PR_SET_NAME) +char name[16]; +if (!s) +return; +name[sizeof(name) - 1] = 0; +strncpy(name, s, sizeof(name)); +/* Could rewrite argv[0] too, but that's a bit more complicated. + This simple way is enough for `top'. */ +if (prctl(PR_SET_NAME, name)) { +perror(unable to change process name); +exit(1); +} +#else +fprintf(stderr, Change of process name not supported by your OS\n); +exit(1); +#endif +} + /* * Parse OS specific command line options. * return 0 if option handled, -1 otherwise diff --git a/qemu-os-posix.h b/qemu-os-posix.h index cb210ba..ed5c058 100644 --- a/qemu-os-posix.h +++ b/qemu-os-posix.h @@ -31,6 +31,7 @@ static inline void os_host_main_loop_wait(int *timeout) } void os_set_line_buffering(void); +void os_set_proc_name(const char *s); void os_setup_signal_handling(void); void os_daemonize(void); void os_setup_post(void); diff --git a/qemu-os-win32.h b/qemu-os-win32.h index 5a97d8d..6323f7f 100644 --- a/qemu-os-win32.h +++ b/qemu-os-win32.h @@ -47,5 +47,6 @@ static inline void os_daemonize(void) {} static inline void os_setup_post(void) {} /* Win32 doesn't support line-buffering and requires size = 2 */ static inline void os_set_line_buffering(void) {} +static inline void os_set_proc_name(const char *dummy) {} #endif diff --git a/vl.c b/vl.c index f18886a..9eac300 100644 --- a/vl.c +++ b/vl.c @@ -59,7 +59,6 @@ #ifdef __linux__ #include pty.h #include malloc.h -#include sys/prctl.h #include linux/ppdev.h #include linux/parport.h @@ -284,22 +283,6 @@ static int default_driver_check(QemuOpts *opts, void *opaque) } /***/ - -static void set_proc_name(const char *s) -{ -#if defined(__linux__) defined(PR_SET_NAME) -char name[16]; -if (!s) -return; -name[sizeof(name) - 1] = 0; -strncpy(name, s, sizeof(name)); -/* Could rewrite argv[0] too, but that's a bit more complicated. - This simple way is enough for `top'. */ -prctl(PR_SET_NAME, name); -#endif -} - -/***/ /* real time host monotonic timer */ /* compute with 96 bit intermediate result: (a*b)/c */ @@ -2988,7 +2971,7 @@ int main(int argc, char **argv, char **envp) exit(1); } p += 8; - set_proc_name(p); + os_set_proc_name(p); } } break; -- 1.6.5.2
[Qemu-devel] [PATCH 12/17] Move runas handling from vl.c to OS specific files.
From: Jes Sorensen jes.soren...@redhat.com Move code to handle runas, ie. change of user id of QEMU process to OS specific files and provide dummy stub for Win32. Signed-off-by: Jes Sorensen jes.soren...@redhat.com Acked-by: Juan Quintela quint...@redhat.com Acked-by: Richard Henderson r...@redhat.com --- os-posix.c | 28 qemu-os-posix.h |1 + qemu-os-win32.h |1 + vl.c| 29 + 4 files changed, 31 insertions(+), 28 deletions(-) diff --git a/os-posix.c b/os-posix.c index 0deddf3..8b686a4 100644 --- a/os-posix.c +++ b/os-posix.c @@ -28,6 +28,7 @@ #include signal.h #include sys/types.h #include sys/wait.h +#include pwd.h #include libgen.h /* Needed early for CONFIG_BSD etc. */ @@ -36,6 +37,8 @@ #include net/slirp.h #include qemu-options.h +static struct passwd *user_pwd; + void os_setup_early_signal_handling(void) { struct sigaction act; @@ -146,6 +149,31 @@ void os_parse_cmd_args(int index, const char *optarg) exit(1); break; #endif +case QEMU_OPTION_runas: +user_pwd = getpwnam(optarg); +if (!user_pwd) { +fprintf(stderr, User \%s\ doesn't exist\n, optarg); +exit(1); +} +break; } return; } + +void os_change_process_uid(void) +{ +if (user_pwd) { +if (setgid(user_pwd-pw_gid) 0) { +fprintf(stderr, Failed to setgid(%d)\n, user_pwd-pw_gid); +exit(1); +} +if (setuid(user_pwd-pw_uid) 0) { +fprintf(stderr, Failed to setuid(%d)\n, user_pwd-pw_uid); +exit(1); +} +if (setuid(0) != -1) { +fprintf(stderr, Dropping privileges failed\n); +exit(1); +} +} +} diff --git a/qemu-os-posix.h b/qemu-os-posix.h index ff5adb1..6d8cf79 100644 --- a/qemu-os-posix.h +++ b/qemu-os-posix.h @@ -31,5 +31,6 @@ static inline void os_host_main_loop_wait(int *timeout) } void os_setup_signal_handling(void); +void os_change_process_uid(void); #endif diff --git a/qemu-os-win32.h b/qemu-os-win32.h index e7e2ee3..70fdca5 100644 --- a/qemu-os-win32.h +++ b/qemu-os-win32.h @@ -43,5 +43,6 @@ void qemu_del_wait_object(HANDLE handle, WaitObjectFunc *func, void *opaque); void os_host_main_loop_wait(int *timeout); static inline void os_setup_signal_handling(void) {} +static inline void os_change_process_uid(void) {} #endif diff --git a/vl.c b/vl.c index 417c5f3..4b76e2d 100644 --- a/vl.c +++ b/vl.c @@ -34,7 +34,6 @@ #ifndef _WIN32 #include libgen.h -#include pwd.h #include sys/times.h #include sys/wait.h #include termios.h @@ -2310,9 +2309,7 @@ int main(int argc, char **argv, char **envp) const char *incoming = NULL; #ifndef _WIN32 int fd = 0; -struct passwd *pwd = NULL; const char *chroot_dir = NULL; -const char *run_as = NULL; #endif int show_vnc_port = 0; int defconfig = 1; @@ -3060,9 +3057,6 @@ int main(int argc, char **argv, char **envp) case QEMU_OPTION_chroot: chroot_dir = optarg; break; -case QEMU_OPTION_runas: -run_as = optarg; -break; #endif case QEMU_OPTION_xen_domid: if (!(xen_available())) { @@ -3553,14 +3547,6 @@ int main(int argc, char **argv, char **envp) exit(1); } -if (run_as) { -pwd = getpwnam(run_as); -if (!pwd) { -fprintf(stderr, User \%s\ doesn't exist\n, run_as); -exit(1); -} -} - if (chroot_dir) { if (chroot(chroot_dir) 0) { fprintf(stderr, chroot failed\n); @@ -3572,20 +3558,7 @@ int main(int argc, char **argv, char **envp) } } -if (run_as) { -if (setgid(pwd-pw_gid) 0) { -fprintf(stderr, Failed to setgid(%d)\n, pwd-pw_gid); -exit(1); -} -if (setuid(pwd-pw_uid) 0) { -fprintf(stderr, Failed to setuid(%d)\n, pwd-pw_uid); -exit(1); -} -if (setuid(0) != -1) { -fprintf(stderr, Dropping privileges failed\n); -exit(1); -} -} +os_change_process_uid(); if (daemonize) { dup2(fd, 0); -- 1.6.5.2
[Qemu-devel] [PATCH 13/17] Move chroot handling to OS specific files.
From: Jes Sorensen jes.soren...@redhat.com Move chroot handling to OS specific files. Signed-off-by: Jes Sorensen jes.soren...@redhat.com Acked-by: Juan Quintela quint...@redhat.com Acked-by: Richard Henderson r...@redhat.com --- os-posix.c | 19 +++ qemu-os-posix.h |1 + qemu-os-win32.h |1 + vl.c| 18 +- 4 files changed, 22 insertions(+), 17 deletions(-) diff --git a/os-posix.c b/os-posix.c index 8b686a4..6417d16 100644 --- a/os-posix.c +++ b/os-posix.c @@ -38,6 +38,7 @@ #include qemu-options.h static struct passwd *user_pwd; +static const char *chroot_dir; void os_setup_early_signal_handling(void) { @@ -156,6 +157,9 @@ void os_parse_cmd_args(int index, const char *optarg) exit(1); } break; +case QEMU_OPTION_chroot: +chroot_dir = optarg; +break; } return; } @@ -177,3 +181,18 @@ void os_change_process_uid(void) } } } + +void os_change_root(void) +{ +if (chroot_dir) { +if (chroot(chroot_dir) 0) { +fprintf(stderr, chroot failed\n); +exit(1); +} +if (chdir(/)) { +perror(not able to chdir to /); +exit(1); +} +} + +} diff --git a/qemu-os-posix.h b/qemu-os-posix.h index 6d8cf79..91c7b68 100644 --- a/qemu-os-posix.h +++ b/qemu-os-posix.h @@ -32,5 +32,6 @@ static inline void os_host_main_loop_wait(int *timeout) void os_setup_signal_handling(void); void os_change_process_uid(void); +void os_change_root(void); #endif diff --git a/qemu-os-win32.h b/qemu-os-win32.h index 70fdca5..e2a97d2 100644 --- a/qemu-os-win32.h +++ b/qemu-os-win32.h @@ -44,5 +44,6 @@ void os_host_main_loop_wait(int *timeout); static inline void os_setup_signal_handling(void) {} static inline void os_change_process_uid(void) {} +static inline void os_change_root(void) {} #endif diff --git a/vl.c b/vl.c index 4b76e2d..c5f0e63 100644 --- a/vl.c +++ b/vl.c @@ -2309,7 +2309,6 @@ int main(int argc, char **argv, char **envp) const char *incoming = NULL; #ifndef _WIN32 int fd = 0; -const char *chroot_dir = NULL; #endif int show_vnc_port = 0; int defconfig = 1; @@ -3053,11 +3052,6 @@ int main(int argc, char **argv, char **envp) default_cdrom = 0; default_sdcard = 0; break; -#ifndef _WIN32 -case QEMU_OPTION_chroot: -chroot_dir = optarg; -break; -#endif case QEMU_OPTION_xen_domid: if (!(xen_available())) { printf(Option %s not supported for this target\n, popt-name); @@ -3547,17 +3541,7 @@ int main(int argc, char **argv, char **envp) exit(1); } -if (chroot_dir) { -if (chroot(chroot_dir) 0) { -fprintf(stderr, chroot failed\n); -exit(1); -} -if (chdir(/)) { -perror(not able to chdir to /); -exit(1); -} -} - +os_change_root(); os_change_process_uid(); if (daemonize) { -- 1.6.5.2
[Qemu-devel] [PATCH 11/17] Introduce OS specific cmdline argument handling and move SMB arg to os-posix.c
From: Jes Sorensen jes.soren...@redhat.com Introduce OS specific cmdline argument handling by calling os_parse_cmd_args() at the end of switch() statement. Move option enum to qemu-options.h and have it included from os-posix.c and os-win32.c in addition to vl.c. In addition move SMB argument to os-posix.c Signed-off-by: Jes Sorensen jes.soren...@redhat.com Acked-by: Juan Quintela quint...@redhat.com Acked-by: Richard Henderson r...@redhat.com --- Makefile.objs |2 ++ os-posix.c | 19 +++ os-win32.c | 10 ++ qemu-options.h | 41 + sysemu.h |1 + vl.c | 19 +++ 6 files changed, 76 insertions(+), 16 deletions(-) create mode 100644 qemu-options.h diff --git a/Makefile.objs b/Makefile.objs index 124afe7..27595df 100644 --- a/Makefile.objs +++ b/Makefile.objs @@ -259,6 +259,8 @@ vl.o: QEMU_CFLAGS+=$(GPROF_CFLAGS) vl.o: QEMU_CFLAGS+=$(SDL_CFLAGS) vl.o: qemu-options.def +os-posix.o: qemu-options.def +os-win32.o: qemu-options.def qemu-options.def: $(SRC_PATH)/qemu-options.hx $(call quiet-command,sh $(SRC_PATH)/hxtool -h $ $@, GEN $(TARGET_DIR)$@) diff --git a/os-posix.c b/os-posix.c index 621ad06..0deddf3 100644 --- a/os-posix.c +++ b/os-posix.c @@ -33,6 +33,8 @@ /* Needed early for CONFIG_BSD etc. */ #include config-host.h #include sysemu.h +#include net/slirp.h +#include qemu-options.h void os_setup_early_signal_handling(void) { @@ -130,3 +132,20 @@ char *os_find_datadir(const char *argv0) } #undef SHARE_SUFFIX #undef BUILD_SUFFIX + +/* + * Parse OS specific command line options. + * return 0 if option handled, -1 otherwise + */ +void os_parse_cmd_args(int index, const char *optarg) +{ +switch (index) { +#ifdef CONFIG_SLIRP +case QEMU_OPTION_smb: +if (net_slirp_smb(optarg) 0) +exit(1); +break; +#endif +} +return; +} diff --git a/os-win32.c b/os-win32.c index 1758538..aefc535 100644 --- a/os-win32.c +++ b/os-win32.c @@ -31,6 +31,7 @@ #include sys/time.h #include config-host.h #include sysemu.h +#include qemu-options.h /***/ /* Polling handling */ @@ -204,3 +205,12 @@ char *os_find_datadir(const char *argv0) } return NULL; } + +/* + * Parse OS specific command line options. + * return 0 if option handled, -1 otherwise + */ +void os_parse_cmd_args(int index, const char *optarg) +{ +return; +} diff --git a/qemu-options.h b/qemu-options.h new file mode 100644 index 000..c96f994 --- /dev/null +++ b/qemu-options.h @@ -0,0 +1,41 @@ +/* + * qemu-options.h + * + * Defines needed for command line argument processing. + * + * Copyright (c) 2003-2008 Fabrice Bellard + * Copyright (c) 2010 Jes Sorensen jes.soren...@redhat.com + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the Software), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#ifndef _QEMU_OPTIONS_H_ +#define _QEMU_OPTIONS_H_ + +enum { +#define DEF(option, opt_arg, opt_enum, opt_help, arch_mask) \ +opt_enum, +#define DEFHEADING(text) +#include qemu-options.def +#undef DEF +#undef DEFHEADING +#undef GEN_DOCS +}; + +#endif diff --git a/sysemu.h b/sysemu.h index 72f3734..2162b1d 100644 --- a/sysemu.h +++ b/sysemu.h @@ -82,6 +82,7 @@ void do_info_slirp(Monitor *mon); /* OS specific functions */ void os_setup_early_signal_handling(void); char *os_find_datadir(const char *argv0); +void os_parse_cmd_args(int index, const char *optarg); typedef enum DisplayType { diff --git a/vl.c b/vl.c index 214b9c1..417c5f3 100644 --- a/vl.c +++ b/vl.c @@ -148,6 +148,7 @@ int main(int argc, char **argv) #include qemu-option.h #include qemu-config.h #include qemu-objects.h +#include qemu-options.h #ifdef CONFIG_LINUX #include fsdev/qemu-fsdev.h #endif @@ -1899,16 +1900,6 @@ static void help(int exitcode) #define HAS_ARG 0x0001 -enum { -#define DEF(option, opt_arg, opt_enum, opt_help, arch_mask) \ -opt_enum,
[Qemu-devel] [PATCH 15/17] Make os_change_process_uid and os_change_root os-posix.c local
From: Jes Sorensen jes.soren...@redhat.com os_change_process_uid() and os_change_root() are now only called from os-posix.c, so no need to keep win32 stubs for them. Signed-off-by: Jes Sorensen jes.soren...@redhat.com Acked-by: Juan Quintela quint...@redhat.com Acked-by: Richard Henderson r...@redhat.com --- os-posix.c |8 qemu-os-posix.h |2 -- qemu-os-win32.h |2 -- 3 files changed, 4 insertions(+), 8 deletions(-) diff --git a/os-posix.c b/os-posix.c index 1672e06..3a96c91 100644 --- a/os-posix.c +++ b/os-posix.c @@ -169,7 +169,7 @@ void os_parse_cmd_args(int index, const char *optarg) return; } -void os_change_process_uid(void) +static void change_process_uid(void) { if (user_pwd) { if (setgid(user_pwd-pw_gid) 0) { @@ -187,7 +187,7 @@ void os_change_process_uid(void) } } -void os_change_root(void) +static void change_root(void) { if (chroot_dir) { if (chroot(chroot_dir) 0) { @@ -276,8 +276,8 @@ void os_setup_post(void) exit(1); } -os_change_root(); -os_change_process_uid(); +change_root(); +change_process_uid(); if (daemonize) { dup2(fd, 0); diff --git a/qemu-os-posix.h b/qemu-os-posix.h index 9b07660..8be583d 100644 --- a/qemu-os-posix.h +++ b/qemu-os-posix.h @@ -31,8 +31,6 @@ static inline void os_host_main_loop_wait(int *timeout) } void os_setup_signal_handling(void); -void os_change_process_uid(void); -void os_change_root(void); void os_daemonize(void); void os_setup_post(void); diff --git a/qemu-os-win32.h b/qemu-os-win32.h index c4aa84a..39df333 100644 --- a/qemu-os-win32.h +++ b/qemu-os-win32.h @@ -43,8 +43,6 @@ void qemu_del_wait_object(HANDLE handle, WaitObjectFunc *func, void *opaque); void os_host_main_loop_wait(int *timeout); static inline void os_setup_signal_handling(void) {} -static inline void os_change_process_uid(void) {} -static inline void os_change_root(void) {} static inline void os_daemonize(void) {} static inline void os_setup_post(void) {} -- 1.6.5.2
[Qemu-devel] Re: [PATCH 6/6] apic: avoid using CPUState internals
On 06/09/2010 09:59 PM, Blue Swirl wrote: struct APICState { -CPUState *cpu_env; +void *cpu_env; I proposed having an opaque CPUState type in hw/ but it was rejected. But I don't think using a void pointer is any better. It's not necessary for the patch. Maybe it's possible to avoid all CPUState references in apic.c by pushing the dependencies to pc.c. It could affect performance though. I think it's unnecessary. But I'd leave CPUState Paolo
Re: [Qemu-devel] Re: KVM call minutes for June 8
Am 09.06.2010 18:22, schrieb Anthony Liguori: On 06/09/2010 10:31 AM, Daniel P. Berrange wrote: However, libvirt was counting on this feature and on the snapshot commands to switch from the text Monitor. We have two options: 1. Ask them to wait one more release (not so good for us) 2. Try to find a way to have those features in for 0.13 Daniel has commented to me that making the snapshot commands synchronous for 0.13 wouldn't be that bad, what do you think? The thought is that changing a command from synchronous to asynchronous is not an ABI incompatible change. An existing app simply won't know to take advantage of the new possibilities that async commands offer. It's not QMP that's the major issue with savevm. The major issue is actually the way snapshots are saved in qcow2. You need to know the size of the snapshot prior to creating the snapshot Huh, why this? Seems I still haven't understood all of qcow2 then... I always thought that there's just a specific offset where VM state starts, but no explicit end. Kevin
Re: [Qemu-devel] [PATCH 10/35] tcg-s390: New TCG target
On Fri, Jun 04, 2010 at 12:14:18PM -0700, Richard Henderson wrote: We already have stubs for a TCG target on S390, but were missing code that would actually generate instructions. So I took Uli's patch, cleaned it up and present it to you again :-). I hope I found all odd coding style and unprettiness issues, but if you still spot one feel free to nag about it. Signed-off-by: Alexander Graf ag...@suse.de CC: Uli Hecht u...@suse.de Signed-off-by: Richard Henderson r...@twiddle.net --- tcg/s390/tcg-target.c | 1171 - tcg/s390/tcg-target.h | 13 +- 2 files changed, 1157 insertions(+), 27 deletions(-) This patch is difficult to review, as a lot of changes are done in latter patches. I think the best would be to do a quick final review after squashing all the tcg/s390/* patches all together. diff --git a/tcg/s390/tcg-target.c b/tcg/s390/tcg-target.c index 265194a..55f0fa9 100644 --- a/tcg/s390/tcg-target.c +++ b/tcg/s390/tcg-target.c @@ -2,6 +2,7 @@ * Tiny Code Generator for QEMU * * Copyright (c) 2009 Ulrich Hecht u...@suse.de + * Copyright (c) 2009 Alexander Graf ag...@suse.de * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the Software), to deal @@ -22,81 +23,1209 @@ * THE SOFTWARE. */ +/* #define DEBUG_S390_TCG */ + +#ifdef DEBUG_S390_TCG +#define dprintf(fmt, ...) \ +do { fprintf(stderr, fmt, ## __VA_ARGS__); } while (0) +#else +#define dprintf(fmt, ...) \ +do { } while (0) +#endif + +#define TCG_CT_CONST_S160x100 +#define TCG_CT_CONST_U120x200 + +/* Several places within the instruction set 0 means no register + rather than TCG_REG_R0. */ +#define TCG_REG_NONE0 + +/* All of the following instructions are prefixed with their instruction + format, and are defined as 8- or 16-bit quantities, even when the two + halves of the 16-bit quantity may appear 32 bits apart in the insn. + This makes it easy to copy the values from the tables in Appendix B. */ +typedef enum S390Opcode { +RIL_BRASL = 0xc005, +RIL_BRCL= 0xc004, +RIL_LARL= 0xc000, + +RI_AGHI = 0xa70b, +RI_AHI = 0xa70a, +RI_BRC = 0xa704, +RI_IILH = 0xa502, +RI_LGHI = 0xa709, +RI_LLILL= 0xa50f, + +RRE_AGR = 0xb908, +RRE_CGR = 0xb920, +RRE_CLGR= 0xb921, +RRE_DLGR= 0xb987, +RRE_DLR = 0xb997, +RRE_DSGFR = 0xb91d, +RRE_DSGR= 0xb90d, +RRE_LCGR= 0xb903, +RRE_LGFR= 0xb914, +RRE_LGR = 0xb904, +RRE_LLGFR = 0xb916, +RRE_MSGR= 0xb90c, +RRE_MSR = 0xb252, +RRE_NGR = 0xb980, +RRE_OGR = 0xb981, +RRE_SGR = 0xb909, +RRE_XGR = 0xb982, + +RR_AR = 0x1a, +RR_BASR = 0x0d, +RR_BCR = 0x07, +RR_CLR = 0x15, +RR_CR = 0x19, +RR_DR = 0x1d, +RR_LCR = 0x13, +RR_LR = 0x18, +RR_NR = 0x14, +RR_OR = 0x16, +RR_SR = 0x1b, +RR_XR = 0x17, + +RSY_SLLG= 0xeb0d, +RSY_SRAG= 0xeb0a, +RSY_SRLG= 0xeb0c, + +RS_SLL = 0x89, +RS_SRA = 0x8a, +RS_SRL = 0x88, + +RXY_CG = 0xe320, +RXY_LB = 0xe376, +RXY_LG = 0xe304, +RXY_LGB = 0xe377, +RXY_LGF = 0xe314, +RXY_LGH = 0xe315, +RXY_LHY = 0xe378, +RXY_LLC = 0xe394, +RXY_LLGC= 0xe390, +RXY_LLGF= 0xe316, +RXY_LLGH= 0xe391, +RXY_LLH = 0xe395, +RXY_LMG = 0xeb04, +RXY_LRV = 0xe31e, +RXY_LRVG= 0xe30f, +RXY_LRVH= 0xe31f, +RXY_LY = 0xe358, +RXY_STCY= 0xe372, +RXY_STG = 0xe324, +RXY_STHY= 0xe370, +RXY_STMG= 0xeb24, +RXY_STRV= 0xe33e, +RXY_STRVG = 0xe32f, +RXY_STRVH = 0xe33f, +RXY_STY = 0xe350, + +RX_L= 0x58, +RX_LH = 0x48, +RX_ST = 0x50, +RX_STC = 0x42, +RX_STH = 0x40, +} S390Opcode; + +#define LD_SIGNED 0x04 +#define LD_UINT8 0x00 +#define LD_INT8(LD_UINT8 | LD_SIGNED) +#define LD_UINT16 0x01 +#define LD_INT16 (LD_UINT16 | LD_SIGNED) +#define LD_UINT32 0x02 +#define LD_INT32 (LD_UINT32 | LD_SIGNED) +#define LD_UINT64 0x03 +#define LD_INT64 (LD_UINT64 | LD_SIGNED) + +#ifndef NDEBUG +static const char * const tcg_target_reg_names[TCG_TARGET_NB_REGS] = { +%r0, %r1, %r2, %r3, %r4, %r5, %r6, %r7, +%r8, %r9, %r10 %r11 %r12 %r13 %r14 %r15 +}; +#endif + static const int tcg_target_reg_alloc_order[] = { +TCG_REG_R6, +TCG_REG_R7, +TCG_REG_R8, +TCG_REG_R9, +TCG_REG_R10, +TCG_REG_R11, +TCG_REG_R12, +
Re: [Qemu-devel] [PATCH 11/35] tcg-s390: Tidy unimplemented opcodes.
On Fri, Jun 04, 2010 at 12:14:19PM -0700, Richard Henderson wrote: Signed-off-by: Richard Henderson r...@twiddle.net --- tcg/s390/tcg-target.c | 25 ++--- 1 files changed, 10 insertions(+), 15 deletions(-) diff --git a/tcg/s390/tcg-target.c b/tcg/s390/tcg-target.c index 55f0fa9..5b2134b 100644 --- a/tcg/s390/tcg-target.c +++ b/tcg/s390/tcg-target.c @@ -824,11 +824,6 @@ static inline void tcg_out_op(TCGContext *s, TCGOpcode opc, } break; -case INDEX_op_jmp: -/* XXX */ -tcg_abort(); -break; - case INDEX_op_ld8u_i32: case INDEX_op_ld8u_i64: /* ??? LLC (RXY format) is only present with the extended-immediate @@ -891,16 +886,6 @@ static inline void tcg_out_op(TCGContext *s, TCGOpcode opc, tcg_out_st(s, TCG_TYPE_I64, args[0], args[1], args[2]); break; -case INDEX_op_mov_i32: -/* XXX */ -tcg_abort(); -break; - -case INDEX_op_movi_i32: -/* XXX */ -tcg_abort(); -break; - case INDEX_op_add_i32: if (const_args[2]) { tcg_out_insn(s, RI, AHI, args[0], args[2]); @@ -1077,6 +1062,16 @@ static inline void tcg_out_op(TCGContext *s, TCGOpcode opc, tcg_out_qemu_st(s, args, LD_UINT64); break; +case INDEX_op_mov_i32: +case INDEX_op_mov_i64: +case INDEX_op_movi_i32: +case INDEX_op_movi_i64: +/* These are always emitted by TCG directly. */ OTOH, these 4 ones are very easy to write in case TCG starts to emit such opcodes at some point. +case INDEX_op_jmp: +/* This one is obsolete and never emitted. */ +tcg_abort(); I am fine with this one. +break; + default: fprintf(stderr,unimplemented opc 0x%x\n,opc); tcg_abort(); -- 1.7.0.1 -- Aurelien Jarno GPG: 1024D/F1BCDB73 aurel...@aurel32.net http://www.aurel32.net
Re: [Qemu-devel] [PATCH 07/35] tcg: Optionally sign-extend 32-bit arguments for 64-bit host.
On Fri, Jun 04, 2010 at 12:14:15PM -0700, Richard Henderson wrote: Some hosts (amd64, ia64) have an ABI that ignores the high bits of the 64-bit register when passing 32-bit arguments. Others, like s390x, require the value to be properly sign-extended for the type. I.e. int32_t must be sign-extended and uint32_t must be zero-extended to 64-bits. To effect this, extend the sizemask parameter to tcg_gen_callN to include the signedness of the type of each parameter. If the tcg target requires it, extend each 32-bit argument into a 64-bit temp and pass that to the function call. Signed-off-by: Richard Henderson r...@twiddle.net --- def-helper.h | 38 +- target-i386/ops_sse_header.h |3 +++ target-ppc/helper.h |1 + tcg/s390/tcg-target.h|2 ++ tcg/tcg-op.h | 42 +- tcg/tcg.c| 41 +++-- 6 files changed, 91 insertions(+), 36 deletions(-) diff --git a/def-helper.h b/def-helper.h index 8a88c5b..8a822c7 100644 --- a/def-helper.h +++ b/def-helper.h @@ -81,9 +81,29 @@ #define dh_is_64bit_ptr (TCG_TARGET_REG_BITS == 64) #define dh_is_64bit(t) glue(dh_is_64bit_, dh_alias(t)) +#define dh_is_signed_void 0 +#define dh_is_signed_i32 0 +#define dh_is_signed_s32 1 +#define dh_is_signed_i64 0 +#define dh_is_signed_s64 1 +#define dh_is_signed_f32 0 +#define dh_is_signed_f64 0 +#define dh_is_signed_tl 0 +#define dh_is_signed_int 1 +/* ??? This is highly specific to the host cpu. There are even special + extension instructions that may be required, e.g. ia64's addp4. But + for now we don't support any 64-bit targets with 32-bit pointers. */ +#define dh_is_signed_ptr 0 +#define dh_is_signed_env dh_is_signed_ptr +#define dh_is_signed(t) dh_is_signed_##t + +#define dh_sizemask(t, n) \ + sizemask |= dh_is_64bit(t) (n*2); \ + sizemask |= dh_is_signed(t) (n*2+1) + #define dh_arg(t, n) \ args[n - 1] = glue(GET_TCGV_, dh_alias(t))(glue(arg, n)); \ - sizemask |= dh_is_64bit(t) n + dh_sizemask(t, n) #define dh_arg_decl(t, n) glue(TCGv_, dh_alias(t)) glue(arg, n) @@ -138,8 +158,8 @@ static inline void glue(gen_helper_, name)(dh_retvar_decl0(ret)) \ static inline void glue(gen_helper_, name)(dh_retvar_decl(ret) dh_arg_decl(t1, 1)) \ { \ TCGArg args[1]; \ - int sizemask; \ - sizemask = dh_is_64bit(ret); \ + int sizemask = 0; \ + dh_sizemask(ret, 0); \ dh_arg(t1, 1); \ tcg_gen_helperN(HELPER(name), flags, sizemask, dh_retvar(ret), 1, args); \ } @@ -149,8 +169,8 @@ static inline void glue(gen_helper_, name)(dh_retvar_decl(ret) dh_arg_decl(t1, 1 dh_arg_decl(t2, 2)) \ { \ TCGArg args[2]; \ - int sizemask; \ - sizemask = dh_is_64bit(ret); \ + int sizemask = 0; \ + dh_sizemask(ret, 0); \ dh_arg(t1, 1); \ dh_arg(t2, 2); \ tcg_gen_helperN(HELPER(name), flags, sizemask, dh_retvar(ret), 2, args); \ @@ -161,8 +181,8 @@ static inline void glue(gen_helper_, name)(dh_retvar_decl(ret) dh_arg_decl(t1, 1 dh_arg_decl(t2, 2), dh_arg_decl(t3, 3)) \ { \ TCGArg args[3]; \ - int sizemask; \ - sizemask = dh_is_64bit(ret); \ + int sizemask = 0; \ + dh_sizemask(ret, 0); \ dh_arg(t1, 1); \ dh_arg(t2, 2); \ dh_arg(t3, 3); \ @@ -174,8 +194,8 @@ static inline void glue(gen_helper_, name)(dh_retvar_decl(ret) dh_arg_decl(t1, 1 dh_arg_decl(t2, 2), dh_arg_decl(t3, 3), dh_arg_decl(t4, 4)) \ { \ TCGArg args[4]; \ - int sizemask; \ - sizemask = dh_is_64bit(ret); \ + int sizemask = 0; \ + dh_sizemask(ret, 0); \ dh_arg(t1, 1); \ dh_arg(t2, 2); \ dh_arg(t3, 3); \ diff --git a/target-i386/ops_sse_header.h b/target-i386/ops_sse_header.h index a0a6361..8d4b2b7 100644 --- a/target-i386/ops_sse_header.h +++ b/target-i386/ops_sse_header.h @@ -30,6 +30,9 @@ #define dh_ctype_Reg Reg * #define dh_ctype_XMMReg XMMReg * #define dh_ctype_MMXReg MMXReg * +#define dh_is_signed_Reg dh_is_signed_ptr +#define dh_is_signed_XMMReg dh_is_signed_ptr +#define dh_is_signed_MMXReg dh_is_signed_ptr DEF_HELPER_2(glue(psrlw, SUFFIX), void, Reg, Reg) DEF_HELPER_2(glue(psraw, SUFFIX), void, Reg, Reg) diff --git a/target-ppc/helper.h b/target-ppc/helper.h index 5cf6cd4..c025a2f 100644 --- a/target-ppc/helper.h +++ b/target-ppc/helper.h @@ -95,6 +95,7 @@ DEF_HELPER_3(fsel, i64, i64, i64, i64) #define dh_alias_avr ptr #define dh_ctype_avr ppc_avr_t * +#define dh_is_signed_avr dh_is_signed_ptr DEF_HELPER_3(vaddubm, void, avr, avr, avr) DEF_HELPER_3(vadduhm, void, avr, avr, avr) diff --git a/tcg/s390/tcg-target.h b/tcg/s390/tcg-target.h index d7fe0c7..8c19262 100644 --- a/tcg/s390/tcg-target.h +++ b/tcg/s390/tcg-target.h @@ -87,6 +87,8 @@ enum { #define TCG_TARGET_STACK_ALIGN 8 #define TCG_TARGET_CALL_STACK_OFFSET 0 +#define
Re: [Qemu-devel] [PATCH 13/35] tcg-s390: Tidy regset initialization; use R14 as temporary.
On Fri, Jun 04, 2010 at 12:14:21PM -0700, Richard Henderson wrote: Signed-off-by: Richard Henderson r...@twiddle.net --- tcg/s390/tcg-target.c | 26 -- 1 files changed, 12 insertions(+), 14 deletions(-) This patch looks fine. diff --git a/tcg/s390/tcg-target.c b/tcg/s390/tcg-target.c index 2b80c02..95ea3c8 100644 --- a/tcg/s390/tcg-target.c +++ b/tcg/s390/tcg-target.c @@ -41,7 +41,7 @@ #define TCG_REG_NONE0 /* A scratch register that may be be used throughout the backend. */ -#define TCG_TMP0TCG_REG_R13 +#define TCG_TMP0TCG_REG_R14 /* All of the following instructions are prefixed with their instruction @@ -1185,24 +1185,22 @@ void tcg_target_init(TCGContext *s) tcg_regset_set32(tcg_target_available_regs[TCG_TYPE_I32], 0, 0x); tcg_regset_set32(tcg_target_available_regs[TCG_TYPE_I64], 0, 0x); -tcg_regset_set32(tcg_target_call_clobber_regs, 0, - (1 TCG_REG_R0) | - (1 TCG_REG_R1) | - (1 TCG_REG_R2) | - (1 TCG_REG_R3) | - (1 TCG_REG_R4) | - (1 TCG_REG_R5) | - (1 TCG_REG_R14)); /* link register */ + +tcg_regset_clear(tcg_target_call_clobber_regs); +tcg_regset_set_reg(tcg_target_call_clobber_regs, TCG_REG_R0); +tcg_regset_set_reg(tcg_target_call_clobber_regs, TCG_REG_R1); +tcg_regset_set_reg(tcg_target_call_clobber_regs, TCG_REG_R2); +tcg_regset_set_reg(tcg_target_call_clobber_regs, TCG_REG_R3); +tcg_regset_set_reg(tcg_target_call_clobber_regs, TCG_REG_R4); +tcg_regset_set_reg(tcg_target_call_clobber_regs, TCG_REG_R5); +/* The return register can be considered call-clobbered. */ +tcg_regset_set_reg(tcg_target_call_clobber_regs, TCG_REG_R14); tcg_regset_clear(s-reserved_regs); -/* frequently used as a temporary */ tcg_regset_set_reg(s-reserved_regs, TCG_TMP0); -/* another temporary */ -tcg_regset_set_reg(s-reserved_regs, TCG_REG_R12); /* XXX many insns can't be used with R0, so we better avoid it for now */ tcg_regset_set_reg(s-reserved_regs, TCG_REG_R0); -/* The stack pointer. */ -tcg_regset_set_reg(s-reserved_regs, TCG_REG_R15); +tcg_regset_set_reg(s-reserved_regs, TCG_REG_CALL_STACK); tcg_add_target_add_op_defs(s390_op_defs); } -- 1.7.0.1 -- Aurelien Jarno GPG: 1024D/F1BCDB73 aurel...@aurel32.net http://www.aurel32.net
Re: [Qemu-devel] [PATCH 12/35] tcg-s390: Define TCG_TMP0.
On Fri, Jun 04, 2010 at 12:14:20PM -0700, Richard Henderson wrote: Use a define for the temp register instead of hard-coding it. Signed-off-by: Richard Henderson r...@twiddle.net --- tcg/s390/tcg-target.c | 54 ++-- 1 files changed, 29 insertions(+), 25 deletions(-) This patch looks ok. diff --git a/tcg/s390/tcg-target.c b/tcg/s390/tcg-target.c index 5b2134b..2b80c02 100644 --- a/tcg/s390/tcg-target.c +++ b/tcg/s390/tcg-target.c @@ -40,6 +40,10 @@ rather than TCG_REG_R0. */ #define TCG_REG_NONE0 +/* A scratch register that may be be used throughout the backend. */ +#define TCG_TMP0TCG_REG_R13 + + /* All of the following instructions are prefixed with their instruction format, and are defined as 8- or 16-bit quantities, even when the two halves of the 16-bit quantity may appear 32 bits apart in the insn. @@ -376,12 +380,12 @@ static inline void tcg_out_movi(TCGContext *s, TCGType type, tcg_out_insn(s, RI, IILH, ret, arg 16); } else { /* branch over constant and store its address in R13 */ -tcg_out_insn(s, RIL, BRASL, TCG_REG_R13, (6 + 8) 1); +tcg_out_insn(s, RIL, BRASL, TCG_TMP0, (6 + 8) 1); /* 64-bit constant */ tcg_out32(s, arg 32); tcg_out32(s, arg); /* load constant to ret */ -tcg_out_insn(s, RXY, LG, ret, TCG_REG_R13, 0, 0); +tcg_out_insn(s, RXY, LG, ret, TCG_TMP0, 0, 0); } } @@ -399,14 +403,14 @@ static void tcg_out_mem(TCGContext *s, S390Opcode opc_rx, S390Opcode opc_rxy, if (ofs -0x8 || ofs = 0x8) { /* Combine the low 16 bits of the offset with the actual load insn; the high 48 bits must come from an immediate load. */ -tcg_out_movi(s, TCG_TYPE_PTR, TCG_REG_R13, ofs ~0x); +tcg_out_movi(s, TCG_TYPE_PTR, TCG_TMP0, ofs ~0x); ofs = 0x; /* If we were already given an index register, add it in. */ if (index != TCG_REG_NONE) { -tcg_out_insn(s, RRE, AGR, TCG_REG_R13, index); +tcg_out_insn(s, RRE, AGR, TCG_TMP0, index); } -index = TCG_REG_R13; +index = TCG_TMP0; } if (opc_rx ofs = 0 ofs 0x1000) { @@ -482,8 +486,8 @@ static void tgen_gotoi(TCGContext *s, int cc, tcg_target_long dest) } else if (off == (int32_t)off) { tcg_out_insn(s, RIL, BRCL, cc, off); } else { -tcg_out_movi(s, TCG_TYPE_PTR, TCG_REG_R13, dest); -tcg_out_insn(s, RR, BCR, cc, TCG_REG_R13); +tcg_out_movi(s, TCG_TYPE_PTR, TCG_TMP0, dest); +tcg_out_insn(s, RR, BCR, cc, TCG_TMP0); } } @@ -505,8 +509,8 @@ static void tgen_calli(TCGContext *s, tcg_target_long dest) if (off == (int32_t)off) { tcg_out_insn(s, RIL, BRASL, TCG_REG_R14, off); } else { -tcg_out_movi(s, TCG_TYPE_PTR, TCG_REG_R13, dest); -tcg_out_insn(s, RR, BASR, TCG_REG_R14, TCG_REG_R13); +tcg_out_movi(s, TCG_TYPE_PTR, TCG_TMP0, dest); +tcg_out_insn(s, RR, BASR, TCG_REG_R14, TCG_TMP0); } } @@ -538,22 +542,22 @@ static void tcg_prepare_qemu_ldst(TCGContext* s, int data_reg, int addr_reg, tcg_out_sh64(s, RSY_SRLG, arg1, addr_reg, TCG_REG_NONE, TARGET_PAGE_BITS - CPU_TLB_ENTRY_BITS); -tcg_out_movi(s, TCG_TYPE_PTR, TCG_REG_R13, +tcg_out_movi(s, TCG_TYPE_PTR, TCG_TMP0, TARGET_PAGE_MASK | ((1 s_bits) - 1)); -tcg_out_insn(s, RRE, NGR, arg0, TCG_REG_R13); +tcg_out_insn(s, RRE, NGR, arg0, TCG_TMP0); -tcg_out_movi(s, TCG_TYPE_PTR, TCG_REG_R13, +tcg_out_movi(s, TCG_TYPE_PTR, TCG_TMP0, (CPU_TLB_SIZE - 1) CPU_TLB_ENTRY_BITS); -tcg_out_insn(s, RRE, NGR, arg1, TCG_REG_R13); +tcg_out_insn(s, RRE, NGR, arg1, TCG_TMP0); if (is_store) { -tcg_out_movi(s, TCG_TYPE_PTR, TCG_REG_R13, +tcg_out_movi(s, TCG_TYPE_PTR, TCG_TMP0, offsetof(CPUState, tlb_table[mem_index][0].addr_write)); } else { -tcg_out_movi(s, TCG_TYPE_PTR, TCG_REG_R13, +tcg_out_movi(s, TCG_TYPE_PTR, TCG_TMP0, offsetof(CPUState, tlb_table[mem_index][0].addr_read)); } -tcg_out_insn(s, RRE, AGR, arg1, TCG_REG_R13); +tcg_out_insn(s, RRE, AGR, arg1, TCG_TMP0); tcg_out_insn(s, RRE, AGR, arg1, TCG_AREG0); @@ -688,8 +692,8 @@ static void tcg_out_qemu_ld(TCGContext* s, const TCGArg* args, int opc) #else /* swapped unsigned halfword load with upper bits zeroed */ tcg_out_insn(s, RXY, LRVH, data_reg, arg0, 0, 0); -tcg_out_movi(s, TCG_TYPE_PTR, TCG_REG_R13, 0xL); -tcg_out_insn(s, RRE, NGR, data_reg, 13); +tcg_out_movi(s, TCG_TYPE_PTR, TCG_TMP0, 0xL); +tcg_out_insn(s, RRE, NGR, data_reg, TCG_TMP0); #endif break;
Re: [Qemu-devel] [PATCH 14/35] tcg-s390: Rearrange register allocation order.
On Fri, Jun 04, 2010 at 12:14:22PM -0700, Richard Henderson wrote: Try to avoid conflicting with the outgoing function call arguments. Signed-off-by: Richard Henderson r...@twiddle.net --- tcg/s390/tcg-target.c | 23 +-- 1 files changed, 13 insertions(+), 10 deletions(-) This patch looks fine. diff --git a/tcg/s390/tcg-target.c b/tcg/s390/tcg-target.c index 95ea3c8..3944cb1 100644 --- a/tcg/s390/tcg-target.c +++ b/tcg/s390/tcg-target.c @@ -149,22 +149,25 @@ static const char * const tcg_target_reg_names[TCG_TARGET_NB_REGS] = { }; #endif +/* Since R6 is a potential argument register, choose it last of the + call-saved registers. Likewise prefer the call-clobbered registers + in reverse order to maximize the chance of avoiding the arguments. */ static const int tcg_target_reg_alloc_order[] = { -TCG_REG_R6, -TCG_REG_R7, -TCG_REG_R8, -TCG_REG_R9, -TCG_REG_R10, -TCG_REG_R11, -TCG_REG_R12, TCG_REG_R13, +TCG_REG_R12, +TCG_REG_R11, +TCG_REG_R10, +TCG_REG_R9, +TCG_REG_R8, +TCG_REG_R7, +TCG_REG_R6, TCG_REG_R14, TCG_REG_R0, TCG_REG_R1, -TCG_REG_R2, -TCG_REG_R3, -TCG_REG_R4, TCG_REG_R5, +TCG_REG_R4, +TCG_REG_R3, +TCG_REG_R2, }; static const int tcg_target_call_iarg_regs[] = { -- 1.7.0.1 -- Aurelien Jarno GPG: 1024D/F1BCDB73 aurel...@aurel32.net http://www.aurel32.net
Re: [Qemu-devel] [PATCH 15/35] tcg-s390: Query instruction extensions that are installed.
On Fri, Jun 04, 2010 at 12:14:23PM -0700, Richard Henderson wrote: Verify that we have all the instruction extensions that we generate. Future patches can tailor code generation to the set of instructions that are present. Signed-off-by: Richard Henderson r...@twiddle.net --- tcg/s390/tcg-target.c | 113 + 1 files changed, 113 insertions(+), 0 deletions(-) diff --git a/tcg/s390/tcg-target.c b/tcg/s390/tcg-target.c index 3944cb1..d99bb5c 100644 --- a/tcg/s390/tcg-target.c +++ b/tcg/s390/tcg-target.c @@ -229,6 +229,17 @@ static void *qemu_st_helpers[4] = { static uint8_t *tb_ret_addr; +/* A list of relevant facilities used by this translator. Some of these + are required for proper operation, and these are checked at startup. */ + +#define FACILITY_ZARCH (1ULL (63 - 1)) +#define FACILITY_ZARCH_ACTIVE(1ULL (63 - 2)) +#define FACILITY_LONG_DISP (1ULL (63 - 18)) +#define FACILITY_EXT_IMM (1ULL (63 - 21)) +#define FACILITY_GEN_INST_EXT(1ULL (63 - 34)) + +static uint64_t facilities; + static void patch_reloc(uint8_t *code_ptr, int type, tcg_target_long value, tcg_target_long addend) { @@ -1177,6 +1188,106 @@ static const TCGTargetOpDef s390_op_defs[] = { { -1 }, }; +/* ??? Linux kernels provide an AUXV entry AT_HWCAP that provides most of + this information. However, getting at that entry is not easy this far + away from main. Our options are: start searching from environ, but + that fails as soon as someone does a setenv in between. Read the data + from /proc/self/auxv. Or do the probing ourselves. The only thing + extra that AT_HWCAP gives us is HWCAP_S390_HIGH_GPRS, which indicates + that the kernel saves all 64-bits of the registers around traps while + in 31-bit mode. But this is true of all recent kernels (ought to dig + back and see from when this might not be true). */ + +#include signal.h + +static volatile sig_atomic_t got_sigill; + +static void sigill_handler(int sig) +{ +got_sigill = 1; +} + +static void query_facilities(void) +{ +struct sigaction sa_old, sa_new; +register int r0 __asm__(0); +register void *r1 __asm__(1); +int fail; + +memset(sa_new, 0, sizeof(sa_new)); +sa_new.sa_handler = sigill_handler; +sigaction(SIGILL, sa_new, sa_old); + +/* First, try STORE FACILITY LIST EXTENDED. If this is present, then + we need not do any more probing. Unfortunately, this itself is an + extension and the original STORE FACILITY LIST instruction is + kernel-only, storing its results at absolute address 200. */ +/* stfle 0(%r1) */ +r1 = facilities; +asm volatile(.word 0xb2b0,0x1000 + : =r(r0) : 0(0), r(r1) : memory, cc); Wouldn't it be possible to use the instruction directly instead of dumping the opcode values? Same below + +if (got_sigill) { +/* STORE FACILITY EXTENDED is not available. Probe for one of each + kind of instruction that we're interested in. */ +/* ??? Possibly some of these are in practice never present unless + the store-facility-extended facility is also present. But since + that isn't documented it's just better to probe for each. */ + +/* Test for z/Architecture. Required even in 31-bit mode. */ +got_sigill = 0; +/* agr %r0,%r0 */ +asm volatile(.word 0xb908,0x : =r(r0) : : cc); +if (!got_sigill) { +facilities |= FACILITY_ZARCH | FACILITY_ZARCH_ACTIVE; +} + +/* Test for long displacement. */ +got_sigill = 0; +/* ly %r0,0(%r1) */ +r1 = facilities; +asm volatile(.word 0xe300,0x1000,0x0058 + : =r(r0) : r(r1) : cc); +if (!got_sigill) { +facilities |= FACILITY_LONG_DISP; +} + +/* Test for extended immediates. */ +got_sigill = 0; +/* afi %r0,0 */ +asm volatile(.word 0xc209,0x,0x : : : cc); +if (!got_sigill) { +facilities |= FACILITY_EXT_IMM; +} + +/* Test for general-instructions-extension. */ +got_sigill = 0; +/* msfi %r0,1 */ +asm volatile(.word 0xc201,0x,0x0001); +if (!got_sigill) { +facilities |= FACILITY_GEN_INST_EXT; +} +} + +sigaction(SIGILL, sa_old, NULL); + +/* The translator currently uses these extensions unconditionally. + Pruning this back to the base ESA/390 architecture doesn't seem + worthwhile, since even the KVM target requires z/Arch. */ +fail = 0; +if ((facilities FACILITY_ZARCH_ACTIVE) == 0) { +fprintf(stderr, TCG: z/Arch facility is required\n); +fail = 1; +} +if ((facilities FACILITY_LONG_DISP) == 0) { +
[Qemu-devel] Re: [PATCH v3 3/5] QMP: Introduce MIGRATION events
Luiz Capitulino lcapitul...@redhat.com wrote: On Wed, 9 Jun 2010 14:10:56 +0200 Juan Quintela quint...@redhat.com wrote: +MIGRATION_FAILED + + +Emitted when migration fails (both is source and target). Notice +that this event will be changed for 0.14 when we have infrastructure +to emit a QError when things fail. This is not the kind of information this file should have, compatible changes should be noted when time comes and incompatible ones are just forbidden after 0.13. Then how you express that this value is going to have a QError in it on the future? Adding a Default QError that puts 'This QError is going to be refined' or what? Later, Juan.
[Qemu-devel] Re: [PATCH v3 0/5] Add QMP migration events
Luiz Capitulino lcapitul...@redhat.com wrote: On Wed, 9 Jun 2010 14:10:53 +0200 Juan Quintela quint...@redhat.com wrote: This is a resent with what we agreed on yesterday call. Migration events would be there for 0.13 until we get proper async command support. Something which is not clear to me is the set of events we'd have if migrate was an async command. Ie, do we really need MIGRATION_FAILED in this case? Don't we expect to get this information from the async response? I am not able to define simpler semantics for this events: - MIGRATION_STARTED: somebody started a migration, it is emited on source and target, all monitors receive this event. - MIGRATION_ENDED: migration ended with sucess, all needed data is in target machine. Also emitted in all monitors on source and target. - MIGRATION_CANCELED: in one of the source monitors somebody typed: migrate_cancel. It is only emmited on the source monitors, target monitors will receive a MIGRATION_FAILED event. - MIGRATION_FAILED (with this error). At this point we don't have neither the QMP infraestructure for sending (with this error) nor migration infrastructure to put there anything different than -1. This event is emmited on all source and target monitors. - For 0.13: Event don't have a QError. - For 0.14: It will gain a QError. About migration becoming an async command. Really it is independent of what events we emit. If migration becomes async command, only difference is for the monitor that emitted the command, rest of monitors see nothing. If we want to be able to see that informantion in the other monitors, we need the events anyways. Why do we want this? It makes things like audit simpler (we already know when a machine starts/stops, knowing when it migrates is also a good idea. Same for things like the storage management examples that danp did. With events, it becomes trivial, without events, it can be done with workarounds, sending messages left, rigth and center. Spice also wanted the equivalent of this events to reconnect to the new server machine. I can't see why people have so much trouble with this events, they are of the simpler class. The only real problem that we have is what to put on the MIGRATE_FAILED event, and the problem is an infrastructure one, that we don't have neither what or how to put something useful there. At this point, management applications only want to know if migration ended with success or with failure, but they will like to know at some point what kind of failure they had. Later, Juan.
Re: [Qemu-devel] [PATCH 2/2] virtio-blk: simplify multiwrite calling conventions
Am 08.06.2010 18:26, schrieb Christoph Hellwig: Pass the MultiReqBuffer structure down all the way to the I/O submission instead of takin it apart. Also mark num_writes unsigned as it can't go negative, and take the check for any pending I/O requests into the submission function. Last but not least rename do_multiwrite to virtio_submit_multiwrite to fit the general naming scheme and make clear what it does. Signed-off-by: Christoph Hellwig h...@lst.de Thanks, applied all to the block branch. Kevin
Re: [Qemu-devel] Disable PS/2 mouse
Gerd Hoffmann wrote: On 06/10/2010 09:12 AM, Dor Laor wrote: On 06/09/2010 05:35 PM, Gerd Hoffmann wrote: Hi, with 0.12.4 it is still the case that a total idle vm takes about 6-8% of a 2.4GHz Xeon Core. I see that order of magitude too, no matter whenever usb is on or off. With older qemu and usbtablet it used to be up to 25%. Is it possible to dynamically control the refresh internally within qemu so VMs without a connected VNC client will have rare refreshes or no refresh at all? I hope it's not the OS who polls it. vnc/vga or usb tablet? For the vga it happens already, with no vnc client connected vnc zaps the refresh timer and stops calling vga_hw_update(), thus vga stops doing framebuffer dirty tracking too. For usb hid devices: No idea how they work and whenever we can put them into sleep somehow (with/without guest cooperation). is it the emulated bus or the tablet device that is generating the load? cheers, Gerd
[Qemu-devel] [Bug 586420] Re: WinXP install cd hangs at boot time if machine started with floppy
Well, I forgot something to mention. Again: I can boot the install CDs of Windows XP and Windows Server 2003 if I DON'T use any floppy drive. -fda/-fdb FILE as well as -drive file=FILE,if=floppy are causing this bug, the bug not to be able to boot these install CDs. -- WinXP install cd hangs at boot time if machine started with floppy https://bugs.launchpad.net/bugs/586420 You received this bug notification because you are a member of qemu- devel-ml, which is subscribed to QEMU. Status in QEMU: Incomplete Bug description: I have a second problem: I wanted to install Windows Server 2003 on a virtio drive, so I tried to start the machine with the install cd as the boot drive and a floppy image with the viostor drivers. The problem is, the install cd hangs at boot time. If I start VNC I just see a black ground with 640x480. I've also tried this with the install cd of Windows Server 2008 R2 and it works! Could it be that the BIOS screws up because the older install cds are using the floppy emulation to boot the setup?
[Qemu-devel] [Bug 586420] Re: WinXP install cd hangs at boot time if machine started with floppy
I admit I used -L wrong, but that's not the issue. I don't need to specify it, because QEMU finds the right directory itself. My problem is, the installer CD hangs also if I add -hda/-hdb. The setup should be able to boot anyway, even without any hard drive. It's possible that the CD image could be damaged, but I used it since years and it booted in every real machine and also in VirtualBox. (I would like to try qemu.git, but it doesn't want to be compiled. Either it breaks up or it hangs up.) -- WinXP install cd hangs at boot time if machine started with floppy https://bugs.launchpad.net/bugs/586420 You received this bug notification because you are a member of qemu- devel-ml, which is subscribed to QEMU. Status in QEMU: Incomplete Bug description: I have a second problem: I wanted to install Windows Server 2003 on a virtio drive, so I tried to start the machine with the install cd as the boot drive and a floppy image with the viostor drivers. The problem is, the install cd hangs at boot time. If I start VNC I just see a black ground with 640x480. I've also tried this with the install cd of Windows Server 2008 R2 and it works! Could it be that the BIOS screws up because the older install cds are using the floppy emulation to boot the setup?
Re: [Qemu-devel] [Bug 586420] Re: WinXP install cd hangs at boot time if machine started with floppy
10.06.2010 14:49, tekditt wrote: Well, I forgot something to mention. Again: I can boot the install CDs of Windows XP and Windows Server 2003 if I DON'T use any floppy drive. -fda/-fdb FILE as well as -drive file=FILE,if=floppy are causing this bug, the bug not to be able to boot these install CDs. Works For Me (tm) with and without floppy image, with several versions of qemu-kvm and qemu, and using several different winXP install CD images (one is even pre-SP1). Just a wild guess: maybe you've something wrong in the floppy image that causes winXP to hang? I tried ms-dos-6.22 boot floppy and a blank (all-zeros) image. Or maybe it's of a wrong geometry/size, whatever... /mjt
Re: [Qemu-devel] Re: [PATCH V3 1/3] qemu: Add qemu-wrappers for pthread_attr_t
On Fri, Jun 04, 2010 at 03:19:34PM +0200, Corentin Chary wrote: On Fri, Jun 4, 2010 at 3:07 PM, Anthony Liguori anth...@codemonkey.ws wrote: On 06/03/2010 07:31 AM, Paolo Bonzini wrote: On 06/03/2010 10:56 AM, Gautham R Shenoy wrote: Add qemu wrappers for pthread_attr_t handling. The point of these wrappers AFAIU is not only to add error_exit, but also to be portable to Windows in the future. Is it necessary to create the threads as detached? If you set queue-min_threads to zero all threads should exit as soon as they finish their work (which is better than exiting immediately). This is historical because the code was largely inspired by glibc's implementation of posix-aio. It doesn't need to be detached and since Corentin wants to be able to join a worker, it makes sense to just avoid detaching and pay the overhead of making the threads joinable. Regards, Anthony Liguori Sorry for the late response. I had been away for the last few days. Actually, I want to know if the queue is empty and if no job are currently being processed: all worker are idle or stopped. In other words, you just want to know if the already submitted jobs have gotten over or not so that you could probably destroy the queue. The subsystem using the queueing infrastructure is responsible for providing the guarantee that no new job would be submitted while/after making a call query the idleness of the queue. If this understanding is correct, we might want to have a qemu_async_barrier() implementation which waits for all the threads finish processing the queued jobs, and destroy themselves. I don't really need pthread_join() for that, since worker can be idle (we don't want to always start and stop the thread :) ). -- Thanks and Regards gautham
Re: [Qemu-devel] [PATCH V3 2/3] qemu: Generic asynchronous threading framework to offload tasks
On Fri, Jun 04, 2010 at 08:16:19AM -0500, Anthony Liguori wrote: --- /dev/null +++ b/async-work.c @@ -0,0 +1,136 @@ +/* + * Async work support + * + * Copyright IBM, Corp. 2010 + * + * Authors: + * Aneesh Kumar K.Vaneesh.ku...@linux.vnet.ibm.com + * + * This work is licensed under the terms of the GNU GPL, version 2. See + * the COPYING file in the top-level directory. Please preserve the original copyright of the copied code. Will update the comment containing the Copyright. + +struct work_item +{ +QTAILQ_ENTRY(work_item) node; +void (*func)(struct work_item *work); +void *private; +}; Structs are not named in accordance to CODING_STYLE. Will fix this. +static inline void async_queue_init(struct async_queue *queue, +int max_threads, int min_threads) +{ +queue-cur_threads = 0; +queue-idle_threads = 0; +queue-max_threads = max_threads; +queue-min_threads = min_threads; +QTAILQ_INIT((queue-request_list)); +QTAILQ_INIT((queue-work_item_pool)); +qemu_mutex_init((queue-lock)); +qemu_cond_init((queue-cond)); +} I'd prefer there be a single queue that everything used verses multiple queues. Otherwise, we'll end up having per device queues and my concern is that we'll end up with thousands and thousands of threads with no central place to tune the maximum thread number. Aah! So, the original idea was to have a single queue, but since we were making it generic, we thought that the subsystems might like the flexibility of having their own queue. I suppose we are not looking to differentiate between the worker threads belonging to different subsystems in terms of their relative importance/priorities, right ? +static inline struct work_item *async_work_init(struct async_queue *queue, + void (*func)(struct work_item *), + void *data) I'd suggest actually using a Notifier as the worker or at least something that looks exactly like it. There's no need to pass a void * because more often than not, a caller just wants to pass a state structure anyway and they can embed the Notifier within the structure. IOW: async_work_submit(queue, s-worker); Then in the callback: DeviceState *s = container_of(worker, DeviceState, worker); I don't think the name makes the most sense either. I think something like: threadlet_submit() Makes sense. Will implement this. Would work best. It would be good for there to be a big comment warning that the routine does not run with the qemu_mutex and therefore cannot make use of any qemu functions without very special consideration. There shouldn't need to be an explicit init vs. submit function either. Ok, will address these comments. Regards, Anthony Liguori -- Thanks and Regards gautham
Re: [Qemu-devel] Disable PS/2 mouse
For usb hid devices: No idea how they work and whenever we can put them into sleep somehow (with/without guest cooperation). The issue with USB is that it is (by design) a polled system. The UHCI adapter has to wakeup every 1ms to read transfer descriptors from guest RAM. Until recently there was a bug in the UHCI emulation that would wake the guest even if the tablet NACKed the poll. See http://lists.nongnu.org/archive/html/qemu-devel/2010-04/msg00150.html USB does support autosuspend. This allows a guest to put a device to sleep, and have it wake up when something interesting happens. In theory this includes HID devices. However I believe linux disables it because there's so much broken hardware out there that implements it incorrectly. I suspect qemu does not currently implement this feature either. Paul
Re: [Qemu-devel] Re: KVM call minutes for June 8
On 06/10/2010 04:43 AM, Kevin Wolf wrote: Huh, why this? Seems I still haven't understood all of qcow2 then... I always thought that there's just a specific offset where VM state starts, but no explicit end. A live snapshot can last for a very long time. What happens if you need to allocate a new block for disk I/O while saving a snapshot? Regards, Anthony Liguori Kevin
[Qemu-devel] [Bug 538908] Re: qemu-system-cris crashes after a few seconds
Hi, You need to provide a boot/kernel image. What you are seeing is that QEMU boots into empty memory, the CPU just executes NOP's until it hits an address that is not backed by anything so it bails out. I've commited a patch that bails out earlier with an error message if there was no image to boot into. Cheers, Edgar -- qemu-system-cris crashes after a few seconds https://bugs.launchpad.net/bugs/538908 You received this bug notification because you are a member of qemu- devel-ml, which is subscribed to QEMU. Status in QEMU: New Status in “qemu” package in Ubuntu: New Bug description: qemu-system-cris crashes after a few seconds. Running the binary without any options loads the qemu window and it sits there waiting for me to do something. About a minute later it crashes. Dump attached. Running Linux 2.6.27-17-generic on Ubuntu 8.10. Athlon XP 3000+ 2GB RAM
Re: [Qemu-devel] Re: KVM call minutes for June 8
Am 10.06.2010 14:53, schrieb Anthony Liguori: On 06/10/2010 04:43 AM, Kevin Wolf wrote: Huh, why this? Seems I still haven't understood all of qcow2 then... I always thought that there's just a specific offset where VM state starts, but no explicit end. A live snapshot can last for a very long time. What happens if you need to allocate a new block for disk I/O while saving a snapshot? You allocate it, I guess? Note that VM state must be virtually contiguous, but not necessarily physically (virtually = on the virtual hard disk as seen by the guest; physically = in the image file). It's just not seen by the guest because it's saved at a high offset that is after the end of the real disk content, but otherwise it should behave the same as guest data. Kevin
[Qemu-devel] [PULL] pci,virtio
The following changes since commit 0ffbba357c557d9fa5caf9476878a4b9c155a614: migration-exec: fix OpenBSD build warning (2010-06-04 20:01:07 +) are available in the git repository at: git://git.kernel.org/pub/scm/linux/kernel/git/mst/qemu.git for_anthony Amit Shah (1): net: Fix hotplug with pci_add Michael S. Tsirkin (2): virtio-net: stop vhost backend on vmstop virtio-net: truncating packet hw/virtio-net.c | 26 ++ net.c |7 +-- 2 files changed, 19 insertions(+), 14 deletions(-)
Re: [Qemu-devel] Re: KVM call minutes for June 8
On 06/10/2010 04:08 PM, Kevin Wolf wrote: It's just not seen by the guest because it's saved at a high offset that is after the end of the real disk content, but otherwise it should behave the same as guest data. That's very unfriendly towards extending the guest-visible portion of the disk. -- error compiling committee.c: too many arguments to function
[Qemu-devel] Re: [PATCH 07/13] blockdev: Means to destroy blockdev only if made with drive_init()
Am 02.06.2010 18:55, schrieb Markus Armbruster: All drives are still made that way. They get destroyed along with their device. That's inappropriate for the alternative way to make blockdevs that will appear later in this series. These won't have a DriveInfo. blockdev_detach() destroys the blockdev only if it has a DriveInfo. blockdev_attach() does nothing for now. It'll be fleshed out later. Signed-off-by: Markus Armbruster arm...@redhat.com --- blockdev.c | 35 +++ blockdev.h |7 +++ 2 files changed, 42 insertions(+), 0 deletions(-) diff --git a/blockdev.c b/blockdev.c index ace74e4..f90d4fc 100644 --- a/blockdev.c +++ b/blockdev.c @@ -1,8 +1,12 @@ /* * QEMU host block devices * + * Copyright (C) 2010 Red Hat Inc. * Copyright (c) 2003-2008 Fabrice Bellard * + * Authors: + * Markus Armbruster arm...@redhat.com, + * * This work is licensed under the terms of the GNU GPL, version 2 or * later. See the COPYING file in the top-level directory. */ @@ -17,6 +21,37 @@ static QTAILQ_HEAD(drivelist, DriveInfo) drives = QTAILQ_HEAD_INITIALIZER(drives); +static int blockdev_del_dinfo(BlockDriverState *bs) +{ +DriveInfo *dinfo, *next_dinfo; +int res = 0; + +QTAILQ_FOREACH_SAFE(dinfo, drives, next, next_dinfo) { +if (dinfo-bdrv == bs) { +qemu_opts_del(dinfo-opts); +QTAILQ_REMOVE(drives, dinfo, next); +qemu_free(dinfo); +res = 1; +} +} + +return res; Can it happen that a BlockDriverState belongs to multiple DriveInfos? If no, why not returning in the loop? Wouldn't need a FOREACH_SAFE then, too. It's not worth respinning because of this one, but there were more comments and I think you'll send a v2 for the actual -blockdev option anyway once we have decided how to do it. I have applied patches 1 to 6 now, and I think I could safely go on until patch 9 if the minor improvements that were mentioned in comments are made. I'd ignore patch 10 to 13 for now. Is this what you would have expected or should I handle anything in a different way? Kevin
Re: [Qemu-devel] Re: KVM call minutes for June 8
On 06/10/2010 08:08 AM, Kevin Wolf wrote: Am 10.06.2010 14:53, schrieb Anthony Liguori: On 06/10/2010 04:43 AM, Kevin Wolf wrote: Huh, why this? Seems I still haven't understood all of qcow2 then... I always thought that there's just a specific offset where VM state starts, but no explicit end. A live snapshot can last for a very long time. What happens if you need to allocate a new block for disk I/O while saving a snapshot? You allocate it, I guess? Note that VM state must be virtually contiguous, but not necessarily physically (virtually = on the virtual hard disk as seen by the guest; physically = in the image file). It's just not seen by the guest because it's saved at a high offset that is after the end of the real disk content, but otherwise it should behave the same as guest data. I guess you could just start writing and then once your finished, you could update the snapshot information. So yeah, I think your right that it's doable with the current format. Regards, Anthony Liguori Kevin
Re: [Qemu-devel] [RFC PATCH 3/6] RAMBlock: Add a name field
On Thu, 2010-06-10 at 10:23 +0200, Gerd Hoffmann wrote: I may have been a bit misleading here. What we really want to do is use the same matching algorithm as is used by the rest of the device state. Currently this is a vmstate name and [arbitrary] numeric id. I don't remember whether there's a convenient link from a device to its associated vmstate - if there isn't there probably should be. DeviceState-info-vmsd-name for the name. Dunno about the numeric id, I think savevm.c doesn't export it. Ok, we can certainly do vmsd-name.vmsd-instance\driver string. It seems like this highlights a deficiency in the vmstate matching though. If on the source we do: pci_add addr=4 nic model=e1000 pci_add addr=3 nic model=e1000 Then we start the target, ordering the nics sequentially, are we going to store the vmstate into the opposite nics? AIUI, libvirt does this correctly today, but I don't like the idea of being required to remember the history of a vm to migrate it. Alex
Re: [Qemu-devel] [Bug 586420] Re: WinXP install cd hangs at boot time if machine started with floppy
On 06/10/10 12:49, tekditt wrote: Well, I forgot something to mention. Again: I can boot the install CDs of Windows XP and Windows Server 2003 if I DON'T use any floppy drive. -fda/-fdb FILE as well as -drive file=FILE,if=floppy are causing this bug, the bug not to be able to boot these install CDs. Just to be sure I understand you 100% - what you are saying is that it works ok if you don't specify a floppy image? If that is the case, does this floppy image you are specifying boot on it's own? It could be corrupted. Cheers, Jes
Re: [Qemu-devel] [RFC PATCH 3/6] RAMBlock: Add a name field
On Thu, 2010-06-10 at 10:23 +0200, Gerd Hoffmann wrote: I may have been a bit misleading here. What we really want to do is use the same matching algorithm as is used by the rest of the device state. Currently this is a vmstate name and [arbitrary] numeric id. I don't remember whether there's a convenient link from a device to its associated vmstate - if there isn't there probably should be. DeviceState-info-vmsd-name for the name. Dunno about the numeric id, I think savevm.c doesn't export it. Ok, we can certainly do vmsd-name.vmsd-instance\driver string. It seems like this highlights a deficiency in the vmstate matching Why are you forcing this to be a string? Then we start the target, ordering the nics sequentially, are we going to store the vmstate into the opposite nics? That's a separate problem. As long as you use the same matching as for the rest of the device state then it should just work. If it doesn't work then migration is already broken so it doen't matter. Paul
[Qemu-devel] RE: [RFC] Moving the kvm ioapic, pic, and pit back to userspace
A VF interrupt usually happens in 4-8KHZ. How about the virtio? I assume virtio will be widely used together w/ leagcy guest with INTx mode. True, but in time it will be replaced by MSI. Note without vhost virtio is also in userspace, so there are lots of exits anyway for the status register. Few months ago, we noticed the interrupt frequency of PV I/O in previous solution is almost same with physical NIC interrupt which ticks in ~4KHZ. Each PV I/O frontend driver (or its interrupt source) has similar interrupt frequency which means Nx more interrupt. I guess virtio is in similar situation. We then did an optimization for PV IO to mitigate the interrupt to guest by setting interrupt throttle in backend side, because native NIC also does in that way -- so called ITR register in Intel NIC. We can see 30-90% CPU utilization saving depending on how many frontend driver interrupt is employed. Not sure if it is adopted in vhost side. One drawback of course is the latency, but it is mostly tolerable if it is reduced to ~1KHZ. Thx, Eddie
[Qemu-devel] [BUG] tcg-i386: regression after merge 64-bit
My guest Linux/PPC cannot boot on my host x86 since this commit: 5d8a4f8f: tcg-i386: Merge 64-bit generation This is the output: zImage starting: loaded at 0x40 (sp: 0x004e5eb0) inflate returned -3 msg: invalid literal/lengths set -- Thomas
Re: [Qemu-devel] [RFC PATCH 3/6] RAMBlock: Add a name field
On Wed, 2010-06-09 at 21:36 +0100, Paul Brook wrote: Not really. This identifier is device and bus independent, which is why I suggested passing the device to qemu_ram_alloc. This can then figure out how to the identify the device. It should probably do this the same way that we identify the saved state for the device. Currently I think this is an arbitrary vmstate name/id, but I expect this to change to a qdev address (e.g. /i440FX-pcihost/pci.0/_addr_04.0). Ok, that seems fairly reasonable, so from a device pointer we can get something like /i440FX-pcihost/pci.0/_addr_04.0, then we can add something like :rom or :bar.0 to it via an extra string. qemu_ram_alloc(DeviceState *dev, const char *info, size) Exactly - though personally I wouldn't call the second argument info. Hmm, this gets a little hairy for patch 5/6 where we try to create a block on the fly to match the migration source. For now, this is mainly to catch things like devices that are hot plugged then removed before migration, but don't currently have a functional qemu_ram_free() to clean up. However, if we could get past that and clean up drivers, it might be nice for the string to provide enough information to instantiate the missing device on the target. I suddenly see that char[64] name becoming insufficient. Maybe we should follow the vmstate example and use a variable length string preceded by a length byte (or two). Alex
Re: [Qemu-devel] [RFC PATCH 3/6] RAMBlock: Add a name field
On Thu, 2010-06-10 at 15:49 +0100, Paul Brook wrote: On Thu, 2010-06-10 at 10:23 +0200, Gerd Hoffmann wrote: I may have been a bit misleading here. What we really want to do is use the same matching algorithm as is used by the rest of the device state. Currently this is a vmstate name and [arbitrary] numeric id. I don't remember whether there's a convenient link from a device to its associated vmstate - if there isn't there probably should be. DeviceState-info-vmsd-name for the name. Dunno about the numeric id, I think savevm.c doesn't export it. Ok, we can certainly do vmsd-name.vmsd-instance\driver string. It seems like this highlights a deficiency in the vmstate matching Why are you forcing this to be a string? It seemed like a good way to send an identifier. What do you suggest? Alex
[Qemu-devel] Re: [PATCH 13/13] blockdev: New -blockdev to define a host block device
On 06/02/2010 06:55 PM, Markus Armbruster wrote: * Like -drive, -blockdev ignores cache= silently when snapshot=on. Do we really want that? Yes, the changes are throw-away by definition. Might as well use cache=unsafe. +if (snapshot) { +/* always use write-back with snapshot */ +/* FIXME ignores explicit cache= *silently*; really want that? */ +flags = ~BDRV_O_CACHE_MASK; +flags |= (BDRV_O_SNAPSHOT | BDRV_O_CACHE_WB); +flags |= BDRV_O_SNAPSHOT; Cut and paste? Paolo
[Qemu-devel] Re: [PATCH 14/19] Add a query-argv command to QMP
On 06/07/2010 05:01 PM, Anthony Liguori wrote: On 06/07/2010 09:42 AM, Daniel P. Berrange wrote: Add a new QMP command called 'query-argv' to information about the command line arguments supported by the QEMU binary. This is intended to remove the need for apps to parse '-help' output. This is just as bad as parsing -help output IMHO. The problem with something like this is that it discourages people from using proper APIs to get at capabilities information. What about a query-qemuopts instead? This has a well-defined schema and, while it won't let you get all arguments, going forward libvirt is going to try and use more qemuopts options and only the bare minimum legacy options (-incoming, -S). Paolo
[Qemu-devel] Re: [PATCH 07/13] blockdev: Means to destroy blockdev only if made with drive_init()
Kevin Wolf kw...@redhat.com writes: Am 02.06.2010 18:55, schrieb Markus Armbruster: All drives are still made that way. They get destroyed along with their device. That's inappropriate for the alternative way to make blockdevs that will appear later in this series. These won't have a DriveInfo. blockdev_detach() destroys the blockdev only if it has a DriveInfo. blockdev_attach() does nothing for now. It'll be fleshed out later. Signed-off-by: Markus Armbruster arm...@redhat.com --- blockdev.c | 35 +++ blockdev.h |7 +++ 2 files changed, 42 insertions(+), 0 deletions(-) diff --git a/blockdev.c b/blockdev.c index ace74e4..f90d4fc 100644 --- a/blockdev.c +++ b/blockdev.c @@ -1,8 +1,12 @@ /* * QEMU host block devices * + * Copyright (C) 2010 Red Hat Inc. * Copyright (c) 2003-2008 Fabrice Bellard * + * Authors: + * Markus Armbruster arm...@redhat.com, + * * This work is licensed under the terms of the GNU GPL, version 2 or * later. See the COPYING file in the top-level directory. */ @@ -17,6 +21,37 @@ static QTAILQ_HEAD(drivelist, DriveInfo) drives = QTAILQ_HEAD_INITIALIZER(drives); +static int blockdev_del_dinfo(BlockDriverState *bs) +{ +DriveInfo *dinfo, *next_dinfo; +int res = 0; + +QTAILQ_FOREACH_SAFE(dinfo, drives, next, next_dinfo) { +if (dinfo-bdrv == bs) { +qemu_opts_del(dinfo-opts); +QTAILQ_REMOVE(drives, dinfo, next); +qemu_free(dinfo); +res = 1; +} +} + +return res; Can it happen that a BlockDriverState belongs to multiple DriveInfos? If no, why not returning in the loop? Wouldn't need a FOREACH_SAFE then, too. No, that shouldn't happen. Defensive coding, I don't want to leave dinfos with dangling dinfo-bdrv around. Maybe I should put an assert(!res) before the qemu_opts_del(). Or just forget about it, and simplify like you suggest. It's not worth respinning because of this one, but there were more comments and I think you'll send a v2 for the actual -blockdev option anyway once we have decided how to do it. I have applied patches 1 to 6 now, and I think I could safely go on until patch 9 if the minor improvements that were mentioned in comments are made. I'd ignore patch 10 to 13 for now. Is this what you would have expected or should I handle anything in a different way? No, that suits me fine. I definitely need to respin from part 8 on (commit message too terse).
[Qemu-devel] Re: [PULL] pci,virtio
On 06/10/2010 08:56 AM, Michael S. Tsirkin wrote: The following changes since commit 0ffbba357c557d9fa5caf9476878a4b9c155a614: migration-exec: fix OpenBSD build warning (2010-06-04 20:01:07 +) are available in the git repository at: git://git.kernel.org/pub/scm/linux/kernel/git/mst/qemu.git for_anthony Pulled. Thanks. Regards, Anthony Liguori Amit Shah (1): net: Fix hotplug with pci_add Michael S. Tsirkin (2): virtio-net: stop vhost backend on vmstop virtio-net: truncating packet hw/virtio-net.c | 26 ++ net.c |7 +-- 2 files changed, 19 insertions(+), 14 deletions(-)
Re: [Qemu-devel] [RFC PATCH 3/6] RAMBlock: Add a name field
* Alex Williamson (alex.william...@redhat.com) wrote: On Wed, 2010-06-09 at 13:18 +0100, Paul Brook wrote: to the identify the device. It should probably do this the same way that we identify the saved state for the device. Currently I think this is an arbitrary vmstate name/id, but I expect this to change to a qdev address (e.g. /i440FX-pcihost/pci.0/_addr_04.0). Ok, that seems fairly reasonable, so from a device pointer we can get something like /i440FX-pcihost/pci.0/_addr_04.0, then we can add something like :rom or :bar.0 to it via an extra string. In the fun game of what ifs... The cmdline starts w/ device A placed at pci bus addr 00:04.0 (so matched on source and target). The source does hotunplug of 04.0 and replaces it w/ new device. I think we need something that is more uniquely identifying the block. Not sure that device name is correct or a generation ID. thanks, -chris
Re: [Qemu-devel] [RFC PATCH 3/6] RAMBlock: Add a name field
to the identify the device. It should probably do this the same way that we identify the saved state for the device. Currently I think this is an arbitrary vmstate name/id, but I expect this to change to a qdev address (e.g. /i440FX-pcihost/pci.0/_addr_04.0). Ok, that seems fairly reasonable, so from a device pointer we can get something like /i440FX-pcihost/pci.0/_addr_04.0, then we can add something like :rom or :bar.0 to it via an extra string. In the fun game of what ifs... The cmdline starts w/ device A placed at pci bus addr 00:04.0 (so matched on source and target). The source does hotunplug of 04.0 and replaces it w/ new device. I think we need something that is more uniquely identifying the block. Not sure that device name is correct or a generation ID. You shouldn't be solving this problem for RAM blocks. You should be solving it for the device state. Paul
[Qemu-devel] Re: [PATCH 13/13] blockdev: New -blockdev to define a host block device
Paolo Bonzini pbonz...@redhat.com writes: On 06/02/2010 06:55 PM, Markus Armbruster wrote: * Like -drive, -blockdev ignores cache= silently when snapshot=on. Do we really want that? Yes, the changes are throw-away by definition. Might as well use cache=unsafe. I understand why that's the most sensible cache setting. But if the user explicitly asks for something else, I think we better give it to him, or tell him no. Ignoring him silently isn't nice. +if (snapshot) { +/* always use write-back with snapshot */ +/* FIXME ignores explicit cache= *silently*; really want that? */ +flags = ~BDRV_O_CACHE_MASK; +flags |= (BDRV_O_SNAPSHOT | BDRV_O_CACHE_WB); +flags |= BDRV_O_SNAPSHOT; Cut and paste? Pasto indeed, will fix. Thanks!
[Qemu-devel] Re: [PATCH 13/13] blockdev: New -blockdev to define a host block device
On 06/10/2010 06:32 PM, Markus Armbruster wrote: I understand why that's the most sensible cache setting. But if the user explicitly asks for something else, I think we better give it to him, or tell him no. Ignoring him silently isn't nice. Ah, it's clearer now... I guess one could use cache=something together with snapshot to do benchmarking. Actually the same changes in behavior (unsafe as default, but observe a non-default value) can be done to -drive ...,snapshot too. Maybe I'll give it a shot. Paolo
Re: [Qemu-devel] [PATCH 22/22] machine: introduce -machine-def option to define a machine via config
On Mon, Jun 07, 2010 at 07:50:14PM -0500, Anthony Liguori wrote: On 06/07/2010 06:52 PM, Anthony Liguori wrote: Since we have MachineCore and can represent a machine entirely via default options, we can introduce a new option that let's us dynamically register a machine based on those options. For instance, we could add the following to target-x86_64.conf: [machine-def] name = pc-0.11 desc = Standard PC acpi = on pci = on cpu = qemu64 max_cpus = 255 virtio-blk-pci.vectors = 0 virtio-serial-pci.max_nr_ports = 1 virtio-serial-pci.vectors = 0 ide-drive.ver = 0.11 scsi-disk.ver = 0.11 PCI.rombar = 0 What's really exciting, is that a user can then define their own machines that better suite their desires: [kvmpc] name = kvmpc accel = kvm|tcg ram_size = 512M max_cpus = 64 sockets = 16 default_drive = virtio I'd eventually like to move all PC compatibility machines to the default config but for now, I wanted to keep this simple. Signed-off-by: Anthony Liguorialigu...@us.ibm.com From the perspective of a tool like libvirt, I think there are a couple ways it could handle something like this and I think it's worth discussing the options. Assume we move all the compat machine definitions into a config file, since libvirt presumably uses -nodefconfig today, it could simply include it's own machine definitions for each qemu version based on the definitions we ship. That makes sure that the definition is always static for libvirt. Due to a screwup on my part, we don't currently use -nodefconfig but we should be. I had originally thought '-nodefaults' turned off all defaults, but I see it only does defaults hardware, but not default configs. Another option would be for libvirt to not use -nodefconfig, and instead to let the user's global configs be read. libvirt would then read the config file from the running qemu instance to sync it's state up. The tricky thing I'm seeing here is the scope of the stuff you can put in the configuration files. On the one had there are config options that effectively provide new capabilities to the QEMU binary eg new machine types, new CPU definitions. These don't cause any trouble, since that are a complete no-op unless you launch a guest that actually requests to make use of them eg by adding a -M mycustommachine or a -cpu mycustomCPUmodel flag. A '-M pc-010' guest will never be impacted by fact that you added some new machine types in the global config. On the other hand there are config options that immediately change the virtual hardware in all guests launched, eg if I edit the /etc/qemu/target-i386.conf and add [drive] if = ide file = foo.iso then every single guest gets a new piece of hardware, which is what we tried to avoid with the '-nodefaults' flag already. The later option is a bit more work up front but longer term, I think it addresses a couple things nicely. It provides a way for a user specified config to co-exist with libvirt. It also let's tools tweak power config options in a way that's compatible with libvirt. If libvirt can embed the qemu config description in its own XML, then there is no problem for libvirt to recreate the system on a different box even if the global configuration is different. If the global config is just adding new capabilities (machine types, cpu types, etc) I see no problem with having these loaded by default for any libvirt guest. When the global config can add extra hardware (eg drives) this becomes very tricky to re-concile, which is exactly why we had '-nodefaults' to turn off extra global hardware. We want all hardware libvirt knows about to be visible in the XML. eg, if the default config contained a [drive] section, you'd expect that to appear as a disk in libvirt XML. So if we parsed the default global config to sync it to the libvirt XML, when we come to launch the guest, we have even more fun figuring out which of the disks in the XML config needs a '-drive' on the ARGV, and which don't need any arg because they're in the global config. To make that practical we'd need to read the global config, turn it into libvirt XML, and then launch the guest with -nodefconfig and just use -drive as normal for everything. But then we loose useful things like new machine types cpu types :-( Is it practical to a way to separate the global config into two global configs. One config that is used to define extra capabilities (machine types, cpu types, etc) that on their own are guarenteed to never impact any existing guest config. One that is used to add default hardware (disks nics, etc) which clearly does impact every guest. Then, we could let the global capabilities config be in effect at all times, QEMU wouldn't even need a way to turn that off. The global hardware config could be enabled/disable as per the needs of the mgmt app, reconciled with their config as required. Daniel -- |:
[Qemu-devel] RFC v2: blockdev_add friends, brief rationale, QMP docs
v2: Cover protocols Split blockdev_change into media_insert and media_remove Option syntax list TODOs Rationale: Why new commands for block devices? == We want a clean separation between host part and guest part. Existing -drive and drive_add don't provide that; they were designed to specify both parts together. Moreover, drive_add is limited to adding virtio drives (with pci_add's help) and SCSI drives. We already have commands to specify the guest part: -device and device_add. Support for defining just a host part for use with -device and device_add was grafted onto -drive and drive_add (if=none), but it's a mess. Some parts are redundant, other parts are broken. For instance, unit, bus, index, addr are redundant: -device/device_add don't use them. They provide their own parameters to specify bus and bus-specific address. The checks whether rerror, werror, readonly, cyls, heads, secs are sane for a particular guest device model are broken. The checks are in the -drive code, which used to know what the guest device model supports, but can't with if=none. Moreover, -drive/drive_add have several flaws: * Many parameters set with -drive/drive_add silently revert to defaults on media change. * There are two ways to specify protocol, and both are flawed: you either use parameter format (then you can neither specify a non-default format, nor supply protocol options), or encode it in parameter file (yet another ad hoc mini-language, breaks filenames with ':'). * Behavior when format= is missing is insecure. My proposed solution is a new option -blockdev and monitor command blockdev_add. These specify only the host drive. Guest drive properties are left to -device/device_add. We keep -drive for backwards compatibility and command line convenience. Except we get rid of if=none (may need a grace period). New monitor command blockdev_del works regardless of how the host block device was created. New monitor commands media_insert, media_remove provide full control over the host part, unlike the existing change command. Summary of the host / guest split: -drive options host or guest? bus, unit, if, index, addr guest, already covered by qdev cyls, heads, secs, transguest, new qdev properties (but defaults depend on image) media guest FIXME snapshot, cache, aiohost, blockdev_add options file, formathost, blockdev_add options separate option for protocol format is just that, not protocol file is just a filename, no protocol rerror, werror host, guest device models will reject values they don't support serial guest, new qdev properties readonlyboth host guest, qdev will refuse to connect readonly host to read/write guest QMP command docs blockdev_add Add host block device. Arguments: - id: the host block device's ID, must be unique (json-string) - format: image format (json-string, optional) - Possible values: raw, qcow2, ... - protocol: image access protocol (json-object, optional) - Has a member type (json-string), and depending on its value additional members - For type = file, [...] - file: name of image file (json-string) - For type = nbd: - domain: address family (json-string, optional) - Possible values: inet (default), unix - file: name of socket file (json-string), only with domain = unix - host: host name (json-string), only with domain = inet - port: port (json-int), only with domain = inet - For type = blkdebug: - config: name of config file (json-string) - protocol: image access protocol (json-object), as above [...] - aio: host AIO (json-string, optional) - Possible values: threads (default), native - cache: host cache usage (json-string, optional) - Possible values: writethrough (default), writeback, unsafe, none - readonly: open image read-only (json-bool, optional, default false) - rerror: what to do on read error (json-string, optional) - Possible values: report (default), ignore, stop - werror: what to do on write error (json-string, optional) - Possible values: enospc (default), report, ignore, stop - snapshot: enable snapshot (json-bool, optional, default false) Example: - { execute: blockdev_add, arguments: { id: blk1, format: raw, protocol: { type: file, file: fedora.img } } } - { return: {} } - { execute: blockdev_add, arguments: { id: blk2, format: qcow2, protocol: { type: blkdebug, config: test.blkdebug,
Re: [Qemu-devel] [Bug 592028] [NEW] sparc32plus user test failed
On Thu, Jun 10, 2010 at 5:56 AM, kruglov.dima kruglov.d...@gmail.com wrote: Public bug reported: Hello, I try to execute on linux machine sparc binary (simple hello word application) using qemu-sparc32plus and get segfault.Before test I copy all libraries and headers (/usr/lib, /lib/, /usr/local/lib /usr/include /usr/local/include) from original solaris workstation to separate directory on linux machine: /usr/cross/sysroot User emulation between different operating systems is not supported. On Linux, the user emulator can execute Linux binaries from different CPU architectures or ABIs. So Linux qemu-sparc32plus can only execute Linux Sparc32plus binaries. It should be possible to make a user emulator for Sparc32plus Solaris binaries (for x86 Solaris) but there may be license issues. I also copy statically builded qemu binaries and hello_world app in /usr/cross/sysroot/bin and start app as: chroot /usr/cross/sysroot qemu-sparc32plus bin/hello_world but also I get segfault. As I see all necessary shared libs and interpreter (/usr/lib/ld.so.1) exists in apropriate directories: /usr/lib, /lib/, /usr/local/lib under new sysroot = /usr/cross/sysroot. I also try to run simple sparc32 app using qemu-sparc32plus but also get segfault. After that I try to run tests from linux-user-test-0.3 packet but they also fail with qemu-sparc32plus emulation. I try to perform such test on different type of systems (see further) and several version of qemu (builded from sources qemu-0.12.4 qemu-0.11.1 with configure make ). Probably I miss something in configuration or perform some wrong step with qemu-sparc32plus, could you please clarify is sparc32plus user mode emulation is sucessfuly exists in the latest versions of qemu? configuration of original Solaris sparc station where I build app: bash-3.00# uname -a SunOS fs650 5.10 Generic_137111-07 sun4us sparc FJSV,GPUZC-M bash-3.00# gcc --version gcc (GCC) 3.4.6 Copyright (C) 2006 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. bash-3.00# psrinfo -v Status of virtual processor 0 as of: 05/27/2010 12:23:06 on-line since 05/13/2010 18:40:47. The sparcv9 processor operates at 1889 MHz, and has a sparcv9 floating point processor. skipped 1 - 6. Status of virtual processor 7 as of: 05/27/2010 12:23:06 on-line since 05/13/2010 18:41:14. The sparcv9 processor operates at 1889 MHz, and has a sparcv9 floating point processor. source: bash-3.00# cat sample.c #include stdio.h int main(int argc, char* argv[]) { printf(Hello word!\n); return 0; } compilation string: bash-3.00# g++ -m32 -mcpu=v9 sample.c bash-3.00# file a.out a.out: ELF 32-bit MSB executable SPARC32PLUS Version 1, V8+ Required, dynamically linked, not stripped, no debugging information available configuration of 1st test machine - Debian Testing : /home/dima# uname -a Linux T291-2 2.6.32-trunk-686 #1 SMP Sun Jan 10 06:32:16 UTC 2010 i686 GNU/Linux /home/dima# cat /etc/issue Debian GNU/Linux squeeze/sid /home/dima# cat /proc/cpuinfo processor : 0 vendor_id : GenuineIntel cpu family : 6 model : 15 model name : Intel(R) Pentium(R) Dual CPU E2160 @ 1.80GHz stepping : 13 cpu MHz : 1799.624 cache size : 1024 KB physical id : 0 siblings : 2 core id : 0 cpu cores : 2 apicid : 0 initial apicid : 0 fdiv_bug : no hlt_bug : no f00f_bug : no coma_bug : no fpu : yes fpu_exception : yes cpuid level : 10 wp : yes flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe lm constant_tsc arch_perfmon pebs bts aperfmperf pni dtes64 monitor ds_cpl est tm2 ssse3 cx16 xtpr pdcm lahf_lm bogomips : 3599.24 clflush size : 64 cache_alignment : 64 address sizes : 36 bits physical, 48 bits virtual power management: processor : 1 ...skipped.. address sizes : 36 bits physical, 48 bits virtual power management: configuration of 2nd test machine - Debian Lenny stable: d...@debian:~/Desktop/linux-user-test-0.3$ uname -a Linux debian 2.6.26-1-686 #1 SMP Sat Jan 10 18:29:31 UTC 2009 i686 GNU/Linux d...@debian:~/Desktop/linux-user-test-0.3$ gcc --version gcc (Debian 4.3.2-1.1) 4.3.2 Copyright (C) 2008 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. cpu - intel q6600 configuration of 3rd test machine: vmware image of SLES 11 cat /etc/issue Welcome to SUSE Linux Enterprise Server 11 (x86_64) - Kernel \r (\l). cat
Re: [Qemu-devel] [RFC PATCH 0/2] Add USB Video Class device emulation.
On 06/08/10 09:34, Natalia Portillo wrote: Hi, This currently adds an emulated USB webcam compliant with USB Video Class Specification 1.0a. It only works on Linux guests and feeds the emulated device using a Video4Linux 2 host device, as long as it supports 320x240 MJPEG format. This is a Request for Comments as surely code needs some cleaning or style. You can see it working here: http://www.youtube.com/watch?v=fzGYvjZzx6E with Linux guest http://www.youtube.com/watch?v=_Yo9TWPDXCo with Windows XP Home guest To add the device use -device usb-uvc-webcam,device=path to v4l2 device Regards, Natalia Portillo Attempting to try out your patches, but it's failing with the following: usb-uvc: Init called usb-uvc: Trying to open /dev/video0 .usb-uvc: Device opened correctly. usb-uvc: Querying capabilities. usb-uvc: Device driver: uvcvideo usb-uvc: Device name: Laptop_Integrated_Webcam_0.3M usb-uvc: Device bus: usb-:00:1a.7-6 usb-uvc: Driver version: 0.1.0 usb-uvc: Device capabilities: 0x0401 usb-uvc: Enumerating video inputs. usb-uvc: Setting video input to index 0 usb-uvc: Video input correctly set. usb-uvc: Trying to set 320x240 MJPEG. qemu-system-x86_64: -device usb-uvc-webcam,device=/dev/video0: Invalid format. Using ekiga for example I know that 320x240 is ok. I know very little about the v4l (or video in general). Can you provide some pointers? Also, I tried a PWC camera which is not a V4L2_INPUT_TYPE_CAMERA and noticed that video_input_index is used uninitialized in usb_uvc_initfn David
Re: [Qemu-devel] [PATCH] qbus: fix memory leak in qbus_free()
Thanks, applied. On Thu, May 27, 2010 at 5:35 AM, Isaku Yamahata yamah...@valinux.co.jp wrote: BusState::name is allocated in qbus_create_inplace(). So it should be freed by qbus_free(). Signed-off-by: Isaku Yamahata yamah...@valinux.co.jp --- hw/qdev.c | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) diff --git a/hw/qdev.c b/hw/qdev.c index af17486..2845af5 100644 --- a/hw/qdev.c +++ b/hw/qdev.c @@ -700,6 +700,7 @@ void qbus_free(BusState *bus) QLIST_REMOVE(bus, sibling); bus-parent-num_child_bus--; } + qemu_free((void*)bus-name); if (bus-qdev_allocated) { qemu_free(bus); } -- 1.6.6.1
Re: [Qemu-devel] [PATCH] multiboot: compilation fix with DEBUG_MULTIBOOT enabled.
Thanks, applied. On Thu, May 27, 2010 at 5:37 AM, Isaku Yamahata yamah...@valinux.co.jp wrote: This patch fixes the following compilation errors in multiboot.c when DEBUG_MULTIBOOT is defined. Use TARGET_FMT_plx instead of %x for target_phys_addr_t. CC i386-softmmu/multiboot.o cc1: warnings being treated as errors qemu/hw/multiboot.c: In function 'mb_add_mod': qemu/hw/multiboot.c:121: error: format '%08x' expects type 'unsigned int', but argument 4 has type 'target_phys_addr_t' qemu/hw/multiboot.c:121: error: format '%08x' expects type 'unsigned int', but argument 5 has type 'target_phys_addr_t' qemu/hw/multiboot.c: In function 'load_multiboot': qemu/hw/multiboot.c:279: error: format '%#x' expects type 'unsigned int', but argument 5 has type 'target_phys_addr_t' qemu/hw/multiboot.c:307: error: format '%x' expects type 'unsigned int', but argument 3 has type 'target_phys_addr_t' qemu/hw/multiboot.c:308: error: format '%x' expects type 'unsigned int', but argument 3 has type 'target_phys_addr_t' make[1]: *** [multiboot.o] Error 1 Signed-off-by: Isaku Yamahata yamah...@valinux.co.jp --- hw/multiboot.c | 9 + 1 files changed, 5 insertions(+), 4 deletions(-) diff --git a/hw/multiboot.c b/hw/multiboot.c index a1b665c..dc980e6 100644 --- a/hw/multiboot.c +++ b/hw/multiboot.c @@ -118,7 +118,8 @@ static void mb_add_mod(MultibootState *s, stl_p(p + MB_MOD_END, end); stl_p(p + MB_MOD_CMDLINE, cmdline_phys); - mb_debug(mod%02d: %08x - %08x\n, s-mb_mods_count, start, end); + mb_debug(mod%02d: TARGET_FMT_plx - TARGET_FMT_plx\n, + s-mb_mods_count, start, end); s-mb_mods_count++; } @@ -276,7 +277,7 @@ int load_multiboot(void *fw_cfg, mb_add_mod(mbs, mbs.mb_buf_phys + offs, mbs.mb_buf_phys + offs + mb_mod_length, c); - mb_debug(mod_start: %p\nmod_end: %p\n cmdline: %#x\n, + mb_debug(mod_start: %p\nmod_end: %p\n cmdline: TARGET_FMT_plx\n, (char *)mbs.mb_buf + offs, (char *)mbs.mb_buf + offs + mb_mod_length, c); initrd_filename = next_initrd+1; @@ -304,8 +305,8 @@ int load_multiboot(void *fw_cfg, stl_p(bootinfo + MBI_MMAP_ADDR, ADDR_E820_MAP); mb_debug(multiboot: mh_entry_addr = %#x\n, mh_entry_addr); - mb_debug( mb_buf_phys = %x\n, mbs.mb_buf_phys); - mb_debug( mod_start = %x\n, mbs.mb_buf_phys + mbs.offset_mods); + mb_debug( mb_buf_phys = TARGET_FMT_plx\n, mbs.mb_buf_phys); + mb_debug( mod_start = TARGET_FMT_plx\n, mbs.mb_buf_phys + mbs.offset_mods); mb_debug( mb_mods_count = %d\n, mbs.mb_mods_count); /* save bootinfo off the stack */ -- 1.6.6.1 -- yamahata
Re: [Qemu-devel] [PATCH] vga-isa-mm: remove one #ifdef CONFIG_BOCHS_VBE.
Thanks, applied. On Thu, May 27, 2010 at 5:37 AM, Isaku Yamahata yamah...@valinux.co.jp wrote: remove one #ifdef CONFIG_BOCHS_VBE. Call vga_init_vbe() instead. Signed-off-by: Isaku Yamahata yamah...@valinux.co.jp --- hw/vga-isa-mm.c | 6 +- 1 files changed, 1 insertions(+), 5 deletions(-) diff --git a/hw/vga-isa-mm.c b/hw/vga-isa-mm.c index 2faefa5..8e31e36 100644 --- a/hw/vga-isa-mm.c +++ b/hw/vga-isa-mm.c @@ -121,10 +121,6 @@ int isa_vga_mm_init(target_phys_addr_t vram_base, s-vga.ds = graphic_console_init(s-vga.update, s-vga.invalidate, s-vga.screen_dump, s-vga.text_update, s); -#ifdef CONFIG_BOCHS_VBE - /* XXX: use optimized standard vga accesses */ - cpu_register_physical_memory(VBE_DISPI_LFB_PHYSICAL_ADDRESS, - VGA_RAM_SIZE, s-vga.vram_offset); -#endif + vga_init_vbe(s-vga); return 0; } -- 1.6.6.1
Re: [Qemu-devel] [RFC PATCH 1/2] USB Video Class device emulation.
Hi Blue, You're right on all things. I'll check CODING_STYLE and do the things. Thanks a lot.
Re: [Qemu-devel] [RFC PATCH 0/2] Add USB Video Class device emulation.
Hi David, Attempting to try out your patches, but it's failing with the following: usb-uvc: Init called usb-uvc: Trying to open /dev/video0 .usb-uvc: Device opened correctly. usb-uvc: Querying capabilities. usb-uvc: Device driver: uvcvideo usb-uvc: Device name: Laptop_Integrated_Webcam_0.3M usb-uvc: Device bus: usb-:00:1a.7-6 usb-uvc: Driver version: 0.1.0 usb-uvc: Device capabilities: 0x0401 usb-uvc: Enumerating video inputs. usb-uvc: Setting video input to index 0 usb-uvc: Video input correctly set. usb-uvc: Trying to set 320x240 MJPEG. qemu-system-x86_64: -device usb-uvc-webcam,device=/dev/video0: Invalid format. As for now only cameras that allow MJPEG format will work. Check your camera specifications (lsusb -v works if your real camera is UVC, check driver's source otherwise). Cameras with RAW frames (YUYV and NV12 formats) do not work, yet. I'm on it. Also, I tried a PWC camera which is not a V4L2_INPUT_TYPE_CAMERA and noticed that video_input_index is used uninitialized in usb_uvc_initfn It's a webcam? Could you give me more information? Manufacturer, model, linux's module name. All webcams SHOULD (and MUST) implement V4L2_INPUT_TYPE_CAMERA. Not the same for video cameras or capture devices (PAL/NTSC, DVB/ATSC). Regards, Natalia Portillo
Re: [Qemu-devel] [PATCH] main: allocate gui_timer only once.
Thanks, applied. On Thu, May 27, 2010 at 5:38 AM, Isaku Yamahata yamah...@valinux.co.jp wrote: fix memory leak. there is no need to allocate more than one gui_timer. Signed-off-by: Isaku Yamahata yamah...@valinux.co.jp --- vl.c | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) diff --git a/vl.c b/vl.c index 417554f..22cdf43 100644 --- a/vl.c +++ b/vl.c @@ -3794,6 +3794,7 @@ int main(int argc, char **argv, char **envp) if (dcl-dpy_refresh != NULL) { ds-gui_timer = qemu_new_timer(rt_clock, gui_update, ds); qemu_mod_timer(ds-gui_timer, qemu_get_clock(rt_clock)); + break; } dcl = dcl-next; } -- 1.6.6.1
[Qemu-devel] [Bug 546458] Re: kernel NULL pointer in -virtual (-server) kernel
Just to confirm -- still present, 10.04 LTS up-to-date, UEC images also 10.04 up-to-date. A 2,000 run creating KVM instances under Eucalyptus shows 6 occurences of this OOPS: WARNING:INSTANCE i-3EDE078A:[ 129.998256] BUG: unable to handle kernel NULL pointer dereference at 0358 WARNING:INSTANCE i-406C06CE:[ 89.245841] BUG: unable to handle kernel NULL pointer dereference at 0358 WARNING:INSTANCE i-411D0851:[ 158.375444] BUG: unable to handle kernel NULL pointer dereference at 0358 WARNING:INSTANCE i-4E1C08D4:[ 196.089623] BUG: unable to handle kernel NULL pointer dereference at 0358 WARNING:INSTANCE i-54800A8D:[ 67.825483] BUG: unable to handle kernel NULL pointer dereference at 0358 WARNING:INSTANCE i-5E970AA3:[ 87.610866] BUG: unable to handle kernel NULL pointer dereference at 0358 -- kernel NULL pointer in -virtual (-server) kernel https://bugs.launchpad.net/bugs/546458 You received this bug notification because you are a member of qemu- devel-ml, which is subscribed to QEMU. Status in QEMU: Invalid Status in “linux” package in Ubuntu: Triaged Status in “qemu-kvm” package in Ubuntu: Confirmed Status in “linux” package in Fedora: Unknown Bug description: When stress testing eucalyptus we have run into this oops inside VMs [ 82.907577] BUG: unable to handle kernel NULL pointer dereference at 0358^M [ 82.908842] IP: [813982e8] sym_int_sir+0x2a8/0x750^M [ 82.909773] PGD 0 ^M [ 82.910110] Thread overran stack, or stack corrupted^M [ 82.910870] Oops: [#1] SMP ^M [ 82.911407] last sysfs file: /sys/devices/virtual/block/ram9/uevent^M We launched 18 instances, 2 of them failed this way. The instances run with 192M of memory. With 6 VM launches on a single node all at the same time the host is under heavy load. This occurred in 20100323 lucid x86_64 uec-image instance. ProblemType: Bug AlsaDevices: Error: command ['ls', '-l', '/dev/snd/'] failed with exit code 2: ls: cannot access /dev/snd/: No such file or directory AplayDevices: Error: [Errno 2] No such file or directory Architecture: amd64 ArecordDevices: Error: [Errno 2] No such file or directory CurrentDmesg: Date: Wed Mar 24 22:06:32 2010 DistroRelease: Ubuntu 10.04 Frequency: Once a day. Lsusb: Bus 001 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub MachineType: Bochs Bochs Package: linux-image-2.6.32-16-virtual 2.6.32-16.25 PciMultimedia: ProcCmdLine: root=/dev/sda1 console=ttyS0 ProcEnviron: LANG=en_US.UTF-8 SHELL=/bin/bash ProcVersionSignature: User Name 2.6.32-16.25-server Regression: No Reproducible: No SourcePackage: linux TestedUpstream: No Uname: Linux 2.6.32-16-server x86_64 dmi.bios.date: 01/01/2007 dmi.bios.vendor: Bochs dmi.bios.version: Bochs dmi.chassis.type: 1 dmi.chassis.vendor: Bochs dmi.modalias: dmi:bvnBochs:bvrBochs:bd01/01/2007:svnBochs:pnBochs:pvr:cvnBochs:ct1:cvr: dmi.product.name: Bochs dmi.sys.vendor: Bochs
Re: [Qemu-devel] [RFC PATCH 0/2] Add USB Video Class device emulation.
On 06/10/10 12:26, Natalia Portillo wrote: Hi David, Attempting to try out your patches, but it's failing with the following: usb-uvc: Init called usb-uvc: Trying to open /dev/video0 .usb-uvc: Device opened correctly. usb-uvc: Querying capabilities. usb-uvc: Device driver: uvcvideo usb-uvc: Device name: Laptop_Integrated_Webcam_0.3M usb-uvc: Device bus: usb-:00:1a.7-6 usb-uvc: Driver version: 0.1.0 usb-uvc: Device capabilities: 0x0401 usb-uvc: Enumerating video inputs. usb-uvc: Setting video input to index 0 usb-uvc: Video input correctly set. usb-uvc: Trying to set 320x240 MJPEG. qemu-system-x86_64: -device usb-uvc-webcam,device=/dev/video0: Invalid format. As for now only cameras that allow MJPEG format will work. Check your camera specifications (lsusb -v works if your real camera is UVC, check driver's source otherwise). Cameras with RAW frames (YUYV and NV12 formats) do not work, yet. I'm on it. Trying to guess the relevant descriptors: VideoStreaming Interface Descriptor: bLength50 bDescriptorType36 bDescriptorSubtype 5 (FRAME_UNCOMPRESSED) bFrameIndex 3 bmCapabilities 0x00 Still image unsupported wWidth320 wHeight 240 dwMinBitRate 768000 dwMaxBitRate 4608000 dwMaxVideoFrameBufferSize 153600 dwDefaultFrameInterval 33 bFrameIntervalType 6 dwFrameInterval( 0)33 dwFrameInterval( 1)40 dwFrameInterval( 2)50 dwFrameInterval( 3)66 dwFrameInterval( 4) 100 dwFrameInterval( 5) 200 VideoStreaming Interface Descriptor: bLength 6 bDescriptorType36 bDescriptorSubtype 13 (COLORFORMAT) bColorPrimaries 1 (BT.709,sRGB) bTransferCharacteristics1 (BT.709) bMatrixCoefficients 4 (SMPTE 170M (BT.601)) Also, I tried a PWC camera which is not a V4L2_INPUT_TYPE_CAMERA and noticed that video_input_index is used uninitialized in usb_uvc_initfn It's a webcam? Could you give me more information? Manufacturer, model, linux's module name. usb 7-1: new full speed USB device using uhci_hcd and address 3 usb 7-1: New USB device found, idVendor=046d, idProduct=08b6 usb 7-1: New USB device strings: Mfr=0, Product=0, SerialNumber=0 pwc: Logitech/Cisco VT Camera webcam detected. David All webcams SHOULD (and MUST) implement V4L2_INPUT_TYPE_CAMERA. Not the same for video cameras or capture devices (PAL/NTSC, DVB/ATSC). Regards, Natalia Portillo
Re: [Qemu-devel] [RFC PATCH 0/2] Add USB Video Class device emulation.
Hi, Trying to guess the relevant descriptors: VideoStreaming Interface Descriptor: bLength50 bDescriptorType36 bDescriptorSubtype 5 (FRAME_UNCOMPRESSED) bFrameIndex 3 bmCapabilities 0x00 Still image unsupported wWidth320 wHeight 240 dwMinBitRate 768000 dwMaxBitRate 4608000 dwMaxVideoFrameBufferSize 153600 dwDefaultFrameInterval 33 bFrameIntervalType 6 dwFrameInterval( 0)33 dwFrameInterval( 1)40 dwFrameInterval( 2)50 dwFrameInterval( 3)66 dwFrameInterval( 4) 100 dwFrameInterval( 5) 200 VideoStreaming Interface Descriptor: bLength 6 bDescriptorType36 bDescriptorSubtype 13 (COLORFORMAT) bColorPrimaries 1 (BT.709,sRGB) bTransferCharacteristics1 (BT.709) bMatrixCoefficients 4 (SMPTE 170M (BT.601)) Unless there is any FRAME_MJPEG in the descriptor, the camera is as now, unsupported yet. I'm working on supported cameras FRAME_UNCOMPRESSED. Also, I tried a PWC camera which is not a V4L2_INPUT_TYPE_CAMERA and noticed that video_input_index is used uninitialized in usb_uvc_initfn It's a webcam? Could you give me more information? Manufacturer, model, linux's module name. usb 7-1: new full speed USB device using uhci_hcd and address 3 usb 7-1: New USB device found, idVendor=046d, idProduct=08b6 usb 7-1: New USB device strings: Mfr=0, Product=0, SerialNumber=0 pwc: Logitech/Cisco VT Camera webcam detected. The only thing I'm able to found about it is that the driver is Video4Linux 1.0 not 2.0. Do you have manufacturer and model? Do you have idea of that input type v4l2 defines for it? May you give me SSH access to a machine with that cam installed to test and implement? Regards, Natalia Portillo
[Qemu-devel] Re: [BUG] tcg-i386: regression after merge 64-bit
On Thu, Jun 10, 2010 at 04:51:24PM +0200, Thomas Monjalon wrote: My guest Linux/PPC cannot boot on my host x86 since this commit: 5d8a4f8f: tcg-i386: Merge 64-bit generation This is the output: zImage starting: loaded at 0x40 (sp: 0x004e5eb0) inflate returned -3 msg: invalid literal/lengths set Sorry, I concentrated on testing x86_64, because I was waiting for the breakage on that side, I should also have tested i386. That should be fixed in the git tree now. -- Aurelien Jarno GPG: 1024D/F1BCDB73 aurel...@aurel32.net http://www.aurel32.net
[Qemu-devel] [PATCH-V6 01/10] virtio-9p: Introduces an option to specify the security model.
The new option is: -fsdev fstype,id=myid,path=/share_path/,security_model=[mapped|passthrough] -virtfs fstype,path=/share_path/,security_model=[mapped|passthrough],mnt_tag=tag In the case of mapped security model, files are created with QEMU user credentials and the client-user's credentials are saved in extended attributes. Whereas in the case of passthrough security model, files on the filesystem are directly created with client-user's credentials. Signed-off-by: Venkateswararao Jujjuri jv...@linux.vnet.ibm.com --- fsdev/qemu-fsdev.c |9 - fsdev/qemu-fsdev.h |1 + hw/virtio-9p.c |9 + qemu-config.c |6 ++ qemu-options.hx| 15 +++ vl.c | 18 +++--- 6 files changed, 50 insertions(+), 8 deletions(-) diff --git a/fsdev/qemu-fsdev.c b/fsdev/qemu-fsdev.c index 813e1f7..ad69b0e 100644 --- a/fsdev/qemu-fsdev.c +++ b/fsdev/qemu-fsdev.c @@ -34,7 +34,7 @@ int qemu_fsdev_add(QemuOpts *opts) return -1; } - for (i = 0; i ARRAY_SIZE(FsTypes); i++) { +for (i = 0; i ARRAY_SIZE(FsTypes); i++) { if (strcmp(FsTypes[i].name, qemu_opt_get(opts, fstype)) == 0) { break; } @@ -46,10 +46,17 @@ int qemu_fsdev_add(QemuOpts *opts) return -1; } +if (qemu_opt_get(opts, security_model) == NULL) { +fprintf(stderr, fsdev: No security_model specified.\n); +return -1; +} + fsle = qemu_malloc(sizeof(*fsle)); fsle-fse.fsdev_id = qemu_strdup(qemu_opts_id(opts)); fsle-fse.path = qemu_strdup(qemu_opt_get(opts, path)); +fsle-fse.security_model = qemu_strdup(qemu_opt_get(opts, +security_model)); fsle-fse.ops = FsTypes[i].ops; QTAILQ_INSERT_TAIL(fstype_entries, fsle, next); diff --git a/fsdev/qemu-fsdev.h b/fsdev/qemu-fsdev.h index b50fbe0..6c27881 100644 --- a/fsdev/qemu-fsdev.h +++ b/fsdev/qemu-fsdev.h @@ -40,6 +40,7 @@ typedef struct FsTypeTable { typedef struct FsTypeEntry { char *fsdev_id; char *path; +char *security_model; FileOperations *ops; } FsTypeEntry; diff --git a/hw/virtio-9p.c b/hw/virtio-9p.c index 038bb39..2530488 100644 --- a/hw/virtio-9p.c +++ b/hw/virtio-9p.c @@ -2253,6 +2253,15 @@ VirtIODevice *virtio_9p_init(DeviceState *dev, V9fsConf *conf) exit(1); } +if (!strcmp(fse-security_model, passthrough) +!strcmp(fse-security_model, mapped)) { +/* user haven't specified a correct security option */ +fprintf(stderr, one of the following must be specified as the +security option:\n\t security_model=passthrough \n\t +security_model=mapped\n); +return NULL; +} + if (lstat(fse-path, stat)) { fprintf(stderr, share path %s does not exist\n, fse-path); exit(1); diff --git a/qemu-config.c b/qemu-config.c index 5a4e61b..95abe61 100644 --- a/qemu-config.c +++ b/qemu-config.c @@ -163,6 +163,9 @@ QemuOptsList qemu_fsdev_opts = { }, { .name = path, .type = QEMU_OPT_STRING, +}, { +.name = security_model, +.type = QEMU_OPT_STRING, }, { /*End of list */ } }, @@ -184,6 +187,9 @@ QemuOptsList qemu_virtfs_opts = { }, { .name = mount_tag, .type = QEMU_OPT_STRING, +}, { +.name = security_model, +.type = QEMU_OPT_STRING, }, { /*End of list */ } diff --git a/qemu-options.hx b/qemu-options.hx index a6928b7..d1d2272 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -486,7 +486,7 @@ ETEXI DEFHEADING(File system options:) DEF(fsdev, HAS_ARG, QEMU_OPTION_fsdev, --fsdev local,id=id,path=path\n, +-fsdev local,id=id,path=path,security_model=[mapped|passthrough]\n, QEMU_ARCH_ALL) STEXI @@ -502,7 +502,7 @@ The specific Fstype will determine the applicable options. Options to each backend are described below. -...@item -fsdev local ,i...@var{id} ,pa...@var{path} +...@item -fsdev local ,i...@var{id} ,pa...@var{path} ,security_mod...@var{security_model} Create a file-system-device for local-filesystem. @@ -510,6 +510,9 @@ Create a file-system-device for local-filesystem. @option{path} specifies the path to be exported. @option{path} is required. +...@option{security_model} specifies the security model to be followed. +...@option{security_model} is required. + @end table ETEXI #endif @@ -518,7 +521,7 @@ ETEXI DEFHEADING(Virtual File system pass-through options:) DEF(virtfs, HAS_ARG, QEMU_OPTION_virtfs, --virtfs local,path=path,mount_tag=tag\n, +-virtfs local,path=path,mount_tag=tag,security_model=[mapped|passthrough]\n, QEMU_ARCH_ALL) STEXI @@ -534,7 +537,7 @@ The specific Fstype will determine the applicable options. Options to each backend are described below. -...@item -virtfs local ,pa...@var{path} ,mount_t...@var{mount_tag} +...@item -virtfs
[Qemu-devel] [PATCH 5/8] net: vde: introduce info_dict
Signed-off-by: Miguel Di Ciurcio Filho miguel.fi...@gmail.com --- net/vde.c |8 1 files changed, 8 insertions(+), 0 deletions(-) diff --git a/net/vde.c b/net/vde.c index 0b46fa6..0fe7c09 100644 --- a/net/vde.c +++ b/net/vde.c @@ -31,6 +31,9 @@ #include qemu-char.h #include qemu-common.h #include qemu-option.h +#include qdict.h +#include qstring.h +#include qint.h #include sysemu.h typedef struct VDEState { @@ -102,6 +105,11 @@ static int net_vde_init(VLANState *vlan, const char *model, snprintf(nc-info_str, sizeof(nc-info_str), sock=%s,fd=%d, sock, vde_datafd(vde)); +assert(nc-info_dict == NULL); +nc-info_dict = qdict_new(); +qdict_put(nc-info_dict, sock, qstring_from_str(sock)); +qdict_put(nc-info_dict, fd, qint_from_int(vde_datafd(vde))); + s = DO_UPCAST(VDEState, nc, nc); s-vde = vde; -- 1.7.1
[Qemu-devel] [RFC v2] [PATCH 1/3] Export tdb_hash()
For now, I simply export tdb_hash() from qdict.h for use by tracing framework. Luiz suggested renaming and exporting it from a location other than qdict.h . Would qemu-common.h be a better place? Signed-off-by: Prerna Saxena pre...@linux.vnet.ibm.com --- qdict.c |2 +- qdict.h |2 ++ 2 files changed, 3 insertions(+), 1 deletions(-) diff --git a/qdict.c b/qdict.c index 175bc17..5261872 100644 --- a/qdict.c +++ b/qdict.c @@ -56,7 +56,7 @@ QDict *qobject_to_qdict(const QObject *obj) * tdb_hash(): based on the hash agorithm from gdbm, via tdb * (from module-init-tools) */ -static unsigned int tdb_hash(const char *name) +unsigned int tdb_hash(const char *name) { unsigned value;/* Used to compute the hash value. */ unsigned i; /* Used to cycle through random values. */ diff --git a/qdict.h b/qdict.h index 5e5902c..d221c18 100644 --- a/qdict.h +++ b/qdict.h @@ -59,4 +59,6 @@ int64_t qdict_get_try_int(const QDict *qdict, const char *key, int64_t err_value); const char *qdict_get_try_str(const QDict *qdict, const char *key); +/* Export tdb_hash() for use by trace framework */ +unsigned int tdb_hash(const char *name); #endif /* QDICT_H */ -- 1.6.2.5 -- Prerna Saxena Linux Technology Centre, IBM Systems and Technology Lab, Bangalore, India
[Qemu-devel] [PATCH-V6 05/10] virtio-9p: Implemented Security model for lstat and fstat
Signed-off-by: Venkateswararao Jujjuri jv...@linux.vnet.ibm.com --- hw/virtio-9p-local.c | 62 ++--- 1 files changed, 58 insertions(+), 4 deletions(-) diff --git a/hw/virtio-9p-local.c b/hw/virtio-9p-local.c index 1d7cb32..74c81a6 100644 --- a/hw/virtio-9p-local.c +++ b/hw/virtio-9p-local.c @@ -27,9 +27,38 @@ static const char *rpath(FsContext *ctx, const char *path) return buffer; } -static int local_lstat(FsContext *ctx, const char *path, struct stat *stbuf) + +static int local_lstat(FsContext *fs_ctx, const char *path, struct stat *stbuf) { -return lstat(rpath(ctx, path), stbuf); +int err; +err = lstat(rpath(fs_ctx, path), stbuf); +if (err) { +return err; +} +if (fs_ctx-fs_sm == SM_MAPPED) { +/* Actual credentials are part of extended attrs */ +uid_t tmp_uid; +gid_t tmp_gid; +mode_t tmp_mode; +dev_t tmp_dev; +if (getxattr(rpath(fs_ctx, path), user.virtfs.uid, tmp_uid, +sizeof(uid_t)) 0) { +stbuf-st_uid = tmp_uid; +} +if (getxattr(rpath(fs_ctx, path), user.virtfs.gid, tmp_gid, +sizeof(gid_t)) 0) { +stbuf-st_gid = tmp_gid; +} +if (getxattr(rpath(fs_ctx, path), user.virtfs.mode, tmp_mode, +sizeof(mode_t)) 0) { +stbuf-st_mode = tmp_mode; +} +if (getxattr(rpath(fs_ctx, path), user.virtfs.rdev, tmp_dev, +sizeof(dev_t)) 0) { +stbuf-st_rdev = tmp_dev; +} +} +return err; } static int local_set_xattr(const char *path, FsCred *credp) @@ -171,9 +200,34 @@ static int local_mkdir(FsContext *ctx, const char *path, mode_t mode) return mkdir(rpath(ctx, path), mode); } -static int local_fstat(FsContext *ctx, int fd, struct stat *stbuf) +static int local_fstat(FsContext *fs_ctx, int fd, struct stat *stbuf) { -return fstat(fd, stbuf); +int err; +err = fstat(fd, stbuf); +if (err) { +return err; +} +if (fs_ctx-fs_sm == SM_MAPPED) { +/* Actual credentials are part of extended attrs */ +uid_t tmp_uid; +gid_t tmp_gid; +mode_t tmp_mode; +dev_t tmp_dev; + +if (fgetxattr(fd, user.virtfs.uid, tmp_uid, sizeof(uid_t)) 0) { +stbuf-st_uid = tmp_uid; +} +if (fgetxattr(fd, user.virtfs.gid, tmp_gid, sizeof(gid_t)) 0) { +stbuf-st_gid = tmp_gid; +} +if (fgetxattr(fd, user.virtfs.mode, tmp_mode, sizeof(mode_t)) 0) { +stbuf-st_mode = tmp_mode; +} +if (fgetxattr(fd, user.virtfs.rdev, tmp_dev, sizeof(dev_t)) 0) { +stbuf-st_rdev = tmp_dev; +} +} +return err; } static int local_open2(FsContext *ctx, const char *path, int flags, mode_t mode) -- 1.6.5.2
[Qemu-devel] [PATCH-V6 07/10] virtio-9p: Security model for mkdir
Signed-off-by: Venkateswararao Jujjuri jv...@linux.vnet.ibm.com --- hw/file-op-9p.h |2 +- hw/virtio-9p-local.c | 35 +-- hw/virtio-9p.c | 12 +--- 3 files changed, 43 insertions(+), 6 deletions(-) diff --git a/hw/file-op-9p.h b/hw/file-op-9p.h index b345189..12223de 100644 --- a/hw/file-op-9p.h +++ b/hw/file-op-9p.h @@ -70,7 +70,7 @@ typedef struct FileOperations ssize_t (*readv)(FsContext *, int, const struct iovec *, int); ssize_t (*writev)(FsContext *, int, const struct iovec *, int); off_t (*lseek)(FsContext *, int, off_t, int); -int (*mkdir)(FsContext *, const char *, mode_t); +int (*mkdir)(FsContext *, const char *, FsCred *); int (*fstat)(FsContext *, int, struct stat *); int (*rename)(FsContext *, const char *, const char *); int (*truncate)(FsContext *, const char *, off_t); diff --git a/hw/virtio-9p-local.c b/hw/virtio-9p-local.c index bb5140e..e99eff9 100644 --- a/hw/virtio-9p-local.c +++ b/hw/virtio-9p-local.c @@ -207,9 +207,40 @@ static int local_mksock(FsContext *ctx2, const char *path) return 0; } -static int local_mkdir(FsContext *ctx, const char *path, mode_t mode) +static int local_mkdir(FsContext *fs_ctx, const char *path, FsCred *credp) { -return mkdir(rpath(ctx, path), mode); +int err = -1; +int serrno = 0; + +/* Determine the security model */ +if (fs_ctx-fs_sm == SM_MAPPED) { +err = mkdir(rpath(fs_ctx, path), SM_LOCAL_DIR_MODE_BITS); +if (err == -1) { +return err; +} +credp-fc_mode = credp-fc_mode|S_IFDIR; +err = local_set_xattr(rpath(fs_ctx, path), credp); +if (err == -1) { +serrno = errno; +goto err_end; +} +} else if (fs_ctx-fs_sm == SM_PASSTHROUGH) { +err = mkdir(rpath(fs_ctx, path), credp-fc_mode); +if (err == -1) { +return err; +} +err = local_post_create_passthrough(fs_ctx, path, credp); +if (err == -1) { +serrno = errno; +goto err_end; +} +} +return err; + +err_end: +remove(rpath(fs_ctx, path)); +errno = serrno; +return err; } static int local_fstat(FsContext *fs_ctx, int fd, struct stat *stbuf) diff --git a/hw/virtio-9p.c b/hw/virtio-9p.c index 49a3065..005f725 100644 --- a/hw/virtio-9p.c +++ b/hw/virtio-9p.c @@ -170,9 +170,15 @@ static int v9fs_do_mksock(V9fsState *s, V9fsString *path) return s-ops-mksock(s-ctx, path-data); } -static int v9fs_do_mkdir(V9fsState *s, V9fsString *path, mode_t mode) +static int v9fs_do_mkdir(V9fsState *s, V9fsCreateState *vs) { -return s-ops-mkdir(s-ctx, path-data, mode); +FsCred cred; + +cred_init(cred); +cred.fc_uid = vs-fidp-uid; +cred.fc_mode = vs-perm 0777; + +return s-ops-mkdir(s-ctx, vs-fullname.data, cred); } static int v9fs_do_fstat(V9fsState *s, int fd, struct stat *stbuf) @@ -1776,7 +1782,7 @@ static void v9fs_create_post_lstat(V9fsState *s, V9fsCreateState *vs, int err) } if (vs-perm P9_STAT_MODE_DIR) { -err = v9fs_do_mkdir(s, vs-fullname, vs-perm 0777); +err = v9fs_do_mkdir(s, vs); v9fs_create_post_mkdir(s, vs, err); } else if (vs-perm P9_STAT_MODE_SYMLINK) { err = v9fs_do_symlink(s, vs-extension, vs-fullname); -- 1.6.5.2
[Qemu-devel] [PATCH-V6 02/10] virtio-9p: Make infrastructure for the new security model.
This patch adds required infrastructure for the new security model. Signed-off-by: Venkateswararao Jujjuri jv...@linux.vnet.ibm.com --- hw/file-op-9p.h | 20 +++ hw/virtio-9p-local.c | 65 +++--- hw/virtio-9p.c | 23 - 3 files changed, 66 insertions(+), 42 deletions(-) diff --git a/hw/file-op-9p.h b/hw/file-op-9p.h index f84767f..307bd1e 100644 --- a/hw/file-op-9p.h +++ b/hw/file-op-9p.h @@ -18,13 +18,33 @@ #include utime.h #include sys/stat.h #include sys/uio.h +#include sys/vfs.h +#define SM_LOCAL_MODE_BITS0600 +#define SM_LOCAL_DIR_MODE_BITS0700 + +typedef enum +{ +SM_PASSTHROUGH = 1, /* uid/gid set on fileserver files */ +SM_MAPPED, /* uid/gid part of xattr */ +} SecModel; + +typedef struct FsCred +{ +uid_t fc_uid; +gid_t fc_gid; +mode_t fc_mode; +dev_t fc_rdev; +} FsCred; typedef struct FsContext { char *fs_root; +SecModel fs_sm; uid_t uid; } FsContext; +extern void cred_init(FsCred *); + typedef struct FileOperations { int (*lstat)(FsContext *, const char *, struct stat *); diff --git a/hw/virtio-9p-local.c b/hw/virtio-9p-local.c index 1afb731..056b4ba 100644 --- a/hw/virtio-9p-local.c +++ b/hw/virtio-9p-local.c @@ -17,6 +17,7 @@ #include grp.h #include sys/socket.h #include sys/un.h +#include attr/xattr.h static const char *rpath(FsContext *ctx, const char *path) { @@ -31,45 +32,37 @@ static int local_lstat(FsContext *ctx, const char *path, struct stat *stbuf) return lstat(rpath(ctx, path), stbuf); } -static int local_setuid(FsContext *ctx, uid_t uid) +static int local_set_xattr(const char *path, FsCred *credp) { -struct passwd *pw; -gid_t groups[33]; -int ngroups; -static uid_t cur_uid = -1; - -if (cur_uid == uid) { -return 0; -} - -if (setreuid(0, 0)) { -return -1; -} - -pw = getpwuid(uid); -if (pw == NULL) { -return -1; -} - -ngroups = 33; -if (getgrouplist(pw-pw_name, pw-pw_gid, groups, ngroups) == -1) { -return -1; +int err; +if (credp-fc_uid != -1) { +err = setxattr(path, user.virtfs.uid, credp-fc_uid, sizeof(uid_t), +0); +if (err) { +return err; +} } - -if (setgroups(ngroups, groups)) { -return -1; +if (credp-fc_gid != -1) { +err = setxattr(path, user.virtfs.gid, credp-fc_gid, sizeof(gid_t), +0); +if (err) { +return err; +} } - -if (setregid(-1, pw-pw_gid)) { -return -1; +if (credp-fc_mode != -1) { +err = setxattr(path, user.virtfs.mode, credp-fc_mode, +sizeof(mode_t), 0); +if (err) { +return err; +} } - -if (setreuid(-1, uid)) { -return -1; +if (credp-fc_rdev != -1) { +err = setxattr(path, user.virtfs.rdev, credp-fc_rdev, +sizeof(dev_t), 0); +if (err) { +return err; +} } - -cur_uid = uid; - return 0; } @@ -183,6 +176,7 @@ static int local_open2(FsContext *ctx, const char *path, int flags, mode_t mode) return open(rpath(ctx, path), flags, mode); } + static int local_symlink(FsContext *ctx, const char *oldpath, const char *newpath) { @@ -259,12 +253,13 @@ static int local_remove(FsContext *ctx, const char *path) static int local_fsync(FsContext *ctx, int fd) { +if (0) /* Just to supress the warning. Will be removed in next patch. */ +(void)local_set_xattr(NULL, NULL); return fsync(fd); } FileOperations local_ops = { .lstat = local_lstat, -.setuid = local_setuid, .readlink = local_readlink, .close = local_close, .closedir = local_closedir, diff --git a/hw/virtio-9p.c b/hw/virtio-9p.c index 2530488..a7ba4b6 100644 --- a/hw/virtio-9p.c +++ b/hw/virtio-9p.c @@ -67,14 +67,17 @@ static int omode_to_uflags(int8_t mode) return ret; } -static int v9fs_do_lstat(V9fsState *s, V9fsString *path, struct stat *stbuf) +void cred_init(FsCred *credp) { -return s-ops-lstat(s-ctx, path-data, stbuf); +credp-fc_uid = -1; +credp-fc_gid = -1; +credp-fc_mode = -1; +credp-fc_rdev = -1; } -static int v9fs_do_setuid(V9fsState *s, uid_t uid) +static int v9fs_do_lstat(V9fsState *s, V9fsString *path, struct stat *stbuf) { -return s-ops-setuid(s-ctx, uid); +return s-ops-lstat(s-ctx, path-data, stbuf); } static ssize_t v9fs_do_readlink(V9fsState *s, V9fsString *path, V9fsString *buf) @@ -348,7 +351,6 @@ static V9fsFidState *lookup_fid(V9fsState *s, int32_t fid) for (f = s-fid_list; f; f = f-next) { if (f-fid == fid) { -v9fs_do_setuid(s, f-uid); return f; } } @@ -2253,8 +2255,15 @@ VirtIODevice *virtio_9p_init(DeviceState *dev, V9fsConf *conf) exit(1); } -if
[Qemu-devel] Re: [BUG] tcg-i386: regression after merge 64-bit
On 06/10/2010 11:55 AM, Aurelien Jarno wrote: On Thu, Jun 10, 2010 at 04:51:24PM +0200, Thomas Monjalon wrote: My guest Linux/PPC cannot boot on my host x86 since this commit: 5d8a4f8f: tcg-i386: Merge 64-bit generation This is the output: zImage starting: loaded at 0x40 (sp: 0x004e5eb0) inflate returned -3 msg: invalid literal/lengths set Sorry, I concentrated on testing x86_64, because I was waiting for the breakage on that side, I should also have tested i386. That should be fixed in the git tree now. Sorry about that. Merge error after we dropped the bits that performed ext8u with AND for i386, reg = 4. r~
[Qemu-devel] [PATCH] [virtio-9p] Define and implement TSYMLINK for 9P2000.L
This patch implements creating a symlink for TSYMLINK request and responds with RSYMLINK. In the case of error, we return RERROR. SYNOPSIS size[4] Tsymlink tag[2] fid[4] name[s] symtgt[s] gid[4] size[4] Rsymlink tag[2] qid[13] DESCRIPTION Create a symbolic link named 'name' pointing to 'symtgt'. gid represents the effective group id of the caller. The permissions of a symbolic link are irrelevant hence it is omitted from the protocol. Signed-off-by: Venkateswararao Jujjuri jv...@linux.vnet.ibm.com --- hw/virtio-9p-debug.c | 11 +++ hw/virtio-9p.c | 78 ++ hw/virtio-9p.h | 14 + 3 files changed, 97 insertions(+), 6 deletions(-) diff --git a/hw/virtio-9p-debug.c b/hw/virtio-9p-debug.c index 18ef485..dbe7b24 100644 --- a/hw/virtio-9p-debug.c +++ b/hw/virtio-9p-debug.c @@ -462,6 +462,17 @@ void pprint_pdu(V9fsPDU *pdu) pprint_qid(pdu, 1, offset, qid); pprint_int32(pdu, 1, offset, , iounit); break; +case P9_TSYMLINK: + fprintf(llogfile, TSYMLINK: (); + pprint_int32(pdu, 0, offset, fid); + pprint_str(pdu, 0, offset, , name); + pprint_str(pdu, 0, offset, , symname); + pprint_int32(pdu, 0, offset, , gid); + break; +case P9_RSYMLINK: + fprintf(llogfile, RSYMLINK: (); + pprint_qid(pdu, 1, offset, qid); + break; case P9_TREAD: fprintf(llogfile, TREAD: (); pprint_int32(pdu, 0, offset, fid); diff --git a/hw/virtio-9p.c b/hw/virtio-9p.c index b5960cb..955283e 100644 --- a/hw/virtio-9p.c +++ b/hw/virtio-9p.c @@ -200,15 +200,16 @@ static int v9fs_do_open2(V9fsState *s, V9fsCreateState *vs) return s-ops-open2(s-ctx, vs-fullname.data, flags, cred); } -static int v9fs_do_symlink(V9fsState *s, V9fsCreateState *vs) +static int v9fs_do_symlink(V9fsState *s, V9fsFidState *fidp, +const char *oldpath, const char *newpath, gid_t gid) { FsCred cred; cred_init(cred); -cred.fc_uid = vs-fidp-uid; -cred.fc_mode = vs-perm | 0777; +cred.fc_uid = fidp-uid; +cred.fc_gid = gid; +cred.fc_mode = 0777; -return s-ops-symlink(s-ctx, vs-extension.data, vs-fullname.data, -cred); +return s-ops-symlink(s-ctx, oldpath, newpath, cred); } static int v9fs_do_link(V9fsState *s, V9fsString *oldpath, V9fsString *newpath) @@ -2149,7 +2150,8 @@ static void v9fs_create_post_lstat(V9fsState *s, V9fsCreateState *vs, int err) err = v9fs_do_mkdir(s, vs); v9fs_create_post_mkdir(s, vs, err); } else if (vs-perm P9_STAT_MODE_SYMLINK) { -err = v9fs_do_symlink(s, vs); +err = v9fs_do_symlink(s, vs-fidp, vs-extension.data, +vs-fullname.data, -1); v9fs_create_post_perms(s, vs, err); } else if (vs-perm P9_STAT_MODE_LINK) { int32_t nfid = atoi(vs-extension.data); @@ -2238,6 +2240,69 @@ out: qemu_free(vs); } +static void v9fs_post_symlink(V9fsState *s, V9fsSymlinkState *vs, int err) +{ +if (err == 0) { +stat_to_qid(vs-stbuf, vs-qid); +vs-offset += pdu_marshal(vs-pdu, vs-offset, Q, vs-qid); +err = vs-offset; +} else { +err = -errno; +} +complete_pdu(s, vs-pdu, err); +v9fs_string_free(vs-name); +v9fs_string_free(vs-symname); +v9fs_string_free(vs-fullname); +qemu_free(vs); +} + +static void v9fs_symlink_post_do_symlink(V9fsState *s, V9fsSymlinkState *vs, +int err) +{ +if (err) { +goto out; +} +err = v9fs_do_lstat(s, vs-fullname, vs-stbuf); +out: +v9fs_post_symlink(s, vs, err); +} + +static void v9fs_symlink(V9fsState *s, V9fsPDU *pdu) +{ +int32_t dfid; +V9fsSymlinkState *vs; +int err = 0; +gid_t gid; + +vs = qemu_malloc(sizeof(*vs)); +vs-pdu = pdu; +vs-offset = 7; + +v9fs_string_init(vs-fullname); + +pdu_unmarshal(vs-pdu, vs-offset, dssd, dfid, vs-name, +vs-symname, gid); + +vs-dfidp = lookup_fid(s, dfid); +if (vs-dfidp == NULL) { +err = -EINVAL; +goto out; +} + +v9fs_string_sprintf(vs-fullname, %s/%s, vs-dfidp-path.data, +vs-name.data); +err = v9fs_do_symlink(s, vs-dfidp, vs-symname.data, +vs-fullname.data, gid); +v9fs_symlink_post_do_symlink(s, vs, err); +return; + +out: +complete_pdu(s, vs-pdu, err); +v9fs_string_free(vs-name); +v9fs_string_free(vs-symname); +qemu_free(vs); +} + static void v9fs_flush(V9fsState *s, V9fsPDU *pdu) { /* A nop call with no return */ @@ -2656,6 +2721,7 @@ static pdu_handler_t *pdu_handlers[] = { #endif [P9_TFLUSH] = v9fs_flush, [P9_TLINK] = v9fs_link, +[P9_TSYMLINK] = v9fs_symlink, [P9_TCREATE] = v9fs_create, [P9_TWRITE] = v9fs_write, [P9_TWSTAT] = v9fs_wstat, diff --git a/hw/virtio-9p.h b/hw/virtio-9p.h index 52136bd..7203626 100644 --- a/hw/virtio-9p.h +++ b/hw/virtio-9p.h @@ -15,6 +15,8 @@ enum {
[Qemu-devel] [PATCH-V6 09/10] virtio-9p: Implement Security model for mknod
Mapped mode stores extended attributes in the user space of the extended attributes. Given that the user space extended attributes are available to regular files only, special files are created as regular files on the fileserver and appropriate mode bits are added to the extended attributes. This method presents all special files and symlinks as regular files on the fileserver while they are represented as special files on the guest mount. On Host/Fileserver: -rw---. 1 virfsuid virtfsgid 0 2010-05-11 09:36 afifo -rw---. 1 virfsuid virtfsgid 0 2010-05-11 09:32 blkdev -rw---. 1 virfsuid virtfsgid 0 2010-05-11 09:33 chardev On Guest/Client: prw-r--r-- 1 guestuser guestuser 0 2010-05-11 12:36 afifo brw-r--r-- 1 guestuser guestuser 0, 0 2010-05-11 12:32 blkdev crw-r--r-- 1 guestuser guestuser 4, 5 2010-05-11 12:33 chardev In the passthrough securit model, specifal files are directly created on the fileserver. But the user credential Signed-off-by: Venkateswararao Jujjuri jv...@linux.vnet.ibm.com --- hw/file-op-9p.h |2 +- hw/virtio-9p-local.c | 34 -- hw/virtio-9p.c | 14 ++ 3 files changed, 43 insertions(+), 7 deletions(-) diff --git a/hw/file-op-9p.h b/hw/file-op-9p.h index 0808630..5bc61b5 100644 --- a/hw/file-op-9p.h +++ b/hw/file-op-9p.h @@ -51,7 +51,7 @@ typedef struct FileOperations ssize_t (*readlink)(FsContext *, const char *, char *, size_t); int (*chmod)(FsContext *, const char *, FsCred *); int (*chown)(FsContext *, const char *, FsCred *); -int (*mknod)(FsContext *, const char *, mode_t, dev_t); +int (*mknod)(FsContext *, const char *, FsCred *); int (*mksock)(FsContext *, const char *); int (*utime)(FsContext *, const char *, const struct utimbuf *); int (*remove)(FsContext *, const char *); diff --git a/hw/virtio-9p-local.c b/hw/virtio-9p-local.c index 711f2b5..791a8ba 100644 --- a/hw/virtio-9p-local.c +++ b/hw/virtio-9p-local.c @@ -195,9 +195,39 @@ static int local_chmod(FsContext *fs_ctx, const char *path, FsCred *credp) return -1; } -static int local_mknod(FsContext *ctx, const char *path, mode_t mode, dev_t dev) +static int local_mknod(FsContext *fs_ctx, const char *path, FsCred *credp) { -return mknod(rpath(ctx, path), mode, dev); +int err = -1; +int serrno = 0; + +/* Determine the security model */ +if (fs_ctx-fs_sm == SM_MAPPED) { +err = mknod(rpath(fs_ctx, path), SM_LOCAL_MODE_BITS|S_IFREG, 0); +if (err == -1) { +return err; +} +local_set_xattr(rpath(fs_ctx, path), credp); +if (err == -1) { +serrno = errno; +goto err_end; +} +} else if (fs_ctx-fs_sm == SM_PASSTHROUGH) { +err = mknod(rpath(fs_ctx, path), credp-fc_mode, credp-fc_rdev); +if (err == -1) { +return err; +} +err = local_post_create_passthrough(fs_ctx, path, credp); +if (err == -1) { +serrno = errno; +goto err_end; +} +} +return err; + +err_end: +remove(rpath(fs_ctx, path)); +errno = serrno; +return err; } static int local_mksock(FsContext *ctx2, const char *path) diff --git a/hw/virtio-9p.c b/hw/virtio-9p.c index 1a25e96..d276db3 100644 --- a/hw/virtio-9p.c +++ b/hw/virtio-9p.c @@ -160,9 +160,15 @@ static int v9fs_do_chmod(V9fsState *s, V9fsString *path, mode_t mode) return s-ops-chmod(s-ctx, path-data, cred); } -static int v9fs_do_mknod(V9fsState *s, V9fsString *path, mode_t mode, dev_t dev) +static int v9fs_do_mknod(V9fsState *s, V9fsCreateState *vs, mode_t mode, +dev_t dev) { -return s-ops-mknod(s-ctx, path-data, mode, dev); +FsCred cred; +cred_init(cred); +cred.fc_uid = vs-fidp-uid; +cred.fc_mode = mode; +cred.fc_rdev = dev; +return s-ops-mknod(s-ctx, vs-fullname.data, cred); } static int v9fs_do_mksock(V9fsState *s, V9fsString *path) @@ -1825,10 +1831,10 @@ static void v9fs_create_post_lstat(V9fsState *s, V9fsCreateState *vs, int err) } nmode |= vs-perm 0777; -err = v9fs_do_mknod(s, vs-fullname, nmode, makedev(major, minor)); +err = v9fs_do_mknod(s, vs, nmode, makedev(major, minor)); v9fs_create_post_perms(s, vs, err); } else if (vs-perm P9_STAT_MODE_NAMED_PIPE) { -err = v9fs_do_mknod(s, vs-fullname, S_IFIFO | (vs-mode 0777), 0); +err = v9fs_do_mknod(s, vs, S_IFIFO | (vs-perm 0777), 0); v9fs_post_create(s, vs, err); } else if (vs-perm P9_STAT_MODE_SOCKET) { err = v9fs_do_mksock(s, vs-fullname); -- 1.6.5.2
[Qemu-devel] [PATCH v2 0/3] Add virtio-blk support to persistent-storage rules
This patch series provides updates to udev to allow the creation symlinks for virtio-blk devices, specifically disk/by-id and disk/by-path. This is most useful for virtio-blk devices that do not yet have any filesystem for which a UUID can be extracted (disk/by-uuid). These patches (save the path_id fix) require an updated[1] qemu (on the host) and virtio-blk (in the guest) to generate the by-id path; however if the guest or host qemu isn't capable then no action is taken. Changes since v1: - Switch ID_VIRTIO_SERIAL to ID_SERIAL - Switched IOCTL_CMD to use numeric value - Add ID_SERIAL_SHORT - Update persistent-storage rules to use ID_SERIAL for virtioblk_id 1. http://lists.gnu.org/archive/html/qemu-devel/2010-03/msg01869.html Signed-off-by: Ryan Harper ry...@us.ibm.com
[Qemu-devel] [PATCH 7/8] net: slirp: introduce info_dict
Signed-off-by: Miguel Di Ciurcio Filho miguel.fi...@gmail.com --- net/slirp.c | 17 - 1 files changed, 16 insertions(+), 1 deletions(-) diff --git a/net/slirp.c b/net/slirp.c index b41c60a..5735009 100644 --- a/net/slirp.c +++ b/net/slirp.c @@ -32,6 +32,10 @@ #include monitor.h #include sysemu.h #include qemu_socket.h +#include qdict.h +#include qbool.h +#include qstring.h +#include qjson.h #include slirp/libslirp.h static int get_str_sep(char *buf, int buf_size, const char **pp, int sep) @@ -243,6 +247,12 @@ static int net_slirp_init(VLANState *vlan, const char *model, snprintf(nc-info_str, sizeof(nc-info_str), net=%s, restricted=%c, inet_ntoa(net), restricted ? 'y' : 'n'); +assert(nc-info_dict == NULL); +nc-info_dict = qobject_to_qdict(qobject_from_jsonf({'net': %s,\ +'host': %s, 'dhcp': %s, 'dns': %s }, inet_ntoa(net), inet_ntoa(host), +inet_ntoa(dhcp), inet_ntoa(dns))); +qdict_put(nc-info_dict, restricted, qbool_from_int(restricted)); + s = DO_UPCAST(SlirpState, nc, nc); s-slirp = slirp_init(restricted, net, mask, host, vhostname, @@ -265,8 +275,13 @@ static int net_slirp_init(VLANState *vlan, const char *model, smb_export = legacy_smb_export; } if (smb_export) { -if (slirp_smb(s, smb_export, smbsrv) 0) +if (slirp_smb(s, smb_export, smbsrv) 0) { goto error; +} else { +qdict_put(nc-info_dict, smb, qstring_from_str(smb_export)); +qdict_put(nc-info_dict, smbserver, +qstring_from_str(inet_ntoa(smbsrv))); +} } #endif -- 1.7.1
[Qemu-devel] [RFC v2] [PATCH 3/3] Toggle tracepoint state
This patch adds support for dynamically enabling/disabling of tracepoints. Monitor commands added : 1) info tracepoints : to view all available tracepoints and their state. 2) tracepoint NAME on|off : to enable/disable data logging from a given tracepoint. Eg, tracepoint paio_submit off disables logging of data when paio_submit is hit. For now it is a simple comparison, I'm exploring optimizations that can be employed to make this faster. Signed-off-by: Prerna Saxena pre...@linux.vnet.ibm.com --- monitor.c | 16 +++- qemu-monitor.hx | 18 ++ simpletrace.c | 53 + tracetool | 30 ++ vl.c|6 ++ 5 files changed, 118 insertions(+), 5 deletions(-) diff --git a/monitor.c b/monitor.c index 8b60830..e4c7bef 100644 --- a/monitor.c +++ b/monitor.c @@ -547,7 +547,14 @@ static void do_commit(Monitor *mon, const QDict *qdict) bdrv_commit(dinfo-bdrv); } } - +#ifdef CONFIG_SIMPLE_TRACE +static void do_change_tracepoint_state(Monitor *mon, const QDict *qdict) +{ +const char *tp_name = qdict_get_str(qdict, name); +bool new_state = qdict_get_bool(qdict, option); +change_tracepoint_state(tp_name, new_state); +} +#endif static void user_monitor_complete(void *opaque, QObject *ret_data) { MonitorCompletionData *data = (MonitorCompletionData *)opaque; @@ -2791,6 +2798,13 @@ static const mon_cmd_t info_cmds[] = { .help = show current contents of trace buffer, .mhandler.info = do_info_trace, }, +{ +.name = tracepoints, +.args_type = , +.params = , +.help = show available tracepoints their state, +.mhandler.info = do_info_all_tracepoints, +}, #endif { .name = NULL, diff --git a/qemu-monitor.hx b/qemu-monitor.hx index 766c30f..8540b8f 100644 --- a/qemu-monitor.hx +++ b/qemu-monitor.hx @@ -117,6 +117,8 @@ show device tree #ifdef CONFIG_SIMPLE_TRACE @item info trace show contents of trace buffer +...@item info tracepoints +show available tracepoints and their state #endif @end table ETEXI @@ -225,6 +227,22 @@ STEXI @item logfile @var{filename} @findex logfile Output logs to @var{filename}. +#ifdef CONFIG_SIMPLE_TRACE +ETEXI + +{ +.name = tracepoint, +.args_type = name:s,option:b, +.params = name on|off, +.help = changes status of a specific tracepoint, +.mhandler.cmd = do_change_tracepoint_state, +}, + +STEXI +...@item tracepoint +...@findex tracepoint +changes status of a tracepoint +#endif ETEXI { diff --git a/simpletrace.c b/simpletrace.c index 00df45a..b601d24 100644 --- a/simpletrace.c +++ b/simpletrace.c @@ -3,6 +3,12 @@ #include trace.h typedef struct { +char *tp_name; +bool state; +unsigned int hash; +} Tracepoint; + +typedef struct { unsigned long event; unsigned long x1; unsigned long x2; @@ -18,10 +24,24 @@ enum { static TraceRecord trace_buf[TRACE_BUF_LEN]; static unsigned int trace_idx; static FILE *trace_fp; +static Tracepoint trace_list[NR_TRACEPOINTS]; + +void init_tracepoint(const char *tname, TraceEvent tevent) { +if (!tname || tevent NR_TRACEPOINTS) +return; + +trace_list[tevent].tp_name = (char*)qemu_malloc(strlen(tname)+1); +strncpy(trace_list[tevent].tp_name, tname, strlen(tname)); +trace_list[tevent].hash = tdb_hash(tname); +trace_list[tevent].state = 1; /* Enable all by default */ +return; +} static void trace(TraceEvent event, unsigned long x1, unsigned long x2, unsigned long x3, unsigned long x4, unsigned long x5) { +if (!trace_list[event].state) +return; TraceRecord *rec = trace_buf[trace_idx]; rec-event = event; rec-x1 = x1; @@ -74,3 +94,36 @@ void do_info_trace(Monitor *mon) trace_buf[i].event, trace_buf[i].x1, trace_buf[i].x2, trace_buf[i].x3, trace_buf[i].x4, trace_buf[i].x5); } + +void do_info_all_tracepoints(Monitor *mon) +{ +unsigned int i; +for (i=0; iNR_TRACEPOINTS; i++) +monitor_printf(mon, %s [Event ID %u] : state %u\n, +trace_list[i].tp_name, i, trace_list[i].state); +} + +static int find_tracepoint_by_name(const char *tname) +{ +unsigned int i, name_hash; + +if (!tname) +return -1; + +name_hash = tdb_hash(tname); + +for (i=0; iNR_TRACEPOINTS; i++) +if (trace_list[i].hash == name_hash + !strncmp(trace_list[i].tp_name, tname, strlen(tname))) +return i; +return -1; /* indicates end of list reached without a
[Qemu-devel] [PATCH 4/8] net: tap/tap-win32: introduce info_dict
Signed-off-by: Miguel Di Ciurcio Filho miguel.fi...@gmail.com --- net/tap-win32.c |6 ++ net/tap.c | 20 2 files changed, 26 insertions(+), 0 deletions(-) diff --git a/net/tap-win32.c b/net/tap-win32.c index 74348da..3833592 100644 --- a/net/tap-win32.c +++ b/net/tap-win32.c @@ -32,6 +32,8 @@ #include net.h #include sysemu.h #include qemu-error.h +#include qdict.h +#include qstring.h #include stdio.h #include windows.h #include winioctl.h @@ -693,6 +695,10 @@ static int tap_win32_init(VLANState *vlan, const char *model, snprintf(s-nc.info_str, sizeof(s-nc.info_str), tap: ifname=%s, ifname); +nc-info_dict = qdict_new() + +qdict_put(nc-info_dict, ifname, qstring_from_str(ifname)); + s-handle = handle; qemu_add_wait_object(s-handle-tap_semaphore, tap_win32_send, s); diff --git a/net/tap.c b/net/tap.c index 0147dab..30ed3da 100644 --- a/net/tap.c +++ b/net/tap.c @@ -39,6 +39,9 @@ #include qemu-char.h #include qemu-common.h #include qemu-error.h +#include qjson.h +#include qint.h +#include qbool.h #include net/tap-linux.h @@ -448,8 +451,13 @@ int net_init_tap(QemuOpts *opts, Monitor *mon, const char *name, VLANState *vlan if (qemu_opt_get(opts, fd)) { snprintf(s-nc.info_str, sizeof(s-nc.info_str), fd=%d, fd); +assert(s-nc.info_dict == NULL); + +s-nc.info_dict = qdict_new(); +qdict_put(s-nc.info_dict, fd, qint_from_int(fd)); } else { const char *ifname, *script, *downscript; +QObject *obj; ifname = qemu_opt_get(opts, ifname); script = qemu_opt_get(opts, script); @@ -459,10 +467,19 @@ int net_init_tap(QemuOpts *opts, Monitor *mon, const char *name, VLANState *vlan ifname=%s,script=%s,downscript=%s, ifname, script, downscript); +obj = qobject_from_jsonf({ 'ifname': %s, \ +'script': %s,'downscript': %s }, +ifname, script, downscript); + +assert(s-nc.info_dict == NULL); +s-nc.info_dict = qobject_to_qdict(obj); + if (strcmp(downscript, no) != 0) { snprintf(s-down_script, sizeof(s-down_script), %s, downscript); snprintf(s-down_script_arg, sizeof(s-down_script_arg), %s, ifname); } + + } if (qemu_opt_get_bool(opts, vhost, !!qemu_opt_get(opts, vhostfd))) { @@ -481,6 +498,9 @@ int net_init_tap(QemuOpts *opts, Monitor *mon, const char *name, VLANState *vlan error_report(vhost-net requested but could not be initialized); return -1; } +qdict_put(s-nc.info_dict, vhost, qbool_from_int(1)); +qdict_put(s-nc.info_dict, vhostfd, qint_from_int(vhostfd)); + } else if (qemu_opt_get(opts, vhostfd)) { error_report(vhostfd= is not valid without vhost); return -1; -- 1.7.1
[Qemu-devel] [PATCH-V2] [virtio-9p] Implement TLINK for 9P2000.L
Create a Hardlink. SYNOPSIS size[4] Tlink tag[2] dfid[4] oldfid[4] newpath[s] size[4] Rlink tag[2] DESCRIPTION Create a link 'newpath' in directory pointed by dfid linking to oldfid path. Signed-off-by: Venkateswararao Jujjuri jv...@linux.vnet.ibm.com --- hw/virtio-9p-debug.c |9 + hw/virtio-9p.c | 38 ++ hw/virtio-9p.h |2 ++ 3 files changed, 49 insertions(+), 0 deletions(-) diff --git a/hw/virtio-9p-debug.c b/hw/virtio-9p-debug.c index 6072491..18ef485 100644 --- a/hw/virtio-9p-debug.c +++ b/hw/virtio-9p-debug.c @@ -495,6 +495,15 @@ void pprint_pdu(V9fsPDU *pdu) case P9_RCLUNK: fprintf(llogfile, RCLUNK: (); break; +case P9_TLINK: +fprintf(llogfile, TLINK: (); +pprint_int32(pdu, 0, offset, fid); +pprint_str(pdu, 0, offset, , oldpath); +pprint_str(pdu, 0, offset, , newpath); +break; +case P9_RLINK: +fprintf(llogfile, RLINK: (); +break; case P9_TREMOVE: fprintf(llogfile, TREMOVE: (); pprint_int32(pdu, 0, offset, fid); diff --git a/hw/virtio-9p.c b/hw/virtio-9p.c index b0c4b12..b5960cb 100644 --- a/hw/virtio-9p.c +++ b/hw/virtio-9p.c @@ -2244,6 +2244,43 @@ static void v9fs_flush(V9fsState *s, V9fsPDU *pdu) complete_pdu(s, pdu, 7); } +static void v9fs_link(V9fsState *s, V9fsPDU *pdu) +{ +int32_t dfid, oldfid; +V9fsFidState *dfidp, *oldfidp; +V9fsString name, fullname; +size_t offset = 7; +int err = 0; + +v9fs_string_init(fullname); + +pdu_unmarshal(pdu, offset, dds, dfid, oldfid, name); + +dfidp = lookup_fid(s, dfid); +if (dfidp == NULL) { +err = -errno; +goto out; +} + +oldfidp = lookup_fid(s, oldfid); +if (oldfidp == NULL) { +err = -errno; +goto out; +} + +v9fs_string_sprintf(fullname, %s/%s, dfidp-path.data, name.data); +err = offset; +err = v9fs_do_link(s, oldfidp-path, fullname); +if (err) { +err = -errno; +} +v9fs_string_free(fullname); + +out: +v9fs_string_free(name); +complete_pdu(s, pdu, err); +} + static void v9fs_remove_post_remove(V9fsState *s, V9fsRemoveState *vs, int err) { @@ -2618,6 +2655,7 @@ static pdu_handler_t *pdu_handlers[] = { [P9_TAUTH] = v9fs_auth, #endif [P9_TFLUSH] = v9fs_flush, +[P9_TLINK] = v9fs_link, [P9_TCREATE] = v9fs_create, [P9_TWRITE] = v9fs_write, [P9_TWSTAT] = v9fs_wstat, diff --git a/hw/virtio-9p.h b/hw/virtio-9p.h index 5f8dca9..52136bd 100644 --- a/hw/virtio-9p.h +++ b/hw/virtio-9p.h @@ -21,6 +21,8 @@ enum { P9_RSETATTR, P9_TREADDIR = 40, P9_RREADDIR, +P9_TLINK = 70, +P9_RLINK, P9_TVERSION = 100, P9_RVERSION, P9_TAUTH = 102, -- 1.6.5.2